httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Hartill <r...@imdb.com>
Subject Re: [STATUS] Mon May 26 21:01:36 EDT 1997
Date Tue, 27 May 1997 15:22:02 GMT
On Mon, 26 May 1997, Ed Korthof wrote:

> >   * RobH's [PATCH]: request for harmless mod_include.c patch (try 2)
> >     <Pine.NEB.3.96.970515223445.22142A-100000@localhost.imdb.com>
> >     Status: +1 RobH
> >             +0 Roy [I've never seen a harmless part of mod_include]
> >                (It should also be USE_PERL_SSI, not USE_PERL)
> 
> If you still want this in, Rob, could you resend it?  I accidentally
> deleted it; I'd be willing to take a look at it & test it out, though.

Here it is (attached). Doug, note the 'USE_PERL_SSI' as recommended by Roy.

Ed, you'll need the latest mod_perl and something like:
EXTRA_CFLAGS= -I./ -I/usr/local/lib/perl5/i386-freebsd/5.003/CORE -DUSE_PERL_SSI

replace 'i386-freebsd' to match your system.

The latest mod_perl is at:

	http://www.osf.org/~dougm/apache/src/dev/

if that dir is empty, try the next level up.


I'm using this patch on my live servers so it's had a damn good testing.
It's far more efficient than 'virtual include' because the perl is called
directly and immediately without the need for subrequests.

BTW, Doug's added mod_perl processing of config files too. You should
see the tricks you can do with Perl code in srm.conf !  :-)


--
Rob Hartill                              Internet Movie Database (Ltd)
http://www.moviedatabase.com/   .. a site for sore eyes.

===========================================================================

Index: mod_include.c
===================================================================
RCS file: /imdb/cvs/apache/src/mod_include.c,v
retrieving revision 1.10
diff -u -r1.10 mod_include.c
--- mod_include.c	1997/05/11 20:40:26	1.10
+++ mod_include.c	1997/05/27 15:06:14
@@ -57,7 +57,22 @@
  * incorporated into the Apache module framework by rst.
  * 
  */
+/* 
+ * sub key may be anything a Perl*Handler can be:
+ * subroutine name, package name (defaults to package::handler),
+ * Class->method call or anoymous sub {}
+ *
+ * Child <!--#perl sub="sub {print $$}" --> accessed
+ * <!--#perl sub="sub {print ++$Access::Cnt }" --> times. <br>
+ *
+ * <!--#perl arg="one" sub="mymod::includer" -->
+ *
+ * -Doug MacEachern
+ */
 
+#ifdef USE_PERL_SSI
+#include "modules/perl/mod_perl.h"
+#else
 #include "httpd.h"
 #include "http_config.h"
 #include "http_request.h"
@@ -66,6 +81,7 @@
 #include "http_log.h"
 #include "http_main.h"
 #include "util_script.h"
+#endif
 
 #define STARTING_SEQUENCE "<!--#"
 #define ENDING_SEQUENCE "-->"
@@ -710,6 +726,32 @@
         }
     }
 }
+#ifdef USE_PERL_SSI
+int handle_perl (FILE *in, request_rec *r, char *error) {
+    char tag[MAX_STRING_LEN];
+    char *tag_val;
+    SV *sub = Nullsv;
+    AV *av  = newAV();
+
+    if (!(allow_options (r) & OPT_INCLUDES)) {
+        log_printf(r->server,
+            "httpd: #perl SSI disallowed by IncludesNoExec in %s", r->filename);
+	return DECLINED;
+    }
+    while(1) {
+	if(!(tag_val = get_tag (r->pool, in, tag, MAX_STRING_LEN, 1))) 
+	    break;
+	if(strnEQ(tag, "sub", 3)) 
+	    sub = newSVpv(tag_val,0);
+	else if(strnEQ(tag, "arg", 3)) 
+	    av_push(av, newSVpv(tag_val,0));	
+	else if(strnEQ(tag,"done", 4))
+	    break;
+    }
+    perl_call_handler(sub, r, av);
+    return OK;
+}
+#endif
 
 /* error and tf must point to a string with room for at 
  * least MAX_STRING_LEN characters 
@@ -1674,6 +1716,10 @@
                 ret=handle_flastmod(f, r, error, timefmt);
             else if(!strcmp(directive,"printenv"))
                 ret=handle_printenv(f, r, error);
+#ifdef USE_PERL_SSI
+            else if(!strcmp(directive,"perl")) 
+                ret=handle_perl(f, r, error);
+#endif
             else {
                 log_printf(r->server,
                         "httpd: unknown directive %s in parsed doc %s",





Mime
View raw message