10 extern cvar_t timestamps;
11 extern cvar_t timeformat;
13 static int sys_nostdout = false;
15 /* The translation table between the graphical font and plain ASCII --KB */
16 static char qfont_table[256] = {
17 '\0', '#', '#', '#', '#', '.', '#', '#',
18 '#', 9, 10, '#', ' ', 13, '.', '.',
19 '[', ']', '0', '1', '2', '3', '4', '5',
20 '6', '7', '8', '9', '.', '<', '=', '>',
21 ' ', '!', '"', '#', '$', '%', '&', '\'',
22 '(', ')', '*', '+', ',', '-', '.', '/',
23 '0', '1', '2', '3', '4', '5', '6', '7',
24 '8', '9', ':', ';', '<', '=', '>', '?',
25 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
26 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
27 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
28 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
29 '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
30 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
31 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
32 'x', 'y', 'z', '{', '|', '}', '~', '<',
34 '<', '=', '>', '#', '#', '.', '#', '#',
35 '#', '#', ' ', '#', ' ', '>', '.', '.',
36 '[', ']', '0', '1', '2', '3', '4', '5',
37 '6', '7', '8', '9', '.', '<', '=', '>',
38 ' ', '!', '"', '#', '$', '%', '&', '\'',
39 '(', ')', '*', '+', ',', '-', '.', '/',
40 '0', '1', '2', '3', '4', '5', '6', '7',
41 '8', '9', ':', ';', '<', '=', '>', '?',
42 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
43 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
44 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
45 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
46 '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
47 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
48 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
49 'x', 'y', 'z', '{', '|', '}', '~', '<'
52 static char sys_timestring[128];
53 char *Sys_TimeString(const char *timeformat)
55 time_t mytime = time(NULL);
56 strftime(sys_timestring, sizeof(sys_timestring), timeformat, localtime(&mytime));
57 return sys_timestring;
61 #define MAXPRINTMSG 16384
63 void Sys_Print(const char *msg)
67 char final[MAXPRINTMSG];
72 if (timestamps.integer)
73 snprintf(final, sizeof(final), "%s%s", Sys_TimeString(timeformat.string), msg);
75 strlcpy (final, msg, sizeof (final));
77 // LordHavoc: make sure the string is terminated
78 final[MAXPRINTMSG-1] = 0;
79 for (p = (unsigned char *) final;*p; p++)
81 Sys_PrintToTerminal(final);
84 void Sys_Printf(const char *fmt, ...)
87 char msg[MAXPRINTMSG]; // String we started with
90 vsnprintf(msg,sizeof(msg),fmt,argptr);
102 char engineversion[128];
104 void Sys_Shared_EarlyInit(void)
113 #if defined(__linux__)
117 #elif defined(__NetBSD__)
119 #elif defined(__OpenBSD__)
124 snprintf (engineversion, sizeof (engineversion), "%s %s %s", gamename, os, buildstring);
126 if (COM_CheckParm("-nostdout"))
129 Con_Printf("%s\n", engineversion);
132 void Sys_Shared_LateInit(void)
137 ===============================================================================
141 ===============================================================================
144 qboolean Sys_LoadLibrary (const char* dllname, dllhandle_t* handle, const dllfunction_t *fcts)
146 const dllfunction_t *func;
147 dllhandle_t dllhandle;
153 for (func = fcts; func && func->name != NULL; func++)
154 *func->funcvariable = NULL;
158 dllhandle = LoadLibrary (dllname);
160 dllhandle = dlopen (dllname, RTLD_LAZY);
164 Con_Printf ("Can't load \"%s\".\n", dllname);
168 // Get the function adresses
169 for (func = fcts; func && func->name != NULL; func++)
170 if (!(*func->funcvariable = (void *) Sys_GetProcAddress (dllhandle, func->name)))
172 Con_Printf ("Missing function \"%s\" - broken library!\n", func->name);
173 Sys_UnloadLibrary (&dllhandle);
178 Con_DPrintf("\"%s\" loaded.\n", dllname);
182 void Sys_UnloadLibrary (dllhandle_t* handle)
184 if (handle == NULL || *handle == NULL)
188 FreeLibrary (*handle);
196 void* Sys_GetProcAddress (dllhandle_t handle, const char* name)
199 return (void *)GetProcAddress (handle, name);
201 return (void *)dlsym (handle, name);