Main Page | Modules | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

mod_include.c File Reference

#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"
#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_protocol.h"
#include "http_log.h"
#include "http_main.h"
#include "util_script.h"
#include "mod_include.h"
#include "util_ebcdic.h"

Include dependency graph for mod_include.c:

Go to the source code of this file.

Defines

#define APR_WANT_STRFUNC
#define APR_WANT_MEMFUNC
#define CORE_PRIVATE
#define MOD_INCLUDE_REDESIGN
#define DEFAULT_XBITHACK   xbithack_off
#define BYTE_COUNT_THRESHOLD   AP_MIN_BYTES_TO_WRITE
#define SSI_CREATE_ERROR_BUCKET(ctx, f, bb)
#define LAZY_VALUE   (&lazy_eval_sentinel)
#define MAXENTLEN   (6)
#define SKIP_TAG_WHITESPACE(ptr)   while ((*ptr != '\0') && (apr_isspace (*ptr))) ptr++
#define PARSE_STRING_INITIAL_SIZE   64
#define MAX_DEBUG_SIZE   10
#define LOG_COND_STATUS(cntx, t_buck, h_ptr, ins_head, tag_text)
#define DUMP_PARSE_EXPR_DEBUG(t_buck, h_ptr, d_buf, ins_head)

Typedefs

typedef ssi_arg_item ssi_arg_item_t

Enumerations

enum  parse_state_t {
  PARSE_PRE_HEAD, PARSE_HEAD, PARSE_DIRECTIVE, PARSE_DIRECTIVE_POSTNAME,
  PARSE_DIRECTIVE_TAIL, PARSE_DIRECTIVE_POSTTAIL, PARSE_PRE_ARG, PARSE_ARG,
  PARSE_ARG_NAME, PARSE_ARG_POSTNAME, PARSE_ARG_EQ, PARSE_ARG_PREVAL,
  PARSE_ARG_VAL, PARSE_ARG_VAL_ESC, PARSE_ARG_POSTVAL, PARSE_TAIL,
  PARSE_TAIL_SEQ, PARSE_EXECUTE
}
enum  token_type {
  token_string, token_re, token_and, token_or,
  token_not, token_eq, token_ne, token_rbrace,
  token_lbrace, token_group, token_ge, token_le,
  token_gt, token_lt
}

Functions

