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]);
65 // see if the names can be loaded relative to the executable path
66 // (this is for Mac OSX which does not check next to the executable)
67 if (strrchr(com_argv[0], '/'))
69 char path[MAX_OSPATH];
70 strlcpy(path, com_argv[0], sizeof(path));
71 strrchr(path, '/')[1] = 0;
72 for (i = 0; dllnames[i] != NULL; i++)
74 char temp[MAX_OSPATH];
75 strlcpy(temp, path, sizeof(temp));
76 strlcat(temp, dllnames[i], sizeof(temp));
78 dllhandle = LoadLibrary (temp);
80 dllhandle = dlopen (temp, RTLD_LAZY);
85 Con_Printf ("Can't load \"%s\".\n", temp);
94 Con_Printf("\"%s\" loaded.\n", dllnames[i]);
96 // Get the function adresses
97 for (func = fcts; func && func->name != NULL; func++)
98 if (!(*func->funcvariable = (void *) Sys_GetProcAddress (dllhandle, func->name)))
100 Con_Printf ("Missing function \"%s\" - broken library!\n", func->name);
101 Sys_UnloadLibrary (&dllhandle);
109 void Sys_UnloadLibrary (dllhandle_t* handle)
111 if (handle == NULL || *handle == NULL)
115 FreeLibrary (*handle);
123 void* Sys_GetProcAddress (dllhandle_t handle, const char* name)
126 return (void *)GetProcAddress (handle, name);
128 return (void *)dlsym (handle, name);