diff options
author | Brent Cook <bcook@openbsd.org> | 2014-07-21 07:34:01 -0500 |
---|---|---|
committer | Brent Cook <bcook@openbsd.org> | 2014-07-21 19:53:53 -0500 |
commit | 0ec7cdcbadd66def45046d093919799d9af3c12e (patch) | |
tree | c10ee7dbe1cc54734710efea0a843e7796a32894 /include | |
parent | 4335a49f515e860bdb3181e4562947cbd4032272 (diff) | |
download | portable-0ec7cdcbadd66def45046d093919799d9af3c12e.tar.gz portable-0ec7cdcbadd66def45046d093919799d9af3c12e.tar.bz2 portable-0ec7cdcbadd66def45046d093919799d9af3c12e.zip |
include err.h shim
Includes compatible replacements, or uses system err.h if available.
ok beck@ guenther@
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 3 | ||||
-rw-r--r-- | include/err.h | 24 |
2 files changed, 26 insertions, 1 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index 7f8cfbd..889f775 100644 --- a/include/Makefile.am +++ b/include/Makefile.am | |||
@@ -1,6 +1,7 @@ | |||
1 | SUBDIRS = openssl | 1 | SUBDIRS = openssl |
2 | 2 | ||
3 | noinst_HEADERS = pqueue.h | 3 | noinst_HEADERS = err.h |
4 | noinst_HEADERS += pqueue.h | ||
4 | noinst_HEADERS += stdlib.h | 5 | noinst_HEADERS += stdlib.h |
5 | noinst_HEADERS += string.h | 6 | noinst_HEADERS += string.h |
6 | noinst_HEADERS += unistd.h | 7 | noinst_HEADERS += unistd.h |
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 | ||