return false;
// Load the DLL
- if (Sys_LoadLibrary (dllnames_libavcodec, &libavcodec_dll, libavcodecfuncs))
+ if (Sys_LoadDependency (dllnames_libavcodec, &libavcodec_dll, libavcodecfuncs))
{
- if(Sys_LoadLibrary(dllnames_libavformat, &libavformat_dll, libavformatfuncs))
+ if(Sys_LoadDependency(dllnames_libavformat, &libavformat_dll, libavformatfuncs))
return true;
Con_Printf(CON_ERROR "Failed to load the libavformat library. Cannot use libavcodec without it\n");
Sys_FreeLibrary(&libavcodec_dll);
};
return
- Sys_LoadLibrary (dllnames_og, &og_dll, oggfuncs)
+ Sys_LoadDependency (dllnames_og, &og_dll, oggfuncs)
&&
- Sys_LoadLibrary (dllnames_th, &th_dll, theorafuncs)
+ Sys_LoadDependency (dllnames_th, &th_dll, theorafuncs)
&&
- Sys_LoadLibrary (dllnames_vo, &vo_dll, vorbisfuncs)
+ Sys_LoadDependency (dllnames_vo, &vo_dll, vorbisfuncs)
&&
- Sys_LoadLibrary (dllnames_ve, &ve_dll, vorbisencfuncs);
+ Sys_LoadDependency (dllnames_ve, &ve_dll, vorbisencfuncs);
}
void SCR_CaptureVideo_Ogg_Init(void)
return false;
// load DLL's
- Sys_LoadLibrary(dllnames_libavw, &libavw_dll, libavwfuncs);
+ Sys_LoadDependency(dllnames_libavw, &libavw_dll, libavwfuncs);
if (!libavw_dll)
return false;
return true;
// Load the DLL
- return Sys_LoadLibrary (dllnames, &d0_blind_id_dll, d0_blind_id_funcs);
+ return Sys_LoadDependency (dllnames, &d0_blind_id_dll, d0_blind_id_funcs);
}
static void Crypto_CloseLibrary (void)
return true;
// Load the DLL
- return Sys_LoadLibrary (dllnames, &d0_rijndael_dll, d0_rijndael_funcs);
+ return Sys_LoadDependency (dllnames, &d0_rijndael_dll, d0_rijndael_funcs);
}
static void Crypto_Rijndael_CloseLibrary (void)
return true;
// Load the DLL
- return Sys_LoadLibrary (dllnames, &zlib_dll, zlibfuncs);
+ return Sys_LoadDependency (dllnames, &zlib_dll, zlibfuncs);
#endif
}
break;
case USERDIRMODE_MYGAMES:
if (!shfolder_dll)
- Sys_LoadLibrary(shfolderdllnames, &shfolder_dll, shfolderfuncs);
+ Sys_LoadDependency(shfolderdllnames, &shfolder_dll, shfolderfuncs);
mydocsdir[0] = 0;
if (qSHGetFolderPath && qSHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir) == S_OK)
{
return -1;
case USERDIRMODE_SAVEDGAMES:
if (!shell32_dll)
- Sys_LoadLibrary(shell32dllnames, &shell32_dll, shell32funcs);
+ Sys_LoadDependency(shell32dllnames, &shell32_dll, shell32funcs);
if (!ole32_dll)
- Sys_LoadLibrary(ole32dllnames, &ole32_dll, ole32funcs);
+ Sys_LoadDependency(ole32dllnames, &ole32_dll, ole32funcs);
if (qSHGetKnownFolderPath && qCoInitializeEx && qCoTaskMemFree && qCoUninitialize)
{
savedgamesdir[0] = 0;
return true;
// Load the DLL
- if (!Sys_LoadLibrary (dllnames, &ft2_dll, ft2funcs))
+ if (!Sys_LoadDependency (dllnames, &ft2_dll, ft2funcs))
return false;
#endif
return true;
return true;
// Load the DLL
- if(!Sys_LoadLibrary (dllnames, &png_dll, pngfuncs))
+ if(!Sys_LoadDependency (dllnames, &png_dll, pngfuncs))
return false;
if(qpng_access_version_number() / 100 >= 104)
- if(!Sys_LoadLibrary (dllnames, &png14_dll, png14funcs))
+ if(!Sys_LoadDependency (dllnames, &png14_dll, png14funcs))
{
Sys_FreeLibrary (&png_dll);
return false;
#endif
// Load the DLL
- return Sys_LoadLibrary (dllnames, &jpeg_dll, jpegfuncs);
+ return Sys_LoadDependency (dllnames, &jpeg_dll, jpegfuncs);
#endif
}
return true;
// Load the DLL
- return Sys_LoadLibrary (dllnames, &curl_dll, curlfuncs);
+ return Sys_LoadDependency (dllnames, &curl_dll, curlfuncs);
}
// Load the DLLs
// We need to load both by hand because some OSes seem to not load
// the vorbis DLL automatically when loading the VorbisFile DLL
- return Sys_LoadLibrary (dllnames_vo, &vo_dll, vorbisfuncs) && Sys_LoadLibrary (dllnames_vf, &vf_dll, vorbisfilefuncs);
+ return Sys_LoadDependency (dllnames_vo, &vo_dll, vorbisfuncs) && Sys_LoadDependency (dllnames_vf, &vf_dll, vorbisfilefuncs);
}
return false;
// Load the DLL
- if (Sys_LoadLibrary (dllnames_xmp, &xmp_dll, xmpfuncs))
+ if (Sys_LoadDependency (dllnames_xmp, &xmp_dll, xmpfuncs))
{
if (*qxmp_vercode < 0x040200)
{
qbool Sys_LoadSelf(dllhandle_t *handle);
-/*! Loads a library.
+/*! Loads a dependency library.
* \param dllnames a NULL terminated array of possible names for the DLL you want to load.
* \param handle
* \param fcts
*/
-qbool Sys_LoadLibrary (const char** dllnames, dllhandle_t* handle, const dllfunction_t *fcts);
+qbool Sys_LoadDependency (const char** dllnames, dllhandle_t* handle, const dllfunction_t *fcts);
+
+/*! Loads a library.
+ * \param name a string of the library filename
+ * \param handle
+ * \return true if library was loaded successfully
+ */
+qbool Sys_LoadLibrary(const char *name, dllhandle_t *handle);
+
void Sys_FreeLibrary (dllhandle_t* handle);
void* Sys_GetProcAddress (dllhandle_t handle, const char* name);
===============================================================================
*/
-static qbool Sys_LoadLibraryFunctions(dllhandle_t dllhandle, const dllfunction_t *fcts, qbool complain, qbool has_next)
+static qbool Sys_LoadDependencyFunctions(dllhandle_t dllhandle, const dllfunction_t *fcts, qbool complain, qbool has_next)
{
const dllfunction_t *func;
if(dllhandle)
return true;
}
-qbool Sys_LoadLibrary (const char** dllnames, dllhandle_t* handle, const dllfunction_t *fcts)
+qbool Sys_LoadDependency (const char** dllnames, dllhandle_t* handle, const dllfunction_t *fcts)
{
#ifdef SUPPORTDLL
const dllfunction_t *func;
#ifndef WIN32
#ifdef PREFER_PRELOAD
dllhandle = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL);
- if(Sys_LoadLibraryFunctions(dllhandle, fcts, false, false))
+ if(Sys_LoadDependencyFunctions(dllhandle, fcts, false, false))
{
Con_DPrintf ("All of %s's functions were already linked in! Not loading dynamically...\n", dllnames[0]);
*handle = dllhandle;
SetDllDirectory("bin32");
# endif
# endif
- dllhandle = LoadLibrary (dllnames[i]);
- // no need to unset this - we want ALL dlls to be loaded from there, anyway
-#else
- dllhandle = dlopen (dllnames[i], RTLD_LAZY | RTLD_GLOBAL);
#endif
- if (Sys_LoadLibraryFunctions(dllhandle, fcts, true, (dllnames[i+1] != NULL) || (strrchr(sys.argv[0], '/'))))
- break;
- else
- Sys_FreeLibrary (&dllhandle);
+ if(Sys_LoadLibrary(dllnames[i], &dllhandle))
+ {
+ if (Sys_LoadDependencyFunctions(dllhandle, fcts, true, (dllnames[i+1] != NULL) || (strrchr(sys.argv[0], '/'))))
+ break;
+ else
+ Sys_FreeLibrary (&dllhandle);
+ }
}
// see if the names can be loaded relative to the executable path
strlcpy(temp, path, sizeof(temp));
strlcat(temp, dllnames[i], sizeof(temp));
Con_DPrintf (" \"%s\"", temp);
-#ifdef WIN32
- dllhandle = LoadLibrary (temp);
-#else
- dllhandle = dlopen (temp, RTLD_LAZY | RTLD_GLOBAL);
-#endif
- if (Sys_LoadLibraryFunctions(dllhandle, fcts, true, dllnames[i+1] != NULL))
- break;
- else
- Sys_FreeLibrary (&dllhandle);
+
+ if(Sys_LoadLibrary(temp, &dllhandle))
+ {
+ if (Sys_LoadDependencyFunctions(dllhandle, fcts, true, (dllnames[i+1] != NULL) || (strrchr(sys.argv[0], '/'))))
+ break;
+ else
+ Sys_FreeLibrary (&dllhandle);
+ }
}
}
#endif
}
+qbool Sys_LoadLibrary(const char *name, dllhandle_t *handle)
+{
+ dllhandle_t dllhandle = 0;
+
+ if(handle == NULL)
+ return false;
+
+#ifdef SUPPORTDLL
+# ifdef WIN32
+ dllhandle = LoadLibrary (name);
+# else
+ dllhandle = dlopen (name, RTLD_LAZY | RTLD_GLOBAL);
+# endif
+#endif
+ if(!dllhandle)
+ return false;
+
+ *handle = dllhandle;
+ return true;
+}
+
void Sys_FreeLibrary (dllhandle_t* handle)
{
#ifdef SUPPORTDLL
# define HAVE_USLEEP 1
#endif
-// this one is referenced elsewhere
+// these are referenced elsewhere
cvar_t sys_usenoclockbutbenchmark = {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "sys_usenoclockbutbenchmark", "0", "don't use ANY real timing, and simulate a clock (for benchmarking); the game then runs as fast as possible. Run a QC mod with bots that does some stuff, then does a quit at the end, to benchmark a server. NEVER do this on a public server."};
+cvar_t sys_libdir = {CF_READONLY | CF_CLIENT | CF_SERVER, "sys_libdir", "", "Default engine library directory"};
// these are not
static cvar_t sys_debugsleep = {CF_CLIENT | CF_SERVER, "sys_debugsleep", "0", "write requested and attained sleep times to standard output, to be used with gnuplot"};
{
Cvar_RegisterVariable(&sys_debugsleep);
Cvar_RegisterVariable(&sys_usenoclockbutbenchmark);
+ Cvar_RegisterVariable(&sys_libdir);
#if HAVE_TIMEGETTIME || HAVE_QUERYPERFORMANCECOUNTER || HAVE_CLOCKGETTIME || HAVE_GETTIMEOFDAY
if(sys_supportsdlgetticks)
{
//Cvar_RegisterVariable(&joy_x360_sensitivityroll);
#ifdef WIN32
- Sys_LoadLibrary(xinputdllnames, &xinputdll_dll, xinputdllfuncs);
+ Sys_LoadDependency(xinputdllnames, &xinputdll_dll, xinputdllfuncs);
#endif
Cmd_AddCommand(CF_CLIENT, "force_centerview", Force_CenterView_f, "recenters view (stops looking up/down)");
#ifndef LINK_TO_LIBODE
// Load the DLL
- if (Sys_LoadLibrary (dllnames, &ode_dll, odefuncs))
+ if (Sys_LoadDependency (dllnames, &ode_dll, odefuncs))
#endif
{
dInitODE();