curb 0.7.15 → 1.0.0

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.
data/ext/curb_easy.h CHANGED
@@ -36,6 +36,9 @@ typedef struct {
36
36
  /* The handler */
37
37
  CURL *curl;
38
38
 
39
+ /* Buffer for error details from CURLOPT_ERRORBUFFER */
40
+ char err_buf[CURL_ERROR_SIZE];
41
+
39
42
  VALUE opts; /* rather then allocate everything we might need to store, allocate a Hash and only store objects we actually use... */
40
43
  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
44
 
@@ -48,14 +51,19 @@ typedef struct {
48
51
  long proxy_auth_types;
49
52
  long max_redirs;
50
53
  unsigned long timeout;
54
+ unsigned long timeout_ms;
51
55
  unsigned long connect_timeout;
56
+ unsigned long connect_timeout_ms;
52
57
  long dns_cache_timeout;
53
58
  unsigned long ftp_response_timeout;
54
59
  long low_speed_limit;
55
60
  long low_speed_time;
61
+ long max_send_speed_large;
62
+ long max_recv_speed_large;
56
63
  long ssl_version;
57
64
  long use_ssl;
58
65
  long ftp_filemethod;
66
+ unsigned short resolve_mode;
59
67
 
60
68
  /* bool flags */
61
69
  char proxy_tunnel;
@@ -70,8 +78,12 @@ typedef struct {
70
78
  char multipart_form_post;
71
79
  char enable_cookies;
72
80
  char ignore_content_length;
81
+ char callback_active;
82
+
73
83
  struct curl_slist *curl_headers;
84
+ struct curl_slist *curl_proxy_headers;
74
85
  struct curl_slist *curl_ftp_commands;
86
+ struct curl_slist *curl_resolve;
75
87
 
76
88
  int last_result; /* last result code from multi loop */
77
89
 
data/ext/curb_errors.c CHANGED
@@ -21,6 +21,7 @@ VALUE eCurlErrFileError;
21
21
  VALUE eCurlErrLDAPError;
22
22
  VALUE eCurlErrTelnetError;
23
23
  VALUE eCurlErrTFTPError;
24
+ VALUE eCurlErrRTSPError;
24
25
 
25
26
  /* Specific libcurl errors */
26
27
  VALUE eCurlErrOK; /* not really an error but a return code */
@@ -28,16 +29,17 @@ VALUE eCurlErrUnsupportedProtocol;
28
29
  VALUE eCurlErrFailedInit;
29
30
  VALUE eCurlErrMalformedURL;
30
31
  VALUE eCurlErrMalformedURLUser;
32
+ VALUE eCurlErrNotBuiltIn;
31
33
  VALUE eCurlErrProxyResolution;
32
34
  VALUE eCurlErrHostResolution;
33
35
  VALUE eCurlErrConnectFailed;
34
- VALUE eCurlErrFTPWierdReply;
36
+ VALUE eCurlErrFTPWeirdReply;
35
37
  VALUE eCurlErrFTPAccessDenied;
36
38
  VALUE eCurlErrFTPBadPassword;
37
- VALUE eCurlErrFTPWierdPassReply;
38
- VALUE eCurlErrFTPWierdUserReply;
39
- VALUE eCurlErrFTPWierdPasvReply;
40
- VALUE eCurlErrFTPWierd227Format;
39
+ VALUE eCurlErrFTPWeirdPassReply;
40
+ VALUE eCurlErrFTPWeirdUserReply;
41
+ VALUE eCurlErrFTPWeirdPasvReply;
42
+ VALUE eCurlErrFTPWeird227Format;
41
43
  VALUE eCurlErrFTPCantGetHost;
42
44
  VALUE eCurlErrFTPCantReconnect;
43
45
  VALUE eCurlErrFTPCouldntSetBinary;
@@ -117,12 +119,27 @@ VALUE mCurlErrBadEasyHandle;
117
119
  VALUE mCurlErrOutOfMemory;
118
120
  VALUE mCurlErrInternalError;
119
121
  VALUE mCurlErrBadSocket;
122
+ #if HAVE_CURLM_ADDED_ALREADY
123
+ VALUE mCurlErrAddedAlready;
124
+ #endif
120
125
  VALUE mCurlErrUnknownOption;
121
126
 
122
127
  /* binding errors */
123
128
  VALUE eCurlErrInvalidPostField;
124
129
 
125
130
 
131
+ /* new errors */
132
+ VALUE eCurlErrFTPPRETFailed;
133
+ VALUE eCurlErrRTSPCseqError;
134
+ VALUE eCurlErrRTSPSessionError;
135
+ VALUE eCurlErrFTPBadFileList;
136
+ VALUE eCurlErrChunkFailed;
137
+ VALUE eCurlErrNoConnectionAvailable;
138
+ VALUE eCurlErrSSLPinnedPubKeyNotMatch;
139
+ VALUE eCurlErrSSLInvalidCertStatus;
140
+ VALUE eCurlErrHTTP2Stream;
141
+
142
+
126
143
  VALUE rb_curl_easy_error(CURLcode code) {
127
144
  VALUE exclz;
128
145
  const char *exmsg = NULL;
@@ -141,9 +158,15 @@ VALUE rb_curl_easy_error(CURLcode code) {
141
158
  case CURLE_URL_MALFORMAT: /* 3 */
142
159
  exclz = eCurlErrMalformedURL;
143
160
  break;
161
+ #ifdef HAVE_CURLE_NOT_BUILT_IN
162
+ case CURLE_NOT_BUILT_IN: /* 4 - [was obsoleted in August 2007 for 7.17.0, reused in April 2011 for 7.21.5] */
163
+ exclz = eCurlErrNotBuiltIn;
164
+ break;
165
+ #else
144
166
  case CURLE_URL_MALFORMAT_USER: /* 4 (NOT USED) */
145
167
  exclz = eCurlErrMalformedURLUser;
146
168
  break;
169
+ #endif
147
170
  case CURLE_COULDNT_RESOLVE_PROXY: /* 5 */
148
171
  exclz = eCurlErrProxyResolution;
149
172
  break;
@@ -154,7 +177,7 @@ VALUE rb_curl_easy_error(CURLcode code) {
154
177
  exclz = eCurlErrConnectFailed;
155
178
  break;
156
179
  case CURLE_FTP_WEIRD_SERVER_REPLY: /* 8 */
157
- exclz = eCurlErrFTPWierdReply;
180
+ exclz = eCurlErrFTPWeirdReply;
158
181
  break;
159
182
  case CURLE_FTP_ACCESS_DENIED: /* 9 denied due to lack of access. */
160
183
  exclz = eCurlErrFTPAccessDenied;
@@ -163,16 +186,16 @@ VALUE rb_curl_easy_error(CURLcode code) {
163
186
  exclz = eCurlErrFTPBadPassword;
164
187
  break;
165
188
  case CURLE_FTP_WEIRD_PASS_REPLY: /* 11 */
166
- exclz = eCurlErrFTPWierdPassReply;
189
+ exclz = eCurlErrFTPWeirdPassReply;
167
190
  break;
168
191
  case CURLE_FTP_WEIRD_USER_REPLY: /* 12 */
169
- exclz = eCurlErrFTPWierdUserReply;
192
+ exclz = eCurlErrFTPWeirdUserReply;
170
193
  break;
171
194
  case CURLE_FTP_WEIRD_PASV_REPLY: /* 13 */
172
- exclz = eCurlErrFTPWierdPasvReply;
195
+ exclz = eCurlErrFTPWeirdPasvReply;
173
196
  break;
174
197
  case CURLE_FTP_WEIRD_227_FORMAT: /* 14 */
175
- exclz = eCurlErrFTPWierd227Format;
198
+ exclz = eCurlErrFTPWeird227Format;
176
199
  break;
177
200
  case CURLE_FTP_CANT_GET_HOST: /* 15 */
178
201
  exclz = eCurlErrFTPCantGetHost;
@@ -279,12 +302,16 @@ VALUE rb_curl_easy_error(CURLcode code) {
279
302
  case CURLE_TELNET_OPTION_SYNTAX: /* 49 - Malformed telnet option */
280
303
  exclz = eCurlErrTelnetBadOptionSyntax;
281
304
  break;
305
+ #ifdef HAVE_CURLE_OBSOLETE
282
306
  case CURLE_OBSOLETE: /* 50 - NOT USED */
283
307
  exclz = eCurlErrObsolete;
284
308
  break;
309
+ #endif
310
+ #if LIBCURL_VERSION_NUM < 0x073e00
285
311
  case CURLE_SSL_PEER_CERTIFICATE: /* 51 - peer's certificate wasn't ok */
286
312
  exclz = eCurlErrSSLPeerCertificate;
287
313
  break;
314
+ #endif
288
315
  case CURLE_GOT_NOTHING: /* 52 - when this is a specific error */
289
316
  exclz = eCurlErrGotNothing;
290
317
  break;
@@ -309,8 +336,13 @@ VALUE rb_curl_easy_error(CURLcode code) {
309
336
  case CURLE_SSL_CIPHER: /* 59 - couldn't use specified cipher */
310
337
  exclz = eCurlErrSSLCipher;
311
338
  break;
339
+ #if LIBCURL_VERSION_NUM >= 0x073e00
340
+ case CURLE_PEER_FAILED_VERIFICATION: /* 60 - problem with the CA cert (path?) */
341
+ exclz = eCurlErrSSLPeerCertificate;
342
+ #else
312
343
  case CURLE_SSL_CACERT: /* 60 - problem with the CA cert (path?) */
313
344
  exclz = eCurlErrSSLCACertificate;
345
+ #endif
314
346
  break;
315
347
  case CURLE_BAD_CONTENT_ENCODING: /* 61 - Unrecognized transfer encoding */
316
348
  exclz = eCurlErrBadContentEncoding;
@@ -433,6 +465,61 @@ VALUE rb_curl_easy_error(CURLcode code) {
433
465
  exclz = eCurlErrSSLIssuerError;
434
466
  break;
435
467
  #endif
468
+
469
+ #ifdef HAVE_CURLE_FTP_PRET_FAILED
470
+ case CURLE_FTP_PRET_FAILED: /* 84 */
471
+ exclz = eCurlErrFTPPRETFailed;
472
+ break;
473
+ #endif
474
+
475
+ #ifdef HAVE_CURLE_RTSP_CSEQ_ERROR
476
+ case CURLE_RTSP_CSEQ_ERROR: /* 85 */
477
+ exclz = eCurlErrRTSPCseqError;
478
+ break;
479
+ #endif
480
+
481
+ #ifdef HAVE_CURLE_RTSP_SESSION_ERROR
482
+ case CURLE_RTSP_SESSION_ERROR: /* 86 */
483
+ exclz = eCurlErrRTSPSessionError;
484
+ break;
485
+ #endif
486
+
487
+ #ifdef HAVE_CURLE_FTP_BAD_FILE_LIST
488
+ case CURLE_FTP_BAD_FILE_LIST: /* 87 */
489
+ exclz = eCurlErrFTPBadFileList;
490
+ break;
491
+ #endif
492
+
493
+ #ifdef HAVE_CURLE_CHUNK_FAILED
494
+ case CURLE_CHUNK_FAILED: /* 88 */
495
+ exclz = eCurlErrChunkFailed;
496
+ break;
497
+ #endif
498
+
499
+ #ifdef HAVE_CURLE_NO_CONNECTION_AVAILABLE
500
+ case CURLE_NO_CONNECTION_AVAILABLE: /* 89 */
501
+ exclz = eCurlErrNoConnectionAvailable;
502
+ break;
503
+ #endif
504
+
505
+ #ifdef HAVE_CURLE_SSL_PINNEDPUBKEYNOTMATCH
506
+ case CURLE_SSL_PINNEDPUBKEYNOTMATCH: /* 90 */
507
+ exclz = eCurlErrSSLPinnedPubKeyNotMatch;
508
+ break;
509
+ #endif
510
+
511
+ #ifdef HAVE_CURLE_SSL_INVALIDCERTSTATUS
512
+ case CURLE_SSL_INVALIDCERTSTATUS: /* 91 */
513
+ exclz = eCurlErrSSLInvalidCertStatus;
514
+ break;
515
+ #endif
516
+
517
+ #ifdef HAVE_CURLE_HTTP2_STREAM
518
+ case CURLE_HTTP2_STREAM: /* 92 */
519
+ exclz = eCurlErrHTTP2Stream;
520
+ break;
521
+ #endif
522
+
436
523
  default:
437
524
  exclz = eCurlErrError;
438
525
  exmsg = "Unknown error result from libcurl";
@@ -450,7 +537,8 @@ VALUE rb_curl_easy_error(CURLcode code) {
450
537
  /* rb_raise an approriate exception for the supplied CURLcode */
451
538
  void raise_curl_easy_error_exception(CURLcode code) {
452
539
  VALUE obj = rb_curl_easy_error(code);
453
- rb_raise(rb_ary_entry(obj,0), RSTRING_PTR(rb_ary_entry(obj,1)));
540
+ VALUE exmsg = rb_ary_entry(obj,1);
541
+ rb_raise(rb_ary_entry(obj,0), "CURLError: %s", StringValueCStr(exmsg));
454
542
  }
455
543
  VALUE rb_curl_multi_error(CURLMcode code) {
456
544
  VALUE exclz;
@@ -482,6 +570,11 @@ VALUE rb_curl_multi_error(CURLMcode code) {
482
570
  case CURLM_UNKNOWN_OPTION: /* 6 */
483
571
  exclz = mCurlErrUnknownOption;
484
572
  break;
573
+ #endif
574
+ #if HAVE_CURLM_ADDED_ALREADY
575
+ case CURLM_ADDED_ALREADY: /* 7 */
576
+ exclz = mCurlErrAddedAlready;
577
+ break;
485
578
  #endif
486
579
  default:
487
580
  exclz = eCurlErrError;
@@ -500,7 +593,8 @@ VALUE rb_curl_multi_error(CURLMcode code) {
500
593
  }
501
594
  void raise_curl_multi_error_exception(CURLMcode code) {
502
595
  VALUE obj = rb_curl_multi_error(code);
503
- rb_raise(rb_ary_entry(obj,0), RSTRING_PTR(rb_ary_entry(obj,1)));
596
+ VALUE exmsg = rb_ary_entry(obj,1);
597
+ rb_raise(rb_ary_entry(obj,0), "CURLError: %s", StringValueCStr(exmsg));
504
598
  }
505
599
 
506
600
  void init_curb_errors() {
@@ -513,23 +607,25 @@ void init_curb_errors() {
513
607
  eCurlErrLDAPError = rb_define_class_under(mCurlErr, "LDAPError", eCurlErrError);
514
608
  eCurlErrTelnetError = rb_define_class_under(mCurlErr, "TelnetError", eCurlErrError);
515
609
  eCurlErrTFTPError = rb_define_class_under(mCurlErr, "TFTPError", eCurlErrError);
610
+ eCurlErrRTSPError = rb_define_class_under(mCurlErr, "RTSPError", eCurlErrError);
516
611
 
517
612
  eCurlErrOK = rb_define_class_under(mCurlErr, "CurlOK", eCurlErrError);
518
613
  eCurlErrUnsupportedProtocol = rb_define_class_under(mCurlErr, "UnsupportedProtocolError", eCurlErrError);
519
614
  eCurlErrFailedInit = rb_define_class_under(mCurlErr, "FailedInitError", eCurlErrError);
520
615
  eCurlErrMalformedURL = rb_define_class_under(mCurlErr, "MalformedURLError", eCurlErrError);
616
+ eCurlErrNotBuiltIn = rb_define_class_under(mCurlErr, "NotBuiltInError", eCurlErrError);
521
617
  eCurlErrMalformedURLUser = rb_define_class_under(mCurlErr, "MalformedURLUserError", eCurlErrError);
522
618
  eCurlErrProxyResolution = rb_define_class_under(mCurlErr, "ProxyResolutionError", eCurlErrError);
523
619
  eCurlErrHostResolution = rb_define_class_under(mCurlErr, "HostResolutionError", eCurlErrError);
524
620
  eCurlErrConnectFailed = rb_define_class_under(mCurlErr, "ConnectionFailedError", eCurlErrError);
525
621
 
526
- eCurlErrFTPWierdReply = rb_define_class_under(mCurlErr, "WierdReplyError", eCurlErrFTPError);
622
+ eCurlErrFTPWeirdReply = rb_define_class_under(mCurlErr, "WeirdReplyError", eCurlErrFTPError);
527
623
  eCurlErrFTPAccessDenied = rb_define_class_under(mCurlErr, "AccessDeniedError", eCurlErrFTPError);
528
- eCurlErrFTPBadPassword = rb_define_class_under(mCurlErr, "BadBasswordError", eCurlErrFTPError);
529
- eCurlErrFTPWierdPassReply = rb_define_class_under(mCurlErr, "WierdPassReplyError", eCurlErrFTPError);
530
- eCurlErrFTPWierdUserReply = rb_define_class_under(mCurlErr, "WierdUserReplyError", eCurlErrFTPError);
531
- eCurlErrFTPWierdPasvReply = rb_define_class_under(mCurlErr, "WierdPasvReplyError", eCurlErrFTPError);
532
- eCurlErrFTPWierd227Format = rb_define_class_under(mCurlErr, "Wierd227FormatError", eCurlErrFTPError);
624
+ eCurlErrFTPBadPassword = rb_define_class_under(mCurlErr, "BadPasswordError", eCurlErrFTPError);
625
+ eCurlErrFTPWeirdPassReply = rb_define_class_under(mCurlErr, "WeirdPassReplyError", eCurlErrFTPError);
626
+ eCurlErrFTPWeirdUserReply = rb_define_class_under(mCurlErr, "WeirdUserReplyError", eCurlErrFTPError);
627
+ eCurlErrFTPWeirdPasvReply = rb_define_class_under(mCurlErr, "WeirdPasvReplyError", eCurlErrFTPError);
628
+ eCurlErrFTPWeird227Format = rb_define_class_under(mCurlErr, "Weird227FormatError", eCurlErrFTPError);
533
629
  eCurlErrFTPCantGetHost = rb_define_class_under(mCurlErr, "CantGetHostError", eCurlErrFTPError);
534
630
  eCurlErrFTPCantReconnect = rb_define_class_under(mCurlErr, "CantReconnectError", eCurlErrFTPError);
535
631
  eCurlErrFTPCouldntSetBinary = rb_define_class_under(mCurlErr, "CouldntSetBinaryError", eCurlErrFTPError);
@@ -613,6 +709,9 @@ void init_curb_errors() {
613
709
  mCurlErrOutOfMemory = rb_define_class_under(mCurlErr, "MultiOutOfMemory", eCurlErrError);
614
710
  mCurlErrInternalError = rb_define_class_under(mCurlErr, "MultiInternalError", eCurlErrError);
615
711
  mCurlErrBadSocket = rb_define_class_under(mCurlErr, "MultiBadSocket", eCurlErrError);
712
+ #if HAVE_CURLM_ADDED_ALREADY
713
+ mCurlErrAddedAlready = rb_define_class_under(mCurlErr, "MultiAddedAlready", eCurlErrError);
714
+ #endif
616
715
  mCurlErrUnknownOption = rb_define_class_under(mCurlErr, "MultiUnknownOption", eCurlErrError);
617
716
 
618
717
  eCurlErrLDAPInvalidURL = rb_define_class_under(mCurlErr, "InvalidLDAPURLError", eCurlErrLDAPError);
@@ -634,4 +733,14 @@ void init_curb_errors() {
634
733
  eCurlErrTFTPNoSuchUser = rb_define_class_under(mCurlErr, "NoSuchUserError", eCurlErrTFTPError);
635
734
 
636
735
  eCurlErrInvalidPostField = rb_define_class_under(mCurlErr, "InvalidPostFieldError", eCurlErrError);
736
+
737
+ eCurlErrFTPPRETFailed = rb_define_class_under(mCurlErr, "PPRETFailedError", eCurlErrFTPError);
738
+ eCurlErrRTSPCseqError = rb_define_class_under(mCurlErr, "CseqError", eCurlErrRTSPError);
739
+ eCurlErrRTSPSessionError = rb_define_class_under(mCurlErr, "SessionError", eCurlErrRTSPError);
740
+ eCurlErrFTPBadFileList = rb_define_class_under(mCurlErr, "BadFileListError", eCurlErrFTPError);
741
+ eCurlErrChunkFailed = rb_define_class_under(mCurlErr, "ChunkFailedError", eCurlErrError);
742
+ eCurlErrNoConnectionAvailable = rb_define_class_under(mCurlErr, "NoConnectionAvailableError", eCurlErrError);
743
+ eCurlErrSSLPinnedPubKeyNotMatch = rb_define_class_under(mCurlErr, "SSLPinnedPubKeyNotMatchError", eCurlErrError);
744
+ eCurlErrSSLInvalidCertStatus = rb_define_class_under(mCurlErr, "SSLInvalidCertStatusError", eCurlErrError);
745
+ eCurlErrHTTP2Stream = rb_define_class_under(mCurlErr, "HTTP2StreamError", eCurlErrHTTPError);
637
746
  }
data/ext/curb_errors.h CHANGED
@@ -30,13 +30,13 @@ extern VALUE eCurlErrMalformedURLUser;
30
30
  extern VALUE eCurlErrProxyResolution;
31
31
  extern VALUE eCurlErrHostResolution;
32
32
  extern VALUE eCurlErrConnectFailed;
33
- extern VALUE eCurlErrFTPWierdReply;
33
+ extern VALUE eCurlErrFTPWeirdReply;
34
34
  extern VALUE eCurlErrFTPAccessDenied;
35
35
  extern VALUE eCurlErrFTPBadPassword;
36
- extern VALUE eCurlErrFTPWierdPassReply;
37
- extern VALUE eCurlErrFTPWierdUserReply;
38
- extern VALUE eCurlErrFTPWierdPasvReply;
39
- extern VALUE eCurlErrFTPWierd227Format;
36
+ extern VALUE eCurlErrFTPWeirdPassReply;
37
+ extern VALUE eCurlErrFTPWeirdUserReply;
38
+ extern VALUE eCurlErrFTPWeirdPasvReply;
39
+ extern VALUE eCurlErrFTPWeird227Format;
40
40
  extern VALUE eCurlErrFTPCantGetHost;
41
41
  extern VALUE eCurlErrFTPCantReconnect;
42
42
  extern VALUE eCurlErrFTPCouldntSetBinary;
@@ -116,6 +116,9 @@ extern VALUE mCurlErrOutOfMemory;
116
116
  extern VALUE mCurlErrInternalError;
117
117
  extern VALUE mCurlErrBadSocket;
118
118
  extern VALUE mCurlErrUnknownOption;
119
+ #if HAVE_CURLM_ADDED_ALREADY
120
+ extern VALUE mCurlErrAddedAlready;
121
+ #endif
119
122
 
120
123
  /* binding errors */
121
124
  extern VALUE eCurlErrInvalidPostField;
data/ext/curb_macros.h CHANGED
@@ -8,6 +8,7 @@
8
8
  #ifndef __CURB_MACROS_H
9
9
  #define __CURB_MACROS_H
10
10
 
11
+ #define rb_easy_sym(sym) ID2SYM(rb_intern(sym))
11
12
  #define rb_easy_hkey(key) ID2SYM(rb_intern(key))
12
13
  #define rb_easy_set(key,val) rb_hash_aset(rbce->opts, rb_easy_hkey(key) , val)
13
14
  #define rb_easy_get(key) rb_hash_aref(rbce->opts, rb_easy_hkey(key))
@@ -98,7 +99,7 @@
98
99
  \
99
100
  return oldproc;
100
101
 
101
- /* setter for numerics that are kept in c ints */
102
+ /* setter for numerics that are kept in c longs */
102
103
  #define CURB_IMMED_SETTER(type, attr, nilval) \
103
104
  type *ptr; \
104
105
  \
@@ -106,12 +107,12 @@
106
107
  if (attr == Qnil) { \
107
108
  ptr->attr = nilval; \
108
109
  } else { \
109
- ptr->attr = NUM2INT(attr); \
110
+ ptr->attr = NUM2LONG(attr); \
110
111
  } \
111
112
  \
112
113
  return attr; \
113
114
 
114
- /* setter for numerics that are kept in c ints */
115
+ /* setter for numerics that are kept in c longs */
115
116
  #define CURB_IMMED_GETTER(type, attr, nilval) \
116
117
  type *ptr; \
117
118
  \
@@ -119,7 +120,7 @@
119
120
  if (ptr->attr == nilval) { \
120
121
  return Qnil; \
121
122
  } else { \
122
- return INT2NUM(ptr->attr); \
123
+ return LONG2NUM(ptr->attr); \
123
124
  }
124
125
 
125
126
  /* special setter for port / port ranges */
@@ -130,7 +131,7 @@
130
131
  if (attr == Qnil) { \
131
132
  ptr->attr = 0; \
132
133
  } else { \
133
- int port = FIX2INT(attr); \
134
+ int port = NUM2INT(attr); \
134
135
  \
135
136
  if ((port) && ((port & 0xFFFF) == port)) { \
136
137
  ptr->attr = port; \
@@ -149,7 +150,10 @@
149
150
  if (ptr->attr == 0) { \
150
151
  return Qnil; \
151
152
  } else { \
152
- return INT2FIX(ptr->attr); \
153
+ return INT2NUM(ptr->attr); \
153
154
  }
154
155
 
156
+ #define CURB_DEFINE(name) \
157
+ rb_define_const(mCurl, #name, LONG2NUM(name))
158
+
155
159
  #endif