13 #include "darkplaces.h"
17 // =======================================================================
19 // =======================================================================
20 void Sys_Shutdown (void)
23 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK);
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) & ~O_NONBLOCK);
37 va_start (argptr,error);
38 dpvsnprintf (string, sizeof (string), error, argptr);
41 Con_Printf(CON_ERROR "Engine Error: %s\n", string);
47 void Sys_Print(const char *text)
51 // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
52 // this is because both go to /dev/tty by default!
55 int origflags = fcntl (sys.outfd, F_GETFL, 0);
56 fcntl (sys.outfd, F_SETFL, origflags & ~O_NONBLOCK);
62 fs_offset_t written = (fs_offset_t)write(sys.outfd, text, (int)strlen(text));
64 break; // sorry, I cannot do anything about this error - without an output
68 fcntl (sys.outfd, F_SETFL, origflags);
71 //fprintf(stdout, "%s", text);
74 char *Sys_ConsoleInput(void)
76 static char text[MAX_INPUTLINE];
77 static unsigned int len = 0;
103 if (len < sizeof (text) - 1)
112 struct timeval timeout;
114 FD_SET(0, &fdset); // stdin
117 if (select (1, &fdset, NULL, NULL, &timeout) != -1 && FD_ISSET(0, &fdset))
119 len = read (0, text, sizeof(text) - 1);
122 // rip off the \n and terminate
123 // div0: WHY? console code can deal with \n just fine
124 // this caused problems with pasting stuff into a terminal window
125 // so, not ripping off the \n, but STILL keeping a NUL terminator
134 char *Sys_GetClipboardData (void)
139 void Sys_SDL_Init(void)
143 qbool sys_supportsdlgetticks = false;
144 unsigned int Sys_SDL_GetTicks (void)
146 Sys_Error("Called Sys_SDL_GetTicks on non-SDL target");
149 void Sys_SDL_Delay (unsigned int milliseconds)
151 Sys_Error("Called Sys_SDL_Delay on non-SDL target");