aboutsummaryrefslogtreecommitdiff
path: root/include/err.h
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/err.h
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 '')
-rw-r--r--include/err.h24
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