/* Crash and burn. */ #include static const char *fut_progname; static void panic(int eval, const char *fmt, ...) { va_list ap; va_start(ap, fmt); fprintf(stderr, "%s: ", fut_progname); vfprintf(stderr, fmt, ap); va_end(ap); exit(eval); } /* For generating arbitrary-sized error messages. It is the callers responsibility to free the buffer at some point. */ static char* msgprintf(const char *s, ...) { va_list vl; va_start(vl, s); size_t needed = 1 + vsnprintf(NULL, 0, s, vl); char *buffer = malloc(needed); va_start(vl, s); /* Must re-init. */ vsnprintf(buffer, needed, s, vl); return buffer; }