18 // =======================================================================
20 // =======================================================================
21 void Sys_Shutdown (void)
24 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
29 void Sys_Error (const char *error, ...)
32 char string[MAX_INPUTLINE];
34 // change stdin to non blocking
36 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
39 va_start (argptr,error);
40 dpvsnprintf (string, sizeof (string), error, argptr);
43 Con_Printf ("Quake Error: %s\n", string);
50 void Sys_PrintToTerminal(const char *text)
55 // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
56 // this is because both go to /dev/tty by default!
58 int origflags = fcntl (outfd, F_GETFL, 0);
59 fcntl (outfd, F_SETFL, origflags & ~FNDELAY);
66 fs_offset_t written = (fs_offset_t)write(outfd, text, (int)strlen(text));
68 break; // sorry, I cannot do anything about this error - without an output
72 fcntl (outfd, F_SETFL, origflags);
75 //fprintf(stdout, "%s", text);
78 char *Sys_ConsoleInput(void)
80 //if (cls.state == ca_dedicated)
82 static char text[MAX_INPUTLINE];
83 static unsigned int len = 0;
109 if (len < sizeof (text) - 1)
118 struct timeval timeout;
120 FD_SET(0, &fdset); // stdin
123 if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset))
125 len = read (0, text, sizeof(text) - 1);
128 // rip off the \n and terminate
129 // div0: WHY? console code can deal with \n just fine
130 // this caused problems with pasting stuff into a terminal window
131 // so, not ripping off the \n, but STILL keeping a NUL terminator
141 char *Sys_GetClipboardData (void)
146 void Sys_InitConsole (void)
150 int main (int argc, char **argv)
153 setlocale(LC_ALL, "");
156 signal(SIGFPE, SIG_IGN);
159 com_argv = (const char **)argv;
162 // COMMANDLINEOPTION: sdl: -noterminal disables console output on stdout
163 if(COM_CheckParm("-noterminal"))
165 // COMMANDLINEOPTION: sdl: -stderr moves console output to stderr
166 else if(COM_CheckParm("-stderr"))
172 fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
180 qboolean sys_supportsdlgetticks = false;
181 unsigned int Sys_SDL_GetTicks (void)
183 Sys_Error("Called Sys_SDL_GetTicks on non-SDL target");
186 void Sys_SDL_Delay (unsigned int milliseconds)
188 Sys_Error("Called Sys_SDL_Delay on non-SDL target");