From 5d1c2193a6c3c98cf426e03eb783eace183e5a0c Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Wed, 25 Jul 2007 18:21:02 +0200 Subject: [PATCH] move plp server handlers to respective modules Keep compatibility wrappers for handler() and everything(). --- PLP.pm | 24 ++++++------------------ PLP/Apache.pm | 15 +++++++++++++++ PLP/CGI.pm | 14 ++++++++------ 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/PLP.pm b/PLP.pm index 2cb68ea..a919cb7 100644 --- a/PLP.pm +++ b/PLP.pm @@ -80,26 +80,14 @@ sub error { } } -# This is run by the CGI script. (#!perl \n use PLP; PLP::everything;) +# Wrap old request handlers. sub everything { require PLP::CGI; - clean(); - PLP::CGI::init(); - start(); + PLP::CGI::everything(); } - -# This is the mod_perl handler. sub handler { require PLP::Apache; - require Apache::Constants; - clean(); - if (my $ret = PLP::Apache::init($_[0])) { - return $ret; - } - #S start($_[0]); - start(); - no strict 'subs'; - return Apache::Constants::OK(); + PLP::Apache::handler(@_); } # Sends the headers waiting in %PLP::Script::header @@ -277,7 +265,7 @@ PLP - Perl in HTML pages SetHandler perl-script - PerlHandler PLP + PerlHandler PLP::Apache PerlSendHeader On PerlSetVar PLPcache On @@ -293,8 +281,8 @@ PLP - Perl in HTML pages =item * /foo/bar/plp.cgi (local filesystem address) #!/usr/bin/perl - use PLP; - PLP::everything(); + use PLP::CGI; + PLP::CGI::everything(); =item * httpd.conf (for CGI setup) diff --git a/PLP/Apache.pm b/PLP/Apache.pm index 217546f..a18ed25 100644 --- a/PLP/Apache.pm +++ b/PLP/Apache.pm @@ -4,6 +4,9 @@ use strict; our $VERSION = '1.00'; +use PLP; +require Apache::Constants; + # mod_perl initializer: returns 0 on success, Apache error code on failure sub init { our $r = shift; @@ -39,5 +42,17 @@ sub print { $PLP::Apache::r->print(@_); } +# This is the mod_perl handler. +sub handler { + PLP::clean(); + if (my $ret = init($_[0])) { + return $ret; + } + #S PLP::start($_[0]); + PLP::start(); + no strict 'subs'; + return Apache::Constants::OK(); +} + 1; diff --git a/PLP/CGI.pm b/PLP/CGI.pm index 1e4d7de..2e23059 100644 --- a/PLP/CGI.pm +++ b/PLP/CGI.pm @@ -4,6 +4,8 @@ use strict; our $VERSION = '1.00'; +use PLP; + # CGI initializer: parses PATH_TRANSLATED sub init { $PLP::print = 'print'; @@ -41,12 +43,12 @@ sub init { $PLP::code = PLP::source($file, 0, undef, $path); } -# This is run by the CGI script. (#!perl \n use PLP; PLP::everything;) -#sub everything { -# clean(); -# cgi_init(); -# start(); -#} +# This is run by the CGI script. (#!perl \n use PLP::CGI; PLP::CGI::everything;) +sub everything { + PLP::clean(); + init(); + PLP::start(); +} 1; -- 2.30.0