Blame include/util_script.h

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