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