util_script.h revision 533d85911f7e4914ee5f9d5c99a2421f4ab4208a
6de8046f8f7e07cd83895a528df25d977e502c76nd/* Licensed to the Apache Software Foundation (ASF) under one or more
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * contributor license agreements. See the NOTICE file distributed with
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * this work for additional information regarding copyright ownership.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * The ASF licenses this file to You under the Apache License, Version 2.0
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * (the "License"); you may not use this file except in compliance with
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * the License. You may obtain a copy of the License at
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * Unless required by applicable law or agreed to in writing, software
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * distributed under the License is distributed on an "AS IS" BASIS,
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * See the License for the specific language governing permissions and
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * limitations under the License.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * @brief Apache script tools
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * @defgroup APACHE_CORE_SCRIPT Script Tools
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * @ingroup APACHE_CORE
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbextern "C" {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Create an environment variable out of an Apache table of key-value pairs
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * @param p pool to allocate out of
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * @param t Apache table of key-value pairs
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * @return An array containing the same key-value pairs suitable for
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * use with an exec call.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * @fn char **ap_create_environment(apr_pool_t *p, apr_table_t *t)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t);
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * This "cute" little function comes about because the path info on
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * filenames and URLs aren't always the same. So we take the two,
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * and find as much of the two that match as possible.
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * @param uri The uri we are currently parsing
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * @param path_info The current path info
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * @return The length of the path info
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * @fn int ap_find_path_info(const char *uri, const char *path_info)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAP_DECLARE(int) ap_find_path_info(const char *uri, const char *path_info);
a2a0abd88b19e042a3eb2a9fa1702c25ad51303dwrowe * Add CGI environment variables required by HTTP/1.1 to the request's
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * environment table
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * @param r the current request
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * @fn void ap_add_cgi_vars(request_rec *r)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Add common CGI environment variables to the requests environment table
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * @param r The current request
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * @fn void ap_add_common_vars(request_rec *r)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Read headers output from a script, ensuring that the output is valid. If
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * the output is valid, then the headers are added to the headers out of the
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * current request
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param r The current request
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param f The file to read from
2d399cd7535887fceaa9f8f116eb98ce68ddd602trawick * @param buffer Empty when calling the function. On output, if there was an
c2cf53a40a9814eb91db2cdf820f97d943f21628coar * error, the string that cause the error is stored here.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @fn int ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer)
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewroweAP_DECLARE(int) ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer);
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * Read headers output from a script, ensuring that the output is valid. If
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * the output is valid, then the headers are added to the headers out of the
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * current request
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param r The current request
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param f The file to read from
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param buffer Empty when calling the function. On output, if there was an
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * error, the string that cause the error is stored here.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param module_index The module index to be used for logging
3e392a5afd51526de3cb15d57ee46d8cb160ae65gregames * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewroweAP_DECLARE(int) ap_scan_script_header_err_ex(request_rec *r, apr_file_t *f,
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar * Read headers output from a script, ensuring that the output is valid. If
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar * the output is valid, then the headers are added to the headers out of the
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar * current request
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar * @param r The current request
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar * @param bb The brigade from which to read
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar * @param buffer Empty when calling the function. On output, if there was an
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * error, the string that cause the error is stored here.
2a6e98ba4ffa30ded5d8831664c5cb2a170a56b6coar * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar * @fn int ap_scan_script_header_err_brigade(request_rec *r, apr_bucket_brigade *bb, char *buffer)
8419e6f8bff1a3617933f3ba760d2bdec7442f44coarAP_DECLARE(int) ap_scan_script_header_err_brigade(request_rec *r,
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * Read headers output from a script, ensuring that the output is valid. If
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * the output is valid, then the headers are added to the headers out of the
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * current request
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param r The current request
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param bb The brigade from which to read
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param buffer Empty when calling the function. On output, if there was an
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * error, the string that cause the error is stored here.
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * @param module_index The module index to be used for logging
3e392a5afd51526de3cb15d57ee46d8cb160ae65gregames * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoarAP_DECLARE(int) ap_scan_script_header_err_brigade_ex(request_rec *r,
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * Read headers strings from a script, ensuring that the output is valid. If
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * the output is valid, then the headers are added to the headers out of the
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * current request
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param r The current request
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * @param buffer Empty when calling the function. On output, if there was an
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * error, the string that cause the error is stored here.
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * @param termch Pointer to the last character parsed.
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * @param termarg Pointer to an int to capture the last argument parsed.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * The varargs are string arguments to parse consecutively for headers,
4775dfc34c90fada8c7c4d6a57ed8a3114d55c2dtrawick * with a NULL argument to terminate the list.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wroweAP_DECLARE_NONSTD(int) ap_scan_script_header_err_strs(request_rec *r,
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe const char **termch,
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * Read headers strings from a script, ensuring that the output is valid. If
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * the output is valid, then the headers are added to the headers out of the
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * current request
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param r The current request
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param buffer Empty when calling the function. On output, if there was an
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * error, the string that cause the error is stored here.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param module_index The module index to be used for logging
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param termch Pointer to the last character parsed.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param termarg Pointer to an int to capture the last argument parsed.
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * The varargs are string arguments to parse consecutively for headers,
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * with a NULL argument to terminate the list.
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
4f9c22c4f27571d54197be9674e1fc0d528192aestrikerAP_DECLARE_NONSTD(int) ap_scan_script_header_err_strs_ex(request_rec *r,
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe const char **termch,
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * Read headers output from a script, ensuring that the output is valid. If
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * the output is valid, then the headers are added to the headers out of the
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * current request
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * @param r The current request
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param buffer Empty when calling the function. On output, if there was an
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * error, the string that cause the error is stored here.
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * @param getsfunc Function to read the headers from. This function should
c2cf53a40a9814eb91db2cdf820f97d943f21628coar act like gets()
c2cf53a40a9814eb91db2cdf820f97d943f21628coar * @param getsfunc_data The place to read from
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantzAP_DECLARE(int) ap_scan_script_header_err_core(request_rec *r, char *buffer,
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz int (*getsfunc) (char *, int, void *),
c2cf53a40a9814eb91db2cdf820f97d943f21628coar * Read headers output from a script, ensuring that the output is valid. If
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * the output is valid, then the headers are added to the headers out of the
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * current request
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * @param r The current request
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * @param buffer Empty when calling the function. On output, if there was an
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * error, the string that cause the error is stored here.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * @param getsfunc Function to read the headers from. This function should
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe act like gets()
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * @param getsfunc_data The place to read from
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * @param module_index The module index to be used for logging
08ab23ee4e41ac8587da5a3bb8d4e9c49523b0b8nd * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
08ab23ee4e41ac8587da5a3bb8d4e9c49523b0b8ndAP_DECLARE(int) ap_scan_script_header_err_core_ex(request_rec *r, char *buffer,
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe int (*getsfunc) (char *, int, void *),
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * Parse query args for the request and store in a new table allocated
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * from the request pool.
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * For args with no value, "1" will be used instead.
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * If no query args were specified, the table will be empty.
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * @param r The current request
c2cf53a40a9814eb91db2cdf820f97d943f21628coar * @param table A new table on output.
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wroweAP_DECLARE(void) ap_args_to_table(request_rec *r, apr_table_t **table);
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe#endif /* !APACHE_UTIL_SCRIPT_H */