diff --git a/docs/libcurl/opts/CURLOPT_FTP_FILEMETHOD.md b/docs/libcurl/opts/CURLOPT_FTP_FILEMETHOD.md index 320b362f8f..7b8999130c 100644 --- a/docs/libcurl/opts/CURLOPT_FTP_FILEMETHOD.md +++ b/docs/libcurl/opts/CURLOPT_FTP_FILEMETHOD.md @@ -68,8 +68,7 @@ int main(void) if(curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/1/2/3/4/new.txt"); - curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, - (long)CURLFTPMETHOD_SINGLECWD); + curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_SINGLECWD); res = curl_easy_perform(curl); diff --git a/include/curl/curl.h b/include/curl/curl.h index e5a57c25cc..258cc28bec 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -1009,12 +1009,14 @@ typedef enum { } curl_ftpcreatedir; /* parameter for the CURLOPT_FTP_FILEMETHOD option */ +#define CURLFTPMETHOD_DEFAULT 0L /* let libcurl pick */ +#define CURLFTPMETHOD_MULTICWD 1L /* single CWD operation for each path + part */ +#define CURLFTPMETHOD_NOCWD 2L /* no CWD at all */ +#define CURLFTPMETHOD_SINGLECWD 3L /* one CWD to full dir, then work on file */ + typedef enum { - CURLFTPMETHOD_DEFAULT, /* let libcurl pick */ - CURLFTPMETHOD_MULTICWD, /* single CWD operation for each path part */ - CURLFTPMETHOD_NOCWD, /* no CWD at all */ - CURLFTPMETHOD_SINGLECWD, /* one CWD to full dir, then work on file */ - CURLFTPMETHOD_LAST /* not an option, never use */ + CURLFTPMETHOD_LAST = 4 /* not an option, never use */ } curl_ftpmethod; /* bitmask defines for CURLOPT_HEADEROPT */ diff --git a/src/tool_cfgable.h b/src/tool_cfgable.h index c52f09d1f5..8c1dd8d269 100644 --- a/src/tool_cfgable.h +++ b/src/tool_cfgable.h @@ -227,7 +227,7 @@ struct OperationConfig { HttpReq httpreq; long proxyver; /* set to CURLPROXY_HTTP* define */ long ftp_ssl_ccc_mode; - int ftp_filemethod; + long ftp_filemethod; enum { CLOBBER_DEFAULT, /* Provides compatibility with previous versions of curl, by using the default behavior for -o, -O, and -J. diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c index 546f18775a..4c7c5a7906 100644 --- a/src/tool_paramhlp.c +++ b/src/tool_paramhlp.c @@ -620,7 +620,7 @@ ParameterError add2list(struct curl_slist **list, const char *ptr) return PARAM_OK; } -int ftpfilemethod(struct OperationConfig *config, const char *str) +long ftpfilemethod(struct OperationConfig *config, const char *str) { if(curl_strequal("singlecwd", str)) return CURLFTPMETHOD_SINGLECWD; diff --git a/src/tool_paramhlp.h b/src/tool_paramhlp.h index 6b201d6f48..16d4311524 100644 --- a/src/tool_paramhlp.h +++ b/src/tool_paramhlp.h @@ -58,7 +58,7 @@ CURLcode get_args(struct OperationConfig *config, const size_t i); ParameterError add2list(struct curl_slist **list, const char *ptr); -int ftpfilemethod(struct OperationConfig *config, const char *str); +long ftpfilemethod(struct OperationConfig *config, const char *str); long ftpcccmethod(struct OperationConfig *config, const char *str); diff --git a/tests/libtest/lib539.c b/tests/libtest/lib539.c index f2c302cf4e..4b333807e3 100644 --- a/tests/libtest/lib539.c +++ b/tests/libtest/lib539.c @@ -49,7 +49,7 @@ static CURLcode test_lib539(char *URL) */ test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_VERBOSE, 1L); - test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD); + test_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_SINGLECWD); res = curl_easy_perform(curl); if(res == CURLE_OK) { @@ -70,7 +70,7 @@ static CURLcode test_lib539(char *URL) } test_setopt(curl, CURLOPT_URL, libtest_arg2); - test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD); + test_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_NOCWD); test_setopt(curl, CURLOPT_QUOTE, slist); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib661.c b/tests/libtest/lib661.c index 84b867c6a1..8f14d27b6a 100644 --- a/tests/libtest/lib661.c +++ b/tests/libtest/lib661.c @@ -50,7 +50,7 @@ static CURLcode test_lib661(char *URL) test_setopt(curl, CURLOPT_URL, newURL); test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, 1L); - test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD); + test_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_SINGLECWD); res = curl_easy_perform(curl); if(res != CURLE_REMOTE_FILE_NOT_FOUND) goto test_cleanup; @@ -77,7 +77,7 @@ static CURLcode test_lib661(char *URL) test_setopt(curl, CURLOPT_URL, newURL); test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, 1L); - test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD); + test_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_NOCWD); res = curl_easy_perform(curl); if(res != CURLE_REMOTE_FILE_NOT_FOUND) goto test_cleanup; @@ -86,7 +86,7 @@ static CURLcode test_lib661(char *URL) curl_free(newURL); newURL = curl_maprintf("%s/folderB/661", URL); test_setopt(curl, CURLOPT_URL, newURL); - test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD); + test_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_SINGLECWD); res = curl_easy_perform(curl); if(res != CURLE_REMOTE_FILE_NOT_FOUND) goto test_cleanup; @@ -94,7 +94,7 @@ static CURLcode test_lib661(char *URL) curl_free(newURL); newURL = curl_maprintf("%s/folderA/661", URL); test_setopt(curl, CURLOPT_URL, newURL); - test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD); + test_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_NOCWD); res = curl_easy_perform(curl); if(res != CURLE_REMOTE_FILE_NOT_FOUND) goto test_cleanup; @@ -119,7 +119,7 @@ static CURLcode test_lib661(char *URL) test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_NOBODY, 1L); - test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD); + test_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_NOCWD); test_setopt(curl, CURLOPT_QUOTE, slist); res = curl_easy_perform(curl); if(res) @@ -138,7 +138,7 @@ static CURLcode test_lib661(char *URL) test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_NOBODY, 1L); - test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD); + test_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_SINGLECWD); test_setopt(curl, CURLOPT_QUOTE, slist); res = curl_easy_perform(curl); if(res) @@ -151,7 +151,7 @@ static CURLcode test_lib661(char *URL) test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_NOBODY, 1L); - test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD); + test_setopt(curl, CURLOPT_FTP_FILEMETHOD, CURLFTPMETHOD_NOCWD); test_setopt(curl, CURLOPT_QUOTE, slist); res = curl_easy_perform(curl);