Apache HTTPD
Classes | Macros | Typedefs | Enumerations | Functions | Variables
util.c File Reference
#include "apr.h"
#include "apr_strings.h"
#include "apr_lib.h"
#include "apr_want.h"
#include "ap_config.h"
#include "apr_base64.h"
#include "apr_fnmatch.h"
#include "httpd.h"
#include "http_main.h"
#include "http_log.h"
#include "http_protocol.h"
#include "http_config.h"
#include "http_core.h"
#include "util_ebcdic.h"
#include "util_varbuf.h"
#include "ap_mpm.h"
#include "test_char.h"

Go to the source code of this file.

Classes

struct  ap_varbuf_info
 
struct  fnames
 

Macros

#define APR_WANT_STDIO
 
#define APR_WANT_STRFUNC
 
#define APLOG_MODULE_INDEX   AP_CORE_MODULE_INDEX
 
#define AP_MAX_FNMATCH_DIR_DEPTH   (128)
 
#define AP_PREGSUB_MAXLEN   (HUGE_STRING_LEN * 8)
 
#define IS_SLASH_OR_NUL(s)   (s == '\0' || AP_IS_SLASH(s))
 
#define MAXHOSTNAMELEN   256
 
#define CHECK_OVERFLOW(a, b)   if (a > b) return APR_EGENERAL
 
#define VARBUF_SMALL_SIZE   2048
 
#define VARBUF_MAX_SIZE
 

Typedefs

typedef enum ap_etag_e ap_etag_e
 

Enumerations

enum  ap_etag_e { AP_ETAG_NONE , AP_ETAG_WEAK , AP_ETAG_STRONG }
 
enum  ap_form_type_t {
  FORM_NORMAL , FORM_AMP , FORM_NAME , FORM_VALUE ,
  FORM_PERCENTA , FORM_PERCENTB , FORM_ABORT
}
 

Functions

charap_field_noparam (apr_pool_t *p, const char *intype)
 
charap_ht_time (apr_pool_t *p, apr_time_t t, const char *fmt, int gmt)
 
int ap_strcmp_match (const char *str, const char *expected)
 
int ap_strcasecmp_match (const char *str, const char *expected)
 
int ap_os_is_path_absolute (apr_pool_t *p, const char *dir)
 
int ap_is_matchexp (const char *str)
 
static apr_status_t regex_cleanup (void *preg)
 
ap_regex_tap_pregcomp (apr_pool_t *p, const char *pattern, int cflags)
 
void ap_pregfree (apr_pool_t *p, ap_regex_t *reg)
 
charap_strcasestr (const char *s1, const char *s2)
 
const charap_stripprefix (const char *bigstring, const char *prefix)
 
static apr_status_t regsub_core (apr_pool_t *p, char **result, struct ap_varbuf *vb, const char *input, const char *source, apr_size_t nmatch, ap_regmatch_t pmatch[], apr_size_t maxlen)
 
charap_pregsub (apr_pool_t *p, const char *input, const char *source, apr_size_t nmatch, ap_regmatch_t pmatch[])
 
apr_status_t ap_pregsub_ex (apr_pool_t *p, char **result, const char *input, const char *source, apr_size_t nmatch, ap_regmatch_t pmatch[], apr_size_t maxlen)
 
static char x2c (const char *what)
 
int ap_normalize_path (char *path, unsigned int flags)
 
void ap_getparents (char *name)
 
void ap_no2slash_ex (char *name, int is_fs_path)
 
void ap_no2slash (char *name)
 
charap_make_dirstr_prefix (char *d, const char *s, int n)
 
charap_make_dirstr_parent (apr_pool_t *p, const char *s)
 
int ap_count_dirs (const char *path)
 
charap_getword_nc (apr_pool_t *atrans, char **line, char stop)
 
charap_getword (apr_pool_t *atrans, const char **line, char stop)
 
charap_getword_white_nc (apr_pool_t *atrans, char **line)
 
charap_getword_white (apr_pool_t *atrans, const char **line)
 
charap_getword_nulls_nc (apr_pool_t *atrans, char **line, char stop)
 
charap_getword_nulls (apr_pool_t *atrans, const char **line, char stop)
 
static charsubstring_conf (apr_pool_t *p, const char *start, int len, char quote)
 
charap_getword_conf_nc (apr_pool_t *p, char **line)
 
charap_getword_conf (apr_pool_t *p, const char **line)
 
charap_getword_conf2_nc (apr_pool_t *p, char **line)
 
charap_getword_conf2 (apr_pool_t *p, const char **line)
 
int ap_cfg_closefile (ap_configfile_t *cfp)
 
static apr_status_t cfg_close (void *param)
 
static apr_status_t cfg_getch (char *ch, void *param)
 
static apr_status_t cfg_getstr (void *buf, apr_size_t bufsiz, void *param)
 
apr_status_t ap_pcfg_openfile (ap_configfile_t **ret_cfg, apr_pool_t *p, const char *name)
 
ap_configfile_tap_pcfg_open_custom (apr_pool_t *p, const char *descr, void *param, apr_status_t(*getc_func)(char *ch, void *param), apr_status_t(*gets_func)(void *buf, apr_size_t bufsize, void *param), apr_status_t(*close_func)(void *param))
 
apr_status_t ap_cfg_getc (char *ch, ap_configfile_t *cfp)
 
const charap_pcfg_strerror (apr_pool_t *p, ap_configfile_t *cfp, apr_status_t rc)
 
static apr_status_t ap_cfg_getline_core (char *buf, apr_size_t bufsize, apr_size_t offset, ap_configfile_t *cfp)
 
static int cfg_trim_line (char *buf)
 
apr_status_t ap_cfg_getline (char *buf, apr_size_t bufsize, ap_configfile_t *cfp)
 
apr_status_t ap_varbuf_cfg_getline (struct ap_varbuf *vb, ap_configfile_t *cfp, apr_size_t max_len)
 
const charap_size_list_item (const char **field, int *len)
 
charap_get_list_item (apr_pool_t *p, const char **field)
 
static int find_list_item (apr_pool_t *p, const char *line, const char *tok, ap_etag_e type)
 
int ap_find_list_item (apr_pool_t *p, const char *line, const char *tok)
 
int ap_find_etag_strong (apr_pool_t *p, const char *line, const char *tok)
 
int ap_find_etag_weak (apr_pool_t *p, const char *line, const char *tok)
 
const charap_parse_token_list_strict (apr_pool_t *p, const char *str_in, apr_array_header_t **tokens, int skip_invalid)
 
const charap_scan_http_field_content (const char *ptr)
 
const charap_scan_http_token (const char *ptr)
 
const charap_scan_vchar_obstext (const char *ptr)
 
charap_get_token (apr_pool_t *p, const char **accept_line, int accept_white)
 
int ap_find_token (apr_pool_t *p, const char *line, const char *tok)
 
static const charfind_last_token (apr_pool_t *p, const char *line, const char *tok)
 
int ap_find_last_token (apr_pool_t *p, const char *line, const char *tok)
 
int ap_is_chunked (apr_pool_t *p, const char *line)
 
charap_escape_shell_cmd (apr_pool_t *p, const char *str)
 
static int unescape_url (char *url, const char *forbid, const char *reserved, unsigned int flags)
 
int ap_unescape_url (char *url)
 
int ap_unescape_url_keep2f (char *url, int decode_slashes)
 
int ap_unescape_url_ex (char *url, unsigned int flags)
 
int ap_unescape_urlencoded (char *query)
 
charap_construct_server (apr_pool_t *p, const char *hostname, apr_port_t port, const request_rec *r)
 
int ap_unescape_all (char *url)
 
static APR_INLINE unsigned charc2x (unsigned what, unsigned char prefix, unsigned char *where)
 
charap_escape_path_segment_buffer (char *copy, const char *segment)
 
charap_escape_path_segment (apr_pool_t *p, const char *segment)
 
charap_os_escape_path (apr_pool_t *p, const char *path, int partial)
 
charap_escape_urlencoded_buffer (char *copy, const char *buffer)
 
