upload apache
[bottlenecks.git] / rubbos / app / apache2 / include / util_script.h
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements.  See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License.  You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef APACHE_UTIL_SCRIPT_H
18 #define APACHE_UTIL_SCRIPT_H
19
20 #include "apr_buckets.h"
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 /**
27  * @package Apache script tools
28  */
29
30 #ifndef APACHE_ARG_MAX
31 #ifdef _POSIX_ARG_MAX
32 #define APACHE_ARG_MAX _POSIX_ARG_MAX
33 #else
34 #define APACHE_ARG_MAX 512
35 #endif
36 #endif
37
38 /**
39  * Create an environment variable out of an Apache table of key-value pairs
40  * @param p pool to allocate out of
41  * @param t Apache table of key-value pairs
42  * @return An array containing the same key-value pairs suitable for
43  *         use with an exec call.
44  * @deffunc char **ap_create_environment(apr_pool_t *p, apr_table_t *t)
45  */
46 AP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t);
47
48 /**
49  * This "cute" little function comes about because the path info on
50  * filenames and URLs aren't always the same. So we take the two,
51  * and find as much of the two that match as possible.
52  * @param uri The uri we are currently parsing
53  * @param path_info The current path info
54  * @return The length of the path info
55  * @deffunc int ap_find_path_info(const char *uri, const char *path_info)
56  */
57 AP_DECLARE(int) ap_find_path_info(const char *uri, const char *path_info);
58
59 /**
60  * Add CGI environment variables required by HTTP/1.1 to the request's 
61  * environment table
62  * @param r the current request
63  * @deffunc void ap_add_cgi_vars(request_rec *r)
64  */
65 AP_DECLARE(void) ap_add_cgi_vars(request_rec *r);
66
67 /**
68  * Add common CGI environment variables to the requests environment table
69  * @param r The current request
70  * @deffunc void ap_add_common_vars(request_rec *r)
71  */
72 AP_DECLARE(void) ap_add_common_vars(request_rec *r);
73
74 /**
75  * Read headers output from a script, ensuring that the output is valid.  If
76  * the output is valid, then the headers are added to the headers out of the
77  * current request
78  * @param r The current request
79  * @param f The file to read from
80  * @param buffer Empty when calling the function.  On output, if there was an
81  *               error, the string that cause the error is stored here. 
82  * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
83  * @deffunc int ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer)
84  */ 
85 AP_DECLARE(int) ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer);
86
87 /**
88  * Read headers output from a script, ensuring that the output is valid.  If
89  * the output is valid, then the headers are added to the headers out of the
90  * current request
91  * @param r The current request
92  * @param bb The brigade from which to read
93  * @param buffer Empty when calling the function.  On output, if there was an
94  *               error, the string that cause the error is stored here. 
95  * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
96  * @deffunc int ap_scan_script_header_err_brigade(request_rec *r, apr_bucket_brigade *bb, char *buffer)
97  */ 
98 AP_DECLARE(int) ap_scan_script_header_err_brigade(request_rec *r,
99                                                   apr_bucket_brigade *bb,
100                                                   char *buffer);
101
102 /**
103  * Read headers strings from a script, ensuring that the output is valid.  If
104  * the output is valid, then the headers are added to the headers out of the
105  * current request
106  * @param r The current request
107  * @param buffer Empty when calling the function.  On output, if there was an
108  *               error, the string that cause the error is stored here. 
109  * @param termch Pointer to the last character parsed.
110  * @param termarg Pointer to an int to capture the last argument parsed.
111  * @param args   String arguments to parse consecutively for headers, 
112  *               a NULL argument terminates the list.
113  * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
114  * @deffunc int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data)
115  */ 
116 AP_DECLARE_NONSTD(int) ap_scan_script_header_err_strs(request_rec *r, 
117                                                       char *buffer, 
118                                                       const char **termch,
119                                                       int *termarg, ...);
120
121 /**
122  * Read headers output from a script, ensuring that the output is valid.  If
123  * the output is valid, then the headers are added to the headers out of the
124  * current request
125  * @param r The current request
126  * @param buffer Empty when calling the function.  On output, if there was an
127  *               error, the string that cause the error is stored here. 
128  * @param getsfunc Function to read the headers from.  This function should
129                    act like gets()
130  * @param getsfunc_data The place to read from
131  * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
132  * @deffunc int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data)
133  */ 
134 AP_DECLARE(int) ap_scan_script_header_err_core(request_rec *r, char *buffer,
135                                        int (*getsfunc) (char *, int, void *),
136                                        void *getsfunc_data);
137
138 #ifdef __cplusplus
139 }
140 #endif
141
142 #endif  /* !APACHE_UTIL_SCRIPT_H */