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.

61 lines
1.2 KiB

  1. /*
  2. * Public domain
  3. * string.h compatibility shim
  4. */
  5. #include_next <string.h>
  6. #ifndef LIBCOMPAT_STRING_H
  7. #define LIBCOMPAT_STRING_H
  8. #include <sys/types.h>
  9. #if defined(__sun) || defined(__hpux)
  10. /* Some functions historically defined in string.h were placed in strings.h by
  11. * SUS. Use the same hack as OS X and FreeBSD use to work around on Solaris and HPUX.
  12. */
  13. #include <strings.h>
  14. #endif
  15. #ifndef HAVE_EXPLICIT_BZERO
  16. void explicit_bzero(void *, size_t);
  17. #endif
  18. #ifndef HAVE_MEMMEM
  19. void * memmem(const void *big, size_t big_len, const void *little,
  20. size_t little_len);
  21. #endif
  22. #ifndef HAVE_STRLCAT
  23. size_t strlcat(char *dst, const char *src, size_t siz);
  24. #endif
  25. #ifndef HAVE_STRLCPY
  26. size_t strlcpy(char *dst, const char *src, size_t siz);
  27. #endif
  28. #ifndef HAVE_TIMINGSAFE_BCMP
  29. int timingsafe_bcmp(const void *b1, const void *b2, size_t n);
  30. #endif
  31. #ifndef HAVE_TIMINGSAFE_MEMCMP
  32. int timingsafe_memcmp(const void *b1, const void *b2, size_t len);
  33. #endif
  34. #ifdef _WIN32
  35. #include <errno.h>
  36. static inline char *
  37. posix_strerror(int errnum)
  38. {
  39. if (errnum == ECONNREFUSED) {
  40. return "Connection refused";
  41. }
  42. return strerror(errnum);
  43. }
  44. #define strerror(errnum) posix_strerror(errnum)
  45. #endif
  46. #endif