Run astyle on httpd.c and maxinfo_exec.c
This commit is contained in:
@ -39,9 +39,9 @@
|
||||
#include <log_manager.h>
|
||||
#include <resultset.h>
|
||||
|
||||
/* @see function load_module in load_utils.c for explanation of the following
|
||||
/* @see function load_module in load_utils.c for explanation of the following
|
||||
* lint directives.
|
||||
*/
|
||||
*/
|
||||
/*lint -e14 */
|
||||
MODULE_INFO info =
|
||||
{
|
||||
@ -145,9 +145,9 @@ static int httpd_read_event(DCB* dcb)
|
||||
SESSION *session = dcb->session;
|
||||
|
||||
int numchars = 1;
|
||||
char buf[HTTPD_REQUESTLINE_MAXLEN-1] = "";
|
||||
char buf[HTTPD_REQUESTLINE_MAXLEN - 1] = "";
|
||||
char *query_string = NULL;
|
||||
char method[HTTPD_METHOD_MAXLEN-1] = "";
|
||||
char method[HTTPD_METHOD_MAXLEN - 1] = "";
|
||||
char url[HTTPD_SMALL_BUFFER] = "";
|
||||
size_t i, j;
|
||||
int headers_read = 0;
|
||||
@ -163,11 +163,13 @@ static int httpd_read_event(DCB* dcb)
|
||||
|
||||
numchars = httpd_get_line(dcb->fd, buf, sizeof(buf));
|
||||
|
||||
i = 0; j = 0;
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (!ISspace(buf[j]) && (i < sizeof(method) - 1))
|
||||
{
|
||||
method[i] = buf[j];
|
||||
i++; j++;
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
method[i] = '\0';
|
||||
|
||||
@ -190,7 +192,8 @@ static int httpd_read_event(DCB* dcb)
|
||||
while ((j < sizeof(buf) - 1) && !ISspace(buf[j]) && (i < sizeof(url) - 1))
|
||||
{
|
||||
url[i] = buf[j];
|
||||
i++; j++;
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
|
||||
url[i] = '\0';
|
||||
@ -225,7 +228,7 @@ static int httpd_read_event(DCB* dcb)
|
||||
{
|
||||
*value = '\0';
|
||||
value++;
|
||||
end = &value[strlen(value) -1];
|
||||
end = &value[strlen(value) - 1];
|
||||
*end = '\0';
|
||||
|
||||
if (strncasecmp(buf, "Hostname", 6) == 0)
|
||||
|
@ -110,10 +110,12 @@ maxinfo_execute(DCB *dcb, MAXINFO_TREE *tree)
|
||||
static void
|
||||
exec_show_services(DCB *dcb, MAXINFO_TREE *tree)
|
||||
{
|
||||
RESULTSET *set;
|
||||
RESULTSET *set;
|
||||
|
||||
if ((set = serviceGetList()) == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
resultset_stream_mysql(set, dcb);
|
||||
resultset_free(set);
|
||||
@ -128,10 +130,12 @@ RESULTSET *set;
|
||||
static void
|
||||
exec_show_listeners(DCB *dcb, MAXINFO_TREE *tree)
|
||||
{
|
||||
RESULTSET *set;
|
||||
RESULTSET *set;
|
||||
|
||||
if ((set = serviceGetListenerList()) == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
resultset_stream_mysql(set, dcb);
|
||||
resultset_free(set);
|
||||
@ -146,10 +150,12 @@ RESULTSET *set;
|
||||
static void
|
||||
exec_show_sessions(DCB *dcb, MAXINFO_TREE *tree)
|
||||
{
|
||||
RESULTSET *set;
|
||||
RESULTSET *set;
|
||||
|
||||
if ((set = sessionGetList(SESSION_LIST_ALL)) == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
resultset_stream_mysql(set, dcb);
|
||||
resultset_free(set);
|
||||
@ -164,10 +170,12 @@ RESULTSET *set;
|
||||
static void
|
||||
exec_show_clients(DCB *dcb, MAXINFO_TREE *tree)
|
||||
{
|
||||
RESULTSET *set;
|
||||
RESULTSET *set;
|
||||
|
||||
if ((set = sessionGetList(SESSION_LIST_CONNECTION)) == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
resultset_stream_mysql(set, dcb);
|
||||
resultset_free(set);
|
||||
@ -182,10 +190,12 @@ RESULTSET *set;
|
||||
static void
|
||||
exec_show_servers(DCB *dcb, MAXINFO_TREE *tree)
|
||||
{
|
||||
RESULTSET *set;
|
||||
RESULTSET *set;
|
||||
|
||||
if ((set = serverGetList()) == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
resultset_stream_mysql(set, dcb);
|
||||
resultset_free(set);
|
||||
@ -200,10 +210,12 @@ RESULTSET *set;
|
||||
static void
|
||||
exec_show_modules(DCB *dcb, MAXINFO_TREE *tree)
|
||||
{
|
||||
RESULTSET *set;
|
||||
RESULTSET *set;
|
||||
|
||||
if ((set = moduleGetList()) == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
resultset_stream_mysql(set, dcb);
|
||||
resultset_free(set);
|
||||
@ -218,10 +230,12 @@ RESULTSET *set;
|
||||
static void
|
||||
exec_show_monitors(DCB *dcb, MAXINFO_TREE *tree)
|
||||
{
|
||||
RESULTSET *set;
|
||||
RESULTSET *set;
|
||||
|
||||
if ((set = monitorGetList()) == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
resultset_stream_mysql(set, dcb);
|
||||
resultset_free(set);
|
||||
@ -236,10 +250,12 @@ RESULTSET *set;
|
||||
static void
|
||||
exec_show_eventTimes(DCB *dcb, MAXINFO_TREE *tree)
|
||||
{
|
||||
RESULTSET *set;
|
||||
RESULTSET *set;
|
||||
|
||||
if ((set = eventTimesGetList()) == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
resultset_stream_mysql(set, dcb);
|
||||
resultset_free(set);
|
||||
@ -248,10 +264,12 @@ RESULTSET *set;
|
||||
/**
|
||||
* The table of show commands that are supported
|
||||
*/
|
||||
static struct {
|
||||
static struct
|
||||
{
|
||||
char *name;
|
||||
void (*func)(DCB *, MAXINFO_TREE *);
|
||||
} show_commands[] = {
|
||||
} show_commands[] =
|
||||
{
|
||||
{ "variables", exec_show_variables },
|
||||
{ "status", exec_show_status },
|
||||
{ "services", exec_show_services },
|
||||
@ -274,8 +292,8 @@ static struct {
|
||||
static void
|
||||
exec_show(DCB *dcb, MAXINFO_TREE *tree)
|
||||
{
|
||||
int i;
|
||||
char errmsg[120];
|
||||
int i;
|
||||
char errmsg[120];
|
||||
|
||||
for (i = 0; show_commands[i].name; i++)
|
||||
{
|
||||
@ -286,7 +304,9 @@ char errmsg[120];
|
||||
}
|
||||
}
|
||||
if (strlen(tree->value) > 80) // Prevent buffer overrun
|
||||
{
|
||||
tree->value[80] = 0;
|
||||
}
|
||||
sprintf(errmsg, "Unsupported show command '%s'", tree->value);
|
||||
maxinfo_send_error(dcb, 0, errmsg);
|
||||
MXS_NOTICE("%s", errmsg);
|
||||
@ -310,7 +330,8 @@ static struct
|
||||
{
|
||||
char *name;
|
||||
void (*func)(DCB *, MAXINFO_TREE *);
|
||||
} flush_commands[] = {
|
||||
} flush_commands[] =
|
||||
{
|
||||
{ "logs", exec_flush_logs},
|
||||
{ NULL, NULL}
|
||||
};
|
||||
@ -390,7 +411,8 @@ static struct
|
||||
{
|
||||
char *name;
|
||||
void (*func)(DCB *, MAXINFO_TREE *);
|
||||
} set_commands[] = {
|
||||
} set_commands[] =
|
||||
{
|
||||
{ "server", exec_set_server},
|
||||
{ NULL, NULL}
|
||||
};
|
||||
@ -470,7 +492,8 @@ static struct
|
||||
{
|
||||
char *name;
|
||||
void (*func)(DCB *, MAXINFO_TREE *);
|
||||
} clear_commands[] = {
|
||||
} clear_commands[] =
|
||||
{
|
||||
{ "server", exec_clear_server},
|
||||
{ NULL, NULL}
|
||||
};
|
||||
@ -590,7 +613,8 @@ static struct
|
||||
{
|
||||
char *name;
|
||||
void (*func)(DCB *, MAXINFO_TREE *);
|
||||
} shutdown_commands[] = {
|
||||
} shutdown_commands[] =
|
||||
{
|
||||
{ "maxscale", exec_shutdown_maxscale},
|
||||
{ "monitor", exec_shutdown_monitor},
|
||||
{ "service", exec_shutdown_service},
|
||||
@ -699,7 +723,8 @@ static struct
|
||||
{
|
||||
char *name;
|
||||
void (*func)(DCB *, MAXINFO_TREE *);
|
||||
} restart_commands[] = {
|
||||
} restart_commands[] =
|
||||
{
|
||||
{ "monitor", exec_restart_monitor},
|
||||
{ "service", exec_restart_service},
|
||||
{ NULL, NULL}
|
||||
@ -776,11 +801,13 @@ typedef void *(*STATSFUNC)();
|
||||
/**
|
||||
* Variables that may be sent in a show variables
|
||||
*/
|
||||
static struct {
|
||||
static struct
|
||||
{
|
||||
char *name;
|
||||
int type;
|
||||
STATSFUNC func;
|
||||
} variables[] = {
|
||||
} variables[] =
|
||||
{
|
||||
{ "version", VT_STRING, (STATSFUNC)getVersion },
|
||||
{ "version_comment", VT_STRING, (STATSFUNC)getVersionComment },
|
||||
{ "basedir", VT_STRING, (STATSFUNC)getMaxScaleHome},
|
||||
@ -793,7 +820,8 @@ static struct {
|
||||
{ NULL, 0, NULL }
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int index;
|
||||
char *like;
|
||||
} VARCONTEXT;
|
||||
@ -808,9 +836,9 @@ typedef struct {
|
||||
static RESULT_ROW *
|
||||
variable_row(RESULTSET *result, void *data)
|
||||
{
|
||||
VARCONTEXT *context = (VARCONTEXT *)data;
|
||||
RESULT_ROW *row;
|
||||
char buf[80];
|
||||
VARCONTEXT *context = (VARCONTEXT *)data;
|
||||
RESULT_ROW *row;
|
||||
char buf[80];
|
||||
|
||||
if (variables[context->index].name)
|
||||
{
|
||||
@ -850,13 +878,17 @@ char buf[80];
|
||||
static void
|
||||
exec_show_variables(DCB *dcb, MAXINFO_TREE *filter)
|
||||
{
|
||||
RESULTSET *result;
|
||||
VARCONTEXT context;
|
||||
RESULTSET *result;
|
||||
VARCONTEXT context;
|
||||
|
||||
if (filter)
|
||||
{
|
||||
context.like = filter->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.like = NULL;
|
||||
}
|
||||
context.index = 0;
|
||||
|
||||
if ((result = resultset_create(variable_row, &context)) == NULL)
|
||||
@ -878,8 +910,8 @@ VARCONTEXT context;
|
||||
RESULTSET *
|
||||
maxinfo_variables()
|
||||
{
|
||||
RESULTSET *result;
|
||||
static VARCONTEXT context;
|
||||
RESULTSET *result;
|
||||
static VARCONTEXT context;
|
||||
|
||||
context.like = NULL;
|
||||
context.index = 0;
|
||||
@ -1040,11 +1072,13 @@ maxinfo_max_event_exec_time()
|
||||
/**
|
||||
* Variables that may be sent in a show status
|
||||
*/
|
||||
static struct {
|
||||
static struct
|
||||
{
|
||||
char *name;
|
||||
int type;
|
||||
STATSFUNC func;
|
||||
} status[] = {
|
||||
} status[] =
|
||||
{
|
||||
{ "Uptime", VT_INT, (STATSFUNC)maxscale_uptime },
|
||||
{ "Uptime_since_flush_status", VT_INT, (STATSFUNC)maxscale_uptime },
|
||||
{ "Threads_created", VT_INT, (STATSFUNC)config_threadcount },
|
||||
@ -1080,9 +1114,9 @@ static struct {
|
||||
static RESULT_ROW *
|
||||
status_row(RESULTSET *result, void *data)
|
||||
{
|
||||
VARCONTEXT *context = (VARCONTEXT *)data;
|
||||
RESULT_ROW *row;
|
||||
char buf[80];
|
||||
VARCONTEXT *context = (VARCONTEXT *)data;
|
||||
RESULT_ROW *row;
|
||||
char buf[80];
|
||||
|
||||
if (status[context->index].name)
|
||||
{
|
||||
@ -1122,13 +1156,17 @@ char buf[80];
|
||||
static void
|
||||
exec_show_status(DCB *dcb, MAXINFO_TREE *filter)
|
||||
{
|
||||
RESULTSET *result;
|
||||
VARCONTEXT context;
|
||||
RESULTSET *result;
|
||||
VARCONTEXT context;
|
||||
|
||||
if (filter)
|
||||
{
|
||||
context.like = filter->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.like = NULL;
|
||||
}
|
||||
context.index = 0;
|
||||
|
||||
if ((result = resultset_create(status_row, &context)) == NULL)
|
||||
@ -1150,8 +1188,8 @@ VARCONTEXT context;
|
||||
RESULTSET *
|
||||
maxinfo_status()
|
||||
{
|
||||
RESULTSET *result;
|
||||
static VARCONTEXT context;
|
||||
RESULTSET *result;
|
||||
static VARCONTEXT context;
|
||||
|
||||
context.like = NULL;
|
||||
context.index = 0;
|
||||
@ -1189,9 +1227,9 @@ exec_select(DCB *dcb, MAXINFO_TREE *tree)
|
||||
static int
|
||||
maxinfo_pattern_match(char *pattern, char *str)
|
||||
{
|
||||
int anchor = 0, len, trailing;
|
||||
char *fixed;
|
||||
extern char *strcasestr();
|
||||
int anchor = 0, len, trailing;
|
||||
char *fixed;
|
||||
extern char *strcasestr();
|
||||
|
||||
if (*pattern != '%')
|
||||
{
|
||||
@ -1204,13 +1242,21 @@ extern char *strcasestr();
|
||||
}
|
||||
len = strlen(fixed);
|
||||
if (fixed[len - 1] == '%')
|
||||
{
|
||||
trailing = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
trailing = 0;
|
||||
}
|
||||
if (anchor == 1 && trailing == 0) // No wildcard
|
||||
{
|
||||
return strcasecmp(pattern, str);
|
||||
}
|
||||
else if (anchor == 1)
|
||||
{
|
||||
return strncasecmp(str, pattern, len - trailing);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *portion = malloc(len + 1);
|
||||
@ -1229,7 +1275,8 @@ extern char *strcasestr();
|
||||
*/
|
||||
void maxinfo_send_ok(DCB *dcb)
|
||||
{
|
||||
static const char ok_packet[] ={
|
||||
static const char ok_packet[] =
|
||||
{
|
||||
0x07, 0x00, 0x00, 0x01,
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
|
Reference in New Issue
Block a user