![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Data Structures | |
| struct | N_PCRE |
| N_PCRE structure. More... | |
Functions | |
| int | _npcre_print_error (int LOG_LEVEL, const char *file, const char *func, int line, int rc) |
| print error helper | |
| int | npcre_clean_match (N_PCRE *pcre) |
| clean match results from a previous npcre_match_capture | |
| int | npcre_delete (N_PCRE **pcre) |
| pcre helper, delete/free a compiled regexp | |
| int | npcre_match (char *str, N_PCRE *pcre) |
| thread-safe pcre match, only returns TRUE/FALSE, no captures stored | |
| int | npcre_match_capture (char *str, N_PCRE *pcre) |
| thread-safe pcre match with captures stored in pcre->match_list | |
| N_PCRE * | npcre_new (char *str, int flags) |
| pcre helper, compile and optimize regexp | |
| struct N_PCRE |
N_PCRE structure.
Collaboration diagram for N_PCRE:| Data Fields | ||
|---|---|---|
| int | captured | flag for match_list cleaning |
| pcre2_match_data * | match_data | match data storage (ovector, etc.) |
| PCRE2_UCHAR8 ** | match_list | populated match list (NULL-terminated) after npcre_match_capture() Allocated by PCRE2 via pcre2_substring_list_get() and must be freed with pcre2_substring_list_free(). |
| pcre2_code * | regexp | regexp |
| char * | regexp_str | original regexp string |
| pthread_rwlock_t | rwlock | rwlock protecting match_data, match_list, and captured |
| int _npcre_print_error | ( | int | LOG_LEVEL, |
| const char * | file, | ||
| const char * | func, | ||
| int | line, | ||
| int | rc | ||
| ) |
print error helper
print error helper
| LOG_LEVEL | The log level to use when printing errors. Note: non error will always be printed in LOG_DEBUG |
| file | name of the file which called the function |
| func | name of the calling function |
| line | line in the file |
| rc | the code to test |
Definition at line 187 of file n_pcre.c.
References _n_log(), LOG_DEBUG, and LOG_LEVEL.
Referenced by npcre_match_capture().
Here is the call graph for this function:
Here is the caller graph for this function:| int npcre_clean_match | ( | N_PCRE * | pcre | ) |
clean match results from a previous npcre_match_capture
clean match results from a previous npcre_match_capture
| pcre | The N_PCRE regexp holder |
Definition at line 164 of file n_pcre.c.
References __n_assert, N_PCRE::captured, N_PCRE::match_list, PCRE2_LIST_FREE_CAST, N_PCRE::rwlock, unlock, and write_lock.
Referenced by main(), and main().
Here is the caller graph for this function:| int npcre_delete | ( | N_PCRE ** | pcre | ) |
pcre helper, delete/free a compiled regexp
pcre helper, delete/free a compiled regexp
| pcre | The N_PCRE regexp holder |
Definition at line 134 of file n_pcre.c.
References __n_assert, FreeNoLog, PCRE2_LIST_FREE_CAST, rw_lock_destroy, unlock, and write_lock.
Referenced by load_config_file(), main(), main(), and npcre_new().
Here is the caller graph for this function:| int npcre_match | ( | char * | str, |
| N_PCRE * | pcre | ||
| ) |
thread-safe pcre match, only returns TRUE/FALSE, no captures stored
thread-safe pcre match, only returns TRUE/FALSE, no captures stored
Uses a local pcre2_match_data so multiple threads can safely share the same compiled N_PCRE pattern. No captures are stored.
| str | String to test against the regexp |
| pcre | The N_PCRE regexp holder (read-only access to regexp field) |
Definition at line 226 of file n_pcre.c.
References __n_assert, LOG_ERR, n_log, and N_PCRE::regexp.
| int npcre_match_capture | ( | char * | str, |
| N_PCRE * | pcre | ||
| ) |
thread-safe pcre match with captures stored in pcre->match_list
thread-safe pcre match with captures stored in pcre->match_list
Thread-safe: uses a rwlock to serialize access to match_data, match_list, captured. The caller must read pcre->match_list/captured before the next call to npcre_match_capture() or npcre_clean_match() on the same N_PCRE, as those will overwrite/free the previous results.
| str | String to test against the regexp |
| pcre | The N_PCRE regexp holder |
Definition at line 261 of file n_pcre.c.
References __n_assert, _npcre_print_error(), N_PCRE::captured, LOG_DEBUG, LOG_ERR, N_PCRE::match_data, N_PCRE::match_list, n_log, PCRE2_LIST_FREE_CAST, N_PCRE::regexp, N_PCRE::regexp_str, N_PCRE::rwlock, unlock, and write_lock.
Referenced by load_config_file(), main(), and main().
Here is the call graph for this function:
Here is the caller graph for this function:| N_PCRE * npcre_new | ( | char * | str, |
| int | flags | ||
| ) |
pcre helper, compile and optimize regexp
pcre helper, compile and optimize regexp
matches anything including NL PCRE_DUPNAMES Allow duplicate names for subpatterns PCRE_EXTENDED Ignore white space and # comments PCRE_EXTRA PCRE extra features (not much use currently) PCRE_FIRSTLINE Force matching to be before newline PCRE_JAVASCRIPT_COMPAT JavaScript compatibility PCRE_MULTILINE ^ and $ match newlines within data PCRE_NEWLINE_ANY Recognize any Unicode newline sequence PCRE_NEWLINE_ANYCRLF Recognize CR, LF, and CRLF as newline sequences PCRE_NEWLINE_CR Set CR as the newline sequence PCRE_NEWLINE_CRLF Set CRLF as the newline sequence PCRE_NEWLINE_LF Set LF as the newline sequence PCRE_NO_AUTO_CAPTURE Disable numbered capturing paren- theses (named ones available) PCRE_NO_UTF16_CHECK Do not check the pattern for UTF-16 validity (only relevant if PCRE_UTF16 is set) PCRE_NO_UTF32_CHECK Do not check the pattern for UTF-32 validity (only relevant if PCRE_UTF32 is set) PCRE_NO_UTF8_CHECK Do not check the pattern for UTF-8 validity (only relevant if PCRE_UTF8 is set) PCRE_UCP Use Unicode properties for backslash-d, backslash-w, etc. PCRE_UNGREEDY Invert greediness of quantifiers PCRE_UTF16 Run in pcre16_compile() UTF-16 mode PCRE_UTF32 Run in pcre32_compile() UTF-32 mode PCRE_UTF8 Run in pcre_compile() UTF-8 mode
new N_PCRE object with given parameters
| str | The string containing the regexp |
| flags | pcre_compile flags |
Definition at line 80 of file n_pcre.c.
References __n_assert, N_PCRE::captured, init_lock, LOG_ERR, Malloc, N_PCRE::match_data, N_PCRE::match_list, n_log, npcre_delete(), N_PCRE::regexp, N_PCRE::regexp_str, and N_PCRE::rwlock.
Referenced by load_config_file(), main(), and main().
Here is the call graph for this function:
Here is the caller graph for this function: