aboutsummaryrefslogtreecommitdiffstats
path: root/com32
diff options
context:
space:
mode:
authorErwan Velu <erwanaliasr1@gmail.com>2012-05-27 11:46:54 +0200
committerErwan Velu <erwanaliasr1@gmail.com>2012-05-27 11:46:54 +0200
commit30abec4d70d34875b0ca312d62eed5e264f9050d (patch)
treedcc6d1b45327605a5b7d3cc5af772348f5f8aab1 /com32
parent1697594b61f9a8f9d092996afc0e2c80bbb2a20a (diff)
downloadsyslinux-30abec4d70d34875b0ca312d62eed5e264f9050d.tar.gz
syslinux-30abec4d70d34875b0ca312d62eed5e264f9050d.tar.xz
syslinux-30abec4d70d34875b0ca312d62eed5e264f9050d.zip
hdt: Adding say command
This command is just for displaing a message to the cli during a defined period of time. Syntax is like the following : say `my message`%<number_of_seconds> An example : say `This is my text message to display during 5 seconds`%5
Diffstat (limited to 'com32')
-rw-r--r--com32/hdt/hdt-cli-hdt.c61
-rw-r--r--com32/hdt/hdt-cli.h1
2 files changed, 62 insertions, 0 deletions
diff --git a/com32/hdt/hdt-cli-hdt.c b/com32/hdt/hdt-cli-hdt.c
index 555237e3..f7f7e949 100644
--- a/com32/hdt/hdt-cli-hdt.c
+++ b/com32/hdt/hdt-cli-hdt.c
@@ -259,6 +259,61 @@ static void do_dump(int argc __unused, char **argv __unused,
dump(hardware);
}
+/**
+ * do_say - say message to user
+ **/
+static void do_say(int argc , char **argv ,
+ struct s_hardware *hardware)
+{
+ (void) hardware;
+ if (argc == 0) return;
+
+ char text_to_say[255]={0};
+ int arg=0;
+ int sleep_time=0;
+#if DEBUG
+ for (int i=0; i<argc;i++) dprintf("SAY: arg[%d]={%s}\n",i,argv[i]);
+#endif
+ char *argument = strchr(argv[arg],'`');
+ if ( argument != NULL) {
+ argument++;
+ strcat(text_to_say, argument);
+
+ while ((strchr(argument, '`') == NULL) && (arg+1<argc)) {
+ arg++;
+ argument = (char *)argv[arg];
+ strcat(text_to_say, " ");
+ strcat(text_to_say, argument);
+ }
+
+ /* Removing last ` if any */
+ char *last_quote = strrchr(text_to_say,'`');
+ if ( last_quote != NULL ) {
+ *last_quote='\0';
+ dprintf("SAY CMD = [%s]\n",text_to_say);
+ }
+
+ /* The % char can be in the same argument, let's consider it again */
+ arg--;
+
+ /* Searching for a % argument to determine the time to show the message */
+ char *time_to_display = NULL;
+ /* Search for a requested time to display */
+ while ( ((time_to_display=strchr(argument, '%')) == NULL) && (arg+1<argc)) {
+ arg++;
+ argument = (char *)argv[arg];
+ }
+
+ if (time_to_display != NULL) {
+ sleep_time=atoi(time_to_display+1);
+ dprintf("SAY CMD :Time to display = %d\n",sleep_time);
+ }
+
+ printf("%s\n",text_to_say);
+ sleep(sleep_time);
+ }
+}
+
/* Default hdt mode */
struct cli_callback_descr list_hdt_default_modules[] = {
{
@@ -294,6 +349,12 @@ struct cli_callback_descr list_hdt_default_modules[] = {
{
.name = CLI_DUMP,
.exec = do_dump,
+ .nomodule = false,
+ },
+ {
+ .name = CLI_SAY,
+ .exec = do_say,
+ .nomodule = true,
},
{
.name = NULL,
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 1e21941c..30fe5187 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -66,6 +66,7 @@
#define CLI_ENABLE "enable"
#define CLI_DISABLE "disable"
#define CLI_DUMP "dump"
+#define CLI_SAY "say"
typedef enum {
INVALID_MODE,