public
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
Search Repo:
Remove thin_ prefix in method and var names
macournoyer (author)
Sun Apr 06 17:54:03 -0700 2008
commit  9709dbc777edf33300af95ca1bc11fa57555922d
tree    7b5ce8d43006a5e838d910bdce8871015e8c75ec
parent  fd730daf88e86f86981e87b9fc167edbaf735fee
...
6
7
8
9
 
10
11
 
12
13
14
15
16
...
21
22
23
24
 
25
26
27
28
29
30
 
31
32
33
 
 
34
35
36
37
...
45
46
47
48
 
49
50
51
 
 
52
53
54
55
56
57
58
59
...
65
66
67
68
 
69
70
71
72
 
73
74
75
76
77
78
79
 
80
81
82
 
 
83
84
85
86
87
88
89
 
90
91
92
 
 
93
94
95
...
98
99
100
101
 
102
103
104
105
106
107
108
109
...
107
108
109
110
 
111
112
113
 
 
114
115
116
 
 
117
118
 
119
120
121
122
123
124
125
 
126
127
128
129
130
131
132
133
134
135
 
 
 
 
 
136
...
6
7
8
 
9
10
 
11
12
13
14
15
16
...
21
22
23
 
24
25
26
27
28
29
 
30
31
 
 
32
33
34
35
36
37
...
45
46
47
 
48
49
 
 
50
51
52
53
54
55
56
57
58
59
...
65
66
67
 
68
69
70
71
 
72
73
74
75
76
77
78
 
79
80
 
 
81
82
83
84
85
86
87
88
 
89
90
 
 
91
92
93
94
95
...
98
99
100
 
101
102
103
104
105
106
107
108
109
...
107
108
109
 
110
111
 
 
112
113
114
 
 
115
116
117
 
118
119
120
121
122
123
124
 
125
126
127
128
129
130
 
 
 
 
 
131
132
133
134
135
136
0
@@ -6,9 +6,9 @@
0
 
0
 /* event callbacks */
0
 
0
-static void thin_backend_accept_cb(EV_P_ struct ev_io *watcher, int revents)
0
+static void backend_accept_cb(EV_P_ struct ev_io *watcher, int revents)
0
 {
0
- thin_backend_t *server = get_ev_data(backend, watcher, accept);
0
+ backend_t *server = get_ev_data(backend, watcher, accept);
0
   struct sockaddr_in remote_addr;
0
   socklen_t sin_size = sizeof(remote_addr);
0
   int fd, flags;
0
0
0
@@ -21,16 +21,16 @@
0
   if ((fcntl(fd, F_SETFL, flags | O_NONBLOCK)) < 0)
0
     rb_sys_fail("fcntl");
0
   
0
- thin_connection_start(server, fd, remote_addr);
0
+ connection_start(server, fd, remote_addr);
0
 }
0
 
0
 
0
 /* public api */
0
 
0
-VALUE thin_backend_init(VALUE self, VALUE address, VALUE port, VALUE app)
0
+VALUE backend_init(VALUE self, VALUE address, VALUE port, VALUE app)
0
 {
0
- thin_backend_t *backend = NULL;
0
- DATA_GET(self, thin_backend_t, backend);
0
+ backend_t *backend = NULL;
0
+ DATA_GET(self, backend_t, backend);
0
     
0
   backend->address = RSTRING_PTR(address);
0
   backend->port = FIX2INT(port);
0
0
@@ -45,10 +45,10 @@
0
   return self;
0
 }
0
 
