From 9ecf53e1544e90aeb2e667fdbbc84f05e341cc07 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 21 Sep 2011 01:54:14 +0200 Subject: curl tool: reviewed code moved to tool_*.[ch] files my_setopt and my_setopt_str no longer ignores curl_easy_setopt result. Fixed some OOM handling issues. --- src/tool_setopt.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/tool_setopt.h (limited to 'src/tool_setopt.h') diff --git a/src/tool_setopt.h b/src/tool_setopt.h new file mode 100644 index 000000000..7a1b8c591 --- /dev/null +++ b/src/tool_setopt.h @@ -0,0 +1,50 @@ +#ifndef HEADER_CURL_TOOL_SETOPT_H +#define HEADER_CURL_TOOL_SETOPT_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ +#include "setup.h" + +CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config, + const char *name, CURLoption tag, ...); + +/* + * Macros used in operate() + */ + +#define my_setopt(x,y,z) do { \ + res = tool_setopt(x, FALSE, config, #y, y, z); \ + if(res) \ + goto quit_curl; \ +} WHILE_FALSE + +#define my_setopt_str(x,y,z) do { \ + res = tool_setopt(x, TRUE, config, #y, y, z); \ + if(res) \ + goto quit_curl; \ +} WHILE_FALSE + +#define res_setopt(x,y,z) tool_setopt(x, FALSE, config, #y, y, z) + +#define res_setopt_str(x,y,z) tool_setopt(x, TRUE, config, #y, y, z) + +#endif /* HEADER_CURL_TOOL_SETOPT_H */ + -- cgit v1.2.1 From 28526ed6e080b5c74fde65fd24abb1324f742789 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 21 Sep 2011 04:28:46 +0200 Subject: curl tool: make my_setopt ignore curl_easy_setopt result again. Related code not ready yet for this kind of checks. --- src/tool_setopt.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/tool_setopt.h') diff --git a/src/tool_setopt.h b/src/tool_setopt.h index 7a1b8c591..e75f328f3 100644 --- a/src/tool_setopt.h +++ b/src/tool_setopt.h @@ -29,7 +29,7 @@ CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config, /* * Macros used in operate() */ - +#if 0 #define my_setopt(x,y,z) do { \ res = tool_setopt(x, FALSE, config, #y, y, z); \ if(res) \ @@ -41,6 +41,10 @@ CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config, if(res) \ goto quit_curl; \ } WHILE_FALSE +#else +#define my_setopt(x,y,z) tool_setopt(x, FALSE, config, #y, y, z) +#define my_setopt_str(x,y,z) tool_setopt(x, TRUE, config, #y, y, z) +#endif #define res_setopt(x,y,z) tool_setopt(x, FALSE, config, #y, y, z) -- cgit v1.2.1 From fb3845a438cad9ef09eb1b0b86388ce99a726502 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 22 Sep 2011 11:16:34 +0200 Subject: curl tool: reviewed code moved to tool_*.[ch] files my_setopt and my_setopt_str no longer ignores curl_easy_setopt result. Fixed some OOM handling issues. --- src/tool_setopt.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/tool_setopt.h') diff --git a/src/tool_setopt.h b/src/tool_setopt.h index e75f328f3..d01c9eb24 100644 --- a/src/tool_setopt.h +++ b/src/tool_setopt.h @@ -29,22 +29,18 @@ CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config, /* * Macros used in operate() */ -#if 0 + #define my_setopt(x,y,z) do { \ res = tool_setopt(x, FALSE, config, #y, y, z); \ if(res) \ - goto quit_curl; \ + goto show_error; \ } WHILE_FALSE #define my_setopt_str(x,y,z) do { \ res = tool_setopt(x, TRUE, config, #y, y, z); \ if(res) \ - goto quit_curl; \ + goto show_error; \ } WHILE_FALSE -#else -#define my_setopt(x,y,z) tool_setopt(x, FALSE, config, #y, y, z) -#define my_setopt_str(x,y,z) tool_setopt(x, TRUE, config, #y, y, z) -#endif #define res_setopt(x,y,z) tool_setopt(x, FALSE, config, #y, y, z) -- cgit v1.2.1 From 2b26eb98573a1402a8f39603b9fdaa9d04142c07 Mon Sep 17 00:00:00 2001 From: Colin Hogben Date: Sun, 5 Feb 2012 17:44:22 +0000 Subject: configure: add option disable --libcurl output --- src/tool_setopt.h | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'src/tool_setopt.h') diff --git a/src/tool_setopt.h b/src/tool_setopt.h index d01c9eb24..fcd60f856 100644 --- a/src/tool_setopt.h +++ b/src/tool_setopt.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,28 +23,47 @@ ***************************************************************************/ #include "setup.h" -CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config, - const char *name, CURLoption tag, ...); - /* * Macros used in operate() */ -#define my_setopt(x,y,z) do { \ - res = tool_setopt(x, FALSE, config, #y, y, z); \ +#define SETOPT_CHECK(v) do { \ + res = (v); \ if(res) \ goto show_error; \ } WHILE_FALSE -#define my_setopt_str(x,y,z) do { \ - res = tool_setopt(x, TRUE, config, #y, y, z); \ - if(res) \ - goto show_error; \ -} WHILE_FALSE +#ifndef CURL_DISABLE_LIBCURL_OPTION + +/* Intercept setopt calls for --libcurl */ + +CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config, + const char *name, CURLoption tag, ...); + +#define my_setopt(x,y,z) \ + SETOPT_CHECK(tool_setopt(x, FALSE, config, #y, y, z)) + +#define my_setopt_str(x,y,z) \ + SETOPT_CHECK(tool_setopt(x, TRUE, config, #y, y, z)) #define res_setopt(x,y,z) tool_setopt(x, FALSE, config, #y, y, z) #define res_setopt_str(x,y,z) tool_setopt(x, TRUE, config, #y, y, z) -#endif /* HEADER_CURL_TOOL_SETOPT_H */ +#else + +/* No --libcurl, so pass options directly to library */ + +#define my_setopt(x,y,z) \ + SETOPT_CHECK(curl_easy_setopt(x, y, z)) +#define my_setopt_str(x,y,z) \ + SETOPT_CHECK(curl_easy_setopt(x, y, z)) + +#define res_setopt(x,y,z) curl_easy_setopt(x,y,z) + +#define res_setopt_str(x,y,z) curl_easy_setopt(x,y,z) + +#endif /* CURL_DISABLE_LIBCURL_OPTION */ + +#endif /* HEADER_CURL_TOOL_SETOPT_H */ -- cgit v1.2.1 From 995424298052fa02ac82a584ee4247939503f24a Mon Sep 17 00:00:00 2001 From: Colin Hogben Date: Thu, 23 Feb 2012 09:43:37 +0000 Subject: Generate lists and use symbols in --libcurl code output. This patch improves the output of curl's --libcurl option by generating code which builds curl_httppost and curl_slist lists, and uses symbolic names for enum and flag values. Variants of the my_setopt macro in tool_setopt.h are added in order to pass extra type information to the code-generation step in tool_setopt.c. If curl is configured with --disable-libcurl-option then the macros call curl_easy_setopt directly. --- src/tool_setopt.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) (limited to 'src/tool_setopt.h') diff --git a/src/tool_setopt.h b/src/tool_setopt.h index fcd60f856..4189addae 100644 --- a/src/tool_setopt.h +++ b/src/tool_setopt.h @@ -35,8 +35,45 @@ #ifndef CURL_DISABLE_LIBCURL_OPTION +/* Associate symbolic names with option values */ +typedef struct { + const char *name; + long value; +} NameValue; + +extern const NameValue setopt_nv_CURLPROXY[]; +extern const NameValue setopt_nv_CURLAUTH[]; +extern const NameValue setopt_nv_CURL_HTTP_VERSION[]; +extern const NameValue setopt_nv_CURL_SSLVERSION[]; +extern const NameValue setopt_nv_CURL_TIMECOND[]; +extern const NameValue setopt_nv_CURLFTPSSL_CCC[]; +extern const NameValue setopt_nv_CURLPROTO[]; + +/* Map options to NameValue sets */ +#define setopt_nv_CURLOPT_HTTP_VERSION setopt_nv_CURL_HTTP_VERSION +#define setopt_nv_CURLOPT_HTTPAUTH setopt_nv_CURLAUTH +#define setopt_nv_CURLOPT_SSLVERSION setopt_nv_CURL_SSLVERSION +#define setopt_nv_CURLOPT_TIMECONDITION setopt_nv_CURL_TIMECOND +#define setopt_nv_CURLOPT_FTP_SSL_CCC setopt_nv_CURLFTPSSL_CCC +#define setopt_nv_CURLOPT_PROTOCOLS setopt_nv_CURLPROTO +#define setopt_nv_CURLOPT_REDIR_PROTOCOLS setopt_nv_CURLPROTO +#define setopt_nv_CURLOPT_PROXYTYPE setopt_nv_CURLPROXY +#define setopt_nv_CURLOPT_PROXYAUTH setopt_nv_CURLAUTH + /* Intercept setopt calls for --libcurl */ +CURLcode tool_setopt_enum(CURL *curl, struct Configurable *config, + const char *name, CURLoption tag, + const NameValue *nv, long lval); +CURLcode tool_setopt_flags(CURL *curl, struct Configurable *config, + const char *name, CURLoption tag, + const NameValue *nv, long lval); +CURLcode tool_setopt_httppost(CURL *curl, struct Configurable *config, + const char *name, CURLoption tag, + struct curl_httppost *httppost); +CURLcode tool_setopt_slist(CURL *curl, struct Configurable *config, + const char *name, CURLoption tag, + struct curl_slist *list); CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config, const char *name, CURLoption tag, ...); @@ -46,11 +83,23 @@ CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config, #define my_setopt_str(x,y,z) \ SETOPT_CHECK(tool_setopt(x, TRUE, config, #y, y, z)) +#define my_setopt_enum(x,y,z) \ + SETOPT_CHECK(tool_setopt_enum(x, config, #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)) + +#define my_setopt_httppost(x,y,z) \ + SETOPT_CHECK(tool_setopt_httppost(x, config, #y, y, z)) + +#define my_setopt_slist(x,y,z) \ + SETOPT_CHECK(tool_setopt_slist(x, config, #y, y, z)) + #define res_setopt(x,y,z) tool_setopt(x, FALSE, config, #y, y, z) #define res_setopt_str(x,y,z) tool_setopt(x, TRUE, config, #y, y, z) -#else +#else /* CURL_DISABLE_LIBCURL_OPTION */ /* No --libcurl, so pass options directly to library */ @@ -60,6 +109,18 @@ CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config, #define my_setopt_str(x,y,z) \ SETOPT_CHECK(curl_easy_setopt(x, y, z)) +#define my_setopt_enum(x,y,z) \ + SETOPT_CHECK(curl_easy_setopt(x, y, z)) + +#define my_setopt_flags(x,y,z) \ + SETOPT_CHECK(curl_easy_setopt(x, y, z)) + +#define my_setopt_httppost(x,y,z) \ + SETOPT_CHECK(curl_easy_setopt(x, y, z)) + +#define my_setopt_slist(x,y,z) \ + SETOPT_CHECK(curl_easy_setopt(x, y, z)) + #define res_setopt(x,y,z) curl_easy_setopt(x,y,z) #define res_setopt_str(x,y,z) curl_easy_setopt(x,y,z) -- cgit v1.2.1 From 919c97fa65a5c00f7044e849eeb0095408413505 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 6 Apr 2012 23:35:15 +0200 Subject: curl tool: use configuration files from lib directory Configuration files such as curl_config.h and all config-*.h no longer exist nor are generated/copied into 'src' directory, now these only exist in 'lib' directory from where curl tool sources uses them. Additionally old src/setup.h has been refactored into src/tool_setup.h which now pulls lib/setup.h The possibility of a makefile needing an include path adjustment exists. --- src/tool_setopt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/tool_setopt.h') diff --git a/src/tool_setopt.h b/src/tool_setopt.h index 4189addae..10134a6e7 100644 --- a/src/tool_setopt.h +++ b/src/tool_setopt.h @@ -21,7 +21,7 @@ * KIND, either express or implied. * ***************************************************************************/ -#include "setup.h" +#include "tool_setup.h" /* * Macros used in operate() -- cgit v1.2.1 From 94111bbbd4f2c875bc33c9c84f6e365c1a1434d7 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 19 Apr 2012 16:31:11 +0200 Subject: Take in account that CURLAUTH_* bitmasks are now 'unsigned long' - follow-up MIPSPro compiler detected curl_easy_getinfo() related missing adjustments. SunPro compiler detected curl tool --libcurl option related missing adjustments. --- src/tool_setopt.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/tool_setopt.h') diff --git a/src/tool_setopt.h b/src/tool_setopt.h index 10134a6e7..d107756b4 100644 --- a/src/tool_setopt.h +++ b/src/tool_setopt.h @@ -41,13 +41,18 @@ typedef struct { long value; } NameValue; +typedef struct { + const char *name; + unsigned long value; +} NameValueUnsigned; + extern const NameValue setopt_nv_CURLPROXY[]; -extern const NameValue setopt_nv_CURLAUTH[]; extern const NameValue setopt_nv_CURL_HTTP_VERSION[]; extern const NameValue setopt_nv_CURL_SSLVERSION[]; extern const NameValue setopt_nv_CURL_TIMECOND[]; extern const NameValue setopt_nv_CURLFTPSSL_CCC[]; extern const NameValue setopt_nv_CURLPROTO[]; +extern const NameValueUnsigned setopt_nv_CURLAUTH[]; /* Map options to NameValue sets */ #define setopt_nv_CURLOPT_HTTP_VERSION setopt_nv_CURL_HTTP_VERSION @@ -68,6 +73,9 @@ CURLcode tool_setopt_enum(CURL *curl, struct Configurable *config, CURLcode tool_setopt_flags(CURL *curl, struct Configurable *config, const char *name, CURLoption tag, const NameValue *nv, long lval); +CURLcode tool_setopt_bitmask(CURL *curl, struct Configurable *config, + const char *name, CURLoption tag, + const NameValueUnsigned *nv, long lval); CURLcode tool_setopt_httppost(CURL *curl, struct Configurable *config, const char *name, CURLoption tag, struct curl_httppost *httppost); @@ -89,6 +97,9 @@ CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config, #define my_setopt_flags(x,y,z) \ SETOPT_CHECK(tool_setopt_flags(x, config, #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)) + #define my_setopt_httppost(x,y,z) \ SETOPT_CHECK(tool_setopt_httppost(x, config, #y, y, z)) @@ -115,6 +126,9 @@ CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config, #define my_setopt_flags(x,y,z) \ SETOPT_CHECK(curl_easy_setopt(x, y, z)) +#define my_setopt_bitmask(x,y,z) \ + SETOPT_CHECK(curl_easy_setopt(x, y, z)) + #define my_setopt_httppost(x,y,z) \ SETOPT_CHECK(curl_easy_setopt(x, y, z)) -- cgit v1.2.1