diff options
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 68 |
1 files changed, 36 insertions, 32 deletions
@@ -16,7 +16,7 @@ /** * @file util.c - * @brief TODO + * @brief \todo */ #include <stdarg.h> #include <stdio.h> @@ -25,63 +25,67 @@ #include "util.h" -static void xvprintf (const char *, va_list); /** - * eprintf + * xvprintf prints a formatstring with prefix "libbrandt: ". If the format + * string ends with a ':', the strerror() from errno.h output will be appended. + * The output is always terminated with a newline. * - * @param fmt TODO - * @param + * @param fmt The format string + * @param ap The inputs to the format string */ void -eprintf (const char *fmt, ...) +xvprintf (const char *fmt, va_list ap) { - va_list ap; + /**\todo: provide other logging target than stderr */ + fputs ("libbrandt: ", stderr); - va_start (ap, fmt); - xvprintf (fmt, ap); - va_end (ap); + vfprintf (stderr, fmt, ap); - abort (); + if (fmt[0] && fmt[strlen (fmt) - 1] == ':') + { + fputc (' ', stderr); + perror (NULL); + } + else + { + fputc ('\n', stderr); + } } + /** - * weprintf + * eprintf prints an error message and then calls abort() to terminate the + * process. * - * @param fmt TODO - * @param + * @param fmt The format string + * @param ... The inputs to the format string */ void -weprintf (const char *fmt, ...) +eprintf (const char *fmt, ...) { va_list ap; va_start (ap, fmt); xvprintf (fmt, ap); va_end (ap); + + abort (); } + /** - * xvprintf + * weprintf prints a warning message * - * @param fmt TODO - * @param ap TODO + * @param fmt The format string + * @param ... The inputs to the format string */ void -xvprintf (const char *fmt, va_list ap) +weprintf (const char *fmt, ...) { - /**TODO: provide other logging target than stderr */ - fputs ("libbrandt: ", stderr); - - vfprintf (stderr, fmt, ap); + va_list ap; - if (fmt[0] && fmt[strlen (fmt) - 1] == ':') - { - fputc (' ', stderr); - perror (NULL); - } - else - { - fputc ('\n', stderr); - } + va_start (ap, fmt); + xvprintf (fmt, ap); + va_end (ap); } |