Browse files

ap_mrb_write_request created.

mod_mruby.c modified
ap_mrb_request.h modified
  • Loading branch information...
1 parent 2a06186 commit e5b92e1395de7940ff30d832370778dcbab3e59e @tsuzakiyo tsuzakiyo committed May 3, 2012
Showing with 35 additions and 0 deletions.
  1. +34 −0 ap_mrb_request.h
  2. +1 −0 mod_mruby.c
View
34 ap_mrb_request.h
@@ -1,7 +1,11 @@
+#include <string.h>
+#include "mruby/string.h"
+
request_rec *mrb_request_rec_state = NULL;
static int ap_mrb_push_request(request_rec *r);
request_rec *ap_mrb_get_request();
+mrb_value ap_mrb_request(mrb_state *mrb, mrb_value str);
static int ap_mrb_push_request(request_rec *r)
@@ -16,3 +20,33 @@ request_rec *ap_mrb_get_request()
return mrb_request_rec_state;
}
+mrb_value ap_mrb_write_request(mrb_state *mrb, mrb_value str)
+{
+
+ struct RProc *b;
+ mrb_value argc, *argv;
+ char *member, *value;
+ request_rec *r = ap_mrb_get_request();
+
+ mrb_get_args(mrb, "b*", &b, &argv, &argc);
+ if (mrb_fixnum(argc) != 2) {
+ ap_log_error(APLOG_MARK
+ , APLOG_WARNING
+ , 0
+ , NULL
+ , "%s ERROR %s: argument is not 2"
+ , MODULE_NAME
+ , __func__
+ );
+ return str;
+ }
+
+ member = RSTRING_PTR(argv[0]);
+ value = RSTRING_PTR(argv[1]);
+
+ if (strcmp(member, "filename") == 0)
+ r->filename = apr_pstrdup(r->pool, value);
+
+ return str;
+}
+
View
1 mod_mruby.c
@@ -375,6 +375,7 @@ static int ap_mruby_class_init(mrb_state *mrb)
mrb_define_class_method(mrb, class, "rputs", ap_mrb_rputs, ARGS_ANY());
mrb_define_class_method(mrb, class, "errlogger", ap_mrb_errlogger, ARGS_ANY());
mrb_define_class_method(mrb, class, "syslogger", ap_mrb_syslogger, ARGS_ANY());
+ mrb_define_class_method(mrb, class, "write_request", ap_mrb_write_request, ARGS_ANY());
return OK;

2 comments on commit e5b92e1

@matsumoto-r
Owner

Great!

@tsuzakiyo

Thanks!

Please sign in to comment.