Run astyle on httpd.c and maxinfo_exec.c
This commit is contained in:
@ -163,11 +163,13 @@ static int httpd_read_event(DCB* dcb)
|
|||||||
|
|
||||||
numchars = httpd_get_line(dcb->fd, buf, sizeof(buf));
|
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))
|
while (!ISspace(buf[j]) && (i < sizeof(method) - 1))
|
||||||
{
|
{
|
||||||
method[i] = buf[j];
|
method[i] = buf[j];
|
||||||
i++; j++;
|
i++;
|
||||||
|
j++;
|
||||||
}
|
}
|
||||||
method[i] = '\0';
|
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))
|
while ((j < sizeof(buf) - 1) && !ISspace(buf[j]) && (i < sizeof(url) - 1))
|
||||||
{
|
{
|
||||||
url[i] = buf[j];
|
url[i] = buf[j];
|
||||||
i++; j++;
|
i++;
|
||||||
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
url[i] = '\0';
|
url[i] = '\0';
|
||||||
|
|||||||
@ -113,7 +113,9 @@ exec_show_services(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
RESULTSET *set;
|
RESULTSET *set;
|
||||||
|
|
||||||
if ((set = serviceGetList()) == NULL)
|
if ((set = serviceGetList()) == NULL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
resultset_stream_mysql(set, dcb);
|
resultset_stream_mysql(set, dcb);
|
||||||
resultset_free(set);
|
resultset_free(set);
|
||||||
@ -131,7 +133,9 @@ exec_show_listeners(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
RESULTSET *set;
|
RESULTSET *set;
|
||||||
|
|
||||||
if ((set = serviceGetListenerList()) == NULL)
|
if ((set = serviceGetListenerList()) == NULL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
resultset_stream_mysql(set, dcb);
|
resultset_stream_mysql(set, dcb);
|
||||||
resultset_free(set);
|
resultset_free(set);
|
||||||
@ -149,7 +153,9 @@ exec_show_sessions(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
RESULTSET *set;
|
RESULTSET *set;
|
||||||
|
|
||||||
if ((set = sessionGetList(SESSION_LIST_ALL)) == NULL)
|
if ((set = sessionGetList(SESSION_LIST_ALL)) == NULL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
resultset_stream_mysql(set, dcb);
|
resultset_stream_mysql(set, dcb);
|
||||||
resultset_free(set);
|
resultset_free(set);
|
||||||
@ -167,7 +173,9 @@ exec_show_clients(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
RESULTSET *set;
|
RESULTSET *set;
|
||||||
|
|
||||||
if ((set = sessionGetList(SESSION_LIST_CONNECTION)) == NULL)
|
if ((set = sessionGetList(SESSION_LIST_CONNECTION)) == NULL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
resultset_stream_mysql(set, dcb);
|
resultset_stream_mysql(set, dcb);
|
||||||
resultset_free(set);
|
resultset_free(set);
|
||||||
@ -185,7 +193,9 @@ exec_show_servers(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
RESULTSET *set;
|
RESULTSET *set;
|
||||||
|
|
||||||
if ((set = serverGetList()) == NULL)
|
if ((set = serverGetList()) == NULL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
resultset_stream_mysql(set, dcb);
|
resultset_stream_mysql(set, dcb);
|
||||||
resultset_free(set);
|
resultset_free(set);
|
||||||
@ -203,7 +213,9 @@ exec_show_modules(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
RESULTSET *set;
|
RESULTSET *set;
|
||||||
|
|
||||||
if ((set = moduleGetList()) == NULL)
|
if ((set = moduleGetList()) == NULL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
resultset_stream_mysql(set, dcb);
|
resultset_stream_mysql(set, dcb);
|
||||||
resultset_free(set);
|
resultset_free(set);
|
||||||
@ -221,7 +233,9 @@ exec_show_monitors(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
RESULTSET *set;
|
RESULTSET *set;
|
||||||
|
|
||||||
if ((set = monitorGetList()) == NULL)
|
if ((set = monitorGetList()) == NULL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
resultset_stream_mysql(set, dcb);
|
resultset_stream_mysql(set, dcb);
|
||||||
resultset_free(set);
|
resultset_free(set);
|
||||||
@ -239,7 +253,9 @@ exec_show_eventTimes(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
RESULTSET *set;
|
RESULTSET *set;
|
||||||
|
|
||||||
if ((set = eventTimesGetList()) == NULL)
|
if ((set = eventTimesGetList()) == NULL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
resultset_stream_mysql(set, dcb);
|
resultset_stream_mysql(set, dcb);
|
||||||
resultset_free(set);
|
resultset_free(set);
|
||||||
@ -248,10 +264,12 @@ RESULTSET *set;
|
|||||||
/**
|
/**
|
||||||
* The table of show commands that are supported
|
* The table of show commands that are supported
|
||||||
*/
|
*/
|
||||||
static struct {
|
static struct
|
||||||
|
{
|
||||||
char *name;
|
char *name;
|
||||||
void (*func)(DCB *, MAXINFO_TREE *);
|
void (*func)(DCB *, MAXINFO_TREE *);
|
||||||
} show_commands[] = {
|
} show_commands[] =
|
||||||
|
{
|
||||||
{ "variables", exec_show_variables },
|
{ "variables", exec_show_variables },
|
||||||
{ "status", exec_show_status },
|
{ "status", exec_show_status },
|
||||||
{ "services", exec_show_services },
|
{ "services", exec_show_services },
|
||||||
@ -286,7 +304,9 @@ char errmsg[120];
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strlen(tree->value) > 80) // Prevent buffer overrun
|
if (strlen(tree->value) > 80) // Prevent buffer overrun
|
||||||
|
{
|
||||||
tree->value[80] = 0;
|
tree->value[80] = 0;
|
||||||
|
}
|
||||||
sprintf(errmsg, "Unsupported show command '%s'", tree->value);
|
sprintf(errmsg, "Unsupported show command '%s'", tree->value);
|
||||||
maxinfo_send_error(dcb, 0, errmsg);
|
maxinfo_send_error(dcb, 0, errmsg);
|
||||||
MXS_NOTICE("%s", errmsg);
|
MXS_NOTICE("%s", errmsg);
|
||||||
@ -310,7 +330,8 @@ static struct
|
|||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
void (*func)(DCB *, MAXINFO_TREE *);
|
void (*func)(DCB *, MAXINFO_TREE *);
|
||||||
} flush_commands[] = {
|
} flush_commands[] =
|
||||||
|
{
|
||||||
{ "logs", exec_flush_logs},
|
{ "logs", exec_flush_logs},
|
||||||
{ NULL, NULL}
|
{ NULL, NULL}
|
||||||
};
|
};
|
||||||
@ -390,7 +411,8 @@ static struct
|
|||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
void (*func)(DCB *, MAXINFO_TREE *);
|
void (*func)(DCB *, MAXINFO_TREE *);
|
||||||
} set_commands[] = {
|
} set_commands[] =
|
||||||
|
{
|
||||||
{ "server", exec_set_server},
|
{ "server", exec_set_server},
|
||||||
{ NULL, NULL}
|
{ NULL, NULL}
|
||||||
};
|
};
|
||||||
@ -470,7 +492,8 @@ static struct
|
|||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
void (*func)(DCB *, MAXINFO_TREE *);
|
void (*func)(DCB *, MAXINFO_TREE *);
|
||||||
} clear_commands[] = {
|
} clear_commands[] =
|
||||||
|
{
|
||||||
{ "server", exec_clear_server},
|
{ "server", exec_clear_server},
|
||||||
{ NULL, NULL}
|
{ NULL, NULL}
|
||||||
};
|
};
|
||||||
@ -590,7 +613,8 @@ static struct
|
|||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
void (*func)(DCB *, MAXINFO_TREE *);
|
void (*func)(DCB *, MAXINFO_TREE *);
|
||||||
} shutdown_commands[] = {
|
} shutdown_commands[] =
|
||||||
|
{
|
||||||
{ "maxscale", exec_shutdown_maxscale},
|
{ "maxscale", exec_shutdown_maxscale},
|
||||||
{ "monitor", exec_shutdown_monitor},
|
{ "monitor", exec_shutdown_monitor},
|
||||||
{ "service", exec_shutdown_service},
|
{ "service", exec_shutdown_service},
|
||||||
@ -699,7 +723,8 @@ static struct
|
|||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
void (*func)(DCB *, MAXINFO_TREE *);
|
void (*func)(DCB *, MAXINFO_TREE *);
|
||||||
} restart_commands[] = {
|
} restart_commands[] =
|
||||||
|
{
|
||||||
{ "monitor", exec_restart_monitor},
|
{ "monitor", exec_restart_monitor},
|
||||||
{ "service", exec_restart_service},
|
{ "service", exec_restart_service},
|
||||||
{ NULL, NULL}
|
{ NULL, NULL}
|
||||||
@ -776,11 +801,13 @@ typedef void *(*STATSFUNC)();
|
|||||||
/**
|
/**
|
||||||
* Variables that may be sent in a show variables
|
* Variables that may be sent in a show variables
|
||||||
*/
|
*/
|
||||||
static struct {
|
static struct
|
||||||
|
{
|
||||||
char *name;
|
char *name;
|
||||||
int type;
|
int type;
|
||||||
STATSFUNC func;
|
STATSFUNC func;
|
||||||
} variables[] = {
|
} variables[] =
|
||||||
|
{
|
||||||
{ "version", VT_STRING, (STATSFUNC)getVersion },
|
{ "version", VT_STRING, (STATSFUNC)getVersion },
|
||||||
{ "version_comment", VT_STRING, (STATSFUNC)getVersionComment },
|
{ "version_comment", VT_STRING, (STATSFUNC)getVersionComment },
|
||||||
{ "basedir", VT_STRING, (STATSFUNC)getMaxScaleHome},
|
{ "basedir", VT_STRING, (STATSFUNC)getMaxScaleHome},
|
||||||
@ -793,7 +820,8 @@ static struct {
|
|||||||
{ NULL, 0, NULL }
|
{ NULL, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
int index;
|
int index;
|
||||||
char *like;
|
char *like;
|
||||||
} VARCONTEXT;
|
} VARCONTEXT;
|
||||||
@ -854,9 +882,13 @@ RESULTSET *result;
|
|||||||
VARCONTEXT context;
|
VARCONTEXT context;
|
||||||
|
|
||||||
if (filter)
|
if (filter)
|
||||||
|
{
|
||||||
context.like = filter->value;
|
context.like = filter->value;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
context.like = NULL;
|
context.like = NULL;
|
||||||
|
}
|
||||||
context.index = 0;
|
context.index = 0;
|
||||||
|
|
||||||
if ((result = resultset_create(variable_row, &context)) == NULL)
|
if ((result = resultset_create(variable_row, &context)) == NULL)
|
||||||
@ -1040,11 +1072,13 @@ maxinfo_max_event_exec_time()
|
|||||||
/**
|
/**
|
||||||
* Variables that may be sent in a show status
|
* Variables that may be sent in a show status
|
||||||
*/
|
*/
|
||||||
static struct {
|
static struct
|
||||||
|
{
|
||||||
char *name;
|
char *name;
|
||||||
int type;
|
int type;
|
||||||
STATSFUNC func;
|
STATSFUNC func;
|
||||||
} status[] = {
|
} status[] =
|
||||||
|
{
|
||||||
{ "Uptime", VT_INT, (STATSFUNC)maxscale_uptime },
|
{ "Uptime", VT_INT, (STATSFUNC)maxscale_uptime },
|
||||||
{ "Uptime_since_flush_status", VT_INT, (STATSFUNC)maxscale_uptime },
|
{ "Uptime_since_flush_status", VT_INT, (STATSFUNC)maxscale_uptime },
|
||||||
{ "Threads_created", VT_INT, (STATSFUNC)config_threadcount },
|
{ "Threads_created", VT_INT, (STATSFUNC)config_threadcount },
|
||||||
@ -1126,9 +1160,13 @@ RESULTSET *result;
|
|||||||
VARCONTEXT context;
|
VARCONTEXT context;
|
||||||
|
|
||||||
if (filter)
|
if (filter)
|
||||||
|
{
|
||||||
context.like = filter->value;
|
context.like = filter->value;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
context.like = NULL;
|
context.like = NULL;
|
||||||
|
}
|
||||||
context.index = 0;
|
context.index = 0;
|
||||||
|
|
||||||
if ((result = resultset_create(status_row, &context)) == NULL)
|
if ((result = resultset_create(status_row, &context)) == NULL)
|
||||||
@ -1204,13 +1242,21 @@ extern char *strcasestr();
|
|||||||
}
|
}
|
||||||
len = strlen(fixed);
|
len = strlen(fixed);
|
||||||
if (fixed[len - 1] == '%')
|
if (fixed[len - 1] == '%')
|
||||||
|
{
|
||||||
trailing = 1;
|
trailing = 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
trailing = 0;
|
trailing = 0;
|
||||||
|
}
|
||||||
if (anchor == 1 && trailing == 0) // No wildcard
|
if (anchor == 1 && trailing == 0) // No wildcard
|
||||||
|
{
|
||||||
return strcasecmp(pattern, str);
|
return strcasecmp(pattern, str);
|
||||||
|
}
|
||||||
else if (anchor == 1)
|
else if (anchor == 1)
|
||||||
|
{
|
||||||
return strncasecmp(str, pattern, len - trailing);
|
return strncasecmp(str, pattern, len - trailing);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *portion = malloc(len + 1);
|
char *portion = malloc(len + 1);
|
||||||
@ -1229,7 +1275,8 @@ extern char *strcasestr();
|
|||||||
*/
|
*/
|
||||||
void maxinfo_send_ok(DCB *dcb)
|
void maxinfo_send_ok(DCB *dcb)
|
||||||
{
|
{
|
||||||
static const char ok_packet[] ={
|
static const char ok_packet[] =
|
||||||
|
{
|
||||||
0x07, 0x00, 0x00, 0x01,
|
0x07, 0x00, 0x00, 0x01,
|
||||||
0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00,
|
||||||
0x00, 0x00,
|
0x00, 0x00,
|
||||||
|
|||||||
Reference in New Issue
Block a user