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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @brief Apache script tools
21 * @defgroup APACHE_CORE_SCRIPT Script Tools
22 * @ingroup APACHE_CORE
26 #ifndef APACHE_UTIL_SCRIPT_H
27 #define APACHE_UTIL_SCRIPT_H
29 #include "apr_buckets.h"
35 #ifndef APACHE_ARG_MAX
37 #define APACHE_ARG_MAX _POSIX_ARG_MAX
39 #define APACHE_ARG_MAX 512
44 * Create an environment variable out of an Apache table of key-value pairs
45 * @param p pool to allocate out of
46 * @param t Apache table of key-value pairs
47 * @return An array containing the same key-value pairs suitable for
48 * use with an exec call.
49 * @fn char **ap_create_environment(apr_pool_t *p, apr_table_t *t)
51 AP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t);
54 * This "cute" little function comes about because the path info on
55 * filenames and URLs aren't always the same. So we take the two,
56 * and find as much of the two that match as possible.
57 * @param uri The uri we are currently parsing
58 * @param path_info The current path info
59 * @return The length of the path info
60 * @fn int ap_find_path_info(const char *uri, const char *path_info)
62 AP_DECLARE(int) ap_find_path_info(const char *uri, const char *path_info);
65 * Add CGI environment variables required by HTTP/1.1 to the request's
67 * @param r the current request
68 * @fn void ap_add_cgi_vars(request_rec *r)
70 AP_DECLARE(void) ap_add_cgi_vars(request_rec *r);
73 * Add common CGI environment variables to the requests environment table
74 * @param r The current request
75 * @fn void ap_add_common_vars(request_rec *r)
77 AP_DECLARE(void) ap_add_common_vars(request_rec *r);
80 * Read headers output from a script, ensuring that the output is valid. If
81 * the output is valid, then the headers are added to the headers out of the
83 * @param r The current request
84 * @param f The file to read from
85 * @param buffer Empty when calling the function. On output, if there was an
86 * error, the string that cause the error is stored here.
87 * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
88 * @fn int ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer)
90 AP_DECLARE(int) ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer);
93 * Read headers output from a script, ensuring that the output is valid. If
94 * the output is valid, then the headers are added to the headers out of the
96 * @param r The current request
97 * @param bb The brigade from which to read
98 * @param buffer Empty when calling the function. On output, if there was an
99 * error, the string that cause the error is stored here.
100 * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
101 * @fn int ap_scan_script_header_err_brigade(request_rec *r, apr_bucket_brigade *bb, char *buffer)
103 AP_DECLARE(int) ap_scan_script_header_err_brigade(request_rec *r,
104 apr_bucket_brigade *bb,
108 * Read headers strings from a script, ensuring that the output is valid. If
109 * the output is valid, then the headers are added to the headers out of the
111 * @param r The current request
112 * @param buffer Empty when calling the function. On output, if there was an
113 * error, the string that cause the error is stored here.
114 * @param termch Pointer to the last character parsed.
115 * @param termarg Pointer to an int to capture the last argument parsed.
116 * @param args String arguments to parse consecutively for headers,
117 * a NULL argument terminates the list.
118 * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
119 * @fn int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data)
121 AP_DECLARE_NONSTD(int) ap_scan_script_header_err_strs(request_rec *r,
127 * Read headers output from a script, ensuring that the output is valid. If
128 * the output is valid, then the headers are added to the headers out of the
130 * @param r The current request
131 * @param buffer Empty when calling the function. On output, if there was an
132 * error, the string that cause the error is stored here.
133 * @param getsfunc Function to read the headers from. This function should
135 * @param getsfunc_data The place to read from
136 * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
137 * @fn int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data)
139 AP_DECLARE(int) ap_scan_script_header_err_core(request_rec *r, char *buffer,
140 int (*getsfunc) (char *, int, void *),
141 void *getsfunc_data);
147 #endif /* !APACHE_UTIL_SCRIPT_H */