1 #define _GNU_SOURCE /* asprintf */
10 /* Do we use syslog for messages or stderr? */
13 /* Do we want to silently drop all warnings? */
16 /* Number of times warn() has been called */
19 /* Do we want informative messages as well as errors? */
22 void message(const char *prefix
, const char *fmt
, va_list *arglist
)
27 ret
= vasprintf(&buf
, fmt
, *arglist
);
29 ret
= asprintf(&buf2
, "%s%s", prefix
, buf
);
32 buf2
= "FATAL: Out of memory.\n";
35 syslog(LOG_NOTICE
, "%s", buf2
);
37 fprintf(stderr
, "%s", buf2
);
46 void warn(const char *fmt
, ...)
50 va_start(arglist
, fmt
);
52 message("WARNING: ", fmt
, &arglist
);
56 void error(const char *fmt
, ...)
59 va_start(arglist
, fmt
);
60 message("ERROR: ", fmt
, &arglist
);
64 void fatal(const char *fmt
, ...)
67 va_start(arglist
, fmt
);
68 message("FATAL: ", fmt
, &arglist
);
73 /* If we don't flush, then child processes print before we do */
74 void info(const char *fmt
, ...)
77 va_start(arglist
, fmt
);
79 vfprintf(stdout
, fmt
, arglist
);