mod_include.c revision 50e59a535cafd083838a173aedf9cfa6917d016d
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
/*
* http_include.c: Handles the server-parsed HTML documents
*
* Original by Rob McCool; substantial fixups by David Robinson;
* 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
*/
#define CORE_PRIVATE
#ifdef USE_PERL_SSI
#include "config.h"
#ifdef USE_SFIO
#define USE_STDIO
#endif
#include "modules/perl/mod_perl.h"
#else
#include "apr_strings.h"
#include "ap_config.h"
#include "util_filter.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>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#endif
#include "util_ebcdic.h"
#define STARTING_SEQUENCE "<!--#"
#define ENDING_SEQUENCE "-->"
#define DEFAULT_ERROR_MSG "[an error occurred while processing this directive]"
#define DEFAULT_TIME_FORMAT "%A, %d-%b-%Y %H:%M:%S %Z"
#define SIZEFMT_BYTES 0
#define SIZEFMT_KMG 1
#ifdef CHARSET_EBCDIC
#else /*CHARSET_EBCDIC*/
#endif /*CHARSET_EBCDIC*/
/* just need some arbitrary non-NULL pointer which can't also be a request_rec */
#define NESTED_INCLUDE_MAGIC (&includes_module)
/* TODO: changing directory should be handled by CreateProcess */
#define ap_chdir_file(x) do {} while(0)
/* ------------------------ Environment function -------------------------- */
/* XXX: could use ap_table_overlap here */
{
#ifndef WIN32
#endif /* ndef WIN32 */
apr_table_t *e = r->subprocess_env;
char *t;
apr_table_setn(e, "LAST_MODIFIED",
#ifndef WIN32
if (pw) {
}
else {
}
#endif /* ndef WIN32 */
apr_table_setn(e, "DOCUMENT_NAME", ++t);
}
else {
}
if (r->args) {
apr_table_setn(e, "QUERY_STRING_UNESCAPED",
}
}
/* --------------------------- Parser functions --------------------------- */
#define OUTBUFSIZE 4096
{
const char *c;
const char *buf;
int state = 0;
do {
if (AP_BUCKET_IS_EOS(dptr)) {
break;
}
/* XXX handle retcodes */
if (len == 0) { /* end of pipe? */
break;
}
c = buf;
state++;
}
else {
/* We want to split the bucket at the '<' and '>'
* respectively. That means adjusting where we split based
* on what we are searching for.
*/
if (str[0] == '<') {
}
else {
}
return AP_BUCKET_NEXT(dptr);
}
else {
state = 0;
/* The reason for this, is that we need to make sure
* that we catch cases like <<--#. This makes the
* second check after the original check fails.
*/
state++;
}
}
}
c++;
}
return NULL;
}
/*
* decodes a string containing html entities or numeric character references.
* 's' is overwritten with the decoded string.
* If 's' is syntatically incorrect, then the followed fixups will be made:
* unknown entities will be left undecoded;
* references to unused numeric characters will be deleted.
* In particular, � will not be decoded, but will be deleted.
*
* drtr
*/
/* maximum length of any ISO-LATIN-1 HTML entity name. */
#define MAXENTLEN (6)
/* The following is a shrinking transformation, therefore safe. */
static void decodehtml(char *s)
{
int val, i, j;
char *p = s;
const char *ents;
{
NULL, /* 0 */
NULL, /* 1 */
"lt\074gt\076", /* 2 */
"amp\046ETH\320eth\360", /* 3 */
"quot\042Auml\304Euml\313Iuml\317Ouml\326Uuml\334auml\344euml\353\
iuml\357ouml\366uuml\374yuml\377", /* 4 */
"Acirc\302Aring\305AElig\306Ecirc\312Icirc\316Ocirc\324Ucirc\333\
THORN\336szlig\337acirc\342aring\345aelig\346ecirc\352icirc\356ocirc\364\
ucirc\373thorn\376", /* 5 */
"Agrave\300Aacute\301Atilde\303Ccedil\307Egrave\310Eacute\311\
Igrave\314Iacute\315Ntilde\321Ograve\322Oacute\323Otilde\325Oslash\330\
Ugrave\331Uacute\332Yacute\335agrave\340aacute\341atilde\343ccedil\347\
egrave\350eacute\351igrave\354iacute\355ntilde\361ograve\362oacute\363\
otilde\365oslash\370ugrave\371uacute\372yacute\375" /* 6 */
};
for (; *s != '\0'; s++, p++) {
if (*s != '&') {
*p = *s;
continue;
}
/* find end of entity */
for (i = 1; s[i] != ';' && s[i] != '\0'; i++) {
continue;
}
if (s[i] == '\0') { /* treat as normal data */
*p = *s;
continue;
}
/* is it numeric ? */
if (s[1] == '#') {
}
s += i;
p--; /* no data to output */
}
else {
*p = RAW_ASCII_CHAR(val);
}
}
else {
j = i - 1;
/* wrong length */
*p = '&';
continue; /* skip it */
}
break;
}
}
if (*ents == '\0') {
*p = '&'; /* unknown */
}
else {
*p = RAW_ASCII_CHAR(((const unsigned char *) ents)[j]);
s += i;
}
}
}
*p = '\0';
}
/*
* extract the next tag name and value.
* if there are no more tags, set the tag name to 'done'
* the tag value is html decoded if dodecode is non-zero
*/
static char *get_tag(apr_pool_t *p, ap_bucket *in, char *tag, int tagbuf_len, int dodecode, apr_off_t *offset)
{
const char *c;
const char *str;
/* makes code below a little less cluttered */
--tagbuf_len;
/* Remove all whitespace */
while (dptr) {
if (!apr_isspace(*c)) {
break;
}
}
if (!apr_isspace(*c)) {
break;
}
}
/* tags can't start with - */
if (*c == '-') {
c++;
if (c == '\0') {
c = str;
}
if (*c == '-') {
do {
c++;
if (c == '\0') {
c = str;
}
} while (apr_isspace(*c));
if (*c == '>') {
return tag;
}
}
return NULL; /* failed */
}
/* find end of tag name */
while (1) {
if (t - tag == tagbuf_len) {
*t = '\0';
return NULL;
}
if (*c == '=' || apr_isspace(*c)) {
break;
}
*(t++) = apr_tolower(*c);
c++;
if (c == '\0') {
c = str;
}
}
*t++ = '\0';
tag_val = t;
while (apr_isspace(*c)) {
c++;
if (c == '\0') {
c = str;
}
}
if (*c != '=') {
/* XXX may need to ungetc() here (see pre-bucketized code) */
return NULL;
}
do {
c++;
if (c == '\0') {
c = str;
}
} while (apr_isspace(*c));
/* we should allow a 'name' as a value */
if (*c != '"' && *c != '\'') {
return NULL;
}
term = *c;
while (1) {
c++;
if (c == '\0') {
c = str;
}
if (t - tag == tagbuf_len) {
*t = '\0';
return NULL;
}
/* Want to accept \" as a valid character within a string. */
if (*c == '\\') {
*(t++) = *c; /* Add backslash */
c++;
if (c == '\0') {
c = str;
}
if (*c == term) { /* Only if */
*(--t) = *c; /* Replace backslash ONLY for terminator */
}
}
else if (*c == term) {
break;
}
*(t++) = *c;
}
*t = '\0';
if (dodecode) {
}
return apr_pstrdup(p, tag_val);
}
{
char *d = dest;
const char *c;
const char *str;
/* make room for nul terminator */
--len;
while (dptr) {
/* need to start past the <!--#
*/
if (!apr_isspace(*c)) {
break;
}
}
if (!apr_isspace(*c)) {
break;
}
}
/* now get directive */
while (dptr) {
}
return 1;
}
*d++ = apr_tolower(*c);
c++;
if (apr_isspace(*c)) {
break;
}
}
if (apr_isspace(*c)) {
break;
}
}
*d = '\0';
return 0;
}
/*
* Do variable substitution on strings
*/
{
char ch;
char *end_out;
/* leave room for nul terminator */
switch (ch) {
case '\\':
/* truncated */
*next = '\0';
return;
}
if (*in == '$') {
}
else {
}
break;
case '$':
{
char var[MAX_STRING_LEN];
const char *start_of_var_name;
const char *end_of_var_name; /* end of var name + 1 */
const char *expansion;
const char *val;
size_t l;
/* guess that the expansion won't happen */
if (*in == '{') {
++in;
0, r, "Missing '}' on variable \"%s\"",
*next = '\0';
return;
}
++in;
}
else {
++in;
}
}
/* what a pain, too bad there's no table_getn where you can
* pass a non-nul terminated string */
l = end_of_var_name - start_of_var_name;
if (l != 0) {
var[l] = '\0';
if (val) {
}
else if (leave_name) {
}
else {
break; /* no expansion to be done */
}
}
else {
/* zero-length variable name causes just the $ to be copied */
l = 1;
}
next += l;
break;
}
default:
/* truncated */
*next = '\0';
return;
}
break;
}
}
*next = '\0';
return;
}
/* --------------------------- Action handlers ---------------------------- */
{
int rr_status;
return -1;
}
/* No hardwired path info or query allowed */
return -1;
}
return -1;
}
/* Script gets parameters of the *document*, for back compatibility */
/* Force sub_req to be treated as a CGI request, even if ordinary
* typing rules would have called it something else.
*/
/* The subrequest should inherit the remaining filters from this request. */
/* Run it. */
if (ap_is_HTTP_REDIRECT(rr_status)) {
}
ap_chdir_file(r->filename);
return 0;
}
/* ensure that path is relative, and does not contain ".." elements
* ensentially ensure that it does not match the regex:
* (^/|(^|/)\.\.(/|$))
* XXX: Needs to become apr_is_path_relative() test
*/
static int is_only_below(const char *path)
{
#ifdef HAVE_DRIVE_LETTERS
return 0;
#endif
#ifdef NETWARE
return 0;
#endif
if (path[0] == '/') {
return 0;
}
while (*path) {
int dots = 0;
++dots;
#if defined(WIN32)
/* If the name is canonical this is redundant
* but in security, redundancy is worthwhile.
* Does OS2 belong here (accepts ... for ..)?
*/
return 0;
#else
return 0;
#endif
++path;
}
return 1;
}
{
char tag[MAX_STRING_LEN];
char parsed_string[MAX_STRING_LEN];
char *tag_val;
while (1) {
return 1;
}
if (tag[0] == 'f') {
/* be safe; only files in this directory or below allowed */
if (!is_only_below(parsed_string)) {
error_fmt = "unable to include file \"%s\" "
"in parsed file %s";
}
else {
}
}
else {
}
error_fmt = "unable to include \"%s\" in parsed file %s";
}
error_fmt = "unable to include potential exec \"%s\" "
"in parsed file %s";
}
/* try to avoid recursive includes. We do this by walking
* up the r->main list of subrequests, and at each level
* walking back through any internal redirects. At each
* step, we compare the filenames and the URIs.
*
* The filename comparison catches a recursive include
* with an ever-changing URL, eg.
* <!--#include virtual=
* "$REQUEST_URI/$QUERY_STRING?$QUERY_STRING/x"-->
* which, although they would eventually be caught because
* we have a limit on the length of files, etc., can
* recurse for a while.
*
* The URI comparison catches the case where the filename
* is changed while processing the request, so the
* current name is never the same as any previous one.
* This can happen with "DocumentRoot /foo" when you
* request "/" on the server and it includes "/".
* This only applies to modules such as mod_dir that
* (somewhat improperly) mess with r->filename outside
* of a filename translation phase.
*/
int founddupe = 0;
request_rec *p;
request_rec *q;
founddupe = 1;
break;
}
}
}
if (p != NULL) {
error_fmt = "Recursive include of \"%s\" "
"in parsed file %s";
}
}
/* see the Kludge in send_parsed_file for why */
if (rr)
if (!error_fmt) {
/* The subrequest should inherit the remaining filters from
* this request. */
if (ap_run_sub_req(rr)) {
error_fmt = "unable to include \"%s\" in parsed file %s";
}
}
ap_chdir_file(r->filename);
if (error_fmt) {
}
/* destroy the sub request if it's not a nested include */
!= NESTED_INCLUDE_MAGIC) {
}
}
return 0;
}
else {
"unknown parameter \"%s\" to tag include in %s",
}
}
}
typedef struct {
#ifdef TPF
#endif
request_rec *r;
char *s;
{
char *w;
numwords = 1;
}
else {
/* count the number of keywords */
if (args[x] == '+') {
++numwords;
}
}
}
/* Everything is - 1 to account for the first parameter which is the
* program name. We didn't used to have to do this, but APR wants it.
*/
}
ap_unescape_url(w);
}
return APR_SUCCESS;
}
{
char **argv;
#if defined(RLIMIT_CPU) || defined(RLIMIT_NPROC) || \
&core_module);
#endif
arg.r = r;
arg.s = s;
#ifdef TPF
#endif
NULL));
}
}
if (r->args) {
}
#ifdef RLIMIT_CPU
#endif
#endif
#ifdef RLIMIT_NPROC
#endif
/* Something bad happened, tell the world. */
"couldn't initialize proc attributes: %s %s", r->filename, s);
rc = !APR_SUCCESS;
}
else {
if (rc != APR_SUCCESS) {
/* Bad things happened. Everyone should have cleaned up. */
"couldn't create child process: %d: %s", rc, s);
}
else {
ap_bucket *b;
/* Fill in BUFF structure for parents pipe to child's stdout */
if (!file)
return APR_EBADF;
b = ap_bucket_create_pipe(file);
/* We can't close the pipe here, because we may return before the
* full CGI has been sent to the network. That's okay though,
* because we can rely on the pool to close the pipe for us.
*/
}
}
return 0;
}
{
char tag[MAX_STRING_LEN];
char *tag_val;
char parsed_string[MAX_STRING_LEN];
while (1) {
return 1;
}
"execution failure for parameter \"%s\" "
"to tag exec in file %s",
}
/* just in case some stooge changed directories */
ap_chdir_file(r->filename);
}
}
ap_chdir_file(r->filename);
}
return 0;
}
else {
"unknown parameter \"%s\" to tag exec in %s",
}
}
}
{
char tag[MAX_STRING_LEN];
char *tag_val;
while (1) {
return 1;
}
if (val) {
}
}
}
}
else {
ap_rputs("(none)", r);
}
}
return 0;
}
else {
"unknown value \"%s\" to parameter \"encoding\" of "
"tag echo in %s",
}
}
else {
"unknown parameter \"%s\" to tag echo in %s",
}
}
}
#ifdef USE_PERL_SSI
{
char tag[MAX_STRING_LEN];
char parsed_string[MAX_STRING_LEN];
char *tag_val;
if (ap_allow_options(r) & OPT_INCNOEXEC) {
"#perl SSI disallowed by IncludesNoExec in %s",
r->filename);
return DECLINED;
}
while (1) {
break;
}
}
}
break;
}
}
perl_setup_env(r);
return OK;
}
#endif
/* error and tf must point to a string with room for at
* least MAX_STRING_LEN characters
*/
int *sizefmt)
{
char tag[MAX_STRING_LEN];
char *tag_val;
char parsed_string[MAX_STRING_LEN];
while (1) {
return 1;
}
}
}
*sizefmt = SIZEFMT_BYTES;
}
*sizefmt = SIZEFMT_KMG;
}
}
return 0;
}
else {
"unknown parameter \"%s\" to tag config in %s",
}
}
}
{
int ret=0;
/* be safe; only files in this directory or below allowed */
if (!is_only_below(tag_val)) {
error_fmt = "unable to access file \"%s\" "
"in parsed file %s";
}
else {
error_fmt = "unable to get information about \"%s\" "
"in parsed file %s";
}
}
else {
error_fmt = "unable to lookup information about \"%s\" "
"in parsed file %s";
}
}
if (error_fmt) {
ret = -1;
/* TODO: pass APLOG_NOERRNO if no apr_stat() failure; pass rv from apr_stat()
* otherwise
*/
}
return ret;
}
return 0;
}
else {
"unable to get information about \"%s\" "
"in parsed file %s",
return -1;
}
}
else {
"unknown parameter \"%s\" to tag %s in %s",
return -1;
}
}
{
char tag[MAX_STRING_LEN];
char *tag_val;
char parsed_string[MAX_STRING_LEN];
while (1) {
return 1;
}
return 0;
}
else {
if (sizefmt == SIZEFMT_KMG) {
}
else {
int l, x;
for (x = 0; x < l; x++) {
if (x && (!((l - x) % 3))) {
ap_rputc(',', r);
}
}
}
}
}
}
}
{
char tag[MAX_STRING_LEN];
char *tag_val;
char parsed_string[MAX_STRING_LEN];
while (1) {
return 1;
}
return 0;
}
else {
}
}
}
}
{
int regex_error;
"unable to compile pattern \"%s\"", rexp);
return -1;
}
return (!regex_error);
}
enum token_type {
};
struct token {
enum token_type type;
char value[MAX_STRING_LEN];
};
/* there is an implicit assumption here that string is at most MAX_STRING_LEN-1
* characters long...
*/
{
char ch;
int next = 0;
int qs = 0;
/* Skip leading white space */
return (char *) NULL;
}
if (!apr_isspace(ch)) {
break;
}
}
if (ch == '\0') {
return (char *) NULL;
}
switch (ch) {
case '(':
return (string);
case ')':
return (string);
case '=':
return (string);
case '!':
if (*string == '=') {
return (string + 1);
}
else {
return (string);
}
case '\'':
qs = 1;
break;
case '|':
if (*string == '|') {
return (string + 1);
}
break;
case '&':
if (*string == '&') {
return (string + 1);
}
break;
case '>':
if (*string == '=') {
return (string + 1);
}
else {
return (string);
}
case '<':
if (*string == '=') {
return (string + 1);
}
else {
return (string);
}
default:
break;
}
/* We should only be here if we are in a string */
if (!qs) {
}
/*
* Yes I know that goto's are BAD. But, c doesn't allow me to
* exit a loop from a switch statement. Yes, I could use a flag,
* but that is (IMHO) even less readable/maintainable than the goto.
*/
/*
* I used the ++string throughout this section so that string
* ends up pointing to the next token and I can just return it
*/
if (ch == '\\') {
goto TOKEN_DONE;
}
continue;
}
if (!qs) {
if (apr_isspace(ch)) {
goto TOKEN_DONE;
}
switch (ch) {
case '(':
goto TOKEN_DONE;
case ')':
goto TOKEN_DONE;
case '=':
goto TOKEN_DONE;
case '!':
goto TOKEN_DONE;
case '|':
goto TOKEN_DONE;
}
break;
case '&':
goto TOKEN_DONE;
}
break;
case '<':
goto TOKEN_DONE;
case '>':
goto TOKEN_DONE;
}
}
else {
if (ch == '\'') {
qs = 0;
++string;
goto TOKEN_DONE;
}
}
}
/* If qs is still set, I have an unmatched ' */
if (qs) {
ap_rputs("\nUnmatched '\n", r);
next = 0;
}
return (string);
}
/*
* Hey I still know that goto's are BAD. I don't think that I've ever
* used two in the same project, let alone the same file before. But,
* I absolutely want to make sure that I clean up the memory in all
* cases. And, without rewriting this completely, the easiest way
* is to just branch to the return code which cleans it up.
*/
/* there is an implicit assumption here that expr is at most MAX_STRING_LEN-1
* characters long...
*/
{
struct parse_node {
const char *parse;
char buffer[MAX_STRING_LEN];
int retval = 0;
return (0);
}
return 0;
/* Create Parse Tree */
while (1) {
sizeof(struct parse_node));
break;
}
case token_string:
#ifdef DEBUG_INCLUDE
#endif
break;
}
case token_string:
}
break;
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:
break;
default:
"Invalid expression \"%s\" in file %s",
goto RETURN;
}
break;
case token_and:
case token_or:
#ifdef DEBUG_INCLUDE
#endif
"Invalid expression \"%s\" in file %s",
goto RETURN;
}
/* Percolate upwards */
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:
continue;
case token_lbrace:
break;
default:
"Invalid expression \"%s\" in file %s",
goto RETURN;
}
break;
}
}
else {
}
break;
case token_not:
#ifdef DEBUG_INCLUDE
ap_rputs(" Token: not\n", r);
#endif
break;
}
/* Percolate upwards */
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:
break;
default:
"Invalid expression \"%s\" in file %s",
goto RETURN;
}
break;
}
}
else {
}
break;
case token_eq:
case token_ne:
case token_ge:
case token_gt:
case token_le:
case token_lt:
#ifdef DEBUG_INCLUDE
#endif
"Invalid expression \"%s\" in file %s",
goto RETURN;
}
/* Percolate upwards */
case token_string:
case token_group:
continue;
case token_lbrace:
case token_and:
case token_or:
break;
case token_not:
case token_eq:
case token_ne:
case token_ge:
case token_gt:
case token_le:
case token_lt:
default:
"Invalid expression \"%s\" in file %s",
goto RETURN;
}
break;
}
}
else {
}
break;
case token_rbrace:
#ifdef DEBUG_INCLUDE
ap_rputs(" Token: rbrace\n", r);
#endif
break;
}
}
"Unmatched ')' in \"%s\" in file %s",
goto RETURN;
}
break;
case token_lbrace:
#ifdef DEBUG_INCLUDE
ap_rputs(" Token: lbrace\n", r);
#endif
break;
}
/* Percolate upwards */
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:
break;
case token_string:
case token_group:
default:
"Invalid expression \"%s\" in file %s",
goto RETURN;
}
break;
}
}
else {
}
break;
default:
break;
}
}
/* Evaluate Parse Tree */
case token_string:
#ifdef DEBUG_INCLUDE
ap_rputs(" Evaluate string\n", r);
#endif
break;
case token_and:
case token_or:
#ifdef DEBUG_INCLUDE
#endif
"Invalid expression \"%s\" in file %s",
goto RETURN;
}
case token_string:
break;
default:
continue;
}
}
case token_string:
break;
default:
continue;
}
}
#ifdef DEBUG_INCLUDE
"\n", NULL);
"\n", NULL);
#endif
}
else {
}
#ifdef DEBUG_INCLUDE
"\n", NULL);
#endif
break;
case token_eq:
case token_ne:
#ifdef DEBUG_INCLUDE
#endif
"Invalid expression \"%s\" in file %s",
goto RETURN;
}
int len;
}
else {
"Invalid rexp \"%s\" in file %s",
goto RETURN;
}
#ifdef DEBUG_INCLUDE
#endif
}
else {
#ifdef DEBUG_INCLUDE
#endif
}
}
#ifdef DEBUG_INCLUDE
"\n", NULL);
#endif
break;
case token_ge:
case token_gt:
case token_le:
case token_lt:
#ifdef DEBUG_INCLUDE
#endif
"Invalid expression \"%s\" in file %s",
goto RETURN;
}
#ifdef DEBUG_INCLUDE
#endif
}
}
}
}
else {
}
#ifdef DEBUG_INCLUDE
"\n", NULL);
#endif
break;
case token_not:
continue;
}
}
else {
}
#ifdef DEBUG_INCLUDE
"\n", NULL);
#endif
break;
case token_group:
continue;
}
}
else {
}
#ifdef DEBUG_INCLUDE
"\n", NULL);
#endif
break;
case token_lbrace:
"Unmatched '(' in \"%s\" in file %s",
goto RETURN;
case token_rbrace:
"Unmatched ')' in \"%s\" in file %s",
goto RETURN;
default:
"bad token type");
goto RETURN;
}
}
return (retval);
}
int *conditional_status, int *printing)
{
char tag[MAX_STRING_LEN];
char *tag_val;
char *expr;
while (1) {
if (*tag == '\0') {
return 1;
}
"missing expr in if statement: %s",
r->filename);
return 1;
}
#ifdef DEBUG_INCLUDE
ap_rvputs(r, "**** if conditional_status=\"",
#endif
return 0;
}
#ifdef DEBUG_INCLUDE
#endif
}
else {
"unknown parameter \"%s\" to tag if in %s",
}
}
}
int *conditional_status, int *printing)
{
char tag[MAX_STRING_LEN];
char *tag_val;
char *expr;
while (1) {
if (*tag == '\0') {
return 1;
}
#ifdef DEBUG_INCLUDE
ap_rvputs(r, "**** elif conditional_status=\"",
#endif
if (*conditional_status) {
*printing = 0;
return (0);
}
"missing expr in elif statement: %s",
r->filename);
return 1;
}
#ifdef DEBUG_INCLUDE
ap_rvputs(r, "**** elif conditional_status=\"",
#endif
return 0;
}
#ifdef DEBUG_INCLUDE
#endif
}
else {
"unknown parameter \"%s\" to tag if in %s",
}
}
}
int *conditional_status, int *printing)
{
char tag[MAX_STRING_LEN];
return 1;
}
#ifdef DEBUG_INCLUDE
ap_rvputs(r, "**** else conditional_status=\"",
#endif
*printing = !(*conditional_status);
*conditional_status = 1;
return 0;
}
else {
"else directive does not take tags in %s",
r->filename);
if (*printing) {
}
return -1;
}
}
int *conditional_status, int *printing)
{
char tag[MAX_STRING_LEN];
return 1;
}
#ifdef DEBUG_INCLUDE
ap_rvputs(r, "**** endif conditional_status=\"",
#endif
*printing = 1;
*conditional_status = 1;
return 0;
}
else {
"endif directive does not take tags in %s",
r->filename);
return -1;
}
}
{
char tag[MAX_STRING_LEN];
char parsed_string[MAX_STRING_LEN];
char *tag_val;
char *var;
while (1) {
return 1;
}
return 0;
}
}
"variable must precede value in set directive in %s",
r->filename);
return -1;
}
}
else {
"Invalid tag for set directive in %s", r->filename);
return -1;
}
}
}
{
char tag[MAX_STRING_LEN];
char *tag_val;
int i;
return 1;
}
}
return 0;
}
else {
"printenv directive does not take tags in %s",
r->filename);
return -1;
}
}
/* -------------------------- The main function --------------------------- */
/* This is a stub which parses a file descriptor. */
ap_filter_t *f)
{
char timefmt[MAX_STRING_LEN];
int sizefmt;
int if_nesting;
int printing;
int conditional_status;
int ret;
/* Turn printing on */
if_nesting = 0;
ap_chdir_file(r->filename);
if (r->args) { /* add QUERY stuff to env cause it ain't yet */
}
/** XXX No ending tag, needs to become an error bucket
** Tag could come in the next brigade (unless we've
** received eos in this brigade).
**
** We're about to segfault.
**/
}
/* At this point, everything between tagbuck and endsec is an SSI
* directive, we just have to deal with it now.
*/
"mod_include: error reading directive in %s",
r->filename);
return;
}
*bb = tag_and_after;
if (!printing) {
if_nesting++;
}
else {
&printing);
if_nesting = 0;
}
continue;
}
if (!if_nesting) {
&printing);
}
continue;
}
if (!if_nesting) {
&printing);
}
continue;
}
if (!if_nesting) {
&printing);
}
else {
if_nesting--;
}
continue;
}
if (!printing) {
continue;
}
if (noexec) {
"exec used but not allowed in %s",
r->filename);
if (printing) {
}
}
else {
}
}
}
}
}
}
}
}
}
#ifdef USE_PERL_SSI
}
#endif
else {
"unknown directive \"%s\" "
"in parsed doc %s",
if (printing) {
}
}
/* AP_BRIGADE_UNSPLICE(dptr, AP_BUCKET_PREV(endsec)); */
}
else {
return;
}
}
}
/*****************************************************************
*
* XBITHACK. Sigh... NB it's configurable per-directory; the compile-time
* option only changes the default.
*/
enum xbithack {
};
#ifdef XBITHACK
#define DEFAULT_XBITHACK xbithack_full
#else
#define DEFAULT_XBITHACK xbithack_off
#endif
{
return result;
}
{
*state = xbithack_off;
}
*state = xbithack_on;
}
*state = xbithack_full;
}
else {
return "XBitHack must be set to Off, On, or Full";
}
return NULL;
}
{
request_rec *r = f->r;
if (!(ap_allow_options(r) & OPT_INCLUDES)) {
return ap_pass_brigade(f->next, b);
}
if (r->method_number != M_GET) {
return ap_pass_brigade(f->next, b);
}
if ((*state == xbithack_full)
/* OS/2 dosen't support Groups. */
#endif
) {
}
/* Kludge --- for nested includes, we want to keep the subprocess
* environment of the base document (for compatibility); that means
* torquing our own last_modified date as well so that the
* LAST_MODIFIED variable gets reset to the proper value if the
* nested document resets <!--#config timefmt-->.
* We also insist that the memory for this subrequest not be
* destroyed, that's dealt with in handle_include().
*/
}
else {
/* we're not a nested include, so we create an initial
* environment */
ap_add_cgi_vars(r);
}
/* XXX: this is bogus, at some point we're going to do a subrequest,
* and when we do it we're going to be subjecting code that doesn't
* expect to be signal-ready to SIGALRM. There is no clean way to
* fix this, except to put alarm support into BUFF. -djg
*/
send_parsed_content(&b, r, f);
ap_pass_brigade(f->next, b);
if (parent) {
/* signify that the sub request should not be killed */
}
return OK;
}
static const command_rec includes_cmds[] =
{
"Off, On, or Full"),
{NULL}
};
static void register_hooks(void)
{
}
{
create_includes_dir_config, /* dir config creater */
NULL, /* dir merger --- default is to override */
NULL, /* server config */
NULL, /* merge server config */
includes_cmds, /* command apr_table_t */
#if 0
includes_handlers, /* handlers */
#else
NULL, /* handlers */
#endif
register_hooks /* register hooks */
};