diff options
| author | 2017-12-30 09:09:12 +0100 | |
|---|---|---|
| committer | 2017-12-30 09:09:12 +0100 | |
| commit | ff7a2e6e4917657a67759b25f8c4f41ce085c3c7 (patch) | |
| tree | d657d180a6040a37346a104548e51d7f23ca9271 /src/common.h | |
| parent | d648e4122e8191f109b1407933da7e0486416d93 (diff) | |
| download | tweetpipe-ff7a2e6e4917657a67759b25f8c4f41ce085c3c7.tar.gz | |
Format errors
Diffstat (limited to 'src/common.h')
| -rw-r--r-- | src/common.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/common.h b/src/common.h index 7a9c555..a45b6f4 100644 --- a/src/common.h +++ b/src/common.h @@ -26,16 +26,18 @@ store32_le(uint8_t dst[4], uint32_t w) } static void -die(const char *msg) +die(int print_errno, const char *format, ...) { - fprintf(stderr, "%s\n", msg); - exit(1); -} + va_list ap; + + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); + if (print_errno) { + fprintf(stderr, "- %s", strerror(errno)); + } + fprintf(stderr, "\n"); -static void -diex(const char *msg) -{ - perror(msg); exit(1); } |