curb 0.5.8.0-x86-darwin-10

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of curb might be problematic. Click here for more details.

@@ -0,0 +1,103 @@
1
+ /* curb_easy.h - Curl easy mode
2
+ * Copyright (c)2006 Ross Bamford.
3
+ * Licensed under the Ruby License. See LICENSE for details.
4
+ *
5
+ * $Id: curb_easy.h 25 2006-12-07 23:38:25Z roscopeco $
6
+ */
7
+ #ifndef __CURB_EASY_H
8
+ #define __CURB_EASY_H
9
+
10
+ #include "curb.h"
11
+
12
+ #include <curl/easy.h>
13
+
14
+ /* a lot of this *could* be kept in the handler itself,
15
+ * but then we lose the ability to query it's status.
16
+ */
17
+ typedef struct {
18
+ /* The handler */
19
+ CURL *curl;
20
+
21
+ /* Objects we associate */
22
+ VALUE url;
23
+ VALUE proxy_url;
24
+
25
+ VALUE body_proc;
26
+ VALUE header_proc;
27
+ VALUE body_data; /* Holds the response body from the last call to curl_easy_perform */
28
+ VALUE header_data; /* unless a block is supplied (they'll be nil) */
29
+ VALUE progress_proc;
30
+ VALUE debug_proc;
31
+ VALUE interface_hm;
32
+ VALUE userpwd;
33
+ VALUE proxypwd;
34
+ VALUE headers; /* ruby array of strings with headers to set */
35
+ VALUE cookies; /* string */
36
+ VALUE cookiefile; /* filename */
37
+ VALUE cookiejar; /* filename */
38
+ VALUE cert;
39
+ VALUE cacert;
40
+ VALUE certpassword;
41
+ VALUE certtype;
42
+ VALUE encoding;
43
+ VALUE useragent;
44
+
45
+ VALUE success_proc;
46
+ VALUE failure_proc;
47
+ VALUE complete_proc;
48
+
49
+ /* Other opts */
50
+ unsigned short local_port; // 0 is no port
51
+ unsigned short local_port_range; // " " " "
52
+ unsigned short proxy_port; // " " " "
53
+ int proxy_type;
54
+ long http_auth_types;
55
+ long proxy_auth_types;
56
+ long max_redirs;
57
+ unsigned long timeout;
58
+ unsigned long connect_timeout;
59
+ long dns_cache_timeout;
60
+ unsigned long ftp_response_timeout;
61
+
62
+ /* bool flags */
63
+ char proxy_tunnel;
64
+ char fetch_file_time;
65
+ char ssl_verify_peer;
66
+ char ssl_verify_host;
67
+ char header_in_body;
68
+ char use_netrc;
69
+ char follow_location;
70
+ char unrestricted_auth;
71
+ char verbose;
72
+ char multipart_form_post;
73
+ char enable_cookies;
74
+
75
+ /* this is sometimes used as a buffer for a form data string,
76
+ * which we alloc in C and need to hang around for the call,
77
+ * and in case it's asked for before the next call.
78
+ */
79
+ VALUE postdata_buffer;
80
+
81
+ /* when added to a multi handle these buffers are needed
82
+ * when the easy handle isn't supplied the body proc
83
+ * or a custom http header is passed.
84
+ */
85
+ VALUE bodybuf;
86
+ VALUE headerbuf;
87
+ struct curl_slist *curl_headers;
88
+
89
+ VALUE self; /* pointer to self, used by multi interface */
90
+ VALUE upload; /* pointer to an active upload otherwise Qnil */
91
+
92
+ int last_result; /* last result code from multi loop */
93
+
94
+ } ruby_curl_easy;
95
+
96
+ extern VALUE cCurlEasy;
97
+
98
+ VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce, VALUE *bodybuf, VALUE *headerbuf, struct curl_slist **headers);
99
+ VALUE ruby_curl_easy_cleanup(VALUE self, ruby_curl_easy *rbce, VALUE bodybuf, VALUE headerbuf, struct curl_slist *headers);
100
+
101
+ void init_curb_easy();
102
+
103
+ #endif
Binary file
@@ -0,0 +1,630 @@
1
+ /* curb_errors.c - Ruby exception types for curl errors
2
+ * Copyright (c)2006 Ross Bamford.
3
+ * Licensed under the Ruby License. See LICENSE for details.
4
+ *
5
+ * $Id: curb_errors.c 10 2006-11-20 00:17:30Z roscopeco $
6
+ */
7
+ #include "curb_errors.h"
8
+
9
+ extern VALUE mCurl;
10
+
11
+ #ifdef RDOC_NEVER_DEFINED
12
+ mCurl = rb_define_module("Curl");
13
+ #endif
14
+
15
+ /* base errors */
16
+ VALUE mCurlErr;
17
+ VALUE eCurlErrError;
18
+ VALUE eCurlErrFTPError;
19
+ VALUE eCurlErrHTTPError;
20
+ VALUE eCurlErrFileError;
21
+ VALUE eCurlErrLDAPError;
22
+ VALUE eCurlErrTelnetError;
23
+ VALUE eCurlErrTFTPError;
24
+
25
+ /* Specific libcurl errors */
26
+ VALUE eCurlErrUnsupportedProtocol;
27
+ VALUE eCurlErrFailedInit;
28
+ VALUE eCurlErrMalformedURL;
29
+ VALUE eCurlErrMalformedURLUser;
30
+ VALUE eCurlErrProxyResolution;
31
+ VALUE eCurlErrHostResolution;
32
+ VALUE eCurlErrConnectFailed;
33
+ VALUE eCurlErrFTPWierdReply;
34
+ VALUE eCurlErrFTPAccessDenied;
35
+ VALUE eCurlErrFTPBadPassword;
36
+ VALUE eCurlErrFTPWierdPassReply;
37
+ VALUE eCurlErrFTPWierdUserReply;
38
+ VALUE eCurlErrFTPWierdPasvReply;
39
+ VALUE eCurlErrFTPWierd227Format;
40
+ VALUE eCurlErrFTPCantGetHost;
41
+ VALUE eCurlErrFTPCantReconnect;
42
+ VALUE eCurlErrFTPCouldntSetBinary;
43
+ VALUE eCurlErrPartialFile;
44
+ VALUE eCurlErrFTPCouldntRetrFile;
45
+ VALUE eCurlErrFTPWrite;
46
+ VALUE eCurlErrFTPQuote;
47
+ VALUE eCurlErrHTTPFailed;
48
+ VALUE eCurlErrWriteError;
49
+ VALUE eCurlErrMalformedUser;
50
+ VALUE eCurlErrFTPCouldntStorFile;
51
+ VALUE eCurlErrReadError;
52
+ VALUE eCurlErrOutOfMemory;
53
+ VALUE eCurlErrTimeout;
54
+ VALUE eCurlErrFTPCouldntSetASCII;
55
+ VALUE eCurlErrFTPPortFailed;
56
+ VALUE eCurlErrFTPCouldntUseRest;
57
+ VALUE eCurlErrFTPCouldntGetSize;
58
+ VALUE eCurlErrHTTPRange;
59
+ VALUE eCurlErrHTTPPost;
60
+ VALUE eCurlErrSSLConnectError;
61
+ VALUE eCurlErrBadResume;
62
+ VALUE eCurlErrFileCouldntRead;
63
+ VALUE eCurlErrLDAPCouldntBind;
64
+ VALUE eCurlErrLDAPSearchFailed;
65
+ VALUE eCurlErrLibraryNotFound;
66
+ VALUE eCurlErrFunctionNotFound;
67
+ VALUE eCurlErrAbortedByCallback;
68
+ VALUE eCurlErrBadFunctionArgument;
69
+ VALUE eCurlErrBadCallingOrder;
70
+ VALUE eCurlErrInterfaceFailed;
71
+ VALUE eCurlErrBadPasswordEntered;
72
+ VALUE eCurlErrTooManyRedirects;
73
+ VALUE eCurlErrTelnetUnknownOption;
74
+ VALUE eCurlErrTelnetBadOptionSyntax;
75
+ VALUE eCurlErrObsolete;
76
+ VALUE eCurlErrSSLPeerCertificate;
77
+ VALUE eCurlErrGotNothing;
78
+ VALUE eCurlErrSSLEngineNotFound;
79
+ VALUE eCurlErrSSLEngineSetFailed;
80
+ VALUE eCurlErrSendError;
81
+ VALUE eCurlErrRecvError;
82
+ VALUE eCurlErrShareInUse;
83
+ VALUE eCurlErrSSLCertificate;
84
+ VALUE eCurlErrSSLCipher;
85
+ VALUE eCurlErrSSLCACertificate;
86
+ VALUE eCurlErrBadContentEncoding;
87
+ VALUE eCurlErrLDAPInvalidURL;
88
+ VALUE eCurlErrFileSizeExceeded;
89
+ VALUE eCurlErrFTPSSLFailed;
90
+ VALUE eCurlErrSendFailedRewind;
91
+ VALUE eCurlErrSSLEngineInitFailed;
92
+ VALUE eCurlErrLoginDenied;
93
+ VALUE eCurlErrTFTPNotFound;
94
+ VALUE eCurlErrTFTPPermission;
95
+ VALUE eCurlErrTFTPDiskFull;
96
+ VALUE eCurlErrTFTPIllegalOperation;
97
+ VALUE eCurlErrTFTPUnknownID;
98
+ VALUE eCurlErrTFTPFileExists;
99
+ VALUE eCurlErrTFTPNoSuchUser;
100
+
101
+ VALUE eCurlErrConvFailed;
102
+ VALUE eCurlErrConvReqd;
103
+ VALUE eCurlErrSSLCacertBadfile;
104
+ VALUE eCurlErrRemoteFileNotFound;
105
+ VALUE eCurlErrSSH;
106
+ VALUE eCurlErrSSLShutdownFailed;
107
+ VALUE eCurlErrAgain;
108
+ VALUE eCurlErrSSLCRLBadfile;
109
+ VALUE eCurlErrSSLIssuerError;
110
+
111
+ /* multi errors */
112
+ VALUE mCurlErrCallMultiPerform;
113
+ VALUE mCurlErrBadHandle;
114
+ VALUE mCurlErrBadEasyHandle;
115
+ VALUE mCurlErrOutOfMemory;
116
+ VALUE mCurlErrInternalError;
117
+ VALUE mCurlErrBadSocket;
118
+ VALUE mCurlErrUnknownOption;
119
+
120
+ /* binding errors */
121
+ VALUE eCurlErrInvalidPostField;
122
+
123
+
124
+ VALUE rb_curl_easy_error(CURLcode code) {
125
+ VALUE exclz;
126
+ const char *exmsg = NULL;
127
+ VALUE results;
128
+
129
+ switch (code) {
130
+ case CURLE_UNSUPPORTED_PROTOCOL: /* 1 */
131
+ exclz = eCurlErrUnsupportedProtocol;
132
+ break;
133
+ case CURLE_FAILED_INIT: /* 2 */
134
+ exclz = eCurlErrFailedInit;
135
+ break;
136
+ case CURLE_URL_MALFORMAT: /* 3 */
137
+ exclz = eCurlErrMalformedURL;
138
+ break;
139
+ case CURLE_URL_MALFORMAT_USER: /* 4 (NOT USED) */
140
+ exclz = eCurlErrMalformedURLUser;
141
+ break;
142
+ case CURLE_COULDNT_RESOLVE_PROXY: /* 5 */
143
+ exclz = eCurlErrProxyResolution;
144
+ break;
145
+ case CURLE_COULDNT_RESOLVE_HOST: /* 6 */
146
+ exclz = eCurlErrHostResolution;
147
+ break;
148
+ case CURLE_COULDNT_CONNECT: /* 7 */
149
+ exclz = eCurlErrConnectFailed;
150
+ break;
151
+ case CURLE_FTP_WEIRD_SERVER_REPLY: /* 8 */
152
+ exclz = eCurlErrFTPWierdReply;
153
+ break;
154
+ case CURLE_FTP_ACCESS_DENIED: /* 9 denied due to lack of access. */
155
+ exclz = eCurlErrFTPAccessDenied;
156
+ break;
157
+ case CURLE_FTP_USER_PASSWORD_INCORRECT: /* 10 */
158
+ exclz = eCurlErrFTPBadPassword;
159
+ break;
160
+ case CURLE_FTP_WEIRD_PASS_REPLY: /* 11 */
161
+ exclz = eCurlErrFTPWierdPassReply;
162
+ break;
163
+ case CURLE_FTP_WEIRD_USER_REPLY: /* 12 */
164
+ exclz = eCurlErrFTPWierdUserReply;
165
+ break;
166
+ case CURLE_FTP_WEIRD_PASV_REPLY: /* 13 */
167
+ exclz = eCurlErrFTPWierdPasvReply;
168
+ break;
169
+ case CURLE_FTP_WEIRD_227_FORMAT: /* 14 */
170
+ exclz = eCurlErrFTPWierd227Format;
171
+ break;
172
+ case CURLE_FTP_CANT_GET_HOST: /* 15 */
173
+ exclz = eCurlErrFTPCantGetHost;
174
+ break;
175
+ case CURLE_FTP_CANT_RECONNECT: /* 16 */
176
+ exclz = eCurlErrFTPCantReconnect;
177
+ break;
178
+ case CURLE_FTP_COULDNT_SET_BINARY: /* 17 */
179
+ exclz = eCurlErrFTPCouldntSetBinary;
180
+ break;
181
+ case CURLE_PARTIAL_FILE: /* 18 */
182
+ exclz = eCurlErrPartialFile;
183
+ break;
184
+ case CURLE_FTP_COULDNT_RETR_FILE: /* 19 */
185
+ exclz = eCurlErrFTPCouldntRetrFile;
186
+ break;
187
+ case CURLE_FTP_WRITE_ERROR: /* 20 */
188
+ exclz = eCurlErrFTPWrite;
189
+ break;
190
+ case CURLE_FTP_QUOTE_ERROR: /* 21 */
191
+ exclz = eCurlErrFTPQuote;
192
+ break;
193
+ case CURLE_HTTP_RETURNED_ERROR: /* 22 */
194
+ exclz = eCurlErrHTTPFailed;
195
+ break;
196
+ case CURLE_WRITE_ERROR: /* 23 */
197
+ exclz = eCurlErrWriteError;
198
+ break;
199
+ case CURLE_MALFORMAT_USER: /* 24 - NOT USED */
200
+ exclz = eCurlErrMalformedUser;
201
+ break;
202
+ case CURLE_FTP_COULDNT_STOR_FILE: /* 25 - failed FTP upload */
203
+ exclz = eCurlErrFTPCouldntStorFile;
204
+ break;
205
+ case CURLE_READ_ERROR: /* 26 - could open/read from file */
206
+ exclz = eCurlErrReadError;
207
+ break;
208
+ case CURLE_OUT_OF_MEMORY: /* 27 */
209
+ exclz = eCurlErrOutOfMemory;
210
+ break;
211
+ case CURLE_OPERATION_TIMEOUTED: /* 28 - the timeout time was reached */
212
+ exclz = eCurlErrTimeout;
213
+ break;
214
+ case CURLE_FTP_COULDNT_SET_ASCII: /* 29 - TYPE A failed */
215
+ exclz = eCurlErrFTPCouldntSetASCII;
216
+ break;
217
+ case CURLE_FTP_PORT_FAILED: /* 30 - FTP PORT operation failed */
218
+ exclz = eCurlErrFTPPortFailed;
219
+ break;
220
+ case CURLE_FTP_COULDNT_USE_REST: /* 31 - the REST command failed */
221
+ exclz = eCurlErrFTPCouldntUseRest;
222
+ break;
223
+ case CURLE_FTP_COULDNT_GET_SIZE: /* 32 - the SIZE command failed */
224
+ exclz = eCurlErrFTPCouldntGetSize;
225
+ break;
226
+ case CURLE_HTTP_RANGE_ERROR: /* 33 - RANGE "command" didn't work */
227
+ exclz = eCurlErrHTTPRange;
228
+ break;
229
+ case CURLE_HTTP_POST_ERROR: /* 34 */
230
+ exclz = eCurlErrHTTPPost;
231
+ break;
232
+ case CURLE_SSL_CONNECT_ERROR: /* 35 - wrong when connecting with SSL */
233
+ exclz = eCurlErrSSLConnectError;
234
+ break;
235
+ case CURLE_BAD_DOWNLOAD_RESUME: /* 36 - couldn't resume download */
236
+ exclz = eCurlErrBadResume;
237
+ break;
238
+ case CURLE_FILE_COULDNT_READ_FILE: /* 37 */
239
+ exclz = eCurlErrFileCouldntRead;
240
+ break;
241
+ case CURLE_LDAP_CANNOT_BIND: /* 38 */
242
+ exclz = eCurlErrLDAPCouldntBind;
243
+ break;
244
+ case CURLE_LDAP_SEARCH_FAILED: /* 39 */
245
+ exclz = eCurlErrLDAPSearchFailed;
246
+ break;
247
+ case CURLE_LIBRARY_NOT_FOUND: /* 40 */
248
+ exclz = eCurlErrLibraryNotFound;
249
+ break;
250
+ case CURLE_FUNCTION_NOT_FOUND: /* 41 */
251
+ exclz = eCurlErrFunctionNotFound;
252
+ break;
253
+ case CURLE_ABORTED_BY_CALLBACK: /* 42 */
254
+ exclz = eCurlErrAbortedByCallback;
255
+ break;
256
+ case CURLE_BAD_FUNCTION_ARGUMENT: /* 43 */
257
+ exclz = eCurlErrBadFunctionArgument;
258
+ break;
259
+ case CURLE_BAD_CALLING_ORDER: /* 44 - NOT USED */
260
+ exclz = eCurlErrBadCallingOrder;
261
+ break;
262
+ case CURLE_INTERFACE_FAILED: /* 45 - CURLOPT_INTERFACE failed */
263
+ exclz = eCurlErrInterfaceFailed;
264
+ break;
265
+ case CURLE_BAD_PASSWORD_ENTERED: /* 46 - NOT USED */
266
+ exclz = eCurlErrBadPasswordEntered;
267
+ break;
268
+ case CURLE_TOO_MANY_REDIRECTS: /* 47 - catch endless re-direct loops */
269
+ exclz = eCurlErrTooManyRedirects;
270
+ break;
271
+ case CURLE_UNKNOWN_TELNET_OPTION: /* 48 - User specified an unknown option */
272
+ exclz = eCurlErrTelnetUnknownOption;
273
+ break;
274
+ case CURLE_TELNET_OPTION_SYNTAX: /* 49 - Malformed telnet option */
275
+ exclz = eCurlErrTelnetBadOptionSyntax;
276
+ break;
277
+ case CURLE_OBSOLETE: /* 50 - NOT USED */
278
+ exclz = eCurlErrObsolete;
279
+ break;
280
+ case CURLE_SSL_PEER_CERTIFICATE: /* 51 - peer's certificate wasn't ok */
281
+ exclz = eCurlErrSSLPeerCertificate;
282
+ break;
283
+ case CURLE_GOT_NOTHING: /* 52 - when this is a specific error */
284
+ exclz = eCurlErrGotNothing;
285
+ break;
286
+ case CURLE_SSL_ENGINE_NOTFOUND: /* 53 - SSL crypto engine not found */
287
+ exclz = eCurlErrSSLEngineNotFound;
288
+ break;
289
+ case CURLE_SSL_ENGINE_SETFAILED: /* 54 - can not set SSL crypto engine as default */
290
+ exclz = eCurlErrSSLEngineSetFailed;
291
+ break;
292
+ case CURLE_SEND_ERROR: /* 55 - failed sending network data */
293
+ exclz = eCurlErrSendError;
294
+ break;
295
+ case CURLE_RECV_ERROR: /* 56 - failure in receiving network data */
296
+ exclz = eCurlErrRecvError;
297
+ break;
298
+ case CURLE_SHARE_IN_USE: /* 57 - share is in use */
299
+ exclz = eCurlErrShareInUse;
300
+ break;
301
+ case CURLE_SSL_CERTPROBLEM: /* 58 - problem with the local certificate */
302
+ exclz = eCurlErrSSLCertificate;
303
+ break;
304
+ case CURLE_SSL_CIPHER: /* 59 - couldn't use specified cipher */
305
+ exclz = eCurlErrSSLCipher;
306
+ break;
307
+ case CURLE_SSL_CACERT: /* 60 - problem with the CA cert (path?) */
308
+ exclz = eCurlErrSSLCACertificate;
309
+ break;
310
+ case CURLE_BAD_CONTENT_ENCODING: /* 61 - Unrecognized transfer encoding */
311
+ exclz = eCurlErrBadContentEncoding;
312
+ break;
313
+ case CURLE_LDAP_INVALID_URL: /* 62 - Invalid LDAP URL */
314
+ exclz = eCurlErrLDAPInvalidURL;
315
+ break;
316
+ case CURLE_FILESIZE_EXCEEDED: /* 63 - Maximum file size exceeded */
317
+ exclz = eCurlErrFileSizeExceeded;
318
+ break;
319
+ case CURLE_FTP_SSL_FAILED: /* 64 - Requested FTP SSL level failed */
320
+ exclz = eCurlErrFTPSSLFailed;
321
+ break;
322
+ #ifdef HAVE_CURLE_SEND_FAIL_REWIND
323
+ case CURLE_SEND_FAIL_REWIND: /* 65 - Sending the data requires a rewind that failed */
324
+ exclz = eCurlErrSendFailedRewind;
325
+ break;
326
+ #endif
327
+ #ifdef HAVE_CURLE_SSL_ENGINE_INITFAILED
328
+ case CURLE_SSL_ENGINE_INITFAILED: /* 66 - failed to initialise ENGINE */
329
+ exclz = eCurlErrSSLEngineInitFailed;
330
+ break;
331
+ #endif
332
+ #ifdef HAVE_CURLE_LOGIN_DENIED
333
+ case CURLE_LOGIN_DENIED: /* 67 - user, password or similar was not accepted and we failed to login */
334
+ exclz = eCurlErrLoginDenied;
335
+ break;
336
+ #endif
337
+
338
+ // recent additions, may not be present in all supported versions
339
+ #ifdef HAVE_CURLE_TFTP_NOTFOUND
340
+ case CURLE_TFTP_NOTFOUND: /* 68 - file not found on server */
341
+ exclz = eCurlErrTFTPNotFound;
342
+ break;
343
+ #endif
344
+ #ifdef HAVE_CURLE_TFTP_PERM
345
+ case CURLE_TFTP_PERM: /* 69 - permission problem on server */
346
+ exclz = eCurlErrTFTPPermission;
347
+ break;
348
+ #endif
349
+ #ifdef HAVE_CURLE_TFTP_DISKFULL
350
+ case CURLE_TFTP_DISKFULL: /* 70 - out of disk space on server */
351
+ exclz = eCurlErrTFTPDiskFull;
352
+ break;
353
+ #endif
354
+ #ifdef HAVE_CURLE_TFTP_ILLEGAL
355
+ case CURLE_TFTP_ILLEGAL: /* 71 - Illegal TFTP operation */
356
+ exclz = eCurlErrTFTPIllegalOperation;
357
+ break;
358
+ #endif
359
+ #ifdef HAVE_CURLE_TFTP_UNKNOWNID
360
+ case CURLE_TFTP_UNKNOWNID: /* 72 - Unknown transfer ID */
361
+ exclz = eCurlErrTFTPUnknownID;
362
+ break;
363
+ #endif
364
+ #ifdef HAVE_CURLE_TFTP_EXISTS
365
+ case CURLE_TFTP_EXISTS: /* 73 - File already exists */
366
+ exclz = eCurlErrTFTPFileExists;
367
+ break;
368
+ #endif
369
+ #ifdef HAVE_CURLE_TFTP_NOSUCHUSER
370
+ case CURLE_TFTP_NOSUCHUSER: /* 74 - No such user */
371
+ exclz = eCurlErrTFTPNotFound;
372
+ break;
373
+ #endif
374
+ #ifdef HAVE_CURLE_CONV_FAILED
375
+ case CURLE_CONV_FAILED: /* 75 - conversion failed */
376
+ exclz = eCurlErrConvFailed;
377
+ break;
378
+ #endif
379
+ #ifdef HAVE_CURLE_CONV_REQD
380
+ case CURLE_CONV_REQD: /* 76 - caller must register conversion
381
+ callbacks using curl_easy_setopt options
382
+ CURLOPT_CONV_FROM_NETWORK_FUNCTION,
383
+ CURLOPT_CONV_TO_NETWORK_FUNCTION, and
384
+ CURLOPT_CONV_FROM_UTF8_FUNCTION */
385
+ exclz = eCurlErrConvReqd;
386
+ break;
387
+ #endif
388
+ #ifdef HAVE_CURLE_SSL_CACERT_BADFILE
389
+ case CURLE_SSL_CACERT_BADFILE: /* 77 - could not load CACERT file, missing
390
+ or wrong format */
391
+ exclz = eCurlErrSSLCacertBadfile;
392
+ break;
393
+ #endif
394
+ #ifdef HAVE_CURLE_REMOTE_FILE_NOT_FOUND
395
+ case CURLE_REMOTE_FILE_NOT_FOUND: /* 78 - remote file not found */
396
+ exclz = eCurlErrRemoteFileNotFound;
397
+ break;
398
+ #endif
399
+ #ifdef HAVE_CURLE_SSH
400
+ case CURLE_SSH: /* 79 - error from the SSH layer, somewhat
401
+ generic so the error message will be of
402
+ interest when this has happened */
403
+ exclz = eCurlErrSSH;
404
+ break;
405
+ #endif
406
+ #ifdef HAVE_CURLE_SSL_SHUTDOWN_FAILED
407
+ case CURLE_SSL_SHUTDOWN_FAILED: /* 80 - Failed to shut down the SSL
408
+ connection */
409
+ exclz = eCurlErrSSLShutdownFailed;
410
+ break;
411
+ #endif
412
+ #ifdef HAVE_CURLE_AGAIN
413
+ case CURLE_AGAIN: /* 81 - socket is not ready for send/recv,
414
+ wait till it's ready and try again (Added
415
+ in 7.18.2) */
416
+ exclz = eCurlErrAgain;
417
+ break;
418
+ #endif
419
+ #ifdef HAVE_CURLE_SSL_CRL_BADFILE
420
+ case CURLE_SSL_CRL_BADFILE: /* 82 - could not load CRL file, missing or
421
+ wrong format (Added in 7.19.0) */
422
+ exclz = eCurlErrSSLCRLBadfile;
423
+ break;
424
+ #endif
425
+ #ifdef HAVE_CURLE_SSL_ISSUER_ERROR
426
+ case CURLE_SSL_ISSUER_ERROR: /* 83 - Issuer check failed. (Added in
427
+ 7.19.0) */
428
+ exclz = eCurlErrSSLIssuerError;
429
+ break;
430
+ #endif
431
+ default:
432
+ exclz = eCurlErrError;
433
+ exmsg = "Unknown error result from libcurl";
434
+ }
435
+
436
+ if (!exmsg) {
437
+ exmsg = curl_easy_strerror(code);
438
+ }
439
+
440
+ results = rb_ary_new2(2);
441
+ rb_ary_push(results, exclz);
442
+ rb_ary_push(results, rb_str_new2(exmsg));
443
+ return results;
444
+ }
445
+ /* rb_raise an approriate exception for the supplied CURLcode */
446
+ void raise_curl_easy_error_exception(CURLcode code) {
447
+ VALUE obj = rb_curl_easy_error(code);
448
+ rb_raise(rb_ary_entry(obj,0), RSTRING_PTR(rb_ary_entry(obj,1)));
449
+ }
450
+ VALUE rb_curl_multi_error(CURLMcode code) {
451
+ VALUE exclz;
452
+ const char *exmsg = NULL;
453
+ VALUE results;
454
+
455
+ switch(code) {
456
+ case CURLM_CALL_MULTI_PERFORM: /* -1 */
457
+ exclz = mCurlErrCallMultiPerform;
458
+ break;
459
+ case CURLM_BAD_HANDLE: /* 1 */
460
+ exclz = mCurlErrBadHandle;
461
+ break;
462
+ case CURLM_BAD_EASY_HANDLE: /* 2 */
463
+ exclz = mCurlErrBadEasyHandle;
464
+ break;
465
+ case CURLM_OUT_OF_MEMORY: /* 3 */
466
+ exclz = mCurlErrOutOfMemory;
467
+ break;
468
+ case CURLM_INTERNAL_ERROR: /* 4 */
469
+ exclz = mCurlErrInternalError;
470
+ break;
471
+ #if HAVE_CURLM_BAD_SOCKET
472
+ case CURLM_BAD_SOCKET: /* 5 */
473
+ exclz = mCurlErrBadSocket;
474
+ break;
475
+ #endif
476
+ #if HAVE_CURLM_UNKNOWN_OPTION
477
+ case CURLM_UNKNOWN_OPTION: /* 6 */
478
+ exclz = mCurlErrUnknownOption;
479
+ break;
480
+ #endif
481
+ default:
482
+ exclz = eCurlErrError;
483
+ exmsg = "Unknown error result from libcurl";
484
+ }
485
+
486
+ if (!exmsg) {
487
+ exmsg = curl_multi_strerror(code);
488
+ }
489
+
490
+ results = rb_ary_new2(2);
491
+ rb_ary_push(results, exclz);
492
+ rb_ary_push(results, rb_str_new2(exmsg));
493
+
494
+ return results;
495
+ }
496
+ void raise_curl_multi_error_exception(CURLMcode code) {
497
+ VALUE obj = rb_curl_multi_error(code);
498
+ rb_raise(rb_ary_entry(obj,0), RSTRING_PTR(rb_ary_entry(obj,1)));
499
+ }
500
+
501
+ void init_curb_errors() {
502
+ mCurlErr = rb_define_module_under(mCurl, "Err");
503
+ eCurlErrError = rb_define_class_under(mCurlErr, "CurlError", rb_eRuntimeError);
504
+
505
+ eCurlErrFTPError = rb_define_class_under(mCurlErr, "FTPError", eCurlErrError);
506
+ eCurlErrHTTPError = rb_define_class_under(mCurlErr, "HTTPError", eCurlErrError);
507
+ eCurlErrFileError = rb_define_class_under(mCurlErr, "FileError", eCurlErrError);
508
+ eCurlErrLDAPError = rb_define_class_under(mCurlErr, "LDAPError", eCurlErrError);
509
+ eCurlErrTelnetError = rb_define_class_under(mCurlErr, "TelnetError", eCurlErrError);
510
+ eCurlErrTFTPError = rb_define_class_under(mCurlErr, "TFTPError", eCurlErrError);
511
+
512
+ eCurlErrUnsupportedProtocol = rb_define_class_under(mCurlErr, "UnsupportedProtocolError", eCurlErrError);
513
+ eCurlErrFailedInit = rb_define_class_under(mCurlErr, "FailedInitError", eCurlErrError);
514
+ eCurlErrMalformedURL = rb_define_class_under(mCurlErr, "MalformedURLError", eCurlErrError);
515
+ eCurlErrMalformedURLUser = rb_define_class_under(mCurlErr, "MalformedURLUserError", eCurlErrError);
516
+ eCurlErrProxyResolution = rb_define_class_under(mCurlErr, "ProxyResolutionError", eCurlErrError);
517
+ eCurlErrHostResolution = rb_define_class_under(mCurlErr, "HostResolutionError", eCurlErrError);
518
+ eCurlErrConnectFailed = rb_define_class_under(mCurlErr, "ConnectionFailedError", eCurlErrError);
519
+
520
+ eCurlErrFTPWierdReply = rb_define_class_under(mCurlErr, "WierdReplyError", eCurlErrFTPError);
521
+ eCurlErrFTPAccessDenied = rb_define_class_under(mCurlErr, "AccessDeniedError", eCurlErrFTPError);
522
+ eCurlErrFTPBadPassword = rb_define_class_under(mCurlErr, "BadBasswordError", eCurlErrFTPError);
523
+ eCurlErrFTPWierdPassReply = rb_define_class_under(mCurlErr, "WierdPassReplyError", eCurlErrFTPError);
524
+ eCurlErrFTPWierdUserReply = rb_define_class_under(mCurlErr, "WierdUserReplyError", eCurlErrFTPError);
525
+ eCurlErrFTPWierdPasvReply = rb_define_class_under(mCurlErr, "WierdPasvReplyError", eCurlErrFTPError);
526
+ eCurlErrFTPWierd227Format = rb_define_class_under(mCurlErr, "Wierd227FormatError", eCurlErrFTPError);
527
+ eCurlErrFTPCantGetHost = rb_define_class_under(mCurlErr, "CantGetHostError", eCurlErrFTPError);
528
+ eCurlErrFTPCantReconnect = rb_define_class_under(mCurlErr, "CantReconnectError", eCurlErrFTPError);
529
+ eCurlErrFTPCouldntSetBinary = rb_define_class_under(mCurlErr, "CouldntSetBinaryError", eCurlErrFTPError);
530
+
531
+ eCurlErrPartialFile = rb_define_class_under(mCurlErr, "PartialFileError", eCurlErrError);
532
+
533
+ eCurlErrFTPCouldntRetrFile = rb_define_class_under(mCurlErr, "CouldntRetrFileError", eCurlErrFTPError);
534
+ eCurlErrFTPWrite = rb_define_class_under(mCurlErr, "FTPWriteError", eCurlErrFTPError);
535
+ eCurlErrFTPQuote = rb_define_class_under(mCurlErr, "FTPQuoteError", eCurlErrFTPError);
536
+
537
+ eCurlErrHTTPFailed = rb_define_class_under(mCurlErr, "HTTPFailedError", eCurlErrHTTPError);
538
+
539
+ eCurlErrWriteError = rb_define_class_under(mCurlErr, "WriteError", eCurlErrError);
540
+ eCurlErrMalformedUser = rb_define_class_under(mCurlErr, "MalformedUserError", eCurlErrError);
541
+
542
+ eCurlErrFTPCouldntStorFile = rb_define_class_under(mCurlErr, "CouldntStorFileError", eCurlErrFTPError);
543
+
544
+ eCurlErrReadError = rb_define_class_under(mCurlErr, "ReadError", eCurlErrError);
545
+ eCurlErrOutOfMemory = rb_define_class_under(mCurlErr, "OutOfMemoryError", eCurlErrError);
546
+ eCurlErrTimeout = rb_define_class_under(mCurlErr, "TimeoutError", eCurlErrError);
547
+
548
+ eCurlErrFTPCouldntSetASCII = rb_define_class_under(mCurlErr, "CouldntSetASCIIError", eCurlErrFTPError);
549
+ eCurlErrFTPPortFailed = rb_define_class_under(mCurlErr, "PortFailedError", eCurlErrFTPError);
550
+ eCurlErrFTPCouldntUseRest = rb_define_class_under(mCurlErr, "CouldntUseRestError", eCurlErrFTPError);
551
+ eCurlErrFTPCouldntGetSize = rb_define_class_under(mCurlErr, "CouldntGetSizeError", eCurlErrFTPError);
552
+
553
+ eCurlErrHTTPRange = rb_define_class_under(mCurlErr, "HTTPRangeError", eCurlErrHTTPError);
554
+ eCurlErrHTTPPost = rb_define_class_under(mCurlErr, "HTTPPostError", eCurlErrHTTPError);
555
+
556
+ eCurlErrSSLConnectError = rb_define_class_under(mCurlErr, "SSLConnectError", eCurlErrError);
557
+ eCurlErrBadResume = rb_define_class_under(mCurlErr, "BadResumeError", eCurlErrError);
558
+
559
+ eCurlErrFileCouldntRead = rb_define_class_under(mCurlErr, "CouldntReadError", eCurlErrFileError);
560
+
561
+ eCurlErrLDAPCouldntBind = rb_define_class_under(mCurlErr, "CouldntBindError", eCurlErrLDAPError);
562
+ eCurlErrLDAPSearchFailed = rb_define_class_under(mCurlErr, "SearchFailedError", eCurlErrLDAPError);
563
+
564
+ eCurlErrLibraryNotFound = rb_define_class_under(mCurlErr, "LibraryNotFoundError", eCurlErrError);
565
+ eCurlErrFunctionNotFound = rb_define_class_under(mCurlErr, "FunctionNotFoundError", eCurlErrError);
566
+ eCurlErrAbortedByCallback = rb_define_class_under(mCurlErr, "AbortedByCallbackError", eCurlErrError);
567
+ eCurlErrBadFunctionArgument = rb_define_class_under(mCurlErr, "BadFunctionArgumentError", eCurlErrError);
568
+ eCurlErrBadCallingOrder = rb_define_class_under(mCurlErr, "BadCallingOrderError", eCurlErrError);
569
+ eCurlErrInterfaceFailed = rb_define_class_under(mCurlErr, "InterfaceFailedError", eCurlErrError);
570
+
571
+ eCurlErrBadPasswordEntered = rb_define_class_under(mCurlErr, "BadPasswordEnteredError", eCurlErrError);
572
+ eCurlErrTooManyRedirects = rb_define_class_under(mCurlErr, "TooManyRedirectsError", eCurlErrError);
573
+
574
+ eCurlErrTelnetUnknownOption = rb_define_class_under(mCurlErr, "UnknownOptionError", eCurlErrTelnetError);
575
+ eCurlErrTelnetBadOptionSyntax = rb_define_class_under(mCurlErr, "BadOptionSyntaxError", eCurlErrTelnetError);
576
+
577
+ eCurlErrObsolete = rb_define_class_under(mCurlErr, "ObsoleteError", eCurlErrError);
578
+ eCurlErrSSLPeerCertificate = rb_define_class_under(mCurlErr, "SSLPeerCertificateError", eCurlErrError);
579
+ eCurlErrGotNothing = rb_define_class_under(mCurlErr, "GotNothingError", eCurlErrError);
580
+
581
+ eCurlErrSSLEngineNotFound = rb_define_class_under(mCurlErr, "SSLEngineNotFoundError", eCurlErrError);
582
+ eCurlErrSSLEngineSetFailed = rb_define_class_under(mCurlErr, "SSLEngineSetFailedError", eCurlErrError);
583
+
584
+ eCurlErrSendError = rb_define_class_under(mCurlErr, "SendError", eCurlErrError);
585
+ eCurlErrRecvError = rb_define_class_under(mCurlErr, "RecvError", eCurlErrError);
586
+ eCurlErrShareInUse = rb_define_class_under(mCurlErr, "ShareInUseError", eCurlErrError);
587
+
588
+ eCurlErrConvFailed = rb_define_class_under(mCurlErr, "ConvFailed", eCurlErrError);
589
+ eCurlErrConvReqd = rb_define_class_under(mCurlErr, "ConvReqd", eCurlErrError);
590
+ eCurlErrRemoteFileNotFound = rb_define_class_under(mCurlErr, "RemoteFileNotFound", eCurlErrError);
591
+ eCurlErrAgain = rb_define_class_under(mCurlErr, "Again", eCurlErrError);
592
+
593
+ eCurlErrSSLCertificate = rb_define_class_under(mCurlErr, "SSLCertificateError", eCurlErrError);
594
+ eCurlErrSSLCipher = rb_define_class_under(mCurlErr, "SSLCypherError", eCurlErrError);
595
+ eCurlErrSSLCACertificate = rb_define_class_under(mCurlErr, "SSLCACertificateError", eCurlErrError);
596
+ eCurlErrBadContentEncoding = rb_define_class_under(mCurlErr, "BadContentEncodingError", eCurlErrError);
597
+ eCurlErrSSLCacertBadfile = rb_define_class_under(mCurlErr, "SSLCaertBadFile", eCurlErrError);
598
+ eCurlErrSSLCRLBadfile = rb_define_class_under(mCurlErr, "SSLCRLBadfile", eCurlErrError);
599
+ eCurlErrSSLIssuerError = rb_define_class_under(mCurlErr, "SSLIssuerError", eCurlErrError);
600
+ eCurlErrSSLShutdownFailed = rb_define_class_under(mCurlErr, "SSLShutdownFailed", eCurlErrError);
601
+ eCurlErrSSH = rb_define_class_under(mCurlErr, "SSH", eCurlErrError);
602
+
603
+ mCurlErrCallMultiPerform = rb_define_class_under(mCurlErr, "MultiPerform", eCurlErrError);
604
+ mCurlErrBadHandle = rb_define_class_under(mCurlErr, "MultiBadHandle", eCurlErrError);
605
+ mCurlErrBadEasyHandle = rb_define_class_under(mCurlErr, "MultiBadEasyHandle", eCurlErrError);
606
+ mCurlErrOutOfMemory = rb_define_class_under(mCurlErr, "MultiOutOfMemory", eCurlErrError);
607
+ mCurlErrInternalError = rb_define_class_under(mCurlErr, "MultiInternalError", eCurlErrError);
608
+ mCurlErrBadSocket = rb_define_class_under(mCurlErr, "MultiBadSocket", eCurlErrError);
609
+ mCurlErrUnknownOption = rb_define_class_under(mCurlErr, "MultiUnknownOption", eCurlErrError);
610
+
611
+ eCurlErrLDAPInvalidURL = rb_define_class_under(mCurlErr, "InvalidLDAPURLError", eCurlErrLDAPError);
612
+
613
+ eCurlErrFileSizeExceeded = rb_define_class_under(mCurlErr, "FileSizeExceededError", eCurlErrError);
614
+
615
+ eCurlErrFTPSSLFailed = rb_define_class_under(mCurlErr, "FTPSSLFailed", eCurlErrFTPError);
616
+
617
+ eCurlErrSendFailedRewind = rb_define_class_under(mCurlErr, "SendFailedRewind", eCurlErrError);
618
+ eCurlErrSSLEngineInitFailed = rb_define_class_under(mCurlErr, "SSLEngineInitFailedError", eCurlErrError);
619
+ eCurlErrLoginDenied = rb_define_class_under(mCurlErr, "LoginDeniedError", eCurlErrError);
620
+
621
+ eCurlErrTFTPNotFound = rb_define_class_under(mCurlErr, "NotFoundError", eCurlErrTFTPError);
622
+ eCurlErrTFTPPermission = rb_define_class_under(mCurlErr, "PermissionError", eCurlErrTFTPError);
623
+ eCurlErrTFTPDiskFull = rb_define_class_under(mCurlErr, "DiskFullError", eCurlErrTFTPError);
624
+ eCurlErrTFTPIllegalOperation = rb_define_class_under(mCurlErr, "IllegalOperationError", eCurlErrTFTPError);
625
+ eCurlErrTFTPUnknownID = rb_define_class_under(mCurlErr, "UnknownIDError", eCurlErrTFTPError);
626
+ eCurlErrTFTPFileExists = rb_define_class_under(mCurlErr, "FileExistsError", eCurlErrTFTPError);
627
+ eCurlErrTFTPNoSuchUser = rb_define_class_under(mCurlErr, "NoSuchUserError", eCurlErrTFTPError);
628
+
629
+ eCurlErrInvalidPostField = rb_define_class_under(mCurlErr, "InvalidPostFieldError", eCurlErrError);
630
+ }