charap_escape_urlencoded (apr_pool_t *p, const char *buffer)
 
charap_escape_html2 (apr_pool_t *p, const char *s, int toasc)
 
charap_escape_logitem (apr_pool_t *p, const char *str)
 
apr_size_t ap_escape_errorlog_item (char *dest, const char *source, apr_size_t buflen)
 
void ap_bin2hex (const void *src, apr_size_t srclen, char *dest)
 
int ap_is_directory (apr_pool_t *p, const char *path)
 
int ap_is_rdirectory (apr_pool_t *p, const char *path)
 
charap_make_full_path (apr_pool_t *a, const char *src1, const char *src2)
 
int ap_is_url (const char *u)
 
int ap_ind (const char *s, char c)
 
int ap_rind (const char *s, char c)
 
void ap_str_tolower (char *str)
 
void ap_str_toupper (char *str)
 
charap_get_local_host (apr_pool_t *a)
 
charap_pbase64decode (apr_pool_t *p, const char *bufcoded)
 
charap_pbase64encode (apr_pool_t *p, char *string)
 
void ap_content_type_tolower (char *str)
 
charap_escape_quotes (apr_pool_t *p, const char *instring)
 
charap_append_pid (apr_pool_t *p, const char *string, const char *delim)
 
apr_status_t ap_timeout_parameter_parse (const char *timeout_parameter, apr_interval_time_t *timeout, const char *default_time_unit)
 
int ap_parse_strict_length (apr_off_t *len, const char *str)
 
int ap_request_has_body (request_rec *r)
 
apr_status_t ap_pool_cleanup_set_null (void *data_)
 
apr_status_t ap_str2_alnum (const char *src, char *dest)
 
apr_status_t ap_pstr2_alnum (apr_pool_t *p, const char *src, const char **dest)
 
int ap_parse_form_data (request_rec *r, ap_filter_t *f, apr_array_header_t **ptr, apr_size_t num, apr_size_t usize)
 
static apr_status_t varbuf_cleanup (void *info_)
 
void ap_varbuf_init (apr_pool_t *p, struct ap_varbuf *vb, apr_size_t init_size)
 
void ap_varbuf_grow (struct ap_varbuf *vb, apr_size_t new_len)
 
void ap_varbuf_strmemcat (struct ap_varbuf *vb, const char *str, int len)
 
void ap_varbuf_free (struct ap_varbuf *vb)
 
charap_varbuf_pdup (apr_pool_t *p, struct ap_varbuf *buf, const char *prepend, apr_size_t prepend_len, const char *append, apr_size_t append_len, apr_size_t *new_len)
 
apr_status_t ap_varbuf_regsub (struct ap_varbuf *vb, const char *input, const char *source, apr_size_t nmatch, ap_regmatch_t pmatch[], apr_size_t maxlen)
 
void ap_abort_on_oom (void)
 
void * ap_malloc (size_t size)
 
void * ap_calloc (size_t nelem, size_t size)
 
void * ap_realloc (void *ptr, size_t size)
 
void ap_get_sload (ap_sload_t *ld)
 
void ap_get_loadavg (ap_loadavg_t *ld)
 
charap_get_exec_line (apr_pool_t *p, const char *cmd, const char *const *argv)
 
int ap_array_str_index (const apr_array_header_t *array, const char *s, int start)
 
int ap_array_str_contains (const apr_array_header_t *array, const char *s)
 
int ap_cstr_casecmp (const char *s1, const char *s2)
 
int ap_cstr_casecmpn (const char *s1, const char *s2, apr_size_t n)
 
static int fname_alphasort (const void *fn1, const void *fn2)
 
ap_dir_match_tap_dir_cfgmatch (cmd_parms *cmd, int flags, const char *(*cb)(ap_dir_match_t *w, const char *fname), void *ctx)
 
const charap_dir_nofnmatch (ap_dir_match_t *w, const char *fname)
 
const charap_dir_fnmatch (ap_dir_match_t *w, const char *path, const char *fname)
 

Variables

static const char c2x_table [] = "0123456789abcdef"
 
static const char nul = '\0'
 
