#include "adu.h"
#include "format.h"
-#include "select.h"
+#include "user.h"
#include "string.h"
+#include "select.cmdline.h"
+#include "select.h"
#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;
};
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;
}
free_format_info(fi);
fi = NULL;
+ free(admissible_uids);
+ admissible_uids = NULL;
return parse_select_options(line, ¶ms, &admissible_uids, &fi);
}
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)