1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
#ifndef HEADER_CURL_TOOL_SETOPT_H
#define HEADER_CURL_TOOL_SETOPT_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, 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 "tool_setup.h"
/*
* Macros used in operate()
*/
#define SETOPT_CHECK(v) do { \
res = (v); \
if(res) \
goto show_error; \
} WHILE_FALSE
#ifndef CURL_DISABLE_LIBCURL_OPTION
/* Associate symbolic names with option values */
typedef struct {
const char *name;
long value;
} NameValue;
typedef struct {
const char *name;
unsigned long value;
} NameValueUnsigned;
extern const NameValue setopt_nv_CURLPROXY[];
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
#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_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);
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, ...);
#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 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_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))
#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 /* CURL_DISABLE_LIBCURL_OPTION */
/* 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 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_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))
#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)
#endif /* CURL_DISABLE_LIBCURL_OPTION */
#endif /* HEADER_CURL_TOOL_SETOPT_H */
|