13 extern cvar_t timestamps;
14 extern cvar_t timeformat;
16 static int sys_nostdout = false;
18 /* The translation table between the graphical font and plain ASCII --KB */
19 static char qfont_table[256] = {
20 '\0', '#', '#', '#', '#', '.', '#', '#',
21 '#', 9, 10, '#', ' ', 13, '.', '.',
22 '[', ']', '0', '1', '2', '3', '4', '5',
23 '6', '7', '8', '9', '.', '<', '=', '>',
24 ' ', '!', '"', '#', '$', '%', '&', '\'',
25 '(', ')', '*', '+', ',', '-', '.', '/',
26 '0', '1', '2', '3', '4', '5', '6', '7',
27 '8', '9', ':', ';', '<', '=', '>', '?',
28 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
29 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
30 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
31 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
32 '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
33 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
34 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
35 'x', 'y', 'z', '{', '|', '}', '~', '<',
37 '<', '=', '>', '#', '#', '.', '#', '#',
38 '#', '#', ' ', '#', ' ', '>', '.', '.',
39 '[', ']', '0', '1', '2', '3', '4', '5',
40 '6', '7', '8', '9', '.', '<', '=', '>',
41 ' ', '!', '"', '#', '$', '%', '&', '\'',
42 '(', ')', '*', '+', ',', '-', '.', '/',
43 '0', '1', '2', '3', '4', '5', '6', '7',
44 '8', '9', ':', ';', '<', '=', '>', '?',
45 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
46 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
47 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
48 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
49 '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
50 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
51 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
52 'x', 'y', 'z', '{', '|', '}', '~', '<'
56 extern HANDLE hinput, houtput;
59 #define MAX_PRINT_MSG 16384
60 void Sys_Printf (const char *fmt, ...)
63 char start[MAX_PRINT_MSG]; // String we started with
64 char stamp[MAX_PRINT_MSG]; // Time stamp
65 char final[MAX_PRINT_MSG]; // String we print
68 struct tm *local = NULL;
75 va_start (argptr, fmt);
77 vsnprintf (start, sizeof(start), fmt, argptr);
79 vsprintf (start, fmt, argptr);
86 if (timestamps.integer)
89 local = localtime (&mytime);
90 strftime (stamp, sizeof (stamp), timeformat.string, local);
92 snprintf (final, sizeof (final), "%s%s", stamp, start);
95 snprintf (final, sizeof (final), "%s", start);
97 // LordHavoc: make sure the string is terminated
98 final[MAX_PRINT_MSG - 1] = 0;
99 for (p = (unsigned char *) final;*p; p++)
100 *p = qfont_table[*p];
102 if (cls.state == ca_dedicated)
103 WriteFile(houtput, final, strlen (final), &dummy, NULL);
109 // LordHavoc: 256 pak files (was 10)
110 #define MAX_HANDLES 256
111 QFile *sys_handles[MAX_HANDLES];
113 int findhandle (void)
117 for (i = 1;i < MAX_HANDLES;i++)
120 Sys_Error ("out of handles");
129 int Sys_FileLength (QFile *f)
134 Qseek (f, 0, SEEK_END);
136 Qseek (f, pos, SEEK_SET);
141 int Sys_FileOpenRead (const char *path, int *handle)
148 f = Qopen(path, "rbz");
159 retval = Sys_FileLength(f);
165 int Sys_FileOpenWrite (const char *path)
172 f = Qopen(path, "wb");
175 Con_Printf("Sys_FileOpenWrite: Error opening %s: %s", path, strerror(errno));
183 void Sys_FileClose (int handle)
185 Qclose (sys_handles[handle]);
186 sys_handles[handle] = NULL;
189 void Sys_FileSeek (int handle, int position)
191 Qseek (sys_handles[handle], position, SEEK_SET);
194 int Sys_FileRead (int handle, void *dest, int count)
196 return Qread (sys_handles[handle], dest, count);
199 int Sys_FileWrite (int handle, void *data, int count)
201 return Qwrite (sys_handles[handle], data, count);
204 int Sys_FileTime (const char *path)
209 f = Qopen(path, "rb");
220 if (stat (path,&buf) == -1)
227 void Sys_mkdir (const char *path)
236 char engineversion[128];
238 void Sys_Shared_EarlyInit(void)
245 #if defined(__linux__)
246 sprintf (engineversion, "%s Linux %s", gamename, buildstring);
248 sprintf (engineversion, "%s Windows %s", gamename, buildstring);
250 sprintf (engineversion, "%s Unknown %s", gamename, buildstring);
253 if (COM_CheckParm("-nostdout"))
256 Con_Printf("%s\n", engineversion);
259 void Sys_Shared_LateInit(void)