2011-09-20 19:54:14 -04:00
|
|
|
#ifndef HEADER_CURL_TOOL_SETOPT_H
|
|
|
|
#define HEADER_CURL_TOOL_SETOPT_H
|
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2014-02-23 07:59:59 -05:00
|
|
|
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2011-09-20 19:54:14 -04:00
|
|
|
*
|
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
2016-02-02 18:19:02 -05:00
|
|
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
2011-09-20 19:54:14 -04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
2012-04-06 17:35:15 -04:00
|
|
|
#include "tool_setup.h"
|
2011-09-20 19:54:14 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Macros used in operate()
|
|
|
|
*/
|
2011-09-22 05:16:34 -04:00
|
|
|
|
2012-02-05 12:44:22 -05:00
|
|
|
#define SETOPT_CHECK(v) do { \
|
2014-12-16 02:35:47 -05:00
|
|
|
result = (v); \
|
|
|
|
if(result) \
|
2011-09-22 05:16:34 -04:00
|
|
|
goto show_error; \
|
2011-09-20 19:54:14 -04:00
|
|
|
} WHILE_FALSE
|
|
|
|
|
2012-02-05 12:44:22 -05:00
|
|
|
#ifndef CURL_DISABLE_LIBCURL_OPTION
|
|
|
|
|
2012-02-23 04:43:37 -05:00
|
|
|
/* Associate symbolic names with option values */
|
|
|
|
typedef struct {
|
|
|
|
const char *name;
|
|
|
|
long value;
|
|
|
|
} NameValue;
|
|
|
|
|
2012-04-19 10:31:11 -04:00
|
|
|
typedef struct {
|
|
|
|
const char *name;
|
|
|
|
unsigned long value;
|
|
|
|
} NameValueUnsigned;
|
|
|
|
|
2012-02-23 04:43:37 -05:00
|
|
|
extern const NameValue setopt_nv_CURLPROXY[];
|
2016-11-16 12:49:15 -05:00
|
|
|
extern const NameValue setopt_nv_CURL_SOCKS_PROXY[];
|
2012-02-23 04:43:37 -05:00
|
|
|
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[];
|
2013-07-22 13:43:08 -04:00
|
|
|
extern const NameValue setopt_nv_CURLUSESSL[];
|
2015-07-17 02:40:16 -04:00
|
|
|
extern const NameValueUnsigned setopt_nv_CURLSSLOPT[];
|
2013-07-22 14:03:27 -04:00
|
|
|
extern const NameValue setopt_nv_CURL_NETRC[];
|
2012-02-23 04:43:37 -05:00
|
|
|
extern const NameValue setopt_nv_CURLPROTO[];
|
2012-04-19 10:31:11 -04:00
|
|
|
extern const NameValueUnsigned setopt_nv_CURLAUTH[];
|
2012-02-23 04:43:37 -05:00
|
|
|
|
|
|
|
/* 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
|
2016-11-16 12:49:15 -05:00
|
|
|
#define setopt_nv_CURLOPT_PROXY_SSLVERSION setopt_nv_CURL_SSLVERSION
|
2012-02-23 04:43:37 -05:00
|
|
|
#define setopt_nv_CURLOPT_TIMECONDITION setopt_nv_CURL_TIMECOND
|
|
|
|
#define setopt_nv_CURLOPT_FTP_SSL_CCC setopt_nv_CURLFTPSSL_CCC
|
2013-07-22 13:43:08 -04:00
|
|
|
#define setopt_nv_CURLOPT_USE_SSL setopt_nv_CURLUSESSL
|
2015-07-17 02:40:16 -04:00
|
|
|
#define setopt_nv_CURLOPT_SSL_OPTIONS setopt_nv_CURLSSLOPT
|
2013-07-22 14:03:27 -04:00
|
|
|
#define setopt_nv_CURLOPT_NETRC setopt_nv_CURL_NETRC
|
2012-02-23 04:43:37 -05:00
|
|
|
#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
|
|
|
|
|
2012-02-05 12:44:22 -05:00
|
|
|
/* Intercept setopt calls for --libcurl */
|
|
|
|
|
2014-03-01 08:38:00 -05:00
|
|
|
CURLcode tool_setopt_enum(CURL *curl, struct GlobalConfig *config,
|
2012-02-23 04:43:37 -05:00
|
|
|
const char *name, CURLoption tag,
|
|
|
|
const NameValue *nv, long lval);
|
2014-03-01 08:38:00 -05:00
|
|
|
CURLcode tool_setopt_flags(CURL *curl, struct GlobalConfig *config,
|
2012-02-23 04:43:37 -05:00
|
|
|
const char *name, CURLoption tag,
|
|
|
|
const NameValue *nv, long lval);
|
2014-03-01 08:38:00 -05:00
|
|
|
CURLcode tool_setopt_bitmask(CURL *curl, struct GlobalConfig *config,
|
2012-04-19 10:31:11 -04:00
|
|
|
const char *name, CURLoption tag,
|
|
|
|
const NameValueUnsigned *nv, long lval);
|
2014-03-01 08:38:00 -05:00
|
|
|
CURLcode tool_setopt_httppost(CURL *curl, struct GlobalConfig *config,
|
2012-02-23 04:43:37 -05:00
|
|
|
const char *name, CURLoption tag,
|
|
|
|
struct curl_httppost *httppost);
|
2014-03-01 08:38:00 -05:00
|
|
|
CURLcode tool_setopt_slist(CURL *curl, struct GlobalConfig *config,
|
2012-02-23 04:43:37 -05:00
|
|
|
const char *name, CURLoption tag,
|
|
|
|
struct curl_slist *list);
|
2014-03-01 08:38:00 -05:00
|
|
|
CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *config,
|
2012-02-05 12:44:22 -05:00
|
|
|
const char *name, CURLoption tag, ...);
|
|
|
|
|
|
|
|
#define my_setopt(x,y,z) \
|
2014-03-01 08:38:00 -05:00
|
|
|
SETOPT_CHECK(tool_setopt(x, FALSE, global, #y, y, z))
|
2012-02-05 12:44:22 -05:00
|
|
|
|
|
|
|
#define my_setopt_str(x,y,z) \
|
2014-03-01 08:38:00 -05:00
|
|
|
SETOPT_CHECK(tool_setopt(x, TRUE, global, #y, y, z))
|
2011-09-20 19:54:14 -04:00
|
|
|
|
2012-02-23 04:43:37 -05:00
|
|
|
#define my_setopt_enum(x,y,z) \
|
2014-03-01 08:38:00 -05:00
|
|
|
SETOPT_CHECK(tool_setopt_enum(x, global, #y, y, setopt_nv_ ## y, z))
|
2012-02-23 04:43:37 -05:00
|
|
|
|
|
|
|
#define my_setopt_flags(x,y,z) \
|
2014-03-01 08:38:00 -05:00
|
|
|
SETOPT_CHECK(tool_setopt_flags(x, global, #y, y, setopt_nv_ ## y, z))
|
2012-02-23 04:43:37 -05:00
|
|
|
|
2012-04-19 10:31:11 -04:00
|
|
|
#define my_setopt_bitmask(x,y,z) \
|
2014-03-01 08:38:00 -05:00
|
|
|
SETOPT_CHECK(tool_setopt_bitmask(x, global, #y, y, setopt_nv_ ## y, z))
|
2012-04-19 10:31:11 -04:00
|
|
|
|
2012-02-23 04:43:37 -05:00
|
|
|
#define my_setopt_httppost(x,y,z) \
|
2014-03-01 08:38:00 -05:00
|
|
|
SETOPT_CHECK(tool_setopt_httppost(x, global, #y, y, z))
|
2012-02-23 04:43:37 -05:00
|
|
|
|
|
|
|
#define my_setopt_slist(x,y,z) \
|
2014-03-01 08:38:00 -05:00
|
|
|
SETOPT_CHECK(tool_setopt_slist(x, global, #y, y, z))
|
2012-02-23 04:43:37 -05:00
|
|
|
|
2014-03-01 08:38:00 -05:00
|
|
|
#define res_setopt(x,y,z) tool_setopt(x, FALSE, global, #y, y, z)
|
2011-09-20 19:54:14 -04:00
|
|
|
|
2014-03-01 08:38:00 -05:00
|
|
|
#define res_setopt_str(x,y,z) tool_setopt(x, TRUE, global, #y, y, z)
|
2011-09-20 19:54:14 -04:00
|
|
|
|
2012-02-23 04:43:37 -05:00
|
|
|
#else /* CURL_DISABLE_LIBCURL_OPTION */
|
2012-02-05 12:44:22 -05:00
|
|
|
|
|
|
|
/* No --libcurl, so pass options directly to library */
|
|
|
|
|
|
|
|
#define my_setopt(x,y,z) \
|
|
|
|
SETOPT_CHECK(curl_easy_setopt(x, y, z))
|
2011-09-20 19:54:14 -04:00
|
|
|
|
2012-02-05 12:44:22 -05:00
|
|
|
#define my_setopt_str(x,y,z) \
|
|
|
|
SETOPT_CHECK(curl_easy_setopt(x, y, z))
|
|
|
|
|
2012-02-23 04:43:37 -05:00
|
|
|
#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))
|
|
|
|
|
2012-04-19 10:31:11 -04:00
|
|
|
#define my_setopt_bitmask(x,y,z) \
|
|
|
|
SETOPT_CHECK(curl_easy_setopt(x, y, z))
|
|
|
|
|
2012-02-23 04:43:37 -05:00
|
|
|
#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))
|
|
|
|
|
2012-02-05 12:44:22 -05:00
|
|
|
#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 */
|