10 static char sys_timestring[128];
11 char *Sys_TimeString(const char *timeformat)
13 time_t mytime = time(NULL);
14 strftime(sys_timestring, sizeof(sys_timestring), timeformat, localtime(&mytime));
15 return sys_timestring;
19 extern qboolean host_shuttingdown;
22 host_shuttingdown = true;
28 ===============================================================================
32 ===============================================================================
35 qboolean Sys_LoadLibrary (const char** dllnames, dllhandle_t* handle, const dllfunction_t *fcts)
37 const dllfunction_t *func;
38 dllhandle_t dllhandle = 0;
45 for (func = fcts; func && func->name != NULL; func++)
46 *func->funcvariable = NULL;
48 // Try every possible name
49 for (i = 0; dllnames[i] != NULL; i++)
52 dllhandle = LoadLibrary (dllnames[i]);
54 dllhandle = dlopen (dllnames[i], RTLD_LAZY);
59 Con_Printf ("Can't load \"%s\".\n", dllnames[i]);
66 Con_Printf("\"%s\" loaded.\n", dllnames[i]);
68 // Get the function adresses
69 for (func = fcts; func && func->name != NULL; func++)
70 if (!(*func->funcvariable = (void *) Sys_GetProcAddress (dllhandle, func->name)))
72 Con_Printf ("Missing function \"%s\" - broken library!\n", func->name);
73 Sys_UnloadLibrary (&dllhandle);
81 void Sys_UnloadLibrary (dllhandle_t* handle)
83 if (handle == NULL || *handle == NULL)
87 FreeLibrary (*handle);
95 void* Sys_GetProcAddress (dllhandle_t handle, const char* name)
98 return (void *)GetProcAddress (handle, name);
100 return (void *)dlsym (handle, name);