All of lore.kernel.org
 help / color / mirror / Atom feed
* pause and echo patch
@ 2007-06-17 11:14 adrian15
  0 siblings, 0 replies; only message in thread
From: adrian15 @ 2007-06-17 11:14 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 2313 bytes --]

I attach the proposal of patch and I comment some doubts that I have.

> diff -urN grub2_2007_05_31_original/commands/echo.c grub2_2007_05_31_pause/commands/echo.c
> --- grub2_2007_05_31_original/commands/echo.c	2007-06-11 11:53:26.000000000 +0200
> +++ grub2_2007_05_31_pause/commands/echo.c	2007-06-17 04:25:26.000000000 +0200
> @@ -110,16 +110,35 @@
>    return 0;
>  }
>  
> +static grub_err_t
> +grub_cmd_pause (struct grub_arg_list *state __attribute__ ((unused)),
> +	      int argc, char **args)
> +
> +{
> +
> +  char key;
> +  if (argc!=0) 
> +    grub_cmd_echo(state,argc,args);
Here there is the trick for not duplicating code!
> +  key = grub_getkey ();
> +  
> +  return 0;
> +}
> +
>  \f
>  GRUB_MOD_INIT(echo)
>  {
> +
> +  (void) mod;			/* To stop warning. */
> +  grub_register_command ("pause", grub_cmd_pause, GRUB_COMMAND_FLAG_BOTH,
> +			 "pause [-e|-n] [MESSAGE]", "Pause and optionally show a message with echo command.", options);
>    (void) mod;			/* To stop warning. */
>    grub_register_command ("echo", grub_cmd_echo, GRUB_COMMAND_FLAG_BOTH,
> -			 "echo [-e|-n] FILE", "Display a line of text.",
> +			 "echo [-e|-n] \"STRING\"", "Display a line of text.",
>  			 options);
>  }
>  
>  GRUB_MOD_FINI(echo)
>  {
>    grub_unregister_command ("echo");
> +  grub_unregister_command ("pause");
>  }
I do not understand very well what's a module.
For instance should I have loaded the echo and pause commands in a
different module?
> 
> diff -urN grub2_2007_05_31_original/conf/common.rmk grub2_2007_05_31_pause/conf/common.rmk
> --- grub2_2007_05_31_original/conf/common.rmk	2007-06-11 11:53:27.000000000 +0200
> +++ grub2_2007_05_31_pause/conf/common.rmk	2007-06-17 04:18:07.000000000 +0200
> @@ -168,7 +168,7 @@
>  pkgdata_MODULES += hello.mod boot.mod terminal.mod ls.mod	\
>  	cmp.mod cat.mod help.mod font.mod search.mod		\
>  	loopback.mod configfile.mod				\
> -	terminfo.mod test.mod blocklist.mod
> +	terminfo.mod test.mod blocklist.mod echo.mod
>  
>  # For hello.mod.
>  hello_mod_SOURCES = hello/hello.c

So if I needed to edit this rmk in order to have one more module I
should replicate the lines where it is read echo.mod and put pause.mod,
but I should not change the lines with echo.c to pause.c because both
commands are in the same file...

	Am I right?


adrian15



[-- Attachment #2: grub2_pause_and_echo.patch --]
[-- Type: text/x-patch, Size: 1685 bytes --]

diff -urN grub2_2007_05_31_original/commands/echo.c grub2_2007_05_31_pause/commands/echo.c
--- grub2_2007_05_31_original/commands/echo.c	2007-06-11 11:53:26.000000000 +0200
+++ grub2_2007_05_31_pause/commands/echo.c	2007-06-17 04:25:26.000000000 +0200
@@ -110,16 +110,35 @@
   return 0;
 }
 
+static grub_err_t
+grub_cmd_pause (struct grub_arg_list *state __attribute__ ((unused)),
+	      int argc, char **args)
+
+{
+
+  char key;
+  if (argc!=0) 
+    grub_cmd_echo(state,argc,args);
+  key = grub_getkey ();
+  
+  return 0;
+}
+
 \f
 GRUB_MOD_INIT(echo)
 {
+
+  (void) mod;			/* To stop warning. */
+  grub_register_command ("pause", grub_cmd_pause, GRUB_COMMAND_FLAG_BOTH,
+			 "pause [-e|-n] [MESSAGE]", "Pause and optionally show a message with echo command.", options);
   (void) mod;			/* To stop warning. */
   grub_register_command ("echo", grub_cmd_echo, GRUB_COMMAND_FLAG_BOTH,
-			 "echo [-e|-n] FILE", "Display a line of text.",
+			 "echo [-e|-n] \"STRING\"", "Display a line of text.",
 			 options);
 }
 
 GRUB_MOD_FINI(echo)
 {
   grub_unregister_command ("echo");
+  grub_unregister_command ("pause");
 }

diff -urN grub2_2007_05_31_original/conf/common.rmk grub2_2007_05_31_pause/conf/common.rmk
--- grub2_2007_05_31_original/conf/common.rmk	2007-06-11 11:53:27.000000000 +0200
+++ grub2_2007_05_31_pause/conf/common.rmk	2007-06-17 04:18:07.000000000 +0200
@@ -168,7 +168,7 @@
 pkgdata_MODULES += hello.mod boot.mod terminal.mod ls.mod	\
 	cmp.mod cat.mod help.mod font.mod search.mod		\
 	loopback.mod configfile.mod				\
-	terminfo.mod test.mod blocklist.mod
+	terminfo.mod test.mod blocklist.mod echo.mod
 
 # For hello.mod.
 hello_mod_SOURCES = hello/hello.c


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-06-17 11:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-17 11:14 pause and echo patch adrian15

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.