ユーティリティ API

構造

ngx_str_t

ngx_str_t
文字の配列と文字の配列の長さへのポインタを含む構造
size_t len

文字の配列の長さ

unsigned char *data

文字の配列へのポインタ

ngx_regex_compile_t

ngx_regex_compile_t

正規表現のためのパラメータをセットアップする構造

ngx_str_t pattern

コンパイルするためのPCRE形式の正規表現

ngx_pool_t *pool

正規表現のために使われるメモリプール

ngx_int_t options

正規表現のためのオプション今のところ、唯一の有効なオプションはNGX_REGEX_CASELESSで、大文字小文字を区別しない検索をします。

ngx_str_t err

正規表現エンジンからのエラーを格納するためのメモリの事前割り当てされたセクション

機能

ngx_string

ngx_str_t ngx_string(const unsigned char str[])

指定されたNULLで終了する文字配列から、ngx_str_tを返します。

注意

これは渡された文字の配列のコピーを作成しません。また、長さを計算するためにsizeof()を使うため、動的に割り当てられたメモリで動作しないでしょう。

パラメータ:
  • str – 変換するNULLで区切られた文字配列
返り値:

文字の文字列を囲むngx_str_t

ngx_null_string

ngx_str_t ngx_null_string(void)

NULLで終了する空のngx_str_t を返します。

返り値:NULLで終了する空のngx_str_t

ngx_str_set

void ngx_str_set(ngx_str_t *str, const unsigned char text[])

指定された文字配列へngx_str_t を設定します

注意

これは文字の配列のコピーを作成しません。また、長さを計算するためにsizeof()を使うため、動的に割り当てられたポインタで動作しないでしょう。

パラメータ:
  • str – 目的のngx_str_t
  • text – 元の文字配列

ngx_str_null

void ngx_str_null(ngx_str_t *str)

指定されたngx_str_t を空のNULLで終了する文字列に設定します。

パラメータ:
  • str – 設定するngx_str_tオブジェクト。

ngx_tolower

unsigned char ngx_tolower(unsigned char c)

ASCII の‘A’ から ‘Z’ を小文字に設定します。他の文字については同じ文字を返します。

パラメータ:
  • c – 入力文字
返り値:

小文字の ‘a’ から ‘z’、あるいは入力文字

ngx_toupper

unsigned char ngx_toupper(unsigned char c)

ASCII の‘A’ から ‘Z’ を大文字に設定します。他の文字については同じ文字を返します。

パラメータ:
  • c – 入力文字
返り値:

大文字の ‘a’ から ‘z’、あるいは入力文字

ngx_strlow

void ngx_strlow(unsigned char *dst, unsigned char *src, size_t n)

指定された長さの全体の文字列上でngx_tolower() を実行します。destination は少なくとも元の長さと同じにあらかじめ割り当てられてなければなりません。

パラメータ:
  • dst – 目的の文字列
  • src – 元の文字列
  • n – 元の文字列の長さ

ngx_strncmp

int ngx_strncmp(const char *s1, const char *s2, size_t n)

標準strncmp 関数へのエイリアス

パラメータ:
  • s1 – 比較するための最初の文字列
  • s2 – 比較するための2つ目の文字列
  • n – 比較するための最大の長さ
返り値:

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

int ngx_strcmp(const char *s1, const char *s2)

標準strcmp 関数のエイリアス

パラメータ:
  • s1 – 比較するための最初の文字列
  • s2 – 比較するための2つ目の文字列
返り値:

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

size_t strlen(const char *s)

標準strlen 関数のエイリアス

パラメータ:
  • sNULL で終了する文字列
返り値:

文字列の長さ

ngx_strstr

char *ngx_strstr(const char *s1, const char *s2)

標準 strstr関数のエイリアス

パラメータ:
  • s1 – 検索先の文字列
  • s2 – 検索する文字の順列
返り値:

最初の一致へのポインタ、あるいは一致しない場合はNULL

ngx_strchr

char *strchr(const char *s1, int c)

標準strchr 関数のエイリアス

パラメータ:
  • s1 – 検索先の文字列
  • c – 文字列内で調べる文字
返り値:

最初の一致へのポインタ、あるいは一致しない場合はNULL

ngx_strlchr

unsigned char *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. 文字の最初の一致へのポインタを返します。

パラメータ:
  • p – 文字列の開始へのポインタ
  • last – 文字列の最後へのポインタ
  • c – 文字列内で調べる文字
返り値:

最初の一致へのポインタ、あるいは一致しない場合はNULL

ngx_memzero

void memzero(void *buf, size_t n)

メモリの指定されたセクションの各バイトをゼロに設定する

パラメータ:
  • buf – メモリへのポインタ
  • n – ゼロに設定するメモリの長さ

ngx_memset

void memset(void *buf, int c, size_t n)

標準memset 関数のエイリアス

パラメータ:
  • buf – メモリへのポインタ
  • c – メモリを埋める文字
  • n – メモリの長さ

ngx_memcpy

void ngx_memcpy(void *dst, const void *src, size_t n)

標準memcpy 関数のエイリアスですが、結果へのポインタを返しません

パラメータ:
  • dst – 結果のメモリポインタ
  • src – 元のメモリポインタ
  • n – コピーするバイト量

ngx_copy

void *ngx_copy(void *dst, const void *src, size_t n)

コピーの後の結果のポインタを返す標準memcpy 関数のラッパー (dst + n)

パラメータ:
  • dst – 結果のメモリポインタ
  • src – 元のメモリポインタ
  • n – コピーするバイト量
返り値:

dst + nのポインタ

ngx_memmove

void *ngx_memmove(void *dst, const void *src, size_t n)

標準memmove 関数のエイリアスですが、結果へのポインタを返しません

パラメータ:
  • dst – 結果のメモリポインタ
  • src – 元のメモリポインタ
  • n – 移動するバイトの数

ngx_movemem

void *ngx_movemem(void *dst, const void *src, size_t n)

コピーの後の結果のポインタを返す標準memmove 関数のラッパー (dst + n)

パラメータ:
  • dst – 結果のメモリポインタ
  • src – 元のメモリポインタ
  • n – 移動するバイトの数
返り値:

dst + nのポインタ

ngx_memcmp

int ngx_memcmp(const void *s1, const void *s2, size_t n)

標準memcmp関数のエイリアス

パラメータ:
  • s1 – 比較するための最初の文字列
  • s2 – 比較するための2つ目の文字列
返り値:

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 *ngx_cpystrn(unsigned char *dst, unsigned char *src, size_t n)

あるメモリの場所から他の場所へ情報をコピーする。nバイトがコピーされるかNULL 終端にぶつかると停止します。コピーが完了した場所のdstのポインタを返す。

パラメータ:
  • dst – 結果のメモリポインタ
  • src – 元のメモリポインタ
  • n – コピーするバイト数
返り値:

dst のポインタにコピーされたバイト数を足したもの

ngx_pstrdup

unsigned char *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()

パラメータ:
  • pool – 使用するメモリプール
  • src – 元の文字列
返り値:

文字列のコピーへのポインタ

ngx_sprintf

unsigned char *ngx_sprintf(unsigned char *buf, const char *fmt, ...)

An sprintf style wrapper around ngx_vslprintf()

パラメータ:
  • buf – 出力のポインタ
  • fmt – 使用するテキストとフォーマットの説明
返り値:

出力へのポインタ

ngx_snprintf

unsigned char *ngx_snprintf(unsigned char *buf, size_t max, const char *fmt, ...)

An snprintf style wrapper around ngx_vslprintf()

パラメータ:
  • buf – 出力のポインタ
  • max – 出力の最大サイズ
  • fmt – 使用するテキストとフォーマットの説明
返り値:

出力へのポインタ

ngx_slprintf

unsigned char *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.

パラメータ:
  • buf – 出力のポインタ
  • last – 出力バッファの最後へのポインタ
  • fmt – 使用するテキストとフォーマットの説明
返り値:

出力へのポインタ

ngx_vslprintf

