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.
17 #ifndef APACHE_UTIL_SCRIPT_H
18 #define APACHE_UTIL_SCRIPT_H
20 #include "apr_buckets.h"
27 * @package Apache script tools
30 #ifndef APACHE_ARG_MAX
32 #define APACHE_ARG_MAX _POSIX_ARG_MAX
34 #define APACHE_ARG_MAX 512
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)
46 AP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t);
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)
57 AP_DECLARE(int) ap_find_path_info(const char *uri, const char *path_info);
60 * Add CGI environment variables required by HTTP/1.1 to the request's
62 * @param r the current request
63 * @deffunc void ap_add_cgi_vars(request_rec *r)
65 AP_DECLARE(void) ap_add_cgi_vars(request_rec *r);
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)
72 AP_DECLARE(void) ap_add_common_vars(request_rec *r);
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
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)
85 AP_DECLARE(int) ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer);
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
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)
98 AP_DECLARE(int) ap_scan_script_header_err_brigade(request_rec *r,
99 apr_bucket_brigade *bb,
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
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)
116 AP_DECLARE_NONSTD(int) ap_scan_script_header_err_strs(request_rec *r,
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
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
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)
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);
142 #endif /* !APACHE_UTIL_SCRIPT_H */