Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Utilities / cmcurl-7.19.0 / tests / libtest / lib500.c
blob1e504e50b59e9e914327002d32c1300eb7ccf468
1 /*****************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * $Id: lib500.c,v 1.1.1.1 2008-09-23 16:32:06 hoffman Exp $
9 */
11 #include "test.h"
13 int test(char *URL)
15 CURLcode res;
16 CURL *curl;
17 char *ipstr=NULL;
19 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
20 fprintf(stderr, "curl_global_init() failed\n");
21 return TEST_ERR_MAJOR_BAD;
24 if ((curl = curl_easy_init()) == NULL) {
25 fprintf(stderr, "curl_easy_init() failed\n");
26 curl_global_cleanup();
27 return TEST_ERR_MAJOR_BAD;
30 curl_easy_setopt(curl, CURLOPT_URL, URL);
31 curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
33 res = curl_easy_perform(curl);
35 if(!res) {
36 FILE *moo;
37 res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ipstr);
38 moo = fopen(libtest_arg2, "wb");
39 if(moo) {
40 fprintf(moo, "IP: %s\n", ipstr);
41 fclose(moo);
45 curl_easy_cleanup(curl);
46 curl_global_cleanup();
48 return (int)res;