Support command sequences separated by " ; ". Also clean up command printing.

This commit is contained in:
Nicholas Marriott
2009-01-18 14:40:48 +00:00
parent c4d5989a4e
commit a15f8fc4a6
23 changed files with 350 additions and 143 deletions

22
cfg.c
View File

@ -1,4 +1,4 @@
/* $Id: cfg.c,v 1.13 2008-07-25 17:20:40 nicm Exp $ */
/* $Id: cfg.c,v 1.14 2009-01-18 14:40:48 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -53,12 +53,12 @@ cfg_error(unused struct cmd_ctx *ctx, const char *fmt, ...)
int
load_cfg(const char *path, char **cause)
{
FILE *f;
u_int n;
char *buf, *line, *ptr;
size_t len;
struct cmd *cmd;
struct cmd_ctx ctx;
FILE *f;
u_int n;
char *buf, *line, *ptr;
size_t len;
struct cmd_list *cmdlist;
struct cmd_ctx ctx;
if ((f = fopen(path, "rb")) == NULL) {
xasprintf(cause, "%s: %s", path, strerror(errno));
@ -78,12 +78,12 @@ load_cfg(const char *path, char **cause)
}
n++;
if (cmd_string_parse(buf, &cmd, cause) != 0) {
if (cmd_string_parse(buf, &cmdlist, cause) != 0) {
if (*cause == NULL)
continue;
goto error;
}
if (cmd == NULL)
if (cmdlist == NULL)
continue;
cfg_cause = NULL;
@ -98,8 +98,8 @@ load_cfg(const char *path, char **cause)
ctx.cmdclient = NULL;
cfg_cause = NULL;
cmd_exec(cmd, &ctx);
cmd_free(cmd);
cmd_list_exec(cmdlist, &ctx);
cmd_list_free(cmdlist);
if (cfg_cause != NULL) {
*cause = cfg_cause;
goto error;