From 324ebed124c5b0f78a1e343fbbd6ee41c2814b49 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Mon, 30 Apr 2001 17:23:04 +0000 Subject: Provide some description of the drivers --- mdk-stage1/Makefile | 9 +++++- mdk-stage1/modules.c | 20 +++++++++++- mdk-stage1/modules_descr.h | 50 +++++++++++++++++++++++++++++ mdk-stage1/newt-frontend.c | 13 +++++--- mdk-stage1/stdio-frontend.c | 78 ++++++++++++--------------------------------- mdk-stage1/tools.c | 13 ++++++++ mdk-stage1/tools.h | 3 +- 7 files changed, 121 insertions(+), 65 deletions(-) create mode 100644 mdk-stage1/modules_descr.h (limited to 'mdk-stage1') diff --git a/mdk-stage1/Makefile b/mdk-stage1/Makefile index 283f64ee9..46c03182d 100644 --- a/mdk-stage1/Makefile +++ b/mdk-stage1/Makefile @@ -203,4 +203,11 @@ tar-mkinitrd_helper: clean ifeq (.depend,$(wildcard .depend)) include .depend -endif +endif + + +*-CDROM.o: %-CDROM.o: %.o + +*-DISK.o: %-DISK.o: %.o + +*-NETWORK.o: %-NETWORK.o: %.o diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c index f3d43bd32..51e2b6902 100644 --- a/mdk-stage1/modules.c +++ b/mdk-stage1/modules.c @@ -30,6 +30,7 @@ #include "log.h" #include "mar/mar-extract-only.h" #include "frontend.h" +#include "modules_descr.h" #include "modules.h" @@ -346,7 +347,24 @@ enum return_type ask_insmod(enum driver_type type) snprintf(msg, sizeof(msg), "Which driver should I try to gain %s access?", mytype); - results = ask_from_list(msg, mar_list_contents(archive_name), &choice); + { + char ** drivers = mar_list_contents(archive_name); + char ** descrs = malloc(sizeof(char *) * string_array_length(drivers)); + char ** p_drivers = drivers; + char ** p_descrs = descrs; + while (p_drivers && *p_drivers) { + int i; + *p_descrs = NULL; + for (i = 0 ; i < modules_descriptions_num ; i++) { + if (!strncmp(*p_drivers, modules_descriptions[i].module, strlen(modules_descriptions[i].module)) + && (*p_drivers)[strlen(modules_descriptions[i].module)] == '.') /* one contains '.o' not the other */ + *p_descrs = modules_descriptions[i].descr; + } + p_drivers++; + p_descrs++; + } + results = ask_from_list_comments(msg, drivers, descrs, &choice); + } if (results == RETURN_OK) { choice[strlen(choice)-2] = '\0'; /* remove trailing .o */ diff --git a/mdk-stage1/modules_descr.h b/mdk-stage1/modules_descr.h new file mode 100644 index 000000000..356605137 --- /dev/null +++ b/mdk-stage1/modules_descr.h @@ -0,0 +1,50 @@ +/* + * Guillaume Cottenceau (gc@mandrakesoft.com) + * + * Copyright 2001 MandrakeSoft + * + * This software may be freely redistributed under the terms of the GNU + * public license. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef _MODULES_DESCR_H_ +#define _MODULES_DESCR_H_ + +struct module_descr { + const char * module; + char * descr; +}; + +struct module_descr modules_descriptions[] = { + /* description of network drivers that have not very explicit names */ + { "ne", "NE1000/NE2000/clones" }, + { "ne2k-pci", "PCI NE2000" }, + { "depca", "DEC DEPCA/DE100/DE101/DE200/DE201/DE202/DE210/DE422" }, + { "dgrs", "Digi RightSwitch SE-X" }, + { "ewrk3", "DEC DE203/DE204/DE205" }, + { "lance", "Allied Telesis AT1500, HP J2405A, NE2100/NE2500" }, + { "sis900", "SiS 900/7016/630E, Am79c901, RTL8201" }, + { "via-rhine", "VIA VT86c100A Rhine-II, 3043 Rhine-I" }, + { "tulip", "DEC 21040-family based cards" }, + { "wd", "WD8003/WD8013" }, + + /* description of scsi drivers that have not very explicit names */ + { "53c7,8xx", "NCR53c810/700" }, + { "sim710", "NCR53c710" }, + { "aic7xxx", "Adaptec 7xxx family (AIC/AHA/etc)" }, + { "atp870u", "ACARD/ARTOP AEC-6710/6712" }, + { "ncr53c8xx", "Symbios 53c family" }, + { "sym53c8xx", "Symbios 53c family" }, + { "sim710", "NCR53C710 family" }, + +}; + +int modules_descriptions_num = sizeof(modules_descriptions) / sizeof(struct module_descr); + + +#endif diff --git a/mdk-stage1/newt-frontend.c b/mdk-stage1/newt-frontend.c index 416d05ae6..85f56ec10 100644 --- a/mdk-stage1/newt-frontend.c +++ b/mdk-stage1/newt-frontend.c @@ -187,14 +187,17 @@ enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_ i = 0; while (elems && *elems) { - items[i] = malloc(sizeof(char) * (strlen(*elems) + strlen(*elems_comments) + 4)); + int j = (*elems_comments) ? strlen(*elems_comments) : 0; + items[i] = malloc(sizeof(char) * (strlen(*elems) + j + 4)); strcpy(items[i], *elems); - strcat(items[i], " ("); - strcat(items[i], *elems_comments); - strcat(items[i], ")"); + if (*elems_comments) { + strcat(items[i], " ("); + strcat(items[i], *elems_comments); + strcat(items[i], ")"); + } + elems_comments++; i++; elems++; - elems_comments++; } items[i] = NULL; diff --git a/mdk-stage1/stdio-frontend.c b/mdk-stage1/stdio-frontend.c index a8622bf1c..ec6601e9c 100644 --- a/mdk-stage1/stdio-frontend.c +++ b/mdk-stage1/stdio-frontend.c @@ -254,25 +254,38 @@ void end_progression(void) enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice) { char ** sav_elems = elems; - int i, j; + int i = 1; + int j = 0; + + printf("> %s\n[ 0] Cancel", msg); - printf("> %s\n(0) Cancel\n", msg); - i = 1; while (elems && *elems) { - printf("(%d) %s (%s)\n", i, *elems, *elems_comments); + if (elems_comments && *elems_comments) { + printf("\n[%2d] %s (%s)", i, *elems, *elems_comments); + j = 0; + } else { + if (j == 0) + printf("\n"); + printf("[%2d] %-14s ", i, *elems); + j++; + } + if (j == 4) + j = 0; + + if (elems_comments) + elems_comments++; i++; elems++; - elems_comments++; } - printf("? "); + printf("\n? "); j = get_int_response(); if (j == 0) return RETURN_BACK; - if (j >= 1 && j < i) { + if (j >= 1 && j <= i) { *choice = strdup(sav_elems[j-1]); return RETURN_OK; } @@ -283,56 +296,7 @@ enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_ enum return_type ask_from_list(char *msg, char ** elems, char ** choice) { - char ** sav_elems = elems; - int i, j; - - i = 0; - while (elems && *elems) { - i++; - elems++; - } - - if (i < 10) { - printf("> %s\n(0) Cancel\n", msg); - for (j=0; j %s\n( 0) Cancel\n", msg); - if (i < 20) - for (j=0; j= 1 && j <= i) { - *choice = strdup(sav_elems[j-1]); - return RETURN_OK; - } - - return RETURN_ERROR; + return ask_from_list_comments(msg, elems, NULL, choice); } diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c index 9d0f083f6..cd1b40fe8 100644 --- a/mdk-stage1/tools.c +++ b/mdk-stage1/tools.c @@ -408,3 +408,16 @@ char ** list_directory(char * direct) tmp[i] = NULL; return memdup(tmp, sizeof(char*) * (i+1)); } + + +int string_array_length(char ** a) +{ + int i = 0; + if (!a) + return -1; + while (a && *a) { + a++; + i++; + } + return i; +} diff --git a/mdk-stage1/tools.h b/mdk-stage1/tools.h index 85295492b..5d38b0364 100644 --- a/mdk-stage1/tools.h +++ b/mdk-stage1/tools.h @@ -39,6 +39,7 @@ void add_to_env(char * name, char * value); void handle_env(char ** env); char ** grab_env(void); char ** list_directory(char * direct); +int string_array_length(char ** a); struct param_elem { @@ -47,6 +48,6 @@ struct param_elem }; #define ptr_begins_static_str(pointer,static_str) (!strncmp(pointer,static_str,sizeof(static_str)-1)) - +#define streq !strcmp #endif -- cgit v1.2.1