static APR_OPTIONAL_FN_TYPE (ap_register_include_handler)
static void add_include_vars (request_rec *r, char *timefmt)
static const char * add_include_vars_lazy (request_rec *r, const char *var)
static const char * get_include_var (request_rec *r, include_ctx_t *ctx, const char *var)
static void bndm_compile (bndm_t *t, const char *n, apr_size_t nl)
static apr_size_t bndm (const char *n, apr_size_t nl, const char *h, apr_size_t hl, bndm_t *t)
static void decodehtml (char *s)
static void ap_ssi_get_tag_and_value (include_ctx_t *ctx, char **tag, char **tag_val, int dodecode)
static char * ap_ssi_parse_string (request_rec *r, include_ctx_t *ctx, const char *in, char *out, apr_size_t length, int leave_name)
static int is_only_below (const char *path)
static int handle_include (include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, apr_bucket **inserted_head)
static int handle_echo (include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, apr_bucket **inserted_head)
static int handle_config (include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, apr_bucket **inserted_head)
static int find_file (request_rec *r, const char *directive, const char *tag, char *tag_val, apr_finfo_t *finfo)
static int handle_fsize (include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, apr_bucket **inserted_head)
static int handle_flastmod (include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, apr_bucket **inserted_head)
static int re_check (request_rec *r, include_ctx_t *ctx, char *string, char *rexp)
static const char * get_ptoken (request_rec *r, const char *string, struct token *token, int *unmatched)
static int parse_expr (request_rec *r, include_ctx_t *ctx, const char *expr, int *was_error, int *was_unmatched, char *debug)
static int handle_if (include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, apr_bucket **inserted_head)
static int handle_elif (include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, apr_bucket **inserted_head)
static int handle_else (include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, apr_bucket **inserted_head)
static int handle_endif (include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, apr_bucket **inserted_head)
static int handle_set (include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, apr_bucket **inserted_head)
static int handle_printenv (include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, apr_bucket **inserted_head)
static apr_size_t find_start_sequence (ssi_ctx_t *ctx, const char *data, apr_size_t len)
static apr_size_t find_partial_start_sequence (ssi_ctx_t *ctx, const char *data, apr_size_t len, apr_size_t *release)
static apr_size_t find_directive (ssi_ctx_t *ctx, const char *data, apr_size_t len, char ***store, apr_size_t **store_len)
static apr_size_t find_arg_or_tail (ssi_ctx_t *ctx, const char *data, apr_size_t len)
static apr_size_t find_tail (ssi_ctx_t *ctx, const char *data, apr_size_t len)
static apr_size_t find_argument (ssi_ctx_t *ctx, const char *data, apr_size_t len, char ***store, apr_size_t **store_len)
static apr_status_t send_parsed_content (ap_filter_t *f, apr_bucket_brigade *bb)
static void * create_includes_dir_config (apr_pool_t *p, char *dummy)
static void * create_includes_server_config (apr_pool_t *p, server_rec *server)
static const char * set_xbithack (cmd_parms *cmd, void *xbp, const char *arg)
static int includes_setup (ap_filter_t *f)
static apr_status_t includes_filter (ap_filter_t *f, apr_bucket_brigade *b)
static void ap_register_include_handler (char *tag, include_handler_fn_t *func)
static int include_post_config (apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
static const char * set_default_error_msg (cmd_parms *cmd, void *mconfig, const char *msg)
static const char * set_default_start_tag (cmd_parms *cmd, void *mconfig, const char *msg)
static const char * set_undefined_echo (cmd_parms *cmd, void *mconfig, const char *msg)
static const char * set_default_end_tag (cmd_parms *cmd, void *mconfig, const char *msg)
static const char * set_default_time_fmt (cmd_parms *cmd, void *mconfig, const char *fmt)
static int include_fixup (request_rec *r)
static void register_hooks (apr_pool_t *p)

Variables

module AP_MODULE_DECLARE_DATA include_module
static apr_hash_tinclude_hash
static const char lazy_eval_sentinel
static const command_rec includes_cmds []


Define Documentation

#define APR_WANT_MEMFUNC
 

Definition at line 34 of file mod_include.c.

#define APR_WANT_STRFUNC
 

Definition at line 33 of file mod_include.c.

#define BYTE_COUNT_THRESHOLD   AP_MIN_BYTES_TO_WRITE
 

Definition at line 148 of file mod_include.c.

#define CORE_PRIVATE
 

Definition at line 37 of file mod_include.c.

#define DEFAULT_XBITHACK   xbithack_off
 

Definition at line 145 of file mod_include.c.

Referenced by create_includes_dir_config().

#define DUMP_PARSE_EXPR_DEBUG t_buck,
h_ptr,
d_buf,
ins_head   ) 
 

Definition at line 2017 of file mod_include.c.

Referenced by handle_elif(), and handle_if().

#define LAZY_VALUE   (&lazy_eval_sentinel)
 

Definition at line 161 of file mod_include.c.

Referenced by add_include_vars(), get_include_var(), and handle_printenv().

#define LOG_COND_STATUS cntx,
t_buck,
h_ptr,
ins_head,
tag_text   ) 
 

Definition at line 2016 of file mod_include.c.

Referenced by handle_elif(), handle_else(), handle_endif(), and handle_if().

#define MAX_DEBUG_SIZE   10
 

Definition at line 2015 of file mod_include.c.

Referenced by handle_elif(), and handle_if().

#define MAXENTLEN   (6)
 

Definition at line 349 of file mod_include.c.

Referenced by decodehtml().

#define MOD_INCLUDE_REDESIGN
 

Definition at line 52 of file mod_include.c.

#define PARSE_STRING_INITIAL_SIZE   64
 

Definition at line 490 of file mod_include.c.

Referenced by ap_ssi_parse_string().

#define SKIP_TAG_WHITESPACE ptr   )     while ((*ptr != '\0') && (apr_isspace (*ptr))) ptr++
 

Definition at line 449 of file mod_include.c.

#define SSI_CREATE_ERROR_BUCKET ctx,
f,
bb   ) 
 

Value:

APR_BRIGADE_INSERT_TAIL((bb),   \
    apr_bucket_pool_create(apr_pstrdup((ctx)->pool, (ctx)->error_str),  \
                           strlen((ctx)->error_str), (ctx)->pool,       \
                           (f)->c->bucket_alloc))

Definition at line 150 of file mod_include.c.

Referenced by send_parsed_content().


Typedef Documentation

