diff options
-rw-r--r-- | com32/hdt/hdt-common.c | 22 | ||||
-rw-r--r-- | com32/hdt/hdt-common.h | 1 | ||||
-rw-r--r-- | com32/hdt/hdt.c | 15 |
3 files changed, 34 insertions, 4 deletions
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c index 1857cc0b..8e9a9e64 100644 --- a/com32/hdt/hdt-common.c +++ b/com32/hdt/hdt-common.c @@ -115,6 +115,27 @@ void detect_parameters(const int argc, const char *argv[], } else if (!strncmp(argv[i], "tftp_ip=", 8)) { strlcpy(hardware->tftp_ip, argv[i] + 8, sizeof(hardware->tftp_ip)); + } else if (!strncmp(argv[i], "postexec=", 9)) { + /* The postexec= 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 postexec='linux memtest.bin' + */ + + char *argument = (char*)argv[i]+10; + /* Extracting the first parameter */ + strcpy(hardware->postexec, argument); + + /* While we can't find the other AUTO_DELIMITER, let's process the argv[] */ + while ((strchr(argument, AUTO_DELIMITER) == NULL) && (i+1<argc)) { + i++; + argument = (char *)argv[i]; + strcat(hardware->postexec, " "); + strcat(hardware->postexec, argument); + } + + hardware->postexec[strlen(hardware->postexec) - 1] = 0; } else if (!strncmp(argv[i], "auto=", 5)) { /* The auto= parameter is separated in several argv[] * as it can contains spaces. @@ -210,6 +231,7 @@ void init_hardware(struct s_hardware *hardware) memset(hardware->dump_filename, 0, sizeof hardware->dump_filename); memset(hardware->vesa_background, 0, sizeof hardware->vesa_background); memset(hardware->tftp_ip, 0, sizeof hardware->tftp_ip); + memset(hardware->postexec, 0, sizeof hardware->postexec); strcat(hardware->dump_path, "hdt"); strcat(hardware->dump_filename, "%{m}+%{p}+%{v}"); strcat(hardware->pciids_path, "pci.ids"); diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h index f007e72f..8c85260b 100644 --- a/com32/hdt/hdt-common.h +++ b/com32/hdt/hdt-common.h @@ -219,6 +219,7 @@ struct s_hardware { char memtest_label[255]; char auto_label[AUTO_COMMAND_SIZE]; char vesa_background[255]; + char postexec[255]; }; void reset_more_printf(void); diff --git a/com32/hdt/hdt.c b/com32/hdt/hdt.c index a1e3923c..851b0462 100644 --- a/com32/hdt/hdt.c +++ b/com32/hdt/hdt.c @@ -74,14 +74,21 @@ int main(const int argc, const char *argv[]) printf("%s\n", version_string); + int return_code = 0; + if (!menumode || automode) start_cli_mode(&hardware); else { - int return_code = start_menu_mode(&hardware, version_string); + 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; + + /* Do we got request to do something at exit time ? */ + if (strlen(hardware.postexec)>0) { + printf("Executing postexec instructions : %s\n",hardware.postexec); + runsyslinuxcmd(hardware.postexec); + } + + return return_code; } |