unsigned char *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. また、長さの識別子の代わりに出力メモリバッファの最後へのポインタを取ります。

識別子 解説
%P ngx_pid_tの内容
%M ngx_msec_tの内容
%V ngx_str_tのデータ
%v ngx_http_variable_value_tのデータ
パラメータ:
  • buf – 出力のポインタ
  • max – 出力の最大サイズ
  • fmt – 使用するテキストとフォーマットの説明
  • args – 変数の引数リスト

ngx_vsnprintf

unsigned char *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()

パラメータ:
  • buf – 出力のポインタ
  • last – 出力バッファの最後へのポインタ
  • fmt – 使用するテキストとフォーマットの説明
  • args – 変数の引数リスト

ngx_strcasecmp

ngx_int_t ngx_strcasecmp(unsigned char *s1, unsigned char *s2)

An optimised function similar to the standard strcasecmp

パラメータ:
  • s1 – 比較するための最初の文字列
  • s2 – 比較するための2つ目の文字列
返り値:

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

ngx_int_t ngx_strncasecmp(unsigned char *s1, unsigned char *s2, size_t n)

An optimised function similar to the standard strncasecmp

パラメータ:
  • s1 – 比較するための最初の文字列
  • s2 – 比較するための2つ目の文字列
  • n – 比較する文字の最大数
返り値:

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 *ngx_strnstr(unsigned char *s1, char *s2, size_t n)

標準strstr に似ていますが、最大の検索長を持ちます。

パラメータ:
  • s1 – 検索先の文字列
  • s2 – 検索する文字の順列
  • ns1で検索する文字の最大長
返り値:

最初の一致へのポインタ、あるいは一致しない場合はNULL

ngx_strstrn

unsigned char *ngx_strstrn(unsigned char *s1, char *s2, size_t n)

標準strstr に似ていますが、s2パラメータのための長さの指定子を持ちます。

パラメータ:
  • s1 – 検索先の文字列
  • s2 – 検索する文字の順列
  • ns2 パラメータの長さ
返り値:

最初の一致へのポインタ、あるいは一致しない場合はNULL

ngx_strcasestrn

unsigned char *ngx_strcasestrn(unsigned char *s1, char *s2, size_t n)

標準strcasestr に似ていますが、s2パラメータのための長さの指定子を持ちます。

パラメータ:
  • s1 – 検索先の文字列
  • s2 – 検索する文字の順列
  • ns2 パラメータの長さ
返り値:

最初の一致へのポインタ、あるいは一致しない場合はNULL

ngx_strlcasestrn

unsigned char *ngx_strlcasestrn(unsigned char *s1, unsigned char *last, unsigned char *s2, size_t n)

標準strcasestrに似ていますが、検索文字列内の最後の文字へのポインタと s2 パラメータのための長さの指定子を持ちます。

パラメータ:
  • s1 – 検索先の文字列
  • lasts1 文字列の中の最後の文字へのポインタ
  • s2 – 検索する文字の順列
  • ns2 パラメータの長さ
返り値:

最初の一致へのポインタ、あるいは一致しない場合はNULL

ngx_rstrncmp

ngx_int_t ngx_rstrncmp(unsigned char *s1, unsigned char *s2, size_t n)

標準strncmp に似ていますが、文字列の最後から開始します。

パラメータ:
  • s1 – 比較するための最初の文字列
  • s2 – 比較するための2つ目の文字列
  • n – 比較するための最大の長さ
返り値:

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

ngx_int_t ngx_rstrncasecmp(unsigned char *s1, unsigned char *s2, size_t n)

標準strncasecmp に似ていますが、文字列の最後から開始します。

パラメータ:
  • s1 – 比較するための最初の文字列
  • s2 – 比較するための2つ目の文字列
  • n – 比較するための最大の長さ
返り値:

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

ngx_int_t ngx_memn2cmp(unsigned char *s1, unsigned char *s2, size_t n1, size_t n2)

二つの指定されたメモリのセグメントの長さを比較します。