typedef struct ssi_arg_item ssi_arg_item_t
 


Enumeration Type Documentation

enum parse_state_t
 

Enumeration values:
PARSE_PRE_HEAD 
PARSE_HEAD 
PARSE_DIRECTIVE 
PARSE_DIRECTIVE_POSTNAME 
PARSE_DIRECTIVE_TAIL 
PARSE_DIRECTIVE_POSTTAIL 
PARSE_PRE_ARG 
PARSE_ARG 
PARSE_ARG_NAME 
PARSE_ARG_POSTNAME 
PARSE_ARG_EQ 
PARSE_ARG_PREVAL 
PARSE_ARG_VAL 
PARSE_ARG_VAL_ESC 
PARSE_ARG_POSTVAL 
PARSE_TAIL 
PARSE_TAIL_SEQ 
PARSE_EXECUTE 

Definition at line 91 of file mod_include.c.

enum token_type
 

Enumeration values:
token_string 
token_re 
token_and 
token_or 
token_not 
token_eq 
token_ne 
token_rbrace 
token_lbrace 
token_group 
token_ge 
token_le 
token_gt 
token_lt 

Definition at line 1195 of file mod_include.c.


Function Documentation

static void add_include_vars request_rec r,
char *  timefmt
[static]
 

Definition at line 163 of file mod_include.c.

References request_rec::args, e, request_rec::filename, LAZY_VALUE, request_rec::path_info, request_rec::pool, request_rec::subprocess_env, t, and request_rec::uri.

Referenced by includes_filter().

static const char* add_include_vars_lazy request_rec r,
const char *  var
[static]
 

Definition at line 191 of file mod_include.c.

References ap_get_module_config, APR_SUCCESS, conf, include_dir_config::default_time_fmt, request_rec::finfo, include_module, apr_finfo_t::mtime, NULL, request_rec::per_dir_config, request_rec::pool, request_rec::request_time, strcasecmp(), request_rec::subprocess_env, apr_finfo_t::user, and val.

Referenced by get_include_var(), and handle_printenv().

Here is the call graph for this function:

static void ap_register_include_handler char *  tag,
include_handler_fn_t func
[static]
 

Definition at line 3594 of file mod_include.c.

Referenced by cgi_post_config(), cgid_init(), include_post_config(), and register_hooks().

static void ap_ssi_get_tag_and_value include_ctx_t ctx,
char **  tag,
char **  tag_val,
int  dodecode
[static]
 

Definition at line 451 of file mod_include.c.

References ap_strchr, include_filter_ctx::combined_tag, include_filter_ctx::curr_tag_pos, decodehtml(), NULL, and include_filter_ctx::tag_length.

Referenced by cgi_post_config(), cgid_init(), handle_config(), handle_echo(), handle_elif(), handle_else(), handle_endif(), handle_flastmod(), handle_fsize(), handle_if(), handle_include(), handle_printenv(), handle_set(), and register_hooks().

Here is the call graph for this function:

static char* ap_ssi_parse_string request_rec r,
include_ctx_t ctx,
const char *  in,
char *  out,
apr_size_t  length,
int  leave_name
[static]
 

Definition at line 497 of file mod_include.c.

References ap_strchr_c, APLOG_ERR, APLOG_MARK, apr_isalnum, get_include_var(), int, NULL, PARSE_STRING_INITIAL_SIZE, request_rec::pool, and val.

Referenced by cgi_post_config(), cgid_init(), handle_config(), handle_echo(), handle_flastmod(), handle_fsize(), handle_include(), handle_set(), parse_expr(), and register_hooks().

Here is the call graph for this function:

static APR_OPTIONAL_FN_TYPE ap_register_include_handler   )  [static]
 

Definition at line 58 of file mod_include.c.

static apr_size_t bndm const char *  n,
apr_size_t  nl,
const char *  h,
apr_size_t  hl,
bndm_t t
[static]
 

Definition at line 298 of file mod_include.c.

References p, bndm_t::T, bndm_t::x, and x.

Referenced by find_start_sequence().

static void bndm_compile bndm_t t,
const char *  n,
apr_size_t  nl
[static]
 

Definition at line 274 of file mod_include.c.

References bndm_t::T, bndm_t::x, and x.

Referenced by create_includes_server_config(), and set_default_start_tag().

static void* create_includes_dir_config apr_pool_t p,
char *  dummy
[static]
 

Definition at line 3398 of file mod_include.c.

