-
Notifications
You must be signed in to change notification settings - Fork 0
/
opt.go
292 lines (284 loc) · 12.6 KB
/
opt.go
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
package curl
//#include <curl/curl.h>
import "C"
type EasyOption int
// long options (0)
const (
OPT_ACCEPTTIMEOUT_MS = C.CURLOPT_ACCEPTTIMEOUT_MS
OPT_ADDRESS_SCOPE = C.CURLOPT_ADDRESS_SCOPE
OPT_APPEND = C.CURLOPT_APPEND
OPT_AUTOREFERER = C.CURLOPT_AUTOREFERER
OPT_BUFFERSIZE = C.CURLOPT_BUFFERSIZE
OPT_CERTINFO = C.CURLOPT_CERTINFO
OPT_CLOSEPOLICY = C.CURLOPT_CLOSEPOLICY
OPT_CONNECTTIMEOUT = C.CURLOPT_CONNECTTIMEOUT
OPT_CONNECTTIMEOUT_MS = C.CURLOPT_CONNECTTIMEOUT_MS
OPT_CONNECT_ONLY = C.CURLOPT_CONNECT_ONLY
OPT_COOKIESESSION = C.CURLOPT_COOKIESESSION
OPT_CRLF = C.CURLOPT_CRLF
OPT_DIRLISTONLY = C.CURLOPT_DIRLISTONLY
OPT_DNS_CACHE_TIMEOUT = C.CURLOPT_DNS_CACHE_TIMEOUT
OPT_DNS_USE_GLOBAL_CACHE = C.CURLOPT_DNS_USE_GLOBAL_CACHE
OPT_FAILONERROR = C.CURLOPT_FAILONERROR
OPT_FILETIME = C.CURLOPT_FILETIME
OPT_FOLLOWLOCATION = C.CURLOPT_FOLLOWLOCATION
OPT_FORBID_REUSE = C.CURLOPT_FORBID_REUSE
OPT_FRESH_CONNECT = C.CURLOPT_FRESH_CONNECT
OPT_FTPSSLAUTH = C.CURLOPT_FTPSSLAUTH
OPT_FTP_CREATE_MISSING_DIRS = C.CURLOPT_FTP_CREATE_MISSING_DIRS
OPT_FTP_FILEMETHOD = C.CURLOPT_FTP_FILEMETHOD
OPT_FTP_RESPONSE_TIMEOUT = C.CURLOPT_FTP_RESPONSE_TIMEOUT
OPT_FTP_SKIP_PASV_IP = C.CURLOPT_FTP_SKIP_PASV_IP
OPT_FTP_SSL_CCC = C.CURLOPT_FTP_SSL_CCC
OPT_FTP_USE_EPRT = C.CURLOPT_FTP_USE_EPRT
OPT_FTP_USE_EPSV = C.CURLOPT_FTP_USE_EPSV
OPT_FTP_USE_PRET = C.CURLOPT_FTP_USE_PRET
OPT_GSSAPI_DELEGATION = C.CURLOPT_GSSAPI_DELEGATION
OPT_HEADER = C.CURLOPT_HEADER
OPT_HTTPAUTH = C.CURLOPT_HTTPAUTH
OPT_HTTPGET = C.CURLOPT_HTTPGET
OPT_HTTPPROXYTUNNEL = C.CURLOPT_HTTPPROXYTUNNEL
OPT_HTTP_CONTENT_DECODING = C.CURLOPT_HTTP_CONTENT_DECODING
OPT_HTTP_TRANSFER_DECODING = C.CURLOPT_HTTP_TRANSFER_DECODING
OPT_HTTP_VERSION = C.CURLOPT_HTTP_VERSION
OPT_IGNORE_CONTENT_LENGTH = C.CURLOPT_IGNORE_CONTENT_LENGTH
OPT_INFILESIZE = C.CURLOPT_INFILESIZE
OPT_IPRESOLVE = C.CURLOPT_IPRESOLVE
OPT_LOCALPORT = C.CURLOPT_LOCALPORT
OPT_LOCALPORTRANGE = C.CURLOPT_LOCALPORTRANGE
OPT_LOW_SPEED_LIMIT = C.CURLOPT_LOW_SPEED_LIMIT
OPT_LOW_SPEED_TIME = C.CURLOPT_LOW_SPEED_TIME
OPT_MAXCONNECTS = C.CURLOPT_MAXCONNECTS
OPT_MAXFILESIZE = C.CURLOPT_MAXFILESIZE
OPT_MAXREDIRS = C.CURLOPT_MAXREDIRS
OPT_NETRC = C.CURLOPT_NETRC
OPT_NEW_DIRECTORY_PERMS = C.CURLOPT_NEW_DIRECTORY_PERMS
OPT_NEW_FILE_PERMS = C.CURLOPT_NEW_FILE_PERMS
OPT_NOBODY = C.CURLOPT_NOBODY
OPT_NOPROGRESS = C.CURLOPT_NOPROGRESS
OPT_NOSIGNAL = C.CURLOPT_NOSIGNAL
OPT_PORT = C.CURLOPT_PORT
OPT_POST = C.CURLOPT_POST
OPT_POSTFIELDSIZE = C.CURLOPT_POSTFIELDSIZE
OPT_POSTREDIR = C.CURLOPT_POSTREDIR
OPT_PROTOCOLS = C.CURLOPT_PROTOCOLS
OPT_PROXYAUTH = C.CURLOPT_PROXYAUTH
OPT_PROXYPORT = C.CURLOPT_PROXYPORT
OPT_PROXYTYPE = C.CURLOPT_PROXYTYPE
OPT_PROXY_TRANSFER_MODE = C.CURLOPT_PROXY_TRANSFER_MODE
OPT_PUT = C.CURLOPT_PUT
OPT_REDIR_PROTOCOLS = C.CURLOPT_REDIR_PROTOCOLS
OPT_RESUME_FROM = C.CURLOPT_RESUME_FROM
OPT_RTSP_CLIENT_CSEQ = C.CURLOPT_RTSP_CLIENT_CSEQ
OPT_RTSP_REQUEST = C.CURLOPT_RTSP_REQUEST
OPT_RTSP_SERVER_CSEQ = C.CURLOPT_RTSP_SERVER_CSEQ
OPT_SOCKS5_GSSAPI_NEC = C.CURLOPT_SOCKS5_GSSAPI_NEC
OPT_SSH_AUTH_TYPES = C.CURLOPT_SSH_AUTH_TYPES
OPT_SSLENGINE_DEFAULT = C.CURLOPT_SSLENGINE_DEFAULT
OPT_SSLVERSION = C.CURLOPT_SSLVERSION
OPT_SSL_OPTIONS = C.CURLOPT_SSL_OPTIONS
OPT_SSL_SESSIONID_CACHE = C.CURLOPT_SSL_SESSIONID_CACHE
OPT_SSL_VERIFYHOST = C.CURLOPT_SSL_VERIFYHOST
OPT_SSL_VERIFYPEER = C.CURLOPT_SSL_VERIFYPEER
OPT_TCP_KEEPALIVE = C.CURLOPT_TCP_KEEPALIVE
OPT_TCP_KEEPIDLE = C.CURLOPT_TCP_KEEPIDLE
OPT_TCP_KEEPINTVL = C.CURLOPT_TCP_KEEPINTVL
OPT_TCP_NODELAY = C.CURLOPT_TCP_NODELAY
OPT_TFTP_BLKSIZE = C.CURLOPT_TFTP_BLKSIZE
OPT_TIMECONDITION = C.CURLOPT_TIMECONDITION
OPT_TIMEOUT = C.CURLOPT_TIMEOUT
OPT_TIMEOUT_MS = C.CURLOPT_TIMEOUT_MS
OPT_TIMEVALUE = C.CURLOPT_TIMEVALUE
OPT_TRANSFERTEXT = C.CURLOPT_TRANSFERTEXT
OPT_TRANSFER_ENCODING = C.CURLOPT_TRANSFER_ENCODING
OPT_UNRESTRICTED_AUTH = C.CURLOPT_UNRESTRICTED_AUTH
OPT_UPLOAD = C.CURLOPT_UPLOAD
OPT_USE_SSL = C.CURLOPT_USE_SSL
OPT_VERBOSE = C.CURLOPT_VERBOSE
OPT_WILDCARDMATCH = C.CURLOPT_WILDCARDMATCH
)
// object pointer options (10000)
const (
OPT_ACCEPT_ENCODING = C.CURLOPT_ACCEPT_ENCODING // string
OPT_CAINFO = C.CURLOPT_CAINFO //string
OPT_CAPATH = C.CURLOPT_CAPATH //string
OPT_CHUNK_DATA = C.CURLOPT_CHUNK_DATA //ptr for CHUNK_BGN_FUNCTION, CHUNK_END_FUNCTION
OPT_CLOSESOCKETDATA = C.CURLOPT_CLOSESOCKETDATA //ptr for CLOSESOCKETFUNCTION
OPT_COOKIE = C.CURLOPT_COOKIE //string
OPT_COOKIEFILE = C.CURLOPT_COOKIEFILE //string
OPT_COOKIEJAR = C.CURLOPT_COOKIEJAR //string
OPT_COOKIELIST = C.CURLOPT_COOKIELIST //string
OPT_COPYPOSTFIELDS = C.CURLOPT_COPYPOSTFIELDS //buffer, length in POSTFIELDSIZE or POSTFIELDSIZE_LARGE
OPT_CRLFILE = C.CURLOPT_CRLFILE //string
OPT_CUSTOMREQUEST = C.CURLOPT_CUSTOMREQUEST //string
OPT_DEBUGDATA = C.CURLOPT_DEBUGDATA //ptr for DEBUGFUNCTION
OPT_DNS_SERVERS = C.CURLOPT_DNS_SERVERS //string
OPT_EGDSOCKET = C.CURLOPT_EGDSOCKET //string
//OPT_ERRORBUFFER = C.CURLOPT_ERRORBUFFER //internal
OPT_FNMATCH_DATA = C.CURLOPT_FNMATCH_DATA //ptr for FNMATCH_FUNCTION
OPT_FTPPORT = C.CURLOPT_FTPPORT //string
OPT_FTP_ACCOUNT = C.CURLOPT_FTP_ACCOUNT //string
OPT_FTP_ALTERNATIVE_TO_USER = C.CURLOPT_FTP_ALTERNATIVE_TO_USER //string
OPT_HEADERDATA = C.CURLOPT_HEADERDATA //ptr for HEADERFUNCTION (or WRITEFUNCTION)
OPT_HTTP200ALIASES = C.CURLOPT_HTTP200ALIASES //slist
OPT_HTTPHEADER = C.CURLOPT_HTTPHEADER //slist, NULL to reset
OPT_HTTPPOST = C.CURLOPT_HTTPPOST //form
OPT_INTERFACE = C.CURLOPT_INTERFACE //string
OPT_INTERLEAVEDATA = C.CURLOPT_INTERLEAVEDATA //ptr for INTERLEAVEFUNCTION
OPT_IOCTLDATA = C.CURLOPT_IOCTLDATA //ptr for IOCTLFUNCTION
OPT_ISSUERCERT = C.CURLOPT_ISSUERCERT //string
OPT_KEYPASSWD = C.CURLOPT_KEYPASSWD //string
OPT_KRBLEVEL = C.CURLOPT_KRBLEVEL //string
OPT_MAIL_AUTH = C.CURLOPT_MAIL_AUTH //string
OPT_MAIL_FROM = C.CURLOPT_MAIL_FROM //string
OPT_MAIL_RCPT = C.CURLOPT_MAIL_RCPT //slist
OPT_NETRC_FILE = C.CURLOPT_NETRC_FILE //string
OPT_NOPROXY = C.CURLOPT_NOPROXY //string
OPT_OPENSOCKETDATA = C.CURLOPT_OPENSOCKETDATA //ptr for OPENSOCKETFUNCTION
OPT_PASSWORD = C.CURLOPT_PASSWORD //string
OPT_POSTFIELDS = C.CURLOPT_POSTFIELDS //string
OPT_POSTQUOTE = C.CURLOPT_POSTQUOTE //slist, NULL to reset
OPT_PREQUOTE = C.CURLOPT_PREQUOTE //slist, NULL to reset
OPT_PRIVATE = C.CURLOPT_PRIVATE //ptr, curl_easy_getinfo(CURLINFO_PRIVATE) to retrieve
OPT_PROGRESSDATA = C.CURLOPT_PROGRESSDATA //ptr for PROGRESSFUNCTION
OPT_PROXY = C.CURLOPT_PROXY //string
OPT_PROXYPASSWORD = C.CURLOPT_PROXYPASSWORD //string
OPT_PROXYUSERNAME = C.CURLOPT_PROXYUSERNAME //string
OPT_PROXYUSERPWD = C.CURLOPT_PROXYUSERPWD //string
OPT_QUOTE = C.CURLOPT_QUOTE //slist, NULL to reset
OPT_RANDOM_FILE = C.CURLOPT_RANDOM_FILE //string
OPT_RANGE = C.CURLOPT_RANGE //string
OPT_REFERER = C.CURLOPT_REFERER //string
OPT_RESOLVE = C.CURLOPT_RESOLVE //slist
OPT_RTSP_SESSION_ID = C.CURLOPT_RTSP_SESSION_ID //string
OPT_RTSP_STREAM_URI = C.CURLOPT_RTSP_STREAM_URI //string
OPT_RTSP_TRANSPORT = C.CURLOPT_RTSP_TRANSPORT //string
OPT_SEEKDATA = C.CURLOPT_SEEKDATA //ptr for SEEKFUNCTION
//OPT_SHARE = C.CURLOPT_SHARE //ptr to share handle
OPT_SOCKOPTDATA = C.CURLOPT_SOCKOPTDATA //ptr for SOCKOPTFUNCTION
OPT_SOCKS5_GSSAPI_SERVICE = C.CURLOPT_SOCKS5_GSSAPI_SERVICE //string
OPT_SSH_HOST_PUBLIC_KEY_MD5 = C.CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 //string
OPT_SSH_KEYDATA = C.CURLOPT_SSH_KEYDATA //ptr for SSH_KEYFUNCTION
OPT_SSH_KNOWNHOSTS = C.CURLOPT_SSH_KNOWNHOSTS //string
OPT_SSH_PRIVATE_KEYFILE = C.CURLOPT_SSH_PRIVATE_KEYFILE //string
OPT_SSH_PUBLIC_KEYFILE = C.CURLOPT_SSH_PUBLIC_KEYFILE //string
OPT_SSLCERT = C.CURLOPT_SSLCERT //string
OPT_SSLCERTTYPE = C.CURLOPT_SSLCERTTYPE //string
OPT_SSLENGINE = C.CURLOPT_SSLENGINE //string
OPT_SSLKEY = C.CURLOPT_SSLKEY //string
OPT_SSLKEYTYPE = C.CURLOPT_SSLKEYTYPE //string
OPT_SSL_CIPHER_LIST = C.CURLOPT_SSL_CIPHER_LIST //string
OPT_SSL_CTX_DATA = C.CURLOPT_SSL_CTX_DATA //ptr for SSL_CTX_FUNCTION
//OPT_STDERR = C.CURLOPT_STDERR //FILE*
OPT_TELNETOPTIONS = C.CURLOPT_TELNETOPTIONS //slist
OPT_TLSAUTH_PASSWORD = C.CURLOPT_TLSAUTH_PASSWORD //string
OPT_TLSAUTH_TYPE = C.CURLOPT_TLSAUTH_TYPE //string
OPT_TLSAUTH_USERNAME = C.CURLOPT_TLSAUTH_USERNAME //string
OPT_URL = C.CURLOPT_URL //string
OPT_USERAGENT = C.CURLOPT_USERAGENT //string
OPT_USERNAME = C.CURLOPT_USERNAME //string
OPT_USERPWD = C.CURLOPT_USERPWD //string
OPT_WRITEDATA = C.CURLOPT_WRITEDATA //ptr for WRITEFUNCTION
)
// function pointer options (20000)
const (
OPT_CHUNK_BGN_FUNCTION = C.CURLOPT_CHUNK_BGN_FUNCTION
OPT_CHUNK_END_FUNCTION = C.CURLOPT_CHUNK_END_FUNCTION
OPT_CLOSESOCKETFUNCTION = C.CURLOPT_CLOSESOCKETFUNCTION
OPT_CONV_FROM_NETWORK_FUNCTION = C.CURLOPT_CONV_FROM_NETWORK_FUNCTION
OPT_CONV_FROM_UTF8_FUNCTION = C.CURLOPT_CONV_FROM_UTF8_FUNCTION
OPT_CONV_TO_NETWORK_FUNCTION = C.CURLOPT_CONV_TO_NETWORK_FUNCTION
OPT_DEBUGFUNCTION = C.CURLOPT_DEBUGFUNCTION
OPT_FNMATCH_FUNCTION = C.CURLOPT_FNMATCH_FUNCTION
OPT_HEADERFUNCTION = C.CURLOPT_HEADERFUNCTION
OPT_INTERLEAVEFUNCTION = C.CURLOPT_INTERLEAVEFUNCTION
OPT_IOCTLFUNCTION = C.CURLOPT_IOCTLFUNCTION
OPT_OPENSOCKETFUNCTION = C.CURLOPT_OPENSOCKETFUNCTION
OPT_PROGRESSFUNCTION = C.CURLOPT_PROGRESSFUNCTION
OPT_READFUNCTION = C.CURLOPT_READFUNCTION
OPT_SEEKFUNCTION = C.CURLOPT_SEEKFUNCTION
OPT_SOCKOPTFUNCTION = C.CURLOPT_SOCKOPTFUNCTION
OPT_SSH_KEYFUNCTION = C.CURLOPT_SSH_KEYFUNCTION
OPT_SSL_CTX_FUNCTION = C.CURLOPT_SSL_CTX_FUNCTION
OPT_WRITEFUNCTION = C.CURLOPT_WRITEFUNCTION
)
// off_t options (30000)
const (
OPT_INFILESIZE_LARGE = C.CURLOPT_INFILESIZE_LARGE
OPT_MAXFILESIZE_LARGE = C.CURLOPT_MAXFILESIZE_LARGE
OPT_MAX_RECV_SPEED_LARGE = C.CURLOPT_MAX_RECV_SPEED_LARGE
OPT_MAX_SEND_SPEED_LARGE = C.CURLOPT_MAX_SEND_SPEED_LARGE
OPT_POSTFIELDSIZE_LARGE = C.CURLOPT_POSTFIELDSIZE_LARGE
OPT_RESUME_FROM_LARGE = C.CURLOPT_RESUME_FROM_LARGE
)
func isStringOption(opt EasyOption) bool {
switch opt {
case OPT_CAINFO: fallthrough
case OPT_CAPATH: fallthrough
case OPT_COOKIE: fallthrough
case OPT_COOKIEFILE: fallthrough
case OPT_COOKIEJAR: fallthrough
case OPT_COOKIELIST: fallthrough
case OPT_CRLFILE: fallthrough
case OPT_CUSTOMREQUEST: fallthrough
case OPT_DNS_SERVERS: fallthrough
case OPT_EGDSOCKET: fallthrough
case OPT_FTPPORT: fallthrough
case OPT_FTP_ACCOUNT: fallthrough
case OPT_FTP_ALTERNATIVE_TO_USER: fallthrough
case OPT_INTERFACE: fallthrough
case OPT_ISSUERCERT: fallthrough
case OPT_KEYPASSWD: fallthrough
case OPT_KRBLEVEL: fallthrough
case OPT_MAIL_AUTH: fallthrough
case OPT_MAIL_FROM: fallthrough
case OPT_NETRC_FILE: fallthrough
case OPT_NOPROXY: fallthrough
case OPT_PASSWORD: fallthrough
case OPT_POSTFIELDS: fallthrough
case OPT_PROXY: fallthrough
case OPT_PROXYPASSWORD: fallthrough
case OPT_PROXYUSERNAME: fallthrough
case OPT_PROXYUSERPWD: fallthrough
case OPT_RANDOM_FILE: fallthrough
case OPT_RANGE: fallthrough
case OPT_REFERER: fallthrough
case OPT_RTSP_SESSION_ID: fallthrough
case OPT_RTSP_STREAM_URI: fallthrough
case OPT_RTSP_TRANSPORT: fallthrough
case OPT_SOCKS5_GSSAPI_SERVICE: fallthrough
case OPT_SSH_HOST_PUBLIC_KEY_MD5: fallthrough
case OPT_SSH_KNOWNHOSTS: fallthrough
case OPT_SSH_PRIVATE_KEYFILE: fallthrough
case OPT_SSH_PUBLIC_KEYFILE: fallthrough
case OPT_SSLCERT: fallthrough
case OPT_SSLCERTTYPE: fallthrough
case OPT_SSLENGINE: fallthrough
case OPT_SSLKEY: fallthrough
case OPT_SSLKEYTYPE: fallthrough
case OPT_SSL_CIPHER_LIST: fallthrough
case OPT_TLSAUTH_PASSWORD: fallthrough
case OPT_TLSAUTH_TYPE: fallthrough
case OPT_TLSAUTH_USERNAME: fallthrough
case OPT_URL: fallthrough
case OPT_USERAGENT: fallthrough
case OPT_USERNAME: fallthrough
case OPT_USERPWD:
return true
}
return false
}
func isStringList(opt EasyOption) bool {
switch opt {
case OPT_HTTP200ALIASES: fallthrough
case OPT_HTTPHEADER: fallthrough
case OPT_MAIL_RCPT: fallthrough
case OPT_POSTQUOTE: fallthrough
case OPT_PREQUOTE: fallthrough
case OPT_QUOTE: fallthrough
case OPT_RESOLVE: fallthrough
case OPT_TELNETOPTIONS:
return true
}
return false
}