パラメータ:
  • s1 – 比較する最初のメモリの場所
  • s2 – 比較する二つ目のメモリの場所
  • n1 – 最初のメモリの場所の長さ
  • n2 – 二つ目のメモリの場所の長さ
返り値:

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_str_cmp

ngx_int_t ngx_dns_strcmp(unsigned char *s1, unsigned char *s2)

ngx_strcmp()に似ていますが、二つのDNSエントリを比較します。

パラメータ:
  • s1 – 比較するための最初の文字列
  • s2 – 比較するための2つ目の文字列
返り値:

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

ngx_int_t ngx_filename_cmp(unsigned char *s1, unsigned char *s2, size_t n)

ngx_strncmp() に似た関数ですが、二つのパスを比較します

パラメータ:
  • s1 – 比較する最初のパス
  • s2 – 比較する二つ目のパス
  • n – 比較するバイト数
返り値:

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_atoi

ngx_int_t ngx_atoi(unsigned char *line, size_t n)

atoi に似た関数ですが、文字列の長さの指定子を持ちます

パラメータ:
  • line – 変換するテキスト
  • nlineの長さ
返り値:

入力の整数値表現

ngx_atofp

ngx_int_t ngx_atofp(unsigned char *line, size_t n, size_t point)

文字列内の浮動小数を整数表現に変換します。例えば: ngx_atofp("10.2", 4, 2)1020を返します

パラメータ:
  • line – 変換するテキスト
  • nlineの長さ
  • point – The number of decimal places to convert
返り値:

入力を表す整数値

ngx_atosz

ssize_t ngx_atosz(unsigned char *line, size_t n)

テキスト文字列内の数を ssize_tに変換します

パラメータ:
  • line – 変換するテキスト
  • nlineの長さ
返り値:

入力のssize_t 表現

ngx_atoof

off_t ngx_atoof(unsigned char *line, size_t n)

テキスト文字列内の数を off_tに変換します

パラメータ:
  • line – 変換するテキスト
  • nlineの長さ
返り値:

入力のoff_t 表現

ngx_atotm

time_t ngx_atotm(unsigned char *line, size_t n)

テキスト文字列内の数を time_tに変換します

パラメータ:
  • line – 変換するテキスト
  • nlineの長さ
返り値:

入力のtime_t 表現

ngx_hextoi

ngx_int_t ngx_hextoi(unsigned char *line, size_t n)

テキスト文字列内の16進数を整数値に変換します

パラメータ:
  • line – 変換するテキスト
  • nlineの長さ
返り値:

16進数入力の整数値表現

ngx_hex_dump

unsigned char *ngx_hex_dump(unsigned char *dst, unsigned char *src, size_t len)

バイナリデータを印刷可能な文字列の16進数表現に変換します

注意

dst2*lenに割り当てられなければなりません。dst はこの関数によって NULL で終了しないでしょう。

パラメータ:
  • dst – 目的の文字列
  • src – 元のバイナリデータ
  • lensrcの長さ
返り値:

dst + (2*len)へのポインタ

ngx_base64_encoded_length

int ngx_base64_encoded_length(int len)

文字列のbase64エンコード長を計算するためのマクロEvaluates to (((len + 2) / 3) * 4). どのようなint型も使うことができます。

パラメータ:
  • len – 入力長
返り値:

出力の長さ

ngx_base64_decoded_length

int ngx_base64_decoded_length(int len)

文字列のbase64デコード長を計算するためのマクロEvaluates to (((len + 3) / 4) * 3). どのようなint型も使うことができます。

パラメータ:
  • len – 入力長
返り値:

出力の長さ

ngx_encode_base64

void ngx_encode_base64(ngx_str_t *dst, ngx_str_t *src)

指定された入力テキストのBase64エンコード。

注意

ngx_base64_encoded_length()dstのためにどれだけのメモリが割り当てられなければならないかを計算するために使われなければなりません。

パラメータ:
  • dst – 出力のバッファ
  • src – 元のデータ

ngx_encode_base64url

void ngx_encode_base64url(ngx_str_t *dst, ngx_str_t *src)

