INTERACTIVE_COMMAND(set, "change the current configuration") \
INTERACTIVE_COMMAND(reset, "reset configuration to defaults") \
INTERACTIVE_COMMAND(help, "show list of commands and one-line descriptions") \
- INTERACTIVE_COMMAND(run, "start the query according to the current configuration")
+ INTERACTIVE_COMMAND(run, "start the query according to the current configuration") \
+ INTERACTIVE_COMMAND(source, "read and execute interactive commands from a file")
#define INTERACTIVE_COMMAND(name, desc) \
return ret;
}
+static int icom_source(char *args)
+{
+ char line[255];
+ FILE *src = fopen(args, "r");
+ int ret;
+
+ if (!src)
+ return -ERRNO_TO_ERROR(errno);
+ while (fgets(line, sizeof(line), src)) {
+ ret = exec_interactive_command(line);
+ if (ret < 0)
+ goto out;
+ }
+ ret = 1;
+out:
+ fclose(src);
+ return ret;
+}
+
int com_interactive(void)
{
char line[255];