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