Author: ianjoyce
Date: Mon Aug 1 07:24:24 2005
New Revision: 182
Added:
mod_parrot/branches/autogen/cc_test.imc
- copied unchanged from r180, mod_parrot/trunk/cc_test.imc
mod_parrot/branches/autogen/eg/mod_pugs-handler.p6
- copied unchanged from r180, mod_parrot/trunk/eg/mod_pugs-handler.p6
mod_parrot/branches/autogen/eg/mod_pugs-httpd.conf
- copied unchanged from r180, mod_parrot/trunk/eg/mod_pugs-httpd.conf
mod_parrot/branches/autogen/lib/APR/ (props changed)
- copied from r180, mod_parrot/trunk/lib/APR/
mod_parrot/branches/autogen/lib/APR/Table.imc
- copied unchanged from r180, mod_parrot/trunk/lib/APR/Table.imc
mod_parrot/branches/autogen/lib/ModParrot/HLL/pugs.imc
- copied unchanged from r180, mod_parrot/trunk/lib/ModParrot/HLL/pugs.imc
mod_parrot/branches/autogen/lib/pugs/
- copied from r180, mod_parrot/trunk/lib/pugs/
mod_parrot/branches/autogen/lib/pugs/Apache/ (props changed)
- copied from r180, mod_parrot/trunk/lib/pugs/Apache/
mod_parrot/branches/autogen/lib/pugs/Apache/RequestRec.imc
- copied unchanged from r180, mod_parrot/trunk/lib/pugs/Apache/RequestRec.imc
mod_parrot/branches/autogen/t/99mod_pugs.t
- copied unchanged from r180, mod_parrot/trunk/t/99mod_pugs.t
mod_parrot/branches/autogen/t/lib/ModPugs/
- copied from r180, mod_parrot/trunk/t/lib/ModPugs/
mod_parrot/branches/autogen/t/lib/ModPugs/Handler.pm
- copied unchanged from r180, mod_parrot/trunk/t/lib/ModPugs/Handler.pm
Modified:
mod_parrot/branches/autogen/CHANGES
mod_parrot/branches/autogen/Configure.pl
mod_parrot/branches/autogen/Makefile.in
mod_parrot/branches/autogen/README
mod_parrot/branches/autogen/TODO
mod_parrot/branches/autogen/build/lib/Generator/ApacheRequestRec.pm
mod_parrot/branches/autogen/docs/apache-conf.txt
mod_parrot/branches/autogen/docs/nci.txt
mod_parrot/branches/autogen/lib/ (props changed)
mod_parrot/branches/autogen/lib/Apache/ (props changed)
mod_parrot/branches/autogen/lib/Apache/RequestRec.imc
mod_parrot/branches/autogen/lib/ModParrot/ (props changed)
mod_parrot/branches/autogen/lib/ModParrot/HLL/ (props changed)
mod_parrot/branches/autogen/lib/ModParrot/HLL/pir.imc
mod_parrot/branches/autogen/lib/ModParrot/init.imc
mod_parrot/branches/autogen/mod_parrot.c
mod_parrot/branches/autogen/mod_parrot.h
mod_parrot/branches/autogen/modparrot_config.c
mod_parrot/branches/autogen/modparrot_config.h
mod_parrot/branches/autogen/nci.c
mod_parrot/branches/autogen/parrot_util.c
mod_parrot/branches/autogen/t/ (props changed)
mod_parrot/branches/autogen/t/01RequestRec.t
mod_parrot/branches/autogen/t/conf/ (props changed)
mod_parrot/branches/autogen/t/conf/extra.conf.in
mod_parrot/branches/autogen/t/lib/ (props changed)
mod_parrot/branches/autogen/t/lib/ModParrot/TestRun.pm
mod_parrot/branches/autogen/t/lib/handlers.imc
Log:
Merged with trunk.
Modified: mod_parrot/branches/autogen/CHANGES
==============================================================================
--- mod_parrot/branches/autogen/CHANGES (original)
+++ mod_parrot/branches/autogen/CHANGES Mon Aug 1 07:24:24 2005
@@ -1,5 +1,24 @@
$Id$
+0.3-dev
+ * Support for Parrot 0.2.2 (geeksunite)
+ * Support new Parrot calling conventions (still backwards compatible)
+ * All Apache hooks are implemented
+ * The init file is no longer required to be PBC
+ * Include a very simple mod_pugs proof of concept, with tests
+ * ParrotTrace now accepts flags that are passed Parrot's trace facility
+ * Parrot*Handler takes an optional language specifier
+ * Use parrot-config.imc to fetch parrot configuration
+ * Configure.pl no longer requires Apache::Test
+ * ModParrot::NCI::backtrace returns a backtrace string
+ * New APR::Table class
+ * New Apache::RequestRec methods:
+ - notes
+ - main
+ - prev
+ - next
+ - status
+
0.2 March 28, 2004
* Formal support for Parrot 0.1.2 "Phoenix"
* New handlers: authz, access, open_logs
Modified: mod_parrot/branches/autogen/Configure.pl
==============================================================================
--- mod_parrot/branches/autogen/Configure.pl (original)
+++ mod_parrot/branches/autogen/Configure.pl Mon Aug 1 07:24:24 2005
@@ -48,6 +48,21 @@ sub parrot_config
$| = 1;
+print "\n";
+
+my $defines;
+print "Determining Parrot calling conventions...";
+my $out = `$parrot_build_dir/parrot cc_test.imc`;
+chomp($out);
+if ($out eq 'new') {
+ $defines = '-DPARROT_NEW_CALL_CONV';
+}
+else {
+ die 'calling convention test failed!' if $out ne 'old';
+}
+
+print "$out\n";
+
# where are apache includes?
my $apache_include_dir = `$apxs -q INCLUDEDIR`;
@@ -55,7 +70,7 @@ my $apache_include_dir = `$apxs -q INCLU
my $mpm = `$apxs -q MPM_NAME`;
$mpm or die "Couldn't find Apache MPM";
chomp($mpm);
-print "\nConfiguring mod_parrot for $mpm MPM.\n";
+print "Configuring mod_parrot for $mpm MPM.\n";
# we can't use the config verbatim -- apxs chokes on it, so we use what we can
my $cflags = " -I$parrot_build_dir/include";
@@ -71,11 +86,13 @@ my $template;
$template = <MAKEFILE_IN>;
close(MAKEFILE_IN);
}
+$template =~ s/\@DEFINES\@/$defines/g;
$template =~ s/\@CFLAGS\@/$cflags/g;
$template =~ s/\@LDFLAGS\@/$ldflags/g;
$template =~ s/\@LIBS\@/$libs/g;
$template =~ s/\@APXS\@/$apxs/g;
$template =~ s/\@PERL\@/$perl/g;
+$template =~ s/\@PARROT_SOURCE\@/$parrot_build_dir/g;
$template =~ s/\@PARROT\@/$parrot_build_dir\/parrot/g;
$template =~ s/\@APACHE_INCLUDE_DIR\@/$apache_include_dir/g;
open(MAKEFILE, ">Makefile") or die $!;
@@ -83,24 +100,30 @@ print MAKEFILE $template;
close(MAKEFILE);
print "done.\n";
-# don't use installed mod_parrot
-package ModParrot::TestRun;
-use base Apache::TestRun;
-use Apache::TestConfig;
-
-sub pre_configure
-{
- my $self = shift;
- Apache::TestConfig::autoconfig_skip_module_add('mod_parrot.c');
- $self->SUPER::pre_configure();
-}
-
-package main;
-use Apache::TestMM;
print "Creating testing infrastructure...";
-push(@ARGV, '-apxs', $apxs);
-Apache::TestMM::filter_args();
-ModParrot::TestRun->generate_script();
-print "done.\n";
+eval "use Apache::TestConfig;";
+unless ($@) {
+ # don't use installed mod_parrot
+ package ModParrot::TestRun;
+ use base Apache::TestRun;
+ use Apache::TestConfig;
+
+ sub pre_configure
+ {
+ my $self = shift;
+ Apache::TestConfig::autoconfig_skip_module_add('mod_parrot.c');
+ $self->SUPER::pre_configure();
+ }
+
+ package main;
+ use Apache::TestMM;
+ push(@ARGV, '-apxs', $apxs);
+ Apache::TestMM::filter_args();
+ ModParrot::TestRun->generate_script();
+ print "done.\n";
+}
+else {
+ print "missing Apache::Test -- SKIPPING.\n";
+}
print "\nType 'make' to build mod_parrot.\n\n";
Modified: mod_parrot/branches/autogen/Makefile.in
==============================================================================
--- mod_parrot/branches/autogen/Makefile.in (original)
+++ mod_parrot/branches/autogen/Makefile.in Mon Aug 1 07:24:24 2005
@@ -2,25 +2,30 @@
# This file is autogenerated. Changes will be lost after reconfiguration.
+DEFINES=@DEFINES@
CFLAGS=@CFLAGS@
LDFLAGS=@LDFLAGS@
LIBS=@LIBS@
PERL=@PERL@
APXS=@APXS@
+PARROT_SOURCE=@PARROT_SOURCE@
PARROT=@PARROT@
APACHE_INCLUDE_DIR=@APACHE_INCLUDE_DIR@
SOURCE_FILES=mod_parrot.c parrot_util.c modparrot_config.c nci.c context.c
+PARROT_OBJS=$(PARROT_SOURCE)/src/parrot_config.o
MPLIBS= lib/Apache/RequestRec \
lib/Apache/Constants \
+ lib/APR/Table \
lib/ModParrot/init \
+ t/lib/handlers \
lib/ModParrot/HLL/pir \
- t/lib/handlers
+ lib/ModParrot/HLL/pugs
all: gen-src mod_parrot.la
mod_parrot.la: $(SOURCE_FILES)
- $(APXS) -c $(CFLAGS) $(LDFLAGS) $(LIBS) $(SOURCE_FILES)
+ $(APXS) -c $(DEFINES) $(CFLAGS) $(LDFLAGS) $(LIBS) $(SOURCE_FILES) $(PARROT_OBJS)
files-clean:
rm -f *.o *.lo *.slo *.la core core.*
@@ -62,7 +67,7 @@ install: mod_parrot.la
$(APXS) -i -n parrot -a mod_parrot.la
nci_sig_test: nci_sig_test.o
- $(CC) -o $@ $(CFLAGS) nci_sig_test.c $(LDFLAGS) $(LIBS)
+ $(CC) -o $@ $(CFLAGS) nci_sig_test.c $(PARROT_OBJS) $(LDFLAGS) $(LIBS)
test: mod_parrot.la libraries nci_sig_test
$(PERL) t/TEST t/*.t
Modified: mod_parrot/branches/autogen/README
==============================================================================
--- mod_parrot/branches/autogen/README (original)
+++ mod_parrot/branches/autogen/README Mon Aug 1 07:24:24 2005
@@ -24,7 +24,7 @@ There are no plans to backport it to Apa
REQUIREMENTS
------------
* Apache 2.0
-* Parrot version 0.1.2 (Phoenix) or later
+* Parrot source from SVN r8028 or later
* Perl 5.6.0 or later
* Apache::Test 1.13 or later (for tests)
@@ -40,6 +40,8 @@ To install:
4) make
5) make libraries
6) make test (requires Apache::Test)
+ NOTE: Apache may dump core *after* all tests have succeeded. This is a
+ problem with Apache and does not indicate a test failure.
7) make install
8) Copy the lib directory to a directory of your choosing. This *should* be
installed in a more standard place, but we'll just copy it anywhere for now.
@@ -88,7 +90,7 @@ CONFIGURING APACHE
EXAMPLES
--------
-See the "eg" directory for simple examples of PIR handlers.
+See the "eg" directory for simple examples of various handlers.
DOCUMENTATION
-------------
@@ -107,6 +109,3 @@ Code might be loaded multiple times, cau
When changing handler code, you should stop and start Apache instead of using
apachectl restart".
-
-ParrotTrace may cause core dumps due to a bug in Parrot's tracing mechanism.
-Unfortunately, this bug has yet to be formally identified.
Modified: mod_parrot/branches/autogen/TODO
==============================================================================
--- mod_parrot/branches/autogen/TODO (original)
+++ mod_parrot/branches/autogen/TODO Mon Aug 1 07:24:24 2005
@@ -1,4 +1,3 @@
-* implement more handlers
* make configuration more robust (the config info from parrot leaves much to
the imagination)
* use parrot test harness once it's available (geoff young, chromatic)
Modified: mod_parrot/branches/autogen/build/lib/Generator/ApacheRequestRec.pm
==============================================================================
--- mod_parrot/branches/autogen/build/lib/Generator/ApacheRequestRec.pm (original)
+++ mod_parrot/branches/autogen/build/lib/Generator/ApacheRequestRec.pm Mon Aug 1 07:24:24 2005
@@ -43,11 +43,11 @@ sub build_attribs
foreach my $record (@$map) {
if ($record->{'return_type'} eq 'int') {
- $record->{'sig'} = 'ipii';
+ $record->{'sig'} = 'iJpii';
$record->{'imc_type'} = 'int';
}
else {
- $record->{'sig'} = 'tpt';
+ $record->{'sig'} = 'tJpt';
$record->{'imc_type'} = 'string';
}
}
@@ -126,7 +126,7 @@ sub get_imc_int_template
my $self = shift;
my $template = <<'END'
-.sub %%NAME%% method, prototyped
+.sub %%NAME%% method
.param int data
.local pmc r
.local int offset
@@ -161,7 +161,7 @@ sub get_imc_string_template
my $self = shift;
my $template = <<'END'
-.sub %%NAME%% method, prototyped
+.sub %%NAME%% method
.param %%IMC_TYPE%% data
.local pmc r
.local int offset
@@ -210,7 +210,7 @@ sub get_c_int_template
my $self = shift;
my $template = <<'END'
-%%RETURN_TYPE%% mpnci_request_rec_%%NAME%%(request_rec *r, int %%NAME%%, int update_r)
+%%RETURN_TYPE%% mpnci_request_rec_%%NAME%%(Parrot_Interp interp, request_rec *r, int %%NAME%%, int update_r)
{
if (update_r == 1) {
r->%%NAME%% = %%NAME%%;
@@ -229,7 +229,7 @@ sub get_c_char_template
my $self = shift;
my $template = <<'END'
-%%RETURN_TYPE%%mpnci_request_rec_%%NAME%%(request_rec *r, char *%%NAME%%)
+%%RETURN_TYPE%%mpnci_request_rec_%%NAME%%(Parrot_Interp interp, request_rec *r, char *%%NAME%%)
{
if (%%NAME%%) {
r->%%NAME%% = (char *)apr_pstrdup(r->pool, %%NAME%%);
Modified: mod_parrot/branches/autogen/docs/apache-conf.txt
==============================================================================
--- mod_parrot/branches/autogen/docs/apache-conf.txt (original)
+++ mod_parrot/branches/autogen/docs/apache-conf.txt Mon Aug 1 07:24:24 2005
@@ -17,11 +17,11 @@ Description: Load PBC, PIR, or high leve
ParrotTrace
-----------
-Syntax: ParrotTrace on|off
+Syntax: ParrotTrace level
Default: off
Context: server config
-Description: Enable Parrot trace output to the error log. Bugs in Parrot
- may cause Apache to core dump when this is enabled.
+Description: Enable Parrot trace output to the error log. See Parrot docs
+ for the appropriate trace levels.
ParrotLanguage
--------------
@@ -34,28 +34,30 @@ Description: Sets the Parrot language fo
ParrotHandler
-------------
-Syntax: ParrotHandler handler
+Syntax: ParrotHandler [hll,]handler
Default: none
Context: directory config
-Description: Sets the Parrot content handler
+Description: Sets the Parrot content handler (hll overrides directory config)
ParrotAuthenHandler
-------------------
-Syntax: ParrotAuthenHandler handler
+Syntax: ParrotAuthenHandler [hll,]handler
Default: none
Context: directory config
-Description: Sets the Parrot authentication handler
+Description: Sets the Parrot authentication handler (hll overrides directory
+ config)
ParrotAuthzHandler
------------------
-Syntax: ParrotAuthzHandler handler
+Syntax: ParrotAuthzHandler [hll,]handler
Default: none
Context: directory config
-Description: Sets the Parrot authorization handler
+Description: Sets the Parrot authorization handler (hll overrides directory
+ config)
ParrotAccessHandler
-------------------
-Syntax: ParrotAccessHandler handler
+Syntax: ParrotAccessHandler [hll,]handler
Default: none
Context: directory config
-Description: Sets the Parrot access handler
+Description: Sets the Parrot access handler (hll overrides directory config)
Modified: mod_parrot/branches/autogen/docs/nci.txt
==============================================================================
--- mod_parrot/branches/autogen/docs/nci.txt (original)
+++ mod_parrot/branches/autogen/docs/nci.txt Mon Aug 1 07:24:24 2005
@@ -23,7 +23,7 @@ C wrappers in the mod_parrot source:
3) mod_parrot functions that should be callable via NCI should be placed in
nci.c and defined in the Parrot namespace ModParrot::NCI. The first
argument passed to the function should be the Parrot interpreter, which
- Parrot will handle for you if you use the 'I' signature. Each function
+ Parrot will handle for you if you use the 'J' signature. Each function
should be prefixed with mpnci_. The PIR code to load these objects should
be placed in lib/ModParrot/init.imc.
@@ -38,5 +38,12 @@ C wrappers in the mod_parrot source:
more stable, a proposal will be made to add the list to the Parrot source.
The test suite will automatically test for any signatures in call_list.txt.
+6) In order to maintain state between the calling Apache process and the NCI
+ function, we use the interpreter object, which we can pass to each NCI
+ function via the 'J' signature. Each interpreter contains a context
+ structure (an UnmanagedStruct PMC) at ModParrot::__context that points
+ to a modparrot_context structure. Use get_interp_ctx() to fetch this in
+ your NCI code. See mod_parrot.h for details.
+
NOTE: The namespaces used in this document are subject to change as Parrot's
namespace conventions become clearer.
Modified: mod_parrot/branches/autogen/lib/Apache/RequestRec.imc
==============================================================================
--- mod_parrot/branches/autogen/lib/Apache/RequestRec.imc (original)
+++ mod_parrot/branches/autogen/lib/Apache/RequestRec.imc Mon Aug 1 07:24:24 2005
@@ -42,7 +42,7 @@ class, but is in no way tied to mod_perl
.namespace [ 'Apache::RequestRec' ]
-.sub _initialize prototyped, @LOAD
+.sub _initialize @LOAD
.local pmc rr_class
.local pmc func
.local pmc nul
@@ -72,15 +72,24 @@ class, but is in no way tied to mod_perl
dlfunc func, nul, "ap_note_basic_auth_failure", "vp"
store_global "Apache::NCI", "ap_note_basic_auth_failure", func
+
+ dlfunc func, nul, "ap_custom_response", "vpit"
+ store_global "Apache::NCI", "ap_custom_response", func
.end
.sub __init method
+ .param pmc new_r
.local pmc request_rec
.local pmc r
.local int offset
+ isnull new_r, GET_R
+ r = new_r
+ goto SETUP_R
+GET_R:
find_global request_rec, 'ModParrot::NCI', 'request_rec'
r = request_rec( )
+SETUP_R:
classoffset offset, self, 'Apache::RequestRec'
setattribute self, offset, r
.end
@@ -97,7 +106,7 @@ Outputs a string into the HTTP content.
=cut
-.sub puts method, prototyped
+.sub puts method
.param string data
.local pmc r
.local pmc ap_rputs
@@ -119,8 +128,9 @@ Outputs an int into the HTTP content. N
=cut
-.sub putc method, prototyped
+.sub putc method
.param int data
+ .param int size
.local pmc r
.local pmc ap_rputc
.local int offset
@@ -148,7 +158,7 @@ THIS METHOD IS EXPERIMENTAL!
=cut
-.sub write method, prototyped
+.sub write method
.param pmc data
.param int size
.local pmc r
@@ -166,29 +176,30 @@ THIS METHOD IS EXPERIMENTAL!
.pcc_end_return
.end
-=item C<STRING hostname()>
+=item C<STRING filename([STRING filename])>
=over 4
-Returns the hostname for the current request.
+Get or set the local filename corresponding to the request's URI.
=back
=cut
-.sub hostname method, prototyped
+.sub filename method
+ .param string f
.local pmc r
- .local pmc request_rec_hostname
+ .local pmc request_rec_filename
.local int offset
- .local string hostname
-
+ .local string filename
+
classoffset offset, self, 'Apache::RequestRec'
getattribute r, self, offset
- find_global request_rec_hostname, 'ModParrot::NCI', 'request_rec_hostname'
- hostname = request_rec_hostname( r )
+ find_global request_rec_filename, 'ModParrot::NCI', 'request_rec_filename'
+ filename = request_rec_filename( r, f )
.pcc_begin_return
- .return hostname
+ .return filename
.pcc_end_return
.end
@@ -206,7 +217,7 @@ message to be written into the error log
=cut
-.sub log_rerror method, prototyped
+.sub log_rerror method
.param string file
.param int line
.param int level
@@ -233,7 +244,7 @@ requested with the C<user> method.
=cut
-.sub get_basic_auth_pw method, prototyped
+.sub get_basic_auth_pw method
.local pmc r
.local int offset
.local pmc request_rec_get_basic_auth_pw
@@ -246,9 +257,10 @@ requested with the C<user> method.
# password will be stored in S15
status = request_rec_get_basic_auth_pw( r )
+ # new calling conventions
.pcc_begin_return
- .return S15
.return status
+ .return S15
.pcc_end_return
.end
@@ -263,7 +275,7 @@ otherwise.
=cut
-.sub is_initial_req method, prototyped
+.sub is_initial_req method
.local pmc r
.local int offset
.local pmc ap_is_initial_req
@@ -289,7 +301,7 @@ Returns the authentication name for the
=cut
-.sub auth_name method, prototyped
+.sub auth_name method
.local pmc r
.local int offset
.local pmc ap_auth_name
@@ -316,7 +328,7 @@ for basic authentication.
=cut
-.sub note_basic_auth_failure method, prototyped
+.sub note_basic_auth_failure method
.local pmc r
.local int offset
.local pmc ap_note_basic_auth_failure
@@ -338,7 +350,7 @@ Returns the authentication type for the
=cut
-.sub auth_type method, prototyped
+.sub auth_type method
.local pmc r
.local int offset
.local pmc ap_auth_type
@@ -354,6 +366,145 @@ Returns the authentication type for the
.pcc_end_return
.end
+=item C<PMC notes()>
+
+=over 4
+
+Returns the request's notes table as an APR::Table object.
+
+=back
+
+=cut
+
+.sub notes method
+ .local pmc r
+ .local pmc notes
+ .local pmc t
+ .local pmc request_rec_notes
+ .local int offset
+
+ classoffset offset, self, 'Apache::RequestRec'
+ getattribute r, self, offset
+
+ find_global request_rec_notes, 'ModParrot::NCI', 'request_rec_notes'
+ notes = request_rec_notes( r )
+
+ find_type $I0, 'APR::Table'
+ t = new $I0, notes
+
+ .pcc_begin_return
+ .return t
+ .pcc_end_return
+.end
+
+=item C<PMC main()>
+
+=over 4
+
+Returns the the main request at the top of the chain.
+
+=back
+
+=cut
+
+.sub main method
+ .local pmc r
+ .local pmc main_r
+ .local pmc request_rec_main
+ .local int offset
+
+ classoffset offset, self, 'Apache::RequestRec'
+ getattribute r, self, offset
+
+ find_global request_rec_main, 'ModParrot::NCI', 'request_rec_main'
+ main_r = request_rec_main( r )
+
+ .pcc_begin_return
+ .return main_r
+ .pcc_end_return
+.end
+
+=item C<PMC next()>
+
+=over 4
+
+Returns the the redirected request if this is an external redirect.
+
+=back
+
+=cut
+
+.sub next method
+ .local pmc r
+ .local pmc next_r
+ .local pmc request_rec_next
+ .local int offset
+
+ classoffset offset, self, 'Apache::RequestRec'
+ getattribute r, self, offset
+
+ find_global request_rec_next, 'ModParrot::NCI', 'request_rec_next'
+ next_r = request_rec_next( r )
+
+ .pcc_begin_return
+ .return next_r
+ .pcc_end_return
+.end
+
+=item C<PMC prev()>
+
+=over 4
+
+Returns the the previous request if this is an internal redirect.
+
+=back
+
+=cut
+
+.sub prev method
+ .local pmc r
+ .local pmc prev_r
+ .local pmc request_rec_prev
+ .local int offset
+
+ classoffset offset, self, 'Apache::RequestRec'
+ getattribute r, self, offset
+
+ find_global request_rec_prev, 'ModParrot::NCI', 'request_rec_prev'
+ $P0 = request_rec_prev( r )
+ $I0 = find_type 'Apache::RequestRec'
+ prev_r = new $I0, $P0
+
+ .pcc_begin_return
+ .return prev_r
+ .pcc_end_return
+.end
+
+=item C<custom_response(INT status, STRING response)>
+
+=over 4
+
+Set a custom response for a particular status. The response can be either a
+string to send back to the client or a URI.
+
+=back
+
+=cut
+
+.sub custom_response method
+ .param int status
+ .param string response
+ .local pmc r
+ .local pmc ap_custom_response
+ .local int offset
+
+ classoffset offset, self, 'Apache::RequestRec'
+ getattribute r, self, offset
+
+ find_global ap_custom_response, 'Apache::NCI', 'ap_custom_response'
+ ap_custom_response(r, status, response)
+.end
+
=back
=head1 AUTHOR
Modified: mod_parrot/branches/autogen/lib/ModParrot/HLL/pir.imc
==============================================================================
--- mod_parrot/branches/autogen/lib/ModParrot/HLL/pir.imc (original)
+++ mod_parrot/branches/autogen/lib/ModParrot/HLL/pir.imc Mon Aug 1 07:24:24 2005
@@ -1,6 +1,9 @@
.namespace [ 'ModParrot::HLL::PIR' ]
-#.sub _load
+.sub _load
+ .param string path
+ load_bytecode path
+.end
#.sub _config
@@ -100,15 +103,48 @@
.local int status
# get the pool objects
- find_global func, 'ModParrot', 'mpnci_conf_pool'
+ find_global func, 'ModParrot::NCI', 'conf_pool'
+ pconf = func()
+ find_global func, 'ModParrot::NCI', 'log_pool'
+ plog = func()
+ find_global func, 'ModParrot::NCI', 'temp_pool'
+ ptemp = func()
+
+ # get the server_rec object
+ find_global func, 'ModParrot::NCI', 'server_rec'
+ s = func()
+
+ # find the handler sub and call it
+ find_global handler, handler_name, '_handler'
+ status = handler(pconf, plog, ptemp, s)
+
+ # return status code
+ .pcc_begin_return
+ .return status
+ .pcc_end_return
+.end
+
+# post_config handler
+.sub _post_config_handler
+ .param string handler_name
+ .local pmc pconf
+ .local pmc plog
+ .local pmc ptemp
+ .local pmc s
+ .local pmc handler
+ .local pmc func
+ .local int status
+
+ # get the pool objects
+ find_global func, 'ModParrot::NCI', 'conf_pool'
pconf = func()
- find_global func, 'ModParrot', 'mpnci_log_pool'
+ find_global func, 'ModParrot::NCI', 'log_pool'
plog = func()
- find_global func, 'ModParrot', 'mpnci_temp_pool'
+ find_global func, 'ModParrot::NCI', 'temp_pool'
ptemp = func()
# get the server_rec object
- find_global func, 'ModParrot', 'mpnci_server_rec'
+ find_global func, 'ModParrot::NCI', 'server_rec'
s = func()
# find the handler sub and call it
@@ -117,6 +153,235 @@
# return status code
.pcc_begin_return
+ .return status
+ .pcc_end_return
+.end
+
+# child init handler
+.sub _child_init_handler
+ .param string handler_name
+ .local pmc pchild
+ .local pmc s
+ .local pmc handler
+ .local pmc func
+ .local int status
+
+ # get the pool object
+ find_global func, 'ModParrot::NCI', 'child_pool'
+ pchild = func()
+
+ # get the server_rec object
+ find_global func, 'ModParrot::NCI', 'server_rec'
+ s = func()
+
+ # find the handler sub and call it
+ find_global handler, handler_name, '_handler'
+ status = handler(pchild, s)
+
+ # return status code
+ .pcc_begin_return
+ .return status
+ .pcc_end_return
+.end
+
+# pre connection handler
+.sub _pre_connection_handler
+ .param string handler_name
+ .local pmc c
+ .local pmc csd
+ .local pmc handler
+ .local pmc func
+ .local int status
+
+ # get the conn_rec object
+ find_global func, 'ModParrot::NCI', 'conn_rec'
+ c = func()
+
+ # get the csd object
+ find_global func, 'ModParrot::NCI', 'csd'
+ csd = func()
+
+ # find the handler sub and call it
+ find_global handler, handler_name, '_handler'
+ status = handler(c, csd)
+
+ # return status code
+ .pcc_begin_return
+ .return status
+ .pcc_end_return
+.end
+
+# process connection handler
+.sub _process_connection_handler
+ .param string handler_name
+ .local pmc c
+ .local pmc handler
+ .local pmc func
+ .local int status
+
+ # get the pool object
+ find_global func, 'ModParrot::NCI', 'conn_rec'
+ c = func()
+
+ # find the handler sub and call it
+ find_global handler, handler_name, '_handler'
+ status = handler(c)
+
+ # return status code
+ .pcc_begin_return
+ .return status
+ .pcc_end_return
+.end
+
+# trans handler
+.sub _trans_handler
+ .param string handler_name
+ .local pmc r
+ .local pmc handler
+ .local pmc func
+ .local int status
+
+ # get the request_rec object
+ find_type $I0, 'Apache::RequestRec'
+ r = new $I0
+
+ # find the handler sub and call it
+ find_global handler, handler_name, '_handler'
+ status = handler(r)
+
+ # return status code
+ .pcc_begin_return
+ .return status
+ .pcc_end_return
+.end
+
+# fixup handler
+.sub _fixup_handler
+ .param string handler_name
+ .local pmc r
+ .local pmc handler
+ .local pmc func
+ .local int status
+
+ # get the request_rec object
+ find_type $I0, 'Apache::RequestRec'
+ r = new $I0
+
+ # find the handler sub and call it
+ find_global handler, handler_name, '_handler'
+ status = handler(r)
+
+ # return status code
+ .pcc_begin_return
+ .return status
+ .pcc_end_return
+.end
+
+# type handler
+.sub _type_handler
+ .param string handler_name
+ .local pmc r
+ .local pmc handler
+ .local pmc func
+ .local int status
+
+ # get the request_rec object
+ find_type $I0, 'Apache::RequestRec'
+ r = new $I0
+
+ # find the handler sub and call it
+ find_global handler, handler_name, '_handler'
+ status = handler(r)
+
+ # return status code
+ .pcc_begin_return
+ .return status
+ .pcc_end_return
+.end
+
+# log handler
+.sub _log_handler
+ .param string handler_name
+ .local pmc r
+ .local pmc handler
+ .local pmc func
+ .local int status
+
+ # get the request_rec object
+ find_type $I0, 'Apache::RequestRec'
+ r = new $I0
+
+ # find the handler sub and call it
+ find_global handler, handler_name, '_handler'
+ status = handler(r)
+
+ # return status code
+ .pcc_begin_return
+ .return status
+ .pcc_end_return
+.end
+
+# map_to_storage handler
+.sub _map_to_storage_handler
+ .param string handler_name
+ .local pmc r
+ .local pmc handler
+ .local pmc func
+ .local int status
+
+ # get the request_rec object
+ find_type $I0, 'Apache::RequestRec'
+ r = new $I0
+
+ # find the handler sub and call it
+ find_global handler, handler_name, '_handler'
+ status = handler(r)
+
+ # return status code
+ .pcc_begin_return
+ .return status
+ .pcc_end_return
+.end
+
+# post_read_request handler
+.sub _post_read_request_handler
+ .param string handler_name
+ .local pmc r
+ .local pmc handler
+ .local pmc func
+ .local int status
+
+ # get the request_rec object
+ find_type $I0, 'Apache::RequestRec'
+ r = new $I0
+
+ # find the handler sub and call it
+ find_global handler, handler_name, '_handler'
+ status = handler(r)
+
+ # return status code
+ .pcc_begin_return
+ .return status
+ .pcc_end_return
+.end
+
+# header_parser handler
+.sub _header_parser_handler
+ .param string handler_name
+ .local pmc r
+ .local pmc handler
+ .local int status
+
+ # get the request_rec object
+ find_type $I0, 'Apache::RequestRec'
+ r = new $I0
+
+ # find the handler sub and call it
+ find_global handler, handler_name, '_handler'
+ status = handler(r)
+
+ # return status code
+ .pcc_begin_return
.return status
.pcc_end_return
.end
Modified: mod_parrot/branches/autogen/lib/ModParrot/init.imc
==============================================================================
--- mod_parrot/branches/autogen/lib/ModParrot/init.imc (original)
+++ mod_parrot/branches/autogen/lib/ModParrot/init.imc Mon Aug 1 07:24:24 2005
@@ -25,9 +25,27 @@
.include "build/src/imc/request_rec_dlfunc.imc"
+ dlfunc func, nul, "mpnci_backtrace", "tJ"
+ store_global "ModParrot::NCI", "backtrace", func
+
dlfunc func, nul, "mpnci_request_rec", "pJ"
store_global "ModParrot::NCI", "request_rec", func
+ dlfunc func, nul, "mpnci_request_rec_main", "pJp"
+ store_global "ModParrot::NCI", "request_rec_main", func
+
+ dlfunc func, nul, "mpnci_request_rec_next", "pJp"
+ store_global "ModParrot::NCI", "request_rec_next", func
+
+ dlfunc func, nul, "mpnci_request_rec_prev", "pJp"
+ store_global "ModParrot::NCI", "request_rec_prev", func
+
+ dlfunc func, nul, "mpnci_request_rec_user", "tJpt"
+ store_global "ModParrot::NCI", "request_rec_user", func
+
+ dlfunc func, nul, "mpnci_request_rec_notes", "pJp"
+ store_global "ModParrot::NCI", "request_rec_notes", func
+
dlfunc func, nul, "mpnci_request_rec_get_basic_auth_pw", "iJp"
store_global "ModParrot::NCI", "request_rec_get_basic_auth_pw", func
@@ -43,6 +61,15 @@
dlfunc func, nul, "mpnci_log_pool", "pJ"
store_global "ModParrot::NCI", "log_pool", func
+ dlfunc func, nul, "mpnci_child_pool", "pJ"
+ store_global "ModParrot::NCI", "child_pool", func
+
dlfunc func, nul, "mpnci_server_rec", "pJ"
store_global "ModParrot::NCI", "server_rec", func
+ dlfunc func, nul, "mpnci_conn_rec", "pJ"
+ store_global "ModParrot::NCI", "conn_rec", func
+
+ dlfunc func, nul, "mpnci_csd", "pJ"
+ store_global "ModParrot::NCI", "csd", func
+
.end
Modified: mod_parrot/branches/autogen/mod_parrot.c
==============================================================================
--- mod_parrot/branches/autogen/mod_parrot.c (original)
+++ mod_parrot/branches/autogen/mod_parrot.c Mon Aug 1 07:24:24 2005
@@ -37,30 +37,29 @@
#define MODPARROT_VERSION "0.2"
#define DEFAULT_HANDLER "_handler"
-#define SHOULD_HANDLE(x) (r->handler ? \
- (strncmp(r->handler, MODPARROT_MAGIC, strlen(MODPARROT_MAGIC)) ? 0 : 1) : 0)
+#define DEFAULT_HLL_HANDLER "PIR"
+#define SHOULD_HANDLE(x) (x->handler ? \
+ (strncmp(x->handler, MODPARROT_MAGIC, strlen(MODPARROT_MAGIC)) ? 0 : 1) : 0)
/* declare our module */
extern module AP_MODULE_DECLARE_DATA parrot_module;
-static Parrot_Interp modparrot_init(modparrot_context *ctx, modparrot_srv_config *cfg)
+static Parrot_Interp modparrot_init(modparrot_context *ctx, server_rec *s)
{
Parrot_Interp interp;
int i, ret;
+ modparrot_srv_config *cfg;
+
+ cfg = ap_get_module_config(s->module_config, &parrot_module);
/* initialize interpreter */
interp = modparrot_init_interpreter();
- if (cfg->enable_trace) {
- Parrot_set_flag(interp, PARROT_TRACE_FLAG);
- Parrot_set_flag(interp, PARROT_GC_DEBUG_FLAG);
- }
-
- imcc_init(interp);
+ Parrot_set_trace(interp, cfg->trace_flags);
/* run initialization code */
if (cfg->init_path) {
- modparrot_load_bytecode_init(interp, cfg->init_path);
- modparrot_call_sub(interp, "ModParrot", "_modparrot_init", &ret);
+ modparrot_load_bytecode(interp, cfg->init_path);
+ modparrot_call_sub(interp, "ModParrot", "_modparrot_init");
}
/* set our context
@@ -71,18 +70,22 @@ static Parrot_Interp modparrot_init(modp
/* load ParrotLoad files */
for (i = 0; i < cfg->preload->nelts; i++) {
- char *filename = ((char **)cfg->preload->elts)[i];
- char *ext = strrchr(filename, '.');
- /* Parrot_load_bytecode only works for PBC, PASM, and IMC for now */
+ /* char *filename = ((char **)cfg->preload->elts)[i]; */
+ modparrot_handler_info *l =
+ &((modparrot_handler_info *)cfg->preload->elts)[i];
+ char *ext = strrchr(l->id, '.');
+ /* load any PBC files */
if (ext && (!strcmp(ext, ".pbc") || !strcmp(ext, ".imc") ||
- !strcmp(ext, ".pasm"))) {
- modparrot_load_bytecode(interp, filename);
+ !strcmp(ext, ".pir") || !strcmp(ext, ".pasm"))) {
+ modparrot_load_bytecode(interp, l->id);
}
-#if 0
else {
- /* call HLL _load subroutine */
+ /* call the HLL _load handler to handle the loading */
+ if (!modparrot_hll_handler(ctx->interp, l->hll, "_load", l->id,
+ &ret)) {
+ MPLOG_ERRORF(s, "no HLL _load handler for '%s'", l->hll);
+ }
}
-#endif
}
return(interp);
}
@@ -97,7 +100,7 @@ static modparrot_context *init_ctx(serve
if ((ctxp = reserve_ctx())) {
if (!ctxp->interp) {
- if (!(interp = modparrot_init(ctxp, cfg))) {
+ if (!(interp = modparrot_init(ctxp, s))) {
MPLOG_ERROR(s,
"modparrot_ctx_init: interpreter initialization failed");
return (modparrot_context *)NULL;
@@ -116,15 +119,27 @@ static modparrot_context *init_ctx(serve
return(ctxp);
}
+int modparrot_hll_handler(Parrot_Interp interp, char *hll, char *hll_handler,
+ char *handler, int *ret)
+{
+ Parrot_PMC sub;
+ char hll_namespace[255];
+
+ if (!hll) hll = DEFAULT_HLL_HANDLER;
+ sprintf(hll_namespace, "ModParrot::HLL::%s", hll);
+ modparrot_call_sub_IS(interp, hll_namespace, hll_handler, ret, handler);
+ return(1);
+}
+
static int modparrot_handler(request_rec *r)
{
modparrot_dir_config *dircfg;
modparrot_srv_config *cfg;
modparrot_context *ctxp;
int handler_status;
- char *sub;
+ char *sub, *hll;
- /* politely decline request if not our handler */
+ /* politely decline request if we shouldn't be handling this */
if (!SHOULD_HANDLE(r)) {
return DECLINED;
}
@@ -133,6 +148,10 @@ static int modparrot_handler(request_rec
dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
cfg = ap_get_module_config(r->server->module_config, &parrot_module);
+ /* politely decline request if not our parrot response handler */
+ if (!dircfg->handler) {
+ return DECLINED;
+ }
/* set default content type */
r->content_type = "text/html";
@@ -144,17 +163,19 @@ static int modparrot_handler(request_rec
/* initialize context */
if (!(ctxp = init_ctx(r->server))) {
MPLOG_ERRORF(r->server,
- "context initialization failed for handler '%s'", dircfg->handler);
+ "context initialization failed for handler '%s'",
+ dircfg->handler->id);
return HTTP_INTERNAL_SERVER_ERROR;
}
ctxp->r = r;
/* call HLL handler */
sub = "_handler";
- if (!modparrot_hll_handler(ctxp->interp, dircfg->hll, sub, dircfg->handler,
+ hll = dircfg->handler->hll ? dircfg->handler->hll : dircfg->hll;
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub, dircfg->handler->id,
&handler_status)) {
- MPLOG_ERRORF(r->server, "no subroutine found for handler '%s'",
- dircfg->handler);
+ MPLOG_ERRORF(r->server,
+ "no subroutine found for handler '%s'", dircfg->handler->id);
release_ctx(ctxp);
return HTTP_INTERNAL_SERVER_ERROR;
}
@@ -166,13 +187,413 @@ static int modparrot_handler(request_rec
return handler_status;
}
+static int modparrot_pre_connection_handler(conn_rec *c, void *csd)
+{
+ modparrot_srv_config *cfg;
+ modparrot_context *ctxp;
+ int handler_status;
+ char *sub, *hll;
+
+ /* get apache configs */
+ cfg = ap_get_module_config(c->base_server->module_config, &parrot_module);
+
+ /* politely decline request if not our handler */
+ if (!cfg->pre_connection_handler) {
+ return DECLINED;
+ }
+
+ /* initialize context */
+ if (!(ctxp = init_ctx(c->base_server))) {
+ MPLOG_ERROR(c->base_server, "context initialization failed");
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ ctxp->c = c;
+ ctxp->csd = csd;
+
+ /* call HLL handler */
+ sub = "_pre_connection_handler";
+ hll = cfg->pre_connection_handler->hll ?
+ cfg->pre_connection_handler->hll : "PIR";
+
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub,
+ cfg->pre_connection_handler->id, &handler_status)) {
+ MPLOG_ERRORF(c->base_server, "no subroutine found for handler '%s'",
+ cfg->pre_connection_handler->id);
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ /* tell apache we're done */
+}
+
+static int modparrot_map_to_storage_handler(request_rec *r)
+{
+ modparrot_srv_config *cfg;
+ modparrot_context *ctxp;
+ int handler_status;
+ char *sub, *hll;
+
+ /* get apache configs */
+ cfg = ap_get_module_config(r->server->module_config, &parrot_module);
+
+ /* politely decline request if not our handler */
+ if (!cfg->map_to_storage_handler) {
+ return DECLINED;
+ }
+
+ /* initialize context */
+ if (!(ctxp = init_ctx(r->server))) {
+ MPLOG_ERROR(r->server, "context initialization failed");
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ ctxp->r = r;
+
+ /* call HLL handler */
+ sub = "_map_to_storage_handler";
+ hll = cfg->map_to_storage_handler->hll ?
+ cfg->map_to_storage_handler->hll : "PIR";
+
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub,
+ cfg->map_to_storage_handler->id, &handler_status)) {
+ MPLOG_ERRORF(r->server, "no subroutine found for handler '%s'",
+ cfg->map_to_storage_handler->id);
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ /* tell apache we're done */
+ return handler_status;
+}
+
+static int modparrot_header_parser_handler(request_rec *r)
+{
+ modparrot_dir_config *dircfg;
+ modparrot_srv_config *cfg;
+ modparrot_context *ctxp;
+ int handler_status;
+ char *sub, *hll;
+
+ /* get apache configs */
+ dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
+ cfg = ap_get_module_config(r->server->module_config, &parrot_module);
+
+ /* politely decline request if not our handler */
+ if (!dircfg->header_parser_handler) {
+ return DECLINED;
+ }
+
+ /* initialize context */
+ if (!(ctxp = init_ctx(r->server))) {
+ MPLOG_ERROR(r->server, "context initialization failed");
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ ctxp->r = r;
+
+ /* call HLL handler */
+ sub = "_header_parser_handler";
+ hll = dircfg->header_parser_handler->hll ?
+ dircfg->header_parser_handler->hll : "PIR";
+
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub,
+ dircfg->header_parser_handler->id, &handler_status)) {
+ MPLOG_ERRORF(r->server, "no subroutine found for handler '%s'",
+ dircfg->header_parser_handler->id);
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ /* tell apache we're done */
+ return handler_status;
+}
+
+static int modparrot_post_read_request_handler(request_rec *r)
+{
+ modparrot_srv_config *cfg;
+ modparrot_context *ctxp;
+ int handler_status;
+ char *sub, *hll;
+
+ /* get apache configs */
+ cfg = ap_get_module_config(r->server->module_config, &parrot_module);
+
+ /* politely decline request if not our handler */
+ if (!cfg->post_read_request_handler) {
+ return DECLINED;
+ }
+
+ /* initialize context */
+ if (!(ctxp = init_ctx(r->server))) {
+ MPLOG_ERROR(r->server, "context initialization failed");
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ ctxp->r = r;
+
+ /* call HLL handler */
+ sub = "_post_read_request_handler";
+ hll = cfg->post_read_request_handler->hll ?
+ cfg->post_read_request_handler->hll : "PIR";
+
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub,
+ cfg->post_read_request_handler->id, &handler_status)) {
+ MPLOG_ERRORF(r->server, "no subroutine found for handler '%s'",
+ cfg->post_read_request_handler->id);
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ /* tell apache we're done */
+ return handler_status;
+}
+
+static int modparrot_process_connection_handler(conn_rec *c)
+{
+ modparrot_srv_config *cfg;
+ modparrot_context *ctxp;
+ int handler_status;
+ char *sub, *hll;
+
+ /* get apache configs */
+ cfg = ap_get_module_config(c->base_server->module_config, &parrot_module);
+
+ /* politely decline request if not our handler */
+ if (!cfg->process_connection_handler) {
+ return DECLINED;
+ }
+
+ /* initialize context */
+ if (!(ctxp = init_ctx(c->base_server))) {
+ MPLOG_ERROR(c->base_server, "context initialization failed");
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ ctxp->c = c;
+
+ /* call HLL handler */
+ sub = "_process_connection_handler";
+ hll = cfg->process_connection_handler->hll ?
+ cfg->process_connection_handler->hll : "PIR";
+
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub,
+ cfg->process_connection_handler->id, &handler_status)) {
+ MPLOG_ERRORF(c->base_server, "no subroutine found for handler '%s'",
+ cfg->process_connection_handler->id);
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ /* tell apache we're done */
+ return handler_status;
+}
+
+/* XXX - how do we notify apache of failures with a void return??? */
+static void modparrot_child_init_handler(apr_pool_t *p, server_rec *s)
+{
+ modparrot_srv_config *cfg;
+ modparrot_context *ctxp;
+ int handler_status;
+ char *sub, *hll;
+
+ /* get apache configs */
+ cfg = ap_get_module_config(s->module_config, &parrot_module);
+
+ /* politely decline request if not our handler */
+ if (!cfg->child_init_handler) {
+ return;
+ }
+
+ /* initialize context */
+ if (!(ctxp = init_ctx(s))) {
+ MPLOG_ERROR(s, "context initialization failed");
+ return;
+ }
+
+ ctxp->pchild = p;
+ ctxp->s = s;
+
+ /* call HLL handler */
+ sub = "_child_init_handler";
+ hll = cfg->child_init_handler->hll ? cfg->child_init_handler->hll : "PIR";
+
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub,
+ cfg->child_init_handler->id, &handler_status)) {
+ MPLOG_ERRORF(s, "no subroutine found for handler '%s'",
+ cfg->child_init_handler->id);
+ return;
+ }
+
+ /* tell apache we're done */
+ return;
+}
+
+static int modparrot_trans_handler(request_rec *r)
+{
+ modparrot_srv_config *cfg;
+ modparrot_context *ctxp;
+ int handler_status;
+ char *sub, *hll;
+
+ /* get apache configs */
+ cfg = ap_get_module_config(r->server->module_config, &parrot_module);
+
+ /* politely decline request if not our handler */
+ if (!cfg->child_init_handler) {
+ return DECLINED;
+ }
+
+ /* initialize context */
+ if (!(ctxp = init_ctx(r->server))) {
+ MPLOG_ERROR(r->server, "context initialization failed");
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ ctxp->r = r;
+
+ /* call HLL handler */
+ sub = "_trans_handler";
+ hll = cfg->trans_handler->hll ? cfg->trans_handler->hll : "PIR";
+
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub,
+ cfg->trans_handler->id, &handler_status)) {
+ MPLOG_ERRORF(r->server, "no subroutine found for handler '%s'",
+ cfg->trans_handler->id);
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ /* tell apache we're done */
+ return handler_status;
+}
+
+static int modparrot_fixup_handler(request_rec *r)
+{
+ modparrot_dir_config *dircfg;
+ modparrot_srv_config *cfg;
+ modparrot_context *ctxp;
+ int handler_status;
+ char *sub, *hll;
+
+ /* get apache configs */
+ dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
+ cfg = ap_get_module_config(r->server->module_config, &parrot_module);
+
+ /* politely decline request if not our handler */
+ if (!dircfg->fixup_handler) {
+ return DECLINED;
+ }
+
+ /* initialize context */
+ if (!(ctxp = init_ctx(r->server))) {
+ MPLOG_ERROR(r->server, "context initialization failed");
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ ctxp->r = r;
+
+ /* call HLL handler */
+ sub = "_fixup_handler";
+ hll = dircfg->fixup_handler->hll ? dircfg->fixup_handler->hll : "PIR";
+
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub,
+ dircfg->fixup_handler->id, &handler_status)) {
+ MPLOG_ERRORF(r->server, "no subroutine found for handler '%s'",
+ dircfg->fixup_handler->id);
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ /* tell apache we're done */
+ return handler_status;
+}
+
+static int modparrot_type_handler(request_rec *r)
+{
+ modparrot_dir_config *dircfg;
+ modparrot_srv_config *cfg;
+ modparrot_context *ctxp;
+ int handler_status;
+ char *sub, *hll;
+
+ /* get apache configs */
+ dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
+ cfg = ap_get_module_config(r->server->module_config, &parrot_module);
+
+ /* politely decline request if not our handler */
+ if (!dircfg->type_handler) {
+ return DECLINED;
+ }
+
+ /* initialize context */
+ if (!(ctxp = init_ctx(r->server))) {
+ MPLOG_ERROR(r->server, "context initialization failed");
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ ctxp->r = r;
+
+ /* call HLL handler */
+ sub = "_type_handler";
+ hll = dircfg->type_handler->hll ? dircfg->type_handler->hll : "PIR";
+
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub,
+ dircfg->type_handler->id, &handler_status)) {
+ MPLOG_ERRORF(r->server, "no subroutine found for handler '%s'",
+ dircfg->type_handler->id);
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ /* tell apache we're done */
+ return handler_status;
+}
+
+static int modparrot_log_handler(request_rec *r)
+{
+ modparrot_dir_config *dircfg;
+ modparrot_srv_config *cfg;
+ modparrot_context *ctxp;
+ int handler_status;
+ char *sub, *hll;
+
+ /* politely decline request if we shouldn't be handling this */
+ if (!SHOULD_HANDLE(r)) {
+ return DECLINED;
+ }
+
+ /* get apache configs */
+ dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
+ cfg = ap_get_module_config(r->server->module_config, &parrot_module);
+
+ /* politely decline request if not our handler */
+ if (!dircfg->log_handler) {
+ return DECLINED;
+ }
+
+ /* initialize context */
+ if (!(ctxp = init_ctx(r->server))) {
+ MPLOG_ERROR(r->server, "context initialization failed");
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ ctxp->r = r;
+
+ /* call HLL handler */
+ sub = "_log_handler";
+ hll = dircfg->log_handler->hll ? dircfg->log_handler->hll : "PIR";
+
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub,
+ dircfg->log_handler->id, &handler_status)) {
+ MPLOG_ERRORF(r->server, "no subroutine found for handler '%s'",
+ dircfg->log_handler->id);
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ /* tell apache we're done */
+ return handler_status;
+}
+
static int modparrot_access_handler(request_rec *r)
{
modparrot_dir_config *dircfg;
modparrot_srv_config *cfg;
modparrot_context *ctxp;
int handler_status;
- char *sub;
+ char *sub, *hll;
/* get apache configs */
dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
@@ -186,17 +607,20 @@ static int modparrot_access_handler(requ
/* initialize context */
if (!(ctxp = init_ctx(r->server))) {
MPLOG_ERRORF(r->server,
- "context initialization failed for handler '%s'", dircfg->handler);
+ "context initialization failed for access handler '%s'",
+ dircfg->access_handler->id);
return HTTP_INTERNAL_SERVER_ERROR;
}
ctxp->r = r;
/* call HLL handler */
sub = "_access_handler";
- if (!modparrot_hll_handler(ctxp->interp, dircfg->hll, sub,
- dircfg->access_handler, &handler_status)) {
+ hll = dircfg->access_handler->hll ?
+ dircfg->access_handler->hll : dircfg->hll;
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub,
+ dircfg->access_handler->id, &handler_status)) {
MPLOG_ERRORF(r->server, "no subroutine found for handler '%s'",
- dircfg->access_handler);
+ dircfg->access_handler->id);
return HTTP_INTERNAL_SERVER_ERROR;
}
@@ -210,7 +634,7 @@ static int modparrot_authen_handler(requ
modparrot_srv_config *cfg;
modparrot_context *ctxp;
int handler_status;
- char *sub;
+ char *sub, *hll;
/* get apache configs */
dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
@@ -224,17 +648,20 @@ static int modparrot_authen_handler(requ
/* initialize context */
if (!(ctxp = init_ctx(r->server))) {
MPLOG_ERRORF(r->server,
- "context initialization failed for handler '%s'", dircfg->handler);
+ "context initialization failed for authen handler '%s'",
+ dircfg->authen_handler->id);
return HTTP_INTERNAL_SERVER_ERROR;
}
ctxp->r = r;
/* call HLL handler */
sub = "_authen_handler";
- if (!modparrot_hll_handler(ctxp->interp, dircfg->hll, sub,
- dircfg->authen_handler, &handler_status)) {
+ hll = dircfg->authen_handler->hll ?
+ dircfg->authen_handler->hll : dircfg->hll;
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub,
+ dircfg->authen_handler->id, &handler_status)) {
MPLOG_ERRORF(r->server, "no subroutine found for handler '%s'",
- dircfg->authen_handler);
+ dircfg->authen_handler->id);
return HTTP_INTERNAL_SERVER_ERROR;
}
@@ -250,7 +677,7 @@ static int modparrot_authz_handler(reque
modparrot_srv_config *cfg;
modparrot_context *ctxp;
int handler_status;
- char *sub;
+ char *sub, *hll;
/* get apache configs */
dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
@@ -264,17 +691,20 @@ static int modparrot_authz_handler(reque
/* initialize context */
if (!(ctxp = init_ctx(r->server))) {
MPLOG_ERRORF(r->server,
- "context initialization failed for handler '%s'", dircfg->handler);
+ "context initialization failed for authz handler '%s'",
+ dircfg->authz_handler->id);
return HTTP_INTERNAL_SERVER_ERROR;
}
ctxp->r = r;
/* call HLL handler */
sub = "_authz_handler";
- if (!modparrot_hll_handler(ctxp->interp, dircfg->hll, sub,
- dircfg->authz_handler, &handler_status)) {
+ hll = dircfg->authz_handler->hll ?
+ dircfg->authz_handler->hll : dircfg->hll;
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub,
+ dircfg->authz_handler->id, &handler_status)) {
MPLOG_ERRORF(r->server, "no subroutine found for handler '%s'",
- dircfg->authz_handler);
+ dircfg->authz_handler->id);
return HTTP_INTERNAL_SERVER_ERROR;
}
@@ -285,15 +715,46 @@ static int modparrot_authz_handler(reque
static int modparrot_post_config_handler(apr_pool_t *pconf, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s)
{
+ modparrot_srv_config *cfg;
+ modparrot_context *ctxp;
+ int handler_status;
+ char *sub, *hll;
+
/* add our info to apache's version string */
ap_add_version_component(pconf, "mod_parrot/" MODPARROT_VERSION);
- /* initialize context pool */
- if (!mp_ctx_pool_init(pconf, 2)) {
- MPLOG_ERROR(s, "context pool creation failed");
+ /* get apache configs */
+ cfg = ap_get_module_config(s->module_config, &parrot_module);
+
+ /* if not our handler, return OK (post_config must return OK) */
+ if (!cfg->open_logs_handler) {
+ return OK;
+ }
+
+ /* initialize context */
+ if (!(ctxp = init_ctx(s))) {
+ MPLOG_ERROR(s, "context initialization failed");
return HTTP_INTERNAL_SERVER_ERROR;
}
- return OK;
+
+ ctxp->pconf = pconf;
+ ctxp->plog = plog;
+ ctxp->ptemp = ptemp;
+ ctxp->s = s;
+
+ /* call HLL handler */
+ sub = "_post_config_handler";
+ hll = cfg->post_config_handler->hll ? cfg->post_config_handler->hll : "PIR";
+
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub,
+ cfg->post_config_handler->id, &handler_status)) {
+ MPLOG_ERRORF(s, "no subroutine found for handler '%s'",
+ cfg->post_config_handler->id);
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ /* tell apache we're done */
+ return handler_status;
}
static int modparrot_open_logs_handler(apr_pool_t *pconf, apr_pool_t *plog,
@@ -302,14 +763,20 @@ static int modparrot_open_logs_handler(a
modparrot_srv_config *cfg;
modparrot_context *ctxp;
int handler_status;
- char *sub;
+ char *sub, *hll;
+
+ /* initialize context pool */
+ if (!mp_ctx_pool_init(pconf, 2)) {
+ MPLOG_ERROR(s, "context pool creation failed");
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
/* get apache configs */
cfg = ap_get_module_config(s->module_config, &parrot_module);
- /* politely decline request if not our handler */
+ /* if not our handler, return OK (open_logs must return OK) */
if (!cfg->open_logs_handler) {
- return DECLINED;
+ return OK;
}
/* initialize context */
@@ -318,12 +785,19 @@ static int modparrot_open_logs_handler(a
return HTTP_INTERNAL_SERVER_ERROR;
}
+ ctxp->pconf = pconf;
+ ctxp->plog = plog;
+ ctxp->ptemp = ptemp;
+ ctxp->s = s;
+
/* call HLL handler */
sub = "_open_logs_handler";
- if (!modparrot_hll_handler(ctxp->interp, "PIR", sub, cfg->open_logs_handler,
- &handler_status)) {
+ hll = cfg->open_logs_handler->hll ? cfg->open_logs_handler->hll : "PIR";
+
+ if (!modparrot_hll_handler(ctxp->interp, hll, sub,
+ cfg->open_logs_handler->id, &handler_status)) {
MPLOG_ERRORF(s, "no subroutine found for handler '%s'",
- cfg->open_logs_handler);
+ cfg->open_logs_handler->id);
return HTTP_INTERNAL_SERVER_ERROR;
}
@@ -339,7 +813,17 @@ static void register_hooks(apr_pool_t *p
/* register the various hooks */
ap_hook_post_config(modparrot_post_config_handler, NULL, NULL, APR_HOOK_FIRST);
+ ap_hook_child_init(modparrot_child_init_handler, NULL, NULL, APR_HOOK_FIRST);
+ ap_hook_pre_connection(modparrot_pre_connection_handler, NULL, NULL, APR_HOOK_FIRST);
+ ap_hook_process_connection(modparrot_process_connection_handler, NULL, NULL, APR_HOOK_FIRST);
+ ap_hook_map_to_storage(modparrot_map_to_storage_handler, NULL, NULL, APR_HOOK_REALLY_FIRST);
+ ap_hook_translate_name(modparrot_trans_handler, NULL, NULL, APR_HOOK_REALLY_FIRST);
+ ap_hook_post_read_request(modparrot_post_read_request_handler, NULL, NULL, APR_HOOK_REALLY_FIRST);
+ ap_hook_header_parser(modparrot_header_parser_handler, NULL, NULL, APR_HOOK_REALLY_FIRST);
ap_hook_handler(modparrot_handler, NULL, NULL, APR_HOOK_REALLY_FIRST);
+ ap_hook_type_checker(modparrot_type_handler, NULL, NULL, APR_HOOK_REALLY_FIRST);
+ ap_hook_fixups(modparrot_fixup_handler, NULL, NULL, APR_HOOK_REALLY_FIRST);
+ ap_hook_log_transaction(modparrot_log_handler, NULL, NULL, APR_HOOK_REALLY_FIRST);
ap_hook_open_logs(modparrot_open_logs_handler, NULL, NULL, APR_HOOK_FIRST);
ap_hook_access_checker(modparrot_access_handler, NULL, NULL, APR_HOOK_REALLY_FIRST);
ap_hook_check_user_id(modparrot_authen_handler, NULL, NULL, APR_HOOK_REALLY_FIRST);
@@ -355,7 +839,7 @@ static const command_rec modparrot_cmds[
RSRC_CONF,
"modparrot initialization file"
),
- AP_INIT_FLAG(
+ AP_INIT_TAKE1(
"ParrotTrace",
modparrot_cmd_trace,
NULL,
@@ -363,11 +847,81 @@ static const command_rec modparrot_cmds[
"enable Parrot opcode tracing (default is off)"
),
AP_INIT_TAKE1(
+ "ParrotOpenLogsHandler",
+ modparrot_cmd_open_logs_handler,
+ NULL,
+ RSRC_CONF,
+ "set the Parrot open logs handler"
+ ),
+ AP_INIT_TAKE1(
+ "ParrotChildInitHandler",
+ modparrot_cmd_child_init_handler,
+ NULL,
+ RSRC_CONF,
+ "set the Parrot child init handler"
+ ),
+ AP_INIT_TAKE1(
+ "ParrotChildExitHandler",
+ modparrot_cmd_child_exit_handler,
+ NULL,
+ RSRC_CONF,
+ "set the Parrot child exit handler"
+ ),
+ AP_INIT_TAKE1(
+ "ParrotPostConfigHandler",
+ modparrot_cmd_post_config_handler,
+ NULL,
+ RSRC_CONF,
+ "set the Parrot child exit handler"
+ ),
+ AP_INIT_TAKE1(
+ "ParrotPreConnectionHandler",
+ modparrot_cmd_pre_connection_handler,
+ NULL,
+ RSRC_CONF,
+ "set the Parrot pre-connection handler"
+ ),
+ AP_INIT_TAKE1(
+ "ParrotProcessConnectionHandler",
+ modparrot_cmd_process_connection_handler,
+ NULL,
+ RSRC_CONF,
+ "set the Parrot process-connection handler"
+ ),
+ AP_INIT_TAKE1(
+ "ParrotMapToStorageHandler",
+ modparrot_cmd_map_to_storage_handler,
+ NULL,
+ RSRC_CONF,
+ "set the Parrot map to storage handler"
+ ),
+ AP_INIT_TAKE1(
+ "ParrotTransHandler",
+ modparrot_cmd_trans_handler,
+ NULL,
+ RSRC_CONF,
+ "set the Parrot trans handler"
+ ),
+ AP_INIT_TAKE1(
+ "ParrotPostReadRequestHandler",
+ modparrot_cmd_post_read_request_handler,
+ NULL,
+ RSRC_CONF,
+ "set the Parrot post read request handler"
+ ),
+ AP_INIT_TAKE1(
+ "ParrotHeaderParserHandler",
+ modparrot_cmd_header_parser_handler,
+ NULL,
+ OR_AUTHCFG,
+ "set the Parrot header parser handler"
+ ),
+ AP_INIT_TAKE1(
"ParrotHandler",
modparrot_cmd_handler,
NULL,
OR_AUTHCFG,
- "set the Parrot content handler"
+ "set the Parrot response handler"
),
AP_INIT_TAKE1(
"ParrotAccessHandler",
@@ -391,6 +945,34 @@ static const command_rec modparrot_cmds[
"set the Parrot authorization handler"
),
AP_INIT_TAKE1(
+ "ParrotTypeHandler",
+ modparrot_cmd_type_handler,
+ NULL,
+ OR_AUTHCFG,
+ "set the Parrot type handler"
+ ),
+ AP_INIT_TAKE1(
+ "ParrotFixupHandler",
+ modparrot_cmd_fixup_handler,
+ NULL,
+ OR_AUTHCFG,
+ "set the Parrot fixup handler"
+ ),
+ AP_INIT_TAKE1(
+ "ParrotLogHandler",
+ modparrot_cmd_log_handler,
+ NULL,
+ OR_AUTHCFG,
+ "set the Parrot log handler"
+ ),
+ AP_INIT_TAKE1(
+ "ParrotCleanupHandler",
+ modparrot_cmd_cleanup_handler,
+ NULL,
+ OR_AUTHCFG,
+ "set the Parrot cleanup handler"
+ ),
+ AP_INIT_TAKE1(
"ParrotLanguage",
modparrot_cmd_language,
NULL,
@@ -411,7 +993,7 @@ module AP_MODULE_DECLARE_DATA parrot_mod
{
STANDARD20_MODULE_STUFF,
create_modparrot_dir_config,
- merge_modparrot_dir_config,
+ NULL, /* merge_modparrot_dir_config, */
create_modparrot_srv_config,
NULL,
modparrot_cmds,
Modified: mod_parrot/branches/autogen/mod_parrot.h
==============================================================================
--- mod_parrot/branches/autogen/mod_parrot.h (original)
+++ mod_parrot/branches/autogen/mod_parrot.h Mon Aug 1 07:24:24 2005
@@ -41,7 +41,10 @@ struct modparrot_context
apr_pool_t *pconf;
apr_pool_t *plog;
apr_pool_t *ptemp;
+ apr_pool_t *pchild;
server_rec *s;
+ conn_rec *c;
+ void *csd;
};
typedef struct modparrot_context modparrot_context;
@@ -49,7 +52,10 @@ typedef struct modparrot_context modparr
Parrot_Interp modparrot_init_interpreter(void);
int modparrot_load_bytecode(Parrot_Interp, char *);
void modparrot_destroy_interpreter(Parrot_Interp);
-int modparrot_call_sub(Parrot_Interp, char *, char *, int *);
+int modparrot_call_sub(Parrot_Interp, char *, char *);
+int modparrot_call_sub_Iv(Parrot_Interp, char *, char *, int *);
+int modparrot_call_sub_IS(Parrot_Interp, char *, char *, int *, char *);
+int modparrot_hll_handler(Parrot_Interp, char *, char *, char *, int *);
Parrot_PMC get_sub_pmc(Parrot_Interp , char *, char *);
int mp_ctx_pool_init(apr_pool_t *, int);
modparrot_context *reserve_ctx(void);
Modified: mod_parrot/branches/autogen/modparrot_config.c
==============================================================================
--- mod_parrot/branches/autogen/modparrot_config.c (original)
+++ mod_parrot/branches/autogen/modparrot_config.c Mon Aug 1 07:24:24 2005
@@ -27,6 +27,7 @@
#include "mod_parrot.h"
#include "modparrot_config.h"
+#include "modparrot_log.h"
#define GET_SERVER_CONFIG(x) \
((modparrot_srv_config *)ap_get_module_config(\
@@ -40,9 +41,9 @@ void *create_modparrot_srv_config(apr_po
cfg = (modparrot_srv_config *)apr_pcalloc(p, sizeof(modparrot_srv_config));
cfg->pool = p;
- cfg->enable_trace = 0;
+ cfg->trace_flags = 0;
cfg->init_path = MODPARROT_DEFAULT_INIT;
- cfg->preload = apr_array_make(p, 2, sizeof(char *));
+ cfg->preload = apr_array_make(p, 2, sizeof(modparrot_handler_info));
return (void *)cfg;
}
@@ -58,11 +59,14 @@ void *create_modparrot_dir_config(apr_po
else {
cfg->directory = (char *)apr_pstrdup(p, path);
}
+ cfg->hll = NULL;
cfg->handler = NULL;
return (void *)cfg;
}
+/* this is too messy for a simple override merge -- punt for now */
+#if 0
void *merge_modparrot_dir_config(apr_pool_t *p, void *base, void *new)
{
modparrot_dir_config *basecfg = (modparrot_dir_config *)base;
@@ -81,91 +85,268 @@ void *merge_modparrot_dir_config(apr_poo
}
if (newcfg->handler) {
- merged->handler = (char *)apr_pstrdup(p, newcfg->handler);
+ merged->handler = (modparrot_handler_info *)apr_pmemdup(p, newcfg->handler, sizeof(modparrot_handler_info));
}
else {
merged->handler =
- basecfg->handler ? (char *)apr_pstrdup(p, basecfg->handler) : NULL;
+ basecfg->handler ? (modparrot_handler_info *)apr_pmemdup(p, basecfg->handler, sizeof(modparrot_handler_info)) : NULL;
}
if (newcfg->access_handler) {
- merged->access_handler = (char *)apr_pstrdup(p, newcfg->access_handler);
+ merged->access_handler = (modparrot_handler_info *)apr_pmemdup(p, newcfg->access_handler, sizeof(modparrot_handler_info));
}
else {
merged->access_handler =
- basecfg->access_handler ? (char *)apr_pstrdup(p, basecfg->access_handler) : NULL;
+ basecfg->access_handler ? (modparrot_handler_info *)apr_pmemdup(p, basecfg->access_handler, sizeof(modparrot_handler_info)) : NULL;
}
if (newcfg->authen_handler) {
- merged->authen_handler = (char *)apr_pstrdup(p, newcfg->authen_handler);
+ merged->authen_handler = (modparrot_handler_info *)apr_pmemdup(p, newcfg->authen_handler, sizeof(modparrot_handler_info));
}
else {
merged->authen_handler =
- basecfg->authen_handler ? (char *)apr_pstrdup(p, basecfg->authen_handler) : NULL;
+ basecfg->authen_handler ? (modparrot_handler_info *)apr_pmemdup(p, basecfg->authen_handler, sizeof(modparrot_handler_info)) : NULL;
}
if (newcfg->authz_handler) {
- merged->authz_handler = (char *)apr_pstrdup(p, newcfg->authz_handler);
+ merged->authz_handler = (modparrot_handler_info *)apr_pmemdup(p, newcfg->authz_handler, sizeof(modparrot_handler_info));
}
else {
merged->authz_handler =
- basecfg->authz_handler ? (char *)apr_pstrdup(p, basecfg->authz_handler) : NULL;
+ basecfg->authz_handler ? (modparrot_handler_info *)apr_pmemdup(p, basecfg->authz_handler, sizeof(modparrot_handler_info)) : NULL;
}
return (void *)merged;
}
+#endif
-const char *modparrot_cmd_trace(cmd_parms *cmd, void *mconfig, int f)
+/* parses a handler into the handler ID and the HLL
+ * if 'l' is NULL, will allocate handler info itself
+ */
+static modparrot_handler_info *parse_handler(apr_pool_t *p, const char *handler,
+ modparrot_handler_info *l)
+{
+ char *part;
+
+ if (!l) {
+ l = (modparrot_handler_info *)apr_pcalloc(p,
+ sizeof(modparrot_handler_info));
+ }
+
+ /* split handler into HLL and ID */
+ if (part = strchr(handler, ',')) {
+ l->hll = apr_pstrndup(p, handler, part-handler);
+ l->id = apr_pstrdup(p, part+1);
+ }
+ else {
+ l->hll = 0;
+ l->id = apr_pstrdup(p, handler);
+ }
+
+ return(l);
+}
+
+const char *modparrot_cmd_trace(cmd_parms *cmd, void *mconfig, const char *f)
+{
+ modparrot_srv_config *cfg;
+ int flags;
+
+ cfg = GET_SERVER_CONFIG(cmd);
+ flags = atoi(f);
+ cfg->trace_flags = flags;
+ return NULL;
+}
+
+const char *modparrot_cmd_load(cmd_parms *cmd, void *mconfig,
+ const char *handler)
+{
+ modparrot_srv_config *cfg;
+ modparrot_handler_info *l;
+
+ cfg = GET_SERVER_CONFIG(cmd);
+ l = (modparrot_handler_info *)apr_array_push(cfg->preload);
+ parse_handler(cmd->pool, handler, l);
+
+ return NULL;
+}
+
+const char *modparrot_cmd_open_logs_handler(cmd_parms *cmd, void *mconfig, const char *handler)
+{
+ modparrot_srv_config *cfg;
+
+ cfg = GET_SERVER_CONFIG(cmd);
+ cfg->open_logs_handler = parse_handler(cmd->pool, handler, NULL);
+ return NULL;
+}
+
+const char *modparrot_cmd_post_config_handler(cmd_parms *cmd, void *mconfig, const char *handler)
+{
+ modparrot_srv_config *cfg;
+
+ cfg = GET_SERVER_CONFIG(cmd);
+ cfg->post_config_handler =parse_handler(cmd->pool, handler, NULL);
+ return NULL;
+}
+
+const char *modparrot_cmd_child_init_handler(cmd_parms *cmd, void *mconfig, const char *handler)
{
modparrot_srv_config *cfg;
cfg = GET_SERVER_CONFIG(cmd);
- cfg->enable_trace = f ? 1 : 0;
+ cfg->child_init_handler =parse_handler(cmd->pool, handler, NULL);
return NULL;
}
-const char *modparrot_cmd_load(cmd_parms *cmd, void *mconfig, const char *path)
+const char *modparrot_cmd_child_exit_handler(cmd_parms *cmd, void *mconfig, const char *handler)
{
modparrot_srv_config *cfg;
cfg = GET_SERVER_CONFIG(cmd);
- *(char **)apr_array_push(cfg->preload) = (char *)apr_pstrdup(cmd->pool, path);
+ cfg->child_exit_handler =parse_handler(cmd->pool, handler, NULL);
return NULL;
}
-const char *modparrot_cmd_handler(cmd_parms *cmd, void *mconfig, const char *namespace)
+const char *modparrot_cmd_pre_connection_handler(cmd_parms *cmd, void *mconfig, const char *handler)
+{
+ modparrot_srv_config *cfg;
+
+ cfg = GET_SERVER_CONFIG(cmd);
+ cfg->pre_connection_handler =parse_handler(cmd->pool, handler, NULL);
+ return NULL;
+}
+
+const char *modparrot_cmd_process_connection_handler(cmd_parms *cmd, void *mconfig, const char *handler)
+{
+ modparrot_srv_config *cfg;
+
+ cfg = GET_SERVER_CONFIG(cmd);
+ cfg->process_connection_handler =parse_handler(cmd->pool, handler, NULL);
+ return NULL;
+}
+
+const char *modparrot_cmd_map_to_storage_handler(cmd_parms *cmd, void *mconfig, const char *handler)
+{
+ modparrot_srv_config *cfg;
+
+ cfg = GET_SERVER_CONFIG(cmd);
+ cfg->map_to_storage_handler =parse_handler(cmd->pool, handler, NULL);
+ return NULL;
+}
+
+const char *modparrot_cmd_trans_handler(cmd_parms *cmd, void *mconfig, const char *handler)
+{
+ modparrot_srv_config *cfg;
+
+ cfg = GET_SERVER_CONFIG(cmd);
+ cfg->trans_handler =parse_handler(cmd->pool, handler, NULL);
+ return NULL;
+}
+
+const char *modparrot_cmd_post_read_request_handler(cmd_parms *cmd, void *mconfig, const char *handler)
+{
+ modparrot_srv_config *cfg;
+
+ cfg = GET_SERVER_CONFIG(cmd);
+ cfg->post_read_request_handler =parse_handler(cmd->pool, handler, NULL);
+ return NULL;
+}
+
+const char *modparrot_cmd_input_filter_handler(cmd_parms *cmd, void *mconfig, const char *handler)
{
modparrot_dir_config *cfg;
cfg = (modparrot_dir_config *)mconfig;
- cfg->handler = (char *)apr_pstrdup(cmd->pool, namespace);
+ cfg->input_filter_handler = parse_handler(cmd->pool, handler, NULL);
return NULL;
}
-const char *modparrot_cmd_access_handler(cmd_parms *cmd, void *mconfig, const char *namespace)
+const char *modparrot_cmd_output_filter_handler(cmd_parms *cmd, void *mconfig, const char *handler)
{
modparrot_dir_config *cfg;
cfg = (modparrot_dir_config *)mconfig;
- cfg->access_handler = (char *)apr_pstrdup(cmd->pool, namespace);
+ cfg->output_filter_handler = parse_handler(cmd->pool, handler, NULL);
return NULL;
}
-const char *modparrot_cmd_authen_handler(cmd_parms *cmd, void *mconfig, const char *namespace)
+const char *modparrot_cmd_header_parser_handler(cmd_parms *cmd, void *mconfig, const char *handler)
{
modparrot_dir_config *cfg;
cfg = (modparrot_dir_config *)mconfig;
- cfg->authen_handler = (char *)apr_pstrdup(cmd->pool, namespace);
+ cfg->header_parser_handler = parse_handler(cmd->pool, handler, NULL);
return NULL;
}
-const char *modparrot_cmd_authz_handler(cmd_parms *cmd, void *mconfig, const char *namespace)
+const char *modparrot_cmd_handler(cmd_parms *cmd, void *mconfig, const char *handler)
+{
+ modparrot_dir_config *cfg;
+
+ cfg = (modparrot_dir_config *)mconfig;
+ cfg->handler = parse_handler(cmd->pool, handler, NULL);
+ return NULL;
+}
+
+const char *modparrot_cmd_access_handler(cmd_parms *cmd, void *mconfig, const char *handler)
+{
+ modparrot_dir_config *cfg;
+
+ cfg = (modparrot_dir_config *)mconfig;
+ cfg->access_handler = parse_handler(cmd->pool, handler, NULL);
+ return NULL;
+}
+
+const char *modparrot_cmd_authen_handler(cmd_parms *cmd, void *mconfig, const char *handler)
+{
+ modparrot_dir_config *cfg;
+
+ cfg = (modparrot_dir_config *)mconfig;
+ cfg->authen_handler = parse_handler(cmd->pool, handler, NULL);
+ return NULL;
+}
+
+const char *modparrot_cmd_authz_handler(cmd_parms *cmd, void *mconfig, const char *handler)
{
modparrot_dir_config *cfg;
cfg = (modparrot_dir_config *)mconfig;
- cfg->authz_handler = (char *)apr_pstrdup(cmd->pool, namespace);
+ cfg->authz_handler = parse_handler(cmd->pool, handler, NULL);
+ return NULL;
+}
+
+const char *modparrot_cmd_type_handler(cmd_parms *cmd, void *mconfig, const char *handler)
+{
+ modparrot_dir_config *cfg;
+
+ cfg = (modparrot_dir_config *)mconfig;
+ cfg->type_handler = parse_handler(cmd->pool, handler, NULL);
+ return NULL;
+}
+
+const char *modparrot_cmd_fixup_handler(cmd_parms *cmd, void *mconfig, const char *handler)
+{
+ modparrot_dir_config *cfg;
+
+ cfg = (modparrot_dir_config *)mconfig;
+ cfg->fixup_handler = parse_handler(cmd->pool, handler, NULL);
+ return NULL;
+}
+
+const char *modparrot_cmd_log_handler(cmd_parms *cmd, void *mconfig, const char *handler)
+{
+ modparrot_dir_config *cfg;
+
+ cfg = (modparrot_dir_config *)mconfig;
+ cfg->log_handler = parse_handler(cmd->pool, handler, NULL);
+ return NULL;
+}
+
+const char *modparrot_cmd_cleanup_handler(cmd_parms *cmd, void *mconfig, const char *handler)
+{
+ modparrot_dir_config *cfg;
+
+ cfg = (modparrot_dir_config *)mconfig;
+ cfg->cleanup_handler = parse_handler(cmd->pool, handler, NULL);
return NULL;
}
Modified: mod_parrot/branches/autogen/modparrot_config.h
==============================================================================
--- mod_parrot/branches/autogen/modparrot_config.h (original)
+++ mod_parrot/branches/autogen/modparrot_config.h Mon Aug 1 07:24:24 2005
@@ -18,35 +18,77 @@
#include "apr_tables.h"
/* configuration */
+struct modparrot_handler_info
+{
+ char *id; /* identifier of the code to load */
+ char *hll; /* HLL of the code */
+};
+typedef struct modparrot_handler_info modparrot_handler_info;
+
struct modparrot_srv_config
{
apr_pool_t *pool;
char *init_path;
- int enable_trace;
+ int trace_flags;
apr_array_header_t *preload;
- char *open_logs_handler;
+ modparrot_handler_info *open_logs_handler;
+ modparrot_handler_info *child_init_handler;
+ modparrot_handler_info *child_exit_handler;
+ modparrot_handler_info *post_config_handler;
+ modparrot_handler_info *pre_connection_handler;
+ modparrot_handler_info *process_connection_handler;
+ modparrot_handler_info *map_to_storage_handler;
+ modparrot_handler_info *trans_handler;
+ modparrot_handler_info *post_read_request_handler;
};
typedef struct modparrot_srv_config modparrot_srv_config;
struct modparrot_dir_config
{
char *directory;
- char *hll;
- char *handler;
- char *access_handler;
- char *authen_handler;
- char *authz_handler;
+ char *hll; /* default HLL handler for this block */
+ modparrot_handler_info *input_filter_handler;
+ modparrot_handler_info *output_filter_handler;
+ modparrot_handler_info *header_parser_handler;
+ modparrot_handler_info *handler;
+ modparrot_handler_info *access_handler;
+ modparrot_handler_info *authen_handler;
+ modparrot_handler_info *authz_handler;
+ modparrot_handler_info *type_handler;
+ modparrot_handler_info *fixup_handler;
+ modparrot_handler_info *log_handler;
+ modparrot_handler_info *cleanup_handler;
};
typedef struct modparrot_dir_config modparrot_dir_config;
void *create_modparrot_srv_config(apr_pool_t *, server_rec *);
void *create_modparrot_dir_config(apr_pool_t *, char *path);
void *merge_modparrot_dir_config(apr_pool_t *, void *, void *);
-const char *modparrot_cmd_init(cmd_parms *, void *, const char *);
-const char *modparrot_cmd_trace(cmd_parms *, void *, int);
+
+/* handler directives */
+const char *modparrot_cmd_open_logs_handler(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_post_config_handler(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_child_init_handler(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_child_exit_handler(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_pre_connection_handler(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_process_connection_handler(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_input_filter_handler(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_output_filter_handler(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_post_read_request_handler(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_trans_handler(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_map_to_storage_handler(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_header_parser_handler(cmd_parms *, void *, const char *);
const char *modparrot_cmd_handler(cmd_parms *, void *, const char *);
const char *modparrot_cmd_access_handler(cmd_parms *, void *, const char *);
const char *modparrot_cmd_authen_handler(cmd_parms *, void *, const char *);
const char *modparrot_cmd_authz_handler(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_type_handler(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_fixup_handler(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_log_handler(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_cleanup_handler(cmd_parms *, void *, const char *);
+
+/* other directives */
+const char *modparrot_cmd_init(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_trace(cmd_parms *, void *, const char *);
const char *modparrot_cmd_language(cmd_parms *, void *, const char *);
const char *modparrot_cmd_load(cmd_parms *, void *, const char *);
Modified: mod_parrot/branches/autogen/nci.c
==============================================================================
--- mod_parrot/branches/autogen/nci.c (original)
+++ mod_parrot/branches/autogen/nci.c Mon Aug 1 07:24:24 2005
@@ -64,6 +64,14 @@ apr_pool_t *mpnci_log_pool(Parrot_Interp
return(ctxp->plog);
}
+apr_pool_t *mpnci_child_pool(Parrot_Interp interp)
+{
+ modparrot_context *ctxp;
+
+ ctxp = get_interp_ctx(interp);
+ return(ctxp->pchild);
+}
+
server_rec *mpnci_server_rec(Parrot_Interp interp)
{
modparrot_context *ctxp;
@@ -72,6 +80,42 @@ server_rec *mpnci_server_rec(Parrot_Inte
return(ctxp->s);
}
+conn_rec *mpnci_conn_rec(Parrot_Interp interp)
+{
+ modparrot_context *ctxp;
+
+ ctxp = get_interp_ctx(interp);
+ return(ctxp->c);
+}
+
+conn_rec *mpnci_csd(Parrot_Interp interp)
+{
+ modparrot_context *ctxp;
+
+ ctxp = get_interp_ctx(interp);
+ return(ctxp->csd);
+}
+
+request_rec *mpnci_request_rec_main(Parrot_Interp interp, request_rec *r)
+{
+ return(r->main);
+}
+
+request_rec *mpnci_request_rec_next(Parrot_Interp interp, request_rec *r)
+{
+ return(r->next);
+}
+
+request_rec *mpnci_request_rec_prev(Parrot_Interp interp, request_rec *r)
+{
+ return(r->prev);
+}
+
+apr_table_t *mpnci_request_rec_notes(Parrot_Interp interp, request_rec *r)
+{
+ return(r->notes);
+}
+
/* We implement ap_get_basic_auth_pw as a wrapper because there is no NCI
* signature type that handles the function's char ** password parameter.
* Even 'B', which is "void **", doesn't work. Should investigate further.
@@ -110,3 +154,7 @@ int mpnci_rwrite(Parrot_Interp interp, P
return(bytes);
}
+char *mpnci_backtrace(Parrot_Interp interp)
+{
+ return (char *)modparrot_backtrace(interp);
+}
Modified: mod_parrot/branches/autogen/parrot_util.c
==============================================================================
--- mod_parrot/branches/autogen/parrot_util.c (original)
+++ mod_parrot/branches/autogen/parrot_util.c Mon Aug 1 07:24:24 2005
@@ -22,8 +22,7 @@
#include "parrot/extend.h"
#include "mod_parrot.h"
-#define BUFFER_SIZE 8192
-#define DEFAULT_HLL_HANDLER "PIR"
+extern void imcc_init(Parrot_Interp);
Parrot_PMC get_sub_pmc(Parrot_Interp interp, char *namespace, char *name)
{
@@ -40,21 +39,18 @@ Parrot_PMC get_sub_pmc(Parrot_Interp int
Parrot_Interp modparrot_init_interpreter(void)
{
Parrot_Interp interp;
+ Parrot_PackFile pf;
+ struct PackFile_Segment *seg;
interp = Parrot_new(NULL);
Parrot_init(interp);
- return(interp);
-}
-
-int modparrot_load_bytecode_init(Parrot_Interp interp, char *path)
-{
- Parrot_PackFile pf;
-
- if (!(pf = Parrot_readbc(interp, path))) {
- return(0);
- }
+ imcc_init(interp);
+ pf = PackFile_new(interp, 0);
+ seg = PackFile_Segment_new_seg(interp, &pf->directory, PF_BYTEC_SEG,
+ "mod_parrot_code", 1);
+ pf->cur_cs = (struct PackFile_ByteCode *)seg;
Parrot_loadbc(interp, pf);
- return(1);
+ return(interp);
}
int modparrot_load_bytecode(Parrot_Interp interp, char *path)
@@ -68,7 +64,18 @@ void modparrot_destroy_interpreter(Parro
Parrot_destroy(interp);
}
-int modparrot_call_sub(Parrot_Interp interp, char *namespace, char *name,
+int modparrot_call_sub(Parrot_Interp interp, char *namespace, char *name)
+{
+ Parrot_PMC sub;
+
+ sub = get_sub_pmc(interp, namespace, name);
+ if (!sub) {
+ return(0);
+ }
+ Parrot_call_sub(interp, sub, "v");
+}
+
+int modparrot_call_sub_Iv(Parrot_Interp interp, char *namespace, char *name,
int *ret)
{
Parrot_PMC sub;
@@ -81,19 +88,128 @@ int modparrot_call_sub(Parrot_Interp int
return(1);
}
-int modparrot_hll_handler(Parrot_Interp interp, char *hll, char *hll_handler,
- char *handler, int *ret)
+int modparrot_call_sub_IS(Parrot_Interp interp, char *namespace, char *name,
+ int *ret, char *arg)
{
Parrot_PMC sub;
- char hll_namespace[255];
- if (!hll) hll = DEFAULT_HLL_HANDLER;
- sprintf(hll_namespace, "ModParrot::HLL::%s", hll);
- sub = get_sub_pmc(interp, hll_namespace, hll_handler);
+ sub = get_sub_pmc(interp, namespace, name);
if (!sub) {
return(0);
}
- *ret = Parrot_call_sub_ret_int(interp, sub, "IS",
- MAKE_PARROT_STRING(handler));
+ *ret = Parrot_call_sub_ret_int(interp, sub, "IS", MAKE_PARROT_STRING(arg));
return(1);
}
+
+/* adapted from Parrot's PDB_backtrace */
+#ifdef PARROT_NEW_CALL_CONV
+char *modparrot_backtrace(Parrot_Interp interp)
+{
+ STRING *str, *buf = NULL;
+ PMC *sub;
+ PMC *old = PMCNULL;
+ int rec_level = 0;
+ parrot_context_t ctx;
+ char *trace_string;
+
+ /* information about the current sub */
+ sub = interpinfo_p(interp, CURRENT_SUB);
+ if (!PMC_IS_NULL(sub)) {
+ str = Parrot_Context_infostr(interp, &interp->ctx);
+ if (str)
+ buf = string_concat(interp, buf, str, 0);
+ }
+
+ /* backtrace: follow the continuation chain */
+ ctx = interp->ctx;
+
+ while (1) {
+ sub = CONTEXT(ctx)->current_cont;
+ if (!sub)
+ break;
+ str = Parrot_Context_infostr(interp,
+ &PMC_cont(sub)->to_ctx);
+ if (!str)
+ break;
+
+ /* recursion detection */
+ if (!PMC_IS_NULL(old) && PMC_cont(old) &&
+ CONTEXT(PMC_cont(old)->to_ctx)->current_pc ==
+ CONTEXT(PMC_cont(sub)->to_ctx)->current_pc &&
+ CONTEXT(PMC_cont(old)->to_ctx)->current_sub ==
+ CONTEXT(PMC_cont(sub)->to_ctx)->current_sub) {
+ ++rec_level;
+ } else if (rec_level != 0) {
+ string_nprintf(interp, buf, 0, "... call repeated %d times\n",
+ rec_level);
+ buf = string_concat(interp, buf, str, 0);
+ rec_level = 0;
+ }
+
+ /* print the context description */
+ if (rec_level == 0)
+ buf = string_concat(interp, buf, str, 0);
+
+ /* get the next Continuation */
+ ctx = PMC_cont(sub)->to_ctx;
+ old = sub;
+ if (!ctx.rctx || !CONTEXT(ctx)->prev)
+ break;
+ }
+ if (rec_level != 0) {
+ string_nprintf(interp, buf, 0, "... call repeated %d times\n",
+ rec_level);
+ }
+
+ trace_string = string_to_cstring(interp, buf);
+ return(trace_string);
+}
+#else /* PARROT_NEW_CALL_CONV */
+char *modparrot_backtrace(Parrot_Interp interp)
+{
+ STRING *str, *buf = NULL;
+ PMC *sub;
+ PMC *old = PMCNULL;
+ int rec_level = 0;
+ char *trace_string;
+
+ /* information about the current sub */
+ sub = interpinfo_p(interp, CURRENT_SUB);
+ if (!PMC_IS_NULL(sub)) {
+ str = Parrot_Context_infostr(interp, &interp->ctx);
+ if (str)
+ buf = string_concat(interp, buf, str, 0);
+ }
+
+ /* backtrace: follow the continuation chain */
+ sub = interpinfo_p(interp, CURRENT_CONT);
+ while (!PMC_IS_NULL(sub) &&
+ sub->vtable->base_type == enum_class_Continuation &&
+ NULL != (str = Parrot_Context_infostr(interp,
+ &PMC_cont(sub)->ctx)) ) {
+
+ /* recursion detection */
+ if (!PMC_IS_NULL(old) && PMC_cont(old) &&
+ PMC_cont(old)->ctx.current_pc == PMC_cont(sub)->ctx.current_pc &&
+ PMC_cont(old)->ctx.current_sub == PMC_cont(sub)->ctx.current_sub) {
+ ++rec_level;
+ } else if (rec_level != 0) {
+ string_nprintf(interp, buf, 0, "... call repeated %d times\n",
+ rec_level);
+ rec_level = 0;
+ }
+
+ /* print the context description */
+ if (rec_level == 0)
+ buf = string_concat(interp, buf, str, 0);
+
+ /* get the next Continuation */
+ old = sub;
+ sub = PMC_cont(sub)->ctx.current_cont;
+ }
+ if (rec_level != 0) {
+ string_nprintf(interp, buf, 0, "... call repeated %d times\n",
+ rec_level);
+ }
+}
+#endif /* PARROT_NEW_CALL_CONV */
Modified: mod_parrot/branches/autogen/t/01RequestRec.t
==============================================================================
--- mod_parrot/branches/autogen/t/01RequestRec.t (original)
+++ mod_parrot/branches/autogen/t/01RequestRec.t Mon Aug 1 07:24:24 2005
@@ -7,7 +7,7 @@ use Test::More;
my $content;
-plan tests => 34, (need_lwp);
+plan tests => 36, (need_lwp);
# Apache::RequestRec->content_type
my $res = GET '/parrot-test/RequestRec-content_type';
@@ -29,11 +29,20 @@ $res = GET '/parrot-test/RequestRec-args
chomp($content = $res->content);
is($content, 'test_string', 'echo passed parameter');
-# Apache::RequestRec->RequestRec-hostname
+# Apache::RequestRec->hostname
$res = GET '/parrot-test/RequestRec-hostname';
chomp($content = $res->content);
like($content, qr/^localhost/, 'verify hostname');
+# Apache::RequestRec->notes
+$res = GET '/parrot-test/RequestRec-notes';
+chomp($content = $res->content);
+is($content, 'bar', 'notes');
+
+# Apache::RequestRec->status
+$res = GET '/parrot-test/RequestRec-status';
+is($res->code, 200, 'status');
+
# Apache::RequestRec->log_rerror
$res = GET '/parrot-test/RequestRec-log_rerror';
# read whole error_log into memory -- should be small
Modified: mod_parrot/branches/autogen/t/conf/extra.conf.in
==============================================================================
--- mod_parrot/branches/autogen/t/conf/extra.conf.in (original)
+++ mod_parrot/branches/autogen/t/conf/extra.conf.in Mon Aug 1 07:24:24 2005
@@ -5,9 +5,14 @@
ParrotInit @ServerRoot@/../lib/ModParrot/init.pbc
ParrotLoad @ServerRoot@/../lib/ModParrot/HLL/pir.pbc
ParrotLoad @ServerRoot@/../lib/Apache/Constants.pbc
+ParrotLoad @ServerRoot@/../lib/APR/Table.pbc
ParrotLoad @ServerRoot@/../lib/Apache/RequestRec.pbc
ParrotLoad @ServerRoot@/lib/handlers.pbc
+# for mod_pugs
+ParrotLoad @ServerRoot@/../lib/ModParrot/HLL/pugs.imc
+ParrotLoad @ServerRoot@/../lib/pugs/Apache/RequestRec.imc
+
<Location /parrot-test/RequestRec-content_type>
SetHandler parrot-code
ParrotLanguage PIR
@@ -38,6 +43,18 @@ ParrotLoad @ServerRoot@/lib/handlers.pbc
ParrotHandler ModParrot::Test::hostname
</Location>
+<Location /parrot-test/RequestRec-notes>
+ SetHandler parrot-code
+ ParrotLanguage PIR
+ ParrotHandler ModParrot::Test::notes
+</Location>
+
+<Location /parrot-test/RequestRec-status>
+ SetHandler parrot-code
+ ParrotLanguage PIR
+ ParrotHandler ModParrot::Test::status
+</Location>
+
<Location /parrot-test/RequestRec-log_rerror>
SetHandler parrot-code
ParrotLanguage PIR
@@ -230,3 +247,8 @@ ParrotLoad @ServerRoot@/lib/handlers.pbc
ParrotHandler ModParrot::Test::eos_sent
</Location>
+<Location /parrot-test/pugs/handler>
+ SetHandler parrot-code
+ ParrotLanguage pugs
+ ParrotHandler ModPugs::Handler
+</Location>
Modified: mod_parrot/branches/autogen/t/lib/ModParrot/TestRun.pm
==============================================================================
--- mod_parrot/branches/autogen/t/lib/ModParrot/TestRun.pm (original)
+++ mod_parrot/branches/autogen/t/lib/ModParrot/TestRun.pm Mon Aug 1 07:24:24 2005
@@ -20,12 +20,17 @@ package ModParrot::TestRun;
use base Apache::TestRun;
use Apache::TestConfig;
+use Apache::Test;
sub pre_configure
{
my $self = shift;
Apache::TestConfig::autoconfig_skip_module_add('mod_parrot.c');
$self->SUPER::pre_configure();
+
+ # XXX adjust @INC for mod_pugs tests. this functionality should be builtin.
+ $ENV{'PERL6LIB'} =
+ Apache::Test::config->{server}->{config}->{vars}->{serverroot}.'/lib';
}
1;
Modified: mod_parrot/branches/autogen/t/lib/handlers.imc
==============================================================================
--- mod_parrot/branches/autogen/t/lib/handlers.imc (original)
+++ mod_parrot/branches/autogen/t/lib/handlers.imc Mon Aug 1 07:24:24 2005
@@ -243,8 +243,6 @@ authz_done:
.pcc_end_return
.end
-# My new tests
-
.namespace [ 'ModParrot::Test::the_request' ]
.sub _handler
@@ -636,3 +634,37 @@ authz_done:
.pcc_end_return
.end
+.namespace [ 'ModParrot::Test::notes' ]
+
+.sub _handler
+ .param pmc r
+ .local pmc ap_const
+
+ $P0 = r.'notes'( )
+ $P0.'set'('foo', 'bar')
+ $S0 = $P0.'get'('foo')
+ r.'puts'($S0)
+
+ ap_const = find_global 'Apache::Constants', 'ap_constants'
+ $I0 = ap_const['OK']
+
+ .pcc_begin_return
+ .return $I0
+ .pcc_end_return
+.end
+
+.namespace [ 'ModParrot::Test::status' ]
+
+.sub _handler
+ .param pmc r
+ .local pmc ap_const
+
+ r.'status'(201)
+
+ ap_const = find_global 'Apache::Constants', 'ap_constants'
+ $I0 = ap_const['OK']
+
+ .pcc_begin_return
+ .return $I0
+ .pcc_end_return
+.end
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.