0
-VALUE thin_backend_listen(VALUE self)
0
+VALUE backend_listen(VALUE self)
0
 {
0
- thin_backend_t *backend = NULL;
0
- DATA_GET(self, thin_backend_t, backend);
0
+ backend_t *backend = NULL;
0
+ DATA_GET(self, backend_t, backend);
0
   int sock_flags;
0
 
0
   if ((backend->fd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
0
0
0
0
0
0
@@ -65,31 +65,31 @@
0
   if (bind(backend->fd, (struct sockaddr *)&backend->local_addr, sizeof backend->local_addr) == -1)
0
     rb_sys_fail("bind");
0
 
0
- if (listen(backend->fd, THIN_LISTEN_BACKLOG) == -1)
0
+ if (listen(backend->fd, LISTEN_BACKLOG) == -1)
0
     rb_sys_fail("listen");
0
   
0
   /* initialise io watchers */
0
- watch(backend, thin_backend_accept_cb, accept, EV_READ);
0
+ watch(backend, backend_accept_cb, accept, EV_READ);
0
   
0
   backend->open = 1;
0
   
0
   return Qtrue;
0
 }
0
 
0
-VALUE thin_backend_loop(VALUE self)
0
+VALUE backend_loop(VALUE self)
0
 {
0
- thin_backend_t *backend = NULL;
0
- DATA_GET(self, thin_backend_t, backend);
0
+ backend_t *backend = NULL;
0
+ DATA_GET(self, backend_t, backend);
0
   
0
   ev_loop(backend->loop, EVLOOP_ONESHOT);
0
   
0
   return Qtrue;
0
 }
0
 
0
-VALUE thin_backend_close(VALUE self)
0
+VALUE backend_close(VALUE self)
0
 {
0
- thin_backend_t *backend = NULL;
0
- DATA_GET(self, thin_backend_t, backend);
0
+ backend_t *backend = NULL;
0
+ DATA_GET(self, backend_t, backend);
0
   
0
   backend->open = 0;
0
   ev_io_stop(backend->loop, &backend->accept_watcher);
0
@@ -98,7 +98,7 @@
0
   return Qtrue;
0
 }
0
 
0
-static void thin_backend_free(thin_backend_t *backend)
0
+static void backend_free(backend_t *backend)
0
 {
0
   if (backend) {
0
     array_destroy(backend->connections);
0
0
0
0
0
0
@@ -107,31 +107,31 @@
0
   }
0
 }
0
 
0
-VALUE thin_backend_alloc(VALUE klass)
0
+VALUE backend_alloc(VALUE klass)
0
 {
0
- thin_backend_t *backend = ALLOC_N(thin_backend_t, 1);
0
- VALUE obj = Data_Wrap_Struct(klass, NULL, thin_backend_free, backend);
0
+ backend_t *backend = ALLOC_N(backend_t, 1);
0
+ VALUE obj = Data_Wrap_Struct(klass, NULL, backend_free, backend);
0
   
0
- backend->connections = array_create(THIN_CONNECTIONS_SIZE, sizeof(thin_connection_t));
0
- thin_connections_create(backend->connections, THIN_CONNECTIONS_SIZE);
0
+ backend->connections = array_create(CONNECTIONS_SIZE, sizeof(connection_t));
0
+ connections_create(backend->connections, CONNECTIONS_SIZE);
0
   
0
- backend->buffer_pool = pool_create(THIN_BUFFER_SLICES, THIN_BUFFER_SIZE);
0
+ backend->buffer_pool = pool_create(BUFFER_SLICES, BUFFER_SIZE);
0
   
0
   backend->obj = obj;
0
   
0
   return obj;
0
 }
0
 
0
-void thin_backend_define(void)
0
+void backend_define(void)
0
 {
0
   /* Plug our C stuff into the Ruby world */
0
   VALUE mThin = rb_define_module("Thin");
0
   VALUE cBackend = rb_define_class_under(mThin, "Backend", rb_cObject);
0
   
0
- rb_define_alloc_func(cBackend, thin_backend_alloc);
0
- rb_define_method(cBackend, "initialize", thin_backend_init, 3);
0
- rb_define_protected_method(cBackend, "listen", thin_backend_listen, 0);
0
- rb_define_protected_method(cBackend, "loop!", thin_backend_loop, 0);
0
- rb_define_protected_method(cBackend, "close", thin_backend_close, 0);
0
+ rb_define_alloc_func(cBackend, backend_alloc);
0
+ rb_define_method(cBackend, "initialize", backend_init, 3);
0
+ rb_define_protected_method(cBackend, "listen", backend_listen, 0);
0
+ rb_define_protected_method(cBackend, "loop!", backend_loop, 0);
0
+ rb_define_protected_method(cBackend, "close", backend_close, 0);
0
 }
...
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
...
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
...
78
79
80
81
 
82
83
84
...
110
111
112
113
 
114
115
116
117
118
...
127
128
129
130
 
131
132
133
134
135
 
136
137
138
139
 
 
140
141
142
...
178
179
180
181
 
182
183
184
185
186
187
...
186
187
188
189
 
190
191
192
193
 
194
195
196
197
 
198
199
200
201
202
 
203
204
205
...
224
225
226
227
 
228
229
230
...
233
234
235
236
 
237
238
239
...
250
251
252
253
 
254
255
256
...
258
259
260
261
 
262
263
264
265
266
...
266
267
268
269
270
271
 
 
 
272
273
 
274
275
276
277
 
278
279
280
...
301
302
303
304
 
305
306
307
308
309
...
309
310
311
312
 
313
314
 
315
316
317
318
319
320
 
321
322
...
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
...
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
...
78
79
80
 
81
82
83
84
...
110
111
112
 
113
114
115
116
117
118
...
127
128
129
 
130
131
132
133
134
 
135
136
137
 
 
138
139
140
141
142
...
178
179
180
 
181
182
183
184
185
186
187
...
186
187
188
 
189
190
191
192
 
193
194
195
196
 
197
198
199
200
201
 
202
203
204
205
...
224
225
226
 
227
228
229
230
...
233
234
235
 
236
237
238
239
...
250
251
252
 
253
254
255
256
...
258
259
260
 
261
262
263
264
265
266
...
266
267
268
 
 
 
269
270
271
272
 
273
274
275
276
 
277
278
279
280
...
301
302
303
 
304
305
306
307
308
309
...
309
310
311
 
312
313
 
314
315
316
317
318
319
 
320
321
322
0
@@ -4,26 +4,26 @@
0
 static VALUE sInternedKeys;
0
 static VALUE sRackInput;
0
 
0
-#define thin_connection_error(connection, msg) \
0
+#define connection_error(connection, msg) \
0
   rb_funcall(connection->backend->obj, rb_intern("log_error"), 1, \
0
              rb_exc_new(rb_eRuntimeError, msg, strlen(msg))); \
0
- thin_connection_close(connection)
0
+ connection_close(connection)
0
 
0
-#define thin_connection_errorno(connection) \
0
- thin_connection_error(connection, strerror(errno))
0
+#define connection_errorno(connection) \
0
+ connection_error(connection, strerror(errno))
0
 
0
 /* event callbacks */
0
 
0
-static void thin_connection_closable_cb(EV_P_ struct ev_io *watcher, int revents)
0
+static void connection_closable_cb(EV_P_ struct ev_io *watcher, int revents)
0
 {
0
- thin_connection_t *connection = get_ev_data(connection, watcher, write);
0
+ connection_t *connection = get_ev_data(connection, watcher, write);
0
   
0
- thin_connection_close(connection);
0
+ connection_close(connection);
0
 }
0
 
0
-static void thin_connection_writable_cb(EV_P_ struct ev_io *watcher, int revents)
0
+static void connection_writable_cb(EV_P_ struct ev_io *watcher, int revents)
0
 {
0
- thin_connection_t *connection = get_ev_data(connection, watcher, write);
0
+ connection_t *connection = get_ev_data(connection, watcher, write);
0
   int sent;
0
   
0
   sent = send(connection->fd,
0
0
0
0
0
0
0
0
0
0
@@ -34,38 +34,38 @@
0
   if (sent > 0) {
0
     connection->write_buffer.current += sent;
0
   } else {
0
- thin_connection_errorno(connection);
0
+ connection_errorno(connection);
0
     return;
0
   }
0
   
0
   if (connection->write_buffer.current == connection->write_buffer.len) {
0
- watcher->cb = thin_connection_closable_cb;
0
+ watcher->cb = connection_closable_cb;
0
   }
0
 }
0
 
0
-static void thin_connection_readable_cb(EV_P_ struct ev_io *watcher, int revents)
0
+static void connection_readable_cb(EV_P_ struct ev_io *watcher, int revents)
0
 {
0
- thin_connection_t *connection = get_ev_data(connection, watcher, read);
0
+ connection_t *connection = get_ev_data(connection, watcher, read);
0
   size_t n;
0
- char buf[THIN_BUFFER_SIZE];
0
+ char buf[BUFFER_SIZE];
0
 
0
- n = recv(connection->fd, buf, THIN_BUFFER_SIZE, 0);
0
+ n = recv(connection->fd, buf, BUFFER_SIZE, 0);
0
   
0
   if (n == -1) {
0
- thin_connection_errorno(connection);
0
+ connection_errorno(connection);
0
     return;
0
   }
0
   
0
- thin_connection_parse(connection, buf, n);
0
+ connection_parse(connection, buf, n);
0
 }
0
 
0
 
0
 /* public api */
0
 
0
-void thin_connection_start(thin_backend_t *backend, int fd, struct sockaddr_in remote_addr)
0
+void connection_start(backend_t *backend, int fd, struct sockaddr_in remote_addr)
0
 {
0
- thin_connection_t *connection = NULL;
0
- thin_connection_t *connections = backend->connections->items;
0
+ connection_t *connection = NULL;
0
+ connection_t *connections = backend->connections->items;
0
   int i = 0;
0
   
0
   /* select the first closed connection */
0
@@ -78,7 +78,7 @@
0
   
0
   /* no free connection found, add more */
0
   if (connection == NULL) {
0
- thin_connections_create(backend->connections, THIN_CONNECTIONS_SIZE);
0
+ connections_create(backend->connections, CONNECTIONS_SIZE);
0
     connections = backend->connections->items;
0
     /* FIXME: bug here on high concurrency, causes segfault on line 88 */
0
     connection = &connections[++i];
0
@@ -110,7 +110,7 @@
0
   connection->read_buffer.current = 0;
0
   
0
   /* assign env[rack.input] */
0
- connection->input = thin_input_new(&connection->read_buffer);
0
+ connection->input = input_new(&connection->read_buffer);
0
   rb_gc_register_address(&connection->input);
0
   rb_hash_aset(connection->env, sRackInput, connection->input);
0
   
0
0
0
@@ -127,16 +127,16 @@
0
   connection->parser.data = connection;
0
   
0
   /* init libev stuff */
0
- watch(connection, thin_connection_readable_cb, read, EV_READ);
0
+ watch(connection, connection_readable_cb, read, EV_READ);
0
   
0
   /* TODO add timeout watcher */
0
 }
0
 
0
-void thin_connection_parse(thin_connection_t *connection, char *buf, int len)
0
+void connection_parse(connection_t *connection, char *buf, int len)
0
 {
0
   if (!http_parser_is_finished(&connection->parser)
0
- && connection->read_buffer.len + len > THIN_MAX_HEADER) {
0
- thin_connection_error(connection, "Header too big");
0
+ && connection->read_buffer.len + len > MAX_HEADER) {
0
+ connection_error(connection, "Header too big");
0
     return;
0
   }
0
   
0
@@ -178,7 +178,7 @@
0
   
0
     /* parser error */
0
     if (http_parser_has_error(&connection->parser)) {
0
- thin_connection_error(connection, "Invalid request");
0
+ connection_error(connection, "Invalid request");
0
       return;
0
     }
0
   }
0
0
0
0
@@ -186,20 +186,20 @@
0
   /* request fully received */
0
   if (http_parser_is_finished(&connection->parser) && connection->read_buffer.len >= connection->content_length) {
0
     unwatch(connection, read);
0
- thin_connection_process(connection);
0
+ connection_process(connection);
0
   }
0
 }
0
 
0
-void thin_connection_send_status(thin_connection_t *connection, const int status)
0
+void connection_send_status(connection_t *connection, const int status)
0
 {
0
   size_t n;
0
   
0
- n = sprintf(connection->write_buffer.ptr, "HTTP/1.1 %s" CRLF, thin_status(status));
0
+ n = sprintf(connection->write_buffer.ptr, "HTTP/1.1 %s" CRLF, get_status_line(status));
0
   
0
   connection->write_buffer.len = n;
0
 }
0
 
0
-void thin_connection_send_headers(thin_connection_t *connection, VALUE headers)
0
+void connection_send_headers(connection_t *connection, VALUE headers)
0
 {
0
   VALUE hash, keys, key, value;
0
   size_t i, n;
0
@@ -224,7 +224,7 @@
0
 
0
 static VALUE iter_body(VALUE chunk, VALUE *val_conn)
0
 {
0
- thin_connection_t *conn = (thin_connection_t *) val_conn;
0
+ connection_t *conn = (connection_t *) val_conn;
0
   size_t len = RSTRING_LEN(chunk);
0
   
0
   memcpy(conn->write_buffer.ptr + conn->write_buffer.len, RSTRING_PTR(chunk), len);
0
@@ -233,7 +233,7 @@
0
   return Qnil;
0
 }
0
 
0
-int thin_connection_send_body(thin_connection_t *conn, VALUE body)
0
+int connection_send_body(connection_t *conn, VALUE body)
0
 {
0
   if (TYPE(body) == T_STRING) {
0
     /* Calling String#each creates several other strings which is slower and use more mem,
0
@@ -250,7 +250,7 @@
0
   }
0
 }
0
 
0
-void thin_connection_process(thin_connection_t *connection)
0
+void connection_process(connection_t *connection)
0
 {
0
   /* Call the app to process the request */
0
   VALUE response = rb_funcall_rescue(connection->backend->app, sInternedCall, 1, connection->env);
0
@@ -258,7 +258,7 @@
0
   if (response == Qundef) {
0
     /* log any error */
0
     rb_funcall(connection->backend->obj, rb_intern("log_error"), 0);
0
- thin_connection_close(connection);
0
+ connection_close(connection);
0
   } else {
0
     /* store response info and prepare for writing */
0
     int status = FIX2INT(rb_ary_entry(response, 0));
0
0
0
@@ -266,15 +266,15 @@
0
     VALUE body = rb_ary_entry(response, 2);
0
     
0
     /* TODO grow buffer if too small */
0
- thin_connection_send_status(connection, status);
0
- thin_connection_send_headers(connection, headers);
0
- thin_connection_send_body(connection, body);
0
+ connection_send_status(connection, status);
0
+ connection_send_headers(connection, headers);
0
+ connection_send_body(connection, body);
0
   
0
- watch(connection, thin_connection_writable_cb, write, EV_WRITE);
0
+ watch(connection, connection_writable_cb, write, EV_WRITE);
0
   }
0
 }
0
 
0
-void thin_connection_close(thin_connection_t *connection)
0
+void connection_close(connection_t *connection)
0
 {
0
   unwatch(connection, read);
0
   unwatch(connection, write);
0
@@ -301,7 +301,7 @@
0
 
0
 /* connections */
0
 
0
-void thin_connections_init()
0
+void connections_init()
0
 {
0
   /* Intern some Ruby string */
0
   sInternedCall = rb_intern("call");
0
0
0
@@ -309,15 +309,15 @@
0
   sRackInput = rb_obj_freeze(rb_str_new2("rack.input"));
0
 }
0
 
0
-void thin_connections_create(array_t *connections, size_t num)
0
+void connections_create(array_t *connections, size_t num)
0
 {
0
- thin_connection_t *connection;
0
+ connection_t *connection;
0
   int i;
0
   
0
   for (i = 0; i <= num; ++i) {
0
     connection = array_push(connections);
0
     connection->open = 0;
0
- thin_setup_parser_callbacks(connection);
0
+ parser_callbacks_setup(connection);
0
   }
0
 }
...
32
33
34
35
 
36
37
38
 
...
32
33
34
 
35
36
37
 
38
0
@@ -32,8 +32,8 @@
0
 $CFLAGS << " -I#{libev_dir} " << flags.join(' ')
0
 $defs << "-DRUBY_VERSION_CODE=#{RUBY_VERSION.gsub(/\D/, '')}"
0
 
0
-dir_config("thin_backend")
0
+dir_config("backend")
0
 have_library("c", "main")
0
 
0
-create_makefile("thin_backend")
0
+create_makefile("backend")
...
1
2
3
 
4
5
6
7
8
9
 
 
 
 
10
...
1
2
 
3
4
5
 
 
 
 
6
7
8
9
10
0
@@ -1,11 +1,11 @@
0
 #include "thin.h"
0
 
0
-void Init_thin_backend()
0
+void Init__backend()
0
 {
0
   /* Initialize internal stuff */
0
- thin_backend_define();
0
- thin_input_define();
0
- thin_connections_init();
0
- thin_parser_callbacks_init();
0
+ backend_define();
0
+ input_define();
0
+ connections_init();
0
+ parser_callbacks_init();
0
 }
...
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
...
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
...
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
...
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
0
@@ -4,20 +4,20 @@
0
 
0
 static VALUE cInput;
0
 
0
-#define thin_buffer_to_s(buf) rb_str_new(buf->ptr, buf->len)
0
+#define buffer_to_s(buf) rb_str_new(buf->ptr, buf->len)
0
 
0
-static VALUE thin_input_gets(VALUE self)
0
+static VALUE input_gets(VALUE self)
0
 {
0
- thin_buffer_t *buf = NULL;
0
- DATA_GET(self, thin_buffer_t, buf);
0
+ buffer_t *buf = NULL;
0
+ DATA_GET(self, buffer_t, buf);
0
   
0
- return thin_buffer_to_s(buf);
0
+ return buffer_to_s(buf);
0
 }
0
 
0
-static VALUE thin_input_read(int argc, VALUE *argv, VALUE self)
0
+static VALUE input_read(int argc, VALUE *argv, VALUE self)
0
 {
0
- thin_buffer_t *buf = NULL;
0
- DATA_GET(self, thin_buffer_t, buf);
0
+ buffer_t *buf = NULL;
0
+ DATA_GET(self, buffer_t, buf);
0
   VALUE vlen, str;
0
   int maxlen, len;
0
   
0
0
0
0
0
0
@@ -40,29 +40,29 @@
0
   return str;
0
 }
0
 
0
-static VALUE thin_input_each(VALUE self)
0
+static VALUE input_each(VALUE self)
0
 {
0
- thin_buffer_t *buf = NULL;
0
- DATA_GET(self, thin_buffer_t, buf);
0
+ buffer_t *buf = NULL;
0
+ DATA_GET(self, buffer_t, buf);
0
   
0
- rb_yield(thin_buffer_to_s(buf));
0
+ rb_yield(buffer_to_s(buf));
0
   
0
   return Qnil;
0
 }
0
 
0
-VALUE thin_input_new(thin_buffer_t *buf)
0
+VALUE input_new(buffer_t *buf)
0
 {
0
   return Data_Wrap_Struct(cInput, NULL, NULL, buf);
0
 }
0
 
0
-void thin_input_define(void)
0
+void input_define(void)
0
 {
0
   /* Plug our C stuff into the Ruby world */
0
   VALUE mThin = rb_define_module("Thin");
0
   cInput = rb_define_class_under(mThin, "Input", rb_cObject);
0
   
0
- rb_define_method(cInput, "gets", thin_input_gets, 0);
0
- rb_define_method(cInput, "read", thin_input_read, -1);
0
- rb_define_method(cInput, "each", thin_input_each, 0);
0
+ rb_define_method(cInput, "gets", input_gets, 0);
0
+ rb_define_method(cInput, "read", input_read, -1);
0
+ rb_define_method(cInput, "each", input_each, 0);
0
 }
...
29
30
31
32
 
33
34
35
...
50
51
52
53
 
54
55
56
...
59
60
61
62
 
63
64
65
...
68
69
70
71
 
72
73
74
...
77
78
79
80
 
81
82
83
...
87
88
89
90
 
91
92
93
...
96
97
98
99
 
100
101
102
...
106
107
108
109
 
110
111
112
...
147
148
149
150
 
151
152
153
154
...
160
161
162
163
 
164
165
166
167
168
 
169
170
171
...
191
192
193
194
 
195
196
197
...
29
30
31
 
32
33
34
35
...
50
51
52
 
53
54
55
56
...
59
60
61
 
62
63
64
65
...
68
69
70
 
71
72
73
74
...
77
78
79
 
80
81
82
83
...
87
88
89
 
90
91
92
93
...
96
97
98
 
99
100
101
102
...
106
107
108
 
109
110
111
112
...
147
148
149
 
150
151
152
153
154
...
160
161
162
 
163
164
165
166
167
 
168
169
170
171
...
191
192
193
 
194
195
196
197
0
@@ -29,7 +29,7 @@
0
 static void http_field(void *data, const char *field, size_t flen, const char *value, size_t vlen)
0
 {
0
   char *ch, *end;
0
- VALUE req = ((thin_connection_t*) data)->env;
0
+ VALUE req = ((connection_t*) data)->env;
0
   VALUE v = Qnil;
0
   VALUE f = Qnil;
0
 
0
@@ -50,7 +50,7 @@
0
 
0
 static void request_method(void *data, const char *at, size_t length)
0
 {
0
- VALUE req = ((thin_connection_t*) data)->env;
0
+ VALUE req = ((connection_t*) data)->env;
0
   VALUE val = Qnil;
0
 
0
   val = rb_str_new(at, length);
0
@@ -59,7 +59,7 @@
0
 
0
 static void request_uri(void *data, const char *at, size_t length)
0
 {
0
- VALUE req = ((thin_connection_t*) data)->env;
0
+ VALUE req = ((connection_t*) data)->env;
0
   VALUE val = Qnil;
0
 
0
   val = rb_str_new(at, length);
0
@@ -68,7 +68,7 @@
0
 
0
 static void fragment(void *data, const char *at, size_t length)
0
 {
0
- VALUE req = ((thin_connection_t*) data)->env;
0
+ VALUE req = ((connection_t*) data)->env;
0
   VALUE val = Qnil;
0
 
0
   val = rb_str_new(at, length);
0
@@ -77,7 +77,7 @@
0
 
0
 static void request_path(void *data, const char *at, size_t length)
0
 {
0
- VALUE req = ((thin_connection_t*) data)->env;
0
+ VALUE req = ((connection_t*) data)->env;
0
   VALUE val = Qnil;
0
 
0
   val = rb_str_new(at, length);
0
@@ -87,7 +87,7 @@
0
 
0
 static void query_string(void *data, const char *at, size_t length)
0
 {
0
- VALUE req = ((thin_connection_t*) data)->env;
0
+ VALUE req = ((connection_t*) data)->env;
0
   VALUE val = Qnil;
0
 
0
   val = rb_str_new(at, length);
0
@@ -96,7 +96,7 @@
0
 
0
 static void http_version(void *data, const char *at, size_t length)
0
 {
0
- VALUE req = ((thin_connection_t*) data)->env;
0
+ VALUE req = ((connection_t*) data)->env;
0
   VALUE val = rb_str_new(at, length);
0
   rb_hash_aset(req, global_http_version, val);
0
 }
0
@@ -106,7 +106,7 @@
0
 
0
 static void header_done(void *data, const char *at, size_t length)
0
 {
0
- thin_connection_t *connection = (thin_connection_t*) data;
0
+ connection_t *connection = (connection_t*) data;
0
   VALUE env = connection->env;
0
   VALUE temp = Qnil;
0
   VALUE ctype = Qnil;
0
@@ -147,7 +147,7 @@
0
 
0
 static void content_length(void *data, const char *at, size_t length)
0
 {
0
- thin_connection_t *connection = (thin_connection_t*)(data);
0
+ connection_t *connection = (connection_t*)(data);
0
   int i, mult;
0
   
0
   connection->content_length = 0;
0
0
@@ -160,12 +160,12 @@
0
 
0
 static void content_type(void *data, const char *at, size_t length)
0
 {
0
- VALUE req = ((thin_connection_t*) data)->env;
0
+ VALUE req = ((connection_t*) data)->env;
0
   VALUE val = rb_str_new(at, length);
0
   rb_hash_aset(req, global_content_type, val);
0
 }
0
 
0
-void thin_parser_callbacks_init()
0
+void parser_callbacks_init()
0
 {
0
   DEF_GLOBAL(empty, "");
0
   DEF_GLOBAL(http_prefix, "HTTP_");
0
@@ -191,7 +191,7 @@
0
   DEF_GLOBAL(path_info, "PATH_INFO");
0
 }
0
 
0
-void thin_setup_parser_callbacks(thin_connection_t *connection)
0
+void parser_callbacks_setup(connection_t *connection)
0
 {
0
   http_parser_init(&(connection->parser));
0
   connection->parser.data = connection;