1 #define _GNU_SOURCE /* asprintf */
10 /* Do we use syslog for messages or stderr? */
13 /* Do we want to silently drop all warnings? */
16 /* Do we want informative messages as well as errors? */
19 void message(const char *prefix
, const char *fmt
, va_list *arglist
)
24 ret
= vasprintf(&buf
, fmt
, *arglist
);
26 ret
= asprintf(&buf2
, "%s%s", prefix
, buf
);
29 buf2
= "FATAL: Out of memory.\n";
32 syslog(LOG_NOTICE
, "%s", buf2
);
34 fprintf(stderr
, "%s", buf2
);
43 void warn(const char *fmt
, ...)
46 va_start(arglist
, fmt
);
48 message("WARNING: ", fmt
, &arglist
);
52 void error(const char *fmt
, ...)
55 va_start(arglist
, fmt
);
56 message("ERROR: ", fmt
, &arglist
);
60 void fatal(const char *fmt
, ...)
63 va_start(arglist
, fmt
);
64 message("FATAL: ", fmt
, &arglist
);
69 /* If we don't flush, then child processes print before we do */
70 void info(const char *fmt
, ...)
73 va_start(arglist
, fmt
);
75 vfprintf(stdout
, fmt
, arglist
);