ghazel-curb 0.5.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/ext/curb_errors.h ADDED
@@ -0,0 +1,128 @@
1
+ /* curb_errors.h - 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.h 4 2006-11-17 18:35:31Z roscopeco $
6
+ */
7
+ #ifndef __CURB_ERRORS_H
8
+ #define __CURB_ERRORS_H
9
+
10
+ #include "curb.h"
11
+
12
+ /* base errors */
13
+ extern VALUE cCurlErr;
14
+
15
+ /* easy errors */
16
+ extern VALUE mCurlErr;
17
+ extern VALUE eCurlErrError;
18
+ extern VALUE eCurlErrFTPError;
19
+ extern VALUE eCurlErrHTTPError;
20
+ extern VALUE eCurlErrFileError;
21
+ extern VALUE eCurlErrLDAPError;
22
+ extern VALUE eCurlErrTelnetError;
23
+ extern VALUE eCurlErrTFTPError;
24
+
25
+ /* libcurl errors */
26
+ extern VALUE eCurlErrUnsupportedProtocol;
27
+ extern VALUE eCurlErrFailedInit;
28
+ extern VALUE eCurlErrMalformedURL;
29
+ extern VALUE eCurlErrMalformedURLUser;
30
+ extern VALUE eCurlErrProxyResolution;
31
+ extern VALUE eCurlErrHostResolution;
32
+ extern VALUE eCurlErrConnectFailed;
33
+ extern VALUE eCurlErrFTPWierdReply;
34
+ extern VALUE eCurlErrFTPAccessDenied;
35
+ extern VALUE eCurlErrFTPBadPassword;
36
+ extern VALUE eCurlErrFTPWierdPassReply;
37
+ extern VALUE eCurlErrFTPWierdUserReply;
38
+ extern VALUE eCurlErrFTPWierdPasvReply;
39
+ extern VALUE eCurlErrFTPWierd227Format;
40
+ extern VALUE eCurlErrFTPCantGetHost;
41
+ extern VALUE eCurlErrFTPCantReconnect;
42
+ extern VALUE eCurlErrFTPCouldntSetBinary;
43
+ extern VALUE eCurlErrPartialFile;
44
+ extern VALUE eCurlErrFTPCouldntRetrFile;
45
+ extern VALUE eCurlErrFTPWrite;
46
+ extern VALUE eCurlErrFTPQuote;
47
+ extern VALUE eCurlErrHTTPFailed;
48
+ extern VALUE eCurlErrWriteError;
49
+ extern VALUE eCurlErrMalformedUser;
50
+ extern VALUE eCurlErrFTPCouldntStorFile;
51
+ extern VALUE eCurlErrReadError;
52
+ extern VALUE eCurlErrOutOfMemory;
53
+ extern VALUE eCurlErrTimeout;
54
+ extern VALUE eCurlErrFTPCouldntSetASCII;
55
+ extern VALUE eCurlErrFTPPortFailed;
56
+ extern VALUE eCurlErrFTPCouldntUseRest;
57
+ extern VALUE eCurlErrFTPCouldntGetSize;
58
+ extern VALUE eCurlErrHTTPRange;
59
+ extern VALUE eCurlErrHTTPPost;
60
+ extern VALUE eCurlErrSSLConnectError;
61
+ extern VALUE eCurlErrBadResume;
62
+ extern VALUE eCurlErrFileCouldntRead;
63
+ extern VALUE eCurlErrLDAPCouldntBind;
64
+ extern VALUE eCurlErrLDAPSearchFailed;
65
+ extern VALUE eCurlErrLibraryNotFound;
66
+ extern VALUE eCurlErrFunctionNotFound;
67
+ extern VALUE eCurlErrAbortedByCallback;
68
+ extern VALUE eCurlErrBadFunctionArgument;
69
+ extern VALUE eCurlErrBadCallingOrder;
70
+ extern VALUE eCurlErrInterfaceFailed;
71
+ extern VALUE eCurlErrBadPasswordEntered;
72
+ extern VALUE eCurlErrTooManyRedirects;
73
+ extern VALUE eCurlErrTelnetUnknownOption;
74
+ extern VALUE eCurlErrTelnetBadOptionSyntax;
75
+ extern VALUE eCurlErrObsolete;
76
+ extern VALUE eCurlErrSSLPeerCertificate;
77
+ extern VALUE eCurlErrGotNothing;
78
+ extern VALUE eCurlErrSSLEngineNotFound;
79
+ extern VALUE eCurlErrSSLEngineSetFailed;
80
+ extern VALUE eCurlErrSendError;
81
+ extern VALUE eCurlErrRecvError;
82
+ extern VALUE eCurlErrShareInUse;
83
+ extern VALUE eCurlErrSSLCertificate;
84
+ extern VALUE eCurlErrSSLCipher;
85
+ extern VALUE eCurlErrSSLCACertificate;
86
+ extern VALUE eCurlErrBadContentEncoding;
87
+ extern VALUE eCurlErrLDAPInvalidURL;
88
+ extern VALUE eCurlErrFileSizeExceeded;
89
+ extern VALUE eCurlErrFTPSSLFailed;
90
+ extern VALUE eCurlErrSendFailedRewind;
91
+ extern VALUE eCurlErrSSLEngineInitFailed;
92
+ extern VALUE eCurlErrLoginDenied;
93
+ extern VALUE eCurlErrTFTPNotFound;
94
+ extern VALUE eCurlErrTFTPPermission;
95
+ extern VALUE eCurlErrTFTPDiskFull;
96
+ extern VALUE eCurlErrTFTPIllegalOperation;
97
+ extern VALUE eCurlErrTFTPUnknownID;
98
+ extern VALUE eCurlErrTFTPFileExists;
99
+ extern VALUE eCurlErrTFTPNoSuchUser;
100
+ extern VALUE eCurlErrConvFailed;
101
+ extern VALUE eCurlErrConvReqd;
102
+ extern VALUE eCurlErrSSLCacertBadfile;
103
+ extern VALUE eCurlErrRemoteFileNotFound;
104
+ extern VALUE eCurlErrSSH;
105
+ extern VALUE eCurlErrSSLShutdownFailed;
106
+ extern VALUE eCurlErrAgain;
107
+ extern VALUE eCurlErrSSLCRLBadfile;
108
+ extern VALUE eCurlErrSSLIssuerError;
109
+
110
+ /* multi errors */
111
+ extern VALUE mCurlErrCallMultiPerform;
112
+ extern VALUE mCurlErrBadHandle;
113
+ extern VALUE mCurlErrBadEasyHandle;
114
+ extern VALUE mCurlErrOutOfMemory;
115
+ extern VALUE mCurlErrInternalError;
116
+ extern VALUE mCurlErrBadSocket;
117
+ extern VALUE mCurlErrUnknownOption;
118
+
119
+ /* binding errors */
120
+ extern VALUE eCurlErrInvalidPostField;
121
+
122
+ void init_curb_errors();
123
+ void raise_curl_easy_error_exception(CURLcode code);
124
+ void raise_curl_multi_error_exception(CURLMcode code);
125
+ VALUE rb_curl_easy_error(CURLcode code);
126
+ VALUE rb_curl_multi_error(CURLMcode code);
127
+
128
+ #endif
data/ext/curb_macros.h ADDED
@@ -0,0 +1,114 @@
1
+ /* Curb - helper macros for ruby integration
2
+ * Copyright (c)2006 Ross Bamford.
3
+ * Licensed under the Ruby License. See LICENSE for details.
4
+ *
5
+ * $Id: curb_macros.h 13 2006-11-23 23:54:25Z roscopeco $
6
+ */
7
+
8
+ #ifndef __CURB_MACROS_H
9
+ #define __CURB_MACROS_H
10
+
11
+ /* getter/setter macros for various things */
12
+ /* setter for anything that stores a ruby VALUE in the struct */
13
+ #define CURB_OBJECT_SETTER(type, attr) \
14
+ type *ptr; \
15
+ \
16
+ Data_Get_Struct(self, type, ptr); \
17
+ ptr->attr = attr; \
18
+ \
19
+ return attr;
20
+
21
+ /* getter for anything that stores a ruby VALUE */
22
+ #define CURB_OBJECT_GETTER(type, attr) \
23
+ type *ptr; \
24
+ \
25
+ Data_Get_Struct(self, type, ptr); \
26
+ return ptr->attr;
27
+
28
+ /* setter for bool flags */
29
+ #define CURB_BOOLEAN_SETTER(type, attr) \
30
+ type *ptr; \
31
+ Data_Get_Struct(self, type, ptr); \
32
+ \
33
+ if (attr == Qnil || attr == Qfalse) { \
34
+ ptr->attr = 0; \
35
+ } else { \
36
+ ptr->attr = 1; \
37
+ } \
38
+ \
39
+ return attr;
40
+
41
+ /* getter for bool flags */
42
+ #define CURB_BOOLEAN_GETTER(type, attr) \
43
+ type *ptr; \
44
+ Data_Get_Struct(self, type, ptr); \
45
+ \
46
+ return((ptr->attr) ? Qtrue : Qfalse);
47
+
48
+ /* special setter for on_event handlers that take a block */
49
+ #define CURB_HANDLER_PROC_SETTER(type, handler) \
50
+ type *ptr; \
51
+ VALUE oldproc; \
52
+ \
53
+ Data_Get_Struct(self, type, ptr); \
54
+ \
55
+ oldproc = ptr->handler; \
56
+ rb_scan_args(argc, argv, "0&", &ptr->handler); \
57
+ \
58
+ return oldproc; \
59
+
60
+ /* setter for numerics that are kept in c ints */
61
+ #define CURB_IMMED_SETTER(type, attr, nilval) \
62
+ type *ptr; \
63
+ \
64
+ Data_Get_Struct(self, type, ptr); \
65
+ if (attr == Qnil) { \
66
+ ptr->attr = nilval; \
67
+ } else { \
68
+ ptr->attr = NUM2INT(attr); \
69
+ } \
70
+ \
71
+ return attr; \
72
+
73
+ /* setter for numerics that are kept in c ints */
74
+ #define CURB_IMMED_GETTER(type, attr, nilval) \
75
+ type *ptr; \
76
+ \
77
+ Data_Get_Struct(self, type, ptr); \
78
+ if (ptr->attr == nilval) { \
79
+ return Qnil; \
80
+ } else { \
81
+ return INT2NUM(ptr->attr); \
82
+ }
83
+
84
+ /* special setter for port / port ranges */
85
+ #define CURB_IMMED_PORT_SETTER(type, attr, msg) \
86
+ type *ptr; \
87
+ \
88
+ Data_Get_Struct(self, type, ptr); \
89
+ if (attr == Qnil) { \
90
+ ptr->attr = 0; \
91
+ } else { \
92
+ int port = FIX2INT(attr); \
93
+ \
94
+ if ((port) && ((port & 0xFFFF) == port)) { \
95
+ ptr->attr = port; \
96
+ } else { \
97
+ rb_raise(rb_eArgError, "Invalid " msg " %d (expected between 1 and 65535)", port); \
98
+ } \
99
+ } \
100
+ \
101
+ return attr; \
102
+
103
+ /* special getter for port / port ranges */
104
+ #define CURB_IMMED_PORT_GETTER(type, attr) \
105
+ type *ptr; \
106
+ \
107
+ Data_Get_Struct(self, type, ptr); \
108
+ if (ptr->attr == 0) { \
109
+ return Qnil; \
110
+ } else { \
111
+ return INT2FIX(ptr->attr); \
112
+ }
113
+
114
+ #endif