Formatted qlafilter

Qlafilter formatted according to the style guide.
This commit is contained in:
Markus Makela
2015-11-18 14:31:02 +02:00
parent a7c0952e66
commit 036fd6f16c

View File

@ -38,6 +38,7 @@
*
* @endverbatim
*/
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
@ -52,7 +53,8 @@
#include <string.h>
#include <atomic.h>
MODULE_INFO info = {
MODULE_INFO info =
{
MODULE_API_FILTER,
MODULE_GA,
FILTER_VERSION,
@ -73,7 +75,8 @@ static int routeQuery(FILTER *instance, void *fsession, GWBUF *queue);
static void diagnostic(FILTER *instance, void *fsession, DCB *dcb);
static FILTER_OBJECT MyObject = {
static FILTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
@ -93,7 +96,8 @@ static FILTER_OBJECT MyObject = {
* To this base a session number is attached such that each session will
* have a unique name.
*/
typedef struct {
typedef struct
{
int sessions; /* The count of sessions */
char *filebase; /* The filename base */
char *source; /* The source of the client connection */
@ -112,7 +116,8 @@ typedef struct {
*
* It also holds the file descriptor to which queries are written.
*/
typedef struct {
typedef struct
{
DOWNSTREAM down;
char *filename;
FILE *fp;
@ -170,9 +175,12 @@ int i;
if ((my_instance = calloc(1, sizeof(QLA_INSTANCE))) != NULL)
{
if (options){
if (options)
{
my_instance->filebase = strdup(options[0]);
}else{
}
else
{
my_instance->filebase = strdup("qla");
}
my_instance->source = NULL;
@ -192,12 +200,17 @@ int i;
my_instance->nomatch = strdup(params[i]->value);
}
else if (!strcmp(params[i]->name, "source"))
{
my_instance->source = strdup(params[i]->value);
}
else if (!strcmp(params[i]->name, "user"))
{
my_instance->userName = strdup(params[i]->value);
}
else if (!strcmp(params[i]->name, "filebase"))
{
if (my_instance->filebase){
if (my_instance->filebase)
{
free(my_instance->filebase);
my_instance->filebase = NULL;
}
@ -219,7 +232,8 @@ int i;
my_instance->match);
free(my_instance->match);
free(my_instance->source);
if(my_instance->filebase){
if (my_instance->filebase)
{
free(my_instance->filebase);
}
free(my_instance);
@ -233,10 +247,13 @@ int i;
" for the nomatch paramter.",
my_instance->match);
if (my_instance->match)
{
regfree(&my_instance->re);
}
free(my_instance->match);
free(my_instance->source);
if(my_instance->filebase){
if (my_instance->filebase)
{
free(my_instance->filebase);
}
free(my_instance);
@ -282,8 +299,10 @@ char *remote, *userName;
&& (remote = session_get_remote(session)) != NULL)
{
if (strcmp(remote, my_instance->source))
{
my_session->active = 0;
}
}
userName = session_getUser(session);
if (my_instance->userName &&
@ -341,8 +360,10 @@ closeSession(FILTER *instance, void *session)
QLA_SESSION *my_session = (QLA_SESSION *) session;
if (my_session->active && my_session->fp)
{
fclose(my_session->fp);
}
}
/**
* Free the memory associated with the session
@ -449,15 +470,23 @@ QLA_SESSION *my_session = (QLA_SESSION *)fsession;
my_session->filename);
}
if (my_instance->source)
{
dcb_printf(dcb, "\t\tLimit logging to connections from %s\n",
my_instance->source);
}
if (my_instance->userName)
{
dcb_printf(dcb, "\t\tLimit logging to user %s\n",
my_instance->userName);
}
if (my_instance->match)
{
dcb_printf(dcb, "\t\tInclude queries that match %s\n",
my_instance->match);
}
if (my_instance->nomatch)
{
dcb_printf(dcb, "\t\tExclude queries that match %s\n",
my_instance->nomatch);
}
}