diff options
Diffstat (limited to 'include/err.h')
-rw-r--r-- | include/err.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/err.h b/include/err.h new file mode 100644 index 0000000..0aba1db --- /dev/null +++ b/include/err.h | |||
@@ -0,0 +1,24 @@ | |||
1 | #ifdef HAVE_ERR_H | ||
2 | |||
3 | #include_next <err.h> | ||
4 | |||
5 | #else | ||
6 | |||
7 | #ifndef LIBCRYPTOCOMPAT_ERR_H | ||
8 | #define LIBCRYPTOCOMPAT_ERR_H | ||
9 | |||
10 | #define err(exitcode, format, args...) \ | ||
11 | errx(exitcode, format ": %s", ## args, strerror(errno)) | ||
12 | |||
13 | #define errx(exitcode, format, args...) \ | ||
14 | do { warnx(format, ## args); exit(exitcode); } while (0) | ||
15 | |||
16 | #define warn(format, args...) \ | ||
17 | warnx(format ": %s", ## args, strerror(errno)) | ||
18 | |||
19 | #define warnx(format, args...) \ | ||
20 | fprintf(stderr, format "\n", ## args) | ||
21 | |||
22 | #endif | ||
23 | |||
24 | #endif | ||