aboutsummaryrefslogtreecommitdiffstats
path: root/com32
diff options
context:
space:
mode:
Diffstat (limited to 'com32')
-rw-r--r--com32/hdt/hdt-cli-pci.c2
-rw-r--r--com32/hdt/hdt-cli.c28
-rw-r--r--com32/hdt/hdt-cli.h1
-rw-r--r--com32/hdt/hdt-common.c28
-rw-r--r--com32/hdt/hdt-common.h10
-rw-r--r--com32/hdt/hdt.c18
6 files changed, 75 insertions, 12 deletions
diff --git a/com32/hdt/hdt-cli-pci.c b/com32/hdt/hdt-cli-pci.c
index 1557b870..75e28968 100644
--- a/com32/hdt/hdt-cli-pci.c
+++ b/com32/hdt/hdt-cli-pci.c
@@ -37,7 +37,7 @@ void main_show_pci(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
cli_detect_pci(hardware);
- reset_more_printf();
+ reset_more_printf();
more_printf("PCI\n");
more_printf(" NB Devices : %d\n", hardware->nb_pci_devices);
}
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();
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index aa27ac7d..3684fa40 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -153,6 +153,7 @@ cli_mode_t mode_s_to_mode_t(char *name);
void set_mode(cli_mode_t mode, struct s_hardware *hardware);
void start_cli_mode(struct s_hardware *hardware);
+void start_auto_mode(struct s_hardware *hardware);
void main_show(char *item, struct s_hardware *hardware);
// DMI STUFF
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index 65c9ec51..c3873dda 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -76,6 +76,33 @@ void detect_parameters(const int argc, const char *argv[],
strncpy(hardware->reboot_label, argv[i] + 7,
sizeof(hardware->reboot_label));
convert_isolinux_filename(hardware->reboot_label,hardware);
+ } else if (!strncmp(argv[i], "auto=", 5)) {
+ /* The auto= parameter is separated in several argv[]
+ * as it can contains spaces.
+ * We use the AUTO_DELIMITER char to define the limits
+ * of this parameter.
+ * i.e auto='show dmi; show pci'
+ */
+
+ /* Extracting the first parameter */
+ strcpy(hardware->auto_label, argv[i] + 6);
+ strcat(hardware->auto_label," ");
+ char *pos;
+ i++;
+
+ /* While we can't find the other AUTO_DELIMITER, let's process the argv[] */
+ while(((pos=strstr(argv[i],AUTO_DELIMITER)) == NULL) && (i<argc)) {
+ strcat(hardware->auto_label,argv[i]);
+ strcat(hardware->auto_label," ");
+ i++;
+ }
+
+ /* If we didn't reach the end of the line, let's grab the last item */
+ if (i<argc) {
+ strcat(hardware->auto_label,argv[i]);
+ hardware->auto_label[strlen(hardware->auto_label)-1]=0;
+ i++;
+ }
}
}
}
@@ -138,6 +165,7 @@ void init_hardware(struct s_hardware *hardware)
sizeof hardware->modules_alias_path);
memset(hardware->memtest_label, 0, sizeof hardware->memtest_label);
memset(hardware->reboot_label, 0, sizeof hardware->reboot_label);
+ memset(hardware->auto_label, 0, sizeof hardware->auto_label);
strcat(hardware->pciids_path, "pci.ids");
strcat(hardware->modules_pcimap_path, "modules.pcimap");
strcat(hardware->modules_alias_path, "modules.alias");
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index b3b46265..baecbc03 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -57,6 +57,15 @@
#define HDT_RETURN_TO_CLI 100
#define MAX_VESA_MODES 255
+/* The maximum number of commands we can process */
+#define MAX_NB_AUTO_COMMANDS 255
+/* The maximum size of a command */
+#define AUTO_COMMAND_SIZE 255
+/* The char that separate two commands */
+#define AUTO_SEPARATOR ";"
+/* The char that surround the list of commands */
+#define AUTO_DELIMITER "'"
+
extern int display_line_nb;
#define pause_printf() do {\
@@ -163,6 +172,7 @@ struct s_hardware {
char pciids_path[255];
char memtest_label[255];
char reboot_label[255];
+ char auto_label[AUTO_COMMAND_SIZE];
};
void reset_more_printf();
diff --git a/com32/hdt/hdt.c b/com32/hdt/hdt.c
index ee3e7cf3..00c5439d 100644
--- a/com32/hdt/hdt.c
+++ b/com32/hdt/hdt.c
@@ -37,7 +37,6 @@
#include <consoles.h>
#include "hdt.h"
#include "hdt-menu.h"
-#include "hdt-cli.h"
#include "hdt-common.h"
int display_line_nb = 0;
@@ -68,17 +67,14 @@ int main(const int argc, const char *argv[])
printf("\033[1;1H");
printf("%s\n", version_string);
-
- if ((arg = find_argument(argv + 1, "nomenu")))
- start_cli_mode(&hardware);
+ if ((arg = find_argument(argv + 1, "nomenu")) || (find_argument(argv+1,"auto")))
+ start_cli_mode(&hardware);
else {
- int return_code = start_menu_mode(&hardware, version_string);
-
- if (return_code == HDT_RETURN_TO_CLI)
- start_cli_mode(&hardware);
- else
- return return_code;
+ int return_code = start_menu_mode(&hardware, version_string);
+ if (return_code == HDT_RETURN_TO_CLI)
+ start_cli_mode(&hardware);
+ else
+ return return_code;
}
-
return 0;
}