static char *const varbuf_empty = (char *)&nul
 
static const char *const oom_message
 
static const short ucharmap []
 

Macro Definition Documentation

◆ AP_MAX_FNMATCH_DIR_DEPTH

#define AP_MAX_FNMATCH_DIR_DEPTH   (128)

Definition at line 84 of file util.c.

◆ AP_PREGSUB_MAXLEN

#define AP_PREGSUB_MAXLEN   (HUGE_STRING_LEN * 8)

Definition at line 455 of file util.c.

◆ APLOG_MODULE_INDEX

#define APLOG_MODULE_INDEX   AP_CORE_MODULE_INDEX

Definition at line 80 of file util.c.

◆ APR_WANT_STDIO

#define APR_WANT_STDIO

Definition at line 34 of file util.c.

◆ APR_WANT_STRFUNC

#define APR_WANT_STRFUNC

Definition at line 35 of file util.c.

◆ CHECK_OVERFLOW

#define CHECK_OVERFLOW (   a,
  b 
)    if (a > b) return APR_EGENERAL

Parse a given timeout parameter string into an apr_interval_time_t value. The unit of the time interval is given as postfix string to the numeric string. Currently the following units are understood:

ms : milliseconds s : seconds mi[n] : minutes h : hours

If no unit is contained in the given timeout parameter the default_time_unit will be used instead.

Parameters
timeout_parameterThe string containing the timeout parameter.
timeoutThe timeout value to be returned.
default_time_unitThe default time unit to use if none is specified in timeout_parameter.
Returns
Status value indicating whether the parsing was successful or not.

Definition at line 2621 of file util.c.

◆ IS_SLASH_OR_NUL

#define IS_SLASH_OR_NUL (   s)    (s == '\0' || AP_IS_SLASH(s))

Definition at line 484 of file util.c.

◆ MAXHOSTNAMELEN

#define MAXHOSTNAMELEN   256

◆ VARBUF_MAX_SIZE

