1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
Patch for Ruby 1.9 compatibility, backport from upstream SVN.
--- ext/fcgi/fcgi.c 2006-06-25 06:06:42.000000000 +0200
+++ ext/fcgi/fcgi.c.r47 2008-12-02 10:37:47.000000000 +0100
@@ -17,6 +17,16 @@
#include "fcgiapp.h"
#endif
+#ifndef RARRAY_PTR
+#define RARRAY_LEN(ary) (RARRAY(ary)->len)
+#define RARRAY_PTR(ary) (RARRAY(ary)->ptr)
+#endif
+
+#ifndef RSTRING_PTR
+#define RSTRING_LEN(str) (RSTRING(str)->len)
+#define RSTRING_PTR(str) (RSTRING(str)->ptr)
+#endif
+
static VALUE cFCGI;
static VALUE eFCGIError;
static VALUE cFCGIStream;
@@ -222,7 +232,7 @@
rb_secure(4);
Data_Get_Struct(self, FCGX_Stream, stream);
str = rb_obj_as_string(str);
- len = FCGX_PutStr(RSTRING(str)->ptr, RSTRING(str)->len, stream);
+ len = FCGX_PutStr(RSTRING_PTR(str), RSTRING_LEN(str), stream);
if (len == EOF) CHECK_STREAM_ERROR(stream);
return INT2NUM(len);
}
@@ -271,8 +281,8 @@
VALUE tmp;
int i;
- for (i=0; i<RARRAY(ary)->len; i++) {
- tmp = RARRAY(ary)->ptr[i];
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ tmp = RARRAY_PTR(ary)[i];
if (rb_inspecting_p(tmp)) {
tmp = rb_str_new2("[...]");
}
@@ -305,7 +315,7 @@
}
line = rb_obj_as_string(line);
fcgi_stream_write(out, line);
- if (RSTRING(line)->ptr[RSTRING(line)->len-1] != '\n') {
+ if (RSTRING_PTR(line)[RSTRING_LEN(line)-1] != '\n') {
fcgi_stream_write(out, rb_default_rs);
}
}
@@ -379,7 +389,7 @@
rb_str_cat(str, buff, strlen(buff));
if (strchr(buff, '\n')) break;
}
- if (RSTRING(str)->len > 0)
+ if (RSTRING_LEN(str) > 0)
return str;
else
return Qnil;
@@ -507,7 +517,8 @@
-void Init_fcgi() {
+void Init_fcgi()
+{
FCGX_Init();
@@ -517,7 +528,7 @@
rb_define_singleton_method(cFCGI, "each", fcgi_s_each, 0);
rb_define_singleton_method(cFCGI, "each_request", fcgi_s_each, 0);
rb_define_singleton_method(cFCGI, "is_cgi?", fcgi_s_iscgi, 0);
- rb_define_method(cFCGI, "in", fcgi_in, 0);
+ rb_define_method(cFCGI, "in", fcgi_in, 0);
rb_define_method(cFCGI, "out", fcgi_out, 0);
rb_define_method(cFCGI, "err", fcgi_err, 0);
rb_define_method(cFCGI, "env", fcgi_env, 0);
|