MXS-580: Added more options for filters

The tee, qlafilter, namedserverfilter and topfilter now support the same filter
options: case, ignorecase and extended. The extended filter option enables
the Extended Regular Expression syntax for the filters which is used when
matching queries.
This commit is contained in:
Markus Makela
2016-02-22 15:48:30 +02:00
parent 19356be848
commit aec1310c52
8 changed files with 154 additions and 41 deletions

View File

@ -191,6 +191,10 @@ createInstance(char **options, FILTER_PARAMETER **params)
{
cflags &= ~REG_ICASE;
}
else if (!strcasecmp(options[i], "extended"))
{
cflags |= REG_EXTENDED;
}
else
{
MXS_ERROR("namedserverfilter: unsupported option '%s'.",

View File

@ -177,14 +177,6 @@ createInstance(char **options, FILTER_PARAMETER **params)
if ((my_instance = calloc(1, sizeof(QLA_INSTANCE))) != NULL)
{
if (options)
{
my_instance->filebase = strdup(options[0]);
}
else
{
my_instance->filebase = strdup("qla");
}
my_instance->source = NULL;
my_instance->userName = NULL;
my_instance->match = NULL;
@ -225,9 +217,36 @@ createInstance(char **options, FILTER_PARAMETER **params)
}
}
}
int cflags = REG_ICASE;
if (options)
{
for (i = 0; options[i]; i++)
{
if (!strcasecmp(options[i], "ignorecase"))
{
cflags |= REG_ICASE;
}
else if (!strcasecmp(options[i], "case"))
{
cflags &= ~REG_ICASE;
}
else if (!strcasecmp(options[i], "extended"))
{
cflags |= REG_EXTENDED;
}
else
{
MXS_ERROR("qlafilter: unsupported option '%s'.",
options[i]);
}
}
}
my_instance->sessions = 0;
if (my_instance->match &&
regcomp(&my_instance->re, my_instance->match, REG_ICASE))
regcomp(&my_instance->re, my_instance->match, cflags))
{
MXS_ERROR("qlafilter: Invalid regular expression '%s'"
" for the match parameter.\n",
@ -242,8 +261,7 @@ createInstance(char **options, FILTER_PARAMETER **params)
return NULL;
}
if (my_instance->nomatch &&
regcomp(&my_instance->nore, my_instance->nomatch,
REG_ICASE))
regcomp(&my_instance->nore, my_instance->nomatch, cflags))
{
MXS_ERROR("qlafilter: Invalid regular expression '%s'"
" for the nomatch paramter.",

View File

@ -407,6 +407,33 @@ createInstance(char **options, FILTER_PARAMETER **params)
}
}
}
int cflags = REG_ICASE;
if (options)
{
for (i = 0; options[i]; i++)
{
if (!strcasecmp(options[i], "ignorecase"))
{
cflags |= REG_ICASE;
}
else if (!strcasecmp(options[i], "case"))
{
cflags &= ~REG_ICASE;
}
else if (!strcasecmp(options[i], "extended"))
{
cflags |= REG_EXTENDED;
}
else
{
MXS_ERROR("tee: unsupported option '%s'.",
options[i]);
}
}
}
if (my_instance->service == NULL)
{
free(my_instance->match);
@ -416,7 +443,7 @@ createInstance(char **options, FILTER_PARAMETER **params)
}
if (my_instance->match &&
regcomp(&my_instance->re, my_instance->match, REG_ICASE))
regcomp(&my_instance->re, my_instance->match, cflags))
{
MXS_ERROR("tee: Invalid regular expression '%s'"
" for the match parameter.",
@ -427,8 +454,7 @@ createInstance(char **options, FILTER_PARAMETER **params)
return NULL;
}
if (my_instance->nomatch &&
regcomp(&my_instance->nore, my_instance->nomatch,
REG_ICASE))
regcomp(&my_instance->nore, my_instance->nomatch, cflags))
{
MXS_ERROR("tee: Invalid regular expression '%s'"
" for the nomatch paramter.\n",

View File

@ -233,14 +233,36 @@ createInstance(char **options, FILTER_PARAMETER **params)
params[i]->name);
}
}
int cflags = REG_ICASE;
if (options)
{
MXS_ERROR("topfilter: Options are not supported by this "
" filter. They will be ignored.");
for (i = 0; options[i]; i++)
{
if (!strcasecmp(options[i], "ignorecase"))
{
cflags |= REG_ICASE;
}
else if (!strcasecmp(options[i], "case"))
{
cflags &= ~REG_ICASE;
}
else if (!strcasecmp(options[i], "extended"))
{
cflags |= REG_EXTENDED;
}
else
{
MXS_ERROR("topfilter: unsupported option '%s'.",
options[i]);
}
}
}
my_instance->sessions = 0;
if (my_instance->match &&
regcomp(&my_instance->re, my_instance->match, REG_ICASE))
regcomp(&my_instance->re, my_instance->match, cflags))
{
MXS_ERROR("topfilter: Invalid regular expression '%s'"
" for the match parameter.",
@ -253,8 +275,7 @@ createInstance(char **options, FILTER_PARAMETER **params)
return NULL;
}
if (my_instance->exclude &&
regcomp(&my_instance->exre, my_instance->exclude,
REG_ICASE))
regcomp(&my_instance->exre, my_instance->exclude, cflags))
{
MXS_ERROR("qlafilter: Invalid regular expression '%s'"
" for the nomatch paramter.\n",