指定された入力URLのBase64エンコード。

注意

ngx_base64_encoded_length()dstのためにどれだけのメモリが割り当てられなければならないかを計算するために使われなければなりません。

パラメータ:
  • dst – 出力のバッファ
  • src – 元のデータ

ngx_decode_base64

ngx_int_t ngx_decode_base64(ngx_str_t *dst, ngx_str_t *src)

指定された入力のBase64デコード

注意

ngx_base64_decoded_length()dstのためにどれだけのメモリが割り当てられなければならないかを計算するために使われなければなりません。

パラメータ:
  • dst – 出力のバッファ
  • src – 元のデータ
返り値:

成功時にはNGX_OK、失敗時にはNGX_ERROR

ngx_decode_base64url

ngx_int_t ngx_decode_base64url(ngx_str_t *dst, ngx_str_t *src)

指定された入力URLのBase64デコード

注意

ngx_base64_decoded_length()dstのためにどれだけのメモリが割り当てられなければならないかを計算するために使われなければなりません。

パラメータ:
  • dst – 出力のバッファ
  • src – 元のデータ
返り値:

成功時にはNGX_OK、失敗時にはNGX_ERROR

ngx_utf8_decode

uint32_t ngx_utf8_decode(unsigned char **p, size_t n)

UTF8文字を検証します。The character pointer pointed to with p is moved to the end of the character. 以下の表は返り値を示します:

意味
0x80 - 0x10ffff 有効な文字
0x110000 - 0xfffffffd 無効な文字
0xfffffffe 不完全な並び
0xffffffff エラー
パラメータ:
  • p – UTF8シーケンスのためのポインタへのポインタ
  • n – シーケンスの長さ
返り値:

上の表での状態

ngx_utf8_length

size_t ngx_utf8_length(unsigned char *p, size_t n)

指定された文字列内のUTF8文字の数を返します。

パラメータ:
  • p – 数え上げる文字列
  • n – 文字列の長さ
返り値:

文字列内のUTF8文字の数、あるいはngx_utf8_decode()からのエラー

ngx_utf8_cpystrn

unsigned char *ngx_utf8_cpystrn(unsigned char *dst, unsigned char *src, size_t n, size_t len)

ある文字列から別の文字列へ無効な文字を無視しながら、有効なUTF8シーケンスをコピーする

パラメータ:
  • dst – 目的の文字列
  • src – 元の文字列
  • ndstの最大長
  • lensrcの長さ
返り値:

dst の場所 プラス コピーされた文字

ngx_escape_uri

uintptr_t ngx_escape_uri(unsigned char *dst, unsigned char *src, size_t size, ngx_uint_t type)

URLをエスケープする異なるタイプはわずかに異なるエスケープアルゴリズムを使います。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.

種類 定義
NGX_ESCAPE_URI 標準URIをエスケープ
NGX_ESCAPE_ARGS クエリ引数をエスケープ
NGX_ESCAPE_URI_COMPONENT ドメインの後のURIをエスケープ
NGX_ESCAPE_HTML SSI includeのためのURIをエスケープ
NGX_ESCAPE_REFRESH refreshヘッダ内のURIをエスケープ
NGX_ESCAPE_MEMCACHED memcached のURIをエスケープ
NGX_ESCAPE_MAIL_AUTH メール認証URIをエスケープ
パラメータ:
  • dst – A destination memory location, or NULL for a length count
  • src – 元の文字列
  • size – 元の文字列の長さ
  • type – 使用するエスケープアルゴリズムの種類
返り値:

A pointer to the end of the used dst or the output count if dst is NULL

ngx_unescape_uri

void ngx_unescape_uri(unsigned char **dst, unsigned char **src, size_t size, ngx_uint_t type)

URIをアンエスケープする異なるタイプはわずかに異なるアンエスケープアルゴリズムを使います。

種類 定義
NGX_UNESCAPE_URI 標準URIをアンエスケープ
NGX_UNESCAPE_REDIRECT リダイレクトURIをアンエスケープ
パラメータ:
  • dst – 出力メモリの場所
  • src – 元の文字列
  • size – 元の文字列の長さ
  • type – 使用するエスケープアルゴリズムの種類

ngx_escape_html

uintptr_t ngx_escape_html(unsigned char *dst, unsigned char *src, size_t size)

HTMLエンティティをエスケープ <, >, & and ". A dst of NULL will return the number of characters that would fill dst. そうでなければdst内のデータの最後へのポインタが返されます。

パラメータ:
  • dst – A destination memory location, or NULL for a length count
  • src – 元の文字列
  • size – 元の文字列の長さ
返り値:

A pointer to the end of the used dst or the output count if dst is NULL

ngx_escape_json

uintptr_t ngx_escape_json(unsigned char *dst, unsigned char *src, size_t size)

JSONエンティティのエスケープ \, " と 0x1f。A dst of NULL will return the number of characters that would fill dst. そうでなければdst内のデータの最後へのポインタが返されます。

パラメータ:
  • dst – A destination memory location, or NULL for a length count
  • src – 元の文字列
  • size – 元の文字列の長さ
返り値:

A pointer to the end of the used dst or the output count if dst is NULL

ngx_sort

void 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.

パラメータ:
  • base – ソートされるポインタの配列へのポインタ
  • n – ソートされるbase 内の要素の数
  • sizebase内の各要素のサイズ
  • cmp – それぞれの比較で実行されるコールバック

ngx_qsort

void ngx_qsort(void* base, size_t num, size_t size, int (*compar)(const void*,const void*))

標準qsort 関数のエイリアス

パラメータ:
  • base – ソートされるポインタの配列へのポインタ
  • num – ソートされるbase 内の要素の数
  • sizebase内の各要素のサイズ
  • compar – それぞれの比較で実行されるコールバック

ngx_hash

ngx_uint_t ngx_hash(ngx_uint_t key, unsigned char c)

1文字のハッシュを生成するマクロ。以下で定義されます:

((ngx_uint_t) key * 31 + c)

完全なハッシュを生成するために文字列全体の上で実行されるように設計されています

パラメータ:
  • key – 新しい文字のハッシュを使って更新するキー
  • c – ハッシュに追加する文字
返り値:

更新されたキー

ngx_hash_strlow

ngx_uint_t ngx_hash_strlow(unsigned char *dst, unsigned char *src, size_t n)

指定された文字列を、各文字上でngx_tolower()を使って小文字に設定し、それを dstに格納し、 ngx_hash()を使って文字列からハッシュを生成します

パラメータ:
  • dst – 小文字の文字列の出力
  • src – 元の文字列
  • n – 元の文字列の長さ
返り値:

dstに基づいたハッシュキー

ngx_regex_init

ngx_int_t ngx_regex_compile(ngx_regex_compile_t *rc)

事前定義された ngx_regex_compile_t 構造に基づいた正規表現をコンパイルします。

パラメータ:
  • rc – コンパイルする正規表現
返り値:

成功時にはNGX_OK、失敗時にはNGX_ERROR

ngx_regex_exec

int 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

パラメータ:
  • rcngx_regex_compile()を使ってコンパイルされた正規表現
  • s – 正規表現を実行する文字列
  • capturess内で捕えられる文字列を識別するために使われるだろう整数の事前に割り当てられた配列
  • sizecapturesのために割り当てられた要素の数
結果:

成功時には0、一致しない場合にはNGX_REGEX_NOMATCH、エラー時には< -1

ngx_regex_exec_array

ngx_int_t ngx_regex_exec_array(ngx_array_t *a, ngx_str_t *s, ngx_log_t *log)

文字列に対して正規表現の配列を実行する。これは、一致の詳細ではなく、一致したかどうかのみを返します

パラメータ:
  • angx_regex_compile_t 正規表現の配列
  • s – 正規表現を行う文字列
  • log – エラーメッセージを送信する先のログオブジェクト
返り値:

一致を見つけた場合はNGX_OK、一致が無い場合はNGX_DECLINED、エラーが起きた場合は NGX_ERROR

TOP
inserted by FC2 system