Portable build framework for OpenNTPD
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
595 B

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