diff options
Diffstat (limited to 'examples/utils.c')
-rw-r--r-- | examples/utils.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/utils.c b/examples/utils.c index 609c354..0830738 100644 --- a/examples/utils.c +++ b/examples/utils.c @@ -34,6 +34,7 @@ * ***** END LICENSE BLOCK ***** */ +#include <stdarg.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -45,8 +46,17 @@ #include "utils.h" -void die_on_error(int x, char const *context) +void die(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); + exit(1); +} + +void die_on_error(int x, char const *context) { if (x < 0) { char *errstr = amqp_error_string(-x); fprintf(stderr, "%s: %s\n", context, errstr); |