Accept cookies for analytics, social media, and advertising, or learn more and adjust your preferences. These cookies are on by default for visitors outside the UK and EEA. Privacy Notice.
ngx_regex_compile_t
¶A structure to set up the parameters for a regular expression
pool
¶A memory pool to use for the regular expression
ngx_string
(const unsigned char str[])¶Returns a ngx_str_t
from a given NULL
terminated character array.
Note
this does not make a copy of the character array supplied. It also uses sizeof()
to calculate length so will not work will dynamically allocated memory.
Parameters: |
|
---|---|
Returns: | A |
ngx_str_set
(ngx_str_t *str, const unsigned char text[])¶Sets a ngx_str_t
to a given character array
Note
this does not make a copy of the character array. It also uses sizeof()
to calculate length so will not work will dynamically allocated pointers.
Parameters: |
|
---|
ngx_tolower
(unsigned char c)¶Sets an ASCII ‘A’ to ‘Z’ to lowercase. For other characters it returns the same character.
Parameters: |
|
---|---|
Returns: | A lowercase ‘a’ to ‘z’ or the input character |
ngx_toupper
(unsigned char c)¶Sets an ASCII ‘a’ to ‘z’ to uppercase. For other characters it returns the same character.
Parameters: |
|
---|---|
Returns: | An uppercase ‘A’ to ‘Z’ or the input character |
ngx_strlow
(unsigned char *dst, unsigned char *src, size_t n)¶Runs ngx_tolower()
on an entire string who’s length is given. The destination should be pre-allocated to at least the same length as the source.
Parameters: |
|
---|
ngx_strncmp
(const char *s1, const char *s2, size_t n)¶An alias to the standard strncmp
function
Parameters: |
|
---|---|
Returns: | 0 if the strings are equal, <0 if the first non-matching character in s1 is lower, >0 if the first non-matching character in s2 is higher |
ngx_strcmp
(const char *s1, const char *s2)¶An alias to the standard strcmp
function
Parameters: |
|
---|---|
Returns: | 0 if the strings are equal, <0 if the first non-matching character in s1 is lower, >0 if the first non-matching character in s2 is higher |
ngx_strlen
(const char *s)¶An alias to the standard strlen
function
Parameters: |
|
---|---|
Returns: | The length of the string |
ngx_strstr
(const char *s1, const char *s2)¶An alias to the standard strstr
function
Parameters: |
|
---|---|
Returns: | A pointer to the first match or |
ngx_strchr
(const char *s1, int c)¶An alias to the standard strchr
function
Parameters: |
|
---|---|
Returns: | A pointer to first match or |
ngx_strlchr
(unsigned char *p, unsigned char *last, unsigned char c)¶Searches a string based on the pointer to the beginning and end of the string for a given character. Returns a pointer to the first match of that character.
Parameters: |
|
---|---|
Returns: | A pointer to the first match or |
ngx_memzero
(void *buf, size_t n)¶Sets every byte of a given section of memory to zero
Parameters: |
|
---|
ngx_memset
(void *buf, int c, size_t n)¶An alias for the standard memset
function
Parameters: |
|
---|
ngx_memcpy
(void *dst, const void *src, size_t n)¶An alias for the standard memcpy
function but does not return the pointer to the destination
Parameters: |
|
---|
ngx_copy
(void *dst, const void *src, size_t n)¶A wrapper for the standard memcpy
function which returns the pointer of the destination after the copy (dst
+ n
)
Parameters: |
|
---|---|
Returns: | The pointer of |
ngx_memmove
(void *dst, const void *src, size_t n)¶An alias for the standard memmove
function but does not return the pointer to the destination
Parameters: |
|
---|
ngx_movemem
(void *dst, const void *src, size_t n)¶A wrapper for the standard memmove
function which returns the pointer of the destination after the copy (dst
+ n
)
Parameters: |
|
---|---|
Returns: | The pointer of |
ngx_memcmp
(const void *s1, const void *s2, size_t n)¶An alias for the standard memcmp function.
Parameters: |
|
---|---|
Returns: | 0 if the strings are equal, <0 if the first non-matching character in s1 is lower, >0 if the first non-matching character in s2 is higher |
ngx_cpystrn
(unsigned char *dst, unsigned char *src, size_t n)¶Copies information from one memory location to another. Stops when n
bytes are copied or a NULL
terminator is hit. Returns the pointer pointer of dst
at the point where the copy has finished.
Parameters: |
|
---|---|
Returns: | The pointer of |
ngx_pstrdup
(ngx_pool_t *pool, ngx_str_t *src)¶Creates a copy of a string into a newly allocated string in a memory pool created with ngx_create_pool()
Parameters: |
|
---|---|
Returns: | A pointer to the copy of the string |
ngx_sprintf
(unsigned char *buf, const char *fmt, ...)¶An sprintf
style wrapper around ngx_vslprintf()
Parameters: |
|
---|---|
Returns: | A pointer to the destination |
ngx_snprintf
(unsigned char *buf, size_t max, const char *fmt, ...)¶An snprintf
style wrapper around ngx_vslprintf()
Parameters: |
|
---|---|
Returns: | A pointer to the destination |
ngx_slprintf
(unsigned char *buf, unsigned char *last, const char *fmt, ...)¶A wrapper around ngx_vslprintf()
similar to snprintf
but instead of a maximum length specifier it takes a pointer to the end of the destination memory buffer.
Parameters: |
|
---|---|
Returns: | A pointer to the destination |
ngx_vslprintf
(unsigned char *buf, unsigned char *last, const char *fmt, va_list args)¶A function similar to the standard vsnprintf
but has additional possible format specifiers. It also takes a pointer to the end of the destination memory buffer instead of a length specifier.
Specifier | Description |
---|---|
%P |
The contents of a ngx_pid_t |
%M |
The contents of a ngx_msec_t |
%V |
The data of a ngx_str_t |
%v |
The data of a ngx_http_variable_value_t |
Parameters: |
|
---|
ngx_vsnprintf
(unsigned char *buf, size_t max, const char *fmt, va_list args)¶A function similar to the standard vsnprintf
which is implemented as a wrapper around ngx_vslprintf()
Parameters: |
|
---|
ngx_strcasecmp
(unsigned char *s1, unsigned char *s2)¶An optimised function similar to the standard strcasecmp
Parameters: |
|
---|---|
Returns: | 0 if the strings are equal, <0 if the first non-matching character in s1 is lower, >0 if the first non-matching character in s2 is higher |
ngx_strncasecmp
(unsigned char *s1, unsigned char *s2, size_t n)¶An optimised function similar to the standard strncasecmp
Parameters: |
|
---|---|
Returns: | 0 if the strings are equal, <0 if the first non-matching character in s1 is lower, >0 if the first non-matching character in s2 is higher |
ngx_strnstr
(unsigned char *s1, char *s2, size_t n)¶A function similar to the standard strstr
but with a maximum search length.
Parameters: |
|
---|---|
Returns: | A pointer to the first match or |
ngx_strstrn
(unsigned char *s1, char *s2, size_t n)¶A function similar to the standard strstr
but with a length specifier for the s2
parameter.
Parameters: |
|
---|---|
Returns: | A pointer to the first match or |
ngx_strcasestrn
(unsigned char *s1, char *s2, size_t n)¶A function similar to the standard strcasestr
but with a length specifier for the s2
parameter.
Parameters: |
|
---|---|
Returns: | A pointer to the first match or |
ngx_strlcasestrn
(unsigned char *s1, unsigned char *last, unsigned char *s2, size_t n)¶A function similar to the standard strcasestr
but with a pointer to the last character in the search string and a length specifier for the s2
parameter.
Parameters: |
|
---|---|
Returns: | A pointer to the first match or |
ngx_rstrncmp
(unsigned char *s1, unsigned char *s2, size_t n)¶A function similar to the standard strncmp
but starts at the end of the string.
Parameters: |
|
---|---|
Returns: | 0 if the strings are equal, <0 if the first non-matching character in s1 is lower, >0 if the first non-matching character in s2 is higher |
ngx_rstrncasecmp
(unsigned char *s1, unsigned char *s2, size_t n)¶A function similar to the standard strncasecmp
but starts at the end of the string.
Parameters: |
|
---|---|
Returns: | 0 if the strings are equal, <0 if the first non-matching character in s1 is lower, >0 if the first non-matching character in s2 is higher |
ngx_memn2cmp
(unsigned char *s1, unsigned char *s2, size_t n1, size_t n2)¶Compares two length specified segments of memory.
Parameters: |
|
---|---|
Returns: | 0 if the strings are equal, <0 if the first non-matching character in s1 is lower, >0 if the first non-matching character in s2 is higher |
ngx_dns_strcmp
(unsigned char *s1, unsigned char *s2)¶A function similar to ngx_strcmp()
but compares two DNS entries.
Parameters: |
|
---|---|
Returns: | 0 if the strings are equal, <0 if the first non-matching character in s1 is lower, >0 if the first non-matching character in s2 is higher |
ngx_filename_cmp
(unsigned char *s1, unsigned char *s2, size_t n)¶A function similar to ngx_strncmp()
but compares two paths
Parameters: |
|
---|---|
Returns: | 0 if the strings are equal, <0 if the first non-matching character in s1 is lower, >0 if the first non-matching character in s2 is higher |
ngx_atofp
(unsigned char *line, size_t n, size_t point)¶Converts a floating point number in a string to an integer representation. For example: ngx_atofp("10.2", 4, 2)
returns 1020
Parameters: |
|
---|---|
Returns: | An integer representing the input |
ngx_atosz
(unsigned char *line, size_t n)¶Converts a number in a text string to a ssize_t
Parameters: |
|
---|---|
Returns: | A |
ngx_atoof
(unsigned char *line, size_t n)¶Converts a number in a text string to an off_t
Parameters: |
|
---|---|
Returns: | A |
ngx_atotm
(unsigned char *line, size_t n)¶Converts a number in a text string to a time_t
Parameters: |
|
---|---|
Returns: | A |
ngx_hex_dump
(unsigned char *dst, unsigned char *src, size_t len)¶Converts binary data to a printable hexadecimal representation of the string
Note
dst
should be allocated to 2*len
. dst
will not be NULL
terminated by this function.
Parameters: |
|
---|---|
Returns: | A pointer to |
ngx_base64_encoded_length
(int len)¶A macro to calculate the base64 encoded length of a string. Evaluates to (((len + 2) / 3) * 4)
. Any int type can be used.
Parameters: |
|
---|---|
Returns: | The output length |
ngx_base64_decoded_length
(int len)¶A macro to calculate the base64 decoded length of a string. Evaluates to (((len + 3) / 4) * 3)
. Any int type can be used.
Parameters: |
|
---|---|
Returns: | The output length |
ngx_encode_base64
(ngx_str_t *dst, ngx_str_t *src)¶Base64 encodes a given input text.
Note
ngx_base64_encoded_length()
should be used to calculate how much memory should be allocated for dst
Parameters: |
|
---|
ngx_encode_base64url
(ngx_str_t *dst, ngx_str_t *src)¶Base64 encodes a given input URL
Note
ngx_base64_encoded_length()
should be used to calculate how much memory should be allocated for dst
Parameters: |
|
---|
ngx_decode_base64
(ngx_str_t *dst, ngx_str_t *src)¶Base64 decodes a given input
Note
ngx_base64_decoded_length()
should be used to calculate how much memory should be allocated for dst
Parameters: |
|
---|---|
Returns: |
|
ngx_decode_base64url
(ngx_str_t *dst, ngx_str_t *src)¶Base64 decodes a given input URL
Note
ngx_base64_decoded_length()
should be used to calculate how much memory should be allocated for dst
Parameters: |
|
---|---|
Returns: |
|
ngx_utf8_decode
(unsigned char **p, size_t n)¶Validates a UTF8 character. The character pointer pointed to with p
is moved to the end of the character. The following table shows the return values:
Value | Meaning |
---|---|
0x80 - 0x10ffff | valid character |
0x110000 - 0xfffffffd | invalid sequence |
0xfffffffe | incomplete sequence |
0xffffffff | error |
Parameters: |
|
---|---|
Returns: | The status in the table above |
ngx_utf8_length
(unsigned char *p, size_t n)¶Returns the number of UTF8 characters in a given string.
Parameters: |
|
---|---|
Returns: | The number of UTF8 characters in the string or an error from |
ngx_utf8_cpystrn
(unsigned char *dst, unsigned char *src, size_t n, size_t len)¶Copies a valid UTF8 sequence from one string to another, ignoring invalid characters
Parameters: |
|
---|---|
Returns: | The position of |
ngx_escape_uri
(unsigned char *dst, unsigned char *src, size_t size, ngx_uint_t type)¶Escapes a URI. Different types use slightly different escape algorithms. A dst
of NULL
will return the number of characters that would be escaped. Otherwise a pointer to the end of data in dst
is returned.
Type | Definition |
---|---|
NGX_ESCAPE_URI |
Escape a standard URI |
NGX_ESCAPE_ARGS |
Escape query arguments |
NGX_ESCAPE_URI_COMPONENT |
Escape the URI after the domain |
NGX_ESCAPE_HTML |
Escape a URI for an SSI include |
NGX_ESCAPE_REFRESH |
Escape a URI in a refresh header |
NGX_ESCAPE_MEMCACHED |
Escape a memcached URI |
NGX_ESCAPE_MAIL_AUTH |
Escape a mail authentication URI |
Parameters: |
|
---|---|
Returns: | A pointer to the end of the used |
ngx_unescape_uri
(unsigned char **dst, unsigned char **src, size_t size, ngx_uint_t type)¶Unescapes a URI. Different types use slightly different unescape algorithms.
Type | Definition |
---|---|
NGX_UNESCAPE_URI |
Unescape a standard URI |
NGX_UNESCAPE_REDIRECT |
Unescape a redirect URI |
Parameters: |
|
---|
ngx_escape_html
(unsigned char *dst, unsigned char *src, size_t size)¶Escapes HTML entities <
, >
, &
and "
. A dst
of NULL
will return the number of characters that would fill dst
. Otherwise a pointer to the end of data in dst
is returned.
Parameters: |
|
---|---|
Returns: | A pointer to the end of the used |
ngx_escape_json
(unsigned char *dst, unsigned char *src, size_t size)¶Escapes the JSON entites \
, "
, 0x1f. Additional escape sequences \n
, \r
, \t
, \b
and \f
are also escaped. A dst
of NULL
will return the number of characters that would fill dst
. Otherwise a pointer to the end of data in dst
is returned.
Parameters: |
|
---|---|
Returns: | A pointer to the end of the used |
ngx_sort
(void *base, size_t n, size_t size, ngx_int_t (*cmp)(const void *, const void *))¶An insertion sort algorithm with a template similar to the standard C qsort
function. Sorts fixed-length data based on the results of a comparitor callback cmp
. cmp
should return -1
to left, 1
to shift right and 0 to not shift.
Parameters: |
|
---|
ngx_qsort
(void* base, size_t num, size_t size, int (*compar)(const void*,const void*))¶An alias to the standard qsort
function
Parameters: |
|
---|
ngx_hash
(ngx_uint_t key, unsigned char c)¶A macro that generates a hash of a single character. Defined as:
((ngx_uint_t) key * 31 + c)
It is designed to be run over an entire string to generate a full hash
Parameters: |
|
---|---|
Returns: | An updated key |
ngx_hash_strlow
(unsigned char *dst, unsigned char *src, size_t n)¶Sets a given string to lowercase using ngx_tolower()
on every character, stores it in dst
and generates a hash from that string using ngx_hash()
Parameters: |
|
---|---|
Returns: | A hash key based on the |
ngx_regex_compile
(ngx_regex_compile_t *rc)¶Compile a regular expression based on a pre-definied ngx_regex_compile_t
structure.
Parameters: |
|
---|---|
Returns: |
|
ngx_regex_exec
(ngx_regex_compile_t *re, ngx_str_t *s, int *captures, int size)¶A macro wrapper around pcre_exec
to execute the regular expression
Parameters: |
|
---|---|
Result: |
|
ngx_regex_exec_array
(ngx_array_t *a, ngx_str_t *s, ngx_log_t *log)¶Execute an array of regular expressions against a string. This only returns whether or not there is a match, no details of the match
Parameters: |
|
---|---|
Returns: |
|