Git init
[external/curl.git] / tests / libtest / lib512.c
1 /*****************************************************************************
2  *                                  _   _ ____  _
3  *  Project                     ___| | | |  _ \| |
4  *                             / __| | | | |_) | |
5  *                            | (__| |_| |  _ <| |___
6  *                             \___|\___/|_| \_\_____|
7  *
8  */
9
10 #include "test.h"
11
12 #include "memdebug.h"
13
14 /* Test case code based on source in a bug report filed by James Bursa on
15    28 Apr 2004 */
16
17 int test(char *URL)
18 {
19   CURLcode code;
20   CURL *curl;
21   CURL *curl2;
22   int rc = 99;
23
24   code = curl_global_init(CURL_GLOBAL_ALL);
25   if(code == CURLE_OK) {
26
27     curl = curl_easy_init();
28     if(curl) {
29
30       curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
31       curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
32
33       curl2 = curl_easy_duphandle(curl);
34       if(curl2) {
35
36         code = curl_easy_setopt(curl2, CURLOPT_URL, URL);
37         if(code == CURLE_OK) {
38
39           code = curl_easy_perform(curl2);
40           if(code == CURLE_OK)
41             rc = 0;
42           else
43             rc = 1;
44         }
45         else
46           rc = 2;
47
48         curl_easy_cleanup(curl2);
49       }
50       else
51         rc = 3;
52
53       curl_easy_cleanup(curl);
54     }
55     else
56       rc = 4;
57
58     curl_global_cleanup();
59   }
60   else
61     rc = 5;
62
63   return rc;
64 }
65