summaryrefslogtreecommitdiff
path: root/src/tool_setopt.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-06-18 22:30:54 +0200
committerDaniel Stenberg <daniel@haxx.se>2019-06-18 22:31:26 +0200
commitb9e0c6d28c3e89cf27ce15b14a8c2300ad32a4e5 (patch)
treeb219b0509668b432e533a50d58dbbd524204841f /src/tool_setopt.c
parent6c2f9bea70b928067b854f0a17981e3da0c65aeb (diff)
downloadcurl-b9e0c6d28c3e89cf27ce15b14a8c2300ad32a4e5.tar.gz
curl: improved skip-setopt-options when built with disabled features
Reduces #ifdefs in src/tool_operate.c Follow-up from 4e86f2fc4e6 Closes #3936
Diffstat (limited to 'src/tool_setopt.c')
-rw-r--r--src/tool_setopt.c73
1 files changed, 68 insertions, 5 deletions
diff --git a/src/tool_setopt.c b/src/tool_setopt.c
index ff67c22e7..b5486e6ef 100644
--- a/src/tool_setopt.c
+++ b/src/tool_setopt.c
@@ -720,9 +720,14 @@ CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *config,
#endif /* CURL_DISABLE_LIBCURL_OPTION */
-CURLcode tool_real_error(CURLcode result, CURLoption tag)
+/*
+ * tool_setopt_skip() allows the curl tool code to avoid setopt options that
+ * are explicitly disabled in the build.
+ */
+bool tool_setopt_skip(CURLoption tag)
{
#ifdef CURL_DISABLE_PROXY
+#define USED_TAG
switch(tag) {
case CURLOPT_HAPROXYPROTOCOL:
case CURLOPT_HTTPPROXYTUNNEL:
@@ -756,13 +761,71 @@ CURLcode tool_real_error(CURLcode result, CURLoption tag)
case CURLOPT_PROXYTYPE:
case CURLOPT_PROXYUSERNAME:
case CURLOPT_PROXYUSERPWD:
- return CURLE_OK; /* pretend it worked */
+ return TRUE;
default:
break;
}
-#else
+#endif
+#ifdef CURL_DISABLE_FTP
+#define USED_TAG
+ switch(tag) {
+ case CURLOPT_FTPPORT:
+ case CURLOPT_FTP_ACCOUNT:
+ case CURLOPT_FTP_ALTERNATIVE_TO_USER:
+ case CURLOPT_FTP_FILEMETHOD:
+ case CURLOPT_FTP_SKIP_PASV_IP:
+ case CURLOPT_FTP_USE_EPRT:
+ case CURLOPT_FTP_USE_EPSV:
+ case CURLOPT_FTP_USE_PRET:
+ case CURLOPT_KRBLEVEL:
+ return TRUE;
+ default:
+ break;
+ }
+#endif
+#ifdef CURL_DISABLE_RTSP
+#define USED_TAG
+ switch(tag) {
+ case CURLOPT_INTERLEAVEDATA:
+ return TRUE;
+ default:
+ break;
+ }
+#endif
+#if defined(CURL_DISABLE_HTTP) || defined(CURL_DISABLE_COOKIES)
+#define USED_TAG
+ switch(tag) {
+ case CURLOPT_COOKIE:
+ case CURLOPT_COOKIEFILE:
+ case CURLOPT_COOKIEJAR:
+ case CURLOPT_COOKIESESSION:
+ return TRUE;
+ default:
+ break;
+ }
+#endif
+#if defined(CURL_DISABLE_TELNET)
+#define USED_TAG
+ switch(tag) {
+ case CURLOPT_TELNETOPTIONS:
+ return TRUE;
+ default:
+ break;
+ }
+#endif
+#ifdef CURL_DISABLE_TFTP
+#define USED_TAG
+ switch(tag) {
+ case CURLOPT_TFTP_BLKSIZE:
+ case CURLOPT_TFTP_NO_OPTIONS:
+ return TRUE;
+ default:
+ break;
+ }
+#endif
+
+#ifndef USED_TAG
(void)tag;
#endif
- return result;
+ return FALSE;
}
-