Lines Matching refs:regex

62 	pcre2_code *regex; /* compiled regular expression */  member
71 int regex_prepare_data(struct regex_data **regex, char const *pattern_string, in regex_prepare_data() argument
76 *regex = regex_data_create(); in regex_prepare_data()
77 if (!(*regex)) in regex_prepare_data()
80 (*regex)->regex = pcre2_compile( in regex_prepare_data()
83 if (!(*regex)->regex) { in regex_prepare_data()
87 (*regex)->match_data = in regex_prepare_data()
88 pcre2_match_data_create_from_pattern((*regex)->regex, NULL); in regex_prepare_data()
89 if (!(*regex)->match_data) { in regex_prepare_data()
95 regex_data_free(*regex); in regex_prepare_data()
96 *regex = NULL; in regex_prepare_data()
111 int regex_load_mmap(struct mmap_area *mmap_area, struct regex_data **regex, in regex_load_mmap() argument
131 *regex = regex_data_create(); in regex_load_mmap()
132 if (!*regex) in regex_load_mmap()
135 rc = pcre2_serialize_decode(&(*regex)->regex, 1, in regex_load_mmap()
141 (*regex)->match_data = in regex_load_mmap()
142 pcre2_match_data_create_from_pattern((*regex)->regex, NULL); in regex_load_mmap()
143 if (!(*regex)->match_data) in regex_load_mmap()
156 regex_data_free(*regex); in regex_load_mmap()
157 *regex = NULL; in regex_load_mmap()
161 int regex_writef(struct regex_data *regex, FILE *fp, int do_write_precompregex) in regex_writef() argument
171 rc = pcre2_serialize_encode((const pcre2_code **)&regex->regex, in regex_writef()
201 void regex_data_free(struct regex_data *regex) in regex_data_free() argument
203 if (regex) { in regex_data_free()
204 if (regex->regex) in regex_data_free()
205 pcre2_code_free(regex->regex); in regex_data_free()
206 if (regex->match_data) in regex_data_free()
207 pcre2_match_data_free(regex->match_data); in regex_data_free()
208 __pthread_mutex_destroy(&regex->match_mutex); in regex_data_free()
209 free(regex); in regex_data_free()
213 int regex_match(struct regex_data *regex, char const *subject, int partial) in regex_match() argument
216 __pthread_mutex_lock(&regex->match_mutex); in regex_match()
218 regex->regex, (PCRE2_SPTR)subject, PCRE2_ZERO_TERMINATED, 0, in regex_match()
219 partial ? PCRE2_PARTIAL_SOFT : 0, regex->match_data, NULL); in regex_match()
220 __pthread_mutex_unlock(&regex->match_mutex); in regex_match()
246 rc = pcre2_pattern_info(regex1->regex, PCRE2_INFO_SIZE, &len1); in regex_cmp()
248 rc = pcre2_pattern_info(regex2->regex, PCRE2_INFO_SIZE, &len2); in regex_cmp()
250 if (len1 != len2 || memcmp(regex1->regex, regex2->regex, len1)) in regex_cmp()
280 pcre *regex; /* compiled regular expression */ member
287 int regex_prepare_data(struct regex_data **regex, char const *pattern_string, in regex_prepare_data() argument
292 *regex = regex_data_create(); in regex_prepare_data()
293 if (!(*regex)) in regex_prepare_data()
296 (*regex)->regex = in regex_prepare_data()
299 if (!(*regex)->regex) in regex_prepare_data()
302 (*regex)->owned = 1; in regex_prepare_data()
304 (*regex)->sd = pcre_study((*regex)->regex, 0, &errordata->error_buffer); in regex_prepare_data()
305 if (!(*regex)->sd && errordata->error_buffer) in regex_prepare_data()
311 regex_data_free(*regex); in regex_prepare_data()
312 *regex = NULL; in regex_prepare_data()
321 int regex_load_mmap(struct mmap_area *mmap_area, struct regex_data **regex, in regex_load_mmap() argument
332 *regex = regex_data_create(); in regex_load_mmap()
333 if (!(*regex)) in regex_load_mmap()
336 (*regex)->owned = 0; in regex_load_mmap()
337 (*regex)->regex = (pcre *)mmap_area->next_addr; in regex_load_mmap()
346 rc = pcre_fullinfo((*regex)->regex, NULL, PCRE_INFO_SIZE, &info_len); in regex_load_mmap()
355 (*regex)->lsd.study_data = (void *)mmap_area->next_addr; in regex_load_mmap()
356 (*regex)->lsd.flags |= PCRE_EXTRA_STUDY_DATA; in regex_load_mmap()
362 rc = pcre_fullinfo((*regex)->regex, &(*regex)->lsd, in regex_load_mmap()
372 regex_data_free(*regex); in regex_load_mmap()
373 *regex = NULL; in regex_load_mmap()
377 static inline pcre_extra *get_pcre_extra(struct regex_data *regex) in get_pcre_extra() argument
379 if (!regex) return NULL; in get_pcre_extra()
380 if (regex->owned) { in get_pcre_extra()
381 return regex->sd; in get_pcre_extra()
382 } else if (regex->lsd.study_data) { in get_pcre_extra()
383 return &regex->lsd; in get_pcre_extra()
389 int regex_writef(struct regex_data *regex, FILE *fp, in regex_writef() argument
396 pcre_extra *sd = get_pcre_extra(regex); in regex_writef()
399 rc = pcre_fullinfo(regex->regex, NULL, PCRE_INFO_SIZE, &size); in regex_writef()
410 len = fwrite(regex->regex, 1, to_write, fp); in regex_writef()
417 pcre_fullinfo(regex->regex, sd, PCRE_INFO_STUDYSIZE, &size); in regex_writef()
439 void regex_data_free(struct regex_data *regex) in regex_data_free() argument
441 if (regex) { in regex_data_free()
442 if (regex->owned) { in regex_data_free()
443 if (regex->regex) in regex_data_free()
444 pcre_free(regex->regex); in regex_data_free()
445 if (regex->sd) in regex_data_free()
446 pcre_free_study(regex->sd); in regex_data_free()
448 free(regex); in regex_data_free()
452 int regex_match(struct regex_data *regex, char const *subject, int partial) in regex_match() argument
456 rc = pcre_exec(regex->regex, get_pcre_extra(regex), in regex_match()
484 rc = pcre_fullinfo(regex1->regex, NULL, PCRE_INFO_SIZE, &len1); in regex_cmp()
486 rc = pcre_fullinfo(regex2->regex, NULL, PCRE_INFO_SIZE, &len2); in regex_cmp()
488 if (len1 != len2 || memcmp(regex1->regex, regex2->regex, len1)) in regex_cmp()