libreSSL/include/compat/err.h

34 lines
607 B
C
Raw Normal View History

/*
* 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))
#define errx(exitcode, format, ...) \
2015-07-22 16:00:38 +02:00
do { warnx(format, ## __VA_ARGS__); exit(exitcode); } while (0)
#define warn(format, ...) \
2015-07-22 16:00:38 +02:00
warnx(format ": %s", ## __VA_ARGS__, strerror(errno))
#define warnx(format, ...) \
2015-07-22 16:00:38 +02:00
fprintf(stderr, format "\n", ## __VA_ARGS__)
#endif
#endif