0
@@ -63,31 +63,12 @@ VALUE env_field(const char *field, int length)
0
-VALUE client_env(ebb_client *_client)
0
- VALUE hash = rb_hash_new();
0
- /* This client->env_fields, client->env_value structure is pretty hacky
0
- * and a bit hard to follow. Look at the #defines at the top of ebb.c to
0
- * see what they are doing. Basically it's a list of (ptr,length) pairs
0
- * for both a field and value
0
- for(i=0; i < _client->env_size; i++) {
0
- rb_hash_aset(hash, env_field(_client->env_fields[i], _client->env_field_lengths[i])
0
- , rb_str_new(_client->env_values[i], _client->env_value_lengths[i])
0
- rb_hash_aset(hash, global_path_info, rb_hash_aref(hash, global_request_path));
0
VALUE client_new(ebb_client *_client)
0
VALUE client = Data_Wrap_Struct(cClient, 0, 0, _client);
0
_client->data = (void*)client;
0
// if(_client->upload_file_filename)
0
// rb_iv_set(client, "@upload_filename", rb_str_new2(_client->upload_file_filename));
0
- rb_iv_set(client, "@ebb_env", client_env(_client));
0
@@ -110,7 +91,7 @@ VALUE server_alloc(VALUE self)
0
-VALUE server_init(VALUE server)
0
+VALUE server_initialize(VALUE x, VALUE server)
0
struct ev_loop *loop = ev_default_loop (0);
0
@@ -121,7 +102,7 @@ VALUE server_init(VALUE server)
0
-VALUE server_listen_on_port(VALUE server, VALUE port)
0
+VALUE server_listen_on_port(VALUE x, VALUE server, VALUE port)
0
Data_Get_Struct(server, ebb_server, _server);
0
@@ -130,7 +111,7 @@ VALUE server_listen_on_port(VALUE server, VALUE port)
0
-VALUE server_listen_on_socket(VALUE server, VALUE socketpath)
0
+VALUE server_listen_on_socket(VALUE x, VALUE server, VALUE socketpath)
0
Data_Get_Struct(server, ebb_server, _server);
0
@@ -143,7 +124,7 @@ static void
0
oneshot_timeout (struct ev_loop *loop, struct ev_timer *w, int revents) {;}
0
-VALUE server_process_connections(VALUE server)
0
+VALUE server_process_connections(VALUE x, VALUE server)
0
@@ -167,7 +148,7 @@ VALUE server_process_connections(VALUE server)
0
-VALUE server_unlisten(VALUE server)
0
+VALUE server_unlisten(VALUE x, VALUE server)
0
Data_Get_Struct(server, ebb_server, _server);
0
@@ -175,34 +156,47 @@ VALUE server_unlisten(VALUE server)
0
-VALUE client_write(VALUE client, VALUE string)
0
+VALUE client_env(VALUE x, VALUE client)
0
+ VALUE hash = rb_hash_new();
0
Data_Get_Struct(client, ebb_client, _client);
0
- ebb_client_write(_client, RSTRING_PTR(string), RSTRING_LEN(string));
0
+ /* This client->env_fields, client->env_value structure is pretty hacky
0
+ * and a bit hard to follow. Look at the #defines at the top of ebb.c to
0
+ * see what they are doing. Basically it's a list of (ptr,length) pairs
0
+ * for both a field and value
0
+ for(i=0; i < _client->env_size; i++) {
0
+ rb_hash_aset(hash, env_field(_client->env_fields[i], _client->env_field_lengths[i])
0
+ , rb_str_new(_client->env_values[i], _client->env_value_lengths[i])
0
+ rb_hash_aset(hash, global_path_info, rb_hash_aref(hash, global_request_path));
0
-VALUE client_finished(VALUE client)
0
+VALUE client_write(VALUE x, VALUE client, VALUE string)
0
Data_Get_Struct(client, ebb_client, _client);
0
- ebb_client_finished(_client);
0
+ ebb_client_write(_client, RSTRING_PTR(string), RSTRING_LEN(string));
0
-VALUE client_close(VALUE client)
0
+VALUE client_finished(VALUE x, VALUE client)
0
Data_Get_Struct(client, ebb_client, _client);
0
- ebb_client_close(_client);
0
+ ebb_client_finished(_client);
0
-VALUE client_read_input(VALUE client, VALUE size)
0
+VALUE client_read_input(VALUE x, VALUE client, VALUE size)
0
@@ -229,13 +223,11 @@ VALUE client_read_input(VALUE client, VALUE size)
0
-VALUE client_init(VALUE self, VALUE something) {return self;}
0
VALUE mEbb = rb_define_module("Ebb");
0
- cServer = rb_define_class_under(mEbb, "Server", rb_cObject);
0
- cClient = rb_define_class_under(mEbb, "Client", rb_cObject);
0
+ VALUE mFFI = rb_define_module_under(mEbb, "FFI");
0
/** Defines global strings in the init method. */
0
#define DEF_GLOBAL(N, val) global_##N = rb_obj_freeze(rb_str_new2(val)); rb_global_variable(&global_##N)
0
@@ -253,18 +245,18 @@ void Init_ebb_ext()
0
DEF_GLOBAL(content_length, "HTTP_CONTENT_LENGTH");
0
DEF_GLOBAL(http_host, "HTTP_HOST");
0
+ cServer = rb_define_class_under(mEbb, "Server", rb_cObject);
0
rb_define_alloc_func(cServer, server_alloc);
0
- rb_define_method(cServer, "init", server_init, 0);
0
- rb_define_method(cServer, "process_connections", server_process_connections, 0);
0
- rb_define_method(cServer, "listen_on_port", server_listen_on_port, 1);
0
- rb_define_method(cServer, "listen_on_socket", server_listen_on_socket, 1);
0
- rb_define_method(cServer, "unlisten", server_unlisten, 0);
0
- rb_define_method(cClient, "initialize", client_init, 1);
0
- rb_define_method(cClient, "write", client_write, 1);
0
- rb_define_method(cClient, "read_input", client_read_input, 1);
0
- rb_define_method(cClient, "finished", client_finished, 0);
0
- rb_define_method(cClient, "read_input", client_read_input, 1);
0
+ rb_define_singleton_method(mFFI, "server_initialize", server_initialize, 1);
0
+ rb_define_singleton_method(mFFI, "server_process_connections", server_process_connections, 1);
0
+ rb_define_singleton_method(mFFI, "server_listen_on_port", server_listen_on_port, 2);
0
+ rb_define_singleton_method(mFFI, "server_listen_on_socket", server_listen_on_socket, 2);
0
+ rb_define_singleton_method(mFFI, "server_unlisten", server_unlisten, 1);
0
+ cClient = rb_define_class_under(mEbb, "Client", rb_cObject);
0
+ rb_define_singleton_method(mFFI, "client_write", client_write, 2);
0
+ rb_define_singleton_method(mFFI, "client_read_input", client_read_input, 2);
0
+ rb_define_singleton_method(mFFI, "client_finished", client_finished, 1);
0
+ rb_define_singleton_method(mFFI, "client_env", client_env, 1);
Comments
No one has commented yet.