2014-07-11 05:06:10 +02:00
|
|
|
/*
|
|
|
|
* Public domain
|
|
|
|
* err.h compatibility shim
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_ERR_H
|
|
|
|
|
|
|
|
#include_next <err.h>
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#ifndef LIBCRYPTOCOMPAT_ERR_H
|
|
|
|
#define LIBCRYPTOCOMPAT_ERR_H
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#define err(exitcode, format, ...) \
|
2015-07-22 16:00:38 +02:00
|
|
|
errx(exitcode, format ": %s", ## __VA_ARGS__, strerror(errno))
|
2014-07-11 05:06:10 +02:00
|
|
|
|
|
|
|
#define errx(exitcode, format, ...) \
|
2015-07-22 16:00:38 +02:00
|
|
|
do { warnx(format, ## __VA_ARGS__); exit(exitcode); } while (0)
|
2014-07-11 05:06:10 +02:00
|
|
|
|
|
|
|
#define warn(format, ...) \
|
2015-07-22 16:00:38 +02:00
|
|
|
warnx(format ": %s", ## __VA_ARGS__, strerror(errno))
|
2014-07-11 05:06:10 +02:00
|
|
|
|
|
|
|
#define warnx(format, ...) \
|
2015-07-22 16:00:38 +02:00
|
|
|
fprintf(stderr, format "\n", ## __VA_ARGS__)
|
2014-07-11 05:06:10 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|