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);
45 MessageBox(NULL, string, "Quake Error", MB_OK | MB_SETFOREGROUND | MB_ICONSTOP);
53 void Sys_PrintToTerminal(const char *text)
58 // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
59 // this is because both go to /dev/tty by default!
61 int origflags = fcntl (outfd, F_GETFL, 0);
62 fcntl (outfd, F_SETFL, origflags & ~FNDELAY);
69 fs_offset_t written = (fs_offset_t)write(outfd, text, (int)strlen(text));
71 break; // sorry, I cannot do anything about this error - without an output
75 fcntl (outfd, F_SETFL, origflags);
78 //fprintf(stdout, "%s", text);
81 char *Sys_ConsoleInput(void)
83 //if (cls.state == ca_dedicated)
85 static char text[MAX_INPUTLINE];
86 static unsigned int len = 0;
112 if (len < sizeof (text) - 1)
121 struct timeval timeout;
123 FD_SET(0, &fdset); // stdin
126 if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset))
128 len = read (0, text, sizeof(text) - 1);
131 // rip off the \n and terminate
132 // div0: WHY? console code can deal with \n just fine
133 // this caused problems with pasting stuff into a terminal window
134 // so, not ripping off the \n, but STILL keeping a NUL terminator
144 char *Sys_GetClipboardData (void)
149 void Sys_InitConsole (void)
153 int main (int argc, char **argv)
155 signal(SIGFPE, SIG_IGN);
158 com_argv = (const char **)argv;
161 // COMMANDLINEOPTION: sdl: -noterminal disables console output on stdout
162 if(COM_CheckParm("-noterminal"))
164 // COMMANDLINEOPTION: sdl: -stderr moves console output to stderr
165 else if(COM_CheckParm("-stderr"))
171 fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
179 qboolean sys_supportsdlgetticks = false;
180 unsigned int Sys_SDL_GetTicks (void)
182 Sys_Error("Called Sys_SDL_GetTicks on non-SDL target");
185 void Sys_SDL_Delay (unsigned int milliseconds)
187 Sys_Error("Called Sys_SDL_Delay on non-SDL target");