mod_include.h revision f6e9f5600e77b78fb013bb543d364135961639d1
18343797fadabacf01280b38ea7688690d12aec0rbb/* ====================================================================
18343797fadabacf01280b38ea7688690d12aec0rbb * The Apache Software License, Version 1.1
18343797fadabacf01280b38ea7688690d12aec0rbb * Copyright (c) 2000 The Apache Software Foundation. All rights
18343797fadabacf01280b38ea7688690d12aec0rbb * reserved.
18343797fadabacf01280b38ea7688690d12aec0rbb * Redistribution and use in source and binary forms, with or without
18343797fadabacf01280b38ea7688690d12aec0rbb * modification, are permitted provided that the following conditions
18343797fadabacf01280b38ea7688690d12aec0rbb * are met:
18343797fadabacf01280b38ea7688690d12aec0rbb * 1. Redistributions of source code must retain the above copyright
18343797fadabacf01280b38ea7688690d12aec0rbb * notice, this list of conditions and the following disclaimer.
18343797fadabacf01280b38ea7688690d12aec0rbb * 2. Redistributions in binary form must reproduce the above copyright
18343797fadabacf01280b38ea7688690d12aec0rbb * notice, this list of conditions and the following disclaimer in
18343797fadabacf01280b38ea7688690d12aec0rbb * the documentation and/or other materials provided with the
18343797fadabacf01280b38ea7688690d12aec0rbb * distribution.
18343797fadabacf01280b38ea7688690d12aec0rbb * 3. The end-user documentation included with the redistribution,
18343797fadabacf01280b38ea7688690d12aec0rbb * if any, must include the following acknowledgment:
18343797fadabacf01280b38ea7688690d12aec0rbb * "This product includes software developed by the
18343797fadabacf01280b38ea7688690d12aec0rbb * Apache Software Foundation (http://www.apache.org/)."
18343797fadabacf01280b38ea7688690d12aec0rbb * Alternately, this acknowledgment may appear in the software itself,
18343797fadabacf01280b38ea7688690d12aec0rbb * if and wherever such third-party acknowledgments normally appear.
18343797fadabacf01280b38ea7688690d12aec0rbb * 4. The names "Apache" and "Apache Software Foundation" must
18343797fadabacf01280b38ea7688690d12aec0rbb * not be used to endorse or promote products derived from this
18343797fadabacf01280b38ea7688690d12aec0rbb * software without prior written permission. For written
18343797fadabacf01280b38ea7688690d12aec0rbb * permission, please contact apache@apache.org.
18343797fadabacf01280b38ea7688690d12aec0rbb * 5. Products derived from this software may not be called "Apache",
18343797fadabacf01280b38ea7688690d12aec0rbb * nor may "Apache" appear in their name, without prior written
18343797fadabacf01280b38ea7688690d12aec0rbb * permission of the Apache Software Foundation.
18343797fadabacf01280b38ea7688690d12aec0rbb * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
18343797fadabacf01280b38ea7688690d12aec0rbb * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18343797fadabacf01280b38ea7688690d12aec0rbb * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18343797fadabacf01280b38ea7688690d12aec0rbb * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
18343797fadabacf01280b38ea7688690d12aec0rbb * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18343797fadabacf01280b38ea7688690d12aec0rbb * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18343797fadabacf01280b38ea7688690d12aec0rbb * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18343797fadabacf01280b38ea7688690d12aec0rbb * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18343797fadabacf01280b38ea7688690d12aec0rbb * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
18343797fadabacf01280b38ea7688690d12aec0rbb * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
18343797fadabacf01280b38ea7688690d12aec0rbb * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
18343797fadabacf01280b38ea7688690d12aec0rbb * SUCH DAMAGE.
18343797fadabacf01280b38ea7688690d12aec0rbb * ====================================================================
18343797fadabacf01280b38ea7688690d12aec0rbb * This software consists of voluntary contributions made by many
18343797fadabacf01280b38ea7688690d12aec0rbb * individuals on behalf of the Apache Software Foundation. For more
18343797fadabacf01280b38ea7688690d12aec0rbb * information on the Apache Software Foundation, please see
18343797fadabacf01280b38ea7688690d12aec0rbb * Portions of this software are based upon public domain software
18343797fadabacf01280b38ea7688690d12aec0rbb * originally written at the National Center for Supercomputing Applications,
18343797fadabacf01280b38ea7688690d12aec0rbb * University of Illinois, Urbana-Champaign.
18343797fadabacf01280b38ea7688690d12aec0rbb#define DEFAULT_ERROR_MSG "[an error occurred while processing this directive]"
18343797fadabacf01280b38ea7688690d12aec0rbb#define RAW_ASCII_CHAR(ch) apr_xlate_conv_byte(ap_hdrs_from_ascii, (unsigned char)ch)
18343797fadabacf01280b38ea7688690d12aec0rbb#else /*CHARSET_EBCDIC*/
18343797fadabacf01280b38ea7688690d12aec0rbb#endif /*CHARSET_EBCDIC*/
18343797fadabacf01280b38ea7688690d12aec0rbb/* just need some arbitrary non-NULL pointer which can't also be a request_rec */
18343797fadabacf01280b38ea7688690d12aec0rbb/* TODO: changing directory should be handled by CreateProcess */
18343797fadabacf01280b38ea7688690d12aec0rbb#define ap_chdir_file(x) do {} while(0)
18343797fadabacf01280b38ea7688690d12aec0rbb/****************************************************************************
18343797fadabacf01280b38ea7688690d12aec0rbb * Used to keep context information during parsing of a request for SSI tags.
18343797fadabacf01280b38ea7688690d12aec0rbb * This is especially useful if the tag stretches across multiple buckets or
18343797fadabacf01280b38ea7688690d12aec0rbb * brigades. This keeps track of which buckets need to be replaced with the
18343797fadabacf01280b38ea7688690d12aec0rbb * content generated by the SSI tag.
18343797fadabacf01280b38ea7688690d12aec0rbb * state: PRE_HEAD - State prior to finding the first character of the
18343797fadabacf01280b38ea7688690d12aec0rbb * STARTING_SEQUENCE. Next state is PARSE_HEAD.
18343797fadabacf01280b38ea7688690d12aec0rbb * PARSE_HEAD - State entered once the first character of the
18343797fadabacf01280b38ea7688690d12aec0rbb * STARTING_SEQUENCE is found and exited when the
18343797fadabacf01280b38ea7688690d12aec0rbb * the full STARTING_SEQUENCE has been matched or
18343797fadabacf01280b38ea7688690d12aec0rbb * a match failure occurs. Next state is PRE_HEAD
18343797fadabacf01280b38ea7688690d12aec0rbb * or PARSE_TAG.
18343797fadabacf01280b38ea7688690d12aec0rbb * PARSE_TAG - State entered once the STARTING sequence has been
18343797fadabacf01280b38ea7688690d12aec0rbb * matched. It is exited when the first character in
18343797fadabacf01280b38ea7688690d12aec0rbb * ENDING_SEQUENCE is found. Next state is PARSE_TAIL.
18343797fadabacf01280b38ea7688690d12aec0rbb * PARSE_TAIL - State entered from PARSE_TAG state when the first
18343797fadabacf01280b38ea7688690d12aec0rbb * character in ENDING_SEQUENCE is encountered. This
18343797fadabacf01280b38ea7688690d12aec0rbb * state is exited when the ENDING_SEQUENCE has been
18343797fadabacf01280b38ea7688690d12aec0rbb * completely matched, or when a match failure occurs.
18343797fadabacf01280b38ea7688690d12aec0rbb * Next state is PARSE_TAG or PARSED.
18343797fadabacf01280b38ea7688690d12aec0rbb * PARSED - State entered from PARSE_TAIL once the complete
18343797fadabacf01280b38ea7688690d12aec0rbb * ENDING_SEQUENCE has been matched. The SSI tag is
18343797fadabacf01280b38ea7688690d12aec0rbb * processed and the SSI buckets are replaced with the
18343797fadabacf01280b38ea7688690d12aec0rbb * SSI content during this state.
18343797fadabacf01280b38ea7688690d12aec0rbb * parse_pos: Current matched position within the STARTING_SEQUENCE or
18343797fadabacf01280b38ea7688690d12aec0rbb * ENDING_SEQUENCE during the PARSE_HEAD and PARSE_TAIL states.
18343797fadabacf01280b38ea7688690d12aec0rbb * This is especially useful when the sequence spans brigades.
18343797fadabacf01280b38ea7688690d12aec0rbb * X_start_bucket: These point to the buckets containing the first character
18343797fadabacf01280b38ea7688690d12aec0rbb * of the STARTING_SEQUENCE, the first non-whitespace
18343797fadabacf01280b38ea7688690d12aec0rbb * character of the tag, and the first character in the
18343797fadabacf01280b38ea7688690d12aec0rbb * ENDING_SEQUENCE (head_, tag_, and tail_ respectively).
18343797fadabacf01280b38ea7688690d12aec0rbb * The buckets are kept intact until the PARSED state is
18343797fadabacf01280b38ea7688690d12aec0rbb * reached, at which time the tag is consolidated and the
18343797fadabacf01280b38ea7688690d12aec0rbb * buckets are released. The buckets that these point to
18343797fadabacf01280b38ea7688690d12aec0rbb * have all been set aside in the ssi_tag_brigade (along
18343797fadabacf01280b38ea7688690d12aec0rbb * with all of the intervening buckets).
18343797fadabacf01280b38ea7688690d12aec0rbb * X_start_index: The index points within the specified bucket contents
18343797fadabacf01280b38ea7688690d12aec0rbb * where the first character of the STARTING_SEQUENCE,
18343797fadabacf01280b38ea7688690d12aec0rbb * the first non-whitespace character of the tag, and the
18343797fadabacf01280b38ea7688690d12aec0rbb * first character in the ENDING_SEQUENCE can be found
18343797fadabacf01280b38ea7688690d12aec0rbb * (head_, tag_, and tail_ respectively).
18343797fadabacf01280b38ea7688690d12aec0rbb * combined_tag: Once the PARSED state is reached the tag is collected from
18343797fadabacf01280b38ea7688690d12aec0rbb * the bucket(s) in the ssi_tag_brigade into this contiguous
18343797fadabacf01280b38ea7688690d12aec0rbb * buffer. The buckets in the ssi_tag_brigade are released
18343797fadabacf01280b38ea7688690d12aec0rbb * and the tag is processed.
18343797fadabacf01280b38ea7688690d12aec0rbb * curr_tag_pos: Ptr to the combined_tag buffer indicating the current
18343797fadabacf01280b38ea7688690d12aec0rbb * parse position.
18343797fadabacf01280b38ea7688690d12aec0rbb * tag_length: The number of bytes in the actual tag (excluding the
18343797fadabacf01280b38ea7688690d12aec0rbb * STARTING_SEQUENCE, leading and trailing whitespace,
18343797fadabacf01280b38ea7688690d12aec0rbb * and ENDING_SEQUENCE). This length is computed as the
18343797fadabacf01280b38ea7688690d12aec0rbb * buckets are parsed and set aside during the PARSE_TAG state.
18343797fadabacf01280b38ea7688690d12aec0rbb * ssi_tag_brigade: The temporary brigade used by this filter to set aside
18343797fadabacf01280b38ea7688690d12aec0rbb * the buckets containing parts of the ssi tag and headers.
f6e9f5600e77b78fb013bb543d364135961639d1rbbtypedef enum {PRE_HEAD, PARSE_HEAD, PARSE_DIRECTIVE, PARSE_TAG, PARSE_TAIL, PARSED} states;
18343797fadabacf01280b38ea7688690d12aec0rbbtypedef struct include_filter_ctx {
18343797fadabacf01280b38ea7688690d12aec0rbb/* These flags are used to set flag bits. */
18343797fadabacf01280b38ea7688690d12aec0rbb#define FLAG_PRINTING 0x00000001 /* Printing conditional lines. */
18343797fadabacf01280b38ea7688690d12aec0rbb#define FLAG_COND_TRUE 0x00000002 /* Conditional eval'd to true. */
18343797fadabacf01280b38ea7688690d12aec0rbb#define FLAG_SIZE_IN_BYTES 0x00000004 /* Sizes displayed in bytes. */
18343797fadabacf01280b38ea7688690d12aec0rbb#define FLAG_NO_EXEC 0x00000008 /* No Exec in current context. */
18343797fadabacf01280b38ea7688690d12aec0rbb/* These flags are used to clear flag bits. */
18343797fadabacf01280b38ea7688690d12aec0rbb#define FLAG_SIZE_ABBREV 0xFFFFFFFB /* Reset SIZE_IN_BYTES bit. */
18343797fadabacf01280b38ea7688690d12aec0rbb#define FLAG_CLEAR_PRINT_COND 0xFFFFFFFC /* Reset PRINTING and COND_TRUE*/
18343797fadabacf01280b38ea7688690d12aec0rbb#define FLAG_CLEAR_PRINTING 0xFFFFFFFE /* Reset just PRINTING bit. */
18343797fadabacf01280b38ea7688690d12aec0rbb#define CREATE_ERROR_BUCKET(cntx, t_buck, h_ptr, ins_head) \
18343797fadabacf01280b38ea7688690d12aec0rbb tag_plus = ap_brigade_split(brgd, cntxt->head_start_bucket); \
f6e9f5600e77b78fb013bb543d364135961639d1rbbtypedef int (*handler)(include_ctx_t *ctx, ap_bucket_brigade **bb,
f6e9f5600e77b78fb013bb543d364135961639d1rbbvoid ap_register_include_handler(char *tag, handler func);
18343797fadabacf01280b38ea7688690d12aec0rbb#endif /* MOD_INCLUDE */