mod_include.c revision 10a4cdd68ef1ca0e54af296fe1d08ac00150c90b
0066eddda7203f6345b56f77d146a759298dc635gryzor/* ====================================================================
0066eddda7203f6345b56f77d146a759298dc635gryzor * The Apache Software License, Version 1.1
8d71cfe50621fe78b960ccef99680b89bb61170elgentis * Copyright (c) 2000 The Apache Software Foundation. All rights
0066eddda7203f6345b56f77d146a759298dc635gryzor * reserved.
0066eddda7203f6345b56f77d146a759298dc635gryzor * Redistribution and use in source and binary forms, with or without
0066eddda7203f6345b56f77d146a759298dc635gryzor * modification, are permitted provided that the following conditions
0066eddda7203f6345b56f77d146a759298dc635gryzor * 1. Redistributions of source code must retain the above copyright
0066eddda7203f6345b56f77d146a759298dc635gryzor * notice, this list of conditions and the following disclaimer.
0066eddda7203f6345b56f77d146a759298dc635gryzor * 2. Redistributions in binary form must reproduce the above copyright
0066eddda7203f6345b56f77d146a759298dc635gryzor * notice, this list of conditions and the following disclaimer in
0066eddda7203f6345b56f77d146a759298dc635gryzor * the documentation and/or other materials provided with the
0066eddda7203f6345b56f77d146a759298dc635gryzor * distribution.
0066eddda7203f6345b56f77d146a759298dc635gryzor * 3. The end-user documentation included with the redistribution,
0066eddda7203f6345b56f77d146a759298dc635gryzor * if any, must include the following acknowledgment:
0066eddda7203f6345b56f77d146a759298dc635gryzor * "This product includes software developed by the
0066eddda7203f6345b56f77d146a759298dc635gryzor * Apache Software Foundation (http://www.apache.org/)."
0066eddda7203f6345b56f77d146a759298dc635gryzor * Alternately, this acknowledgment may appear in the software itself,
0066eddda7203f6345b56f77d146a759298dc635gryzor * if and wherever such third-party acknowledgments normally appear.
0066eddda7203f6345b56f77d146a759298dc635gryzor * 4. The names "Apache" and "Apache Software Foundation" must
0066eddda7203f6345b56f77d146a759298dc635gryzor * not be used to endorse or promote products derived from this
0066eddda7203f6345b56f77d146a759298dc635gryzor * software without prior written permission. For written
0066eddda7203f6345b56f77d146a759298dc635gryzor * permission, please contact apache@apache.org.
0066eddda7203f6345b56f77d146a759298dc635gryzor * 5. Products derived from this software may not be called "Apache",
0066eddda7203f6345b56f77d146a759298dc635gryzor * nor may "Apache" appear in their name, without prior written
0066eddda7203f6345b56f77d146a759298dc635gryzor * permission of the Apache Software Foundation.
0066eddda7203f6345b56f77d146a759298dc635gryzor * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
0066eddda7203f6345b56f77d146a759298dc635gryzor * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0066eddda7203f6345b56f77d146a759298dc635gryzor * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0066eddda7203f6345b56f77d146a759298dc635gryzor * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
0066eddda7203f6345b56f77d146a759298dc635gryzor * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0066eddda7203f6345b56f77d146a759298dc635gryzor * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0066eddda7203f6345b56f77d146a759298dc635gryzor * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
0066eddda7203f6345b56f77d146a759298dc635gryzor * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
0066eddda7203f6345b56f77d146a759298dc635gryzor * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3841a292dc897875faf23e639807abcc90082f3clgentis * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
3841a292dc897875faf23e639807abcc90082f3clgentis * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3841a292dc897875faf23e639807abcc90082f3clgentis * SUCH DAMAGE.
3841a292dc897875faf23e639807abcc90082f3clgentis * ====================================================================
3841a292dc897875faf23e639807abcc90082f3clgentis * This software consists of voluntary contributions made by many
3841a292dc897875faf23e639807abcc90082f3clgentis * individuals on behalf of the Apache Software Foundation. For more
3841a292dc897875faf23e639807abcc90082f3clgentis * information on the Apache Software Foundation, please see
8d71cfe50621fe78b960ccef99680b89bb61170elgentis * Portions of this software are based upon public domain software
3841a292dc897875faf23e639807abcc90082f3clgentis * originally written at the National Center for Supercomputing Applications,
3841a292dc897875faf23e639807abcc90082f3clgentis * University of Illinois, Urbana-Champaign.
3841a292dc897875faf23e639807abcc90082f3clgentis * http_include.c: Handles the server-parsed HTML documents
3841a292dc897875faf23e639807abcc90082f3clgentis * Original by Rob McCool; substantial fixups by David Robinson;
3841a292dc897875faf23e639807abcc90082f3clgentis * incorporated into the Apache module framework by rst.
3841a292dc897875faf23e639807abcc90082f3clgentis * sub key may be anything a Perl*Handler can be:
3841a292dc897875faf23e639807abcc90082f3clgentis * subroutine name, package name (defaults to package::handler),
3841a292dc897875faf23e639807abcc90082f3clgentis * Class->method call or anoymous sub {}
3841a292dc897875faf23e639807abcc90082f3clgentis * Child <!--#perl sub="sub {print $$}" --> accessed
3841a292dc897875faf23e639807abcc90082f3clgentis * <!--#perl sub="sub {print ++$Access::Cnt }" --> times. <br>
3841a292dc897875faf23e639807abcc90082f3clgentis * <!--#perl arg="one" sub="mymod::includer" -->
3841a292dc897875faf23e639807abcc90082f3clgentis * -Doug MacEachern
#include "config.h"
#ifdef USE_SFIO
#define USE_STDIO
#include "modules/perl/mod_perl.h"
#include "apr_strings.h"
#include "ap_config.h"
#include "httpd.h"
#include "http_config.h"
#include "http_request.h"
#include "http_core.h"
#include "http_protocol.h"
#include "http_log.h"
#include "http_main.h"
#include "util_script.h"
#include "http_core.h"
#ifdef HAVE_STRING_H
#include <string.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
#include "util_ebcdic.h"
#define SIZEFMT_BYTES 0
#ifdef CHARSET_EBCDIC
#define ap_chdir_file(x) do {} while(0)
#ifndef WIN32
#ifndef WIN32
if (pw) {
if (r->args) {
#define PUT_CHAR(c,r) \
FLUSH_BUF(r) \
#define FLUSH_BUF(r) \
outind = 0; \
FLUSH_BUF(r); \
apr_close(f); \
return ret; \
int outind = 0;
if (c == str[p]) {
FLUSH_BUF(r);
if (printing) {
PUT_CHAR(c, r);
#define GET_CHAR(f,c,r,p) \
apr_close(f); \
static void decodehtml(char *s)
int val, i, j;
const char *ents;
--tagbuf_len;
} while (apr_isspace(c));
} while (apr_isspace(c));
return tag;
return NULL;
*(t++) = apr_tolower(c);
tag_val = t;
while (apr_isspace(c)) {
return NULL;
} while (apr_isspace(c));
return NULL;
term = c;
return NULL;
else if (c == term) {
if (dodecode) {
char *d = dest;
--len;
if (!apr_isspace(c)) {
*d++ = apr_tolower(c);
if (apr_isspace(c)) {
char ch;
char *end_out;
switch (ch) {
const char *start_of_var_name;
const char *expansion;
const char *val;
size_t l;
++in;
++in;
++in;
if (val) {
else if (leave_name) {
next += l;
int rr_status;
#ifdef HAVE_DRIVE_LETTERS
while (*path) {
++path;
char *tag_val;
int founddupe = 0;
request_rec *p;
request_rec *q;
if (p != NULL) {
if (rr)
if (error_fmt) {
!= NESTED_INCLUDE_MAGIC) {
#ifdef TPF
request_rec *r;
++numwords;
ap_unescape_url(w);
return APR_SUCCESS;
char **argv;
&core_module);
arg.r = r;
arg.s = s;
#ifdef TPF
NULL));
if (r->args) {
#ifdef RLIMIT_CPU
#ifdef RLIMIT_NPROC
if (!iol)
return APR_EBADF;
char *tag_val;
char *tag_val;
if (val) {
#ifdef USE_PERL_SSI
char *tag_val;
r->filename);
return DECLINED;
perl_setup_env(r);
return OK;
int *sizefmt)
char *tag_val;
int ret=0;
if (error_fmt) {
return ret;
char *tag_val;
char *tag_val;
int regex_error;
return (!regex_error);
enum token_type {
struct token {
char ch;
int next = 0;
int qs = 0;
return (char *) NULL;
return (char *) NULL;
switch (ch) {
return (string);
return (string);
return (string);
return (string);
return (string);
return (string);
if (!qs) {
* but that is (IMHO) even less readable/maintainable than the goto.
goto TOKEN_DONE;
if (!qs) {
goto TOKEN_DONE;
switch (ch) {
goto TOKEN_DONE;
goto TOKEN_DONE;
goto TOKEN_DONE;
goto TOKEN_DONE;
goto TOKEN_DONE;
goto TOKEN_DONE;
goto TOKEN_DONE;
goto TOKEN_DONE;
qs = 0;
++string;
goto TOKEN_DONE;
if (qs) {
next = 0;
return (string);
struct parse_node {
const char *parse;
int retval = 0;
sizeof(struct parse_node));
case token_string:
#ifdef DEBUG_INCLUDE
case token_string:
case token_eq:
case token_ne:
case token_and:
case token_or:
case token_lbrace:
case token_not:
case token_ge:
case token_gt:
case token_le:
case token_lt:
goto RETURN;
case token_and:
case token_or:
#ifdef DEBUG_INCLUDE
goto RETURN;
case token_string:
case token_group:
case token_not:
case token_eq:
case token_ne:
case token_and:
case token_or:
case token_ge:
case token_gt:
case token_le:
case token_lt:
case token_lbrace:
goto RETURN;
case token_not:
#ifdef DEBUG_INCLUDE
case token_not:
case token_eq:
case token_ne:
case token_and:
case token_or:
case token_lbrace:
case token_ge:
case token_gt:
case token_le:
case token_lt:
goto RETURN;
case token_eq:
case token_ne:
case token_ge:
case token_gt:
case token_le:
case token_lt:
#ifdef DEBUG_INCLUDE
goto RETURN;
case token_string:
case token_group:
case token_lbrace:
case token_and:
case token_or:
case token_not:
case token_eq:
case token_ne:
case token_ge:
case token_gt:
case token_le:
case token_lt:
goto RETURN;
case token_rbrace:
#ifdef DEBUG_INCLUDE
goto RETURN;
case token_lbrace:
#ifdef DEBUG_INCLUDE
case token_not:
case token_eq:
case token_ne:
case token_and:
case token_or:
case token_lbrace:
case token_ge:
case token_gt:
case token_le:
case token_lt:
case token_string:
case token_group:
goto RETURN;
case token_string:
#ifdef DEBUG_INCLUDE
case token_and:
case token_or:
#ifdef DEBUG_INCLUDE
goto RETURN;
case token_string:
case token_string:
#ifdef DEBUG_INCLUDE
#ifdef DEBUG_INCLUDE
case token_eq:
case token_ne:
#ifdef DEBUG_INCLUDE
goto RETURN;
int len;
goto RETURN;
#ifdef DEBUG_INCLUDE
#ifdef DEBUG_INCLUDE
#ifdef DEBUG_INCLUDE
case token_ge:
case token_gt:
case token_le:
case token_lt:
#ifdef DEBUG_INCLUDE
goto RETURN;
#ifdef DEBUG_INCLUDE
#ifdef DEBUG_INCLUDE
case token_not:
#ifdef DEBUG_INCLUDE
case token_group:
#ifdef DEBUG_INCLUDE
case token_lbrace:
goto RETURN;
case token_rbrace:
goto RETURN;
goto RETURN;
return (retval);
char *tag_val;
char *expr;
r->filename);
#ifdef DEBUG_INCLUDE
#ifdef DEBUG_INCLUDE
char *tag_val;
char *expr;
#ifdef DEBUG_INCLUDE
if (*conditional_status) {
*printing = 0;
r->filename);
#ifdef DEBUG_INCLUDE
#ifdef DEBUG_INCLUDE
#ifdef DEBUG_INCLUDE
r->filename);
if (*printing) {
#ifdef DEBUG_INCLUDE
r->filename);
char *tag_val;
char *var;
r->filename);
char *tag_val;
r->filename);
int if_nesting;
int printing;
int conditional_status;
if_nesting = 0;
r->filename);
if (!printing) {
if_nesting++;
&printing);
if_nesting = 0;
if (!if_nesting) {
&printing);
if (!if_nesting) {
&printing);
if (!if_nesting) {
&printing);
if_nesting--;
if (!printing) {
if (noexec) {
r->filename);
if (printing) {
#ifdef USE_PERL_SSI
if (printing) {
if (ret) {
r->filename);
enum xbithack {
#ifdef XBITHACK
return result;
return NULL;
int errstatus;
return DECLINED;
return DECLINED;
(r->path_info
: r->filename));
return HTTP_NOT_FOUND;
return HTTP_FORBIDDEN;
return errstatus;
if (r->header_only) {
apr_close(f);
return OK;
ap_add_cgi_vars(r);
#ifdef CHARSET_EBCDIC
send_parsed_content(f, r);
if (parent) {
return OK;
return send_parsed_file(r);
return DECLINED;
return DECLINED;
return DECLINED;
return send_parsed_file(r);
{NULL}
{NULL}