rhack 1.2.1 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +13 -5
  2. data/README.md +21 -9
  3. data/ext/curb/curb.c +977 -977
  4. data/ext/curb/curb.h +52 -52
  5. data/ext/curb/curb_config.h +270 -270
  6. data/ext/curb/curb_easy.c +3437 -3434
  7. data/ext/curb/curb_easy.h +94 -94
  8. data/ext/curb/curb_errors.c +647 -647
  9. data/ext/curb/curb_errors.h +129 -129
  10. data/ext/curb/curb_macros.h +162 -162
  11. data/ext/curb/curb_multi.c +704 -702
  12. data/ext/curb/curb_multi.h +26 -26
  13. data/ext/curb/curb_postfield.c +523 -523
  14. data/ext/curb/curb_postfield.h +40 -40
  15. data/ext/curb/curb_upload.c +80 -80
  16. data/ext/curb/curb_upload.h +30 -30
  17. data/ext/curb-original/curb.c +977 -977
  18. data/ext/curb-original/curb.h +52 -52
  19. data/ext/curb-original/curb_config.h +238 -238
  20. data/ext/curb-original/curb_easy.c +3404 -3404
  21. data/ext/curb-original/curb_easy.h +90 -90
  22. data/ext/curb-original/curb_errors.c +647 -647
  23. data/ext/curb-original/curb_errors.h +129 -129
  24. data/ext/curb-original/curb_macros.h +159 -159
  25. data/ext/curb-original/curb_multi.c +633 -633
  26. data/ext/curb-original/curb_multi.h +26 -26
  27. data/ext/curb-original/curb_postfield.c +523 -523
  28. data/ext/curb-original/curb_postfield.h +40 -40
  29. data/ext/curb-original/curb_upload.c +80 -80
  30. data/ext/curb-original/curb_upload.h +30 -30
  31. data/lib/rhack/clients/base.rb +61 -10
  32. data/lib/rhack/clients/oauth.rb +4 -4
  33. data/lib/rhack/curl/easy.rb +1 -0
  34. data/lib/rhack/curl/global.rb +2 -0
  35. data/lib/rhack/curl/response.rb +4 -2
  36. data/lib/rhack/frame.rb +70 -32
  37. data/lib/rhack/js/browser/env.js +697 -697
  38. data/lib/rhack/js/browser/jquery.js +7180 -7180
  39. data/lib/rhack/js/browser/xmlsax.js +1564 -1564
  40. data/lib/rhack/js/browser/xmlw3cdom_1.js +1443 -1443
  41. data/lib/rhack/js/browser/xmlw3cdom_2.js +2744 -2744
  42. data/lib/rhack/page.rb +227 -68
  43. data/lib/rhack/scout.rb +52 -26
  44. data/lib/rhack/scout_squad.rb +10 -2
  45. data/lib/rhack/version.rb +1 -1
  46. data/rhack.gemspec +1 -1
  47. metadata +17 -17
