resolve.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. Test program for the neon resolver interface
  3. Copyright (C) 2002-2003, Joe Orton <[email protected]>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #include "config.h"
  17. #include <stdio.h>
  18. #include "ne_socket.h"
  19. int main(int argc, char **argv)
  20. {
  21. ne_sock_addr *addr;
  22. char buf[256];
  23. int ret = 0;
  24. if (argc < 2) {
  25. printf("Usage: %s hostname\n", argv[0]);
  26. return 1;
  27. }
  28. if (ne_sock_init()) {
  29. printf("%s: Failed to initialize socket library.\n", argv[0]);
  30. return 1;
  31. }
  32. addr = ne_addr_resolve(argv[1], 0);
  33. if (ne_addr_result(addr)) {
  34. printf("Could not resolve `%s': %s\n", argv[1],
  35. ne_addr_error(addr, buf, sizeof buf));
  36. ret = 2;
  37. } else {
  38. const ne_inet_addr *ia;
  39. printf("Resolved `%s' OK:", argv[1]);
  40. for (ia = ne_addr_first(addr); ia; ia = ne_addr_next(addr)) {
  41. printf(" <%s>", ne_iaddr_print(ia, buf, sizeof buf));
  42. }
  43. putchar('\n');
  44. }
  45. ne_addr_destroy(addr);
  46. return ret;
  47. }