Author: joes
Date: Tue Feb 22 15:35:21 2005
New Revision: 154913
URL: http://svn.apache.org/viewcvs?view=rev&rev=154913
Log:
XS-ify APR::Request::Apache2::param().
Ensure the C semantics match the original perl semantics
of Apache::Request::param().
Modified:
httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache/Request.pm
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Apache2/APR__Request__Apache2.h
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.xs
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_functions.map
httpd/apreq/branches/multi-env-unstable/library/module.c
Modified:
httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache/Request.pm
URL:
http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache/Request.pm?view=diff&r1=154912&r2=154913
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache/Request.pm
(original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/lib/Apache/Request.pm Tue
Feb 22 15:35:21 2005
@@ -3,18 +3,6 @@
use Apache::RequestRec;
push our @ISA, qw/Apache::RequestRec APR::Request::Apache2/;
-sub param {
- return &APR::Request::args, &APR::Request::body
- if wantarray;
-
- return &APR::Request::param
- if @_ == 2;
-
- my $req = shift;
- return APR::Request::params($req, $req->pool);
-
-}
-
package Apache::Upload;
use APR::Request::Param;
Modified:
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Apache2/APR__Request__Apache2.h
URL:
http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Apache2/APR__Request__Apache2.h?view=diff&r1=154912&r2=154913
==============================================================================
---
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Apache2/APR__Request__Apache2.h
(original)
+++
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Apache2/APR__Request__Apache2.h
Tue Feb 22 15:35:21 2005
@@ -1 +1,97 @@
#include "mod_perl.h"
+#include "apreq_xs_tables.h"
+#define TABLE_CLASS "APR::Request::Param"
+
+static int apreq_xs_table_keys(void *data, const char *key, const char *val)
+{
+ struct apreq_xs_do_arg *d = (struct apreq_xs_do_arg *)data;
+ dTHXa(d->perl);
+ dSP;
+ apreq_param_t *p = apreq_value_to_param(val);
+ SV *sv = newSVpv(key, 0);
+ if (apreq_param_is_tainted(p))
+ SvTAINTED_on(sv);
+
+ XPUSHs(sv_2mortal(sv));
+ PUTBACK;
+ return 1;
+}
+
+static int apreq_xs_table_values(void *data, const char *key, const char *val)
+{
+ struct apreq_xs_do_arg *d = (struct apreq_xs_do_arg *)data;
+ dTHXa(d->perl);
+ dSP;
+ apreq_param_t *p = apreq_value_to_param(val);
+ SV *sv = apreq_xs_param2sv(aTHX_ p, d->pkg, d->parent);
+
+ XPUSHs(sv_2mortal(sv));
+ PUTBACK;
+ return 1;
+}
+
+static XS(apreq_xs_apache2_param)
+{
+ dXSARGS;
+ apreq_handle_t *req;
+ SV *sv, *obj;
+ IV iv;
+
+ if (items == 0 || items > 2 || !SvROK(ST(0))
+ || !sv_derived_from(ST(0), "APR::Request::Apache2"))
+ Perl_croak(aTHX_ "Usage: APR::Request::Apache2::param($req [,$name])");
+
+ sv = ST(0);
+ obj = apreq_xs_sv2object(aTHX_ sv, HANDLE_CLASS, 'r');
+ iv = SvIVX(obj);
+ req = INT2PTR(apreq_handle_t *, iv);
+
+ if (items == 2 && GIMME_V == G_SCALAR) {
+ apreq_param_t *p = apreq_param(req, SvPV_nolen(ST(1)));
+
+ if (p != NULL) {
+ ST(0) = apreq_xs_param2sv(aTHX_ p, NULL, obj);
+ sv_2mortal(ST(0));
+ XSRETURN(1);
+ }
+ else {
+ XSRETURN_UNDEF;
+ }
+ }
+ else {
+ struct apreq_xs_do_arg d = {NULL, NULL, NULL, aTHX};
+ request_rec *r;
+ const apr_table_t *t;
+
+ r = modperl_xs_sv2request_rec(aTHX_ sv, "Apache::RequestRec", cv);
+ t = apreq_params(req, r->pool);
+
+ if (t == NULL)
+ XSRETURN_EMPTY;
+
+ d.pkg = NULL;
+ d.parent = obj;
+
+ switch (GIMME_V) {
+
+ case G_ARRAY:
+ XSprePUSH;
+ PUTBACK;
+ if (items == 1)
+ apr_table_do(apreq_xs_table_keys, &d, t, NULL);
+ else
+ apr_table_do(apreq_xs_table_values, &d, t,
+ SvPV_nolen(ST(1)), NULL);
+ return;
+
+ case G_SCALAR:
+ ST(0) = apreq_xs_table2sv(aTHX_ t, TABLE_CLASS, obj,
+ PARAM_CLASS, sizeof(PARAM_CLASS) -1);
+ sv_2mortal(ST(0));
+ XSRETURN(1);
+
+ default:
+ XSRETURN(0);
+ }
+ }
+}
Modified:
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.xs
URL:
http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.xs?view=diff&r1=154912&r2=154913
==============================================================================
---
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.xs
(original)
+++
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/APR/Request/Param/Param.xs
Tue Feb 22 15:35:21 2005
@@ -424,7 +424,7 @@
if (param == NULL)
RETVAL = &PL_sv_undef;
else
- RETVAL = apreq_xs_param2sv(aTHX_ param, PARAM_CLASS, obj);
+ RETVAL = apreq_xs_param2sv(aTHX_ param, NULL, obj);
OUTPUT:
Modified:
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_functions.map
URL:
http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_functions.map?view=diff&r1=154912&r2=154913
==============================================================================
---
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_functions.map
(original)
+++
httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_functions.map
Tue Feb 22 15:35:21 2005
@@ -118,8 +118,9 @@
MODULE=APR::Request PACKAGE=APR::Request PREFIX=APR__Request_
DEFINE_parse | apreq_xs_parse |
-MODULE=APR::Request::Apache2 PACKAGE=APR::Request::Apache2
+MODULE=APR::Request::Apache2 PACKAGE=APR::Request::Apache2
PREFIX=APR__Request__Apache2_
apreq_xs_handle_apache2_t *:DEFINE_new | apreq_handle_apache2 (r) | const char
*:class, request_rec *:r
+DEFINE_param | apreq_xs_apache2_param |
MODULE=APR::Request::CGI PACKAGE=APR::Request::CGI
apreq_xs_handle_cgi_t *:DEFINE_new | apreq_handle_cgi (p) | const char
*:class, apr_pool_t *:p
Modified: httpd/apreq/branches/multi-env-unstable/library/module.c
URL:
http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/library/module.c?view=diff&r1=154912&r2=154913
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/library/module.c (original)
+++ httpd/apreq/branches/multi-env-unstable/library/module.c Tue Feb 22
15:35:21 2005
@@ -101,14 +101,16 @@
APREQ_DECLARE(apr_table_t *)apreq_params(apreq_handle_t *req, apr_pool_t *p)
{
const apr_table_t *args, *body;
+ apreq_args(req, &args);
+ apreq_body(req, &body);
- if (apreq_args(req, &args) == APR_SUCCESS)
- if (apreq_body(req, &body) == APR_SUCCESS)
+ if (args != NULL)
+ if (body != NULL)
return apr_table_overlay(p, args, body);
else
return apr_table_copy(p, args);
else
- if (apreq_body(req, &body) == APR_SUCCESS)
+ if (body != NULL)
return apr_table_copy(p, body);
else
return NULL;