@@ -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
@@ -1,159 +1,159 @@
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
- #define CURB_HANDLER_PROC_HSETTER(type, handler) \
90
- type *ptr; \
91
- VALUE oldproc, newproc; \
92
- \
93
- Data_Get_Struct(self, type, ptr); \
94
- \
95
- oldproc = rb_hash_aref(ptr->opts, rb_easy_hkey(#handler)); \
96
- rb_scan_args(argc, argv, "0&", &newproc); \
97
- \
98
- rb_hash_aset(ptr->opts, rb_easy_hkey(#handler), newproc); \
99
- \
100
- return oldproc;
101
-
102
- /* setter for numerics that are kept in c ints */
103
- #define CURB_IMMED_SETTER(type, attr, nilval) \
104
- type *ptr; \
105
- \
106
- Data_Get_Struct(self, type, ptr); \
107
- if (attr == Qnil) { \
108
- ptr->attr = nilval; \
109
- } else { \
110
- ptr->attr = NUM2INT(attr); \
111
- } \
112
- \
113
- return attr; \
114
-
115
- /* setter for numerics that are kept in c ints */
116
- #define CURB_IMMED_GETTER(type, attr, nilval) \
117
- type *ptr; \
118
- \
119
- Data_Get_Struct(self, type, ptr); \
120
- if (ptr->attr == nilval) { \
121
- return Qnil; \
122
- } else { \
123
- return INT2NUM(ptr->attr); \
124
- }
125
-
126
- /* special setter for port / port ranges */
127
- #define CURB_IMMED_PORT_SETTER(type, attr, msg) \
128
- type *ptr; \
129
- \
130
- Data_Get_Struct(self, type, ptr); \
131
- if (attr == Qnil) { \
132
- ptr->attr = 0; \
133
- } else { \
134
- int port = FIX2INT(attr); \
135
- \
136
- if ((port) && ((port & 0xFFFF) == port)) { \
137
- ptr->attr = port; \
138
- } else { \
139
- rb_raise(rb_eArgError, "Invalid " msg " %d (expected between 1 and 65535)", port); \
140
- } \
141
- } \
142
- \
143
- return attr; \
144
-
145
- /* special getter for port / port ranges */
146
- #define CURB_IMMED_PORT_GETTER(type, attr) \
147
- type *ptr; \
148
- \
149
- Data_Get_Struct(self, type, ptr); \
150
- if (ptr->attr == 0) { \
151
- return Qnil; \
152
- } else { \
153
- return INT2FIX(ptr->attr); \
154
- }
155
-
156
- #define CURB_DEFINE(name) \
157
- rb_define_const(mCurl, #name, INT2FIX(name))
158
-
159
- #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
+ #define CURB_HANDLER_PROC_HSETTER(type, handler) \
90
+ type *ptr; \
91
+ VALUE oldproc, newproc; \
92
+ \
93
+ Data_Get_Struct(self, type, ptr); \
94
+ \
95
+ oldproc = rb_hash_aref(ptr->opts, rb_easy_hkey(#handler)); \
96
+ rb_scan_args(argc, argv, "0&", &newproc); \
97
+ \
98
+ rb_hash_aset(ptr->opts, rb_easy_hkey(#handler), newproc); \
99
+ \
100
+ return oldproc;
101
+
102
+ /* setter for numerics that are kept in c ints */
103
+ #define CURB_IMMED_SETTER(type, attr, nilval) \
104
+ type *ptr; \
105
+ \
106
+ Data_Get_Struct(self, type, ptr); \
107
+ if (attr == Qnil) { \
108
+ ptr->attr = nilval; \
109
+ } else { \
110
+ ptr->attr = NUM2INT(attr); \
111
+ } \
112
+ \
113
+ return attr; \
114
+
115
+ /* setter for numerics that are kept in c ints */
116
+ #define CURB_IMMED_GETTER(type, attr, nilval) \
117
+ type *ptr; \
118
+ \
119
+ Data_Get_Struct(self, type, ptr); \
120
+ if (ptr->attr == nilval) { \
121
+ return Qnil; \
122
+ } else { \
123
+ return INT2NUM(ptr->attr); \
124
+ }
125
+
126
+ /* special setter for port / port ranges */
127
+ #define CURB_IMMED_PORT_SETTER(type, attr, msg) \
128
+ type *ptr; \
129
+ \
130
+ Data_Get_Struct(self, type, ptr); \
131
+ if (attr == Qnil) { \
132
+ ptr->attr = 0; \
133
+ } else { \
134
+ int port = FIX2INT(attr); \
135
+ \
136
+ if ((port) && ((port & 0xFFFF) == port)) { \
137
+ ptr->attr = port; \
138
+ } else { \
139
+ rb_raise(rb_eArgError, "Invalid " msg " %d (expected between 1 and 65535)", port); \
140
+ } \
141
+ } \
142
+ \
143
+ return attr; \
144
+
145
+ /* special getter for port / port ranges */
146
+ #define CURB_IMMED_PORT_GETTER(type, attr) \
147
+ type *ptr; \
148
+ \
149
+ Data_Get_Struct(self, type, ptr); \
150
+ if (ptr->attr == 0) { \
151
+ return Qnil; \
152
+ } else { \
153
+ return INT2FIX(ptr->attr); \
154
+ }
155
+
156
+ #define CURB_DEFINE(name) \
157
+ rb_define_const(mCurl, #name, INT2FIX(name))
158
+
159
+ #endif