Nilorea Library
C utilities for networking, threading, graphics
PCREs: regex matching helpers

Data Structures

struct  N_PCRE
 N_PCRE structure. More...
 

Functions

int npcre_clean_match (N_PCRE *pcre)
 clean the match list of the last capture, if any More...
 
int npcre_delete (N_PCRE **pcre)
 Free a N_PCRE pointer. More...
 
int npcre_match (char *str, N_PCRE *pcre)
 Return TRUE if str matches regexp, and make captures up to max_cap. More...
 
N_PCREnpcre_new (char *str, int max_cap, int flags)
 From pcre doc, the flag bits are: PCRE_ANCHORED Force pattern anchoring PCRE_AUTO_CALLOUT Compile automatic callouts PCRE_BSR_ANYCRLF \R matches only CR, LF, or CRLF PCRE_BSR_UNICODE \R matches all Unicode line endings PCRE_CASELESS Do caseless matching PCRE_DOLLAR_ENDONLY $ not to match newline at end PCRE_DOTALL . More...
 

Detailed Description


Data Structure Documentation

◆ N_PCRE

struct N_PCRE

N_PCRE structure.

Examples
ex_gui_dictionary.c, and ex_pcre.c.

Definition at line 28 of file n_pcre.h.

+ Collaboration diagram for N_PCRE:
Data Fields
int captured flag for match_list cleaning
pcre_extra * extra optimization if any
const char ** match_list populated match list if nPcreCapMatch is called
int ovecount configured maximum number of matched occurence
int * ovector list of indexes
pcre * regexp regexp
char * regexp_str original regexp string

Function Documentation

◆ npcre_clean_match()

int npcre_clean_match ( N_PCRE pcre)

clean the match list of the last capture, if any

Parameters
pcreThe N_PCRE regexp holder
Returns
TRUE or FALSE

Definition at line 144 of file n_pcre.c.

References __n_assert.

Referenced by npcre_match().

+ Here is the caller graph for this function:

◆ npcre_delete()

int npcre_delete ( N_PCRE **  pcre)

Free a N_PCRE pointer.

Parameters
pcreThe N_PCRE regexp holder
Returns
TRUE or FALSE

Definition at line 107 of file n_pcre.c.

References __n_assert, Free, and FreeNoLog.

Referenced by load_config_file(), and npcre_new().

+ Here is the caller graph for this function:

◆ npcre_match()

int npcre_match ( char *  str,
N_PCRE pcre 
)

Return TRUE if str matches regexp, and make captures up to max_cap.

Parameters
pcreThe N_PCRE regexp holder
strString to test against the regexp
Returns
TRUE or FALSE

Definition at line 165 of file n_pcre.c.

References __n_assert, LOG_DEBUG, n_log, and npcre_clean_match().

Referenced by load_config_file().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ npcre_new()

N_PCRE * npcre_new ( char *  str,
int  max_cap,
int  flags 
)

From pcre doc, the flag bits are: PCRE_ANCHORED Force pattern anchoring PCRE_AUTO_CALLOUT Compile automatic callouts PCRE_BSR_ANYCRLF \R matches only CR, LF, or CRLF PCRE_BSR_UNICODE \R matches all Unicode line endings PCRE_CASELESS Do caseless matching PCRE_DOLLAR_ENDONLY $ not to match newline at end PCRE_DOTALL .

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

make a ne N_PCRE object with given paramters

Parameters
strThe string containing the regexp
max_capMaximum number of captures. str The string containing the regexp
flagspcre_compile flags
Returns
a filled N_PCRE struct or NULL

Definition at line 59 of file n_pcre.c.

References __n_assert, LOG_ERR, Malloc, n_log, and npcre_delete().

Referenced by load_config_file().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: