17 // =======================================================================
19 // =======================================================================
20 void Sys_Shutdown (void)
23 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
28 void Sys_Error (const char *error, ...)
31 char string[MAX_INPUTLINE];
33 // change stdin to non blocking
35 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
38 va_start (argptr,error);
39 dpvsnprintf (string, sizeof (string), error, argptr);
42 Con_Printf ("Quake Error: %s\n", string);
49 void Sys_PrintToTerminal(const char *text)
54 // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
55 // this is because both go to /dev/tty by default!
57 int origflags = fcntl (outfd, F_GETFL, 0);
58 fcntl (outfd, F_SETFL, origflags & ~FNDELAY);
65 fs_offset_t written = (fs_offset_t)write(outfd, text, strlen(text));
67 break; // sorry, I cannot do anything about this error - without an output
71 fcntl (outfd, F_SETFL, origflags);
74 //fprintf(stdout, "%s", text);
77 char *Sys_ConsoleInput(void)
79 //if (cls.state == ca_dedicated)
81 static char text[MAX_INPUTLINE];
82 static unsigned int len = 0;
108 if (len < sizeof (text) - 1)
117 struct timeval timeout;
119 FD_SET(0, &fdset); // stdin
122 if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset))
124 len = read (0, text, sizeof(text) - 1);
127 // rip off the \n and terminate
128 // div0: WHY? console code can deal with \n just fine
129 // this caused problems with pasting stuff into a terminal window
130 // so, not ripping off the \n, but STILL keeping a NUL terminator
140 char *Sys_GetClipboardData (void)
145 void Sys_InitConsole (void)
149 int main (int argc, char **argv)
151 signal(SIGFPE, SIG_IGN);
154 com_argv = (const char **)argv;
157 // COMMANDLINEOPTION: sdl: -noterminal disables console output on stdout
158 if(COM_CheckParm("-noterminal"))
160 // COMMANDLINEOPTION: sdl: -stderr moves console output to stderr
161 else if(COM_CheckParm("-stderr"))
167 fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
175 qboolean sys_supportsdlgetticks = false;
176 unsigned int Sys_SDL_GetTicks (void)
178 Sys_Error("Called Sys_SDL_GetTicks on non-SDL target");
181 void Sys_SDL_Delay (unsigned int milliseconds)
183 Sys_Error("Called Sys_SDL_Delay on non-SDL target");