References DEFAULT_ERROR_MSG, include_dir_config::default_error_msg, include_dir_config::default_time_fmt, DEFAULT_TIME_FORMAT, DEFAULT_XBITHACK, and result.

static void* create_includes_server_config apr_pool_t p,
server_rec server
[static]
 

Definition at line 3410 of file mod_include.c.

References bndm_compile(), include_server_config::default_end_tag, include_server_config::default_start_tag, ENDING_SEQUENCE, result, include_server_config::start_seq_pat, include_server_config::start_tag_len, STARTING_SEQUENCE, include_server_config::undefinedEcho, and include_server_config::undefinedEchoLen.

Here is the call graph for this function:

static void decodehtml char *  s  )  [static]
 

Definition at line 353 of file mod_include.c.

References apr_isdigit, MAXENTLEN, NULL, p, RAW_ASCII_CHAR, and val.

Referenced by ap_ssi_get_tag_and_value(), and handle_config().

static apr_size_t find_arg_or_tail ssi_ctx_t ctx,
const char *  data,
apr_size_t  len
[static]
 

Definition at line 2640 of file mod_include.c.

References apr_isspace, p, PARSE_ARG, and PARSE_TAIL.

Referenced by send_parsed_content().

static apr_size_t find_argument ssi_ctx_t ctx,
const char *  data,
apr_size_t  len,
char ***  store,
apr_size_t **  store_len
[static]
 

Definition at line 2702 of file mod_include.c.

References APLOG_ERR, APLOG_MARK, apr_isspace, apr_tolower, ssi_arg_item::next, NULL, p, PARSE_ARG, PARSE_ARG_EQ, PARSE_ARG_NAME, PARSE_ARG_POSTNAME, PARSE_ARG_POSTVAL, PARSE_ARG_PREVAL, PARSE_ARG_VAL, PARSE_ARG_VAL_ESC, and PARSE_PRE_ARG.

Referenced by send_parsed_content().

static apr_size_t find_directive ssi_ctx_t ctx,
const char *  data,
apr_size_t  len,
char ***  store,
apr_size_t **  store_len
[static]
 

Definition at line 2542 of file mod_include.c.

References APLOG_ERR, APLOG_MARK, apr_isspace, apr_tolower, NULL, p, PARSE_DIRECTIVE, PARSE_DIRECTIVE_POSTNAME, PARSE_DIRECTIVE_POSTTAIL, PARSE_DIRECTIVE_TAIL, PARSE_EXECUTE, PARSE_PRE_ARG, and sep.

Referenced by send_parsed_content().

static int find_file request_rec r,
const char *  directive,
const char *  tag,
char *  tag_val,
apr_finfo_t finfo
[static]
 

Definition at line 973 of file mod_include.c.

References APLOG_ERR, APLOG_MARK, APR_FINFO_GPROT, APR_FINFO_MIN, APR_INCOMPLETE, APR_SUCCESS, request_rec::filename, apr_finfo_t::filetype, request_rec::finfo, HTTP_OK, is_only_below(), NULL, request_rec::pool, and request_rec::status.

Referenced by handle_flastmod(), and handle_fsize().

Here is the call graph for this function:

static apr_size_t find_partial_start_sequence ssi_ctx_t ctx,
const char *  data,
apr_size_t  len,
apr_size_t *  release
[static]
 

Definition at line 2447 of file mod_include.c.

References p, PARSE_DIRECTIVE, PARSE_PRE_HEAD, and t.

Referenced by send_parsed_content().

static apr_size_t find_start_sequence ssi_ctx_t ctx,
const char *  data,
apr_size_t  len
[static]
 

Definition at line 2374 of file mod_include.c.

References bndm(), ssi_ctx_t::ctx, p, PARSE_DIRECTIVE, PARSE_HEAD, include_filter_ctx::parse_pos, include_filter_ctx::start_seq, include_filter_ctx::start_seq_len, include_filter_ctx::start_seq_pat, and ssi_ctx_t::state.

Referenced by send_parsed_content().

Here is the call graph for this function:

static apr_size_t find_tail ssi_ctx_t ctx,
const char *  data,
apr_size_t  len
[static]
 

Definition at line 2663 of file mod_include.c.

References p, PARSE_ARG, PARSE_EXECUTE, PARSE_TAIL, and PARSE_TAIL_SEQ.

Referenced by send_parsed_content().

static const char* get_include_var request_rec r,
include_ctx_t ctx,
const char *  var
[static]
 

