From ad6042cadfc532aa6c74321fa7d667e86bf6b1ea Mon Sep 17 00:00:00 2001 From: Erik Troan Date: Wed, 26 Apr 2000 23:22:39 +0000 Subject: merge module info files based on module name --- isys/moduleinfo.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/isys/moduleinfo.c b/isys/moduleinfo.c index 5e38f91c6..b40e93652 100644 --- a/isys/moduleinfo.c +++ b/isys/moduleinfo.c @@ -42,7 +42,7 @@ struct moduleInfo * isysFindModuleInfo(moduleInfoSet mis, if (!strcmp(moduleName, mis->moduleList[i].moduleName)) { if (!found) found = mis->moduleList + i; - else if (found->path && !mis->moduleList[i].path) + else if (found->locationID && !mis->moduleList[i].locationID) ; else found = mis->moduleList + i; @@ -57,13 +57,14 @@ moduleInfoSet isysNewModuleInfoSet(void) { } int isysReadModuleInfo(const char * filename, moduleInfoSet mis, - char * modPath) { + char * ident) { int fd, isIndented; char * buf, * start, * next, * chptr; struct stat sb; char oldch; struct moduleInfo * nextModule; int modulesAlloced; + int i; fd = open(filename, O_RDONLY); if (fd < 0) return -1; @@ -102,22 +103,36 @@ int isysReadModuleInfo(const char * filename, moduleInfoSet mis, if (*start != '\n' && *start && *start != '#') { if (!isIndented) { - if (nextModule && nextModule->moduleName) mis->numModules++; + if (nextModule && nextModule->moduleName && + nextModule == (mis->moduleList + mis->numModules)) + mis->numModules++; if (mis->numModules == modulesAlloced) { modulesAlloced += 5; mis->moduleList = realloc(mis->moduleList, modulesAlloced * sizeof(*mis->moduleList)); } - nextModule = mis->moduleList + mis->numModules; - nextModule->moduleName = strdup(start); - nextModule->major = DRIVER_NONE; - nextModule->minor = DRIVER_MINOR_NONE; - nextModule->description = NULL; - nextModule->flags = 0; - nextModule->args = NULL; - nextModule->numArgs = 0; - nextModule->path = modPath; + + nextModule = NULL; + for (i = 0; i < mis->numModules; i++) { + if (!strcmp(mis->mods[i]->name, start) { + nextModule = mis->mods[i]; + break; + } + } + + if (!nextModule) { + nextModule = mis->moduleList + mis->numModules; + + nextModule->moduleName = strdup(start); + nextModule->major = DRIVER_NONE; + nextModule->minor = DRIVER_MINOR_NONE; + nextModule->description = NULL; + nextModule->flags = 0; + nextModule->args = NULL; + nextModule->numArgs = 0; + nextModule->locationID = ident; + } } else if (!nextModule) { /* ACK! syntax error */ return 1; -- cgit