1 /* ====================================================================
2 * The Apache Software License, Version 1.1
4 * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
19 * 3. The end-user documentation included with the redistribution,
20 * if any, must include the following acknowledgment:
21 * "This product includes software developed by the
22 * Apache Software Foundation (http://www.apache.org/)."
23 * Alternately, this acknowledgment may appear in the software itself,
24 * if and wherever such third-party acknowledgments normally appear.
26 * 4. The names "Apache" and "Apache Software Foundation" must
27 * not be used to endorse or promote products derived from this
28 * software without prior written permission. For written
29 * permission, please contact apache@apache.org.
31 * 5. Products derived from this software may not be called "Apache",
32 * nor may "Apache" appear in their name, without prior written
33 * permission of the Apache Software Foundation.
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * ====================================================================
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation. For more
51 * information on the Apache Software Foundation, please see
52 * <http://www.apache.org/>.
54 * Portions of this software are based upon public domain software
55 * originally written at the National Center for Supercomputing Applications,
56 * University of Illinois, Urbana-Champaign.
59 #ifndef APACHE_UTIL_SCRIPT_H
60 #define APACHE_UTIL_SCRIPT_H
67 * @package Apache script tools
70 #ifndef APACHE_ARG_MAX
72 #define APACHE_ARG_MAX _POSIX_ARG_MAX
74 #define APACHE_ARG_MAX 512
79 * Create an environment variable out of an Apache table of key-value pairs
80 * @param p pool to allocate out of
81 * @param t Apache table of key-value pairs
82 * @return An array containing the same key-value pairs suitable for
83 * use with an exec call.
84 * @deffunc char **ap_create_environment(apr_pool_t *p, apr_table_t *t)
86 AP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t);
89 * This "cute" little function comes about because the path info on
90 * filenames and URLs aren't always the same. So we take the two,
91 * and find as much of the two that match as possible.
92 * @param uri The uri we are currently parsing
93 * @param path_info The current path info
94 * @return The length of the path info
95 * @deffunc int ap_fine_path_info(const char *uri, const char *path_info)
97 AP_DECLARE(int) ap_find_path_info(const char *uri, const char *path_info);
100 * Add CGI environment variables required by HTTP/1.1 to the request's
102 * @param r the current request
103 * @deffunc void ap_add_cgi_vars(request_rec *r)
105 AP_DECLARE(void) ap_add_cgi_vars(request_rec *r);
108 * Add common CGI environment variables to the requests environment table
109 * @param r The current request
110 * @deffunc void ap_add_common_vars(request_rec *r)
112 AP_DECLARE(void) ap_add_common_vars(request_rec *r);
115 * Read headers output from a script, ensuring that the output is valid. If
116 * the output is valid, then the headers are added to the headers out of the
118 * @param r The current request
119 * @param f The file to read from
120 * @param buffer Empty when calling the function. On output, if there was an
121 * error, the string that cause the error is stored here.
122 * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
123 * @deffunc int ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer)
125 AP_DECLARE(int) ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer);
128 * Read headers strings from a script, ensuring that the output is valid. If
129 * the output is valid, then the headers are added to the headers out of the
131 * @param r The current request
132 * @param buffer Empty when calling the function. On output, if there was an
133 * error, the string that cause the error is stored here.
134 * @param termch Pointer to the last character parsed.
135 * @param termarg Pointer to an int to capture the last argument parsed.
136 * @param args String arguments to parse consecutively for headers,
137 * a NULL argument terminates the list.
138 * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
139 * @deffunc int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data)
141 AP_DECLARE_NONSTD(int) ap_scan_script_header_err_strs(request_rec *r,
147 * Read headers output from a script, ensuring that the output is valid. If
148 * the output is valid, then the headers are added to the headers out of the
150 * @param r The current request
151 * @param buffer Empty when calling the function. On output, if there was an
152 * error, the string that cause the error is stored here.
153 * @param getsfunc Function to read the headers from. This function should
155 * @param getsfunc_data The place to read from
156 * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
157 * @deffunc int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data)
159 AP_DECLARE(int) ap_scan_script_header_err_core(request_rec *r, char *buffer,
160 int (*getsfunc) (char *, int, void *),
161 void *getsfunc_data);
167 #endif /* !APACHE_UTIL_SCRIPT_H */