1 /* ====================================================================
2 * The Apache Software License, Version 1.1
4 * Copyright (c) 2000-2002 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
62 #include "apr_buckets.h"
69 * @package Apache script tools
72 #ifndef APACHE_ARG_MAX
74 #define APACHE_ARG_MAX _POSIX_ARG_MAX
76 #define APACHE_ARG_MAX 512
81 * Create an environment variable out of an Apache table of key-value pairs
82 * @param p pool to allocate out of
83 * @param t Apache table of key-value pairs
84 * @return An array containing the same key-value pairs suitable for
85 * use with an exec call.
86 * @deffunc char **ap_create_environment(apr_pool_t *p, apr_table_t *t)
88 AP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t);
91 * This "cute" little function comes about because the path info on
92 * filenames and URLs aren't always the same. So we take the two,
93 * and find as much of the two that match as possible.
94 * @param uri The uri we are currently parsing
95 * @param path_info The current path info
96 * @return The length of the path info
97 * @deffunc int ap_fine_path_info(const char *uri, const char *path_info)
99 AP_DECLARE(int) ap_find_path_info(const char *uri, const char *path_info);
102 * Add CGI environment variables required by HTTP/1.1 to the request's
104 * @param r the current request
105 * @deffunc void ap_add_cgi_vars(request_rec *r)
107 AP_DECLARE(void) ap_add_cgi_vars(request_rec *r);
110 * Add common CGI environment variables to the requests environment table
111 * @param r The current request
112 * @deffunc void ap_add_common_vars(request_rec *r)
114 AP_DECLARE(void) ap_add_common_vars(request_rec *r);
117 * Read headers output from a script, ensuring that the output is valid. If
118 * the output is valid, then the headers are added to the headers out of the
120 * @param r The current request
121 * @param f The file to read from
122 * @param buffer Empty when calling the function. On output, if there was an
123 * error, the string that cause the error is stored here.
124 * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
125 * @deffunc int ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer)
127 AP_DECLARE(int) ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer);
130 * Read headers output from a script, ensuring that the output is valid. If
131 * the output is valid, then the headers are added to the headers out of the
133 * @param r The current request
134 * @param bb The brigade from which to read
135 * @param buffer Empty when calling the function. On output, if there was an
136 * error, the string that cause the error is stored here.
137 * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
138 * @deffunc int ap_scan_script_header_err_brigade(request_rec *r, apr_bucket_brigade *bb, char *buffer)
140 AP_DECLARE(int) ap_scan_script_header_err_brigade(request_rec *r,
141 apr_bucket_brigade *bb,
145 * Read headers strings from a script, ensuring that the output is valid. If
146 * the output is valid, then the headers are added to the headers out of the
148 * @param r The current request
149 * @param buffer Empty when calling the function. On output, if there was an
150 * error, the string that cause the error is stored here.
151 * @param termch Pointer to the last character parsed.
152 * @param termarg Pointer to an int to capture the last argument parsed.
153 * @param args String arguments to parse consecutively for headers,
154 * a NULL argument terminates the list.
155 * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
156 * @deffunc int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data)
158 AP_DECLARE_NONSTD(int) ap_scan_script_header_err_strs(request_rec *r,
164 * Read headers output from a script, ensuring that the output is valid. If
165 * the output is valid, then the headers are added to the headers out of the
167 * @param r The current request
168 * @param buffer Empty when calling the function. On output, if there was an
169 * error, the string that cause the error is stored here.
170 * @param getsfunc Function to read the headers from. This function should
172 * @param getsfunc_data The place to read from
173 * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
174 * @deffunc int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data)
176 AP_DECLARE(int) ap_scan_script_header_err_core(request_rec *r, char *buffer,
177 int (*getsfunc) (char *, int, void *),
178 void *getsfunc_data);
184 #endif /* !APACHE_UTIL_SCRIPT_H */