rhack 1.2.1 → 1.2.7
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.
- checksums.yaml +13 -5
- data/README.md +21 -9
- data/ext/curb/curb.c +977 -977
- data/ext/curb/curb.h +52 -52
- data/ext/curb/curb_config.h +270 -270
- data/ext/curb/curb_easy.c +3437 -3434
- data/ext/curb/curb_easy.h +94 -94
- data/ext/curb/curb_errors.c +647 -647
- data/ext/curb/curb_errors.h +129 -129
- data/ext/curb/curb_macros.h +162 -162
- data/ext/curb/curb_multi.c +704 -702
- data/ext/curb/curb_multi.h +26 -26
- data/ext/curb/curb_postfield.c +523 -523
- data/ext/curb/curb_postfield.h +40 -40
- data/ext/curb/curb_upload.c +80 -80
- data/ext/curb/curb_upload.h +30 -30
- data/ext/curb-original/curb.c +977 -977
- data/ext/curb-original/curb.h +52 -52
- data/ext/curb-original/curb_config.h +238 -238
- data/ext/curb-original/curb_easy.c +3404 -3404
- data/ext/curb-original/curb_easy.h +90 -90
- data/ext/curb-original/curb_errors.c +647 -647
- data/ext/curb-original/curb_errors.h +129 -129
- data/ext/curb-original/curb_macros.h +159 -159
- data/ext/curb-original/curb_multi.c +633 -633
- data/ext/curb-original/curb_multi.h +26 -26
- data/ext/curb-original/curb_postfield.c +523 -523
- data/ext/curb-original/curb_postfield.h +40 -40
- data/ext/curb-original/curb_upload.c +80 -80
- data/ext/curb-original/curb_upload.h +30 -30
- data/lib/rhack/clients/base.rb +61 -10
- data/lib/rhack/clients/oauth.rb +4 -4
- data/lib/rhack/curl/easy.rb +1 -0
- data/lib/rhack/curl/global.rb +2 -0
- data/lib/rhack/curl/response.rb +4 -2
- data/lib/rhack/frame.rb +70 -32
- data/lib/rhack/js/browser/env.js +697 -697
- data/lib/rhack/js/browser/jquery.js +7180 -7180
- data/lib/rhack/js/browser/xmlsax.js +1564 -1564
- data/lib/rhack/js/browser/xmlw3cdom_1.js +1443 -1443
- data/lib/rhack/js/browser/xmlw3cdom_2.js +2744 -2744
- data/lib/rhack/page.rb +227 -68
- data/lib/rhack/scout.rb +52 -26
- data/lib/rhack/scout_squad.rb +10 -2
- data/lib/rhack/version.rb +1 -1
- data/rhack.gemspec +1 -1
- metadata +17 -17
data/ext/curb/curb_errors.h
CHANGED
@@ -1,129 +1,129 @@
|
|
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 mCurlErrFailedInit;
|
112
|
-
extern VALUE mCurlErrCallMultiPerform;
|
113
|
-
extern VALUE mCurlErrBadHandle;
|
114
|
-
extern VALUE mCurlErrBadEasyHandle;
|
115
|
-
extern VALUE mCurlErrOutOfMemory;
|
116
|
-
extern VALUE mCurlErrInternalError;
|
117
|
-
extern VALUE mCurlErrBadSocket;
|
118
|
-
extern VALUE mCurlErrUnknownOption;
|
119
|
-
|
120
|
-
/* binding errors */
|
121
|
-
extern VALUE eCurlErrInvalidPostField;
|
122
|
-
|
123
|
-
void init_curb_errors();
|
124
|
-
void raise_curl_easy_error_exception(CURLcode code);
|
125
|
-
void raise_curl_multi_error_exception(CURLMcode code);
|
126
|
-
VALUE rb_curl_easy_error(CURLcode code);
|
127
|
-
VALUE rb_curl_multi_error(CURLMcode code);
|
128
|
-
|
129
|
-
#endif
|
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 mCurlErrFailedInit;
|
112
|
+
extern VALUE mCurlErrCallMultiPerform;
|
113
|
+
extern VALUE mCurlErrBadHandle;
|
114
|
+
extern VALUE mCurlErrBadEasyHandle;
|
115
|
+
extern VALUE mCurlErrOutOfMemory;
|
116
|
+
extern VALUE mCurlErrInternalError;
|
117
|
+
extern VALUE mCurlErrBadSocket;
|
118
|
+
extern VALUE mCurlErrUnknownOption;
|
119
|
+
|
120
|
+
/* binding errors */
|
121
|
+
extern VALUE eCurlErrInvalidPostField;
|
122
|
+
|
123
|
+
void init_curb_errors();
|
124
|
+
void raise_curl_easy_error_exception(CURLcode code);
|
125
|
+
void raise_curl_multi_error_exception(CURLMcode code);
|
126
|
+
VALUE rb_curl_easy_error(CURLcode code);
|
127
|
+
VALUE rb_curl_multi_error(CURLMcode code);
|
128
|
+
|
129
|
+
#endif
|
data/ext/curb/curb_macros.h
CHANGED
@@ -1,162 +1,162 @@
|
|
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
|
-
#define rb_easy_sym(sym) ID2SYM(rb_intern(sym))
|
12
|
-
#define rb_easy_hkey(key) ID2SYM(rb_intern(key))
|
13
|
-
#define rb_easy_set(key,val) rb_hash_aset(rbce->opts, rb_easy_hkey(key) , val)
|
14
|
-
#define rb_easy_get(key) rb_hash_aref(rbce->opts, rb_easy_hkey(key))
|
15
|
-
#define rb_easy_del(key) rb_hash_delete(rbce->opts, rb_easy_hkey(key))
|
16
|
-
#define rb_easy_nil(key) (rb_hash_aref(rbce->opts, rb_easy_hkey(key)) == Qnil)
|
17
|
-
#define rb_easy_type_check(key,type) (rb_type(rb_hash_aref(rbce->opts, rb_easy_hkey(key))) == type)
|
18
|
-
|
19
|
-
// TODO: rb_sym_to_s may not be defined?
|
20
|
-
#define rb_easy_get_str(key) \
|
21
|
-
RSTRING_PTR((rb_easy_type_check(key,T_STRING) ? rb_easy_get(key) : rb_str_to_str(rb_easy_get(key))))
|
22
|
-
|
23
|
-
/* getter/setter macros for various things */
|
24
|
-
/* setter for anything that stores a ruby VALUE in the struct */
|
25
|
-
#define CURB_OBJECT_SETTER(type, attr) \
|
26
|
-
type *ptr; \
|
27
|
-
\
|
28
|
-
Data_Get_Struct(self, type, ptr); \
|
29
|
-
ptr->attr = attr; \
|
30
|
-
\
|
31
|
-
return attr;
|
32
|
-
|
33
|
-
/* getter for anything that stores a ruby VALUE */
|
34
|
-
#define CURB_OBJECT_GETTER(type, attr) \
|
35
|
-
type *ptr; \
|
36
|
-
\
|
37
|
-
Data_Get_Struct(self, type, ptr); \
|
38
|
-
return ptr->attr;
|
39
|
-
|
40
|
-
/* setter for anything that stores a ruby VALUE in the struct opts hash */
|
41
|
-
#define CURB_OBJECT_HSETTER(type, attr) \
|
42
|
-
type *ptr; \
|
43
|
-
\
|
44
|
-
Data_Get_Struct(self, type, ptr); \
|
45
|
-
rb_hash_aset(ptr->opts, rb_easy_hkey(#attr), attr); \
|
46
|
-
\
|
47
|
-
return attr;
|
48
|
-
|
49
|
-
/* getter for anything that stores a ruby VALUE in the struct opts hash */
|
50
|
-
#define CURB_OBJECT_HGETTER(type, attr) \
|
51
|
-
type *ptr; \
|
52
|
-
\
|
53
|
-
Data_Get_Struct(self, type, ptr); \
|
54
|
-
return rb_hash_aref(ptr->opts, rb_easy_hkey(#attr));
|
55
|
-
|
56
|
-
/* setter for bool flags */
|
57
|
-
#define CURB_BOOLEAN_SETTER(type, attr) \
|
58
|
-
type *ptr; \
|
59
|
-
Data_Get_Struct(self, type, ptr); \
|
60
|
-
\
|
61
|
-
if (attr == Qnil || attr == Qfalse) { \
|
62
|
-
ptr->attr = 0; \
|
63
|
-
} else { \
|
64
|
-
ptr->attr = 1; \
|
65
|
-
} \
|
66
|
-
\
|
67
|
-
return attr;
|
68
|
-
|
69
|
-
/* getter for bool flags */
|
70
|
-
#define CURB_BOOLEAN_GETTER(type, attr) \
|
71
|
-
type *ptr; \
|
72
|
-
Data_Get_Struct(self, type, ptr); \
|
73
|
-
\
|
74
|
-
return((ptr->attr) ? Qtrue : Qfalse);
|
75
|
-
|
76
|
-
/* special setter for on_event handlers that take a block */
|
77
|
-
#define CURB_HANDLER_PROC_SETTER(type, handler) \
|
78
|
-
type *ptr; \
|
79
|
-
VALUE oldproc; \
|
80
|
-
\
|
81
|
-
Data_Get_Struct(self, type, ptr); \
|
82
|
-
\
|
83
|
-
oldproc = ptr->handler; \
|
84
|
-
rb_scan_args(argc, argv, "0&", &ptr->handler); \
|
85
|
-
\
|
86
|
-
return oldproc; \
|
87
|
-
|
88
|
-
/* special setter for on_event handlers that take a block, same as above but stores int he opts hash
|
89
|
-
set proc to nil if handler == Proc::NULL; just return current proc if handler is not given
|
90
|
-
*/
|
91
|
-
#define CURB_HANDLER_PROC_HSETTER(type, handler) \
|
92
|
-
type *ptr; \
|
93
|
-
VALUE oldproc, newproc; \
|
94
|
-
\
|
95
|
-
Data_Get_Struct(self, type, ptr); \
|
96
|
-
\
|
97
|
-
oldproc = rb_hash_aref(ptr->opts, rb_easy_hkey(#handler)); \
|
98
|
-
rb_scan_args(argc, argv, "0&", &newproc); \
|
99
|
-
if ( RTEST(rb_funcall(newproc, rb_intern("b"), 0)) ) \
|
100
|
-
rb_hash_aset(ptr->opts, rb_easy_hkey(#handler), newproc); \
|
101
|
-
else if (newproc != Qnil) \
|
102
|
-
rb_hash_aset(ptr->opts, rb_easy_hkey(#handler), Qnil); \
|
103
|
-
return oldproc;
|
104
|
-
|
105
|
-
/* setter for numerics that are kept in c ints */
|
106
|
-
#define CURB_IMMED_SETTER(type, attr, nilval) \
|
107
|
-
type *ptr; \
|
108
|
-
\
|
109
|
-
Data_Get_Struct(self, type, ptr); \
|
110
|
-
if (attr == Qnil) { \
|
111
|
-
ptr->attr = nilval; \
|
112
|
-
} else { \
|
113
|
-
ptr->attr = NUM2INT(attr); \
|
114
|
-
} \
|
115
|
-
\
|
116
|
-
return attr; \
|
117
|
-
|
118
|
-
/* setter for numerics that are kept in c ints */
|
119
|
-
#define CURB_IMMED_GETTER(type, attr, nilval) \
|
120
|
-
type *ptr; \
|
121
|
-
\
|
122
|
-
Data_Get_Struct(self, type, ptr); \
|
123
|
-
if (ptr->attr == nilval) { \
|
124
|
-
return Qnil; \
|
125
|
-
} else { \
|
126
|
-
return INT2NUM(ptr->attr); \
|
127
|
-
}
|
128
|
-
|
129
|
-
/* special setter for port / port ranges */
|
130
|
-
#define CURB_IMMED_PORT_SETTER(type, attr, msg) \
|
131
|
-
type *ptr; \
|
132
|
-
\
|
133
|
-
Data_Get_Struct(self, type, ptr); \
|
134
|
-
if (attr == Qnil) { \
|
135
|
-
ptr->attr = 0; \
|
136
|
-
} else { \
|
137
|
-
int port = FIX2INT(attr); \
|
138
|
-
\
|
139
|
-
if ((port) && ((port & 0xFFFF) == port)) { \
|
140
|
-
ptr->attr = port; \
|
141
|
-
} else { \
|
142
|
-
rb_raise(rb_eArgError, "Invalid " msg " %d (expected between 1 and 65535)", port); \
|
143
|
-
} \
|
144
|
-
} \
|
145
|
-
\
|
146
|
-
return attr; \
|
147
|
-
|
148
|
-
/* special getter for port / port ranges */
|
149
|
-
#define CURB_IMMED_PORT_GETTER(type, attr) \
|
150
|
-
type *ptr; \
|
151
|
-
\
|
152
|
-
Data_Get_Struct(self, type, ptr); \
|
153
|
-
if (ptr->attr == 0) { \
|
154
|
-
return Qnil; \
|
155
|
-
} else { \
|
156
|
-
return INT2FIX(ptr->attr); \
|
157
|
-
}
|
158
|
-
|
159
|
-
#define CURB_DEFINE(name) \
|
160
|
-
rb_define_const(mCurl, #name, INT2FIX(name))
|
161
|
-
|
162
|
-
#endif
|
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
|
+
#define rb_easy_sym(sym) ID2SYM(rb_intern(sym))
|
12
|
+
#define rb_easy_hkey(key) ID2SYM(rb_intern(key))
|
13
|
+
#define rb_easy_set(key,val) rb_hash_aset(rbce->opts, rb_easy_hkey(key) , val)
|
14
|
+
#define rb_easy_get(key) rb_hash_aref(rbce->opts, rb_easy_hkey(key))
|
15
|
+
#define rb_easy_del(key) rb_hash_delete(rbce->opts, rb_easy_hkey(key))
|
16
|
+
#define rb_easy_nil(key) (rb_hash_aref(rbce->opts, rb_easy_hkey(key)) == Qnil)
|
17
|
+
#define rb_easy_type_check(key,type) (rb_type(rb_hash_aref(rbce->opts, rb_easy_hkey(key))) == type)
|
18
|
+
|
19
|
+
// TODO: rb_sym_to_s may not be defined?
|
20
|
+
#define rb_easy_get_str(key) \
|
21
|
+
RSTRING_PTR((rb_easy_type_check(key,T_STRING) ? rb_easy_get(key) : rb_str_to_str(rb_easy_get(key))))
|
22
|
+
|
23
|
+
/* getter/setter macros for various things */
|
24
|
+
/* setter for anything that stores a ruby VALUE in the struct */
|
25
|
+
#define CURB_OBJECT_SETTER(type, attr) \
|
26
|
+
type *ptr; \
|
27
|
+
\
|
28
|
+
Data_Get_Struct(self, type, ptr); \
|
29
|
+
ptr->attr = attr; \
|
30
|
+
\
|
31
|
+
return attr;
|
32
|
+
|
33
|
+
/* getter for anything that stores a ruby VALUE */
|
34
|
+
#define CURB_OBJECT_GETTER(type, attr) \
|
35
|
+
type *ptr; \
|
36
|
+
\
|
37
|
+
Data_Get_Struct(self, type, ptr); \
|
38
|
+
return ptr->attr;
|
39
|
+
|
40
|
+
/* setter for anything that stores a ruby VALUE in the struct opts hash */
|
41
|
+
#define CURB_OBJECT_HSETTER(type, attr) \
|
42
|
+
type *ptr; \
|
43
|
+
\
|
44
|
+
Data_Get_Struct(self, type, ptr); \
|
45
|
+
rb_hash_aset(ptr->opts, rb_easy_hkey(#attr), attr); \
|
46
|
+
\
|
47
|
+
return attr;
|
48
|
+
|
49
|
+
/* getter for anything that stores a ruby VALUE in the struct opts hash */
|
50
|
+
#define CURB_OBJECT_HGETTER(type, attr) \
|
51
|
+
type *ptr; \
|
52
|
+
\
|
53
|
+
Data_Get_Struct(self, type, ptr); \
|
54
|
+
return rb_hash_aref(ptr->opts, rb_easy_hkey(#attr));
|
55
|
+
|
56
|
+
/* setter for bool flags */
|
57
|
+
#define CURB_BOOLEAN_SETTER(type, attr) \
|
58
|
+
type *ptr; \
|
59
|
+
Data_Get_Struct(self, type, ptr); \
|
60
|
+
\
|
61
|
+
if (attr == Qnil || attr == Qfalse) { \
|
62
|
+
ptr->attr = 0; \
|
63
|
+
} else { \
|
64
|
+
ptr->attr = 1; \
|
65
|
+
} \
|
66
|
+
\
|
67
|
+
return attr;
|
68
|
+
|
69
|
+
/* getter for bool flags */
|
70
|
+
#define CURB_BOOLEAN_GETTER(type, attr) \
|
71
|
+
type *ptr; \
|
72
|
+
Data_Get_Struct(self, type, ptr); \
|
73
|
+
\
|
74
|
+
return((ptr->attr) ? Qtrue : Qfalse);
|
75
|
+
|
76
|
+
/* special setter for on_event handlers that take a block */
|
77
|
+
#define CURB_HANDLER_PROC_SETTER(type, handler) \
|
78
|
+
type *ptr; \
|
79
|
+
VALUE oldproc; \
|
80
|
+
\
|
81
|
+
Data_Get_Struct(self, type, ptr); \
|
82
|
+
\
|
83
|
+
oldproc = ptr->handler; \
|
84
|
+
rb_scan_args(argc, argv, "0&", &ptr->handler); \
|
85
|
+
\
|
86
|
+
return oldproc; \
|
87
|
+
|
88
|
+
/* special setter for on_event handlers that take a block, same as above but stores int he opts hash
|
89
|
+
set proc to nil if handler == Proc::NULL; just return current proc if handler is not given
|
90
|
+
*/
|
91
|
+
#define CURB_HANDLER_PROC_HSETTER(type, handler) \
|
92
|
+
type *ptr; \
|
93
|
+
VALUE oldproc, newproc; \
|
94
|
+
\
|
95
|
+
Data_Get_Struct(self, type, ptr); \
|
96
|
+
\
|
97
|
+
oldproc = rb_hash_aref(ptr->opts, rb_easy_hkey(#handler)); \
|
98
|
+
rb_scan_args(argc, argv, "0&", &newproc); \
|
99
|
+
if ( RTEST(rb_funcall(newproc, rb_intern("b"), 0)) ) \
|
100
|
+
rb_hash_aset(ptr->opts, rb_easy_hkey(#handler), newproc); \
|
101
|
+
else if (newproc != Qnil) \
|
102
|
+
rb_hash_aset(ptr->opts, rb_easy_hkey(#handler), Qnil); \
|
103
|
+
return oldproc;
|
104
|
+
|
105
|
+
/* setter for numerics that are kept in c ints */
|
106
|
+
#define CURB_IMMED_SETTER(type, attr, nilval) \
|
107
|
+
type *ptr; \
|
108
|
+
\
|
109
|
+
Data_Get_Struct(self, type, ptr); \
|
110
|
+
if (attr == Qnil) { \
|
111
|
+
ptr->attr = nilval; \
|
112
|
+
} else { \
|
113
|
+
ptr->attr = NUM2INT(attr); \
|
114
|
+
} \
|
115
|
+
\
|
116
|
+
return attr; \
|
117
|
+
|
118
|
+
/* setter for numerics that are kept in c ints */
|
119
|
+
#define CURB_IMMED_GETTER(type, attr, nilval) \
|
120
|
+
type *ptr; \
|
121
|
+
\
|
122
|
+
Data_Get_Struct(self, type, ptr); \
|
123
|
+
if (ptr->attr == nilval) { \
|
124
|
+
return Qnil; \
|
125
|
+
} else { \
|
126
|
+
return INT2NUM(ptr->attr); \
|
127
|
+
}
|
128
|
+
|
129
|
+
/* special setter for port / port ranges */
|
130
|
+
#define CURB_IMMED_PORT_SETTER(type, attr, msg) \
|
131
|
+
type *ptr; \
|
132
|
+
\
|
133
|
+
Data_Get_Struct(self, type, ptr); \
|
134
|
+
if (attr == Qnil) { \
|
135
|
+
ptr->attr = 0; \
|
136
|
+
} else { \
|
137
|
+
int port = FIX2INT(attr); \
|
138
|
+
\
|
139
|
+
if ((port) && ((port & 0xFFFF) == port)) { \
|
140
|
+
ptr->attr = port; \
|
141
|
+
} else { \
|
142
|
+
rb_raise(rb_eArgError, "Invalid " msg " %d (expected between 1 and 65535)", port); \
|
143
|
+
} \
|
144
|
+
} \
|
145
|
+
\
|
146
|
+
return attr; \
|
147
|
+
|
148
|
+
/* special getter for port / port ranges */
|
149
|
+
#define CURB_IMMED_PORT_GETTER(type, attr) \
|
150
|
+
type *ptr; \
|
151
|
+
\
|
152
|
+
Data_Get_Struct(self, type, ptr); \
|
153
|
+
if (ptr->attr == 0) { \
|
154
|
+
return Qnil; \
|
155
|
+
} else { \
|
156
|
+
return INT2FIX(ptr->attr); \
|
157
|
+
}
|
158
|
+
|
159
|
+
#define CURB_DEFINE(name) \
|
160
|
+
rb_define_const(mCurl, #name, INT2FIX(name))
|
161
|
+
|
162
|
+
#endif
|