X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=interactive.c;h=b3254157d6785403573252876624c026ed912ed4;hb=8ea3d2b618aee3a4b0992e31ed2d94294273bd1f;hp=69b0343b3ba5ded9eb5fd8041a9d64c312fd29c5;hpb=f4edf7aa55a79ba35d9c93344280cdae19b5e7f8;p=adu.git diff --git a/interactive.c b/interactive.c index 69b0343..b325415 100644 --- a/interactive.c +++ b/interactive.c @@ -7,9 +7,18 @@ #include "error.h" #include "cmdline.h" +/** + * Describes one valid command for interactive mode. + * + * When invoked in interactive mode, adu reads commands from stdin. There's a + * static array of all such commands. + */ struct interactive_command { + /** The name of the command. */ const char *name; + /** Pointer to The function that is being executed. */ int (*handler)(char *); + /** Help text. */ const char *desc; }; @@ -65,11 +74,17 @@ static int icom_help(__a_unused char *line) void print_interactive_help(void) { - icom_help(NULL); + struct interactive_command *c; + FOR_EACH_COMMAND(c) + fprintf(stdout, "\t%s\t%s\n", c->name, c->desc); } static int icom_reset(__a_unused char *line) { + free_format_info(fi); + fi = NULL; + free(admissible_uids); + admissible_uids = NULL; select_cmdline_parser_init(&select_conf); return 1; } @@ -90,6 +105,8 @@ static int icom_set(char *line) free_format_info(fi); fi = NULL; + free(admissible_uids); + admissible_uids = NULL; return parse_select_options(line, ¶ms, &admissible_uids, &fi); } @@ -115,6 +132,8 @@ static int exec_interactive_command(char *line) if (!*line) return 1; /* OK, we have a non-empty line */ + if (*line == '#') + return 1; cmd = adu_strdup(line); args = cmd + strcspn(cmd, delim); if (!*args)