Re: Problems starting Apache 2.2 with mod_ruby
Shugo Maeda <[email protected]> Wed, 01 Feb 2006 01:59:47 +0900
| Newsgroups | gmane.comp.apache.mod-ruby |
|---|---|
| Message-ID | <[email protected]> |
Hi, Sorry to be late, and thanks for your efforts. At 01/10/06 20:37:53 (JST), Michael Sullivan <[email protected]> wrote: > 1. I edited the file "/usr/local/lib/ruby/1.8/sparc-solaris2.9/config.h" > to comment out the offending line: > > /* #define _FILE_OFFSET_BITS 64 */ > > This doesn't appear to break anything since it is defined in the system > header files. I suspect the leading "_" is a typo within the Ruby 1.8.4 > distribution since none of the other macros have the leading character. It's not typo. _FILE_OFFSET_BITS is necessary if you want to handle large files. If you configure ruby with --disble-largefile, _FILE_OFFSET_BITS is not defined. > 2. I started with the latest mod_ruby svn source. There is a file in > the tarball called "diff-file.list" This contains an svn diff against > the base source and the changed files in the mod_ruby tree. This may > give some hints, but I have scoured it and since there are no other > errors or warning anywhere else, I feel fairly confident that my > function translations are correct. They are all nested within: > > #ifdef APACHE2 > apr_new-function_call(....); > #else > ap_old_function(...); > #endif I prefer to define macros in mod_ruby.h. #ifdef APACHE2 #define ap_old_function(x) apr_new_function(....) #endif or the following may be better at this time: #ifndef APACHE2 #define apr_new_function(x) ap_old_function(....) #endif > Here's the warning an Apache startup error: > > gcc -g -O2 -fPIC -Wall -I. -I/usr/local/lib/ruby/1.8/sparc-solaris2.9 > -I/usr/local/apache2/include -c mod_ruby.c > mod_ruby.c:151: warning: missing braces around initializer > mod_ruby.c:151: warning: (near initialization for `ruby_cmds[0].func') command_rec seems to be modified in Apache 2.2. command_rec.func is now union, so ruby_cmds in the SVN HEAD doesn't work with Apache2.2. Can you try the attached patch (against the SVN HEAD). Thanks a lot, Shugo
apache2.2.diff
(text/plain, 61.4 KB)
Index: apache_multipart_buffer.c
===================================================================
--- apache_multipart_buffer.c (revision 103)
+++ apache_multipart_buffer.c (working copy)
@@ -172,17 +172,30 @@
multipart_buffer *multipart_buffer_new(char *boundary, long length, request_rec *r)
{
multipart_buffer *self = (multipart_buffer *)
+#ifdef APACHE2
+ apr_pcalloc(r->pool, sizeof(multipart_buffer));
+#else
ap_pcalloc(r->pool, sizeof(multipart_buffer));
+#endif
int minsize = strlen(boundary)+6;
if(minsize < FILLUNIT) minsize = FILLUNIT;
self->r = r;
+#ifdef APACHE2
+ self->buffer = (char *) apr_pcalloc(r->pool, minsize+1);
+#else
self->buffer = (char *) ap_pcalloc(r->pool, minsize+1);
+#endif
self->bufsize = minsize;
self->request_length = length;
+#ifdef APACHE2
+ self->boundary = apr_pstrcat(r->pool, "--", boundary, NULL);
+ self->boundary_next = apr_pstrcat(r->pool, "\n", self->boundary, NULL);
+#else
self->boundary = ap_pstrcat(r->pool, "--", boundary, NULL);
self->boundary_next = ap_pstrcat(r->pool, "\n", self->boundary, NULL);
+#endif
self->buf_begin = self->buffer;
self->bytes_in_buffer = 0;
@@ -199,7 +212,11 @@
if(!find_boundary(self, self->boundary)) return NULL;
/* get lines of text, or CRLF_CRLF */
+#ifdef APACHE2
+ tab = apr_table_make(self->r->pool, 10);
+#else
tab = ap_make_table(self->r->pool, 10);
+#endif
while( (line = get_line(self)) && strlen(line) > 0 ) {
/* add header to table */
char *key = line;
@@ -207,7 +224,11 @@
if(value) {
*value = 0;
+#ifdef APACHE2
+ do { value++; } while(apr_isspace(*value));
+#else
do { value++; } while(ap_isspace(*value));
+#endif
#ifdef DEBUG
ap_log_rerror(MPB_ERROR,
@@ -215,7 +236,11 @@
key, value);
#endif
+#ifdef APACHE2
+ apr_table_add(tab, key, value);
+#else
ap_table_add(tab, key, value);
+#endif
}
else {
#ifdef DEBUG
@@ -223,7 +248,11 @@
"multipart_buffer_headers: '%s' = ''", key);
#endif
+#ifdef APACHE2
+ apr_table_add(tab, key, "");
+#else
ap_table_add(tab, key, "");
+#endif
}
}
@@ -277,7 +306,11 @@
char buf[FILLUNIT], *out = "";
while(multipart_buffer_read(self, buf, sizeof(buf)))
+#ifdef APACHE2
+ out = apr_pstrcat(self->r->pool, out, buf, NULL);
+#else
out = ap_pstrcat(self->r->pool, out, buf, NULL);
+#endif
#ifdef DEBUG
ap_log_rerror(MPB_ERROR, "multipart_buffer_read_body: '%s'", out);
Index: mod_ruby.c
===================================================================
--- mod_ruby.c (revision 103)
+++ mod_ruby.c (working copy)
@@ -148,60 +148,69 @@
#endif
static int ruby_post_read_request_handler(request_rec *r);
-static const command_rec ruby_cmds[] =
-{
- {"RubyKanjiCode", ruby_cmd_kanji_code, NULL, OR_ALL, TAKE1,
- "set $KCODE"},
- {"RubyAddPath", ruby_cmd_add_path, NULL, OR_ALL, ITERATE,
- "add path to $:"},
- {"RubyRequire", ruby_cmd_require, NULL, OR_ALL, ITERATE,
- "ruby script name, pulled in via require"},
- {"RubyPassEnv", ruby_cmd_pass_env, NULL, RSRC_CONF, ITERATE,
- "pass environment variables to ENV"},
- {"RubySetEnv", ruby_cmd_set_env, NULL, OR_ALL, TAKE2,
- "Ruby ENV key and value" },
- {"RubyTimeOut", ruby_cmd_timeout, NULL, RSRC_CONF, TAKE1,
- "time to wait execution of ruby script"},
- {"RubySafeLevel", ruby_cmd_safe_level, NULL, OR_ALL, TAKE1,
- "set default $SAFE"},
- {"RubyOutputMode", ruby_cmd_output_mode, NULL, OR_ALL, TAKE1,
- "set output mode (nosync|sync|syncheader)"},
- {"RubyRestrictDirectives", ruby_cmd_restrict_directives, NULL,
- RSRC_CONF, FLAG,
- "whether Ruby* directives are restricted from .htaccess"},
- {"RubyOption", ruby_cmd_option, NULL, OR_ALL, TAKE2,
- "set option for application"},
- {"RubyHandler", ruby_cmd_handler, NULL, OR_ALL, TAKE1,
- "set ruby handler object"},
- {"RubyTransHandler", ruby_cmd_trans_handler, NULL, OR_ALL, TAKE1,
- "set translation handler object"},
- {"RubyAuthenHandler", ruby_cmd_authen_handler, NULL, OR_ALL, TAKE1,
- "set authentication handler object"},
- {"RubyAuthzHandler", ruby_cmd_authz_handler, NULL, OR_ALL, TAKE1,
- "set authorization handler object"},
- {"RubyAccessHandler", ruby_cmd_access_handler, NULL, OR_ALL, TAKE1,
- "set access checker object"},
- {"RubyTypeHandler", ruby_cmd_type_handler, NULL, OR_ALL, TAKE1,
- "set type checker object"},
- {"RubyFixupHandler", ruby_cmd_fixup_handler, NULL, OR_ALL, TAKE1,
- "set fixup handler object"},
- {"RubyLogHandler", ruby_cmd_log_handler, NULL, OR_ALL, TAKE1,
- "set log handler object"},
- {"RubyHeaderParserHandler", ruby_cmd_header_parser_handler,
- NULL, OR_ALL, TAKE1,
- "set header parser object"},
- {"RubyPostReadRequestHandler", ruby_cmd_post_read_request_handler,
- NULL, RSRC_CONF, TAKE1,
- "set post-read-request handler object"},
- {"RubyInitHandler", ruby_cmd_init_handler,
- NULL, OR_ALL, TAKE1,
- "set init handler object"},
- {"RubyCleanupHandler", ruby_cmd_cleanup_handler,
- NULL, OR_ALL, TAKE1,
- "set cleanup handler object"},
- {"RubyChildInitHandler", ruby_cmd_child_init_handler,
- NULL, RSRC_CONF, TAKE1,
- "set child init handler object"},
+#ifndef AP_INIT_TAKE1
+# define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
+ { directive, func, mconfig, where, TAKE1, help }
+# define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
+ { directive, func, mconfig, where, TAKE2, help }
+# define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
+ { directive, func, mconfig, where, ITERATE, help }
+# define AP_INIT_FLAG(directive, func, mconfig, where, help) \
+ { directive, func, mconfig, where, FLAG, help }
+#endif
+
+static const command_rec ruby_cmds[] = {
+ AP_INIT_TAKE1("RubyKanjiCode", (const char *(*)())ruby_cmd_kanji_code, NULL, OR_ALL,
+ "set $KCODE"),
+ AP_INIT_ITERATE("RubyAddPath", ruby_cmd_add_path, NULL, OR_ALL,
+ "add path to $:"),
+ AP_INIT_ITERATE("RubyRequire", ruby_cmd_require, NULL, OR_ALL,
+ "ruby script name, pulled in via require"),
+ AP_INIT_ITERATE("RubyPassEnv", ruby_cmd_pass_env, NULL, RSRC_CONF,
+ "pass environment variables to ENV"),
+ AP_INIT_TAKE2("RubySetEnv", ruby_cmd_set_env, NULL, OR_ALL,
+ "Ruby ENV key and value" ),
+ AP_INIT_TAKE1("RubyTimeOut", ruby_cmd_timeout, NULL, RSRC_CONF,
+ "time to wait execution of ruby script"),
+ AP_INIT_TAKE1("RubySafeLevel", ruby_cmd_safe_level, NULL, OR_ALL,
+ "set default $SAFE"),
+ AP_INIT_TAKE1("RubyOutputMode", ruby_cmd_output_mode, NULL, OR_ALL,
+ "set output mode (nosync|sync|syncheader)"),
+ AP_INIT_FLAG("RubyRestrictDirectives", ruby_cmd_restrict_directives, NULL,
+ RSRC_CONF, "whether Ruby* directives are restricted from .htaccess"),
+ AP_INIT_TAKE2("RubyOption", ruby_cmd_option, NULL, OR_ALL,
+ "set option for application"),
+ AP_INIT_TAKE1("RubyHandler", ruby_cmd_handler, NULL, OR_ALL,
+ "set ruby handler object"),
+ AP_INIT_TAKE1("RubyTransHandler", ruby_cmd_trans_handler, NULL, OR_ALL,
+ "set translation handler object"),
+ AP_INIT_TAKE1("RubyAuthenHandler", ruby_cmd_authen_handler, NULL, OR_ALL,
+ "set authentication handler object"),
+ AP_INIT_TAKE1("RubyAuthzHandler", ruby_cmd_authz_handler, NULL, OR_ALL,
+ "set authorization handler object"),
+ AP_INIT_TAKE1("RubyAccessHandler", ruby_cmd_access_handler, NULL, OR_ALL,
+ "set access checker object"),
+ AP_INIT_TAKE1("RubyTypeHandler", ruby_cmd_type_handler, NULL, OR_ALL,
+ "set type checker object"),
+ AP_INIT_TAKE1("RubyFixupHandler", ruby_cmd_fixup_handler, NULL, OR_ALL,
+ "set fixup handler object"),
+ AP_INIT_TAKE1("RubyLogHandler", ruby_cmd_log_handler, NULL, OR_ALL,
+ "set log handler object"),
+ AP_INIT_TAKE1("RubyHeaderParserHandler", ruby_cmd_header_parser_handler,
+ NULL, OR_ALL,
+ "set header parser object"),
+ AP_INIT_TAKE1("RubyPostReadRequestHandler", ruby_cmd_post_read_request_handler,
+ NULL, RSRC_CONF,
+ "set post-read-request handler object"),
+ AP_INIT_TAKE1("RubyInitHandler", ruby_cmd_init_handler,
+ NULL, OR_ALL,
+ "set init handler object"),
+ AP_INIT_TAKE1("RubyCleanupHandler", ruby_cmd_cleanup_handler,
+ NULL, OR_ALL,
+ "set cleanup handler object"),
+ AP_INIT_TAKE1("RubyChildInitHandler", ruby_cmd_child_init_handler,
+ NULL, RSRC_CONF,
+ "set child init handler object"),
{NULL}
};
@@ -553,7 +562,7 @@
}
}
-static int ruby_require_directly(char *filename,
+static int ruby_require_directly(const char *filename,
ruby_server_config *sconf,
ruby_dir_config *dconf)
{
@@ -830,7 +839,11 @@
static request_rec *fake_request_rec(server_rec *s, pool *p, char *hook)
{
+#ifdef APACHE2
+ request_rec *r = (request_rec *) apr_pcalloc(p, sizeof(request_rec));
+#else /* Apache 1.x */
request_rec *r = (request_rec *) ap_pcalloc(p, sizeof(request_rec));
+#endif
r->pool = p;
r->server = s;
r->per_dir_config = NULL;
@@ -900,7 +913,11 @@
#if APR_HAS_THREADS
}
#endif
+#ifdef APACHE2
+ apr_pool_cleanup_register(p, NULL, ruby_child_cleanup, apr_pool_cleanup_null);
+#else
ap_register_cleanup(p, NULL, ruby_child_cleanup, ap_null_cleanup);
+#endif
}
r = fake_request_rec(s, p, "RubyChildInitHandler");
@@ -912,14 +929,22 @@
static void mod_ruby_clearenv(pool *p)
{
char **env;
+#ifdef APACHE2
+ array_header *names = apr_array_make(p, 1, sizeof(char*));
+#else
array_header *names = ap_make_array(p, 1, sizeof(char*));
+#endif
int i;
env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
if (s) {
+#ifdef APACHE2
+ *(char **) apr_array_push(names) = apr_pstrndup(p, *env, s - *env);
+#else
*(char **) ap_push_array(names) = ap_pstrndup(p, *env, s - *env);
+#endif
}
env++;
}
@@ -949,7 +974,11 @@
table_entry *env;
int i;
+#ifdef APACHE2
+ env_arr = apr_table_elts(tbl);
+#else
env_arr = ap_table_elts(tbl);
+#endif
env = (table_entry *) env_arr->elts;
for (i = 0; i < env_arr->nelts; i++) {
if (env[i].key == NULL)
@@ -1060,13 +1089,23 @@
table *result;
env = GET_ENVIRON(environ);
+#ifdef APACHE2
+ result = apr_table_make(p, 1);
+#else
result = ap_make_table(p, 1);
+#endif
while (*env) {
char *s = strchr(*env, '=');
if (s) {
+#ifdef APACHE2
+ k = apr_pstrndup(p, *env, s - *env);
+ v = apr_pstrdup(p, s + 1);
+ apr_table_set(result, k, v);
+#else
k = ap_pstrndup(p, *env, s - *env);
v = ap_pstrdup(p, s + 1);
ap_table_set(result, k, v);
+#endif
}
env++;
}
@@ -1080,7 +1119,11 @@
int i;
mod_ruby_clearenv(p);
+#ifdef APACHE2
+ hdrs_arr = apr_table_elts(env);
+#else
hdrs_arr = ap_table_elts(env);
+#endif
hdrs = (table_entry *) hdrs_arr->elts;
for (i = 0; i < hdrs_arr->nelts; i++) {
if (hdrs[i].key == NULL)
@@ -1096,7 +1139,11 @@
ruby_dir_config *dconf;
if (r->request_config) {
+#ifdef APACHE2
+ rconf = apr_palloc(r->pool, sizeof(ruby_request_config));
+#else
rconf = ap_palloc(r->pool, sizeof(ruby_request_config));
+#endif
rconf->saved_env = save_env(r->pool);
rconf->request_object = Qnil;
ap_set_module_config(r->request_config, &ruby_module, rconf);
@@ -1260,7 +1307,11 @@
if (handlers_arr == NULL)
return DECLINED;
+#ifdef APACHE2
+ arg = apr_palloc(r->pool, sizeof(handler_internal_arg_t));
+#else
arg = ap_palloc(r->pool, sizeof(handler_internal_arg_t));
+#endif
arg->r = r;
arg->handlers_arr = handlers_arr;
arg->mid = mid;
@@ -1407,13 +1458,22 @@
ruby_dir_config *dconf = get_dir_config(r);
int retval;
+#ifdef APACHE2
+ apr_pool_cleanup_register(r->pool, (void *) r, ruby_cleanup_handler,
+ apr_pool_cleanup_null);
+#else
ap_register_cleanup(r->pool, (void *) r, ruby_cleanup_handler,
ap_null_cleanup);
+#endif
if (dconf->ruby_init_handler) {
retval = ruby_handler(r, dconf->ruby_init_handler,
rb_intern("init"), 1, 0);
+#ifdef APACHE2
+ apr_table_set(r->notes, "ruby_init_ran", "true");
+#else
ap_table_set(r->notes, "ruby_init_ran", "true");
+#endif
if (retval != OK && retval != DECLINED)
return retval;
}
Index: mod_ruby.h
===================================================================
--- mod_ruby.h (revision 103)
+++ mod_ruby.h (working copy)
@@ -168,7 +168,7 @@
} ruby_dir_config;
typedef struct {
- char *filename;
+ const char *filename;
ruby_server_config *server_config;
ruby_dir_config *dir_config;
} ruby_library_context;
Index: apache_request.c
===================================================================
--- apache_request.c (revision 103)
+++ apache_request.c (working copy)
@@ -45,7 +45,11 @@
return HTTP_REQUEST_ENTITY_TOO_LARGE;
}
+#ifdef APACHE2
+ *rbuf = apr_pcalloc(r->pool, length + 1);
+#else
*rbuf = ap_pcalloc(r->pool, length + 1);
+#endif
ap_hard_timeout("[libapreq] util_read", r);
@@ -74,7 +78,11 @@
if (r->path_info && *r->path_info) {
int path_info_start = ap_find_path_info(r->uri, r->path_info);
+#ifdef APACHE2
+ tmp = apr_pstrndup(r->pool, r->uri, path_info_start);
+#else
tmp = ap_pstrndup(r->pool, r->uri, path_info_start);
+#endif
}
else {
tmp = r->uri;
@@ -91,21 +99,37 @@
const char *ApacheRequest_param(ApacheRequest *req, const char *key)
{
ApacheRequest_parse(req);
+#ifdef APACHE2
+ return apr_table_get(req->parms, key);
+#else
return ap_table_get(req->parms, key);
+#endif
}
static int make_params(void *data, const char *key, const char *val)
{
array_header *arr = (array_header *)data;
+#ifdef APACHE2
+ *(char **)apr_array_push(arr) = (char *)val;
+#else
*(char **)ap_push_array(arr) = (char *)val;
+#endif
return 1;
}
array_header *ApacheRequest_params(ApacheRequest *req, const char *key)
{
+#ifdef APACHE2
+ array_header *values = apr_array_make(req->r->pool, 4, sizeof(char *));
+#else
array_header *values = ap_make_array(req->r->pool, 4, sizeof(char *));
+#endif
ApacheRequest_parse(req);
+#ifdef APACHE2
+ apr_table_do(make_params, (void*)values, req->parms, key, NULL);
+#else
ap_table_do(make_params, (void*)values, req->parms, key, NULL);
+#endif
return values;
}
@@ -116,11 +140,19 @@
int i;
for (i=0; i<values->nelts; i++) {
+#ifdef APACHE2
+ retval = apr_pstrcat(req->r->pool,
+ retval ? retval : "",
+ ((char **)values->elts)[i],
+ (i == (values->nelts - 1)) ? NULL : ", ",
+ NULL);
+#else
retval = ap_pstrcat(req->r->pool,
retval ? retval : "",
((char **)values->elts)[i],
(i == (values->nelts - 1)) ? NULL : ", ",
NULL);
+#endif
}
return retval;
@@ -128,7 +160,11 @@
table *ApacheRequest_query_params(ApacheRequest *req, ap_pool *p)
{
+#ifdef APACHE2
+ array_header *a = apr_palloc(p, sizeof *a);
+#else
array_header *a = ap_palloc(p, sizeof *a);
+#endif
array_header *b = (array_header *)req->parms;
a->elts = b->elts;
@@ -141,7 +177,11 @@
table *ApacheRequest_post_params(ApacheRequest *req, ap_pool *p)
{
+#ifdef APACHE2
+ array_header *a = apr_palloc(p, sizeof *a);
+#else
array_header *a = ap_palloc(p, sizeof *a);
+#endif
array_header *b = (array_header *)req->parms;
a->elts = (void *)( (table_entry *)b->elts + req->nargs );
@@ -155,7 +195,11 @@
ApacheUpload *ApacheUpload_new(ApacheRequest *req)
{
ApacheUpload *upload = (ApacheUpload *)
+#ifdef APACHE2
+ apr_pcalloc(req->r->pool, sizeof(ApacheUpload));
+#else
ap_pcalloc(req->r->pool, sizeof(ApacheUpload));
+#endif
upload->next = NULL;
upload->name = NULL;
@@ -183,10 +227,16 @@
ApacheRequest *ApacheRequest_new(request_rec *r)
{
ApacheRequest *req = (ApacheRequest *)
- ap_pcalloc(r->pool, sizeof(ApacheRequest));
+#ifdef APACHE2
+ apr_pcalloc(r->pool, sizeof(ApacheRequest));
+ req->parms = apr_table_make(r->pool, DEFAULT_TABLE_NELTS);
+#else
+ ap_pcalloc(r->pool, sizeof(ApacheRequest));
+
+ req->parms = ap_make_table(r->pool, DEFAULT_TABLE_NELTS);
+#endif
req->status = OK;
- req->parms = ap_make_table(r->pool, DEFAULT_TABLE_NELTS);
req->upload = NULL;
req->post_max = -1;
req->disable_uploads = 0;
@@ -225,8 +275,13 @@
long x = 0;
int i = 0;
while (i < 4 ) {
+#ifdef APACHE2
+ if ( apr_isxdigit(str[i]) != 0 ) {
+ if( apr_isdigit(str[i]) != 0 ) {
+#else
if ( ap_isxdigit(str[i]) != 0 ) {
if( ap_isdigit(str[i]) != 0 ) {
+#endif
x = x * 16 + str[i] - '0';
}
else {
@@ -293,7 +348,11 @@
}
}
else {
+#ifdef APACHE2
+ if (!apr_isxdigit(url[y + 1]) || !apr_isxdigit(url[y + 2])) {
+#else
if (!ap_isxdigit(url[y + 1]) || !ap_isxdigit(url[y + 2])) {
+#endif
badesc = 1;
url[x] = '%';
}
@@ -329,7 +388,11 @@
++pos;
}
+#ifdef APACHE2
+ res = apr_pstrndup(p, *line, pos - *line);
+#else
res = ap_pstrndup(p, *line, pos - *line);
+#endif
while (ch == ';' || ch == '&') {
++pos;
@@ -354,7 +417,11 @@
ap_unescape_url_u((char*)key);
req_plustospace((char*)val);
ap_unescape_url_u((char*)val);
+#ifdef APACHE2
+ apr_table_add(req->parms, key, val);
+#else
ap_table_add(req->parms, key, val);
+#endif
}
}
@@ -370,7 +437,11 @@
}
if (r->method_number == M_POST) {
+#ifdef APACHE2
+ const char *ct = apr_table_get(r->headers_in, "Content-type");
+#else
const char *ct = ap_table_get(r->headers_in, "Content-type");
+#endif
if (ct && strncaseEQ(ct, DEFAULT_ENCTYPE, DEFAULT_ENCTYPE_LENGTH)) {
result = ApacheRequest_parse_urlencoded(req);
}
@@ -400,7 +471,11 @@
if (r->method_number == M_POST) {
const char *data = NULL, *type;
+#ifdef APACHE2
+ type = apr_table_get(r->headers_in, "Content-Type");
+#else
type = ap_table_get(r->headers_in, "Content-Type");
+#endif
if (!strncaseEQ(type, DEFAULT_ENCTYPE, DEFAULT_ENCTYPE_LENGTH)) {
return DECLINED;
@@ -467,8 +542,13 @@
upload->fp = fp;
upload->tempname = name;
+#ifdef APACHE2
+ apr_pool_cleanup_register(r->pool, (void *)upload,
+ remove_tmpfile, apr_pool_cleanup_null);
+#else
ap_register_cleanup(r->pool, (void *)upload,
remove_tmpfile, ap_null_cleanup);
+#endif
return fp;
}
@@ -477,7 +557,11 @@
{
request_rec *r = req->r;
int rc = OK;
+#ifdef APACHE2
+ const char *ct = apr_table_get(r->headers_in, "Content-Type");
+#else
const char *ct = ap_table_get(r->headers_in, "Content-Type");
+#endif
long length;
char *boundary;
multipart_buffer *mbuff;
@@ -537,13 +621,21 @@
return OK;
}
+#ifdef APACHE2
+ if ((cd = apr_table_get(header, "Content-Disposition"))) {
+#else
if ((cd = ap_table_get(header, "Content-Disposition"))) {
+#endif
const char *pair;
while (*cd && (pair = ap_getword(r->pool, &cd, ';'))) {
const char *key;
+#ifdef APACHE2
+ while (apr_isspace(*cd)) {
+#else
while (ap_isspace(*cd)) {
+#endif
++cd;
}
if (ap_ind(pair, '=')) {
@@ -558,7 +650,11 @@
}
if (!filename) {
char *value = multipart_buffer_read_body(mbuff);
+#ifdef APACHE2
+ apr_table_add(req->parms, param, value);
+#else
ap_table_add(req->parms, param, value);
+#endif
continue;
}
if (!param) continue; /* shouldn't happen, but just in case. */
@@ -568,7 +664,11 @@
return HTTP_FORBIDDEN;
}
+#ifdef APACHE2
+ apr_table_add(req->parms, param, filename);
+#else
ap_table_add(req->parms, param, filename);
+#endif
if (upload) {
upload->next = ApacheUpload_new(req);
@@ -584,8 +684,13 @@
}
upload->info = header;
+#ifdef APACHE2
+ upload->filename = apr_pstrdup(req->r->pool, filename);
+ upload->name = apr_pstrdup(req->r->pool, param);
+#else
upload->filename = ap_pstrdup(req->r->pool, filename);
upload->name = ap_pstrdup(req->r->pool, param);
+#endif
/* mozilla empty-file (missing CRLF) hack */
fill_buffer(mbuff);
@@ -664,7 +769,11 @@
}
/* wtf, ap_isdigit() returns false for '1' !? */
+#ifdef APACHE2
+ while (*time_str && (apr_isdigit(*time_str) || (*time_str == '1'))) {
+#else
while (*time_str && (ap_isdigit(*time_str) || (*time_str == '1'))) {
+#endif
buf[ix++] = *time_str++;
}
buf[ix] = '\0';
@@ -687,16 +796,29 @@
when = expire_calc(time_str);
if (!when) {
+#ifdef APACHE2
+ return apr_pstrdup(p, time_str);
+#else
return ap_pstrdup(p, time_str);
+#endif
}
tms = gmtime(&when);
+#ifdef APACHE2
+ return apr_psprintf(p,
+ "%s, %.2d%c%s%c%.2d %.2d:%.2d:%.2d GMT",
+ apr_day_snames[tms->tm_wday],
+ tms->tm_mday, sep, apr_month_snames[tms->tm_mon], sep,
+ tms->tm_year + 1900,
+ tms->tm_hour, tms->tm_min, tms->tm_sec);
+#else
return ap_psprintf(p,
"%s, %.2d%c%s%c%.2d %.2d:%.2d:%.2d GMT",
ap_day_snames[tms->tm_wday],
tms->tm_mday, sep, ap_month_snames[tms->tm_mon], sep,
tms->tm_year + 1900,
tms->tm_hour, tms->tm_min, tms->tm_sec);
+#endif
}
char *ApacheRequest_expires(ApacheRequest *req, char *time_str)
Index: apache_request.h
===================================================================
--- apache_request.h (revision 103)
+++ apache_request.h (working copy)
@@ -106,8 +106,13 @@
#define ApacheUpload_size(upload) ((upload)->size)
+#ifdef APACHE2
#define ApacheUpload_info(upload, key) \
+apr_table_get((upload)->info, (key))
+#else
+#define ApacheUpload_info(upload, key) \
ap_table_get((upload)->info, (key))
+#endif
#define ApacheUpload_type(upload) \
ApacheUpload_info((upload), "Content-Type")
Index: ruby_config.c
===================================================================
--- ruby_config.c (revision 103)
+++ ruby_config.c (working copy)
@@ -33,19 +33,35 @@
static int default_safe_level = MR_DEFAULT_SAFE_LEVEL;
+#ifdef APACHE2
#define push_handler(p, handler, arg) { \
if ((handler) == NULL) \
+ (handler) = apr_array_make(p, 1, sizeof(const char*)); \
+ *(const char **) apr_array_push(handler) = arg; \
+}
+#else
+#define push_handler(p, handler, arg) { \
+ if ((handler) == NULL) \
(handler) = ap_make_array(p, 1, sizeof(char*)); \
*(char **) ap_push_array(handler) = arg; \
}
+#endif
void *ruby_create_server_config(pool *p, server_rec *s)
{
+#ifdef APACHE2
ruby_server_config *conf =
+ (ruby_server_config *) apr_pcalloc(p, sizeof(ruby_server_config));
+
+ conf->load_path = apr_array_make(p, 1, sizeof(char*));
+ conf->env = apr_table_make(p, 1);
+#else
+ ruby_server_config *conf =
(ruby_server_config *) ap_pcalloc(p, sizeof(ruby_server_config));
conf->load_path = ap_make_array(p, 1, sizeof(char*));
conf->env = ap_make_table(p, 1);
+#endif
conf->timeout = MR_DEFAULT_TIMEOUT;
conf->restrict_directives = MR_DEFAULT_RESTRICT_DIRECTIVES;
conf->ruby_child_init_handler = NULL;
@@ -60,13 +76,22 @@
return add;
if (add == NULL)
return base;
+#ifdef APACHE2
+ return apr_array_append(p, add, base);
+#else
return ap_append_arrays(p, add, base);
+#endif
}
void *ruby_merge_server_config(pool *p, void *basev, void *addv)
{
+#ifdef APACHE2
ruby_server_config *new =
+ (ruby_server_config *) apr_pcalloc(p, sizeof(ruby_server_config));
+#else
+ ruby_server_config *new =
(ruby_server_config *) ap_pcalloc(p, sizeof(ruby_server_config));
+#endif
ruby_server_config *base = (ruby_server_config *) basev;
ruby_server_config *add = (ruby_server_config *) addv;
@@ -77,9 +102,17 @@
new->load_path = add->load_path;
}
else {
+#ifdef APACHE2
+ new->load_path = apr_array_append(p, base->load_path, add->load_path);
+#else
new->load_path = ap_append_arrays(p, base->load_path, add->load_path);
+#endif
}
+#ifdef APACHE2
+ new->env = apr_table_overlay(p, add->env, base->env);
+#else
new->env = ap_overlay_tables(p, add->env, base->env);
+#endif
new->timeout = add->timeout ? add->timeout : base->timeout;
new->restrict_directives = add->restrict_directives ?
add->restrict_directives : base->restrict_directives;
@@ -91,15 +124,28 @@
void *ruby_create_dir_config(pool *p, char *dirname)
{
+#ifdef APACHE2
ruby_dir_config *conf =
+ (ruby_dir_config *) apr_palloc(p, sizeof (ruby_dir_config));
+#else
+ ruby_dir_config *conf =
(ruby_dir_config *) ap_palloc(p, sizeof (ruby_dir_config));
+#endif
conf->kcode = NULL;
+#ifdef APACHE2
+ conf->env = apr_table_make(p, 5);
+#else
conf->env = ap_make_table(p, 5);
+#endif
conf->safe_level = default_safe_level;
conf->output_mode = MR_OUTPUT_DEFAULT;
conf->load_path = NULL;
+#ifdef APACHE2
+ conf->options = apr_table_make(p, 5);
+#else
conf->options = ap_make_table(p, 5);
+#endif
conf->ruby_handler = NULL;
conf->ruby_trans_handler = NULL;
conf->ruby_authen_handler = NULL;
@@ -117,13 +163,22 @@
void *ruby_merge_dir_config(pool *p, void *basev, void *addv)
{
+#ifdef APACHE2
ruby_dir_config *new =
+ (ruby_dir_config *) apr_pcalloc(p, sizeof(ruby_dir_config));
+#else
+ ruby_dir_config *new =
(ruby_dir_config *) ap_pcalloc(p, sizeof(ruby_dir_config));
+#endif
ruby_dir_config *base = (ruby_dir_config *) basev;
ruby_dir_config *add = (ruby_dir_config *) addv;
new->kcode = add->kcode ? add->kcode : base->kcode;
+#ifdef APACHE2
+ new->env = apr_table_overlay(p, add->env, base->env);
+#else
new->env = ap_overlay_tables(p, add->env, base->env);
+#endif
if (add->safe_level >= base->safe_level) {
new->safe_level = add->safe_level;
}
@@ -140,10 +195,18 @@
new->load_path = add->load_path;
}
else {
+#ifdef APACHE2
+ new->load_path = apr_array_append(p, base->load_path, add->load_path);
+#else
new->load_path = ap_append_arrays(p, base->load_path, add->load_path);
+#endif
}
+#ifdef APACHE2
+ new->options = apr_table_overlay(p, add->options, base->options);
+#else
new->options = ap_overlay_tables(p, add->options, base->options);
+#endif
new->ruby_handler =
merge_handlers(p, base->ruby_handler, add->ruby_handler);
@@ -201,43 +264,68 @@
return 1;
}
+#ifdef APACHE2
#define check_restrict_directives(cmd, dconf) { \
if (is_restrict_directives((cmd)->server) && \
is_from_htaccess((cmd), (dconf))) { \
+ return apr_psprintf(cmd->pool, \
+ "RubyRestrictDirectives is enabled, " \
+ "%s is not available in .htaccess", \
+ cmd->cmd->name); \
+ } \
+}
+#else
+#define check_restrict_directives(cmd, dconf) { \
+ if (is_restrict_directives((cmd)->server) && \
+ is_from_htaccess((cmd), (dconf))) { \
return ap_psprintf(cmd->pool, \
"RubyRestrictDirectives is enabled, " \
"%s is not available in .htaccess", \
cmd->cmd->name); \
} \
}
+#endif
-const char *ruby_cmd_kanji_code(cmd_parms *cmd, ruby_dir_config *conf,
- char *arg)
+const char *ruby_cmd_kanji_code(cmd_parms *cmd, void *conf,
+ const char *arg)
{
check_restrict_directives(cmd, conf)
- conf->kcode = ap_pstrdup(cmd->pool, arg);
+#ifdef APACHE2
+ ((ruby_dir_config *) conf)->kcode = apr_pstrdup(cmd->pool, arg);
+#else
+ ((ruby_dir_config *) conf)->kcode = ap_pstrdup(cmd->pool, arg);
+#endif
return NULL;
}
-const char *ruby_cmd_add_path(cmd_parms *cmd, ruby_dir_config *dconf, char *arg)
+const char *ruby_cmd_add_path(cmd_parms *cmd, void *dconf, const char *arg)
{
ruby_server_config *sconf;
check_restrict_directives(cmd, dconf)
if (cmd->path == NULL) {
sconf = get_server_config(cmd->server);
+#ifdef APACHE2
+ *(const char **) apr_array_push(sconf->load_path) = arg;
+#else
*(char **) ap_push_array(sconf->load_path) = arg;
+#endif
}
else {
- if (dconf->load_path == NULL)
- dconf->load_path = ap_make_array(cmd->pool, 1, sizeof(char*));
- *(char **) ap_push_array(dconf->load_path) = arg;
+ if (((ruby_dir_config *) dconf)->load_path == NULL)
+#ifdef APACHE2
+ ((ruby_dir_config *) dconf)->load_path = apr_array_make(cmd->pool, 1, sizeof(const char*));
+ *(const char **) apr_array_push(((ruby_dir_config *) dconf)->load_path) = arg;
+#else
+ ((ruby_dir_config *) dconf)->load_path = ap_make_array(cmd->pool, 1, sizeof(char*));
+ *(char **) ap_push_array(((ruby_dir_config *) dconf)->load_path) = arg;
+#endif
}
return NULL;
}
typedef struct require_internal_arg {
- char *filename;
+ const char *filename;
server_rec *server;
ruby_server_config *sconf;
ruby_dir_config *dconf;
@@ -246,7 +334,7 @@
static void *ruby_require_internal(require_internal_arg_t *arg)
{
- char *filename = arg->filename;
+ const char *filename = arg->filename;
server_rec *server = arg->server;
ruby_server_config *sconf = arg->sconf;
ruby_dir_config *dconf = arg->dconf;
@@ -269,13 +357,17 @@
return NULL;
}
-static void ruby_require(pool *p, char *filename,
+static void ruby_require(pool *p, const char *filename,
server_rec *server,
ruby_server_config *sconf, ruby_dir_config *dconf)
{
require_internal_arg_t *arg;
+#ifdef APACHE2
+ arg = apr_palloc(p, sizeof(require_internal_arg_t));
+#else
arg = ap_palloc(p, sizeof(require_internal_arg_t));
+#endif
arg->filename = filename;
arg->server = server;
arg->sconf = sconf;
@@ -302,7 +394,7 @@
#endif
}
-const char *ruby_cmd_require(cmd_parms *cmd, ruby_dir_config *dconf, char *arg)
+const char *ruby_cmd_require(cmd_parms *cmd, void *dconf, const char *arg)
{
ruby_server_config *sconf = get_server_config(cmd->server);
ruby_library_context *lib;
@@ -313,9 +405,15 @@
}
else {
if (ruby_required_libraries == NULL)
+#ifdef APACHE2
ruby_required_libraries =
+ apr_array_make(cmd->pool, 1, sizeof(ruby_library_context));
+ lib = (ruby_library_context *) apr_array_push(ruby_required_libraries);
+#else
+ ruby_required_libraries =
ap_make_array(cmd->pool, 1, sizeof(ruby_library_context));
lib = (ruby_library_context *) ap_push_array(ruby_required_libraries);
+#endif
lib->filename = arg;
lib->server_config = sconf;
lib->dir_config = dconf;
@@ -323,32 +421,48 @@
return NULL;
}
-const char *ruby_cmd_pass_env(cmd_parms *cmd, void *dummy, char *arg)
+const char *ruby_cmd_pass_env(cmd_parms *cmd, void *dummy, const char *arg)
{
ruby_server_config *conf = get_server_config(cmd->server);
- char *key;
- char *val = strchr(arg, ':');
+ const char *key;
+ const char *val = strchr(arg, ':');
if (val) {
+#ifdef APACHE2
+ key = apr_pstrndup(cmd->pool, arg, val - arg);
+#else
key = ap_pstrndup(cmd->pool, arg, val - arg);
+#endif
val++;
}
else {
key = arg;
val = getenv(key);
}
+#ifdef APACHE2
+ apr_table_set(conf->env, key, val);
+#else
ap_table_set(conf->env, key, val);
+#endif
return NULL;
}
-const char *ruby_cmd_set_env(cmd_parms *cmd, ruby_dir_config *conf,
- char *key, char *val)
+const char *ruby_cmd_set_env(cmd_parms *cmd, void *conf,
+ const char *key, const char *val)
{
check_restrict_directives(cmd, conf)
- ap_table_set(conf->env, key, val);
+#ifdef APACHE2
+ apr_table_set(((ruby_dir_config *) conf)->env, key, val);
+#else
+ ap_table_set(((ruby_dir_config *) conf)->env, key, val);
+#endif
if (cmd->path == NULL) {
ruby_server_config *sconf = get_server_config(cmd->server);
+#ifdef APACHE2
+ apr_table_set(sconf->env, key, val);
+#else
ap_table_set(sconf->env, key, val);
+#endif
}
return NULL;
}
@@ -360,7 +474,7 @@
return NULL;
}
-const char *ruby_cmd_timeout(cmd_parms *cmd, void *dummy, char *arg)
+const char *ruby_cmd_timeout(cmd_parms *cmd, void *dummy, const char *arg)
{
ruby_server_config *conf = get_server_config(cmd->server);
@@ -368,29 +482,29 @@
return NULL;
}
-const char *ruby_cmd_safe_level(cmd_parms *cmd, ruby_dir_config *conf, char *arg)
+const char *ruby_cmd_safe_level(cmd_parms *cmd, void *conf, const char *arg)
{
check_restrict_directives(cmd, conf)
if (cmd->path == NULL && !cmd->server->is_virtual) {
- conf->safe_level = default_safe_level = atoi(arg);
+ ((ruby_dir_config *) conf)->safe_level = default_safe_level = atoi(arg);
}
else {
- conf->safe_level = atoi(arg);
+ ((ruby_dir_config *) conf)->safe_level = atoi(arg);
}
return NULL;
}
-const char *ruby_cmd_output_mode(cmd_parms *cmd, ruby_dir_config *conf, char *arg)
+const char *ruby_cmd_output_mode(cmd_parms *cmd, void *conf, const char *arg)
{
check_restrict_directives(cmd, conf)
if (strcasecmp(arg, "nosync") == 0) {
- conf->output_mode = MR_OUTPUT_NOSYNC;
+ ((ruby_dir_config *) conf)->output_mode = MR_OUTPUT_NOSYNC;
}
else if (strcasecmp(arg, "sync") == 0) {
- conf->output_mode = MR_OUTPUT_SYNC;
+ ((ruby_dir_config *) conf)->output_mode = MR_OUTPUT_SYNC;
}
else if (strcasecmp(arg, "syncheader") == 0) {
- conf->output_mode = MR_OUTPUT_SYNC_HEADER;
+ ((ruby_dir_config *) conf)->output_mode = MR_OUTPUT_SYNC_HEADER;
}
else {
return "unknown mode";
@@ -398,104 +512,108 @@
return NULL;
}
-const char *ruby_cmd_option(cmd_parms *cmd, ruby_dir_config *conf,
- char *key, char *val)
+const char *ruby_cmd_option(cmd_parms *cmd, void *conf,
+ const char *key, const char *val)
{
check_restrict_directives(cmd, conf)
- ap_table_set(conf->options, key, val);
+#ifdef APACHE2
+ apr_table_set(((ruby_dir_config *) conf)->options, key, val);
+#else
+ ap_table_set(((ruby_dir_config *) conf)->options, key, val);
+#endif
return NULL;
}
-const char *ruby_cmd_handler(cmd_parms *cmd, ruby_dir_config *conf, char *arg)
+const char *ruby_cmd_handler(cmd_parms *cmd, void *conf, const char *arg)
{
check_restrict_directives(cmd, conf)
- push_handler(cmd->pool, conf->ruby_handler, arg);
+ push_handler(cmd->pool, ((ruby_dir_config *) conf)->ruby_handler, arg);
return NULL;
}
-const char *ruby_cmd_trans_handler(cmd_parms *cmd, ruby_dir_config *conf, char *arg)
+const char *ruby_cmd_trans_handler(cmd_parms *cmd, void *conf, const char *arg)
{
check_restrict_directives(cmd, conf)
- push_handler(cmd->pool, conf->ruby_trans_handler, arg);
+ push_handler(cmd->pool, ((ruby_dir_config *) conf)->ruby_trans_handler, arg);
return NULL;
}
-const char *ruby_cmd_authen_handler(cmd_parms *cmd, ruby_dir_config *conf, char *arg)
+const char *ruby_cmd_authen_handler(cmd_parms *cmd, void *conf, const char *arg)
{
check_restrict_directives(cmd, conf)
- push_handler(cmd->pool, conf->ruby_authen_handler, arg);
+ push_handler(cmd->pool, ((ruby_dir_config *) conf)->ruby_authen_handler, arg);
return NULL;
}
-const char *ruby_cmd_authz_handler(cmd_parms *cmd, ruby_dir_config *conf, char *arg)
+const char *ruby_cmd_authz_handler(cmd_parms *cmd, void *conf, const char *arg)
{
check_restrict_directives(cmd, conf)
- push_handler(cmd->pool, conf->ruby_authz_handler, arg);
+ push_handler(cmd->pool, ((ruby_dir_config *) conf)->ruby_authz_handler, arg);
return NULL;
}
-const char *ruby_cmd_access_handler(cmd_parms *cmd, ruby_dir_config *conf, char *arg)
+const char *ruby_cmd_access_handler(cmd_parms *cmd, void *conf, const char *arg)
{
check_restrict_directives(cmd, conf)
- push_handler(cmd->pool, conf->ruby_access_handler, arg);
+ push_handler(cmd->pool, ((ruby_dir_config *) conf)->ruby_access_handler, arg);
return NULL;
}
-const char *ruby_cmd_type_handler(cmd_parms *cmd, ruby_dir_config *conf, char *arg)
+const char *ruby_cmd_type_handler(cmd_parms *cmd, void *conf, const char *arg)
{
check_restrict_directives(cmd, conf)
- push_handler(cmd->pool, conf->ruby_type_handler, arg);
+ push_handler(cmd->pool, ((ruby_dir_config *) conf)->ruby_type_handler, arg);
return NULL;
}
-const char *ruby_cmd_fixup_handler(cmd_parms *cmd, ruby_dir_config *conf, char *arg)
+const char *ruby_cmd_fixup_handler(cmd_parms *cmd, void *conf, const char *arg)
{
check_restrict_directives(cmd, conf)
- push_handler(cmd->pool, conf->ruby_fixup_handler, arg);
+ push_handler(cmd->pool, ((ruby_dir_config *) conf)->ruby_fixup_handler, arg);
return NULL;
}
-const char *ruby_cmd_log_handler(cmd_parms *cmd, ruby_dir_config *conf, char *arg)
+const char *ruby_cmd_log_handler(cmd_parms *cmd, void *conf, const char *arg)
{
check_restrict_directives(cmd, conf)
- push_handler(cmd->pool, conf->ruby_log_handler, arg);
+ push_handler(cmd->pool, ((ruby_dir_config *) conf)->ruby_log_handler, arg);
return NULL;
}
const char *ruby_cmd_header_parser_handler(cmd_parms *cmd,
- ruby_dir_config *conf, char *arg)
+ void *conf, const char *arg)
{
check_restrict_directives(cmd, conf)
- push_handler(cmd->pool, conf->ruby_header_parser_handler, arg);
+ push_handler(cmd->pool, ((ruby_dir_config *) conf)->ruby_header_parser_handler, arg);
return NULL;
}
const char *ruby_cmd_post_read_request_handler(cmd_parms *cmd,
- ruby_dir_config *conf, char *arg)
+ void *conf, const char *arg)
{
check_restrict_directives(cmd, conf)
- push_handler(cmd->pool, conf->ruby_post_read_request_handler, arg);
+ push_handler(cmd->pool, ((ruby_dir_config *) conf)->ruby_post_read_request_handler, arg);
return NULL;
}
const char *ruby_cmd_init_handler(cmd_parms *cmd,
- ruby_dir_config *conf, char *arg)
+ void *conf, const char *arg)
{
check_restrict_directives(cmd, conf)
- push_handler(cmd->pool, conf->ruby_init_handler, arg);
+ push_handler(cmd->pool, ((ruby_dir_config *) conf)->ruby_init_handler, arg);
return NULL;
}
const char *ruby_cmd_cleanup_handler(cmd_parms *cmd,
- ruby_dir_config *conf, char *arg)
+ void *conf, const char *arg)
{
check_restrict_directives(cmd, conf)
- push_handler(cmd->pool, conf->ruby_cleanup_handler, arg);
+ push_handler(cmd->pool, ((ruby_dir_config *) conf)->ruby_cleanup_handler, arg);
return NULL;
}
const char *ruby_cmd_child_init_handler(cmd_parms *cmd,
- void *dummy, char *arg)
+ void *dummy, const char *arg)
{
ruby_server_config *conf = get_server_config(cmd->server);
Index: paramtable.c
===================================================================
--- paramtable.c (revision 103)
+++ paramtable.c (working copy)
@@ -86,7 +86,11 @@
{
table *tbl = get_paramtable( self );
+#ifdef APACHE2
+ apr_table_clear( tbl );
+#else
ap_clear_table( tbl );
+#endif
return Qnil;
}
@@ -120,14 +124,22 @@
key = StringValuePtr( name );
+#ifdef APACHE2
+ if ( apr_table_get(tbl, key) ) {
+#else
if ( ap_table_get(tbl, key) ) {
+#endif
VALUE ary;
res = rb_class_new_instance(0, 0, rb_cApacheMultiVal);
ary = rb_ivar_get( res, atargs_id );
rb_ary_clear( ary );
+#ifdef APACHE2
+ apr_table_do( rb_ary_tainted_push, &ary, tbl, key, NULL );
+#else
ap_table_do( rb_ary_tainted_push, &ary, tbl, key, NULL );
+#endif
}
return res;
@@ -149,16 +161,28 @@
VALUE str;
int i;
+#ifdef APACHE2
+ apr_table_unset( tbl, key );
+#else
ap_table_unset( tbl, key );
+#endif
for ( i = 0; i < RARRAY(ary)->len; i++ ) {
str = rb_check_convert_type( *(RARRAY(ary)->ptr+i), T_STRING,
"String", "to_str" );
+#ifdef APACHE2
+ apr_table_add( tbl, key, StringValuePtr(str) );
+#else
ap_table_add( tbl, key, StringValuePtr(str) );
+#endif
}
}
else {
val = rb_check_convert_type( val, T_STRING, "String", "to_str" );
+#ifdef APACHE2
+ apr_table_set( tbl, key, StringValuePtr(val) );
+#else
ap_table_set( tbl, key, StringValuePtr(val) );
+#endif
}
return val;
@@ -174,7 +198,11 @@
static VALUE paramtable_unset( VALUE self, VALUE name )
{
table *tbl = get_paramtable( self );
+#ifdef APACHE2
+ apr_table_unset( tbl, StringValuePtr(name) );
+#else
ap_table_unset( tbl, StringValuePtr(name) );
+#endif
return Qnil;
}
@@ -194,7 +222,11 @@
table_entry *hdrs;
int i;
+#ifdef APACHE2
+ hdrs_arr = apr_table_elts( tbl );
+#else
hdrs_arr = ap_table_elts( tbl );
+#endif
hdrs = (table_entry *) hdrs_arr->elts;
res = rb_ary_new2( hdrs_arr->nelts + 1 );
@@ -207,7 +239,11 @@
val = rb_class_new_instance(0, 0, rb_cApacheMultiVal);
ary = rb_ivar_get( val, atargs_id );
rb_ary_clear( ary );
+#ifdef APACHE2
+ apr_table_do( rb_ary_tainted_push, &ary, tbl, hdrs[i].key, NULL );
+#else
ap_table_do( rb_ary_tainted_push, &ary, tbl, hdrs[i].key, NULL );
+#endif
assoc = rb_assoc_new( key, val );
rb_yield( assoc );
@@ -231,7 +267,11 @@
int i;
VALUE res;
- hdrs_arr = ap_table_elts(tbl);
+#ifdef APACHE2
+ hdrs_arr = apr_table_elts( tbl );
+#else
+ hdrs_arr = ap_table_elts( tbl );
+#endif
hdrs = (table_entry *) hdrs_arr->elts;
res = rb_ary_new2( hdrs_arr->nelts + 1 );
@@ -259,7 +299,11 @@
table_entry *hdrs;
int i;
+#ifdef APACHE2
+ hdrs_arr = apr_table_elts( tbl );
+#else
hdrs_arr = ap_table_elts( tbl );
+#endif
hdrs = (table_entry *) hdrs_arr->elts;
res = rb_ary_new2( hdrs_arr->nelts + 1 );
@@ -272,7 +316,11 @@
val = rb_class_new_instance(0, 0, rb_cApacheMultiVal);
ary = rb_ivar_get( val, atargs_id );
rb_ary_clear( ary );
+#ifdef APACHE2
+ apr_table_do( rb_ary_tainted_push, &ary, tbl, hdrs[i].key, NULL );
+#else
ap_table_do( rb_ary_tainted_push, &ary, tbl, hdrs[i].key, NULL );
+#endif
rb_ary_store( res, i, val );
}
Index: apache_cookie.c
===================================================================
--- apache_cookie.c (revision 103)
+++ apache_cookie.c (working copy)
@@ -27,9 +27,15 @@
return c->expires;
}
+#ifdef APACHE2
#define cookie_get_set(thing,val) \
retval = thing; \
+ if(val) thing = apr_pstrdup(c->r->pool, val)
+#else
+#define cookie_get_set(thing,val) \
+ retval = thing; \
if(val) thing = ap_pstrdup(c->r->pool, val)
+#endif
char *ApacheCookie_attr(ApacheCookie *c, char *key, char *val)
{
@@ -73,11 +79,19 @@
va_list args;
ApacheRequest req;
ApacheCookie *c =
+#ifdef APACHE2
+ apr_pcalloc(r->pool, sizeof(ApacheCookie));
+#else
ap_pcalloc(r->pool, sizeof(ApacheCookie));
+#endif
req.r = r;
c->r = r;
+#ifdef APACHE2
+ c->values = apr_array_make(r->pool, 1, sizeof(char *));
+#else
c->values = ap_make_array(r->pool, 1, sizeof(char *));
+#endif
c->secure = 0;
c->name = c->expires = NULL;
@@ -103,17 +117,29 @@
{
const char *pair;
ApacheCookieJar *retval =
+#ifdef APACHE2
+ apr_array_make(r->pool, 1, sizeof(ApacheCookie *));
+#else
ap_make_array(r->pool, 1, sizeof(ApacheCookie *));
+#endif
if (!data)
+#ifdef APACHE2
+ if (!(data = apr_table_get(r->headers_in, "Cookie")))
+#else
if (!(data = ap_table_get(r->headers_in, "Cookie")))
+#endif
return retval;
while (*data && (pair = ap_getword(r->pool, &data, ';'))) {
const char *key, *val;
ApacheCookie *c;
+#ifdef APACHE2
+ while (apr_isspace(*data))
+#else
while (ap_isspace(*data))
+#endif
++data;
key = ap_getword(r->pool, &pair, '=');
@@ -123,7 +149,11 @@
if (c->values)
c->values->nelts = 0;
else
+#ifdef APACHE2
+ c->values = apr_array_make(r->pool, 4, sizeof(char *));
+#else
c->values = ap_make_array(r->pool, 4, sizeof(char *));
+#endif
if (!*pair)
ApacheCookieAdd(c, "");
@@ -143,13 +173,23 @@
return retval;
}
+#ifdef APACHE2
#define cookie_push_arr(arr, val) \
+ *(char **)apr_array_push(arr) = (char *)val
+
+#define cookie_push_named(arr, name, val) \
+ if(val && strlen(val) > 0) { \
+ cookie_push_arr(arr, apr_pstrcat(p, name, "=", val, NULL)); \
+ }
+#else
+#define cookie_push_arr(arr, val) \
*(char **)ap_push_array(arr) = (char *)val
#define cookie_push_named(arr, name, val) \
if(val && strlen(val) > 0) { \
cookie_push_arr(arr, ap_pstrcat(p, name, "=", val, NULL)); \
}
+#endif
static char * escape_url(pool *p, char *val)
{
@@ -195,7 +235,11 @@
if (!c->name)
return "";
+#ifdef APACHE2
+ values = apr_array_make(p, 6, sizeof(char *));
+#else
values = ap_make_array(p, 6, sizeof(char *));
+#endif
cookie_push_named(values, "domain", c->domain);
cookie_push_named(values, "path", c->path);
cookie_push_named(values, "expires", c->expires);
@@ -203,18 +247,34 @@
cookie_push_arr(values, "secure");
}
+#ifdef APACHE2
+ cookie = apr_pstrcat(p, escape_url(p, c->name), "=", NULL);
+#else
cookie = ap_pstrcat(p, escape_url(p, c->name), "=", NULL);
+#endif
for (i=0; i<c->values->nelts; i++) {
+#ifdef APACHE2
+ cookie = apr_pstrcat(p, cookie,
+ escape_url(p, ((char**)c->values->elts)[i]),
+ (i < (c->values->nelts -1) ? "&" : NULL),
+ NULL);
+#else
cookie = ap_pstrcat(p, cookie,
escape_url(p, ((char**)c->values->elts)[i]),
(i < (c->values->nelts -1) ? "&" : NULL),
NULL);
+#endif
}
retval = cookie;
for (i=0; i<values->nelts; i++) {
+#ifdef APACHE2
+ retval = apr_pstrcat(p, retval, "; ",
+ ((char**)values->elts)[i], NULL);
+#else
retval = ap_pstrcat(p, retval, "; ",
((char**)values->elts)[i], NULL);
+#endif
}
return retval;
@@ -222,6 +282,11 @@
void ApacheCookie_bake(ApacheCookie *c)
{
+#ifdef APACHE2
+ apr_table_add(c->r->err_headers_out, "Set-Cookie",
+ ApacheCookie_as_string(c));
+#else
ap_table_add(c->r->err_headers_out, "Set-Cookie",
ApacheCookie_as_string(c));
+#endif
}
Index: ruby_config.h
===================================================================
--- ruby_config.h (revision 103)
+++ ruby_config.h (working copy)
@@ -34,29 +34,29 @@
void *ruby_merge_server_config(pool*, void*, void*);
void *ruby_create_dir_config (pool*, char*);
void *ruby_merge_dir_config(pool*, void*, void*);
-const char *ruby_cmd_kanji_code(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_add_path(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_require(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_pass_env(cmd_parms*, void*, char*);
-const char *ruby_cmd_set_env(cmd_parms*, ruby_dir_config*, char*, char*);
-const char *ruby_cmd_timeout(cmd_parms*, void*, char*);
-const char *ruby_cmd_safe_level(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_output_mode(cmd_parms*, ruby_dir_config*, char*);
+const char *ruby_cmd_kanji_code(cmd_parms*, void*, const char*);
+const char *ruby_cmd_add_path(cmd_parms*, void*, const char*);
+const char *ruby_cmd_require(cmd_parms*, void*, const char*);
+const char *ruby_cmd_pass_env(cmd_parms*, void*, const char*);
+const char *ruby_cmd_set_env(cmd_parms*, void*, const char*, const char*);
+const char *ruby_cmd_timeout(cmd_parms*, void*, const char*);
+const char *ruby_cmd_safe_level(cmd_parms*, void*, const char*);
+const char *ruby_cmd_output_mode(cmd_parms*, void*, const char*);
const char *ruby_cmd_restrict_directives(cmd_parms*, void*, int);
-const char *ruby_cmd_option(cmd_parms*, ruby_dir_config*, char*, char*);
-const char *ruby_cmd_handler(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_trans_handler(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_authen_handler(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_authz_handler(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_access_handler(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_type_handler(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_fixup_handler(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_log_handler(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_header_parser_handler(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_post_read_request_handler(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_init_handler(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_cleanup_handler(cmd_parms*, ruby_dir_config*, char*);
-const char *ruby_cmd_child_init_handler(cmd_parms*, void*, char*);
+const char *ruby_cmd_option(cmd_parms*, void*, const char*, const char*);
+const char *ruby_cmd_handler(cmd_parms*, void*, const char*);
+const char *ruby_cmd_trans_handler(cmd_parms*, void*, const char*);
+const char *ruby_cmd_authen_handler(cmd_parms*, void*, const char*);
+const char *ruby_cmd_authz_handler(cmd_parms*, void*, const char*);
+const char *ruby_cmd_access_handler(cmd_parms*, void*, const char*);
+const char *ruby_cmd_type_handler(cmd_parms*, void*, const char*);
+const char *ruby_cmd_fixup_handler(cmd_parms*, void*, const char*);
+const char *ruby_cmd_log_handler(cmd_parms*, void*, const char*);
+const char *ruby_cmd_header_parser_handler(cmd_parms*, void*, const char*);
+const char *ruby_cmd_post_read_request_handler(cmd_parms*, void*, const char*);
+const char *ruby_cmd_init_handler(cmd_parms*, void*, const char*);
+const char *ruby_cmd_cleanup_handler(cmd_parms*, void*, const char*);
+const char *ruby_cmd_child_init_handler(cmd_parms*, void*, const char*);
#endif /* !RUBY_CONFIG_H */
Index: apache_cookie.h
===================================================================
--- apache_cookie.h (revision 103)
+++ apache_cookie.h (working copy)
@@ -41,15 +41,30 @@
#define ApacheCookieJarFetch(arr,i) \
((ApacheCookie *)(((ApacheCookie **)arr->elts)[i]))
+#ifdef APACHE2
#define ApacheCookieJarAdd(arr,c) \
+*(ApacheCookie **)apr_array_push(arr) = c
+#else /* Apache 1.x */
+#define ApacheCookieJarAdd(arr,c) \
*(ApacheCookie **)ap_push_array(arr) = c
+#endif
#define ApacheCookieItems(c) c->values->nelts
#define ApacheCookieFetch(c,i) \
((char *)(((char **)c->values->elts)[i]))
+#ifdef APACHE2
#define ApacheCookieAddn(c,val) \
+ if(val) *(char **)apr_array_push(c->values) = (char *)val
+
+#define ApacheCookieAdd(c,val) \
+ ApacheCookieAddn(c, apr_pstrdup(c->r->pool, val))
+
+#define ApacheCookieAddLen(c,val,len) \
+ ApacheCookieAddn(c, apr_pstrndup(c->r->pool, val, len))
+#else /* Apache 1.x */
+#define ApacheCookieAddn(c,val) \
if(val) *(char **)ap_push_array(c->values) = (char *)val
#define ApacheCookieAdd(c,val) \
@@ -57,7 +72,13 @@
#define ApacheCookieAddLen(c,val,len) \
ApacheCookieAddn(c, ap_pstrndup(c->r->pool, val, len))
+#endif
+
+#ifdef APACHE2
+#else
+#endif
+
ApacheCookie *ApacheCookie_new(request_rec *r, ...);
ApacheCookieJar *ApacheCookie_parse(request_rec *r, const char *data);
char *ApacheCookie_as_string(ApacheCookie *c);
Index: array_header.c
===================================================================
--- array_header.c (revision 103)
+++ array_header.c (working copy)
@@ -79,9 +79,15 @@
else if (n >= arr->nelts) {
rb_raise(rb_eIndexError, "index %d out of array", n);
}
+#ifdef APACHE2
+ ((char **) arr->elts)[n] = apr_pstrndup(arr->pool,
+ RSTRING(val)->ptr,
+ RSTRING(val)->len);
+#else
((char **) arr->elts)[n] = ap_pstrndup(arr->pool,
RSTRING(val)->ptr,
RSTRING(val)->len);
+#endif
return val;
}
Index: table.c
===================================================================
--- table.c (revision 103)
+++ table.c (working copy)
@@ -40,7 +40,11 @@
table *tbl;
Data_Get_Struct(self, table, tbl);
+#ifdef APACHE2
+ apr_table_clear(tbl);
+#else
ap_clear_table(tbl);
+#endif
return Qnil;
}
@@ -51,7 +55,11 @@
key = StringValuePtr(name);
Data_Get_Struct(self, table, tbl);
+#ifdef APACHE2
+ res = apr_table_get(tbl, key);
+#else
res = ap_table_get(tbl, key);
+#endif
if (res)
return rb_tainted_str_new2(res);
else
@@ -64,7 +72,11 @@
Check_Type(val, T_STRING);
Data_Get_Struct(self, table, tbl);
+#ifdef APACHE2
+ apr_table_set(tbl, StringValuePtr(name), StringValuePtr(val));
+#else
ap_table_set(tbl, StringValuePtr(name), StringValuePtr(val));
+#endif
return val;
}
@@ -74,7 +86,11 @@
Check_Type(val, T_STRING);
Data_Get_Struct(self, table, tbl);
+#ifdef APACHE2
+ apr_table_merge(tbl, StringValuePtr(name), StringValuePtr(val));
+#else
ap_table_merge(tbl, StringValuePtr(name), StringValuePtr(val));
+#endif
return val;
}
@@ -83,7 +99,11 @@
table *tbl;
Data_Get_Struct(self, table, tbl);
+#ifdef APACHE2
+ apr_table_unset(tbl, StringValuePtr(name));
+#else
ap_table_unset(tbl, StringValuePtr(name));
+#endif
return Qnil;
}
@@ -93,7 +113,11 @@
Check_Type(val, T_STRING);
Data_Get_Struct(self, table, tbl);
+#ifdef APACHE2
+ apr_table_add(tbl, StringValuePtr(name), StringValuePtr(val));
+#else
ap_table_add(tbl, StringValuePtr(name), StringValuePtr(val));
+#endif
return val;
}
@@ -106,7 +130,11 @@
int i;
Data_Get_Struct(self, table, tbl);
+#ifdef APACHE2
+ hdrs_arr = apr_table_elts(tbl);
+#else
hdrs_arr = ap_table_elts(tbl);
+#endif
hdrs = (table_entry *) hdrs_arr->elts;
for (i = 0; i < hdrs_arr->nelts; i++) {
if (hdrs[i].key == NULL)
@@ -127,7 +155,11 @@
int i;
Data_Get_Struct(self, table, tbl);
+#ifdef APACHE2
+ hdrs_arr = apr_table_elts(tbl);
+#else
hdrs_arr = ap_table_elts(tbl);
+#endif
hdrs = (table_entry *) hdrs_arr->elts;
for (i = 0; i < hdrs_arr->nelts; i++) {
if (hdrs[i].key == NULL)
@@ -145,7 +177,11 @@
int i;
Data_Get_Struct(self, table, tbl);
+#ifdef APACHE2
+ hdrs_arr = apr_table_elts(tbl);
+#else
hdrs_arr = ap_table_elts(tbl);
+#endif
hdrs = (table_entry *) hdrs_arr->elts;
for (i = 0; i < hdrs_arr->nelts; i++) {
if (hdrs[i].key == NULL)
Index: request.c
===================================================================
--- request.c (revision 103)
+++ request.c (working copy)
@@ -76,6 +76,7 @@
#define REQUEST_STRING_ATTR_READER(fname, member) \
DEFINE_STRING_ATTR_READER(fname, request_data, request->member)
+#ifdef APACHE2
#define REQUEST_STRING_ATTR_WRITER(fname, member) \
static VALUE fname(VALUE self, VALUE val) \
{ \
@@ -83,10 +84,23 @@
Check_Type(val, T_STRING); \
data = get_request_data(self); \
data->request->member = \
+ apr_pstrndup(data->request->pool, \
+ RSTRING(val)->ptr, RSTRING(val)->len); \
+ return val; \
+}
+#else
+#define REQUEST_STRING_ATTR_WRITER(fname, member) \
+static VALUE fname(VALUE self, VALUE val) \
+{ \
+ request_data *data; \
+ Check_Type(val, T_STRING); \
+ data = get_request_data(self); \
+ data->request->member = \
ap_pstrndup(data->request->pool, \
RSTRING(val)->ptr, RSTRING(val)->len); \
return val; \
}
+#endif
#define REQUEST_INT_ATTR_READER(fname, member) \
DEFINE_INT_ATTR_READER(fname, request_data, request->member)
@@ -178,7 +192,11 @@
data->cookies = rb_hash_new();
data->param_table = Qnil;
data->options = rb_hash_new();
- opts_arr = ap_table_elts(dconf->options);
+#ifdef APACHE2
+ opts_arr = apr_table_elts(dconf->options);
+#else
+ opts_arr = apr_table_elts(dconf->options);
+#endif
opts = (table_entry *) opts_arr->elts;
for (i = 0; i < opts_arr->nelts; i++) {
if (opts[i].key == NULL)
@@ -193,8 +211,13 @@
ruby_request_config *rconf = get_request_config(r);
rconf->request_object = obj;
}
+#ifdef APACHE2
+ apr_pool_cleanup_register(r->pool, (void *) r,
+ cleanup_request_object, apr_pool_cleanup_null);
+#else
ap_register_cleanup(r->pool, (void *) r,
cleanup_request_object, ap_null_cleanup);
+#endif
if (dconf) {
switch (dconf->output_mode) {
case MR_OUTPUT_SYNC_HEADER:
@@ -626,7 +649,11 @@
rb_warn("content_length is obsolete; use headers_in[\"Content-Length\"] instead");
data = get_request_data(self);
+#ifdef APACHE2
+ s = apr_table_get(data->request->headers_in, "Content-Length");
+#else
s = ap_table_get(data->request->headers_in, "Content-Length");
+#endif
return s ? rb_cstr2inum(s, 10) : Qnil;
}
@@ -641,9 +668,15 @@
else {
Check_Type(str, T_STRING);
str = rb_funcall(str, rb_intern("downcase"), 0);
+#ifdef APACHE2
data->request->content_type =
+ apr_pstrndup(data->request->pool,
+ RSTRING(str)->ptr, RSTRING(str)->len);
+#else
+ data->request->content_type =
ap_pstrndup(data->request->pool,
RSTRING(str)->ptr, RSTRING(str)->len);
+#endif
}
return str;
}
@@ -659,10 +692,17 @@
else {
Check_Type(str, T_STRING);
str = rb_funcall(str, rb_intern("downcase"), 0);
+#ifdef APACHE2
data->request->content_encoding =
+ apr_pstrndup(data->request->pool,
+ RSTRING(str)->ptr,
+ RSTRING(str)->len);
+#else
+ data->request->content_encoding =
ap_pstrndup(data->request->pool,
RSTRING(str)->ptr,
RSTRING(str)->len);
+#endif
}
return str;
}
@@ -694,15 +734,27 @@
for (i = 0; i < RARRAY(ary)->len; i++) {
Check_Type(RARRAY(ary)->ptr[i], T_STRING);
}
+#ifdef APACHE2
data->request->content_languages =
+ apr_array_make(data->request->pool, RARRAY(ary)->len, sizeof(char *));
+#else
+ data->request->content_languages =
ap_make_array(data->request->pool, RARRAY(ary)->len, sizeof(char *));
+#endif
for (i = 0; i < RARRAY(ary)->len; i++) {
VALUE str = RARRAY(ary)->ptr[i];
str = rb_funcall(str, rb_intern("downcase"), 0);
+#ifdef APACHE2
+ *(char **) apr_array_push(data->request->content_languages) =
+ apr_pstrndup(data->request->pool,
+ RSTRING(str)->ptr,
+ RSTRING(str)->len);
+#else
*(char **) ap_push_array(data->request->content_languages) =
ap_pstrndup(data->request->pool,
RSTRING(str)->ptr,
RSTRING(str)->len);
+#endif
}
}
return ary;
@@ -939,7 +991,11 @@
if (ap_should_client_block(r)) {
if (len < 0)
len = r->remaining;
+#ifdef APACHE2
+ buf = (char *) apr_palloc(r->pool, len);
+#else
buf = (char *) ap_palloc(r->pool, len);
+#endif
result = rb_tainted_str_new("", 0);
while (len > 0) {
nrd = ap_get_client_block(r, buf, len);
@@ -1193,7 +1249,11 @@
Check_Type(name, T_STRING);
data = get_request_data(self);
+#ifdef APACHE2
+ s = apr_pstrndup(data->request->pool, RSTRING(name)->ptr, RSTRING(name)->len);
+#else
s = ap_pstrndup(data->request->pool, RSTRING(name)->ptr, RSTRING(name)->len);
+#endif
ap_soft_timeout(s, data->request);
return Qnil;
}
@@ -1340,9 +1400,15 @@
Check_Type(val, T_STRING);
data = get_request_data(self);
+#ifdef APACHE2
+ data->request->user = apr_pstrndup(data->request->pool,
+ RSTRING(val)->ptr,
+ RSTRING(val)->len);
+#else
data->request->user = ap_pstrndup(data->request->pool,
RSTRING(val)->ptr,
RSTRING(val)->len);
+#endif
return val;
}
#else /* Apache 1.x */
@@ -1434,9 +1500,15 @@
data = get_request_data(self);
conf = (core_dir_config *)
ap_get_module_config(data->request->per_dir_config, &core_module);
+#ifdef APACHE2
+ conf->ap_auth_type = apr_pstrndup(data->request->pool,
+ RSTRING(val)->ptr,
+ RSTRING(val)->len);
+#else
conf->ap_auth_type = ap_pstrndup(data->request->pool,
RSTRING(val)->ptr,
RSTRING(val)->len);
+#endif
ap_set_module_config(data->request->per_dir_config, &core_module, conf);
return val;
}
@@ -1466,9 +1538,15 @@
data = get_request_data(self);
conf = (core_dir_config *)
ap_get_module_config(data->request->per_dir_config, &core_module);
+#ifdef APACHE2
+ conf->ap_auth_name = apr_pstrndup(data->request->pool,
+ RSTRING(val)->ptr,
+ RSTRING(val)->len);
+#else
conf->ap_auth_name = ap_pstrndup(data->request->pool,
RSTRING(val)->ptr,
RSTRING(val)->len);
+#endif
ap_set_module_config(data->request->per_dir_config, &core_module, conf);
return val;
}
@@ -1598,7 +1676,11 @@
data->headers_out = rb_apache_table_new(data->request->headers_out);
Data_Get_Struct(data->headers_out, table, tbl);
+#ifdef APACHE2
+ hdrs_arr = apr_table_elts(tbl);
+#else
hdrs_arr = ap_table_elts(tbl);
+#endif
hdrs = (table_entry *) hdrs_arr->elts;
for (i = 0; i < hdrs_arr->nelts; i++) {
if (hdrs[i].key == NULL)
@@ -1623,12 +1705,22 @@
Data_Get_Struct(data->headers_out, table, tbl);
if (arg == Qtrue) {
+#ifdef APACHE2
+ apr_table_setn(tbl, "Pragma", "no-cache");
+ apr_table_setn(tbl, "Cache-control", "no-cache");
+#else
ap_table_setn(tbl, "Pragma", "no-cache");
ap_table_setn(tbl, "Cache-control", "no-cache");
+#endif
return Qtrue;
} else {
+#ifdef APACHE2
+ apr_table_unset(tbl, "Pragma");
+ apr_table_unset(tbl, "Cache-control");
+#else
ap_table_unset(tbl, "Pragma");
ap_table_unset(tbl, "Cache-control");
+#endif
return Qfalse;
}
}
@@ -1718,19 +1810,36 @@
if (argc == 0)
plain_cleanup = rb_f_lambda();
if (NIL_P(plain_cleanup))
+#ifdef APACHE2
+ plain_cleanup_func = apr_pool_cleanup_null;
+#else
plain_cleanup_func = ap_null_cleanup;
+#endif
else
plain_cleanup_func = call_plain_cleanup;
if (NIL_P(child_cleanup))
+#ifdef APACHE2
+ child_cleanup_func = apr_pool_cleanup_null;
+#else
child_cleanup_func = ap_null_cleanup;
+#endif
else
child_cleanup_func = call_child_cleanup;
+#ifdef APACHE2
+ cleanup = apr_palloc(data->request->pool, sizeof(request_cleanup_t));
+#else
cleanup = ap_palloc(data->request->pool, sizeof(request_cleanup_t));
+#endif
cleanup->pool = data->request->pool;
cleanup->plain_cleanup = plain_cleanup;
cleanup->child_cleanup = child_cleanup;
+#ifdef APACHE2
+ apr_pool_cleanup_register(data->request->pool, (void *) cleanup,
+ plain_cleanup_func, child_cleanup_func);
+#else
ap_register_cleanup(data->request->pool, (void *) cleanup,
plain_cleanup_func, child_cleanup_func);
+#endif
return Qnil;
}
@@ -1992,7 +2101,11 @@
if (!data->apreq->parsed) rb_funcall(self, rb_intern("parse"), 0);
result = rb_hash_new();
+#ifdef APACHE2
+ apr_table_do(make_all_params, (void *) result, data->apreq->parms, NULL);
+#else
ap_table_do(make_all_params, (void *) result, data->apreq->parms, NULL);
+#endif
return result;
}