ref: 17c753b3afc975b1e710c7f5c150f01e5f283b3c
dir: /unix/otfsys.c/
#include "otfsys.h" #include <stdarg.h> #include <time.h> #define ERRMAX 512 static char errstr[ERRMAX]; char * otferrstr(void) { return errstr; } void werrstr(char *fmt, ...) { va_list a; char buf[ERRMAX]; int n; va_start(a, fmt); n = vsnprintf(buf, sizeof(buf), fmt, a); va_end(a); if(n >= 2 && buf[n-2] == '%' && buf[n-1] == 'r') snprintf(buf+n-2, sizeof(buf)-n+2, "%s", errstr); snprintf(errstr, sizeof(errstr), "%s", buf); } char * fmttime(long long v) { static char buf[32]; time_t t = v; struct tm *tm; tm = gmtime(&t); strftime(buf, sizeof(buf), "%c", tm); return buf; }