/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/tests/gethostbyname.c

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs · C · 53 lines · 27 code · 8 blank · 18 comment · 5 complexity · d23ebab2b99180640563a6f8ba9e72a9 MD5 · raw file

  1. /*
  2. gethostbyname.c - test host lookup
  3. Copyright (C) 2008 siliconforks.com
  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 along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #include <config.h>
  17. #include <assert.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #ifdef HAVE_ARPA_INET_H
  22. #include <arpa/inet.h>
  23. #endif
  24. #include "http-server.h"
  25. int main(int argc, char ** argv) {
  26. #ifdef __MINGW32__
  27. WSADATA data;
  28. if (WSAStartup(MAKEWORD(1, 1), &data) != 0) {
  29. return 1;
  30. }
  31. #endif
  32. if (argc < 2) {
  33. exit(EXIT_FAILURE);
  34. }
  35. struct in_addr a;
  36. if (xgethostbyname(argv[1], &a) != 0) {
  37. exit(EXIT_FAILURE);
  38. }
  39. char * result = inet_ntoa(a);
  40. printf("%s\n", result);
  41. return 0;
  42. }