Commit 25ec057f authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Add quit command.

parent 6aca83ed
......@@ -876,6 +876,11 @@ parse_config_line(int c, gnc_t gnc, void *closure, int *action_return)
if_conf, default_interface_conf);
free(if_conf);
}
} else if(strcmp(token, "quit") == 0) {
c = skip_eol(c, gnc, closure);
if(c < -1 || !action_return)
goto fail;
*action_return = CONFIG_QUIT;
} else {
c = parse_option(c, gnc, closure, token);
if(c < -1)
......
......@@ -23,6 +23,7 @@ THE SOFTWARE.
/* Values returned by parse_config_from_string. */
#define CONFIG_DONE 0
#define CONFIG_QUIT 1
struct filter_result {
unsigned int add_metric; /* allow = 0, deny = INF, metric = <0..INF> */
......
......@@ -107,12 +107,19 @@ local_read(struct local_socket *s)
return 1;
rc = parse_config_from_string(s->buf, eol + 1 - s->buf);
if(rc < 0) {
switch(rc) {
case CONFIG_DONE:
break;
case CONFIG_QUIT:
shutdown(s->fd, 1);
break;
default: {
char *buf = "error\n";
rc = write_timeout(s->fd, buf, 6);
if(rc < 0)
goto fail;
}
}
if(s->n > eol + 1 - s->buf) {
memmove(s->buf, eol + 1, s->n - (eol + 1 - s->buf));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment