rhack 0.2.2

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