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.

44 lines
1.1 KiB

  1. --- a/lib/nicInfo/nicInfoPosix.c
  2. +++ b/lib/nicInfo/nicInfoPosix.c
  3. @@ -65,6 +65,9 @@
  4. #include <netinet/in.h>
  5. #include <arpa/nameser.h>
  6. #include <resolv.h>
  7. +#if defined(__linux__) && !defined(__GLIBC__)
  8. +#include "resolv_compat.h"
  9. +#endif
  10. #ifdef __linux__
  11. # include <net/if.h>
  12. --- a/lib/nicInfo/resolv_compat.h
  13. +++ b/lib/nicInfo/resolv_compat.h
  14. @@ -0,0 +1,29 @@
  15. +#if !defined(__GLIBC__)
  16. +/***************************************************************************
  17. + * resolv_compat.h
  18. + *
  19. + * Mimick GLIBC's res_ninit() and res_nclose() for musl libc
  20. + * Note: res_init() is actually deprecated according to
  21. + * http://docs.oracle.com/cd/E36784_01/html/E36875/res-nclose-3resolv.html
  22. + **************************************************************************/
  23. +#include <string.h>
  24. +
  25. +static inline int res_ninit(res_state statp)
  26. +{
  27. + int rc = res_init();
  28. + if (statp != &_res) {
  29. + memcpy(statp, &_res, sizeof(*statp));
  30. + }
  31. + return rc;
  32. +}
  33. +
  34. +static inline int res_nclose(res_state statp)
  35. +{
  36. + if (!statp)
  37. + return -1;
  38. + if (statp != &_res) {
  39. + memset(statp, 0, sizeof(*statp));
  40. + }
  41. + return 0;
  42. +}
  43. +#endif