aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErwan Velu <erwan.velu@free.fr>2009-02-21 14:21:31 +0100
committerH. Peter Anvin <hpa@zytor.com>2009-02-25 20:58:43 -0800
commit55c14f0f4e6f7e277c3d4b0ca061a3984e5e260d (patch)
tree6c3a05a645c4c5108b60c20367a2bdd400394c20
parent624544ec8eaaca3f0c9aa68c519dc7a492c565f2 (diff)
downloadsyslinux-elf-55c14f0f4e6f7e277c3d4b0ca061a3984e5e260d.tar.gz
syslinux-elf-55c14f0f4e6f7e277c3d4b0ca061a3984e5e260d.tar.xz
syslinux-elf-55c14f0f4e6f7e277c3d4b0ca061a3984e5e260d.zip
hdt: More cleanup from Oznog
-rw-r--r--com32/hdt/hdt-cli.c33
-rw-r--r--com32/hdt/hdt-cli.h10
-rw-r--r--com32/hdt/hdt-common.c2
-rw-r--r--com32/hdt/hdt-common.h2
-rw-r--r--com32/hdt/hdt.c5
5 files changed, 34 insertions, 18 deletions
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 4b5910a5..7f168bb5 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -31,21 +31,32 @@
#include <stdlib.h>
#include <string.h>
-void set_mode(struct s_cli_mode *cli_mode, int mode, struct s_hardware *hardware) {
+void set_mode(struct s_cli_mode *cli_mode, cli_mode_t mode, struct s_hardware *hardware) {
switch (mode) {
- case EXIT_MODE: cli_mode->mode=mode; snprintf(cli_mode->prompt,sizeof cli_mode->prompt,"%s:",CLI_EXIT); break;
- case HDT_MODE: cli_mode->mode=mode; snprintf(cli_mode->prompt,sizeof cli_mode->prompt,"%s:",CLI_HDT); break;
+ case EXIT_MODE:
+ cli_mode->mode=mode;
+ snprintf(cli_mode->prompt, sizeof(cli_mode->prompt), "%s:", CLI_EXIT);
+ break;
+
+ case HDT_MODE:
+ cli_mode->mode=mode;
+ snprintf(cli_mode->prompt, sizeof cli_mode->prompt, "%s:", CLI_HDT);
+ break;
+
case PCI_MODE:
cli_mode->mode=mode;
- snprintf(cli_mode->prompt,sizeof cli_mode->prompt,"%s:",CLI_PCI);
- if (hardware->pci_detection==false) detect_pci(hardware);
+ snprintf(cli_mode->prompt,sizeof cli_mode->prompt,"%s:", CLI_PCI);
+ if (!hardware->pci_detection)
+ detect_pci(hardware);
break;
+
case DMI_MODE:
- if (hardware->dmi_detection==false) detect_dmi(hardware);
- if (hardware->is_dmi_valid==false) {
+ if (!hardware->dmi_detection)
+ detect_dmi(hardware);
+ if (!hardware->is_dmi_valid) {
printf("No valid DMI table found, exiting.\n");
break;
- }
+ }
cli_mode->mode=mode;
snprintf(cli_mode->prompt,sizeof cli_mode->prompt,"%s:",CLI_DMI);
break;
@@ -108,9 +119,9 @@ void start_cli_mode(int argc, char *argv[]) {
int do_exit(struct s_cli_mode *cli_mode) {
switch (cli_mode->mode) {
- case HDT_MODE: return EXIT_MODE; break;
- case PCI_MODE: return HDT_MODE; break;
- case DMI_MODE: return HDT_MODE; break;
+ case HDT_MODE: return EXIT_MODE;
+ case PCI_MODE: return HDT_MODE;
+ case DMI_MODE: return HDT_MODE;
}
return HDT_MODE;
}
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 14f62c56..f4022e6e 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -46,12 +46,18 @@
#define CLI_DMI_SYSTEM "system"
#define CLI_DMI_MODULES "modules"
+typedef enum {
+ EXIT_MODE,
+ HDT_MODE,
+ PCI_MODE,
+ DMI_MODE
+} cli_mode_t;
+
struct s_cli_mode {
- int mode;
+ cli_mode_t mode;
char prompt[32];
};
-enum { EXIT_MODE, HDT_MODE, PCI_MODE, DMI_MODE };
void show_cli_help(struct s_cli_mode *cli_mode);
void start_cli_mode(int argc, char *argv[]);
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index c6694462..cf5b1aee 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -69,7 +69,7 @@ void detect_disks(struct s_hardware *hardware) {
if (get_disk_params(drive,hardware->disk_info) != 0)
continue;
struct diskinfo *d=&hardware->disk_info[drive];
- printf(" DISK 0x%X: %s : %s %s: sectors=%d, s/t=%d head=%d : EDD=%s\n",drive,d->aid.model,d->host_bus_type,d->interface_type, d->sectors, d->sectors_per_track,d-<heads,d->edd_version);
+ printf(" DISK 0x%X: %s : %s %s: sectors=%d, s/t=%d head=%d : EDD=%s\n",drive,d->aid.model,d->host_bus_type,d->interface_type, d->sectors, d->sectors_per_track,d->heads,d->edd_version);
}
}
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index 3031a601..f568ea19 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -63,7 +63,7 @@ struct s_hardware {
bool disk_detection; /* Does the disk stuff have been already detected */
};
-char *find_argument(char **argv, const char *argument);
+char *find_argument(const char **argv, const char *argument);
int detect_dmi(struct s_hardware *hardware);
void detect_disks(struct s_hardware *hardware);
void detect_pci(struct s_hardware *hardware);
diff --git a/com32/hdt/hdt.c b/com32/hdt/hdt.c
index 42f6bf36..f482da97 100644
--- a/com32/hdt/hdt.c
+++ b/com32/hdt/hdt.c
@@ -44,8 +44,7 @@ int display_line_nb=0;
int main(int argc, char *argv[])
{
char version_string[256];
- char *arg, **argp;
- argp = argv+1;
+ char *arg;
snprintf(version_string,sizeof version_string,"%s %s by %s",PRODUCT_NAME,VERSION,AUTHOR);
@@ -56,7 +55,7 @@ int main(int argc, char *argv[])
printf("%s\n",version_string);
- if ((arg = find_argument(argp, "nomenu"))) {
+ if ((arg = find_argument(argv+1, "nomenu"))) {
start_cli_mode(argc, argv);
} else{
return start_menu_mode(version_string);