codders-curb 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/LICENSE +51 -0
  2. data/README +194 -0
  3. data/Rakefile +320 -0
  4. data/doc.rb +42 -0
  5. data/ext/curb.c +977 -0
  6. data/ext/curb.h +52 -0
  7. data/ext/curb_easy.c +3404 -0
  8. data/ext/curb_easy.h +90 -0
  9. data/ext/curb_errors.c +647 -0
  10. data/ext/curb_errors.h +129 -0
  11. data/ext/curb_macros.h +159 -0
  12. data/ext/curb_multi.c +633 -0
  13. data/ext/curb_multi.h +26 -0
  14. data/ext/curb_postfield.c +523 -0
  15. data/ext/curb_postfield.h +40 -0
  16. data/ext/curb_upload.c +80 -0
  17. data/ext/curb_upload.h +30 -0
  18. data/ext/extconf.rb +399 -0
  19. data/lib/curb.rb +4 -0
  20. data/lib/curl.rb +57 -0
  21. data/lib/curl/easy.rb +468 -0
  22. data/lib/curl/multi.rb +248 -0
  23. data/tests/alltests.rb +3 -0
  24. data/tests/bug_crash_on_debug.rb +39 -0
  25. data/tests/bug_crash_on_progress.rb +33 -0
  26. data/tests/bug_curb_easy_blocks_ruby_threads.rb +52 -0
  27. data/tests/bug_curb_easy_post_with_string_no_content_length_header.rb +83 -0
  28. data/tests/bug_instance_post_differs_from_class_post.rb +53 -0
  29. data/tests/bug_multi_segfault.rb +14 -0
  30. data/tests/bug_postfields_crash.rb +26 -0
  31. data/tests/bug_postfields_crash2.rb +57 -0
  32. data/tests/bug_require_last_or_segfault.rb +40 -0
  33. data/tests/bugtests.rb +9 -0
  34. data/tests/helper.rb +199 -0
  35. data/tests/mem_check.rb +65 -0
  36. data/tests/require_last_or_segfault_script.rb +36 -0
  37. data/tests/tc_curl_download.rb +75 -0
  38. data/tests/tc_curl_easy.rb +1011 -0
  39. data/tests/tc_curl_easy_setopt.rb +31 -0
  40. data/tests/tc_curl_multi.rb +485 -0
  41. data/tests/tc_curl_postfield.rb +143 -0
  42. data/tests/timeout.rb +100 -0
  43. data/tests/timeout_server.rb +33 -0
  44. data/tests/unittests.rb +2 -0
  45. metadata +133 -0
