| 6 |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com> |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com> |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
|
#ifdef HAVE_CONFIG_H |
| 10 |
|
#include "config.h" |
| 11 |
|
#endif |
| 12 |
|
|
| 13 |
#define PCRE2_CODE_UNIT_WIDTH 8 |
#define PCRE2_CODE_UNIT_WIDTH 8 |
| 14 |
|
|
| 15 |
#include "bwf.h" |
#include "bwf.h" |
| 35 |
size_t len_line; |
size_t len_line; |
| 36 |
char *p = bwf_pattern_str; |
char *p = bwf_pattern_str; |
| 37 |
int line_id = 0; |
int line_id = 0; |
|
int errorcode; |
|
|
PCRE2_SIZE erroroffset; |
|
| 38 |
|
|
| 39 |
if (filename == NULL) |
if (filename == NULL) |
| 40 |
{ |
{ |
| 95 |
log_error("Debug: bwf_pattern_str: %s\n", bwf_pattern_str); |
log_error("Debug: bwf_pattern_str: %s\n", bwf_pattern_str); |
| 96 |
#endif |
#endif |
| 97 |
|
|
| 98 |
bwf_unload(); |
return 0; |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
int bwf_compile(void) |
| 102 |
|
{ |
| 103 |
|
int errorcode; |
| 104 |
|
PCRE2_SIZE erroroffset; |
| 105 |
|
|
| 106 |
|
bwf_cleanup(); |
| 107 |
|
|
| 108 |
bwf_code = pcre2_compile((PCRE2_SPTR)bwf_pattern_str, PCRE2_ZERO_TERMINATED, PCRE2_CASELESS, &errorcode, &erroroffset, NULL); |
bwf_code = pcre2_compile((PCRE2_SPTR)bwf_pattern_str, PCRE2_ZERO_TERMINATED, PCRE2_CASELESS, &errorcode, &erroroffset, NULL); |
| 109 |
if (bwf_code == NULL) |
if (bwf_code == NULL) |
| 110 |
{ |
{ |
| 111 |
log_error("pcre2_compile() error: %d", errorcode); |
log_error("pcre2_compile() error: %d", errorcode); |
| 112 |
return -4; |
return -1; |
| 113 |
} |
} |
| 114 |
|
|
| 115 |
return 0; |
return 0; |
| 116 |
} |
} |
| 117 |
|
|
| 118 |
void bwf_unload(void) |
void bwf_cleanup(void) |
| 119 |
{ |
{ |
| 120 |
if (bwf_code != NULL) |
if (bwf_code != NULL) |
| 121 |
{ |
{ |