Definition at line 227 of file mod_include.c.

References add_include_vars_lazy(), apr_isdigit, LAZY_VALUE, len, NULL, request_rec::pool, include_filter_ctx::re_result, include_filter_ctx::re_string, request_rec::subprocess_env, and val.

Referenced by ap_ssi_parse_string(), and handle_echo().

Here is the call graph for this function:

static const char* get_ptoken request_rec r,
const char *  string,
struct token token,
int unmatched
[static]
 

Definition at line 1206 of file mod_include.c.

References apr_isspace, NULL, token_and, token_eq, token_ge, token_gt, token_lbrace, token_le, token_lt, token_ne, token_not, token_or, token_rbrace, token_re, token_string, token::type, and token::value.

Referenced by parse_expr().

static int handle_config include_ctx_t ctx,
apr_bucket_brigade **  bb,
request_rec r,
ap_filter_t f,
apr_bucket head_ptr,
apr_bucket **  inserted_head
[static]
 

Definition at line 900 of file mod_include.c.

References ap_ssi_get_tag_and_value(), ap_ssi_parse_string(), APLOG_ERR, APLOG_MARK, CREATE_ERROR_BUCKET, decodehtml(), env, request_rec::filename, request_rec::finfo, FLAG_PRINTING, FLAG_SIZE_ABBREV, FLAG_SIZE_IN_BYTES, include_filter_ctx::flags, MAX_STRING_LEN, apr_finfo_t::mtime, NULL, request_rec::pool, request_rec::request_time, and request_rec::subprocess_env.

Referenced by include_post_config().

Here is the call graph for this function:

static int handle_echo include_ctx_t ctx,
apr_bucket_brigade **  bb,
request_rec r,
ap_filter_t f,
apr_bucket head_ptr,
apr_bucket **  inserted_head
[static]
 

Definition at line 810 of file mod_include.c.

References ap_escape_uri, ap_get_module_config, ap_ssi_get_tag_and_value(), ap_ssi_parse_string(), APLOG_ERR, APLOG_MARK, APR_BUCKET_INSERT_BEFORE, conn_rec::bucket_alloc, c, request_rec::connection, CREATE_ERROR_BUCKET, request_rec::filename, FLAG_PRINTING, include_filter_ctx::flags, get_include_var(), include_module, MAX_STRING_LEN, server_rec::module_config, NULL, request_rec::pool, sconf, request_rec::server, strcasecmp(), include_server_config::undefinedEcho, include_server_config::undefinedEchoLen, and val.

Referenced by include_post_config().

Here is the call graph for this function:

static int handle_elif include_ctx_t ctx,
apr_bucket_brigade **  bb,
request_rec r,
ap_filter_t f,
apr_bucket head_ptr,
apr_bucket **  inserted_head
[static]
 

Definition at line 2104 of file mod_include.c.

References ap_ssi_get_tag_and_value(), APLOG_ERR, APLOG_MARK, APR_BUCKET_INSERT_BEFORE, conn_rec::bucket_alloc, request_rec::connection, CREATE_ERROR_BUCKET, DUMP_PARSE_EXPR_DEBUG, request_rec::filename, FLAG_CLEAR_PRINT_COND, FLAG_CLEAR_PRINTING, FLAG_COND_TRUE, FLAG_PRINTING, include_filter_ctx::flags, include_filter_ctx::if_nesting_level, LOG_COND_STATUS, MAX_DEBUG_SIZE, NULL, and parse_expr().

Referenced by include_post_config().

Here is the call graph for this function:

static int handle_else include_ctx_t ctx,
apr_bucket_brigade **  bb,
request_rec r,
ap_filter_t f,
apr_bucket head_ptr,
apr_bucket **  inserted_head
[static]
 

Definition at line 2187 of file mod_include.c.

References ap_ssi_get_tag_and_value(), APLOG_ERR, APLOG_MARK, CREATE_ERROR_BUCKET, request_rec::filename, FLAG_CLEAR_PRINTING, FLAG_COND_TRUE, FLAG_PRINTING, include_filter_ctx::flags, include_filter_ctx::if_nesting_level, LOG_COND_STATUS, and NULL.

Referenced by include_post_config().

Here is the call graph for this function:

static int handle_endif include_ctx_t ctx,
apr_bucket_brigade **  bb,
request_rec r,
ap_filter_t f,
apr_bucket head_ptr,