19 // =======================================================================
21 // =======================================================================
22 void Sys_Shutdown (void)
25 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_Errorf ("Engine 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 (sys.outfd, F_GETFL, 0);
59 fcntl (sys.outfd, F_SETFL, origflags & ~FNDELAY);
66 fs_offset_t written = (fs_offset_t)write(sys.outfd, text, (int)strlen(text));
68 break; // sorry, I cannot do anything about this error - without an output
72 fcntl (sys.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)
152 signal(SIGFPE, SIG_IGN);
155 sys.argv = (const char **)argv;
158 // COMMANDLINEOPTION: sdl: -noterminal disables console output on stdout
159 if(COM_CheckParm("-noterminal"))
161 // COMMANDLINEOPTION: sdl: -stderr moves console output to stderr
162 else if(COM_CheckParm("-stderr"))
168 fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
176 qboolean sys_supportsdlgetticks = false;
177 unsigned int Sys_SDL_GetTicks (void)
179 Sys_Error("Called Sys_SDL_GetTicks on non-SDL target");
182 void Sys_SDL_Delay (unsigned int milliseconds)
184 Sys_Error("Called Sys_SDL_Delay on non-SDL target");