1 #include "lib9.h" 2 3 #include <errno.h> 4 5 static char errstring[ERRMAX]; 6 7 enum 8 { 9 Magic = 0xffffff 10 }; 11 12 void 13 werrstr(char *fmt, ...) 14 { 15 va_list arg; 16 17 va_start(arg, fmt); 18 vseprint(errstring, errstring+sizeof(errstring), fmt, arg); 19 va_end(arg); 20 errno = Magic; 21 } 22 23 void 24 oserrstr(char *buf, uint nerr) 25 { 26 char *s; 27 28 if(errno != EINTR) 29 s = strerror(errno); 30 else 31 s = "interrupted"; 32 utfecpy(buf, buf+nerr, s); 33 } 34 35 int 36 errstr(char *buf, uint nerr) 37 { 38 if(errno == Magic) 39 utfecpy(buf, buf+nerr, errstring); 40 else 41 oserrstr(buf, nerr); 42 return 1; 43 } 44