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.

69 lines
1.4 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_STRLCPY
  16. size_t strlcpy(char *dst, const char *src, size_t siz);
  17. #endif
  18. #ifndef HAVE_STRLCAT
  19. size_t strlcat(char *dst, const char *src, size_t siz);
  20. #endif
  21. #ifndef HAVE_STRNDUP
  22. char * strndup(const char *str, size_t maxlen);
  23. /* the only user of strnlen is strndup, so only build it if needed */
  24. #ifndef HAVE_STRNLEN
  25. size_t strnlen(const char *str, size_t maxlen);
  26. #endif
  27. #endif
  28. #ifndef HAVE_EXPLICIT_BZERO
  29. void explicit_bzero(void *, size_t);
  30. #endif
  31. #ifndef HAVE_TIMINGSAFE_BCMP
  32. int timingsafe_bcmp(const void *b1, const void *b2, size_t n);
  33. #endif
  34. #ifndef HAVE_TIMINGSAFE_MEMCMP
  35. int timingsafe_memcmp(const void *b1, const void *b2, size_t len);
  36. #endif
  37. #ifndef HAVE_MEMMEM
  38. void * memmem(const void *big, size_t big_len, const void *little,
  39. size_t little_len);
  40. #endif
  41. #ifdef _WIN32
  42. #include <errno.h>
  43. static inline char *
  44. posix_strerror(int errnum)
  45. {
  46. if (errnum == ECONNREFUSED) {
  47. return "Connection refused";
  48. }
  49. return strerror(errnum);
  50. }
  51. #define strerror(errnum) posix_strerror(errnum)
  52. #endif
  53. #endif