From 2e5aae98ffdcae5477fc2026fc030bbacd3f70db Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Sat, 12 Mar 2005 00:41:19 +0000 Subject: Changed the #module command to handle searching multiple (currently compiled in) library paths, and remove the requirement for the .so part of the filename so that in future versions we can support .dll under cygwin diff --git a/cmd.c b/cmd.c index 45ca1c0..5460f96 100644 --- a/cmd.c +++ b/cmd.c @@ -228,14 +228,26 @@ static void cmd_module __P1 (char *,arg) { void *lib; void (*func)(); + int pindex; + struct stat junk; + char *prefixes[] = { + "./", + "/lib/powwow", + "/usr/lib/powwow", + "/usr/local/lib/powwow", + "$HOME/.powwow/lib" /* this doesn't work, but is here to remind me :p */ + }; + arg = skipspace(arg); - bzero( libname, 1024 ); - if( *arg == '.' || *arg == '/' ) { - /* No path mungling */ - strncpy( libname, arg, 1024 ); - }else{ - snprintf( libname, 1024, "/usr/local/lib/powwow/%s", arg ); + /* I changed it to work this way so that you can have libs in multiple places and + * also eventually to allow it to use .dll instead of .so under the cygwin environment */ + for( pindex = 0; pindex < 4; pindex++ ) { + bzero( libname, 1024 ); + snprintf( libname, 1024, "%s/%s.so", prefixes[ pindex ], arg ); + if( stat( libname, &junk ) == 0 ) { + break; + } } /* open lib */ -- cgit v0.10.2