From 89445853bc2fb08e0dea88a9092616320f3a6191 Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Tue, 15 Dec 2009 10:16:48 +0100 Subject: [PATCH] hdt: Merging nomenu & auto mode detection Impact: code cleanup Let's use a single place to detect all hdt's parameters. --- com32/hdt/hdt-common.c | 9 +++++++++ com32/hdt/hdt-common.h | 6 ++++++ com32/hdt/hdt.c | 3 +-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c index ec51f10..6457141 100644 --- a/com32/hdt/hdt-common.c +++ b/com32/hdt/hdt-common.c @@ -66,6 +66,12 @@ void detect_parameters(const int argc, const char *argv[], /* Vesa mode isn't set until we explictly call it */ vesamode = false; + /* Automode isn't the default*/ + automode = false; + + /* Menu mode is the default*/ + menumode = true; + for (int i = 1; i < argc; i++) { if (!strncmp(argv[i], "quiet", 5)) { quiet = true; @@ -102,6 +108,8 @@ void detect_parameters(const int argc, const char *argv[], } else if (!strncmp(argv[i], "novesa", 6)) { vesamode = false; max_console_lines = MAX_VESA_CLI_LINES; + } else if (!strncmp(argv[i], "nomenu", 6)) { + menumode = false; } else if (!strncmp(argv[i], "auto=", 5)) { /* The auto= parameter is separated in several argv[] * as it can contains spaces. @@ -110,6 +118,7 @@ void detect_parameters(const int argc, const char *argv[], * i.e auto='show dmi; show pci' */ + automode=true; /* Extracting the first parameter */ strcpy(hardware->auto_label, argv[i] + 6); strcat(hardware->auto_label, " "); diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h index 31e88d6..08c7f4d 100644 --- a/com32/hdt/hdt-common.h +++ b/com32/hdt/hdt-common.h @@ -83,6 +83,12 @@ bool quiet; /* Defines if we must use the vesa mode */ bool vesamode; +/* Defines if we must use the menu mode */ +bool menumode; + +/* Defines if we are running the auto mode */ +bool automode; + /* Defines the number of lines in the console * Default is 20 for a std console */ extern int max_console_lines; diff --git a/com32/hdt/hdt.c b/com32/hdt/hdt.c index 229af54..56848b0 100644 --- a/com32/hdt/hdt.c +++ b/com32/hdt/hdt.c @@ -75,8 +75,7 @@ int main(const int argc, const char *argv[]) printf("%s\n", version_string); - if ((arg = find_argument(argv + 1, "nomenu")) - || (find_argument(argv + 1, "auto"))) + if (!menumode || automode) start_cli_mode(&hardware); else { int return_code = start_menu_mode(&hardware, version_string); -- 2.7.4