lib539.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
00009  *
00010  * This software is licensed as described in the file COPYING, which
00011  * you should have received as part of this distribution. The terms
00012  * are also available at https://curl.haxx.se/docs/copyright.html.
00013  *
00014  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00015  * copies of the Software, and permit persons to whom the Software is
00016  * furnished to do so, under the terms of the COPYING file.
00017  *
00018  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00019  * KIND, either express or implied.
00020  *
00021  ***************************************************************************/
00022 #include "test.h"
00023 
00024 #include "memdebug.h"
00025 
00026 int test(char *URL)
00027 {
00028    CURLcode res;
00029    CURL *curl;
00030    char *newURL = NULL;
00031    struct curl_slist *slist = NULL;
00032 
00033    if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
00034      fprintf(stderr, "curl_global_init() failed\n");
00035      return TEST_ERR_MAJOR_BAD;
00036    }
00037 
00038    curl = curl_easy_init();
00039    if(!curl) {
00040      fprintf(stderr, "curl_easy_init() failed\n");
00041      curl_global_cleanup();
00042      return TEST_ERR_MAJOR_BAD;
00043    }
00044 
00045    /*
00046     * Begin with curl set to use a single CWD to the URL's directory.
00047     */
00048    test_setopt(curl, CURLOPT_URL, URL);
00049    test_setopt(curl, CURLOPT_VERBOSE, 1L);
00050    test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD);
00051 
00052    res = curl_easy_perform(curl);
00053 
00054    /*
00055     * Change the FTP_FILEMETHOD option to use full paths rather than a CWD
00056     * command.  Alter the URL's path a bit, appending a "./".  Use an innocuous
00057     * QUOTE command, after which curl will CWD to ftp_conn->entrypath and then
00058     * (on the next call to ftp_statemach_act) find a non-zero ftpconn->dirdepth
00059     * even though no directories are stored in the ftpconn->dirs array (after a
00060     * call to freedirs).
00061     */
00062    newURL = aprintf("%s./", URL);
00063    if(newURL == NULL) {
00064      curl_easy_cleanup(curl);
00065      curl_global_cleanup();
00066      return TEST_ERR_MAJOR_BAD;
00067    }
00068 
00069    slist = curl_slist_append(NULL, "SYST");
00070    if(slist == NULL) {
00071      free(newURL);
00072      curl_easy_cleanup(curl);
00073      curl_global_cleanup();
00074      return TEST_ERR_MAJOR_BAD;
00075    }
00076 
00077    test_setopt(curl, CURLOPT_URL, newURL);
00078    test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD);
00079    test_setopt(curl, CURLOPT_QUOTE, slist);
00080 
00081    res = curl_easy_perform(curl);
00082 
00083 test_cleanup:
00084 
00085    curl_slist_free_all(slist);
00086    free(newURL);
00087    curl_easy_cleanup(curl);
00088    curl_global_cleanup();
00089 
00090    return (int)res;
00091 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:05