From f9704bda9bae78c22fb0485d3e261df85a5f8560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 11 Jan 2019 16:02:25 +0200 Subject: [PATCH] Rename regexfilter structures --- .../modules/filter/regexfilter/regexfilter.cc | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/server/modules/filter/regexfilter/regexfilter.cc b/server/modules/filter/regexfilter/regexfilter.cc index 5666c0fef..48e280b2c 100644 --- a/server/modules/filter/regexfilter/regexfilter.cc +++ b/server/modules/filter/regexfilter/regexfilter.cc @@ -26,7 +26,6 @@ /** * @file regexfilter.c - a very simple regular expression rewrite filter. - * @verbatim * * A simple regular expression query rewrite filter. * Two parameters should be defined in the filter configuration @@ -35,10 +34,6 @@ * Two optional parameters * source= * user= - * - * Date Who Description - * 19/06/2014 Mark Riddoch Addition of source and user parameters - * @endverbatim */ static MXS_FILTER* createInstance(const char* name, MXS_CONFIG_PARAMETER* params); @@ -61,7 +56,7 @@ static char* regex_replace(const char* sql, /** * Instance structure */ -typedef struct +struct RegexInstance { char* source; /*< Source address to restrict matches */ char* user; /*< User name to restrict matches */ @@ -71,22 +66,22 @@ typedef struct pcre2_match_data* match_data; /*< Matching data used by the compiled regex */ FILE* logfile; /*< Log file */ bool log_trace; /*< Whether messages should be printed to tracelog */ -} REGEX_INSTANCE; +}; /** * The session structure for this regex filter */ -typedef struct +struct RegexSession { MXS_DOWNSTREAM down; /* The downstream filter */ pthread_mutex_t lock; int no_change; /* No. of unchanged requests */ int replacements; /* No. of changed requests */ int active; /* Is filter active */ -} REGEX_SESSION; +}; -void log_match(REGEX_INSTANCE* inst, char* re, char* old, char* newsql); -void log_nomatch(REGEX_INSTANCE* inst, char* re, char* old); +void log_match(RegexInstance* inst, char* re, char* old, char* newsql); +void log_nomatch(RegexInstance* inst, char* re, char* old); static const MXS_ENUM_VALUE option_values[] = { @@ -179,7 +174,7 @@ extern "C" * Free a regexfilter instance. * @param instance instance to free */ -void free_instance(REGEX_INSTANCE* instance) +void free_instance(RegexInstance* instance) { if (instance) { @@ -213,7 +208,7 @@ void free_instance(REGEX_INSTANCE* instance) */ static MXS_FILTER* createInstance(const char* name, MXS_CONFIG_PARAMETER* params) { - REGEX_INSTANCE* my_instance = static_cast(MXS_CALLOC(1, sizeof(REGEX_INSTANCE))); + RegexInstance* my_instance = static_cast(MXS_CALLOC(1, sizeof(RegexInstance))); if (my_instance) { @@ -281,11 +276,11 @@ static MXS_FILTER* createInstance(const char* name, MXS_CONFIG_PARAMETER* params */ static MXS_FILTER_SESSION* newSession(MXS_FILTER* instance, MXS_SESSION* session) { - REGEX_INSTANCE* my_instance = (REGEX_INSTANCE*) instance; - REGEX_SESSION* my_session; + RegexInstance* my_instance = (RegexInstance*) instance; + RegexSession* my_session; const char* remote, * user; - if ((my_session = static_cast(MXS_CALLOC(1, sizeof(REGEX_SESSION)))) != NULL) + if ((my_session = static_cast(MXS_CALLOC(1, sizeof(RegexSession)))) != NULL) { my_session->no_change = 0; my_session->replacements = 0; @@ -341,7 +336,7 @@ static void freeSession(MXS_FILTER* instance, MXS_FILTER_SESSION* session) */ static void setDownstream(MXS_FILTER* instance, MXS_FILTER_SESSION* session, MXS_DOWNSTREAM* downstream) { - REGEX_SESSION* my_session = (REGEX_SESSION*) session; + RegexSession* my_session = (RegexSession*) session; my_session->down = *downstream; } @@ -357,8 +352,8 @@ static void setDownstream(MXS_FILTER* instance, MXS_FILTER_SESSION* session, MXS */ static int routeQuery(MXS_FILTER* instance, MXS_FILTER_SESSION* session, GWBUF* queue) { - REGEX_INSTANCE* my_instance = (REGEX_INSTANCE*) instance; - REGEX_SESSION* my_session = (REGEX_SESSION*) session; + RegexInstance* my_instance = (RegexInstance*) instance; + RegexSession* my_session = (RegexSession*) session; char* sql, * newsql; if (my_session->active && modutil_is_SQL(queue)) @@ -407,8 +402,8 @@ static int routeQuery(MXS_FILTER* instance, MXS_FILTER_SESSION* session, GWBUF* */ static void diagnostic(MXS_FILTER* instance, MXS_FILTER_SESSION* fsession, DCB* dcb) { - REGEX_INSTANCE* my_instance = (REGEX_INSTANCE*) instance; - REGEX_SESSION* my_session = (REGEX_SESSION*) fsession; + RegexInstance* my_instance = (RegexInstance*) instance; + RegexSession* my_session = (RegexSession*) fsession; dcb_printf(dcb, "\t\tSearch and replace: s/%s/%s/\n", @@ -449,8 +444,8 @@ static void diagnostic(MXS_FILTER* instance, MXS_FILTER_SESSION* fsession, DCB* */ static json_t* diagnostic_json(const MXS_FILTER* instance, const MXS_FILTER_SESSION* fsession) { - REGEX_INSTANCE* my_instance = (REGEX_INSTANCE*)instance; - REGEX_SESSION* my_session = (REGEX_SESSION*)fsession; + RegexInstance* my_instance = (RegexInstance*)instance; + RegexSession* my_session = (RegexSession*)fsession; json_t* rval = json_object(); @@ -532,7 +527,7 @@ static char* regex_replace(const char* sql, pcre2_code* re, pcre2_match_data* ma * @param old Old SQL statement * @param new New SQL statement */ -void log_match(REGEX_INSTANCE* inst, char* re, char* old, char* newsql) +void log_match(RegexInstance* inst, char* re, char* old, char* newsql) { if (inst->logfile) { @@ -551,7 +546,7 @@ void log_match(REGEX_INSTANCE* inst, char* re, char* old, char* newsql) * @param re Regular expression * @param old SQL statement */ -void log_nomatch(REGEX_INSTANCE* inst, char* re, char* old) +void log_nomatch(RegexInstance* inst, char* re, char* old) { if (inst->logfile) {