| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include "shared-forward.h" |
| 5 |
|
| 6 |
#if HAVE_PCRE2 |
| 7 |
|
| 8 |
#include "dlfcn-util.h" |
| 9 |
|
| 10 |
#define PCRE2_CODE_UNIT_WIDTH 8 |
| 11 |
#include <pcre2.h> /* IWYU pragma: export */ |
| 12 |
|
| 13 |
extern DLSYM_PROTOTYPE(pcre2_match_data_create); |
| 14 |
extern DLSYM_PROTOTYPE(pcre2_match_data_free); |
| 15 |
extern DLSYM_PROTOTYPE(pcre2_code_free); |
| 16 |
extern DLSYM_PROTOTYPE(pcre2_compile); |
| 17 |
extern DLSYM_PROTOTYPE(pcre2_get_error_message); |
| 18 |
extern DLSYM_PROTOTYPE(pcre2_match); |
| 19 |
extern DLSYM_PROTOTYPE(pcre2_get_ovector_pointer); |
| 20 |
|
| 21 |
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(pcre2_match_data*, sym_pcre2_match_data_free, pcre2_match_data_freep, NULL); |
| 22 |
#else |
| 23 |
|
| 24 |
typedef struct pcre2_code pcre2_code; |
| 25 |
|
| 26 |
static inline void sym_pcre2_code_free(pcre2_code *p) { |
| 27 |
assert(!p); |
| 28 |
} |
| 29 |
|
| 30 |
#endif |
| 31 |
|
| 32 |
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(pcre2_code*, sym_pcre2_code_free, pcre2_code_freep, NULL); |
| 33 |
|
| 34 |
extern const struct hash_ops pcre2_code_hash_ops_free; |
| 35 |
|
| 36 |
typedef enum PatternCompileCase { |
| 37 |
PATTERN_COMPILE_CASE_AUTO, |
| 38 |
PATTERN_COMPILE_CASE_SENSITIVE, |
| 39 |
PATTERN_COMPILE_CASE_INSENSITIVE, |
| 40 |
_PATTERN_COMPILE_CASE_MAX, |
| 41 |
_PATTERN_COMPILE_CASE_INVALID = -EINVAL, |
| 42 |
} PatternCompileCase; |
| 43 |
|
| 44 |
int pattern_compile_and_log(const char *pattern, PatternCompileCase case_, pcre2_code **ret); |
| 45 |
int pattern_matches_and_log(pcre2_code *compiled_pattern, const char *message, size_t size, size_t *ret_ovec); |
| 46 |
|
| 47 |
int dlopen_pcre2(int log_level); |