79 const char* error = NULL;
82 pcre->
regexp = pcre_compile(str, flags, &error, &erroroffset, NULL);
84 n_log(
LOG_ERR,
" pcre compilation of %s failed at offset %d : %s", str, erroroffset, error);
104 if ((*pcre)->ovector) {
105 Free((*pcre)->ovector);
107 if ((*pcre)->regexp) {
108 pcre_free((*pcre)->regexp);
109 (*pcre)->regexp = NULL;
112 pcre_free_study((*pcre)->extra);
113 (*pcre)->extra = NULL;
115 pcre_free((*pcre)->extra);
116 (*pcre)->extra = NULL;
118 if ((*pcre)->captured > 0) {
119 pcre_free_substring_list((*pcre)->match_list);
156 len = (int)strlen(str);
161 case PCRE_ERROR_NOMATCH:
163 case PCRE_ERROR_NULL:
166 case PCRE_ERROR_BADOPTION:
169 case PCRE_ERROR_BADMAGIC:
172 case PCRE_ERROR_UNKNOWN_NODE:
175 case PCRE_ERROR_NOMEMORY:
183 }
else if (rc == 0) {
#define FreeNoLog(__ptr)
Free Handler without log.
#define Malloc(__ptr, __struct, __size)
Malloc Handler to get errors and set to 0.
#define __n_assert(__ptr, __ret)
macro to assert things
#define Free(__ptr)
Free Handler to get errors.
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_DEBUG
debug-level messages
#define LOG_ERR
error conditions
char * regexp_str
original regexp string
int captured
flag for match_list cleaning
const char ** match_list
populated match list if nPcreCapMatch is called
int * ovector
list of indexes
int ovecount
configured maximum number of matched occurence
pcre_extra * extra
optimization if any
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 aut...
int npcre_match(char *str, N_PCRE *pcre)
Return TRUE if str matches regexp, and make captures up to max_cap.
int npcre_clean_match(N_PCRE *pcre)
clean the match list of the last capture, if any
int npcre_delete(N_PCRE **pcre)
Free a N_PCRE pointer.
PCRE helpers for regex matching.