1 #ifndef HEADER_CURL_TOOL_SETOPT_H
2 #define HEADER_CURL_TOOL_SETOPT_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at http://curl.haxx.se/docs/copyright.html.
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ***************************************************************************/
24 #include "tool_setup.h"
27 * Macros used in operate()
30 #define SETOPT_CHECK(v) do { \
36 #ifndef CURL_DISABLE_LIBCURL_OPTION
38 /* Associate symbolic names with option values */
49 extern const NameValue setopt_nv_CURLPROXY[];
50 extern const NameValue setopt_nv_CURL_HTTP_VERSION[];
51 extern const NameValue setopt_nv_CURL_SSLVERSION[];
52 extern const NameValue setopt_nv_CURL_TIMECOND[];
53 extern const NameValue setopt_nv_CURLFTPSSL_CCC[];
54 extern const NameValue setopt_nv_CURLUSESSL[];
55 extern const NameValue setopt_nv_CURL_NETRC[];
56 extern const NameValue setopt_nv_CURLPROTO[];
57 extern const NameValueUnsigned setopt_nv_CURLAUTH[];
59 /* Map options to NameValue sets */
60 #define setopt_nv_CURLOPT_HTTP_VERSION setopt_nv_CURL_HTTP_VERSION
61 #define setopt_nv_CURLOPT_HTTPAUTH setopt_nv_CURLAUTH
62 #define setopt_nv_CURLOPT_SSLVERSION setopt_nv_CURL_SSLVERSION
63 #define setopt_nv_CURLOPT_TIMECONDITION setopt_nv_CURL_TIMECOND
64 #define setopt_nv_CURLOPT_FTP_SSL_CCC setopt_nv_CURLFTPSSL_CCC
65 #define setopt_nv_CURLOPT_USE_SSL setopt_nv_CURLUSESSL
66 #define setopt_nv_CURLOPT_NETRC setopt_nv_CURL_NETRC
67 #define setopt_nv_CURLOPT_PROTOCOLS setopt_nv_CURLPROTO
68 #define setopt_nv_CURLOPT_REDIR_PROTOCOLS setopt_nv_CURLPROTO
69 #define setopt_nv_CURLOPT_PROXYTYPE setopt_nv_CURLPROXY
70 #define setopt_nv_CURLOPT_PROXYAUTH setopt_nv_CURLAUTH
72 /* Intercept setopt calls for --libcurl */
74 CURLcode tool_setopt_enum(CURL *curl, struct Configurable *config,
75 const char *name, CURLoption tag,
76 const NameValue *nv, long lval);
77 CURLcode tool_setopt_flags(CURL *curl, struct Configurable *config,
78 const char *name, CURLoption tag,
79 const NameValue *nv, long lval);
80 CURLcode tool_setopt_bitmask(CURL *curl, struct Configurable *config,
81 const char *name, CURLoption tag,
82 const NameValueUnsigned *nv, long lval);
83 CURLcode tool_setopt_httppost(CURL *curl, struct Configurable *config,
84 const char *name, CURLoption tag,
85 struct curl_httppost *httppost);
86 CURLcode tool_setopt_slist(CURL *curl, struct Configurable *config,
87 const char *name, CURLoption tag,
88 struct curl_slist *list);
89 CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config,
90 const char *name, CURLoption tag, ...);
92 #define my_setopt(x,y,z) \
93 SETOPT_CHECK(tool_setopt(x, FALSE, config, #y, y, z))
95 #define my_setopt_str(x,y,z) \
96 SETOPT_CHECK(tool_setopt(x, TRUE, config, #y, y, z))
98 #define my_setopt_enum(x,y,z) \
99 SETOPT_CHECK(tool_setopt_enum(x, config, #y, y, setopt_nv_ ## y, z))
101 #define my_setopt_flags(x,y,z) \
102 SETOPT_CHECK(tool_setopt_flags(x, config, #y, y, setopt_nv_ ## y, z))
104 #define my_setopt_bitmask(x,y,z) \
105 SETOPT_CHECK(tool_setopt_bitmask(x, config, #y, y, setopt_nv_ ## y, z))
107 #define my_setopt_httppost(x,y,z) \
108 SETOPT_CHECK(tool_setopt_httppost(x, config, #y, y, z))
110 #define my_setopt_slist(x,y,z) \
111 SETOPT_CHECK(tool_setopt_slist(x, config, #y, y, z))
113 #define res_setopt(x,y,z) tool_setopt(x, FALSE, config, #y, y, z)
115 #define res_setopt_str(x,y,z) tool_setopt(x, TRUE, config, #y, y, z)
117 #else /* CURL_DISABLE_LIBCURL_OPTION */
119 /* No --libcurl, so pass options directly to library */
121 #define my_setopt(x,y,z) \
122 SETOPT_CHECK(curl_easy_setopt(x, y, z))
124 #define my_setopt_str(x,y,z) \
125 SETOPT_CHECK(curl_easy_setopt(x, y, z))
127 #define my_setopt_enum(x,y,z) \
128 SETOPT_CHECK(curl_easy_setopt(x, y, z))
130 #define my_setopt_flags(x,y,z) \
131 SETOPT_CHECK(curl_easy_setopt(x, y, z))
133 #define my_setopt_bitmask(x,y,z) \
134 SETOPT_CHECK(curl_easy_setopt(x, y, z))
136 #define my_setopt_httppost(x,y,z) \
137 SETOPT_CHECK(curl_easy_setopt(x, y, z))
139 #define my_setopt_slist(x,y,z) \
140 SETOPT_CHECK(curl_easy_setopt(x, y, z))
142 #define res_setopt(x,y,z) curl_easy_setopt(x,y,z)
144 #define res_setopt_str(x,y,z) curl_easy_setopt(x,y,z)
146 #endif /* CURL_DISABLE_LIBCURL_OPTION */
148 #endif /* HEADER_CURL_TOOL_SETOPT_H */