]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sys_shared.c
- Sys_LoadLibrary now accepts several possible names for a DLL (it fixes
[xonotic/darkplaces.git] / sys_shared.c
index 9bebbde3175b270ae217aec611f190061beb93f5..e876daf18ae32d0c73741eb90ed9a05f9a11325a 100644 (file)
@@ -48,6 +48,8 @@ void Sys_Shared_EarlyInit(void)
        os = "NetBSD";
 #elif defined(__OpenBSD__)
        os = "OpenBSD";
+#elif defined(MACOSX)
+       os = "Mac OS X";
 #else
        os = "Unknown";
 #endif
@@ -72,10 +74,11 @@ DLL MANAGEMENT
 ===============================================================================
 */
 
-qboolean Sys_LoadLibrary (const char* dllname, dllhandle_t* handle, const dllfunction_t *fcts)
+qboolean Sys_LoadLibrary (const char** dllnames, dllhandle_t* handle, const dllfunction_t *fcts)
 {
        const dllfunction_t *func;
-       dllhandle_t dllhandle;
+       dllhandle_t dllhandle = 0;
+       unsigned int i;
 
        if (handle == NULL)
                return false;
@@ -84,17 +87,25 @@ qboolean Sys_LoadLibrary (const char* dllname, dllhandle_t* handle, const dllfun
        for (func = fcts; func && func->name != NULL; func++)
                *func->funcvariable = NULL;
 
-       // Load the DLL
+       // Try every possible name
+       for (i = 0; dllnames[i] != NULL; i++)
+       {
 #ifdef WIN32
-       dllhandle = LoadLibrary (dllname);
+               dllhandle = LoadLibrary (dllnames[i]);
 #else
-       dllhandle = dlopen (dllname, RTLD_LAZY);
+               dllhandle = dlopen (dllnames[i], RTLD_LAZY);
 #endif
+               if (dllhandle)
+                       break;
+
+               Con_Printf ("Can't load \"%s\".\n", dllnames[i]);
+       }
+
+       // No DLL found
        if (! dllhandle)
-       {
-               Con_Printf ("Can't load \"%s\".\n", dllname);
                return false;
-       }
+
+       Con_Printf("\"%s\" loaded.\n", dllnames[i]);
 
        // Get the function adresses
        for (func = fcts; func && func->name != NULL; func++)
@@ -106,7 +117,6 @@ qboolean Sys_LoadLibrary (const char* dllname, dllhandle_t* handle, const dllfun
                }
 
        *handle = dllhandle;
-       Con_Printf("\"%s\" loaded.\n", dllname);
        return true;
 }