hdt: Adding Silent mode
authorErwan Velu <erwanaliasr1@gmail.com>
Mon, 10 Sep 2012 19:02:02 +0000 (21:02 +0200)
committerErwan Velu <erwanaliasr1@gmail.com>
Mon, 10 Sep 2012 19:02:02 +0000 (21:02 +0200)
By using the "silent" option at the cmdline, HDT tries not displaying
any boring message.

This is particulary interesting with the "display" option.

com32/hdt/floppy/hdt.cfg
com32/hdt/hdt-common.c
com32/hdt/hdt-common.h

index 7cfe6a7..524c4e0 100644 (file)
@@ -103,7 +103,7 @@ TEXT HELP
  A Picture is shown by using the display command
 ENDTEXT
 COM32 hdt.c32
-APPEND modules_pcimap=modules.pcimap modules_alias=modules.alias pciids=pci.ids quiet nomenu vesa auto='display display.png; sleep 5000; display red.png'
+APPEND modules_pcimap=modules.pcimap modules_alias=modules.alias pciids=pci.ids silent nomenu vesa auto='display display.png; sleep 5000; display red.png'
 
 MENU SEPARATOR
 
index 0797ddd..dcad28c 100644 (file)
@@ -63,6 +63,9 @@ void detect_parameters(const int argc, const char *argv[],
     /* Quiet mode - make the output more quiet */
     quiet = true;
 
+    /* Silent mode - make not output at all */
+    silent = false;
+
     /* Vesa mode isn't set until we explictly call it */
     vesamode = false;
 
@@ -75,6 +78,8 @@ void detect_parameters(const int argc, const char *argv[],
     for (int i = 1; i < argc; i++) {
        if (!strncmp(argv[i], "quiet", 5)) {
            quiet = true;
+       } else if (!strncmp(argv[i], "silent", 6)) {
+           silent = true;
        } else  if (!strncmp(argv[i], "verbose", 7)) {
            quiet = false;
        } else if (!strncmp(argv[i], "modules_pcimap=", 15)) {
index 8c85260..c2299b4 100644 (file)
@@ -87,6 +87,9 @@ struct upload_backend *upload;
 /* Defines if the cli is quiet*/
 bool quiet;
 
+/* Defines if the cli is totally silent*/
+bool silent;
+
 /* Defines if we must use the vesa mode */
 bool vesamode;
 
@@ -114,16 +117,18 @@ extern bool disable_more_printf;
  * one \n (and only one)
  */
 #define more_printf(...) do {\
- if (__likely(!disable_more_printf)) {\
-  if (display_line_nb == max_console_lines) {\
-   display_line_nb=0;\
-   printf("\n--More--");\
-   get_key(stdin, 0);\
-   printf("\033[2K\033[1G\033[1F");\
+ if (__likely(!silent)) {\
+  if (__likely(!disable_more_printf)) {\
+   if (display_line_nb == max_console_lines) {\
+    display_line_nb=0;\
+    printf("\n--More--");\
+    get_key(stdin, 0);\
+    printf("\033[2K\033[1G\033[1F");\
+   }\
+   display_line_nb++;\
   }\
-  display_line_nb++;\
+  printf(__VA_ARGS__);\
  }\
- printf(__VA_ARGS__);\
 } while (0);
 
 /* Display CPU registers for debugging purposes */