@@ -0,0 +1,40 @@
1
+ /* curb_postfield.h - Field class for POST method
2
+ * Copyright (c)2006 Ross Bamford.
3
+ * Licensed under the Ruby License. See LICENSE for details.
4
+ *
5
+ * $Id: curb_postfield.h 4 2006-11-17 18:35:31Z roscopeco $
6
+ */
7
+ #ifndef __CURB_POSTFIELD_H
8
+ #define __CURB_POSTFIELD_H
9
+
10
+ #include "curb.h"
11
+
12
+ /*
13
+ * postfield doesn't actually wrap a curl_httppost - instead,
14
+ * it just holds together some ruby objects and has a C-side
15
+ * method to add it to a given form list during the perform.
16
+ */
17
+ typedef struct {
18
+ /* Objects we associate */
19
+ VALUE name;
20
+ VALUE content;
21
+ VALUE content_type;
22
+ VALUE content_proc;
23
+ VALUE local_file;
24
+ VALUE remote_file;
25
+
26
+ /* this will sometimes hold a string, which is the result
27
+ * of the content_proc invocation. We need it to hang around.
28
+ */
29
+ VALUE buffer_str;
30
+ } ruby_curl_postfield;
31
+
32
+ extern VALUE cCurlPostField;
33
+
34
+ void append_to_form(VALUE self,
35
+ struct curl_httppost **first,
36
+ struct curl_httppost **last);
37
+
38
+ void init_curb_postfield();
39
+
40
+ #endif
data/ext/curb_upload.c ADDED
@@ -0,0 +1,80 @@
1
+ /* curb_upload.c - Curl upload handle
2
+ * Copyright (c)2009 Todd A Fisher.
3
+ * Licensed under the Ruby License. See LICENSE for details.
4
+ */
5
+ #include "curb_upload.h"
6
+ extern VALUE mCurl;
7
+ VALUE cCurlUpload;
8
+
9
+ #ifdef RDOC_NEVER_DEFINED
10
+ mCurl = rb_define_module("Curl");
11
+ #endif
12
+
13
+ static void curl_upload_mark(ruby_curl_upload *rbcu) {
14
+ if (rbcu->stream && !NIL_P(rbcu->stream)) rb_gc_mark(rbcu->stream);
15
+ }
16
+ static void curl_upload_free(ruby_curl_upload *rbcu) {
17
+ free(rbcu);
18
+ }
19
+
20
+ /*
21
+ * call-seq:
22
+ * internal class for sending large file uploads
23
+ */
24
+ VALUE ruby_curl_upload_new(VALUE klass) {
25
+ VALUE upload;
26
+ ruby_curl_upload *rbcu = ALLOC(ruby_curl_upload);
27
+ rbcu->stream = Qnil;
28
+ rbcu->offset = 0;
29
+ upload = Data_Wrap_Struct(klass, curl_upload_mark, curl_upload_free, rbcu);
30
+ return upload;
31
+ }
32
+
33
+ /*
34
+ * call-seq:
35
+ * internal class for sending large file uploads
36
+ */
37
+ VALUE ruby_curl_upload_stream_set(VALUE self, VALUE stream) {
38
+ ruby_curl_upload *rbcu;
39
+ Data_Get_Struct(self, ruby_curl_upload, rbcu);
40
+ rbcu->stream = stream;
41
+ return stream;
42
+ }
43
+ /*
44
+ * call-seq:
45
+ * internal class for sending large file uploads
46
+ */
47
+ VALUE ruby_curl_upload_stream_get(VALUE self) {
48
+ ruby_curl_upload *rbcu;
49
+ Data_Get_Struct(self, ruby_curl_upload, rbcu);
50
+ return rbcu->stream;
51
+ }
52
+ /*
53
+ * call-seq:
54
+ * internal class for sending large file uploads
55
+ */
56
+ VALUE ruby_curl_upload_offset_set(VALUE self, VALUE offset) {
57
+ ruby_curl_upload *rbcu;
58
+ Data_Get_Struct(self, ruby_curl_upload, rbcu);
59
+ rbcu->offset = FIX2LONG(offset);
60
+ return offset;
61
+ }
62
+ /*
63
+ * call-seq:
64
+ * internal class for sending large file uploads
65
+ */
66
+ VALUE ruby_curl_upload_offset_get(VALUE self) {
67
+ ruby_curl_upload *rbcu;
68
+ Data_Get_Struct(self, ruby_curl_upload, rbcu);
69
+ return INT2FIX(rbcu->offset);
70
+ }
71
+
72
+ /* =================== INIT LIB =====================*/
73
+ void init_curb_upload() {
74
+ cCurlUpload = rb_define_class_under(mCurl, "Upload", rb_cObject);
75
+ rb_define_singleton_method(cCurlUpload, "new", ruby_curl_upload_new, 0);
76
+ rb_define_method(cCurlUpload, "stream=", ruby_curl_upload_stream_set, 1);
77
+ rb_define_method(cCurlUpload, "stream", ruby_curl_upload_stream_get, 0);
78
+ rb_define_method(cCurlUpload, "offset=", ruby_curl_upload_offset_set, 1);
79
+ rb_define_method(cCurlUpload, "offset", ruby_curl_upload_offset_get, 0);
80
+ }
data/ext/curb_upload.h ADDED
@@ -0,0 +1,30 @@
1
+ /* curb_upload.h - Curl upload handle
2
+ * Copyright (c)2009 Todd A Fisher.
3
+ * Licensed under the Ruby License. See LICENSE for details.
4
+ */
5
+ #ifndef __CURB_UPLOAD_H
6
+ #define __CURB_UPLOAD_H
7
+
8
+ #include "curb.h"
9
+
10
+ #include <curl/easy.h>
11
+
12
+ /*
13
+ * Maintain the state of an upload e.g. for putting large streams with very little memory
14
+ * out to a server. via PUT requests
15
+ */
16
+ typedef struct {
17
+ VALUE stream;
18
+ size_t offset;
19
+ } ruby_curl_upload;
20
+
21
+ extern VALUE cCurlUpload;
22
+ void init_curb_upload();
23
+
24
+ VALUE ruby_curl_upload_new(VALUE klass);
25
+ VALUE ruby_curl_upload_stream_set(VALUE self, VALUE stream);
26
+ VALUE ruby_curl_upload_stream_get(VALUE self);
27
+ VALUE ruby_curl_upload_offset_set(VALUE self, VALUE offset);
28
+ VALUE ruby_curl_upload_offset_get(VALUE self);
29
+
30
+ #endif
data/ext/extconf.rb ADDED
@@ -0,0 +1,399 @@
1
+ require 'mkmf'
2
+
3
+ dir_config('curl')
4
+
5
+ if find_executable('curl-config')
6
+ $CFLAGS << " #{`curl-config --cflags`.strip} -g"
7
+ if ENV['STATIC_BUILD']
8
+ $LIBS << " #{`curl-config --static-libs`.strip}"
9
+ else
10
+ $LIBS << " #{`curl-config --libs`.strip}"
11
+ end
12
+ ca_bundle_path=`curl-config --ca`.strip
13
+ if !ca_bundle_path.nil? and ca_bundle_path != ''
14
+ $defs.push( %{-D HAVE_CURL_CONFIG_CA} )
15
+ $defs.push( %{-D CURL_CONFIG_CA='#{ca_bundle_path.inspect}'} )
16
+ end
17
+ elsif !have_library('curl') or !have_header('curl/curl.h')
18
+ fail <<-EOM
19
+ Can't find libcurl or curl/curl.h
20
+
21
+ Try passing --with-curl-dir or --with-curl-lib and --with-curl-include
22
+ options to extconf.
23
+ EOM
24
+ end
25
+
26
+ # Check arch flags
27
+ # TODO: detect mismatched arch types when libcurl mac ports is mixed with native mac ruby or vice versa
28
+ #archs = $CFLAGS.scan(/-arch\s(.*?)\s/).first # get the first arch flag
29
+ #if archs and archs.size >= 1
30
+ # # need to reduce the number of archs...
31
+ # # guess the first one is correct... at least the first one is probably the ruby installed arch...
32
+ # # this could lead to compiled binaries that crash at runtime...
33
+ # $CFLAGS.gsub!(/-arch\s(.*?)\s/,' ')
34
+ # $CFLAGS << " -arch #{archs.first}"
35
+ # puts "Selected arch: #{archs.first}"
36
+ #end
37
+
38
+ def define(s, v=1)
39
+ $defs.push( format("-D HAVE_%s=%d", s.to_s.upcase, v) )
40
+ end
41
+
42
+ def have_constant(name)
43
+ sname = name.is_a?(Symbol) ? name.to_s : name.upcase
44
+ checking_for name do
45
+ src = %{
46
+ #include <curl/curl.h>
47
+ int main() {
48
+ int test = (int)#{sname};
49
+ return 0;
50
+ }
51
+ }
52
+ if try_compile(src,"#{$CFLAGS} #{$LIBS}")
53
+ define name
54
+ true
55
+ else
56
+ #define name, 0
57
+ false
58
+ end
59
+ end
60
+ end
61
+
62
+ have_constant "curlinfo_redirect_time"
63
+ have_constant "curlinfo_response_code"
64
+ have_constant "curlinfo_filetime"
65
+ have_constant "curlinfo_redirect_count"
66
+ have_constant "curlinfo_os_errno"
67
+ have_constant "curlinfo_num_connects"
68
+ have_constant "curlinfo_ftp_entry_path"
69
+ have_constant "curl_version_ssl"
70
+ have_constant "curl_version_libz"
71
+ have_constant "curl_version_ntlm"
72
+ have_constant "curl_version_gssnegotiate"
73
+ have_constant "curl_version_debug"
74
+ have_constant "curl_version_asynchdns"
75
+ have_constant "curl_version_spnego"
76
+ have_constant "curl_version_largefile"
77
+ have_constant "curl_version_idn"
78
+ have_constant "curl_version_sspi"
79
+ have_constant "curl_version_conv"
80
+ have_constant "curlproxy_http"
81
+ have_constant "curlproxy_socks4"
82
+ have_constant "curlproxy_socks5"
83
+ have_constant "curlauth_basic"
84
+ have_constant "curlauth_digest"
85
+ have_constant "curlauth_gssnegotiate"
86
+ have_constant "curlauth_ntlm"
87
+ have_constant "curlauth_anysafe"
88
+ have_constant "curlauth_any"
89
+ have_constant "curle_tftp_notfound"
90
+ have_constant "curle_tftp_perm"
91
+ have_constant "curle_tftp_diskfull"
92
+ have_constant "curle_tftp_illegal"
93
+ have_constant "curle_tftp_unknownid"
94
+ have_constant "curle_tftp_exists"
95
+ have_constant "curle_tftp_nosuchuser"
96
+ # older versions of libcurl 7.12
97
+ have_constant "curle_send_fail_rewind"
98
+ have_constant "curle_ssl_engine_initfailed"
99
+ have_constant "curle_login_denied"
100
+
101
+ # older than 7.16.3
102
+ have_constant "curlmopt_maxconnects"
103
+
104
+ have_constant "curlopt_seekfunction"
105
+ have_constant "curlopt_seekdata"
106
+ have_constant "curlopt_sockoptfunction"
107
+ have_constant "curlopt_sockoptdata"
108
+ have_constant "curlopt_opensocketfunction"
109
+ have_constant "curlopt_opensocketdata"
110
+
111
+ # additional consts
112
+ have_constant "curle_conv_failed"
113
+ have_constant "curle_conv_reqd"
114
+ have_constant "curle_ssl_cacert_badfile"
115
+ have_constant "curle_remote_file_not_found"
116
+ have_constant "curle_ssh"
117
+ have_constant "curle_ssl_shutdown_failed"
118
+ have_constant "curle_again"
119
+ have_constant "curle_ssl_crl_badfile"
120
+ have_constant "curle_ssl_issuer_error"
121
+
122
+ # added in 7.18.2
123
+ have_constant "curlinfo_redirect_url"
124
+
125
+ # username/password added in 7.19.1
126
+ have_constant "curlopt_username"
127
+ have_constant "curlopt_password"
128
+ have_constant "curlinfo_primary_ip"
129
+
130
+ # ie quirk added in 7.19.3
131
+ have_constant "curlauth_digest_ie"
132
+
133
+ # added in 7.15.1
134
+ have_constant "curlftpmethod_multicwd"
135
+ have_constant "curlftpmethod_nocwd"
136
+ have_constant "curlftpmethod_singlecwd"
137
+
138
+ # centos 4.5 build of libcurl
139
+ have_constant "curlm_bad_socket"
140
+ have_constant "curlm_unknown_option"
141
+ have_func("curl_multi_timeout")
142
+ have_func("curl_multi_fdset")
143
+ have_func("curl_multi_perform")
144
+
145
+ # constants
146
+ have_constant "curlopt_interleavefunction"
147
+ have_constant "curlopt_interleavedata"
148
+ have_constant "curlopt_chunk_bgn_function"
149
+ have_constant "curlopt_chunk_end_function"
150
+ have_constant "curlopt_chunk_data"
151
+ have_constant "curlopt_fnmatch_function"
152
+ have_constant "curlopt_fnmatch_data"
153
+ have_constant "curlopt_errorbuffer"
154
+ have_constant "curlopt_stderr"
155
+ have_constant "curlopt_failonerror"
156
+ have_constant "curlopt_url"
157
+ have_constant "curlopt_protocols"
158
+ have_constant "curlopt_redir_protocols"
159
+ have_constant "curlopt_proxy"
160
+ have_constant "curlopt_proxyport"
161
+ have_constant "curlopt_proxytype"
162
+ have_constant "curlopt_noproxy"
163
+ have_constant "curlopt_httpproxytunnel"
164
+ have_constant "curlopt_socks5_gssapi_service"
165
+ have_constant "curlopt_socks5_gssapi_nec"
166
+ have_constant "curlopt_interface"
167
+ have_constant "curlopt_localport"
168
+ have_constant "curlopt_dns_cache_timeout"
169
+ have_constant "curlopt_dns_use_global_cache"
170
+ have_constant "curlopt_buffersize"
171
+ have_constant "curlopt_port"
172
+ have_constant "curlopt_tcp_nodelay"
173
+ have_constant "curlopt_address_scope"
174
+ have_constant "curlopt_netrc"
175
+ have_constant "curl_netrc_optional"
176
+ have_constant "curl_netrc_ignored"
177
+ have_constant "curl_netrc_required"
178
+ have_constant "curlopt_netrc_file"
179
+ have_constant "curlopt_userpwd"
180
+ have_constant "curlopt_proxyuserpwd"
181
+ have_constant "curlopt_username"
182
+ have_constant "curlopt_password"
183
+ have_constant "curlopt_password"
184
+ have_constant "curlopt_password"
185
+ have_constant "curlopt_httpauth"
186
+ have_constant "curlauth_digest_ie"
187
+ have_constant "curlauth_only"
188
+ have_constant "curlopt_tlsauth_type"
189
+ have_constant "curlopt_tlsauth_srp"
190
+ have_constant "curlopt_tlsauth_username"
191
+ have_constant "curlopt_tlsauth_password"
192
+ have_constant "curlopt_proxyauth"
193
+ have_constant "curlopt_autoreferer"
194
+ have_constant "curlopt_encoding"
195
+ have_constant "curlopt_followlocation"
196
+ have_constant "curlopt_unrestricted_auth"
197
+ have_constant "curlopt_maxredirs"
198
+ have_constant "curlopt_postredir"
199
+ have_constant "curlopt_put"
200
+ have_constant "curlopt_post"
201
+ have_constant "curlopt_postfields"
202
+ have_constant "curlopt_postfieldsize"
203
+ have_constant "curlopt_postfieldsize_large"
204
+ have_constant "curlopt_copypostfields"
205
+ have_constant "curlopt_httppost"
206
+ have_constant "curlopt_referer"
207
+ have_constant "curlopt_useragent"
208
+ have_constant "curlopt_httpheader"
209
+ have_constant "curlopt_http200aliases"
210
+ have_constant "curlopt_cookie"
211
+ have_constant "curlopt_cookiefile"
212
+ have_constant "curlopt_cookiejar"
213
+ have_constant "curlopt_cookiesession"
214
+ have_constant "curlopt_cookielist"
215
+ have_constant "curlopt_httpget"
216
+ have_constant "curlopt_http_version"
217
+ have_constant "curl_http_version_none"
218
+ have_constant "curl_http_version_1_0"
219
+ have_constant "curl_http_version_1_1"
220
+ have_constant "curlopt_ignore_content_length"
221
+ have_constant "curlopt_http_content_decoding"
222
+ have_constant "curlopt_http_transfer_decoding"
223
+ have_constant "curlopt_mail_from"
224
+ have_constant "curlopt_mail_rcpt"
225
+ have_constant "curlopt_tftp_blksize"
226
+ have_constant "curlopt_ftpport"
227
+ have_constant "curlopt_quote"
228
+ have_constant "curlopt_postquote"
229
+ have_constant "curlopt_prequote"
230
+ have_constant "curlopt_dirlistonly"
231
+ have_constant "curlopt_append"
232
+ have_constant "curlopt_ftp_use_eprt"
233
+ have_constant "curlopt_ftp_use_epsv"
234
+ have_constant "curlopt_ftp_use_pret"
235
+ have_constant "curlopt_ftp_create_missing_dirs"
236
+ have_constant "curlopt_ftp_response_timeout"
237
+ have_constant "curlopt_ftp_alternative_to_user"
238
+ have_constant "curlopt_ftp_skip_pasv_ip"
239
+ have_constant "curlopt_ftpsslauth"
240
+ have_constant "curlftpauth_default"
241
+ have_constant "curlftpauth_ssl"
242
+ have_constant "curlftpauth_tls"
243
+ have_constant "curlopt_ftp_ssl_ccc"
244
+ have_constant "curlftpssl_ccc_none"
245
+ have_constant "curlftpssl_ccc_passive"
246
+ have_constant "curlftpssl_ccc_active"
247
+ have_constant "curlopt_ftp_account"
248
+ have_constant "curlopt_ftp_filemethod"
249
+ have_constant "curlftpmethod_multicwd"
250
+ have_constant "curlftpmethod_nocwd"
251
+ have_constant "curlftpmethod_singlecwd"
252
+ have_constant "curlopt_rtsp_request"
253
+ have_constant "curl_rtspreq_options"
254
+ have_constant "curl_rtspreq_describe"
255
+ have_constant "curl_rtspreq_announce"
256
+ have_constant "curl_rtspreq_setup"
257
+ have_constant "curl_rtspreq_play"
258
+ have_constant "curl_rtspreq_pause"
259
+ have_constant "curl_rtspreq_teardown"
260
+ have_constant "curl_rtspreq_get_parameter"
261
+ have_constant "curl_rtspreq_set_parameter"
262
+ have_constant "curl_rtspreq_record"
263
+ have_constant "curl_rtspreq_receive"
264
+ have_constant "curlopt_rtsp_session_id"
265
+ have_constant "curlopt_rtsp_stream_uri"
266
+ have_constant "curlopt_rtsp_transport"
267
+ have_constant "curlopt_rtsp_header"
268
+ have_constant "curlopt_rtsp_client_cseq"
269
+ have_constant "curlopt_rtsp_server_cseq"
270
+ have_constant "curlopt_transfertext"
271
+ have_constant "curlopt_proxy_transfer_mode"
272
+ have_constant "curlopt_crlf"
273
+ have_constant "curlopt_range"
274
+ have_constant "curlopt_resume_from"
275
+ have_constant "curlopt_resume_from_large"
276
+ have_constant "curlopt_customrequest"
277
+ have_constant "curlopt_filetime"
278
+ have_constant "curlopt_nobody"
279
+ have_constant "curlopt_infilesize"
280
+ have_constant "curlopt_infilesize_large"
281
+ have_constant "curlopt_upload"
282
+ have_constant "curlopt_maxfilesize"
283
+ have_constant "curlopt_maxfilesize_large"
284
+ have_constant "curlopt_timecondition"
285
+ have_constant "curlopt_timevalue"
286
+ have_constant "curlopt_timeout"
287
+ have_constant "curlopt_timeout_ms"
288
+ have_constant "curlopt_low_speed_limit"
289
+ have_constant "curlopt_low_speed_time"
290
+ have_constant "curlopt_max_send_speed_large"
291
+ have_constant "curlopt_max_recv_speed_large"
292
+ have_constant "curlopt_maxconnects"
293
+ have_constant "curlopt_closepolicy"
294
+ have_constant "curlopt_fresh_connect"
295
+ have_constant "curlopt_forbid_reuse"
296
+ have_constant "curlopt_connecttimeout"
297
+ have_constant "curlopt_connecttimeout_ms"
298
+ have_constant "curlopt_ipresolve"
299
+ have_constant "curl_ipresolve_whatever"
300
+ have_constant "curl_ipresolve_v4"
301
+ have_constant "curl_ipresolve_v6"
302
+ have_constant "curlopt_connect_only"
303
+ have_constant "curlopt_use_ssl"
304
+ have_constant "curlusessl_none"
305
+ have_constant "curlusessl_try"
306
+ have_constant "curlusessl_control"
307
+ have_constant "curlusessl_all"
308
+ have_constant "curlopt_resolve"
309
+ have_constant "curlopt_sslcert"
310
+ have_constant "curlopt_sslcerttype"
311
+ have_constant "curlopt_sslkey"
312
+ have_constant "curlopt_sslkeytype"
313
+ have_constant "curlopt_keypasswd"
314
+ have_constant "curlopt_sslengine"
315
+ have_constant "curlopt_sslengine_default"
316
+ have_constant "curlopt_sslversion"
317
+ have_constant "curl_sslversion_default"
318
+ have_constant :CURL_SSLVERSION_TLSv1
319
+ have_constant :CURL_SSLVERSION_SSLv2
320
+ have_constant :CURL_SSLVERSION_SSLv3
321
+ have_constant "curlopt_ssl_verifypeer"
322
+ have_constant "curlopt_cainfo"
323
+ have_constant "curlopt_issuercert"
324
+ have_constant "curlopt_capath"
325
+ have_constant "curlopt_crlfile"
326
+ have_constant "curlopt_ssl_verifyhost"
327
+ have_constant "curlopt_certinfo"
328
+ have_constant "curlopt_random_file"
329
+ have_constant "curlopt_egdsocket"
330
+ have_constant "curlopt_ssl_cipher_list"
331
+ have_constant "curlopt_ssl_sessionid_cache"
332
+ have_constant "curlopt_krblevel"
333
+ have_constant "curlopt_ssh_auth_types"
334
+ have_constant "curlopt_ssh_host_public_key_md5"
335
+ have_constant "curlopt_ssh_public_keyfile"
336
+ have_constant "curlopt_ssh_private_keyfile"
337
+ have_constant "curlopt_ssh_knownhosts"
338
+ have_constant "curlopt_ssh_keyfunction"
339
+ have_constant "curlkhstat_fine_add_to_file"
340
+ have_constant "curlkhstat_fine"
341
+ have_constant "curlkhstat_reject"
342
+ have_constant "curlkhstat_defer"
343
+ have_constant "curlopt_ssh_keydata"
344
+ have_constant "curlopt_private"
345
+ have_constant "curlopt_share"
346
+ have_constant "curlopt_new_file_perms"
347
+ have_constant "curlopt_new_directory_perms"
348
+ have_constant "curlopt_telnetoptions"
349
+ # was obsoleted in August 2007 for 7.17.0, reused in April 2011 for 7.21.5
350
+ have_constant "curle_not_built_in"
351
+
352
+ have_constant "curle_obsolete" # removed in 7.24 ?
353
+
354
+ if try_compile('int main() { return 0; }','-Wall')
355
+ $CFLAGS << ' -Wall'
356
+ end
357
+
358
+ # do some checking to detect ruby 1.8 hash.c vs ruby 1.9 hash.c
359
+ def test_for(name, const, src)
360
+ checking_for name do
361
+ if try_compile(src,"#{$CFLAGS} #{$LIBS}")
362
+ define const
363
+ true
364
+ else
365
+ false
366
+ end
367
+ end
368
+ end
369
+ test_for("Ruby 1.9 Hash", "RUBY19_HASH", %{
370
+ #include <ruby.h>
371
+ int main() {
372
+ VALUE hash = rb_hash_new();
373
+ if( RHASH(hash)->ntbl->num_entries ) {
374
+ return 0;
375
+ }
376
+ return 1;
377
+ }
378
+ })
379
+ test_for("Ruby 1.9 st.h", "RUBY19_ST_H", %{
380
+ #include <ruby.h>
381
+ #include <ruby/st.h>
382
+ int main() {
383
+ return 0;
384
+ }
385
+ })
386
+
387
+ test_for("curl_easy_escape", "CURL_EASY_ESCAPE", %{
388
+ #include <curl/curl.h>
389
+ int main() {
390
+ CURL *easy = curl_easy_init();
391
+ curl_easy_escape(easy,"hello",5);
392
+ return 0;
393
+ }
394
+ })
395
+
396
+ have_func('rb_thread_blocking_region')
397
+
398
+ create_header('curb_config.h')
399
+ create_makefile('curb_core')