aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBrent Cook <bcook@openbsd.org>2014-07-21 07:34:01 -0500
committerBrent Cook <bcook@openbsd.org>2014-07-21 19:53:53 -0500
commit0ec7cdcbadd66def45046d093919799d9af3c12e (patch)
treec10ee7dbe1cc54734710efea0a843e7796a32894 /include
parent4335a49f515e860bdb3181e4562947cbd4032272 (diff)
downloadportable-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.am3
-rw-r--r--include/err.h24
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 @@
1SUBDIRS = openssl 1SUBDIRS = openssl
2 2
3noinst_HEADERS = pqueue.h 3noinst_HEADERS = err.h
4noinst_HEADERS += pqueue.h
4noinst_HEADERS += stdlib.h 5noinst_HEADERS += stdlib.h
5noinst_HEADERS += string.h 6noinst_HEADERS += string.h
6noinst_HEADERS += unistd.h 7noinst_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