1 /* 2 * Public domain 3 * err.h compatibility shim 4 */ 5 6 #ifndef HAVE_ERR_H 7 8 #ifndef LIBCRYPTOCOMPAT_ERR_H 9 #define LIBCRYPTOCOMPAT_ERR_H 10 11 #include <errno.h> 12 #include <stdio.h> 13 #include <string.h> 14 15 #define err(exitcode, format, args...) \ 16 errx(exitcode, format ": %s", ## args, strerror(errno)) 17 18 #define errx(exitcode, format, args...) \ 19 do { warnx(format, ## args); exit(exitcode); } while (0) 20 21 #define warn(format, args...) \ 22 warnx(format ": %s", ## args, strerror(errno)) 23 24 #define warnx(format, args...) \ 25 fprintf(stderr, format "\n", ## args) 26 27 #endif 28 29 #endif 30