aboutsummaryrefslogtreecommitdiff
path: root/src/tool_setopt.c
diff options
context:
space:
mode:
authorYves Arrouye <yarrouye@expedia.com>2013-01-14 20:06:32 +0100
committerDaniel Stenberg <daniel@haxx.se>2013-01-16 15:49:31 +0100
commit4ed6b07d8dbf6a61aeba1eb8ac802f0b6a65c082 (patch)
tree7807ebdea79a4e69e25784ad34e0ec7bad62b711 /src/tool_setopt.c
parent533c31b78550603017f895180f301b760471c762 (diff)
--libcurl: fix for non-zero default options
If the default value for an option taking a long as its value is non zero, and it is set by zero by a command line option, then that command line option is not reflected in --libcurl's output. This is because line 520-521 of tool_setopt.c look like: if(!lval) skip = TRUE; An example of a command-line option doing so is the -k option that sets CURLOPT_SLL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST to 0L, when the defaults are non-zero.
Diffstat (limited to 'src/tool_setopt.c')
-rw-r--r--src/tool_setopt.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/tool_setopt.c b/src/tool_setopt.c
index 9aefc21d5..4014177f2 100644
--- a/src/tool_setopt.c
+++ b/src/tool_setopt.c
@@ -39,6 +39,7 @@
/* and finally any "NONE" value. */
#define NV(e) {#e, e}
+#define NV1(e, v) {#e, (v)}
#define NVEND {NULL, 0} /* sentinel to mark end of list */
const NameValue setopt_nv_CURLPROXY[] = {
@@ -122,6 +123,13 @@ const NameValue setopt_nv_CURLPROTO[] = {
NVEND,
};
+/* These options have non-zero default values. */
+static const NameValue setopt_nv_CURLNONZERODEFAULTS[] = {
+ NV1(CURLOPT_SSL_VERIFYPEER, 1),
+ NV1(CURLOPT_SSL_VERIFYHOST, 1),
+ NVEND
+};
+
/* Format and add code; jump to nomem on malloc error */
#define ADD(args) do { \
ret = easysrc_add args; \
@@ -453,10 +461,19 @@ CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config,
if(tag < CURLOPTTYPE_OBJECTPOINT) {
/* Value is expected to be a long */
long lval = va_arg(arg, long);
+ long defval = 0L;
+ const NameValue *nv = NULL;
+ for(nv=setopt_nv_CURLNONZERODEFAULTS; nv->name; nv++) {
+ if(!strcmp(name, nv->name)) {
+ defval = nv->value;
+ break; /* found it */
+ }
+ }
+
snprintf(buf, sizeof(buf), "%ldL", lval);
value = buf;
ret = curl_easy_setopt(curl, tag, lval);
- if(!lval)
+ if(lval == defval)
skip = TRUE;
}
else if(tag < CURLOPTTYPE_OFF_T) {