joes 2004/06/07 21:13:36
Modified: . CHANGES STATUS
glue/perl/t/response/TestApReq request.pm
glue/perl/xsbuilder/Apache/Request Apache__Request.h
Request_pod
glue/perl/xsbuilder/maps apreq_functions.map
Log:
Add Apache::Upload::slurp().
Revision Changes Path
1.33 +5 -1 httpd-apreq-2/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/httpd-apreq-2/CHANGES,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- CHANGES 4 Jun 2004 22:02:11 -0000 1.32
+++ CHANGES 8 Jun 2004 04:13:36 -0000 1.33
@@ -3,7 +3,11 @@
@section v2_03_dev Changes with libapreq2-2.03-dev
-- C API [joes]
+- Perl API [joes]
+ Added $upload->slurp($data), which reads the contents of the file
+ upload "$upload" into the scalar "$data".
+
+- C API [joes, randyk]
apreq_run_(hook|parser) are macros, so they are capitalized now.
Fixed apreq_params_as_string() and added apreq_params_as_array().
Reworked definitions of APREQ_DECLARE_HOOK, APREQ_DECLARE_PARSER
1.47 +1 -3 httpd-apreq-2/STATUS
Index: STATUS
===================================================================
RCS file: /home/cvs/httpd-apreq-2/STATUS,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- STATUS 4 Jun 2004 22:02:11 -0000 1.46
+++ STATUS 8 Jun 2004 04:13:36 -0000 1.47
@@ -73,8 +73,6 @@
- symbol exports files:
-# aix needs .exp files
- - Add $upload->slurp to perl API.
-
OPEN ISSUES:
1.8 +2 -8 httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm
Index: request.pm
===================================================================
RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- request.pm 28 Feb 2004 05:16:11 -0000 1.7
+++ request.pm 8 Jun 2004 04:13:36 -0000 1.8
@@ -23,14 +23,8 @@
}
elsif ($test eq 'upload') {
my ($upload) = values %{$req->upload};
-# unlink("/home/joe/tmp/foo");
- my $bb = $upload->bb;
- while (my $b = $bb->first) {
- $b->read(my $buffer);
- $r->print($buffer);
- $b->remove;
- }
-# $upload->link("/home/joe/tmp/foo");
+ $upload->slurp(my $data);
+ $r->print($data);
}
return 0;
1.25 +34 -0
httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Apache__Request.h
Index: Apache__Request.h
===================================================================
RCS file:
/home/cvs/httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Apache__Request.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- Apache__Request.h 16 Apr 2004 16:37:55 -0000 1.24
+++ Apache__Request.h 8 Jun 2004 04:13:36 -0000 1.25
@@ -171,6 +171,40 @@
}
+static XS(apreq_xs_upload_slurp)
+{
+ dXSARGS;
+ MAGIC *mg;
+ void *env;
+ char *data;
+ apr_off_t len;
+ apr_bucket_brigade *bb;
+ apr_bucket *e;
+ apr_status_t s;
+
+ if (items != 2 || !SvROK(ST(0)))
+ Perl_croak(aTHX_ "Usage: $upload->slurp($data)");
+
+ if (!(mg = mg_find(SvRV(ST(0)), PERL_MAGIC_ext)))
+ Perl_croak(aTHX_ "$upload->slurp($data): can't find env");
+
+ env = mg->mg_ptr;
+ bb = apreq_xs_rv2param(ST(0))->bb;
+
+ s = apr_brigade_length(bb, 0, &len);
+ if (s != APR_SUCCESS)
+ XSRETURN_IV(s);
+
+ SvUPGRADE(ST(1), SVt_PV);
+ data = SvGROW(ST(1), len + 1);
+ data[len] = 0;
+ SvCUR_set(ST(1), len);
+ SvPOK_only(ST(1));
+
+ s = apr_brigade_flatten(bb, data, &len);
+ XSRETURN_IV(s);
+}
+
static XS(apreq_xs_request_config)
{
dXSARGS;
1.9 +10 -0
httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Request_pod
Index: Request_pod
===================================================================
RCS file:
/home/cvs/httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Request_pod,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Request_pod 16 Apr 2004 16:37:55 -0000 1.8
+++ Request_pod 8 Jun 2004 04:13:36 -0000 1.9
@@ -246,6 +246,16 @@
Typically the new name must lie on the same file system as the
brigade's tempfile. Check your system's link(2) manpage for details.
+=head2 slurp
+
+Reads the full contents of a file upload into the scalar argument.
+The return value is the APR status code (0 on success, error otherwise).
+
+ # print out the upload file
+ my $contents;
+ print $contents if $upload->slurp($contents) == 0;
+
+
=head1 SEE ALSO
APR::Table(3)
1.17 +1 -0
httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_functions.map
Index: apreq_functions.map
===================================================================
RCS file:
/home/cvs/httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_functions.map,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- apreq_functions.map 24 Mar 2004 08:22:48 -0000 1.16
+++ apreq_functions.map 8 Jun 2004 04:13:36 -0000 1.17
@@ -30,6 +30,7 @@
char *:DEFINE_filename | apreq_param_value(apreq_xs_rv2param(sv))
| SV *:sv
apr_status_t:DEFINE_status | apreq_param_status(apreq_xs_rv2param(sv))
| SV *:sv
DEFINE_link | apreq_xs_upload_link |
+ DEFINE_slurp | apreq_xs_upload_slurp |
MODULE=Apache::Request PACKAGE=Apache::Upload::Table
PREFIX=Apache__Upload__Table_
DEFINE_get | apreq_xs_upload_table_get |