11 extern cvar_t timestamps;
12 extern cvar_t timeformat;
14 static int sys_nostdout = false;
16 /* The translation table between the graphical font and plain ASCII --KB */
17 static char qfont_table[256] = {
18 '\0', '#', '#', '#', '#', '.', '#', '#',
19 '#', 9, 10, '#', ' ', 13, '.', '.',
20 '[', ']', '0', '1', '2', '3', '4', '5',
21 '6', '7', '8', '9', '.', '<', '=', '>',
22 ' ', '!', '"', '#', '$', '%', '&', '\'',
23 '(', ')', '*', '+', ',', '-', '.', '/',
24 '0', '1', '2', '3', '4', '5', '6', '7',
25 '8', '9', ':', ';', '<', '=', '>', '?',
26 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
27 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
28 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
29 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
30 '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
31 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
32 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
33 'x', 'y', 'z', '{', '|', '}', '~', '<',
35 '<', '=', '>', '#', '#', '.', '#', '#',
36 '#', '#', ' ', '#', ' ', '>', '.', '.',
37 '[', ']', '0', '1', '2', '3', '4', '5',
38 '6', '7', '8', '9', '.', '<', '=', '>',
39 ' ', '!', '"', '#', '$', '%', '&', '\'',
40 '(', ')', '*', '+', ',', '-', '.', '/',
41 '0', '1', '2', '3', '4', '5', '6', '7',
42 '8', '9', ':', ';', '<', '=', '>', '?',
43 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
44 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
45 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
46 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
47 '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
48 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
49 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
50 'x', 'y', 'z', '{', '|', '}', '~', '<'
54 extern HANDLE hinput, houtput;
57 #define MAX_PRINT_MSG 16384
58 void Sys_Printf (const char *fmt, ...)
61 char start[MAX_PRINT_MSG]; // String we started with
62 char stamp[MAX_PRINT_MSG]; // Time stamp
63 char final[MAX_PRINT_MSG]; // String we print
66 struct tm *local = NULL;
73 va_start (argptr, fmt);
75 vsnprintf (start, sizeof(start), fmt, argptr);
77 vsprintf (start, fmt, argptr);
84 if (timestamps.integer)
87 local = localtime (&mytime);
88 strftime (stamp, sizeof (stamp), timeformat.string, local);
90 snprintf (final, sizeof (final), "%s%s", stamp, start);
93 snprintf (final, sizeof (final), "%s", start);
95 // LordHavoc: make sure the string is terminated
96 final[MAX_PRINT_MSG - 1] = 0;
97 for (p = (unsigned char *) final;*p; p++)
100 if (cls.state == ca_dedicated)
101 WriteFile(houtput, final, strlen (final), &dummy, NULL);
107 // LordHavoc: 256 pak files (was 10)
108 #define MAX_HANDLES 256
109 QFile *sys_handles[MAX_HANDLES];
111 int findhandle (void)
115 for (i = 1;i < MAX_HANDLES;i++)
118 Sys_Error ("out of handles");
127 int Sys_FileLength (QFile *f)
132 Qseek (f, 0, SEEK_END);
134 Qseek (f, pos, SEEK_SET);
139 int Sys_FileOpenRead (const char *path, int *handle)
146 f = Qopen(path, "rbz");
157 retval = Sys_FileLength(f);
163 int Sys_FileOpenWrite (const char *path)
170 f = Qopen(path, "wb");
173 Con_Printf("Sys_FileOpenWrite: Error opening %s: %s", path, strerror(errno));
181 void Sys_FileClose (int handle)
183 Qclose (sys_handles[handle]);
184 sys_handles[handle] = NULL;
187 void Sys_FileSeek (int handle, int position)
189 Qseek (sys_handles[handle], position, SEEK_SET);
192 int Sys_FileRead (int handle, void *dest, int count)
194 return Qread (sys_handles[handle], dest, count);
197 int Sys_FileWrite (int handle, void *data, int count)
199 return Qwrite (sys_handles[handle], data, count);
202 int Sys_FileTime (const char *path)
207 f = Qopen(path, "rb");
218 if (stat (path,&buf) == -1)
225 void Sys_mkdir (const char *path)
234 char engineversion[128];
236 void Sys_Shared_EarlyInit(void)
240 #if defined(__linux__)
241 sprintf (engineversion, "%s Linux %s", gamename, buildstring);
243 sprintf (engineversion, "%s Windows %s", gamename, buildstring);
245 sprintf (engineversion, "%s Unknown %s", gamename, buildstring);
248 if (COM_CheckParm("-nostdout"))
251 printf("%s\n", engineversion);
254 void Sys_Shared_LateInit(void)