httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Schaefer <...@sunstarsys.com>
Subject Re: specifying parameter origin
Date Fri, 06 Dec 2002 10:04:05 GMT
"David Brancato" <David@Brancato.com> writes:

[...]

> Unfortunately, I'm not familiar with the COW hack so I haven't tried
> that. I've only experimented with the "three table" approach, the
> "nargs" approach and rolling my own table that had three columns (key,
> val, origin). All worked fine.

I prefer the "nargs" approach.  Here's a diff against current cvs;
please comment.  I've got tests ready if other people like the idea.

% cvs diff apache_request.h apache_request.c
Index: apache_request.h
===================================================================
RCS file: /home/cvs/httpd-apreq/c/apache_request.h,v
retrieving revision 1.9
diff -u -r1.9 apache_request.h
--- apache_request.h	5 Nov 2002 00:07:16 -0000	1.9
+++ apache_request.h	6 Dec 2002 09:56:54 -0000
@@ -45,6 +45,7 @@
     void *hook_data;
     char* temp_dir;
     request_rec *r;
+    int nargs;
 } ApacheRequest;
 
 struct ApacheUpload {
@@ -97,6 +98,8 @@
 int ApacheRequest___parse(ApacheRequest *req);
 #define ApacheRequest_parse(req) \
     (req->status = req->parsed ? req->status : ApacheRequest___parse(req)) 
+table *ApacheRequest_query_params(ApacheRequest *req, ap_pool *p);
+table *ApacheRequest_post_params(ApacheRequest *req, ap_pool *p);
 
 FILE *ApacheRequest_tmpfile(ApacheRequest *req, ApacheUpload *upload);
 ApacheUpload *ApacheUpload_new(ApacheRequest *req);
Index: apache_request.c
===================================================================
RCS file: /home/cvs/httpd-apreq/c/apache_request.c,v
retrieving revision 1.21
diff -u -r1.21 apache_request.c
--- apache_request.c	20 Jun 2002 05:10:07 -0000	1.21
+++ apache_request.c	6 Dec 2002 09:56:55 -0000
@@ -167,6 +167,32 @@
     return retval;
 }
 
+table *ApacheRequest_query_params(ApacheRequest *req, ap_pool *p)
+{
+    array_header *a = ap_palloc(p, sizeof *a);
+    array_header *b = (array_header *)req->parms;
+
+    a->elts     = b->elts;
+    a->nelts    = req->nargs;
+
+    a->nalloc   = a->nelts; /* COW hack: array push will induce copying */
+    a->elt_size = sizeof(table_entry);
+    return (table *)a;
+}
+
+table *ApacheRequest_post_params(ApacheRequest *req, ap_pool *p)
+{
+    array_header *a = ap_palloc(p, sizeof *a);
+    array_header *b = (array_header *)req->parms;
+
+    a->elts     = (void *)( (table_entry *)b->elts + req->nargs );
+    a->nelts    = b->nelts - req->nargs;
+
+    a->nalloc   = a->nelts; /* COW hack: array push will induce copying */
+    a->elt_size = sizeof(table_entry);
+    return (table *)a;
+}
+
 ApacheUpload *ApacheUpload_new(ApacheRequest *req)
 {
     ApacheUpload *upload = (ApacheUpload *)
@@ -210,6 +236,7 @@
     req->temp_dir = NULL;
     req->parsed = 0;
     req->r = r;
+    req->nargs = 0;
 
     return req;
 }
@@ -264,6 +291,7 @@
 
     if (r->args) {
         split_to_parms(req, r->args);
+        req->nargs = ((array_header *)req->parms)->nelts;
     }
 
     if (r->method_number == M_POST) {

Mime
View raw message