httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham Clark <g...@dcs.ed.ac.uk>
Subject Re: bug in ApacheRequest_parse macro
Date Thu, 10 Jul 2003 18:58:18 GMT

Hi again,

Thanks for all the info Joe! Would there be any interest in
incorporating the following patches too? My aim was to provide a way
to get the parameter keys only. I'm not yet sure of the philosophy of
apreq, so if this is overkill, or there's an easier way to do this,
I'd be glad to know :-)

Graham

Index: apache_request.h
===================================================================
RCS file: /home/cvspublic/httpd-apreq/c/apache_request.h,v
retrieving revision 1.11
diff -u -r1.11 apache_request.h
--- apache_request.h	10 Jul 2003 11:08:50 -0000	1.11
+++ apache_request.h	10 Jul 2003 18:56:26 -0000
@@ -100,6 +100,8 @@
     ((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);
+array_header *ApacheRequest_query_keys(ApacheRequest *req);
+array_header *ApacheRequest_post_keys(ApacheRequest *req);
 
 FILE *ApacheRequest_tmpfile(ApacheRequest *req, ApacheUpload *upload);
 ApacheUpload *ApacheUpload_new(ApacheRequest *req);



Index: apache_request.c
===================================================================
RCS file: /home/cvspublic/httpd-apreq/c/apache_request.c,v
retrieving revision 1.25
diff -u -r1.25 apache_request.c
--- apache_request.c	30 Apr 2003 14:53:09 -0000	1.25
+++ apache_request.c	10 Jul 2003 18:56:20 -0000
@@ -193,6 +193,33 @@
     return (table *)a;
 }
 
+static int make_keys(void *data, const char *key, const char *val) 
+{                        
+  array_header *arr = (array_header *)data; 
+  *(char **)ap_push_array(arr) = (char *)key;
+  return 1; 
+} 
+ 
+array_header *ApacheRequest_query_keys(ApacheRequest *req)
+{
+  table *queryparams;
+  array_header *values = ap_make_array(req->r->pool, 4, sizeof(char *));
+  ApacheRequest_parse(req);
+  queryparams = ApacheRequest_query_params(req, req->r->pool);
+  ap_table_do(make_keys, (void*)values, queryparams, NULL, NULL); 
+  return values;
+}
+
+array_header *ApacheRequest_post_keys(ApacheRequest *req)
+{
+  table *postparams;
+  array_header *values = ap_make_array(req->r->pool, 4, sizeof(char *));
+  ApacheRequest_parse(req);
+  postparams = ApacheRequest_post_params(req, req->r->pool);
+  ap_table_do(make_keys, (void*)values, postparams, NULL, NULL); 
+  return values;
+}
+
 ApacheUpload *ApacheUpload_new(ApacheRequest *req)
 {
     ApacheUpload *upload = (ApacheUpload *)

Mime
View raw message