#define VARBUF_MAX_SIZE
Value:
(APR_SIZE_MAX - 1 - \
apr_size_t size

Definition at line 2940 of file util.c.

◆ VARBUF_SMALL_SIZE

#define VARBUF_SMALL_SIZE   2048

Definition at line 2939 of file util.c.

Typedef Documentation

◆ ap_etag_e

Enumeration Type Documentation

◆ ap_etag_e

Enumerator
AP_ETAG_NONE 
AP_ETAG_WEAK 
AP_ETAG_STRONG 

Definition at line 1398 of file util.c.

◆ ap_form_type_t

Read the body and parse any form found, which must be of the type application/x-www-form-urlencoded.

Name/value pairs are returned in an array, with the names as strings with a maximum length of HUGE_STRING_LEN, and the values as bucket brigades. This allows values to be arbitrarily large.

All url-encoding is removed from both the names and the values on the fly. The names are interpreted as strings, while the values are interpreted as blocks of binary data, that may contain the 0 character.

In order to ensure that resource limits are not exceeded, a maximum size must be provided. If the sum of the lengths of the names and the values exceed this size, this function will return HTTP_REQUEST_ENTITY_TOO_LARGE.

An optional number of parameters can be provided, if the number of parameters provided exceeds this amount, this function will return HTTP_REQUEST_ENTITY_TOO_LARGE. If this value is negative, no limit is imposed, and the number of parameters is in turn constrained by the size parameter above.

This function honours any kept_body configuration, and the original raw request body will be saved to the kept_body brigade if so configured, just as ap_discard_request_body does.

NOTE: File upload is not yet supported, but can be without change to the function call.

Enumerator
FORM_NORMAL 
FORM_AMP 
FORM_NAME 
FORM_VALUE 
FORM_PERCENTA 
FORM_PERCENTB 
FORM_ABORT 

Definition at line 2777 of file util.c.

Function Documentation

◆ ap_cfg_getline_core()

static apr_status_t ap_cfg_getline_core ( char buf,
apr_size_t  bufsize,
apr_size_t  offset,
ap_configfile_t cfp 
)
static

Definition at line 1079 of file util.c.

◆ ap_dir_cfgmatch()

ap_dir_match_t * ap_dir_cfgmatch ( cmd_parms cmd,
int  flags,
const char *(*)(ap_dir_match_t *w, const char *fname cb,
void *  ctx 
)

Definition at line 3589 of file util.c.

◆ ap_dir_fnmatch()

const char * ap_dir_fnmatch ( ap_dir_match_t w,
const char path,
const char fname 
)

< an atomic unix apr_dir_read()

< Type

< Period must be matched by period.

Definition at line 3681 of file util.c.

◆ ap_dir_nofnmatch()

const char * ap_dir_nofnmatch ( ap_dir_match_t w,
const char fname 
)

< an atomic unix apr_dir_read()

< Type

Definition at line 3605 of file util.c.

◆ ap_pcfg_open_custom()

ap_configfile_t * ap_pcfg_open_custom ( apr_pool_t p,
const char descr,
void *  param,
apr_status_t(*)(char *ch, void *param getc_func,
apr_status_t(*)(void *buf, apr_size_t bufsize, void *param gets_func,
apr_status_t(*)(void *param close_func 
)

Definition at line 1038 of file util.c.

◆ c2x()

static APR_INLINE unsigned char * c2x ( unsigned  what,
unsigned char  prefix,
unsigned char where 
)
static

Definition at line 2022 of file util.c.

◆ cfg_close()

static apr_status_t cfg_close ( void *  param)
static

Definition at line 941 of file util.c.

◆ cfg_getch()

static apr_status_t cfg_getch ( char ch,
void *  param 
)
static

Definition at line 946 of file util.c.

◆ cfg_getstr()

static apr_status_t cfg_getstr ( void *  buf,
apr_size_t  bufsiz,
void *  param 
)
static

Definition at line 951 of file util.c.

◆ cfg_trim_line()

static int cfg_trim_line ( char buf)
static

Definition at line 1174 of file util.c.

◆ find_last_token()

static const char * find_last_token ( apr_pool_t p,
const char line,
const char tok 
)
static

Definition at line 1758 of file util.c.

◆ find_list_item()

static int find_list_item ( apr_pool_t p,
const char line,
const char tok,
ap_etag_e  type 
)
static

Definition at line 1409 of file util.c.

◆ fname_alphasort()

static int fname_alphasort ( const void *  fn1,
const void *  fn2 
)
static

Definition at line 3581 of file util.c.

◆ regex_cleanup()

static apr_status_t regex_cleanup ( void *  preg)
static

Definition at line 256 of file util.c.

◆ regsub_core()

static apr_status_t regsub_core ( apr_pool_t p,
char **  result,
struct ap_varbuf vb,
const char input,
const char source,
apr_size_t  nmatch,
ap_regmatch_t  pmatch[],
apr_size_t  maxlen 
)
static

Definition at line 365 of file util.c.

◆ substring_conf()

static char * substring_conf ( apr_pool_t p,
const char start,
int  len,
char  quote 
)
static

Definition at line 805 of file util.c.

◆ unescape_url()

static int unescape_url ( char url,
const char forbid,
const char reserved,
unsigned int  flags 
)
static

< Module has handled this stage.

< Module has handled this stage.

Definition at line 1877 of file util.c.

◆ varbuf_cleanup()

static apr_status_t varbuf_cleanup ( void *  info_)
static

Definition at line 2948 of file util.c.

◆ x2c()

static char x2c ( const char what)
static

Definition at line 1845 of file util.c.

Variable Documentation

◆ c2x_table

const char c2x_table[] = "0123456789abcdef"
static

Definition at line 2020 of file util.c.

◆ nul

const char nul = '\0'
static

Definition at line 2956 of file util.c.

◆ oom_message

const char* const oom_message
static
Initial value:
= "[crit] Memory allocation failed, "
"aborting process." APR_EOL_STR

Definition at line 3133 of file util.c.

◆ ucharmap

const short ucharmap[]
static

Definition at line 3459 of file util.c.

◆ varbuf_empty

char* const varbuf_empty = (char *)&nul
static

Definition at line 2957 of file util.c.