ref: 6bf0a834bc0b9a179a63eab0f603db232227da42
dir: /unix.c/
#include "otfsys.h" #include <stdarg.h> #include <time.h> 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; } #define ERRMAX 512 static char errstr[ERRMAX]; 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); strcpy(errstr, buf); }