aboutsummaryrefslogtreecommitdiff
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
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@
-rw-r--r--configure.ac.tpl2
-rw-r--r--include/Makefile.am3
-rw-r--r--include/err.h24
3 files changed, 28 insertions, 1 deletions
diff --git a/configure.ac.tpl b/configure.ac.tpl
index 99c2f6f..84d2f69 100644
--- a/configure.ac.tpl
+++ b/configure.ac.tpl
@@ -111,6 +111,8 @@ AC_CHECK_FUNC(funopen, AC_DEFINE(HAVE_FUNOPEN))
111 111
112AC_CHECK_HEADER(sys/sysctl.h, AC_DEFINE(HAVE_SYS_SYSCTL_H)) 112AC_CHECK_HEADER(sys/sysctl.h, AC_DEFINE(HAVE_SYS_SYSCTL_H))
113 113
114AC_CHECK_HEADER(err.h, AC_DEFINE(HAVE_ERR_H))
115
114AC_ARG_WITH([openssldir], 116AC_ARG_WITH([openssldir],
115 AS_HELP_STRING([--with-openssldir], [Set the default openssl directory]), 117 AS_HELP_STRING([--with-openssldir], [Set the default openssl directory]),
116 AC_DEFINE_UNQUOTED(OPENSSLDIR, "$withval") 118 AC_DEFINE_UNQUOTED(OPENSSLDIR, "$withval")
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