curb 0.1.0
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.
- data/LICENSE +51 -0
- data/README +106 -0
- data/Rakefile +302 -0
- data/doc.rb +42 -0
- data/ext/curb.c +333 -0
- data/ext/curb.h +39 -0
- data/ext/curb.rb +46 -0
- data/ext/curb_easy.c +2138 -0
- data/ext/curb_easy.h +73 -0
- data/ext/curb_errors.c +471 -0
- data/ext/curb_errors.h +106 -0
- data/ext/curb_macros.h +114 -0
- data/ext/curb_postfield.c +499 -0
- data/ext/curb_postfield.h +40 -0
- data/ext/curl.rb +2 -0
- data/ext/extconf.rb +24 -0
- data/samples/gmail.rb +46 -0
- data/tests/alltests.rb +3 -0
- data/tests/bug_instance_post_differs_from_class_post.rb +53 -0
- data/tests/bug_require_last_or_segfault.rb +40 -0
- data/tests/helper.rb +15 -0
- data/tests/require_last_or_segfault_script.rb +36 -0
- data/tests/tc_curl_easy.rb +415 -0
- data/tests/tc_curl_postfield.rb +141 -0
- data/tests/unittests.rb +2 -0
- metadata +80 -0
data/ext/curb_easy.h
ADDED
@@ -0,0 +1,73 @@
|
|
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_addr;
|
24
|
+
|
25
|
+
VALUE body_proc;
|
26
|
+
VALUE header_proc;
|
27
|
+
VALUE body_data; /* These have the result from the last curl_easy_perform */
|
28
|
+
VALUE header_data; /* unless a block is supplied (when they'll be nil) */
|
29
|
+
VALUE progress_proc;
|
30
|
+
VALUE debug_proc;
|
31
|
+
VALUE interface;
|
32
|
+
VALUE userpwd;
|
33
|
+
VALUE proxypwd;
|
34
|
+
VALUE headers; /* ruby array of strings with headers to set */
|
35
|
+
VALUE cookiejar; /* filename */
|
36
|
+
|
37
|
+
/* Other opts */
|
38
|
+
unsigned short local_port; // 0 is no port
|
39
|
+
unsigned short local_port_range; // " " " "
|
40
|
+
unsigned short proxy_port; // " " " "
|
41
|
+
int proxy_type;
|
42
|
+
long http_auth_types;
|
43
|
+
long proxy_auth_types;
|
44
|
+
long max_redirs;
|
45
|
+
unsigned long timeout;
|
46
|
+
unsigned long connect_timeout;
|
47
|
+
long dns_cache_timeout;
|
48
|
+
unsigned long ftp_response_timeout;
|
49
|
+
|
50
|
+
/* bool flags */
|
51
|
+
char proxy_tunnel;
|
52
|
+
char fetch_file_time;
|
53
|
+
char ssl_verify_peer;
|
54
|
+
char header_in_body;
|
55
|
+
char use_netrc;
|
56
|
+
char follow_location;
|
57
|
+
char unrestricted_auth;
|
58
|
+
char verbose;
|
59
|
+
char multipart_form_post;
|
60
|
+
char enable_cookies;
|
61
|
+
|
62
|
+
/* this is sometimes used as a buffer for a form data string,
|
63
|
+
* which we alloc in C and need to hang around for the call,
|
64
|
+
* and in case it's asked for before the next call.
|
65
|
+
*/
|
66
|
+
VALUE postdata_buffer;
|
67
|
+
} ruby_curl_easy;
|
68
|
+
|
69
|
+
extern VALUE cCurlEasy;
|
70
|
+
|
71
|
+
void init_curb_easy();
|
72
|
+
|
73
|
+
#endif
|
data/ext/curb_errors.c
ADDED
@@ -0,0 +1,471 @@
|
|
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
|
+
/* binding errors */
|
102
|
+
VALUE eCurlErrInvalidPostField;
|
103
|
+
|
104
|
+
/* rb_raise an approriate exception for the supplied CURLcode */
|
105
|
+
void raise_curl_easy_error_exception(CURLcode code) {
|
106
|
+
VALUE exclz;
|
107
|
+
const char *exmsg = NULL;
|
108
|
+
|
109
|
+
switch (code) {
|
110
|
+
case CURLE_UNSUPPORTED_PROTOCOL: /* 1 */
|
111
|
+
exclz = eCurlErrUnsupportedProtocol;
|
112
|
+
break;
|
113
|
+
case CURLE_FAILED_INIT: /* 2 */
|
114
|
+
exclz = eCurlErrFailedInit;
|
115
|
+
break;
|
116
|
+
case CURLE_URL_MALFORMAT: /* 3 */
|
117
|
+
exclz = eCurlErrMalformedURL;
|
118
|
+
break;
|
119
|
+
case CURLE_URL_MALFORMAT_USER: /* 4 (NOT USED) */
|
120
|
+
exclz = eCurlErrMalformedURLUser;
|
121
|
+
break;
|
122
|
+
case CURLE_COULDNT_RESOLVE_PROXY: /* 5 */
|
123
|
+
exclz = eCurlErrProxyResolution;
|
124
|
+
break;
|
125
|
+
case CURLE_COULDNT_RESOLVE_HOST: /* 6 */
|
126
|
+
exclz = eCurlErrHostResolution;
|
127
|
+
break;
|
128
|
+
case CURLE_COULDNT_CONNECT: /* 7 */
|
129
|
+
exclz = eCurlErrConnectFailed;
|
130
|
+
break;
|
131
|
+
case CURLE_FTP_WEIRD_SERVER_REPLY: /* 8 */
|
132
|
+
exclz = eCurlErrFTPWierdReply;
|
133
|
+
break;
|
134
|
+
case CURLE_FTP_ACCESS_DENIED: /* 9 denied due to lack of access. */
|
135
|
+
exclz = eCurlErrFTPAccessDenied;
|
136
|
+
break;
|
137
|
+
case CURLE_FTP_USER_PASSWORD_INCORRECT: /* 10 */
|
138
|
+
exclz = eCurlErrFTPBadPassword;
|
139
|
+
break;
|
140
|
+
case CURLE_FTP_WEIRD_PASS_REPLY: /* 11 */
|
141
|
+
exclz = eCurlErrFTPWierdPassReply;
|
142
|
+
break;
|
143
|
+
case CURLE_FTP_WEIRD_USER_REPLY: /* 12 */
|
144
|
+
exclz = eCurlErrFTPWierdUserReply;
|
145
|
+
break;
|
146
|
+
case CURLE_FTP_WEIRD_PASV_REPLY: /* 13 */
|
147
|
+
exclz = eCurlErrFTPWierdPasvReply;
|
148
|
+
break;
|
149
|
+
case CURLE_FTP_WEIRD_227_FORMAT: /* 14 */
|
150
|
+
exclz = eCurlErrFTPWierd227Format;
|
151
|
+
break;
|
152
|
+
case CURLE_FTP_CANT_GET_HOST: /* 15 */
|
153
|
+
exclz = eCurlErrFTPCantGetHost;
|
154
|
+
break;
|
155
|
+
case CURLE_FTP_CANT_RECONNECT: /* 16 */
|
156
|
+
exclz = eCurlErrFTPCantReconnect;
|
157
|
+
break;
|
158
|
+
case CURLE_FTP_COULDNT_SET_BINARY: /* 17 */
|
159
|
+
exclz = eCurlErrFTPCouldntSetBinary;
|
160
|
+
break;
|
161
|
+
case CURLE_PARTIAL_FILE: /* 18 */
|
162
|
+
exclz = eCurlErrPartialFile;
|
163
|
+
break;
|
164
|
+
case CURLE_FTP_COULDNT_RETR_FILE: /* 19 */
|
165
|
+
exclz = eCurlErrFTPCouldntRetrFile;
|
166
|
+
break;
|
167
|
+
case CURLE_FTP_WRITE_ERROR: /* 20 */
|
168
|
+
exclz = eCurlErrFTPWrite;
|
169
|
+
break;
|
170
|
+
case CURLE_FTP_QUOTE_ERROR: /* 21 */
|
171
|
+
exclz = eCurlErrFTPQuote;
|
172
|
+
break;
|
173
|
+
case CURLE_HTTP_RETURNED_ERROR: /* 22 */
|
174
|
+
exclz = eCurlErrHTTPFailed;
|
175
|
+
break;
|
176
|
+
case CURLE_WRITE_ERROR: /* 23 */
|
177
|
+
exclz = eCurlErrWriteError;
|
178
|
+
break;
|
179
|
+
case CURLE_MALFORMAT_USER: /* 24 - NOT USED */
|
180
|
+
exclz = eCurlErrMalformedUser;
|
181
|
+
break;
|
182
|
+
case CURLE_FTP_COULDNT_STOR_FILE: /* 25 - failed FTP upload */
|
183
|
+
exclz = eCurlErrFTPCouldntStorFile;
|
184
|
+
break;
|
185
|
+
case CURLE_READ_ERROR: /* 26 - could open/read from file */
|
186
|
+
exclz = eCurlErrReadError;
|
187
|
+
break;
|
188
|
+
case CURLE_OUT_OF_MEMORY: /* 27 */
|
189
|
+
exclz = eCurlErrOutOfMemory;
|
190
|
+
break;
|
191
|
+
case CURLE_OPERATION_TIMEOUTED: /* 28 - the timeout time was reached */
|
192
|
+
exclz = eCurlErrTimeout;
|
193
|
+
break;
|
194
|
+
case CURLE_FTP_COULDNT_SET_ASCII: /* 29 - TYPE A failed */
|
195
|
+
exclz = eCurlErrFTPCouldntSetASCII;
|
196
|
+
break;
|
197
|
+
case CURLE_FTP_PORT_FAILED: /* 30 - FTP PORT operation failed */
|
198
|
+
exclz = eCurlErrFTPPortFailed;
|
199
|
+
break;
|
200
|
+
case CURLE_FTP_COULDNT_USE_REST: /* 31 - the REST command failed */
|
201
|
+
exclz = eCurlErrFTPCouldntUseRest;
|
202
|
+
break;
|
203
|
+
case CURLE_FTP_COULDNT_GET_SIZE: /* 32 - the SIZE command failed */
|
204
|
+
exclz = eCurlErrFTPCouldntGetSize;
|
205
|
+
break;
|
206
|
+
case CURLE_HTTP_RANGE_ERROR: /* 33 - RANGE "command" didn't work */
|
207
|
+
exclz = eCurlErrHTTPRange;
|
208
|
+
break;
|
209
|
+
case CURLE_HTTP_POST_ERROR: /* 34 */
|
210
|
+
exclz = eCurlErrHTTPPost;
|
211
|
+
break;
|
212
|
+
case CURLE_SSL_CONNECT_ERROR: /* 35 - wrong when connecting with SSL */
|
213
|
+
exclz = eCurlErrSSLConnectError;
|
214
|
+
break;
|
215
|
+
case CURLE_BAD_DOWNLOAD_RESUME: /* 36 - couldn't resume download */
|
216
|
+
exclz = eCurlErrBadResume;
|
217
|
+
break;
|
218
|
+
case CURLE_FILE_COULDNT_READ_FILE: /* 37 */
|
219
|
+
exclz = eCurlErrFileCouldntRead;
|
220
|
+
break;
|
221
|
+
case CURLE_LDAP_CANNOT_BIND: /* 38 */
|
222
|
+
exclz = eCurlErrLDAPCouldntBind;
|
223
|
+
break;
|
224
|
+
case CURLE_LDAP_SEARCH_FAILED: /* 39 */
|
225
|
+
exclz = eCurlErrLDAPSearchFailed;
|
226
|
+
break;
|
227
|
+
case CURLE_LIBRARY_NOT_FOUND: /* 40 */
|
228
|
+
exclz = eCurlErrLibraryNotFound;
|
229
|
+
break;
|
230
|
+
case CURLE_FUNCTION_NOT_FOUND: /* 41 */
|
231
|
+
exclz = eCurlErrFunctionNotFound;
|
232
|
+
break;
|
233
|
+
case CURLE_ABORTED_BY_CALLBACK: /* 42 */
|
234
|
+
exclz = eCurlErrAbortedByCallback;
|
235
|
+
break;
|
236
|
+
case CURLE_BAD_FUNCTION_ARGUMENT: /* 43 */
|
237
|
+
exclz = eCurlErrBadFunctionArgument;
|
238
|
+
break;
|
239
|
+
case CURLE_BAD_CALLING_ORDER: /* 44 - NOT USED */
|
240
|
+
exclz = eCurlErrBadCallingOrder;
|
241
|
+
break;
|
242
|
+
case CURLE_INTERFACE_FAILED: /* 45 - CURLOPT_INTERFACE failed */
|
243
|
+
exclz = eCurlErrInterfaceFailed;
|
244
|
+
break;
|
245
|
+
case CURLE_BAD_PASSWORD_ENTERED: /* 46 - NOT USED */
|
246
|
+
exclz = eCurlErrBadPasswordEntered;
|
247
|
+
break;
|
248
|
+
case CURLE_TOO_MANY_REDIRECTS: /* 47 - catch endless re-direct loops */
|
249
|
+
exclz = eCurlErrTooManyRedirects;
|
250
|
+
break;
|
251
|
+
case CURLE_UNKNOWN_TELNET_OPTION: /* 48 - User specified an unknown option */
|
252
|
+
exclz = eCurlErrTelnetUnknownOption;
|
253
|
+
break;
|
254
|
+
case CURLE_TELNET_OPTION_SYNTAX: /* 49 - Malformed telnet option */
|
255
|
+
exclz = eCurlErrTelnetBadOptionSyntax;
|
256
|
+
break;
|
257
|
+
case CURLE_OBSOLETE: /* 50 - NOT USED */
|
258
|
+
exclz = eCurlErrObsolete;
|
259
|
+
break;
|
260
|
+
case CURLE_SSL_PEER_CERTIFICATE: /* 51 - peer's certificate wasn't ok */
|
261
|
+
exclz = eCurlErrSSLPeerCertificate;
|
262
|
+
break;
|
263
|
+
case CURLE_GOT_NOTHING: /* 52 - when this is a specific error */
|
264
|
+
exclz = eCurlErrGotNothing;
|
265
|
+
break;
|
266
|
+
case CURLE_SSL_ENGINE_NOTFOUND: /* 53 - SSL crypto engine not found */
|
267
|
+
exclz = eCurlErrSSLEngineNotFound;
|
268
|
+
break;
|
269
|
+
case CURLE_SSL_ENGINE_SETFAILED: /* 54 - can not set SSL crypto engine as default */
|
270
|
+
exclz = eCurlErrSSLEngineSetFailed;
|
271
|
+
break;
|
272
|
+
case CURLE_SEND_ERROR: /* 55 - failed sending network data */
|
273
|
+
exclz = eCurlErrSendError;
|
274
|
+
break;
|
275
|
+
case CURLE_RECV_ERROR: /* 56 - failure in receiving network data */
|
276
|
+
exclz = eCurlErrRecvError;
|
277
|
+
break;
|
278
|
+
case CURLE_SHARE_IN_USE: /* 57 - share is in use */
|
279
|
+
exclz = eCurlErrShareInUse;
|
280
|
+
break;
|
281
|
+
case CURLE_SSL_CERTPROBLEM: /* 58 - problem with the local certificate */
|
282
|
+
exclz = eCurlErrSSLCertificate;
|
283
|
+
break;
|
284
|
+
case CURLE_SSL_CIPHER: /* 59 - couldn't use specified cipher */
|
285
|
+
exclz = eCurlErrSSLCipher;
|
286
|
+
break;
|
287
|
+
case CURLE_SSL_CACERT: /* 60 - problem with the CA cert (path?) */
|
288
|
+
exclz = eCurlErrSSLCACertificate;
|
289
|
+
break;
|
290
|
+
case CURLE_BAD_CONTENT_ENCODING: /* 61 - Unrecognized transfer encoding */
|
291
|
+
exclz = eCurlErrBadContentEncoding;
|
292
|
+
break;
|
293
|
+
case CURLE_LDAP_INVALID_URL: /* 62 - Invalid LDAP URL */
|
294
|
+
exclz = eCurlErrLDAPInvalidURL;
|
295
|
+
break;
|
296
|
+
case CURLE_FILESIZE_EXCEEDED: /* 63 - Maximum file size exceeded */
|
297
|
+
exclz = eCurlErrFileSizeExceeded;
|
298
|
+
break;
|
299
|
+
case CURLE_FTP_SSL_FAILED: /* 64 - Requested FTP SSL level failed */
|
300
|
+
exclz = eCurlErrFTPSSLFailed;
|
301
|
+
break;
|
302
|
+
case CURLE_SEND_FAIL_REWIND: /* 65 - Sending the data requires a rewind that failed */
|
303
|
+
exclz = eCurlErrSendFailedRewind;
|
304
|
+
break;
|
305
|
+
case CURLE_SSL_ENGINE_INITFAILED: /* 66 - failed to initialise ENGINE */
|
306
|
+
exclz = eCurlErrSSLEngineInitFailed;
|
307
|
+
break;
|
308
|
+
case CURLE_LOGIN_DENIED: /* 67 - user, password or similar was not accepted and we failed to login */
|
309
|
+
exclz = eCurlErrLoginDenied;
|
310
|
+
break;
|
311
|
+
|
312
|
+
// recent additions, may not be present in all supported versions
|
313
|
+
#ifdef CURLE_TFTP_NOTFOUND
|
314
|
+
case CURLE_TFTP_NOTFOUND: /* 68 - file not found on server */
|
315
|
+
exclz = eCurlErrTFTPNotFound;
|
316
|
+
break;
|
317
|
+
#endif
|
318
|
+
#ifdef CURLE_TFTP_PERM
|
319
|
+
case CURLE_TFTP_PERM: /* 69 - permission problem on server */
|
320
|
+
exclz = eCurlErrTFTPPermission;
|
321
|
+
break;
|
322
|
+
#endif
|
323
|
+
#ifdef CURLE_TFTP_DISKFULL
|
324
|
+
case CURLE_TFTP_DISKFULL: /* 70 - out of disk space on server */
|
325
|
+
exclz = eCurlErrTFTPDiskFull;
|
326
|
+
break;
|
327
|
+
#endif
|
328
|
+
#ifdef CURLE_TFTP_ILLEGAL
|
329
|
+
case CURLE_TFTP_ILLEGAL: /* 71 - Illegal TFTP operation */
|
330
|
+
exclz = eCurlErrTFTPIllegalOperation;
|
331
|
+
break;
|
332
|
+
#endif
|
333
|
+
#ifdef CURLE_TFTP_UNKNOWNID
|
334
|
+
case CURLE_TFTP_UNKNOWNID: /* 72 - Unknown transfer ID */
|
335
|
+
exclz = eCurlErrTFTPUnknownID;
|
336
|
+
break;
|
337
|
+
#endif
|
338
|
+
#ifdef CURLE_TFTP_EXISTS
|
339
|
+
case CURLE_TFTP_EXISTS: /* 73 - File already exists */
|
340
|
+
exclz = eCurlErrTFTPFileExists;
|
341
|
+
break;
|
342
|
+
#endif
|
343
|
+
#ifdef CURLE_TFTP_NOSUCHUSER
|
344
|
+
case CURLE_TFTP_NOSUCHUSER: /* 74 - No such user */
|
345
|
+
exclz = eCurlErrTFTPNotFound;
|
346
|
+
break;
|
347
|
+
#endif
|
348
|
+
default:
|
349
|
+
exclz = eCurlErrError;
|
350
|
+
exmsg = "Unknown error result from libcurl";
|
351
|
+
}
|
352
|
+
|
353
|
+
if (!exmsg) {
|
354
|
+
exmsg = curl_easy_strerror(code);
|
355
|
+
}
|
356
|
+
|
357
|
+
rb_raise(exclz, exmsg);
|
358
|
+
}
|
359
|
+
|
360
|
+
void init_curb_errors() {
|
361
|
+
mCurlErr = rb_define_module_under(mCurl, "Err");
|
362
|
+
eCurlErrError = rb_define_class_under(mCurlErr, "CurlError", rb_eRuntimeError);
|
363
|
+
|
364
|
+
eCurlErrFTPError = rb_define_class_under(mCurlErr, "FTPError", eCurlErrError);
|
365
|
+
eCurlErrHTTPError = rb_define_class_under(mCurlErr, "HTTPError", eCurlErrError);
|
366
|
+
eCurlErrFileError = rb_define_class_under(mCurlErr, "FileError", eCurlErrError);
|
367
|
+
eCurlErrLDAPError = rb_define_class_under(mCurlErr, "LDAPError", eCurlErrError);
|
368
|
+
eCurlErrTelnetError = rb_define_class_under(mCurlErr, "TelnetError", eCurlErrError);
|
369
|
+
eCurlErrTFTPError = rb_define_class_under(mCurlErr, "TFTPError", eCurlErrError);
|
370
|
+
|
371
|
+
eCurlErrUnsupportedProtocol = rb_define_class_under(mCurlErr, "UnsupportedProtocolError", eCurlErrError);
|
372
|
+
eCurlErrFailedInit = rb_define_class_under(mCurlErr, "FailedInitError", eCurlErrError);
|
373
|
+
eCurlErrMalformedURL = rb_define_class_under(mCurlErr, "MalformedURLError", eCurlErrError);
|
374
|
+
eCurlErrMalformedURLUser = rb_define_class_under(mCurlErr, "MalformedURLUserError", eCurlErrError);
|
375
|
+
eCurlErrProxyResolution = rb_define_class_under(mCurlErr, "ProxyResolutionError", eCurlErrError);
|
376
|
+
eCurlErrHostResolution = rb_define_class_under(mCurlErr, "HostResolutionError", eCurlErrError);
|
377
|
+
eCurlErrConnectFailed = rb_define_class_under(mCurlErr, "ConnectionFailedError", eCurlErrError);
|
378
|
+
|
379
|
+
eCurlErrFTPWierdReply = rb_define_class_under(mCurlErr, "WierdReplyError", eCurlErrFTPError);
|
380
|
+
eCurlErrFTPAccessDenied = rb_define_class_under(mCurlErr, "AccessDeniedError", eCurlErrFTPError);
|
381
|
+
eCurlErrFTPBadPassword = rb_define_class_under(mCurlErr, "BadBasswordError", eCurlErrFTPError);
|
382
|
+
eCurlErrFTPWierdPassReply = rb_define_class_under(mCurlErr, "WierdPassReplyError", eCurlErrFTPError);
|
383
|
+
eCurlErrFTPWierdUserReply = rb_define_class_under(mCurlErr, "WierdUserReplyError", eCurlErrFTPError);
|
384
|
+
eCurlErrFTPWierdPasvReply = rb_define_class_under(mCurlErr, "WierdPasvReplyError", eCurlErrFTPError);
|
385
|
+
eCurlErrFTPWierd227Format = rb_define_class_under(mCurlErr, "Wierd227FormatError", eCurlErrFTPError);
|
386
|
+
eCurlErrFTPCantGetHost = rb_define_class_under(mCurlErr, "CantGetHostError", eCurlErrFTPError);
|
387
|
+
eCurlErrFTPCantReconnect = rb_define_class_under(mCurlErr, "CantReconnectError", eCurlErrFTPError);
|
388
|
+
eCurlErrFTPCouldntSetBinary = rb_define_class_under(mCurlErr, "CouldntSetBinaryError", eCurlErrFTPError);
|
389
|
+
|
390
|
+
eCurlErrPartialFile = rb_define_class_under(mCurlErr, "PartialFileError", eCurlErrError);
|
391
|
+
|
392
|
+
eCurlErrFTPCouldntRetrFile = rb_define_class_under(mCurlErr, "CouldntRetrFileError", eCurlErrFTPError);
|
393
|
+
eCurlErrFTPWrite = rb_define_class_under(mCurlErr, "FTPWriteError", eCurlErrFTPError);
|
394
|
+
eCurlErrFTPQuote = rb_define_class_under(mCurlErr, "FTPQuoteError", eCurlErrFTPError);
|
395
|
+
|
396
|
+
eCurlErrHTTPFailed = rb_define_class_under(mCurlErr, "HTTPFailedError", eCurlErrHTTPError);
|
397
|
+
|
398
|
+
eCurlErrWriteError = rb_define_class_under(mCurlErr, "WriteError", eCurlErrError);
|
399
|
+
eCurlErrMalformedUser = rb_define_class_under(mCurlErr, "MalformedUserError", eCurlErrError);
|
400
|
+
|
401
|
+
eCurlErrFTPCouldntStorFile = rb_define_class_under(mCurlErr, "CouldntStorFileError", eCurlErrFTPError);
|
402
|
+
|
403
|
+
eCurlErrReadError = rb_define_class_under(mCurlErr, "ReadError", eCurlErrError);
|
404
|
+
eCurlErrOutOfMemory = rb_define_class_under(mCurlErr, "OutOfMemoryError", eCurlErrError);
|
405
|
+
eCurlErrTimeout = rb_define_class_under(mCurlErr, "TimeoutError", eCurlErrError);
|
406
|
+
|
407
|
+
eCurlErrFTPCouldntSetASCII = rb_define_class_under(mCurlErr, "CouldntSetASCIIError", eCurlErrFTPError);
|
408
|
+
eCurlErrFTPPortFailed = rb_define_class_under(mCurlErr, "PortFailedError", eCurlErrFTPError);
|
409
|
+
eCurlErrFTPCouldntUseRest = rb_define_class_under(mCurlErr, "CouldntUseRestError", eCurlErrFTPError);
|
410
|
+
eCurlErrFTPCouldntGetSize = rb_define_class_under(mCurlErr, "CouldntGetSizeError", eCurlErrFTPError);
|
411
|
+
|
412
|
+
eCurlErrHTTPRange = rb_define_class_under(mCurlErr, "HTTPRangeError", eCurlErrHTTPError);
|
413
|
+
eCurlErrHTTPPost = rb_define_class_under(mCurlErr, "HTTPPostError", eCurlErrHTTPError);
|
414
|
+
|
415
|
+
eCurlErrSSLConnectError = rb_define_class_under(mCurlErr, "SSLConnectError", eCurlErrError);
|
416
|
+
eCurlErrBadResume = rb_define_class_under(mCurlErr, "BadResumeError", eCurlErrError);
|
417
|
+
|
418
|
+
eCurlErrFileCouldntRead = rb_define_class_under(mCurlErr, "CouldntReadError", eCurlErrFileError);
|
419
|
+
|
420
|
+
eCurlErrLDAPCouldntBind = rb_define_class_under(mCurlErr, "CouldntBindError", eCurlErrLDAPError);
|
421
|
+
eCurlErrLDAPSearchFailed = rb_define_class_under(mCurlErr, "SearchFailedError", eCurlErrLDAPError);
|
422
|
+
|
423
|
+
eCurlErrLibraryNotFound = rb_define_class_under(mCurlErr, "LibraryNotFoundError", eCurlErrError);
|
424
|
+
eCurlErrFunctionNotFound = rb_define_class_under(mCurlErr, "FunctionNotFoundError", eCurlErrError);
|
425
|
+
eCurlErrAbortedByCallback = rb_define_class_under(mCurlErr, "AbortedByCallbackError", eCurlErrError);
|
426
|
+
eCurlErrBadFunctionArgument = rb_define_class_under(mCurlErr, "BadFunctionArgumentError", eCurlErrError);
|
427
|
+
eCurlErrBadCallingOrder = rb_define_class_under(mCurlErr, "BadCallingOrderError", eCurlErrError);
|
428
|
+
eCurlErrInterfaceFailed = rb_define_class_under(mCurlErr, "InterfaceFailedError", eCurlErrError);
|
429
|
+
|
430
|
+
eCurlErrBadPasswordEntered = rb_define_class_under(mCurlErr, "BadPasswordEnteredError", eCurlErrError);
|
431
|
+
eCurlErrTooManyRedirects = rb_define_class_under(mCurlErr, "TooManyRedirectsError", eCurlErrError);
|
432
|
+
|
433
|
+
eCurlErrTelnetUnknownOption = rb_define_class_under(mCurlErr, "UnknownOptionError", eCurlErrTelnetError);
|
434
|
+
eCurlErrTelnetBadOptionSyntax = rb_define_class_under(mCurlErr, "BadOptionSyntaxError", eCurlErrTelnetError);
|
435
|
+
|
436
|
+
eCurlErrObsolete = rb_define_class_under(mCurlErr, "ObsoleteError", eCurlErrError);
|
437
|
+
eCurlErrSSLPeerCertificate = rb_define_class_under(mCurlErr, "SSLPeerCertificateError", eCurlErrError);
|
438
|
+
eCurlErrGotNothing = rb_define_class_under(mCurlErr, "GotNothingError", eCurlErrError);
|
439
|
+
|
440
|
+
eCurlErrSSLEngineNotFound = rb_define_class_under(mCurlErr, "SSLEngineNotFoundError", eCurlErrError);
|
441
|
+
eCurlErrSSLEngineSetFailed = rb_define_class_under(mCurlErr, "SSLEngineSetFailedError", eCurlErrError);
|
442
|
+
|
443
|
+
eCurlErrSendError = rb_define_class_under(mCurlErr, "SendError", eCurlErrError);
|
444
|
+
eCurlErrRecvError = rb_define_class_under(mCurlErr, "RecvError", eCurlErrError);
|
445
|
+
eCurlErrShareInUse = rb_define_class_under(mCurlErr, "ShareInUseError", eCurlErrError);
|
446
|
+
|
447
|
+
eCurlErrSSLCertificate = rb_define_class_under(mCurlErr, "SSLCertificateError", eCurlErrError);
|
448
|
+
eCurlErrSSLCipher = rb_define_class_under(mCurlErr, "SSLCypherError", eCurlErrError);
|
449
|
+
eCurlErrSSLCACertificate = rb_define_class_under(mCurlErr, "SSLCACertificateError", eCurlErrError);
|
450
|
+
eCurlErrBadContentEncoding = rb_define_class_under(mCurlErr, "BadContentEncodingError", eCurlErrError);
|
451
|
+
|
452
|
+
eCurlErrLDAPInvalidURL = rb_define_class_under(mCurlErr, "InvalidLDAPURLError", eCurlErrLDAPError);
|
453
|
+
|
454
|
+
eCurlErrFileSizeExceeded = rb_define_class_under(mCurlErr, "FileSizeExceededError", eCurlErrError);
|
455
|
+
|
456
|
+
eCurlErrFTPSSLFailed = rb_define_class_under(mCurlErr, "FTPSSLFailed", eCurlErrFTPError);
|
457
|
+
|
458
|
+
eCurlErrSendFailedRewind = rb_define_class_under(mCurlErr, "SendFailedRewind", eCurlErrError);
|
459
|
+
eCurlErrSSLEngineInitFailed = rb_define_class_under(mCurlErr, "SSLEngineInitFailedError", eCurlErrError);
|
460
|
+
eCurlErrLoginDenied = rb_define_class_under(mCurlErr, "LoginDeniedError", eCurlErrError);
|
461
|
+
|
462
|
+
eCurlErrTFTPNotFound = rb_define_class_under(mCurlErr, "NotFoundError", eCurlErrTFTPError);
|
463
|
+
eCurlErrTFTPPermission = rb_define_class_under(mCurlErr, "PermissionError", eCurlErrTFTPError);
|
464
|
+
eCurlErrTFTPDiskFull = rb_define_class_under(mCurlErr, "DiskFullError", eCurlErrTFTPError);
|
465
|
+
eCurlErrTFTPIllegalOperation = rb_define_class_under(mCurlErr, "IllegalOperationError", eCurlErrTFTPError);
|
466
|
+
eCurlErrTFTPUnknownID = rb_define_class_under(mCurlErr, "UnknownIDError", eCurlErrTFTPError);
|
467
|
+
eCurlErrTFTPFileExists = rb_define_class_under(mCurlErr, "FileExistsError", eCurlErrTFTPError);
|
468
|
+
eCurlErrTFTPNoSuchUser = rb_define_class_under(mCurlErr, "NoSuchUserError", eCurlErrTFTPError);
|
469
|
+
|
470
|
+
eCurlErrInvalidPostField = rb_define_class_under(mCurlErr, "InvalidPostFieldError", eCurlErrError);
|
471
|
+
}
|