util_script.h revision b99dbaab171d91e1b664397cc40e039d0c087c65
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd/* ====================================================================
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * The Apache Software License, Version 1.1
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd *
b475917ddf898282aa51ce31b3275c2c4783ce98coar * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd * reserved.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd *
031b91a62d25106ae69d4693475c79618dd5e884fielding * Redistribution and use in source and binary forms, with or without
031b91a62d25106ae69d4693475c79618dd5e884fielding * modification, are permitted provided that the following conditions
031b91a62d25106ae69d4693475c79618dd5e884fielding * are met:
031b91a62d25106ae69d4693475c79618dd5e884fielding *
031b91a62d25106ae69d4693475c79618dd5e884fielding * 1. Redistributions of source code must retain the above copyright
031b91a62d25106ae69d4693475c79618dd5e884fielding * notice, this list of conditions and the following disclaimer.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd *
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd * 2. Redistributions in binary form must reproduce the above copyright
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd * notice, this list of conditions and the following disclaimer in
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd * the documentation and/or other materials provided with the
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd * distribution.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd *
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd * 3. The end-user documentation included with the redistribution,
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd * if any, must include the following acknowledgment:
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd * "This product includes software developed by the
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd * Apache Software Foundation (http://www.apache.org/)."
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * Alternately, this acknowledgment may appear in the software itself,
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * if and wherever such third-party acknowledgments normally appear.
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd *
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * 4. The names "Apache" and "Apache Software Foundation" must
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * not be used to endorse or promote products derived from this
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * software without prior written permission. For written
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * permission, please contact apache@apache.org.
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd *
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * 5. Products derived from this software may not be called "Apache",
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * nor may "Apache" appear in their name, without prior written
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * permission of the Apache Software Foundation.
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd *
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * SUCH DAMAGE.
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * ====================================================================
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd *
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * This software consists of voluntary contributions made by many
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * individuals on behalf of the Apache Software Foundation. For more
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * information on the Apache Software Foundation, please see
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * <http://www.apache.org/>.
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd *
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * Portions of this software are based upon public domain software
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * originally written at the National Center for Supercomputing Applications,
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * University of Illinois, Urbana-Champaign.
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd */
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd#ifndef APACHE_UTIL_SCRIPT_H
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd#define APACHE_UTIL_SCRIPT_H
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd#ifdef __cplusplus
4ef32fc8ca017f80aa0d8ff267722a335c9d7784ndextern "C" {
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd#endif
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd/**
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @package Apache script tools
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd */
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd#ifndef APACHE_ARG_MAX
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd#ifdef _POSIX_ARG_MAX
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd#define APACHE_ARG_MAX _POSIX_ARG_MAX
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd#else
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd#define APACHE_ARG_MAX 512
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd#endif
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd#endif
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd/**
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * Create an environment variable out of an Apache table of key-value pairs
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @param p pool to allocate out of
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @param t Apache table of key-value pairs
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @return An array containing the same key-value pairs suitable for
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * use with an exec call.
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @deffunc char **ap_create_environment(apr_pool_t *p, apr_table_t *t)
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd */
4ef32fc8ca017f80aa0d8ff267722a335c9d7784ndAP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t);
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd/**
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * This "cute" little function comes about because the path info on
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * filenames and URLs aren't always the same. So we take the two,
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * and find as much of the two that match as possible.
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * @param uri The uri we are currently parsing
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * @param path_info The current path info
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * @return The length of the path info
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * @deffunc int ap_fine_path_info(const char *uri, const char *path_info)
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd */
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fndAP_DECLARE(int) ap_find_path_info(const char *uri, const char *path_info);
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd/**
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * Add CGI environment variables required by HTTP/1.1 to the request's
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * environment table
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * @param r the current request
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * @deffunc void ap_add_cgi_vars(request_rec *r)
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd */
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fndAP_DECLARE(void) ap_add_cgi_vars(request_rec *r);
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd/**
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * Add common CGI environment variables to the requests environment table
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @param r The current request
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @deffunc void ap_add_common_vars(request_rec *r)
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd */
4ef32fc8ca017f80aa0d8ff267722a335c9d7784ndAP_DECLARE(void) ap_add_common_vars(request_rec *r);
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd/**
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * Read headers output from a script, ensuring that the output is valid. If
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * the output is valid, then the headers are added to the headers out of the
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * current request
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @param r The current request
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @param f The file to read from
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @param buffer Empty when calling the function. On output, if there was an
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * error, the string that cause the error is stored here.
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @deffunc int ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer)
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd */
4ef32fc8ca017f80aa0d8ff267722a335c9d7784ndAP_DECLARE(int) ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer);
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd/**
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * Read headers strings from a script, ensuring that the output is valid. If
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * the output is valid, then the headers are added to the headers out of the
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * current request
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @param r The current request
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @param buffer Empty when calling the function. On output, if there was an
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * error, the string that cause the error is stored here.
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @param termch Pointer to the last character parsed.
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @param termarg Pointer to an int to capture the last argument parsed.
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * @param args String arguments to parse consecutively for headers,
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * a NULL argument terminates the list.
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd * @deffunc int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data)
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fnd */
5718d2b6ea423b4eb2d45f64bbc4c8eb61e0400fndAP_DECLARE_NONSTD(int) ap_scan_script_header_err_strs(request_rec *r,
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd char *buffer,
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd const char **termch,
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd int *termarg, ...);
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd/**
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * Read headers output from a script, ensuring that the output is valid. If
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * the output is valid, then the headers are added to the headers out of the
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * current request
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @param r The current request
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @param buffer Empty when calling the function. On output, if there was an
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * error, the string that cause the error is stored here.
4ef32fc8ca017f80aa0d8ff267722a335c9d7784nd * @param getsfunc Function to read the headers from. This function should
act like gets()
* @param getsfunc_data The place to read from
* @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
* @deffunc int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data)
*/
AP_DECLARE(int) ap_scan_script_header_err_core(request_rec *r, char *buffer,
int (*getsfunc) (char *, int, void *),
void *getsfunc_data);
/**
* Convert the file size given in size into a formatted string and send the
* string to the client. The size should always be in bytes, although the
* string sent to the client may be in bytes, kb, or MB, depending on the size
* of the file.
* @param size The size of the file
* @param r The currnt request
* @deffunc void ap_send_size(apr_ssize_t size, request_rec *r)
*/
AP_DECLARE(void) ap_send_size(apr_ssize_t size, request_rec *r);
#ifdef __cplusplus
}
#endif
#endif /* !APACHE_UTIL_SCRIPT_H */