aboutsummaryrefslogtreecommitdiffstats
path: root/com32/hdt/hdt-cli-hdt.c
diff options
context:
space:
mode:
authorPierre-Alexandre Meyer <pierre@mouraf.org>2009-04-22 23:57:33 -0700
committerPierre-Alexandre Meyer <pierre@mouraf.org>2009-04-22 23:57:33 -0700
commitd0a0e562d9554cb38650f64be6e9dab9c29d99de (patch)
tree8d95b1534e44569f7d0093230d2b755a329f1903 /com32/hdt/hdt-cli-hdt.c
parent272c28d921ee807dc4c20634873af4b64765cacf (diff)
parent13c60849867ecc575b8f28dc259705b772611402 (diff)
downloadsyslinux.git-d0a0e562d9554cb38650f64be6e9dab9c29d99de.tar.gz
syslinux.git-d0a0e562d9554cb38650f64be6e9dab9c29d99de.tar.xz
syslinux.git-d0a0e562d9554cb38650f64be6e9dab9c29d99de.zip
Merge commit 'mouraf/for-erwan' into for-erwan
Conflicts: com32/hdt/hdt-cli-hdt.c
Diffstat (limited to 'com32/hdt/hdt-cli-hdt.c')
-rw-r--r--com32/hdt/hdt-cli-hdt.c54
1 files changed, 38 insertions, 16 deletions
diff --git a/com32/hdt/hdt-cli-hdt.c b/com32/hdt/hdt-cli-hdt.c
index 8b92e939..46f3669a 100644
--- a/com32/hdt/hdt-cli-hdt.c
+++ b/com32/hdt/hdt-cli-hdt.c
@@ -50,11 +50,13 @@ static void cli_clear_screen(int argc __unused, char** argv __unused,
static void main_show_modes(int argc __unused, char** argv __unused,
struct s_hardware *hardware __unused)
{
- int i;
+ int i = 0;
printf("Available modes:\n");
- for (i = 0; i < MAX_MODES; i++)
+ while (list_modes[i]) {
printf("\t%s\n", list_modes[i]->name);
+ i++;
+ }
}
/**
@@ -108,7 +110,7 @@ static void do_exit(int argc __unused, char** argv __unused,
static void show_cli_help(int argc __unused, char** argv __unused,
struct s_hardware *hardware __unused)
{
- int j;
+ int j = 0;
struct cli_mode_descr *current_mode;
struct cli_callback_descr* associated_module = NULL;
@@ -117,36 +119,46 @@ static void show_cli_help(int argc __unused, char** argv __unused,
printf("Available commands are:\n");
/* List first default modules of the mode */
- if (current_mode->default_modules != NULL ) {
- for (j = 0; j < current_mode->default_modules->nb_modules; j++) {
+ if (current_mode->default_modules &&
+ current_mode->default_modules->modules) {
+ while (current_mode->default_modules->modules[j].name) {
printf("%s ",
current_mode->default_modules->modules[j].name);
+ j++;
}
printf("\n");
}
/* List secondly the show modules of the mode */
- if (current_mode->show_modules != NULL &&
- current_mode->show_modules->nb_modules != 0) {
+ if (current_mode->show_modules &&
+ current_mode->show_modules->modules) {
printf("show commands:\n");
- for (j = 0; j < current_mode->show_modules->nb_modules; j++)
+ j = 0;
+ while (current_mode->show_modules->modules[j].name) {
printf("\t%s\n",
current_mode->show_modules->modules[j].name);
+ j++;
+ }
}
/* List thirdly the set modules of the mode */
- if (current_mode->set_modules != NULL &&
- current_mode->set_modules->nb_modules != 0) {
+ if (current_mode->set_modules &&
+ current_mode->set_modules->modules) {
printf("set commands:\n");
- for (j = 0; j < current_mode->set_modules->nb_modules; j++)
+ j = 0;
+ while (current_mode->set_modules->modules[j].name) {
printf("\t%s\n",
current_mode->set_modules->modules[j].name);
+ j++;
+ }
}
/* List finally the default modules of the hdt mode */
if (current_mode->mode != hdt_mode.mode &&
- hdt_mode.default_modules != NULL ) {
- for (j = 0; j < hdt_mode.default_modules->nb_modules; j++) {
+ hdt_mode.default_modules &&
+ hdt_mode.default_modules->modules) {
+ j = 0;
+ while (hdt_mode.default_modules->modules[j].name) {
/*
* Any default command that is present in hdt mode but
* not in the current mode is available. A default
@@ -160,6 +172,7 @@ static void show_cli_help(int argc __unused, char** argv __unused,
if (associated_module == NULL)
printf("%s ",
hdt_mode.default_modules->modules[j].name);
+ j++;
}
printf("\n");
}
@@ -248,6 +261,10 @@ struct cli_callback_descr list_hdt_default_modules[] = {
.name = CLI_MENU,
.exec = goto_menu,
},
+ {
+ .name = NULL,
+ .exec = NULL
+ },
};
struct cli_callback_descr list_hdt_show_modules[] = {
@@ -291,6 +308,10 @@ struct cli_callback_descr list_hdt_show_modules[] = {
.name = "modes",
.exec = main_show_modes,
},
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
};
struct cli_callback_descr list_hdt_set_modules[] = {
@@ -298,22 +319,23 @@ struct cli_callback_descr list_hdt_set_modules[] = {
.name = CLI_MODE,
.exec = cli_set_mode,
},
+ {
+ .name = NULL,
+ .exec = NULL,
+ },
};
struct cli_module_descr hdt_default_modules = {
.modules = list_hdt_default_modules,
- .nb_modules = 4,
};
struct cli_module_descr hdt_show_modules = {
.modules = list_hdt_show_modules,
- .nb_modules = 10,
.default_callback = main_show_summary,
};
struct cli_module_descr hdt_set_modules = {
.modules = list_hdt_set_modules,
- .nb_modules = 1,
};
struct cli_mode_descr hdt_mode = {