From f1a9e6858e6f2cd7ff54eac79df02640f0624a2a Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Sat, 1 Mar 2014 13:38:00 +0000 Subject: [PATCH] tool: Moved --libcurl to the global config --- src/tool_cfgable.c | 2 -- src/tool_cfgable.h | 2 +- src/tool_easysrc.c | 4 ++-- src/tool_easysrc.h | 3 ++- src/tool_getparam.c | 2 +- src/tool_main.c | 2 ++ src/tool_setopt.c | 12 ++++++------ src/tool_setopt.h | 30 +++++++++++++++--------------- 8 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/tool_cfgable.c b/src/tool_cfgable.c index 444cddc42..1e67f54a4 100644 --- a/src/tool_cfgable.c +++ b/src/tool_cfgable.c @@ -135,8 +135,6 @@ static void free_config_fields(struct OperationConfig *config) Curl_safefree(config->ftp_account); Curl_safefree(config->ftp_alternative_to_user); - - Curl_safefree(config->libcurl); } void config_free(struct OperationConfig *config) diff --git a/src/tool_cfgable.h b/src/tool_cfgable.h index 08da30a24..104117590 100644 --- a/src/tool_cfgable.h +++ b/src/tool_cfgable.h @@ -179,7 +179,6 @@ struct OperationConfig { bool ignorecl; /* --ignore-content-length */ bool disable_sessionid; - char *libcurl; /* output libcurl code to this file name */ bool raw; bool post301; bool post302; @@ -225,6 +224,7 @@ struct GlobalConfig { trace tracetype; bool tracetime; /* include timestamp? */ int progressmode; /* CURL_PROGRESS_BAR / CURL_PROGRESS_STATS */ + char *libcurl; /* Output libcurl code to this file name */ struct OperationConfig *first; struct OperationConfig *current; diff --git a/src/tool_easysrc.c b/src/tool_easysrc.c index bcf2f63fe..bf44b1c5c 100644 --- a/src/tool_easysrc.c +++ b/src/tool_easysrc.c @@ -165,7 +165,7 @@ CURLcode easysrc_cleanup(void) return CURLE_OK; } -void dumpeasysrc(struct OperationConfig *config) +void dumpeasysrc(struct GlobalConfig *config) { struct curl_slist *ptr; char *o = config->libcurl; @@ -180,7 +180,7 @@ void dumpeasysrc(struct OperationConfig *config) else out = stdout; if(!out) - warnf(config, "Failed to open %s to write libcurl code!\n", o); + warnf(config->current, "Failed to open %s to write libcurl code!\n", o); else { int i; const char *c; diff --git a/src/tool_easysrc.h b/src/tool_easysrc.h index e5f20e7be..07a4b787e 100644 --- a/src/tool_easysrc.h +++ b/src/tool_easysrc.h @@ -40,7 +40,8 @@ extern CURLcode easysrc_add(struct curl_slist **plist, const char *bupf); extern CURLcode easysrc_addf(struct curl_slist **plist, const char *fmt, ...); extern CURLcode easysrc_perform(void); extern CURLcode easysrc_cleanup(void); -void dumpeasysrc(struct OperationConfig *config); + +void dumpeasysrc(struct GlobalConfig *config); #endif /* CURL_DISABLE_LIBCURL_OPTION */ diff --git a/src/tool_getparam.c b/src/tool_getparam.c index 208d5aac7..26ec8a7a2 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -867,7 +867,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */ "--libcurl option was disabled at build-time!\n"); return PARAM_OPTION_UNKNOWN; #else - GetStr(&config->libcurl, nextarg); + GetStr(&global->libcurl, nextarg); break; #endif case '#': /* --raw */ diff --git a/src/tool_main.c b/src/tool_main.c index 8a613cb21..ef96dc3a4 100644 --- a/src/tool_main.c +++ b/src/tool_main.c @@ -187,6 +187,8 @@ static void free_config_fields(struct GlobalConfig *config) if(config->trace_fopened && config->trace_stream) fclose(config->trace_stream); config->trace_stream = NULL; + + Curl_safefree(config->libcurl); } /* diff --git a/src/tool_setopt.c b/src/tool_setopt.c index d1604245c..62d94a65f 100644 --- a/src/tool_setopt.c +++ b/src/tool_setopt.c @@ -230,7 +230,7 @@ static char *c_escape(const char *str) } /* setopt wrapper for enum types */ -CURLcode tool_setopt_enum(CURL *curl, struct OperationConfig *config, +CURLcode tool_setopt_enum(CURL *curl, struct GlobalConfig *config, const char *name, CURLoption tag, const NameValue *nvlist, long lval) { @@ -263,7 +263,7 @@ CURLcode tool_setopt_enum(CURL *curl, struct OperationConfig *config, } /* setopt wrapper for flags */ -CURLcode tool_setopt_flags(CURL *curl, struct OperationConfig *config, +CURLcode tool_setopt_flags(CURL *curl, struct GlobalConfig *config, const char *name, CURLoption tag, const NameValue *nvlist, long lval) { @@ -305,7 +305,7 @@ CURLcode tool_setopt_flags(CURL *curl, struct OperationConfig *config, } /* setopt wrapper for bitmasks */ -CURLcode tool_setopt_bitmask(CURL *curl, struct OperationConfig *config, +CURLcode tool_setopt_bitmask(CURL *curl, struct GlobalConfig *config, const char *name, CURLoption tag, const NameValueUnsigned *nvlist, long lval) @@ -348,7 +348,7 @@ CURLcode tool_setopt_bitmask(CURL *curl, struct OperationConfig *config, } /* setopt wrapper for CURLOPT_HTTPPOST */ -CURLcode tool_setopt_httppost(CURL *curl, struct OperationConfig *config, +CURLcode tool_setopt_httppost(CURL *curl, struct GlobalConfig *config, const char *name, CURLoption tag, struct curl_httppost *post) { @@ -424,7 +424,7 @@ CURLcode tool_setopt_httppost(CURL *curl, struct OperationConfig *config, } /* setopt wrapper for curl_slist options */ -CURLcode tool_setopt_slist(CURL *curl, struct OperationConfig *config, +CURLcode tool_setopt_slist(CURL *curl, struct GlobalConfig *config, const char *name, CURLoption tag, struct curl_slist *list) { @@ -464,7 +464,7 @@ CURLcode tool_setopt_slist(CURL *curl, struct OperationConfig *config, /* generic setopt wrapper for all other options. * Some type information is encoded in the tag value. */ -CURLcode tool_setopt(CURL *curl, bool str, struct OperationConfig *config, +CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *config, const char *name, CURLoption tag, ...) { va_list arg; diff --git a/src/tool_setopt.h b/src/tool_setopt.h index 8a17d9920..cd144bc0d 100644 --- a/src/tool_setopt.h +++ b/src/tool_setopt.h @@ -71,48 +71,48 @@ extern const NameValueUnsigned setopt_nv_CURLAUTH[]; /* Intercept setopt calls for --libcurl */ -CURLcode tool_setopt_enum(CURL *curl, struct OperationConfig *config, +CURLcode tool_setopt_enum(CURL *curl, struct GlobalConfig *config, const char *name, CURLoption tag, const NameValue *nv, long lval); -CURLcode tool_setopt_flags(CURL *curl, struct OperationConfig *config, +CURLcode tool_setopt_flags(CURL *curl, struct GlobalConfig *config, const char *name, CURLoption tag, const NameValue *nv, long lval); -CURLcode tool_setopt_bitmask(CURL *curl, struct OperationConfig *config, +CURLcode tool_setopt_bitmask(CURL *curl, struct GlobalConfig *config, const char *name, CURLoption tag, const NameValueUnsigned *nv, long lval); -CURLcode tool_setopt_httppost(CURL *curl, struct OperationConfig *config, +CURLcode tool_setopt_httppost(CURL *curl, struct GlobalConfig *config, const char *name, CURLoption tag, struct curl_httppost *httppost); -CURLcode tool_setopt_slist(CURL *curl, struct OperationConfig *config, +CURLcode tool_setopt_slist(CURL *curl, struct GlobalConfig *config, const char *name, CURLoption tag, struct curl_slist *list); -CURLcode tool_setopt(CURL *curl, bool str, struct OperationConfig *config, +CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *config, const char *name, CURLoption tag, ...); #define my_setopt(x,y,z) \ - SETOPT_CHECK(tool_setopt(x, FALSE, config, #y, y, z)) + SETOPT_CHECK(tool_setopt(x, FALSE, global, #y, y, z)) #define my_setopt_str(x,y,z) \ - SETOPT_CHECK(tool_setopt(x, TRUE, config, #y, y, z)) + SETOPT_CHECK(tool_setopt(x, TRUE, global, #y, y, z)) #define my_setopt_enum(x,y,z) \ - SETOPT_CHECK(tool_setopt_enum(x, config, #y, y, setopt_nv_ ## y, z)) + SETOPT_CHECK(tool_setopt_enum(x, global, #y, y, setopt_nv_ ## y, z)) #define my_setopt_flags(x,y,z) \ - SETOPT_CHECK(tool_setopt_flags(x, config, #y, y, setopt_nv_ ## y, z)) + SETOPT_CHECK(tool_setopt_flags(x, global, #y, y, setopt_nv_ ## y, z)) #define my_setopt_bitmask(x,y,z) \ - SETOPT_CHECK(tool_setopt_bitmask(x, config, #y, y, setopt_nv_ ## y, z)) + SETOPT_CHECK(tool_setopt_bitmask(x, global, #y, y, setopt_nv_ ## y, z)) #define my_setopt_httppost(x,y,z) \ - SETOPT_CHECK(tool_setopt_httppost(x, config, #y, y, z)) + SETOPT_CHECK(tool_setopt_httppost(x, global, #y, y, z)) #define my_setopt_slist(x,y,z) \ - SETOPT_CHECK(tool_setopt_slist(x, config, #y, y, z)) + SETOPT_CHECK(tool_setopt_slist(x, global, #y, y, z)) -#define res_setopt(x,y,z) tool_setopt(x, FALSE, config, #y, y, z) +#define res_setopt(x,y,z) tool_setopt(x, FALSE, global, #y, y, z) -#define res_setopt_str(x,y,z) tool_setopt(x, TRUE, config, #y, y, z) +#define res_setopt_str(x,y,z) tool_setopt(x, TRUE, global, #y, y, z) #else /* CURL_DISABLE_LIBCURL_OPTION */