19 // =======================================================================
21 // =======================================================================
22 void Sys_Shutdown (void)
24 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NDELAY);
28 void Sys_Error (const char *error, ...)
31 char string[MAX_INPUTLINE];
33 // change stdin to non blocking
34 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NDELAY);
36 va_start (argptr,error);
37 dpvsnprintf (string, sizeof (string), error, argptr);
40 Con_Printf(CON_ERROR "Engine Error: %s\n", string);
46 void Sys_PrintToTerminal(const char *text)
50 // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
51 // this is because both go to /dev/tty by default!
53 int origflags = fcntl (sys.outfd, F_GETFL, 0);
54 fcntl (sys.outfd, F_SETFL, origflags & ~O_NDELAY);
60 fs_offset_t written = (fs_offset_t)write(sys.outfd, text, (int)strlen(text));
62 break; // sorry, I cannot do anything about this error - without an output
65 fcntl (sys.outfd, F_SETFL, origflags);
67 //fprintf(stdout, "%s", text);
70 char *Sys_ConsoleInput(void)
72 //if (cls.state == ca_dedicated)
74 static char text[MAX_INPUTLINE];
75 static unsigned int len = 0;
101 if (len < sizeof (text) - 1)
110 struct timeval timeout;
112 FD_SET(0, &fdset); // stdin
115 if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset))
117 len = read (0, text, sizeof(text) - 1);
120 // rip off the \n and terminate
121 // div0: WHY? console code can deal with \n just fine
122 // this caused problems with pasting stuff into a terminal window
123 // so, not ripping off the \n, but STILL keeping a NUL terminator
133 char *Sys_GetClipboardData (void)
138 void Sys_InitConsole (void)
142 int main (int argc, char **argv)
144 signal(SIGFPE, SIG_IGN);
147 sys.argv = (const char **)argv;
150 // COMMANDLINEOPTION: sdl: -noterminal disables console output on stdout
151 if(COM_CheckParm("-noterminal"))
153 // COMMANDLINEOPTION: sdl: -stderr moves console output to stderr
154 else if(COM_CheckParm("-stderr"))
159 fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | O_NDELAY);
166 qboolean sys_supportsdlgetticks = false;
167 unsigned int Sys_SDL_GetTicks (void)
169 Sys_Error("Called Sys_SDL_GetTicks on non-SDL target");
172 void Sys_SDL_Delay (unsigned int milliseconds)
174 Sys_Error("Called Sys_SDL_Delay on non-SDL target");