]> arthur.barton.de Git - bup.git/blob - src/bup/io.c
README: fix and simplify cirrus badges
[bup.git] / src / bup / io.c
1
2 #define _GNU_SOURCE  1
3 #undef NDEBUG
4
5 #include <stdarg.h>
6 #include <stdlib.h>
7
8 #include "bup/io.h"
9
10 __attribute__ ((format(printf, 2, 3)))
11 void
12 msg(FILE* f, const char * const msg, ...)
13 {
14     if (fputs("bup: ", f) == EOF)
15         exit(3);
16     va_list ap;
17     va_start(ap, msg);
18     if (vfprintf(f, msg, ap) < 0)
19         exit(3);
20     va_end(ap);
21 }
22
23 __attribute__ ((format(printf, 2, 3)))
24 void
25 die(int exit_status, const char * const msg, ...)
26 {
27     if (fputs("bup: ", stderr) == EOF)
28         exit(3);
29     va_list ap;
30     va_start(ap, msg);
31     if (vfprintf(stderr, msg, ap) < 0)
32         exit(3);
33     va_end(ap);
34     exit(exit_status);
35 }