mod_include.c revision b6055b7832a0e4d0818416252fff5925aaebae4b
/* ====================================================================
* 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 "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 */
ap_table_t *e = r->subprocess_env;
char *t;
ap_table_setn(e, "LAST_MODIFIED",
#ifndef WIN32
if (pw) {
}
else {
}
#endif /* ndef WIN32 */
ap_table_setn(e, "DOCUMENT_NAME", ++t);
}
else {
}
if (r->args) {
ap_table_setn(e, "QUERY_STRING_UNESCAPED",
}
}
/* --------------------------- Parser functions --------------------------- */
#define OUTBUFSIZE 4096
/* PUT_CHAR and FLUSH_BUF currently only work within the scope of
* find_string(); they are hacks to avoid calling rputc for each and
* every character output. A common set of buffering calls for this
* type of output SHOULD be implemented.
*/
#define PUT_CHAR(c,r) \
{ \
if (outind == OUTBUFSIZE) { \
FLUSH_BUF(r) \
}; \
}
/* there SHOULD be some error checking on the return value of
* rwrite, however it is unclear what the API for rwrite returning
* errors is and little can really be done to help the error in
* any case.
*/
#define FLUSH_BUF(r) \
{ \
outind = 0; \
}
/*
* f: file handle being read from
* c: character to read into
* ret: return value to use if input fails
* r: current request_rec
*
* This macro is redefined after find_string() for historical reasons
* to avoid too many code changes. This is one of the many things
* that should be fixed.
*/
{ \
"encountered error in GET_CHAR macro, " \
"mod_include."); \
} \
FLUSH_BUF(r); \
ap_close(f); \
return ret; \
} \
}
{
char outbuf[OUTBUFSIZE];
int outind = 0;
char c;
p = 0;
while (1) {
if (c == str[p]) {
if ((++p) == l) {
FLUSH_BUF(r);
return 0;
}
}
else {
if (printing) {
for (x = 0; x < p; x++) {
}
PUT_CHAR(c, r);
}
p = 0;
}
}
}
#define GET_CHAR(f,c,r,p) \
{ \
"encountered error in GET_CHAR macro, " \
"mod_include."); \
} \
ap_close(f); \
return r; \
} \
}
/*
* 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
*/
{
/* makes code below a little less cluttered */
--tagbuf_len;
do { /* skip whitespace */
} while (ap_isspace(c));
/* tags can't start with - */
if (c == '-') {
if (c == '-') {
do {
} while (ap_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 == '=' || ap_isspace(c)) {
break;
}
*(t++) = ap_tolower(c);
}
*t++ = '\0';
tag_val = t;
while (ap_isspace(c)) {
}
if (c != '=') {
return NULL;
}
do {
} while (ap_isspace(c));
/* we should allow a 'name' as a value */
if (c != '"' && c != '\'') {
return NULL;
}
term = c;
while (1) {
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 */
if (c == term) { /* Only if */
*(--t) = c; /* Replace backslash ONLY for terminator */
}
}
else if (c == term) {
break;
}
*(t++) = c;
}
*t = '\0';
if (dodecode) {
}
return ap_pstrdup(p, tag_val);
}
{
char *d = dest;
char c;
/* make room for nul terminator */
--len;
/* skip initial whitespace */
while (1) {
if (!ap_isspace(c)) {
break;
}
}
/* now get directive */
while (1) {
return 1;
}
*d++ = ap_tolower(c);
if (ap_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 ---------------------------- */
static int include_cgi(char *s, request_rec *r)
{
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.
*/
/* 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: this needs os abstraction... consider c:..\foo in win32
*/
static int is_only_below(const char *path)
{
#ifdef HAVE_DRIVE_LETTERS
return 0;
#endif
if (path[0] == '/') {
return 0;
}
return 0;
}
while (*path) {
return 0;
}
++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)
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;
}
static int include_cmd(char *s, request_rec *r)
{
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 {
/* Fill in BUFF structure for parents pipe to child's stdout */
if (!iol)
return APR_EBADF;
ap_send_fb(script_in, r);
}
}
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 ap_stat() failure; pass rv from ap_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 (!ap_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 (ap_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. */
{
char timefmt[MAX_STRING_LEN];
int if_nesting;
int printing;
int conditional_status;
/* Turn printing on */
if_nesting = 0;
ap_chdir_file(r->filename);
if (r->args) { /* add QUERY stuff to env cause it ain't yet */
}
while (1) {
"mod_include: error reading directive in %s",
r->filename);
return;
}
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) {
}
}
if (ret) {
"premature EOF in parsed file %s",
r->filename);
return;
}
}
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;
}
static int send_parsed_file(request_rec *r)
{
int errstatus;
if (!(ap_allow_options(r) & OPT_INCLUDES)) {
return DECLINED;
}
if (r->method_number != M_GET) {
return DECLINED;
}
if (r->finfo.protection == 0) {
"File does not exist: %s",
(r->path_info
: r->filename));
return HTTP_NOT_FOUND;
}
if (errstatus != APR_SUCCESS) {
"file permissions deny server access: %s", r->filename);
return HTTP_FORBIDDEN;
}
if ((*state == xbithack_full)
/* OS/2 dosen't support Groups. */
#endif
) {
}
return errstatus;
}
if (r->header_only) {
ap_close(f);
return OK;
}
/* 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
*/
#ifdef CHARSET_EBCDIC
#endif
send_parsed_content(f, r);
if (parent) {
/* signify that the sub request should not be killed */
}
return OK;
}
static int send_shtml_file(request_rec *r)
{
r->content_type = "text/html";
return send_parsed_file(r);
}
static int xbithack_handler(request_rec *r)
{
/* OS/2 dosen't currently support the xbithack. This is being worked on. */
return DECLINED;
#else
return DECLINED;
}
if (*state == xbithack_off) {
return DECLINED;
}
return send_parsed_file(r);
#endif
}
static const command_rec includes_cmds[] =
{
"Off, On, or Full"),
{NULL}
};
static const handler_rec includes_handlers[] =
{
{"server-parsed", send_parsed_file},
{"text/html", xbithack_handler},
{NULL}
};
{
create_includes_dir_config, /* dir config creater */
NULL, /* dir merger --- default is to override */
NULL, /* server config */
NULL, /* merge server config */
includes_cmds, /* command ap_table_t */
includes_handlers, /* handlers */
NULL /* register hooks */
};