lib500.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*****************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * $Id$
  9. */
  10. #include "test.h"
  11. int test(char *URL)
  12. {
  13. CURLcode res;
  14. CURL *curl;
  15. char *ipstr=NULL;
  16. if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
  17. fprintf(stderr, "curl_global_init() failed\n");
  18. return TEST_ERR_MAJOR_BAD;
  19. }
  20. if ((curl = curl_easy_init()) == NULL) {
  21. fprintf(stderr, "curl_easy_init() failed\n");
  22. curl_global_cleanup();
  23. return TEST_ERR_MAJOR_BAD;
  24. }
  25. curl_easy_setopt(curl, CURLOPT_URL, URL);
  26. curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
  27. res = curl_easy_perform(curl);
  28. if(!res) {
  29. FILE *moo;
  30. res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ipstr);
  31. moo = fopen(libtest_arg2, "wb");
  32. if(moo) {
  33. fprintf(moo, "IP: %s\n", ipstr);
  34. fclose(moo);
  35. }
  36. }
  37. curl_easy_cleanup(curl);
  38. curl_global_cleanup();
  39. return (int)res;
  40. }