aboutsummaryrefslogtreecommitdiffstats
path: root/com32/hdt/hdt-cli.c
diff options
context:
space:
mode:
authorErwan Velu <erwan.velu@free.fr>2009-11-03 22:41:30 +0100
committerErwan Velu <erwan.velu@free.fr>2009-11-03 22:41:30 +0100
commit35c507ee84ae948f7b51ba3a8d5062178680d88c (patch)
treee8390bea29424a1bab76bf02889ce67fe7526a44 /com32/hdt/hdt-cli.c
parentc9d07318d415f697a873e40f933834ff0e8e949b (diff)
downloadsyslinux-35c507ee84ae948f7b51ba3a8d5062178680d88c.tar.gz
syslinux-35c507ee84ae948f7b51ba3a8d5062178680d88c.tar.xz
syslinux-35c507ee84ae948f7b51ba3a8d5062178680d88c.zip
hdt: Adding automatic mode
Impact: HDT can be controlled via the cmdline When the auto= parameter is set, HDT execute a set of commands and return to the cli after. i.e auto='show summary; show pci' will show the summary then the pci and return to the cli. Note that the auto= feature, requires a the "'" char to define the complete set of commands and the ";" char to separate commands. Some more examples: auto='show syslinux; exit' -> this will show the syslinux release and then exit to return to the bootloader auto='show summary; reboot' -> this will show the summary and then reboot the computer
Diffstat (limited to 'com32/hdt/hdt-cli.c')
-rw-r--r--com32/hdt/hdt-cli.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 86e818f9..5f23b2ae 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -749,6 +749,27 @@ static void reset_prompt()
}
}
+void start_auto_mode(struct s_hardware *hardware)
+{
+ char *mypch;
+ char *temp;
+ int nb_commands=0;
+ char *commands[MAX_NB_AUTO_COMMANDS];
+
+ temp=strdup(hardware->auto_label);
+ printf("Entering Auto mode\n");
+ mypch = strtok (temp,AUTO_SEPARATOR);
+ while (mypch != NULL) {
+ nb_commands++;
+ commands[nb_commands]=malloc(AUTO_COMMAND_SIZE);
+ sprintf(commands[nb_commands],"%s",mypch);
+ mypch = strtok (NULL, AUTO_SEPARATOR);
+ }
+ for (int i=1;i<=nb_commands;i++)
+ exec_command(commands[i], hardware);
+}
+
+
/* Code that manages the cli mode */
void start_cli_mode(struct s_hardware *hardware)
{
@@ -772,6 +793,13 @@ void start_cli_mode(struct s_hardware *hardware)
return;
}
+ /* Start the auto mode if the command line is set*/
+ if (strlen(hardware->auto_label) > 0) {
+ start_auto_mode(hardware);
+ /* No need to return to cli */
+ return;
+ }
+
printf("Entering CLI mode\n");
reset_prompt();