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 utfecpy(buf, buf+nerr, strerror(errno)); 27 } 28 29 int 30 errstr(char *buf, uint nerr) 31 { 32 if(errno == Magic) 33 utfecpy(buf, buf+nerr, errstring); 34 else 35 oserrstr(buf, nerr); 36 return 1; 37 } 38