19 // =======================================================================
21 // =======================================================================
22 void Sys_Shutdown (void)
25 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK);
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) & ~O_NONBLOCK);
39 va_start (argptr,error);
40 dpvsnprintf (string, sizeof (string), error, argptr);
43 Con_Printf(CON_ERROR "Engine Error: %s\n", string);
49 void Sys_PrintToTerminal(const char *text)
53 // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
54 // this is because both go to /dev/tty by default!
57 int origflags = fcntl (sys.outfd, F_GETFL, 0);
58 fcntl (sys.outfd, F_SETFL, origflags & ~O_NONBLOCK);
64 fs_offset_t written = (fs_offset_t)write(sys.outfd, text, (int)strlen(text));
66 break; // sorry, I cannot do anything about this error - without an output
70 fcntl (sys.outfd, F_SETFL, origflags);
73 //fprintf(stdout, "%s", text);
76 char *Sys_ConsoleInput(void)
78 //if (cls.state == ca_dedicated)
80 static char text[MAX_INPUTLINE];
81 static unsigned int len = 0;
107 if (len < sizeof (text) - 1)
116 struct timeval timeout;
118 FD_SET(0, &fdset); // stdin
121 if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset))
123 len = read (0, text, sizeof(text) - 1);
126 // rip off the \n and terminate
127 // div0: WHY? console code can deal with \n just fine
128 // this caused problems with pasting stuff into a terminal window
129 // so, not ripping off the \n, but STILL keeping a NUL terminator
139 char *Sys_GetClipboardData (void)
144 void Sys_InitConsole (void)
148 int main (int argc, char **argv)
150 signal(SIGFPE, SIG_IGN);
153 sys.argv = (const char **)argv;
156 // COMMANDLINEOPTION: sdl: -noterminal disables console output on stdout
157 if(COM_CheckParm("-noterminal"))
159 // COMMANDLINEOPTION: sdl: -stderr moves console output to stderr
160 else if(COM_CheckParm("-stderr"))
165 fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | O_NONBLOCK);
168 // used by everything
178 qboolean sys_supportsdlgetticks = false;
179 unsigned int Sys_SDL_GetTicks (void)
181 Sys_Error("Called Sys_SDL_GetTicks on non-SDL target");
184 void Sys_SDL_Delay (unsigned int milliseconds)
186 Sys_Error("Called Sys_SDL_Delay on non-SDL target");