tst-res.c 774 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. res_close();
  23. #ifdef __UCLIBC__
  24. /* assume there is at least one resolver configured */
  25. assert (state._u._ext.nscount > 0);
  26. #else
  27. assert (state._u._ext.nscount == 0);
  28. #endif
  29. assert (state.options & RES_INIT);
  30. res_nclose(&state);
  31. #ifdef __UCLIBC__
  32. /* We wipe the whole thing */
  33. assert ((state.options & RES_INIT) == 0);
  34. #endif
  35. assert (state._u._ext.nscount == 0);
  36. return 0;
  37. }