dconf: added pcre options and pcre global

dconf: fixed issue in module support report
This commit is contained in:
Kevin Lin
2014-09-16 11:20:39 -04:00
parent 82fa5ba043
commit df50a5ffda
3 changed files with 21 additions and 4 deletions

View File

@@ -137,6 +137,8 @@ static struct dconf_module modules[] = {
{ "STATS", "PESECTION DISABLED", DCONF_STATS_PE_SECTION_DISABLED, 0 },
{ "PCRE", "SUPPORT", PCRE_CONF_SUPPORT, 1 },
{ "PCRE", "OPTIONS", PCRE_CONF_OPTIONS, 1 },
{ "PCRE", "GLOBAL", PCRE_CONF_GLOBAL, 1 },
{ NULL, NULL, 0, 0 }
};
@@ -303,7 +305,7 @@ void cli_dconf_print(struct cli_dconf *dconf)
} else if (!strcmp(modules[i].mname, "PCRE")) {
if (!pcre) {
cli_dbgmsg("Module PCRE %s\n", dconf->pcre ? "On" : "Off");
stats = 1;
pcre = 1;
}
if (dconf->pcre)

View File

@@ -132,6 +132,8 @@ struct cli_dconf {
/* PCRE flags */
#define PCRE_CONF_SUPPORT 0x1
#define PCRE_CONF_OPTIONS 0x2
#define PCRE_CONF_GLOBAL 0x4
#define BYTECODE_ENGINE_MASK (BYTECODE_INTERPRETER | BYTECODE_JIT_X86 | BYTECODE_JIT_PPC | BYTECODE_JIT_ARM)

View File

@@ -210,15 +210,28 @@ int cli_pcre_addpatt(struct cli_matcher *root, const char *trigger, const char *
return CL_ENULLARG;
}
cli_dbgmsg("cli_pcre_build: Compiling regex: %s\n", pm->pdata.expression);
/* disable global */
if ((pm->flags & CLI_PCRE_GLOBAL) & !(dconf->pcre & PCRE_CONF_GLOBAL)) {
cli_dbgmsg("cli_pcre_build: disabling global option for regex /%s/\n", pm->pdata.expression);
pm->flags &= ~(CLI_PCRE_GLOBAL);
}
/* options override through metadata manipulation */
//pm->pdata.options |= PCRE_NEVER_UTF; /* implemented in 8.33, disables (?UTF*) */
//pm->pdata.options |= PCRE_UCP;/* implemented in 8.20 */
//pm->pdata.options |= PCRE_AUTO_CALLOUT; /* used with CALLOUT(-BACK) function */
/* parse the regex, no options override *wink* */
if ((ret = cli_pcre_compile(&(pm->pdata), match_limit, recmatch_limit, 0, 0)) != CL_SUCCESS) {
if (dconf->pcre & PCRE_CONF_OPTIONS) {
/* compile the regex, no options override *wink* */
cli_dbgmsg("cli_pcre_build: Compiling regex: /%s/\n", pm->pdata.expression);
ret = cli_pcre_compile(&(pm->pdata), match_limit, recmatch_limit, 0, 0);
}
else {
/* compile the regex, options overrided and disabled */
cli_dbgmsg("cli_pcre_build: Compiling regex: /%s/ (without options)\n", pm->pdata.expression);
ret = cli_pcre_compile(&(pm->pdata), match_limit, recmatch_limit, 0, 1);
}
if (ret != CL_SUCCESS) {
cli_errmsg("cli_pcre_build: failed to build pcre regex\n");
pm->flags |= CLI_PCRE_DISABLED; /* disable the pcre */
return ret;