tst-res.c 891 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include <stdlib.h>
  2. #include <assert.h>
  3. #include <sys/types.h>
  4. #include <netinet/in.h>
  5. #include <arpa/nameser.h>
  6. #include <resolv.h>
  7. #include <netdb.h>
  8. int main(int argc, char **argv)
  9. {
  10. #if defined(__GLIBC__) || defined(__UCLIBC__)
  11. int r;
  12. struct __res_state state;
  13. r = res_ninit(&state);
  14. if (r) {
  15. herror("ninit");
  16. abort();
  17. }
  18. r = res_init();
  19. if (r) {
  20. herror("init");
  21. abort();
  22. }
  23. #ifdef __UCLIBC_HAS_BSD_RES_CLOSE__
  24. res_close();
  25. #endif
  26. #ifdef __UCLIBC__
  27. /* assume there is at least one resolver configured */
  28. assert (state._u._ext.nscount > 0);
  29. #else
  30. assert (state._u._ext.nscount == 0);
  31. #endif
  32. assert (state.options & RES_INIT);
  33. res_nclose(&state);
  34. #ifdef __UCLIBC__
  35. /* We wipe the whole thing */
  36. assert ((state.options & RES_INIT) == 0);
  37. #endif
  38. assert (state._u._ext.nscount == 0);
  39. return 0;
  40. #else
  41. return 23;
  42. #endif
  43. }