tst-res.c 817 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. int r;
  11. struct __res_state state;
  12. r = res_ninit(&state);
  13. if (r) {
  14. herror("ninit");
  15. abort();
  16. }
  17. r = res_init();
  18. if (r) {
  19. herror("init");
  20. abort();
  21. }
  22. #ifdef __UCLIBC_HAS_BSD_RES_CLOSE__
  23. res_close();
  24. #endif
  25. #ifdef __UCLIBC__
  26. /* assume there is at least one resolver configured */
  27. assert (state._u._ext.nscount > 0);
  28. #else
  29. assert (state._u._ext.nscount == 0);
  30. #endif
  31. assert (state.options & RES_INIT);
  32. res_nclose(&state);
  33. #ifdef __UCLIBC__
  34. /* We wipe the whole thing */
  35. assert ((state.options & RES_INIT) == 0);
  36. #endif
  37. assert (state._u._ext.nscount == 0);
  38. return 0;
  39. }