Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Utilities / cmcurl-7.19.0 / tests / libtest / lib539.c
blobda4702150a223e21e5b81d79a836600dbb2ffdcf
1 /*****************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * $Id: lib539.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 *newURL;
18 struct curl_slist *slist;
20 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
21 fprintf(stderr, "curl_global_init() failed\n");
22 return TEST_ERR_MAJOR_BAD;
25 if ((curl = curl_easy_init()) == NULL) {
26 fprintf(stderr, "curl_easy_init() failed\n");
27 curl_global_cleanup();
28 return TEST_ERR_MAJOR_BAD;
32 * Begin with cURL set to use a single CWD to the URL's directory.
34 curl_easy_setopt(curl, CURLOPT_URL, URL);
35 curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
36 curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_SINGLECWD);
38 res = curl_easy_perform(curl);
41 * Change the FTP_FILEMETHOD option to use full paths rather than a CWD
42 * command. Alter the URL's path a bit, appending a "./". Use an innocuous
43 * QUOTE command, after which cURL will CWD to ftp_conn->entrypath and then
44 * (on the next call to ftp_statemach_act) find a non-zero ftpconn->dirdepth
45 * even though no directories are stored in the ftpconn->dirs array (after a
46 * call to freedirs).
48 newURL = strcat (strcpy ((char*)malloc (strlen (URL) + 3),
49 URL),
50 "./");
51 slist = curl_slist_append (NULL, "SYST");
53 curl_easy_setopt(curl, CURLOPT_URL, newURL);
54 curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_NOCWD);
55 curl_easy_setopt(curl, CURLOPT_QUOTE, slist);
57 res = curl_easy_perform(curl);
59 curl_slist_free_all(slist);
60 free(newURL);
61 curl_easy_cleanup(curl);
62 curl_global_cleanup();
64 return (int)res;