MXS-1841 Compile all filters as C++
Minimal changes to make the files compile with a C++ compiler.
This commit is contained in:
parent
658329b648
commit
aa1c956aa7
@ -1,18 +1,18 @@
|
||||
add_subdirectory(binlogfilter)
|
||||
add_subdirectory(cache)
|
||||
add_subdirectory(maxrows)
|
||||
add_subdirectory(ccrfilter)
|
||||
add_subdirectory(dbfwfilter)
|
||||
add_subdirectory(hintfilter)
|
||||
add_subdirectory(insertstream)
|
||||
add_subdirectory(luafilter)
|
||||
add_subdirectory(masking)
|
||||
add_subdirectory(maxrows)
|
||||
add_subdirectory(mqfilter)
|
||||
add_subdirectory(namedserverfilter)
|
||||
add_subdirectory(nullfilter)
|
||||
add_subdirectory(qlafilter)
|
||||
add_subdirectory(regexfilter)
|
||||
add_subdirectory(tee)
|
||||
add_subdirectory(throttlefilter)
|
||||
add_subdirectory(topfilter)
|
||||
add_subdirectory(tpmfilter)
|
||||
add_subdirectory(masking)
|
||||
add_subdirectory(insertstream)
|
||||
add_subdirectory(binlogfilter)
|
||||
add_subdirectory(throttlefilter)
|
||||
|
@ -1,4 +1,4 @@
|
||||
add_library(ccrfilter SHARED ccrfilter.c)
|
||||
add_library(ccrfilter SHARED ccrfilter.cc)
|
||||
target_link_libraries(ccrfilter maxscale-common)
|
||||
set_target_properties(ccrfilter PROPERTIES VERSION "1.0.0")
|
||||
install_module(ccrfilter core)
|
||||
|
@ -119,6 +119,9 @@ typedef enum ccr_hint_value_t
|
||||
|
||||
static CCR_HINT_VALUE search_ccr_hint(GWBUF* buffer);
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
/**
|
||||
* The module entry point routine. It is this routine that
|
||||
* must populate the structure that is referred to as the
|
||||
@ -177,6 +180,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
return &info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the filter for a particular service
|
||||
* within MaxScale.
|
||||
@ -190,7 +195,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
static MXS_FILTER *
|
||||
createInstance(const char *name, char **options, MXS_CONFIG_PARAMETER *params)
|
||||
{
|
||||
CCR_INSTANCE *my_instance = MXS_CALLOC(1, sizeof(CCR_INSTANCE));
|
||||
CCR_INSTANCE *my_instance = static_cast<CCR_INSTANCE*>(MXS_CALLOC(1, sizeof(CCR_INSTANCE)));
|
||||
|
||||
if (my_instance)
|
||||
{
|
||||
@ -237,7 +242,7 @@ static MXS_FILTER_SESSION *
|
||||
newSession(MXS_FILTER *instance, MXS_SESSION *session)
|
||||
{
|
||||
CCR_INSTANCE *my_instance = (CCR_INSTANCE *)instance;
|
||||
CCR_SESSION *my_session = MXS_MALLOC(sizeof(CCR_SESSION));
|
||||
CCR_SESSION *my_session = static_cast<CCR_SESSION*>(MXS_MALLOC(sizeof(CCR_SESSION)));
|
||||
|
||||
if (my_session)
|
||||
{
|
||||
@ -490,14 +495,14 @@ static CCR_HINT_VALUE search_ccr_hint(GWBUF* buffer)
|
||||
|
||||
while (hint && !found_ccr)
|
||||
{
|
||||
if (hint->type == HINT_PARAMETER && strcasecmp(hint->data, CCR) == 0)
|
||||
if (hint->type == HINT_PARAMETER && strcasecmp(static_cast<char*>(hint->data), CCR) == 0)
|
||||
{
|
||||
found_ccr = true;
|
||||
if (strcasecmp(hint->value, "match") == 0)
|
||||
if (strcasecmp(static_cast<char*>(hint->value), "match") == 0)
|
||||
{
|
||||
rval = CCR_HINT_MATCH;
|
||||
}
|
||||
else if (strcasecmp(hint->value, "ignore") == 0)
|
||||
else if (strcasecmp(static_cast<char*>(hint->value), "ignore") == 0)
|
||||
{
|
||||
rval = CCR_HINT_IGNORE;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
add_library(hintfilter SHARED hintfilter.c hintparser.c)
|
||||
add_library(hintfilter SHARED hintfilter.cc hintparser.cc)
|
||||
set_target_properties(hintfilter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_LIBDIR} VERSION "1.0.0")
|
||||
target_link_libraries(hintfilter maxscale-common)
|
||||
install_module(hintfilter core)
|
||||
|
@ -36,6 +36,9 @@ 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);
|
||||
static uint64_t getCapabilities(MXS_FILTER* instance);
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
/**
|
||||
* The module entry point routine. It is this routine that
|
||||
* must populate the structure that is referred to as the
|
||||
@ -83,6 +86,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
return &info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the filter for a particular service
|
||||
* within MaxScale.
|
||||
@ -98,7 +103,7 @@ createInstance(const char *name, char **options, MXS_CONFIG_PARAMETER *params)
|
||||
{
|
||||
HINT_INSTANCE *my_instance;
|
||||
|
||||
if ((my_instance = MXS_CALLOC(1, sizeof(HINT_INSTANCE))) != NULL)
|
||||
if ((my_instance = static_cast<HINT_INSTANCE*>(MXS_CALLOC(1, sizeof(HINT_INSTANCE)))) != NULL)
|
||||
{
|
||||
my_instance->sessions = 0;
|
||||
}
|
||||
@ -118,7 +123,7 @@ newSession(MXS_FILTER *instance, MXS_SESSION *session)
|
||||
HINT_INSTANCE *my_instance = (HINT_INSTANCE *)instance;
|
||||
HINT_SESSION *my_session;
|
||||
|
||||
if ((my_session = MXS_CALLOC(1, sizeof(HINT_SESSION))) != NULL)
|
||||
if ((my_session = static_cast<HINT_SESSION*>(MXS_CALLOC(1, sizeof(HINT_SESSION)))) != NULL)
|
||||
{
|
||||
my_session->query_len = 0;
|
||||
my_session->request = NULL;
|
@ -33,7 +33,7 @@
|
||||
*/
|
||||
struct
|
||||
{
|
||||
char *keyword;
|
||||
const char *keyword;
|
||||
TOKEN_VALUE token;
|
||||
} keywords[] =
|
||||
{
|
||||
@ -49,7 +49,7 @@ struct
|
||||
{ "master", TOK_MASTER},
|
||||
{ "slave", TOK_SLAVE},
|
||||
{ "server", TOK_SERVER},
|
||||
{ NULL, 0}
|
||||
{ NULL, static_cast<TOKEN_VALUE>(0)}
|
||||
};
|
||||
/**
|
||||
HINT_TOKEN kwords[] = {
|
||||
@ -600,7 +600,7 @@ hint_next_token(GWBUF **buf, char **ptr)
|
||||
if (*ptr > (char *)((*buf)->end) && (*buf)->next)
|
||||
{
|
||||
*buf = (*buf)->next;
|
||||
*ptr = (*buf)->start;
|
||||
*ptr = static_cast<char*>((*buf)->start);
|
||||
}
|
||||
|
||||
if (dest - word > 98)
|
@ -1,4 +1,4 @@
|
||||
add_library(insertstream SHARED insertstream.c)
|
||||
add_library(insertstream SHARED insertstream.cc)
|
||||
target_link_libraries(insertstream maxscale-common mysqlcommon)
|
||||
set_target_properties(insertstream PROPERTIES VERSION "1.0.0")
|
||||
install_module(insertstream core)
|
||||
|
@ -78,6 +78,9 @@ typedef struct
|
||||
char target[MYSQL_TABLE_MAXLEN + MYSQL_DATABASE_MAXLEN + 1]; /**< Current target table */
|
||||
} DS_SESSION;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
/**
|
||||
* The module entry point routine. It is this routine that
|
||||
* must populate the structure that is referred to as the
|
||||
@ -128,6 +131,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
return &info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Free a insertstream instance.
|
||||
* @param instance instance to free
|
||||
@ -162,7 +167,7 @@ createInstance(const char *name, char **options, MXS_CONFIG_PARAMETER *params)
|
||||
{
|
||||
DS_INSTANCE *my_instance;
|
||||
|
||||
if ((my_instance = MXS_CALLOC(1, sizeof(DS_INSTANCE))) != NULL)
|
||||
if ((my_instance = static_cast<DS_INSTANCE*>(MXS_CALLOC(1, sizeof(DS_INSTANCE)))) != NULL)
|
||||
{
|
||||
my_instance->source = config_copy_string(params, "source");
|
||||
my_instance->user = config_copy_string(params, "user");
|
||||
@ -184,7 +189,7 @@ newSession(MXS_FILTER *instance, MXS_SESSION *session)
|
||||
DS_INSTANCE *my_instance = (DS_INSTANCE *) instance;
|
||||
DS_SESSION *my_session;
|
||||
|
||||
if ((my_session = MXS_CALLOC(1, sizeof(DS_SESSION))) != NULL)
|
||||
if ((my_session = static_cast<DS_SESSION*>(MXS_CALLOC(1, sizeof(DS_SESSION)))) != NULL)
|
||||
{
|
||||
my_session->target[0] = '\0';
|
||||
my_session->state = DS_STREAM_CLOSED;
|
||||
@ -354,7 +359,7 @@ static int32_t routeQuery(MXS_FILTER *instance, MXS_FILTER_SESSION *session, GWB
|
||||
|
||||
if (send_empty)
|
||||
{
|
||||
char empty_packet[] = {0, 0, 0, packet_num};
|
||||
char empty_packet[] = {0, 0, 0, static_cast<char>(packet_num)};
|
||||
queue = gwbuf_alloc_and_load(sizeof(empty_packet), &empty_packet[0]);
|
||||
}
|
||||
}
|
||||
@ -418,7 +423,7 @@ static GWBUF* convert_to_stream(GWBUF* buffer, uint8_t packet_num)
|
||||
buffer = gwbuf_consume(buffer, (modptr - dataptr) - MYSQL_HEADER_LEN);
|
||||
char* header_start = (char*)GWBUF_DATA(buffer);
|
||||
char* store_end = dataptr = header_start + MYSQL_HEADER_LEN;
|
||||
char* end = buffer->end;
|
||||
char* end = static_cast<char*>(buffer->end);
|
||||
char* value;
|
||||
uint32_t valuesize;
|
||||
|
||||
@ -622,7 +627,7 @@ static bool extract_insert_target(GWBUF *buffer, char* target, int len)
|
||||
|
||||
if (tables)
|
||||
{
|
||||
for (int i = 0; i < (size_t)n_tables; ++i)
|
||||
for (int i = 0; i < n_tables; ++i)
|
||||
{
|
||||
MXS_FREE(tables[i]);
|
||||
}
|
@ -2,7 +2,7 @@ if (BUILD_LUAFILTER)
|
||||
find_package(Lua)
|
||||
if(LUA_FOUND)
|
||||
include_directories(${LUA_INCLUDE_DIR})
|
||||
add_library(luafilter SHARED luafilter.c)
|
||||
add_library(luafilter SHARED luafilter.cc)
|
||||
set_target_properties(luafilter PROPERTIES VERSION "1.0.0")
|
||||
target_link_libraries(luafilter maxscale-common ${LUA_LIBRARIES})
|
||||
install_module(luafilter experimental)
|
||||
|
@ -67,6 +67,9 @@ 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);
|
||||
static uint64_t getCapabilities(MXS_FILTER *instance);
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
/**
|
||||
* The module entry point routine. It is this routine that
|
||||
* must populate the structure that is referred to as the
|
||||
@ -116,6 +119,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
return &info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int id_pool = 0;
|
||||
static GWBUF *current_global_query = NULL;
|
||||
|
@ -1,4 +1,4 @@
|
||||
add_library(maxrows SHARED maxrows.c)
|
||||
add_library(maxrows SHARED maxrows.cc)
|
||||
target_link_libraries(maxrows maxscale-common)
|
||||
set_target_properties(maxrows PROPERTIES VERSION "1.0.0")
|
||||
set_target_properties(maxrows PROPERTIES LINK_FLAGS -Wl,-z,defs)
|
||||
|
@ -82,6 +82,9 @@ static const MXS_ENUM_VALUE return_option_values[] =
|
||||
|
||||
/* Global symbols of the Module */
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
/**
|
||||
* The module entry point function, called when the module is loaded.
|
||||
*
|
||||
@ -148,6 +151,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
return &info;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/* Implementation */
|
||||
|
||||
typedef struct maxrows_config
|
||||
@ -233,7 +238,7 @@ static MXS_FILTER *createInstance(const char *name,
|
||||
char **options,
|
||||
MXS_CONFIG_PARAMETER *params)
|
||||
{
|
||||
MAXROWS_INSTANCE *cinstance = MXS_CALLOC(1, sizeof(MAXROWS_INSTANCE));
|
||||
MAXROWS_INSTANCE *cinstance = static_cast<MAXROWS_INSTANCE*>(MXS_CALLOC(1, sizeof(MAXROWS_INSTANCE)));
|
||||
|
||||
if (cinstance)
|
||||
{
|
||||
@ -242,9 +247,10 @@ static MXS_FILTER *createInstance(const char *name,
|
||||
"max_resultset_rows");
|
||||
cinstance->config.max_resultset_size = config_get_size(params,
|
||||
"max_resultset_size");
|
||||
cinstance->config.m_return = config_get_enum(params,
|
||||
"max_resultset_return",
|
||||
return_option_values);
|
||||
cinstance->config.m_return =
|
||||
static_cast<maxrows_return_mode>(config_get_enum(params,
|
||||
"max_resultset_return",
|
||||
return_option_values));
|
||||
cinstance->config.debug = config_get_integer(params, "debug");
|
||||
}
|
||||
|
||||
@ -873,6 +879,7 @@ static int handle_rows(MAXROWS_SESSION_DATA *csdata, GWBUF* buffer, size_t extra
|
||||
|
||||
// We have at least one complete packet and we can process the command byte.
|
||||
int command = (int)MYSQL_GET_COMMAND(header);
|
||||
int flags = 0;
|
||||
|
||||
switch (command)
|
||||
{
|
||||
@ -933,7 +940,7 @@ static int handle_rows(MAXROWS_SESSION_DATA *csdata, GWBUF* buffer, size_t extra
|
||||
break;
|
||||
}
|
||||
|
||||
int flags = gw_mysql_get_byte2(header + MAXROWS_MYSQL_EOF_PACKET_FLAGS_OFFSET);
|
||||
flags = gw_mysql_get_byte2(header + MAXROWS_MYSQL_EOF_PACKET_FLAGS_OFFSET);
|
||||
|
||||
// Check whether the EOF terminates the resultset or indicates MORE_RESULTS
|
||||
if (!(flags & SERVER_MORE_RESULTS_EXIST))
|
||||
@ -1093,7 +1100,7 @@ static int send_eof_upstream(MAXROWS_SESSION_DATA *csdata)
|
||||
size_t offset = gwbuf_length(csdata->res.column_defs);
|
||||
|
||||
/* Data to send + added EOF */
|
||||
uint8_t *new_result = MXS_MALLOC(offset + MYSQL_EOF_PACKET_LEN);
|
||||
uint8_t *new_result = static_cast<uint8_t*>(MXS_MALLOC(offset + MYSQL_EOF_PACKET_LEN));
|
||||
|
||||
if (new_result)
|
||||
{
|
||||
@ -1197,7 +1204,7 @@ static int send_error_upstream(MAXROWS_SESSION_DATA *csdata)
|
||||
GWBUF *err_pkt;
|
||||
uint8_t hdr_err[MYSQL_ERR_PACKET_MIN_LEN];
|
||||
unsigned long bytes_copied;
|
||||
char *err_msg_prefix = "Row limit/size exceeded for query: ";
|
||||
const char *err_msg_prefix = "Row limit/size exceeded for query: ";
|
||||
int err_prefix_len = strlen(err_msg_prefix);
|
||||
unsigned long pkt_len = MYSQL_ERR_PACKET_MIN_LEN + err_prefix_len;
|
||||
unsigned long sql_len = gwbuf_length(csdata->input_sql) -
|
@ -1,7 +1,7 @@
|
||||
find_package(RabbitMQ)
|
||||
if(RABBITMQ_FOUND)
|
||||
include_directories(${RABBITMQ_HEADERS})
|
||||
add_library(mqfilter SHARED mqfilter.c)
|
||||
add_library(mqfilter SHARED mqfilter.cc)
|
||||
target_link_libraries(mqfilter maxscale-common ${RABBITMQ_LIBRARIES})
|
||||
add_dependencies(mqfilter pcre2)
|
||||
set_target_properties(mqfilter PROPERTIES VERSION "1.0.2")
|
||||
|
@ -249,6 +249,9 @@ static const MXS_ENUM_VALUE trigger_values[] =
|
||||
{NULL}
|
||||
};
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
/**
|
||||
* The module entry point routine. It is this routine that
|
||||
* must populate the structure that is referred to as the
|
||||
@ -315,6 +318,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
return &info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function used to initialize the connection to
|
||||
* the RabbitMQ server. Also used to reconnect to the server
|
||||
@ -495,7 +500,7 @@ char** parse_optstr(const char* str, const char* tok, int* szstore)
|
||||
size++;
|
||||
}
|
||||
|
||||
char **arr = MXS_MALLOC(sizeof(char*) * size);
|
||||
char **arr = static_cast<char**>(MXS_MALLOC(sizeof(char*) * size));
|
||||
MXS_ABORT_IF_NULL(arr);
|
||||
|
||||
*szstore = size;
|
||||
@ -523,7 +528,7 @@ char** parse_optstr(const char* str, const char* tok, int* szstore)
|
||||
static MXS_FILTER *
|
||||
createInstance(const char *name, char **options, MXS_CONFIG_PARAMETER *params)
|
||||
{
|
||||
MQ_INSTANCE *my_instance = MXS_CALLOC(1, sizeof(MQ_INSTANCE));
|
||||
MQ_INSTANCE *my_instance = static_cast<MQ_INSTANCE*>(MXS_CALLOC(1, sizeof(MQ_INSTANCE)));
|
||||
|
||||
if (my_instance)
|
||||
{
|
||||
@ -543,7 +548,8 @@ createInstance(const char *name, char **options, MXS_CONFIG_PARAMETER *params)
|
||||
my_instance->rconn_intv = 1;
|
||||
|
||||
my_instance->port = config_get_integer(params, "port");
|
||||
my_instance->trgtype = config_get_enum(params, "logging_trigger", trigger_values);
|
||||
my_instance->trgtype =
|
||||
static_cast<log_trigger_t>(config_get_enum(params, "logging_trigger", trigger_values));
|
||||
my_instance->log_all = config_get_bool(params, "logging_log_all");
|
||||
my_instance->strict_logging = config_get_bool(params, "logging_strict");
|
||||
my_instance->hostname = MXS_STRDUP_A(config_get_string(params, "hostname"));
|
||||
@ -773,7 +779,7 @@ bool sendMessage(void* data)
|
||||
void pushMessage(MQ_INSTANCE *instance, amqp_basic_properties_t* prop, char* msg)
|
||||
{
|
||||
|
||||
mqmessage* newmsg = MXS_CALLOC(1, sizeof(mqmessage));
|
||||
mqmessage* newmsg = static_cast<mqmessage*>(MXS_CALLOC(1, sizeof(mqmessage)));
|
||||
if (newmsg)
|
||||
{
|
||||
newmsg->msg = msg;
|
||||
@ -823,7 +829,7 @@ newSession(MXS_FILTER *instance, MXS_SESSION *session)
|
||||
|
||||
MQ_SESSION *my_session;
|
||||
|
||||
if ((my_session = MXS_CALLOC(1, sizeof(MQ_SESSION))) != NULL)
|
||||
if ((my_session = static_cast<MQ_SESSION*>(MXS_CALLOC(1, sizeof(MQ_SESSION)))) != NULL)
|
||||
{
|
||||
my_session->was_query = false;
|
||||
my_session->uid = NULL;
|
||||
@ -945,16 +951,16 @@ routeQuery(MXS_FILTER *instance, MXS_FILTER_SESSION *session, GWBUF *queue)
|
||||
amqp_basic_properties_t *prop;
|
||||
|
||||
/**The user is changing databases*/
|
||||
if (*((char*) (queue->start + 4)) == 0x02)
|
||||
if (*(static_cast<char*>(queue->start) + 4) == 0x02)
|
||||
{
|
||||
if (my_session->db)
|
||||
{
|
||||
MXS_FREE(my_session->db);
|
||||
}
|
||||
plen = pktlen(queue->start);
|
||||
my_session->db = MXS_CALLOC(plen, sizeof(char));
|
||||
my_session->db = static_cast<char*>(MXS_CALLOC(plen, sizeof(char)));
|
||||
MXS_ABORT_IF_NULL(my_session->db);
|
||||
memcpy(my_session->db, queue->start + 5, plen - 1);
|
||||
memcpy(my_session->db, static_cast<char*>(queue->start) + 5, plen - 1);
|
||||
}
|
||||
|
||||
if (modutil_is_SQL(queue))
|
||||
@ -1167,7 +1173,7 @@ routeQuery(MXS_FILTER *instance, MXS_FILTER_SESSION *session, GWBUF *queue)
|
||||
if (my_session->uid == NULL)
|
||||
{
|
||||
|
||||
my_session->uid = MXS_CALLOC(33, sizeof(char));
|
||||
my_session->uid = static_cast<char*>(MXS_CALLOC(33, sizeof(char)));
|
||||
|
||||
if (my_session->uid)
|
||||
{
|
||||
@ -1179,8 +1185,8 @@ routeQuery(MXS_FILTER *instance, MXS_FILTER_SESSION *session, GWBUF *queue)
|
||||
{
|
||||
|
||||
my_session->was_query = true;
|
||||
|
||||
if ((prop = MXS_MALLOC(sizeof(amqp_basic_properties_t))))
|
||||
prop = static_cast<amqp_basic_properties_t*>(MXS_MALLOC(sizeof(amqp_basic_properties_t)));
|
||||
if (prop)
|
||||
{
|
||||
prop->_flags = AMQP_BASIC_CONTENT_TYPE_FLAG |
|
||||
AMQP_BASIC_DELIVERY_MODE_FLAG |
|
||||
@ -1207,7 +1213,7 @@ routeQuery(MXS_FILTER *instance, MXS_FILTER_SESSION *session, GWBUF *queue)
|
||||
sprintf(t_buf, "%lu|", (unsigned long) time(NULL));
|
||||
|
||||
int qlen = strnlen(canon_q, length) + strnlen(t_buf, 128);
|
||||
combined = MXS_MALLOC((qlen + 1) * sizeof(char));
|
||||
combined = static_cast<char*>(MXS_MALLOC((qlen + 1) * sizeof(char)));
|
||||
MXS_ABORT_IF_NULL(combined);
|
||||
strcpy(combined, t_buf);
|
||||
strncat(combined, canon_q, length);
|
||||
@ -1303,7 +1309,7 @@ unsigned int consume_leitoi(unsigned char** c)
|
||||
char* consume_lestr(unsigned char** c)
|
||||
{
|
||||
unsigned int slen = consume_leitoi(c);
|
||||
char *str = MXS_CALLOC((slen + 1), sizeof(char));
|
||||
char *str = static_cast<char*>(MXS_CALLOC((slen + 1), sizeof(char)));
|
||||
if (str)
|
||||
{
|
||||
memcpy(str, *c, slen);
|
||||
@ -1354,7 +1360,7 @@ static int clientReply(MXS_FILTER* instance, MXS_FILTER_SESSION *session, GWBUF
|
||||
|
||||
if (pkt_len > 0)
|
||||
{
|
||||
if ((prop = MXS_MALLOC(sizeof(amqp_basic_properties_t))))
|
||||
if ((prop = static_cast<amqp_basic_properties_t*>(MXS_MALLOC(sizeof(amqp_basic_properties_t)))))
|
||||
{
|
||||
prop->_flags = AMQP_BASIC_CONTENT_TYPE_FLAG |
|
||||
AMQP_BASIC_DELIVERY_MODE_FLAG |
|
||||
@ -1366,7 +1372,7 @@ static int clientReply(MXS_FILTER* instance, MXS_FILTER_SESSION *session, GWBUF
|
||||
prop->message_id = amqp_cstring_bytes("reply");
|
||||
}
|
||||
|
||||
combined = MXS_CALLOC(GWBUF_LENGTH(reply) + 256, sizeof(char));
|
||||
combined = static_cast<char*>(MXS_CALLOC(GWBUF_LENGTH(reply) + 256, sizeof(char)));
|
||||
MXS_ABORT_IF_NULL(combined);
|
||||
|
||||
memset(t_buf, 0, 128);
|
||||
@ -1412,7 +1418,7 @@ static int clientReply(MXS_FILTER* instance, MXS_FILTER_SESSION *session, GWBUF
|
||||
{
|
||||
/**ERR packet*/
|
||||
sprintf(combined + offset, "ERROR - message: %.*s",
|
||||
(int) (reply->end - ((void*) (reply->sbuf->data + 13))),
|
||||
(int) (static_cast<unsigned char*>(reply->end) - (reply->sbuf->data + 13)),
|
||||
(char *) reply->sbuf->data + 13);
|
||||
packet_ok = 1;
|
||||
was_last = 1;
|
||||
@ -1435,7 +1441,7 @@ static int clientReply(MXS_FILTER* instance, MXS_FILTER_SESSION *session, GWBUF
|
||||
char *tmp;
|
||||
unsigned int col_cnt = consume_leitoi(&rset);
|
||||
|
||||
tmp = MXS_CALLOC(256, sizeof(char));
|
||||
tmp = static_cast<char*>(MXS_CALLOC(256, sizeof(char)));
|
||||
MXS_ABORT_IF_NULL(tmp);
|
||||
sprintf(tmp, "Columns: %d", col_cnt);
|
||||
memcpy(combined + offset, tmp, strnlen(tmp, 256));
|
@ -1,4 +1,4 @@
|
||||
add_library(regexfilter SHARED regexfilter.c)
|
||||
add_library(regexfilter SHARED regexfilter.cc)
|
||||
target_link_libraries(regexfilter maxscale-common)
|
||||
add_dependencies(regexfilter pcre2)
|
||||
set_target_properties(regexfilter PROPERTIES VERSION "1.1.0")
|
||||
|
@ -82,7 +82,7 @@ typedef struct
|
||||
int active; /* Is filter active */
|
||||
} REGEX_SESSION;
|
||||
|
||||
void log_match(REGEX_INSTANCE* inst, char* re, char* old, char* new);
|
||||
void log_match(REGEX_INSTANCE* inst, char* re, char* old, char* newsql);
|
||||
void log_nomatch(REGEX_INSTANCE* inst, char* re, char* old);
|
||||
|
||||
static const MXS_ENUM_VALUE option_values[] =
|
||||
@ -92,6 +92,9 @@ static const MXS_ENUM_VALUE option_values[] =
|
||||
{NULL}
|
||||
};
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
/**
|
||||
* The module entry point routine. It is this routine that
|
||||
* must populate the structure that is referred to as the
|
||||
@ -146,6 +149,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
return &info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Free a regexfilter instance.
|
||||
* @param instance instance to free
|
||||
@ -185,7 +190,7 @@ void free_instance(REGEX_INSTANCE *instance)
|
||||
static MXS_FILTER *
|
||||
createInstance(const char *name, char **options, MXS_CONFIG_PARAMETER *params)
|
||||
{
|
||||
REGEX_INSTANCE *my_instance = MXS_CALLOC(1, sizeof(REGEX_INSTANCE));
|
||||
REGEX_INSTANCE *my_instance = static_cast<REGEX_INSTANCE*>(MXS_CALLOC(1, sizeof(REGEX_INSTANCE)));
|
||||
|
||||
if (my_instance)
|
||||
{
|
||||
@ -256,7 +261,7 @@ newSession(MXS_FILTER *instance, MXS_SESSION *session)
|
||||
REGEX_SESSION *my_session;
|
||||
const char *remote, *user;
|
||||
|
||||
if ((my_session = MXS_CALLOC(1, sizeof(REGEX_SESSION))) != NULL)
|
||||
if ((my_session = static_cast<REGEX_SESSION*>(MXS_CALLOC(1, sizeof(REGEX_SESSION)))) != NULL)
|
||||
{
|
||||
my_session->no_change = 0;
|
||||
my_session->replacements = 0;
|
||||
@ -467,7 +472,7 @@ regex_replace(const char *sql, pcre2_code *re, pcre2_match_data *match_data, con
|
||||
if (pcre2_match(re, (PCRE2_SPTR) sql, PCRE2_ZERO_TERMINATED, 0, 0, match_data, NULL) > 0)
|
||||
{
|
||||
result_size = strlen(sql) + strlen(replace);
|
||||
result = MXS_MALLOC(result_size);
|
||||
result = static_cast<char*>(MXS_MALLOC(result_size));
|
||||
|
||||
size_t result_size_tmp = result_size;
|
||||
while (result &&
|
||||
@ -478,7 +483,7 @@ regex_replace(const char *sql, pcre2_code *re, pcre2_match_data *match_data, con
|
||||
{
|
||||
result_size_tmp = 1.5 * result_size;
|
||||
char *tmp;
|
||||
if ((tmp = MXS_REALLOC(result, result_size_tmp)) == NULL)
|
||||
if ((tmp = static_cast<char*>(MXS_REALLOC(result, result_size_tmp))) == NULL)
|
||||
{
|
||||
MXS_FREE(result);
|
||||
result = NULL;
|
||||
@ -498,16 +503,16 @@ regex_replace(const char *sql, pcre2_code *re, pcre2_match_data *match_data, con
|
||||
* @param old Old SQL statement
|
||||
* @param new New SQL statement
|
||||
*/
|
||||
void log_match(REGEX_INSTANCE* inst, char* re, char* old, char* new)
|
||||
void log_match(REGEX_INSTANCE* inst, char* re, char* old, char* newsql)
|
||||
{
|
||||
if (inst->logfile)
|
||||
{
|
||||
fprintf(inst->logfile, "Matched %s: [%s] -> [%s]\n", re, old, new);
|
||||
fprintf(inst->logfile, "Matched %s: [%s] -> [%s]\n", re, old, newsql);
|
||||
fflush(inst->logfile);
|
||||
}
|
||||
if (inst->log_trace)
|
||||
{
|
||||
MXS_INFO("Match %s: [%s] -> [%s]", re, old, new);
|
||||
MXS_INFO("Match %s: [%s] -> [%s]", re, old, newsql);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
add_library(topfilter SHARED topfilter.c)
|
||||
add_library(topfilter SHARED topfilter.cc)
|
||||
target_link_libraries(topfilter maxscale-common)
|
||||
set_target_properties(topfilter PROPERTIES VERSION "1.0.1")
|
||||
install_module(topfilter core)
|
||||
|
@ -126,6 +126,9 @@ static const MXS_ENUM_VALUE option_values[] =
|
||||
{NULL}
|
||||
};
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
/**
|
||||
* The module entry point routine. It is this routine that
|
||||
* must populate the structure that is referred to as the
|
||||
@ -185,6 +188,9 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
|
||||
return &info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the filter for a particular service
|
||||
* within MaxScale.
|
||||
@ -276,7 +282,7 @@ newSession(MXS_FILTER *instance, MXS_SESSION *session)
|
||||
int i;
|
||||
const char *remote, *user;
|
||||
|
||||
if ((my_session = MXS_CALLOC(1, sizeof(TOPN_SESSION))) != NULL)
|
||||
if ((my_session = static_cast<TOPN_SESSION*>(MXS_CALLOC(1, sizeof(TOPN_SESSION)))) != NULL)
|
||||
{
|
||||
if ((my_session->filename =
|
||||
(char *) MXS_MALLOC(strlen(my_instance->filebase) + 20))
|
@ -1,4 +1,4 @@
|
||||
add_library(tpmfilter SHARED tpmfilter.c)
|
||||
add_library(tpmfilter SHARED tpmfilter.cc)
|
||||
target_link_libraries(tpmfilter maxscale-common)
|
||||
set_target_properties(tpmfilter PROPERTIES VERSION "1.0.0")
|
||||
install_module(tpmfilter experimental)
|
||||
|
@ -67,7 +67,7 @@
|
||||
/* The maximum size for query statements in a transaction (64MB) */
|
||||
static size_t sql_size_limit = 64 * 1024 * 1024;
|
||||
/* The size of the buffer for recording latency of individual statements */
|
||||
static size_t latency_buf_size = 64 * 1024;
|
||||
static int latency_buf_size = 64 * 1024;
|
||||
static const int default_sql_size = 4 * 1024;
|
||||
|
||||
#define DEFAULT_QUERY_DELIMITER "@@@"
|
||||
@ -140,6 +140,9 @@ typedef struct
|
||||
size_t max_sql_size;
|
||||
} TPM_SESSION;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
/**
|
||||
* The module entry point routine. It is this routine that
|
||||
* must populate the structure that is referred to as the
|
||||
@ -193,6 +196,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
return &info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the filter for a particular service
|
||||
* within MaxScale.
|
||||
@ -205,7 +210,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
static MXS_FILTER *
|
||||
createInstance(const char *name, char **options, MXS_CONFIG_PARAMETER *params)
|
||||
{
|
||||
TPM_INSTANCE *my_instance = MXS_CALLOC(1, sizeof(TPM_INSTANCE));
|
||||
TPM_INSTANCE *my_instance = static_cast<TPM_INSTANCE*>(MXS_CALLOC(1, sizeof(TPM_INSTANCE)));
|
||||
|
||||
if (my_instance)
|
||||
{
|
||||
@ -310,7 +315,7 @@ newSession(MXS_FILTER *instance, MXS_SESSION *session)
|
||||
int i;
|
||||
const char *remote, *user;
|
||||
|
||||
if ((my_session = MXS_CALLOC(1, sizeof(TPM_SESSION))) != NULL)
|
||||
if ((my_session = static_cast<TPM_SESSION*>(MXS_CALLOC(1, sizeof(TPM_SESSION)))) != NULL)
|
||||
{
|
||||
atomic_add(&my_instance->sessions, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user