struct cli_mode_descr dmi_mode = {
.mode = DMI_MODE,
- .name = "dmi",
+ .name = CLI_DMI,
.default_modules = NULL,
.show_modules = &dmi_show_modules,
.set_modules = NULL,
more_printf(" Copyright : %s\n", hardware->sv->copyright_string + 1);
}
-static void show_syslinux_help()
-{
- more_printf("Show supports the following commands : %s\n",
- CLI_SHOW_LIST);
-}
+struct cli_module_descr syslinux_show_modules = {
+ .modules = NULL,
+ .nb_modules = 0,
+ .default_callback = main_show_syslinux,
+};
-static void syslinux_show(char *item, struct s_hardware *hardware)
-{
- if (!strncmp(item, CLI_SHOW_LIST, sizeof(CLI_SHOW_LIST) - 1)) {
- main_show_syslinux(0, NULL, hardware);
- return;
- }
- show_syslinux_help();
-}
-
-void handle_syslinux_commands(char *cli_line, struct s_hardware *hardware)
-{
- if (!strncmp(cli_line, CLI_SHOW, sizeof(CLI_SHOW) - 1)) {
- syslinux_show(strstr(cli_line, "show") + sizeof(CLI_SHOW),
- hardware);
- return;
- }
-}
+struct cli_mode_descr syslinux_mode = {
+ .mode = SYSLINUX_MODE,
+ .name = CLI_SYSLINUX,
+ .default_modules = NULL,
+ .show_modules = &syslinux_show_modules,
+ .set_modules = NULL,
+};
struct cli_mode_descr *list_modes[] = {
&hdt_mode,
&dmi_mode,
+ &syslinux_mode,
};
/**
/* Execute the callback */
if (current_module != NULL)
return current_module->exec(argc, argv, hardware);
+ else {
+ if (current_mode->show_modules->default_callback != NULL)
+ return current_mode->show_modules
+ ->default_callback(argc,
+ argv,
+ hardware);
+ }
} else if (!strncmp(line, CLI_SET, sizeof(CLI_SET) - 1)) {
find_cli_callback_descr(module, current_mode->set_modules,
¤t_module);
/* Execute the callback */
if (current_module != NULL)
return current_module->exec(argc, argv, hardware);
+ else {
+ if (current_mode->set_modules->default_callback != NULL)
+ return current_mode->set_modules
+ ->default_callback(argc,
+ argv,
+ hardware);
+ }
}
dprintf("CLI DEBUG: callback not found!\n", argc);
case VESA_MODE:
handle_vesa_commands(line, hardware);
break;
- case SYSLINUX_MODE:
- handle_syslinux_commands(line, hardware);
- break;
case KERNEL_MODE:
handle_kernel_commands(line, hardware);
break;
struct cli_module_descr {
struct cli_callback_descr* modules;
const int nb_modules;
+ void ( * default_callback ) ( int argc, char** argv, struct s_hardware *hardware );
};
/* Describe a callback (belongs to a mode and a module) */
};
/* List of implemented modes */
-#define MAX_MODES 2
+#define MAX_MODES 3
struct cli_mode_descr *list_modes[MAX_MODES];
struct cli_mode_descr hdt_mode;
struct cli_mode_descr dmi_mode;
+struct cli_mode_descr syslinux_mode;
/* cli helpers */
void find_cli_mode_descr(cli_mode_t mode, struct cli_mode_descr **mode_found);