mod_include.c revision 9255a23a3f3fc01dd96943aff26466dbc6205eea
f545d156561c08020a67f9640c51454c2df4fb57fabien/* ====================================================================
f545d156561c08020a67f9640c51454c2df4fb57fabien * The Apache Software License, Version 1.1
f545d156561c08020a67f9640c51454c2df4fb57fabien * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
f545d156561c08020a67f9640c51454c2df4fb57fabien * reserved.
f545d156561c08020a67f9640c51454c2df4fb57fabien * Redistribution and use in source and binary forms, with or without
f545d156561c08020a67f9640c51454c2df4fb57fabien * modification, are permitted provided that the following conditions
f545d156561c08020a67f9640c51454c2df4fb57fabien * 1. Redistributions of source code must retain the above copyright
f545d156561c08020a67f9640c51454c2df4fb57fabien * notice, this list of conditions and the following disclaimer.
f545d156561c08020a67f9640c51454c2df4fb57fabien * 2. Redistributions in binary form must reproduce the above copyright
* Apache Software Foundation (http://www.apache.org/)."
* http_include.c: Handles the server-parsed HTML documents
#include "apr.h"
#include "apr_strings.h"
#include "apr_thread_proc.h"
#include "apr_hash.h"
#include "apr_user.h"
#include "apr_lib.h"
#include "apr_optional.h"
#define APR_WANT_STRFUNC
#define APR_WANT_MEMFUNC
#include "apr_want.h"
#include "ap_config.h"
#include "util_filter.h"
#include "httpd.h"
#include "http_config.h"
#include "http_core.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"
#include "mod_include.h"
#include "util_ebcdic.h"
(unsigned char)ch)
#ifdef DEBUG_INCLUDE
} xbithack_t;
} bndm_t;
const char *default_error_msg;
const char *default_time_fmt;
const char *default_start_tag;
const char *default_end_tag;
const char *undefined_echo;
typedef struct arg_item {
char *name;
char *value;
} arg_item_t;
struct ssi_internal_ctx {
int seen_eos;
int error;
request_rec *r;
const char *start_seq;
const char *end_seq;
char *error_str_override;
char *time_str_override;
char *re_string;
static const char lazy_eval_sentinel;
#ifdef XBITHACK
* | Environment/Expansion Functions
static void decodehtml(char *s)
int val, i, j;
const char *ents;
if (r->args) {
char *val;
if (val) {
return val;
const char *var)
const char *val;
* v.s. empty strings on an empty match is deliberate.
return NULL;
return NULL;
return val;
char ch;
char *next;
char *end_out;
if (!out) {
switch (ch) {
char *new_out;
return out;
const char *start_of_var_name;
char tmp_store;
apr_size_t l;
++in;
return out;
++in;
++in;
if (val) {
else if (leave_name) {
char *new_out;
next += l;
char *new_out;
return out;
return out;
int regex_error;
return (!regex_error);
enum token_type {
struct token {
char* value;
char ch;
int next = 0;
char qs = 0;
int tkn_fnd = 0;
return (char *) NULL;
return (char *) NULL;
switch (ch) {
return (string);
return (string);
return (string);
return (string);
return (string);
return (string);
if (!qs) {
if (!qs) {
switch (ch) {
if (!tkn_fnd) {
qs = 0;
string++;
if (tkn_fnd) {
if (qs) {
next = 0;
return (string);
struct parse_node {
const char *parse;
char* buffer;
int retval = 0;
*was_error = 0;
*was_unmatched = 0;
sizeof(struct parse_node));
(char *) NULL) {
case token_string:
#ifdef DEBUG_INCLUDE
case token_string:
NULL);
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:
return retval;
case token_re:
#ifdef DEBUG_INCLUDE
case token_eq:
case token_ne:
case token_and:
case token_or:
case token_lbrace:
case token_not:
return retval;
case token_and:
case token_or:
#ifdef DEBUG_INCLUDE
return retval;
case token_string:
case token_re:
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:
return retval;
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:
return retval;
case token_eq:
case token_ne:
case token_ge:
case token_gt:
case token_le:
case token_lt:
#ifdef DEBUG_INCLUDE
return retval;
case token_string:
case token_re:
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:
return retval;
case token_rbrace:
#ifdef DEBUG_INCLUDE
return retval;
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_re:
case token_group:
return retval;
case token_string:
#ifdef DEBUG_INCLUDE
MAX_STRING_LEN, 0);
case token_re:
return retval;
case token_and:
case token_or:
#ifdef DEBUG_INCLUDE
return retval;
case token_string:
case token_string:
#ifdef DEBUG_INCLUDE
#ifdef DEBUG_INCLUDE
case token_eq:
case token_ne:
#ifdef DEBUG_INCLUDE
return retval;
#ifdef DEBUG_INCLUDE
#ifdef DEBUG_INCLUDE
#ifdef DEBUG_INCLUDE
case token_ge:
case token_gt:
case token_le:
case token_lt:
#ifdef DEBUG_INCLUDE
return retval;
#ifdef DEBUG_INCLUDE
#ifdef DEBUG_INCLUDE
case token_not:
#ifdef DEBUG_INCLUDE
case token_group:
#ifdef DEBUG_INCLUDE
case token_lbrace:
return retval;
case token_rbrace:
return retval;
return retval;
return (retval);
#ifdef HAVE_DRIVE_LETTERS
#ifdef NETWARE
while (*path) {
int dots = 0;
++dots;
#if defined(WIN32)
int ret=0;
if (error_fmt) {
return ret;
request_rec *r = f->r;
r->filename);
return APR_SUCCESS;
return APR_SUCCESS;
char *parsed_string;
if (!error_fmt) {
int founddupe = 0;
request_rec *p, *q;
for (q = p; q; q = q->prev) {
if (rr) {
if (error_fmt) {
r->filename);
if (rr) {
if (error_fmt) {
return APR_SUCCESS;
request_rec *r = f->r;
r->filename);
return APR_SUCCESS;
return APR_SUCCESS;
const char *val;
if (val) {
switch(encode) {
case E_NONE:
case E_URL:
case E_ENTITY:
return APR_SUCCESS;
request_rec *r = f->r;
r->filename);
return APR_SUCCESS;
return APR_SUCCESS;
char *parsed_string;
return APR_SUCCESS;
request_rec *r = f->r;
r->filename);
return APR_SUCCESS;
return APR_SUCCESS;
char *parsed_string;
char *buf;
char *tmp;
++len;
if (len == l) {
for (pos = x = 0; x < l; ++x) {
return APR_SUCCESS;
request_rec *r = f->r;
r->filename);
return APR_SUCCESS;
return APR_SUCCESS;
char *parsed_string;
char *t_val;
return APR_SUCCESS;
request_rec *r = f->r;
r->filename);
return APR_SUCCESS;
return APR_SUCCESS;
return APR_SUCCESS;
if (!expr) {
return APR_SUCCESS;
#ifdef DEBUG_INCLUDE
if (was_error) {
return APR_SUCCESS;
if (was_unmatched) {
if (expr_ret) {
return APR_SUCCESS;
request_rec *r = f->r;
r->filename);
return APR_SUCCESS;
return APR_SUCCESS;
return APR_SUCCESS;
if (!expr) {
return APR_SUCCESS;
#ifdef DEBUG_INCLUDE
return APR_SUCCESS;
if (was_error) {
return APR_SUCCESS;
if (was_unmatched) {
if (expr_ret) {
return APR_SUCCESS;
request_rec *r = f->r;
r->filename);
return APR_SUCCESS;
return APR_SUCCESS;
return APR_SUCCESS;
request_rec *r = f->r;
r->filename);
return APR_SUCCESS;
return APR_SUCCESS;
return APR_SUCCESS;
request_rec *r = f->r;
r->filename);
return APR_SUCCESS;
return APR_SUCCESS;
while (sub) {
char *parsed_string;
if (!var) {
r->filename);
return APR_SUCCESS;
request_rec *r = f->r;
*next = 0;
r->pool,
return APR_SUCCESS;
r->filename);
return APR_SUCCESS;
return APR_SUCCESS;
const char *skip;
while (p < he) {
skip = p;
if (p != pi) {
skip = p;
return hl;
const char *p, *ep;
return index;
if (p < ep) {
++pos;
if (p == ep) {
return index;
} while (p < ep);
return len;
const char *data,
const char *p, *ep;
*release = 0;
p = data;
++pos;
return (p - data);
if (p == ep) {
return (p - data);
++spos;
++*release;
++spos;
++*release;
--pos;
if (t == pos) {
if (pos) {
const char *p = data;
case PARSE_DIRECTIVE:
return (p - data);
case PARSE_DIRECTIVE_TAIL:
++pos;
if (p == ep) {
case PARSE_DIRECTIVE_POSTTAIL:
case PARSE_DIRECTIVE_POSTNAME:
return (p - data);
const char *p = data;
if (p < ep) {
return (p - data);
const char *p = data;
++pos;
return (p - data);
if (p == ep) {
return (p - data);
const char *p = data;
case PARSE_ARG:
return (p - data);
case PARSE_ARG_NAME:
if (p < ep) {
return (p - data);
case PARSE_ARG_POSTNAME:
while (*sp) {
++sp;
case PARSE_ARG_EQ:
if (p < ep) {
return (p - data);
case PARSE_ARG_PREVAL:
if (p < ep) {
return (p - data);
case PARSE_ARG_VAL_ESC:
case PARSE_ARG_VAL:
for (; p < ep; ++p) {
if (p == ep) {
return (p - data);
case PARSE_ARG_POSTVAL:
char *sp;
++sp;
++sp;
++shift;
if (shift) {
request_rec *r = f->r;
return APR_SUCCESS;
intern->r = r;
if (APR_BUCKET_IS_METADATA(b)) {
if (APR_BUCKET_IS_EOS(b)) {
if (APR_BUCKET_IS_FLUSH(b)) {
b = newb;
return rv;
len = 0;
return rv;
b = APR_BUCKET_NEXT(b);
case PARSE_PRE_HEAD:
b = newb;
case PARSE_HEAD:
f->c->bucket_alloc);
b = newb;
case PARSE_DIRECTIVE:
case PARSE_DIRECTIVE_POSTNAME:
case PARSE_DIRECTIVE_TAIL:
case PARSE_DIRECTIVE_POSTTAIL:
if (index) {
if (store) {
if (index) {
b = newb;
else if (index) {
b = newb;
case PARSE_PRE_ARG:
b = newb;
case PARSE_ARG:
case PARSE_ARG_NAME:
case PARSE_ARG_POSTNAME:
case PARSE_ARG_EQ:
case PARSE_ARG_PREVAL:
case PARSE_ARG_VAL:
case PARSE_ARG_VAL_ESC:
case PARSE_ARG_POSTVAL:
if (index) {
if (store) {
if (index) {
b = newb;
else if (index) {
b = newb;
case PARSE_TAIL:
case PARSE_TAIL_SEQ:
b = newb;
b = newb;
case PARSE_EXECUTE:
if (handle_func) {
return rv;
r->filename);
f->c->bucket_alloc));
return rv;
return OK;
request_rec *r = f->r;
if (!f->ctx) {
ap_add_cgi_vars(r);
/* Always unset the ETag/Last-Modified fields - see RFC2616 - 13.3.4.
if (r->args) {
return send_parsed_content(f, b);
return DECLINED;
return DECLINED;
return DECLINED;
return DECLINED;
return DECLINED;
return result;
return result;
return NULL;
const char *tag)
const char *p = tag;
if (apr_isspace(*p)) {
return NULL;
const char *tag)
const char *p = tag;
if (apr_isspace(*p)) {
return NULL;
const char *msg)
return NULL;
const char *msg)
return NULL;
const char *fmt)
return NULL;
if(ssi_pfn_register) {
return OK;
{NULL}