From 86744cbde38ef4b4e5cd6f5d318f1a940f83c14f Mon Sep 17 00:00:00 2001 From: zimoch Date: Thu, 21 Apr 2005 15:15:10 +0000 Subject: [PATCH] getLibVersion function added --- require.c | 28 +++++++++++++++++++++++----- require.h | 1 + 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/require.c b/require.c index 79c5f4e..44bb8c8 100644 --- a/require.c +++ b/require.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -15,7 +16,6 @@ int require(char* lib, char* version) { char libname[256]; char dbdname[256]; - char symbol[256]; char** path; char* loaded; SYM_TYPE type; @@ -33,7 +33,6 @@ int require(char* lib, char* version) printf("Directory is LIB = %s\n", *path); return ERROR; } - sprintf(symbol, "_%sLibRelease", lib); if (version) { sprintf(libname, "%s/%sLib-%s", *path, lib, version); @@ -45,16 +44,22 @@ int require(char* lib, char* version) sprintf(dbdname, "%s/dbd/%s.dbd", *path, lib); } - if (symFindByName(sysSymTbl, symbol, &loaded, &type) != OK) + loaded = getLibVersion(lib); + if (!loaded) { /* Load library and dbd file of requested version */ - if (ld(0, 0, libname) == NULL) + errno = 0; + if (ld(0, 0, libname) == NULL || errno) { + if (errno == S_symLib_SYMBOL_NOT_FOUND) + { + printf ("Library requires some other library\n"); + } printf ("Aborting startup stript.\n"); shellScriptAbort(); return ERROR; } - symFindByName(sysSymTbl, symbol, &loaded, &type); + loaded = getLibVersion(lib); printf("%sLib-%s loaded\n", lib, loaded); if (stat(dbdname, &filestat) != ERROR) { @@ -98,3 +103,16 @@ int require(char* lib, char* version) return OK; } } + +char* getLibVersion(char* lib) +{ + char symbol[256]; + char* loaded; + SYM_TYPE type; + + sprintf(symbol, "_%sLibRelease", lib); + if (symFindByName(sysSymTbl, symbol, &loaded, &type) != OK) return NULL; + return loaded; +} + + diff --git a/require.h b/require.h index 37eef6c..461dabe 100644 --- a/require.h +++ b/require.h @@ -2,5 +2,6 @@ #define require_h int require(char* lib, char* version); +char* getLibVersion(char* lib); #endif