aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErwan Velu <erwanaliasr1@gmail.com>2012-05-27 11:41:39 +0200
committerErwan Velu <erwanaliasr1@gmail.com>2012-05-27 11:41:39 +0200
commit1697594b61f9a8f9d092996afc0e2c80bbb2a20a (patch)
tree253b7535c5ba0477dc22a2892d1a4f66b33ad30f
parent748979d7bda20e876806e5aab8554ee2e5a35c8c (diff)
downloadsyslinux-1697594b61f9a8f9d092996afc0e2c80bbb2a20a.tar.gz
syslinux-1697594b61f9a8f9d092996afc0e2c80bbb2a20a.tar.xz
syslinux-1697594b61f9a8f9d092996afc0e2c80bbb2a20a.zip
hdt: Adding nomodule support in cli
Some new commands might need being able to manage the argv directly instead of the much more oriented scheme we had until now. This commit add a .nomodule option to cli object to explically tell they don't have a module as parameter but only arguments. This will be needed for the 'say' command.
-rw-r--r--com32/hdt/hdt-cli-acpi.c2
-rw-r--r--com32/hdt/hdt-cli-disk.c3
-rw-r--r--com32/hdt/hdt-cli-dmi.c15
-rw-r--r--com32/hdt/hdt-cli-hdt.c26
-rw-r--r--com32/hdt/hdt-cli-memory.c5
-rw-r--r--com32/hdt/hdt-cli-pci.c3
-rw-r--r--com32/hdt/hdt-cli-vesa.c5
-rw-r--r--com32/hdt/hdt-cli.c29
-rw-r--r--com32/hdt/hdt-cli.h1
9 files changed, 84 insertions, 5 deletions
diff --git a/com32/hdt/hdt-cli-acpi.c b/com32/hdt/hdt-cli-acpi.c
index a978bb36..55b0c3c7 100644
--- a/com32/hdt/hdt-cli-acpi.c
+++ b/com32/hdt/hdt-cli-acpi.c
@@ -267,10 +267,12 @@ struct cli_callback_descr list_acpi_show_modules[] = {
{
.name = "apic",
.exec = show_acpi_apic,
+ .nomodule = false,
},
{
.name = NULL,
.exec = NULL,
+ .nomodule = false,
},
};
diff --git a/com32/hdt/hdt-cli-disk.c b/com32/hdt/hdt-cli-disk.c
index 24fce676..10c95d7d 100644
--- a/com32/hdt/hdt-cli-disk.c
+++ b/com32/hdt/hdt-cli-disk.c
@@ -225,14 +225,17 @@ struct cli_callback_descr list_disk_show_modules[] = {
{
.name = "disks",
.exec = main_show_disks,
+ .nomodule = false,
},
{
.name = "disk",
.exec = main_show_disk,
+ .nomodule = false,
},
{
.name = NULL,
.exec = NULL,
+ .nomodule = false,
},
};
diff --git a/com32/hdt/hdt-cli-dmi.c b/com32/hdt/hdt-cli-dmi.c
index 45cbb240..02bea0f7 100644
--- a/com32/hdt/hdt-cli-dmi.c
+++ b/com32/hdt/hdt-cli-dmi.c
@@ -617,62 +617,77 @@ struct cli_callback_descr list_dmi_show_modules[] = {
{
.name = CLI_DMI_BASE_BOARD,
.exec = show_dmi_base_board,
+ .nomodule = false,
},
{
.name = CLI_DMI_BIOS,
.exec = show_dmi_bios,
+ .nomodule = false,
},
{
.name = CLI_DMI_BATTERY,
.exec = show_dmi_battery,
+ .nomodule = false,
},
{
.name = CLI_DMI_CHASSIS,
.exec = show_dmi_chassis,
+ .nomodule = false,
},
{
.name = CLI_DMI_MEMORY,
.exec = show_dmi_memory_modules,
+ .nomodule = false,
},
{
.name = CLI_DMI_MEMORY_BANK,
.exec = show_dmi_memory_bank,
+ .nomodule = false,
},
{
.name = "module",
.exec = show_dmi_memory_module,
+ .nomodule = false,
},
{
.name = CLI_DMI_PROCESSOR,
.exec = show_dmi_cpu,
+ .nomodule = false,
},
{
.name = CLI_DMI_SYSTEM,
.exec = show_dmi_system,
+ .nomodule = false,
},
{
.name = CLI_DMI_OEM,
.exec = show_dmi_oem_strings,
+ .nomodule = false,
},
{
.name = CLI_DMI_SECURITY,
.exec = show_dmi_hardware_security,
+ .nomodule = false,
},
{
.name = CLI_DMI_IPMI,
.exec = show_dmi_ipmi,
+ .nomodule = false,
},
{
.name = CLI_DMI_CACHE,
.exec = show_dmi_cache,
+ .nomodule = false,
},
{
.name = CLI_DMI_LIST,
.exec = show_dmi_modules,
+ .nomodule = false,
},
{
.name = NULL,
.exec = NULL,
+ .nomodule = false,
},
};
diff --git a/com32/hdt/hdt-cli-hdt.c b/com32/hdt/hdt-cli-hdt.c
index e9752612..555237e3 100644
--- a/com32/hdt/hdt-cli-hdt.c
+++ b/com32/hdt/hdt-cli-hdt.c
@@ -264,26 +264,32 @@ struct cli_callback_descr list_hdt_default_modules[] = {
{
.name = CLI_CLEAR,
.exec = cli_clear_screen,
+ .nomodule = false,
},
{
.name = CLI_EXIT,
.exec = do_exit,
+ .nomodule = false,
},
{
.name = CLI_HELP,
.exec = show_cli_help,
+ .nomodule = false,
},
{
.name = CLI_MENU,
.exec = goto_menu,
+ .nomodule = false,
},
{
.name = CLI_REBOOT,
.exec = do_reboot,
+ .nomodule = false,
},
{
.name = CLI_HISTORY,
.exec = print_history,
+ .nomodule = false,
},
{
.name = CLI_DUMP,
@@ -291,69 +297,85 @@ struct cli_callback_descr list_hdt_default_modules[] = {
},
{
.name = NULL,
- .exec = NULL},
+ .exec = NULL,
+ .nomodule = false},
};
struct cli_callback_descr list_hdt_show_modules[] = {
{
.name = CLI_SUMMARY,
.exec = main_show_summary,
+ .nomodule = false,
},
{
.name = CLI_PCI,
.exec = main_show_pci,
+ .nomodule = false,
},
{
.name = CLI_DMI,
.exec = main_show_dmi,
+ .nomodule = false,
},
{
.name = CLI_CPU,
.exec = main_show_cpu,
+ .nomodule = false,
},
{
.name = CLI_DISK,
.exec = disks_summary,
+ .nomodule = false,
},
{
.name = CLI_PXE,
.exec = main_show_pxe,
+ .nomodule = false,
},
{
.name = CLI_SYSLINUX,
.exec = main_show_syslinux,
+ .nomodule = false,
},
{
.name = CLI_KERNEL,
.exec = main_show_kernel,
+ .nomodule = false,
},
{
.name = CLI_VESA,
.exec = main_show_vesa,
+ .nomodule = false,
},
{
.name = CLI_HDT,
.exec = main_show_hdt,
+ .nomodule = false,
},
{
.name = CLI_VPD,
.exec = main_show_vpd,
+ .nomodule = false,
},
{
.name = CLI_MEMORY,
.exec = show_dmi_memory_modules,
+ .nomodule = false,
},
{
.name = CLI_ACPI,
.exec = main_show_acpi,
+ .nomodule = false,
},
{
.name = "modes",
.exec = main_show_modes,
+ .nomodule = false,
},
{
.name = NULL,
.exec = NULL,
+ .nomodule = false,
},
};
@@ -361,10 +383,12 @@ struct cli_callback_descr list_hdt_set_modules[] = {
{
.name = CLI_MODE,
.exec = cli_set_mode,
+ .nomodule = false,
},
{
.name = NULL,
.exec = NULL,
+ .nomodule = false,
},
};
diff --git a/com32/hdt/hdt-cli-memory.c b/com32/hdt/hdt-cli-memory.c
index 51d087e8..c05b7cd6 100644
--- a/com32/hdt/hdt-cli-memory.c
+++ b/com32/hdt/hdt-cli-memory.c
@@ -101,22 +101,27 @@ struct cli_callback_descr list_memory_show_modules[] = {
{
.name = "e820",
.exec = show_memory_e820,
+ .nomodule=false,
},
{
.name = "e801",
.exec = show_memory_e801,
+ .nomodule=false,
},
{
.name = "88",
.exec = show_memory_88,
+ .nomodule=false,
},
{
.name = CLI_DMI_MEMORY_BANK,
.exec = show_dmi_memory_bank,
+ .nomodule=false,
},
{
.name = NULL,
.exec = NULL,
+ .nomodule=false,
},
};
diff --git a/com32/hdt/hdt-cli-pci.c b/com32/hdt/hdt-cli-pci.c
index 07c079d5..75fc0011 100644
--- a/com32/hdt/hdt-cli-pci.c
+++ b/com32/hdt/hdt-cli-pci.c
@@ -266,14 +266,17 @@ struct cli_callback_descr list_pci_show_modules[] = {
{
.name = CLI_IRQ,
.exec = show_pci_irq,
+ .nomodule=false,
},
{
.name = CLI_PCI_DEVICE,
.exec = show_pci_device,
+ .nomodule=false,
},
{
.name = NULL,
.exec = NULL,
+ .nomodule=false,
},
};
diff --git a/com32/hdt/hdt-cli-vesa.c b/com32/hdt/hdt-cli-vesa.c
index 702f8bd6..ca44987a 100644
--- a/com32/hdt/hdt-cli-vesa.c
+++ b/com32/hdt/hdt-cli-vesa.c
@@ -98,10 +98,12 @@ struct cli_callback_descr list_vesa_show_modules[] = {
{
.name = CLI_MODES,
.exec = show_vesa_modes,
+ .nomodule=false,
},
{
.name = NULL,
.exec = NULL,
+ .nomodule=false,
},
};
@@ -109,15 +111,18 @@ struct cli_callback_descr list_vesa_commands[] = {
{
.name = CLI_ENABLE,
.exec = enable_vesa,
+ .nomodule=false,
},
{
.name = CLI_DISABLE,
.exec = disable_vesa,
+ .nomodule=false,
},
{
.name = NULL,
.exec = NULL,
+ .nomodule=false,
},
};
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 3dd982ef..11984e5a 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -626,22 +626,43 @@ static void exec_command(char *line, struct s_hardware *hardware)
/* This will allocate memory for command and module */
parse_command_line(line, &command, &module, &argc, argv);
+ dprintf("CLI DEBUG exec: Checking for aliases\n");
/*
* Expand shortcuts, if needed
* This will allocate memory for argc/argv
*/
expand_aliases(line, &command, &module, &argc, argv);
+
+ find_cli_callback_descr(command, current_mode->default_modules,
+ &current_module);
- if (module == NULL) {
- dprintf("CLI DEBUG: single command detected\n");
+ if ((module == NULL) || (current_module->nomodule == true)) {
+ dprintf("CLI DEBUG exec : single command detected\n");
/*
* A single word was specified: look at the list of default
* commands in the current mode to see if there is a match.
* If not, it may be a generic function (exit, help, ...). These
* are stored in the list of default commands of the hdt mode.
*/
- find_cli_callback_descr(command, current_mode->default_modules,
- &current_module);
+
+ /* First of all it the command doesn't need module, let's rework the arguments */
+ if ((current_module->nomodule == true) && ( module != NULL)) {
+ dprintf("CLI_DEBUG exec: Reworking arguments with argc=%d\n",argc);
+ char **new_argv=NULL;
+ new_argv=malloc((argc + 2)*sizeof(char));
+ for (int argc_iter=0; argc_iter<argc; argc_iter++) {
+ dprintf("CLI_DEBUG exec rework : copy %d to %d (%s)\n",argc_iter,argc_iter+1,argv[argc_iter]);
+ new_argv[argc_iter+1] = malloc(strlen(argv[argc_iter]));
+ strlcpy(new_argv[argc_iter+1], argv[argc_iter], strlen(argv[argc_iter]));
+ free(argv[argc_iter]);
+ }
+ new_argv[0] = malloc(strlen(module)*sizeof(char));
+ strlcpy(new_argv[0], module, strlen(module));
+ argc++;
+ free(argv);
+ argv=new_argv;
+ }
+
if (current_module != NULL)
current_module->exec(argc, argv, hardware);
else if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1) &&
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 68b33158..1e21941c 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -120,6 +120,7 @@ struct cli_module_descr {
struct cli_callback_descr {
const char *name;
void (*exec) (int argc, char **argv, struct s_hardware * hardware);
+ bool nomodule;
};
/* Manage aliases */