2014-11-19 14:43:07 +01:00
|
|
|
/*
|
|
|
|
* Public domain
|
|
|
|
* err.h compatibility shim
|
|
|
|
*/
|
|
|
|
|
2014-07-21 14:34:01 +02:00
|
|
|
#ifdef HAVE_ERR_H
|
|
|
|
|
|
|
|
#include_next <err.h>
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#ifndef LIBCRYPTOCOMPAT_ERR_H
|
|
|
|
#define LIBCRYPTOCOMPAT_ERR_H
|
|
|
|
|
2014-07-27 13:10:23 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2014-07-21 14:34:01 +02:00
|
|
|
#define err(exitcode, format, args...) \
|
|
|
|
errx(exitcode, format ": %s", ## args, strerror(errno))
|
|
|
|
|
|
|
|
#define errx(exitcode, format, args...) \
|
|
|
|
do { warnx(format, ## args); exit(exitcode); } while (0)
|
|
|
|
|
|
|
|
#define warn(format, args...) \
|
|
|
|
warnx(format ": %s", ## args, strerror(errno))
|
|
|
|
|
|
|
|
#define warnx(format, args...) \
|
|
|
|
fprintf(stderr, format "\n", ## args)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|