shithub: fnt

ref: 103afe43213f6cb1e6969ffa72fe0dab1db1c45e
dir: /unix/otfsys.c/

View raw version
#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);
}