16 // =======================================================================
18 // =======================================================================
20 void Sys_Shutdown (void)
23 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
30 void Sys_Error (const char *error, ...)
33 char string[MAX_INPUTLINE];
35 // change stdin to non blocking
37 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
40 va_start (argptr,error);
41 dpvsnprintf (string, sizeof (string), error, argptr);
44 Con_Printf ("Quake Error: %s\n", string);
50 void Sys_PrintToTerminal(const char *text)
53 // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
54 int origflags = fcntl (1, F_GETFL, 0);
55 fcntl (1, F_SETFL, origflags & ~FNDELAY);
61 int written = (int)write(1, text, (int)strlen(text));
63 break; // sorry, I cannot do anything about this error - without an output
67 fcntl (1, F_SETFL, origflags);
69 //fprintf(stdout, "%s", text);
72 char *Sys_ConsoleInput(void)
74 if (cls.state == ca_dedicated)
76 static char text[MAX_INPUTLINE];
107 if (len == sizeof (text))
112 struct timeval timeout;
114 FD_SET(0, &fdset); // stdin
117 if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset))
119 len = read (0, text, sizeof(text));
122 // rip off the \n and terminate
132 char *Sys_GetClipboardData (void)
138 if (OpenClipboard (NULL) != 0)
140 HANDLE hClipboardData;
142 if ((hClipboardData = GetClipboardData (CF_TEXT)) != 0)
144 if ((cliptext = (char *)GlobalLock (hClipboardData)) != 0)
147 allocsize = GlobalSize (hClipboardData) + 1;
148 data = (char *)Z_Malloc (allocsize);
149 strlcpy (data, cliptext, allocsize);
150 GlobalUnlock (hClipboardData);
161 void Sys_InitConsole (void)
165 int main (int argc, char *argv[])
167 signal(SIGFPE, SIG_IGN);
170 com_argv = (const char **)argv;
173 fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
176 // we don't know which systems we'll want to init, yet...
184 qboolean sys_supportsdlgetticks = true;
185 unsigned int Sys_SDL_GetTicks (void)
187 return SDL_GetTicks();
189 void Sys_SDL_Delay (unsigned int milliseconds)
191 SDL_Delay(milliseconds);