]> git.xonotic.org Git - xonotic/darkplaces.git/blob - sys_unix.c
deduplicate Sys_Error()
[xonotic/darkplaces.git] / sys_unix.c
1
2 #ifdef WIN32
3 #include <windows.h>
4 #include <mmsystem.h>
5 #include <io.h>
6 #else
7 #include <sys/time.h>
8 #include <unistd.h>
9 #include <fcntl.h>
10 #endif
11
12 #include "darkplaces.h"
13
14 sys_t sys;
15
16 // =======================================================================
17 // General routines
18 // =======================================================================
19 void Sys_Shutdown (void)
20 {
21 #ifndef WIN32
22         fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK);
23 #endif
24         fflush(stdout);
25 }
26
27 void Sys_SDL_Dialog(const char *title, const char *string)
28 {
29 }
30
31 void Sys_Print(const char *text)
32 {
33         if(sys.outfd < 0)
34                 return;
35         // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
36         // this is because both go to /dev/tty by default!
37         {
38 #ifndef WIN32
39                 int origflags = fcntl (sys.outfd, F_GETFL, 0);
40                 fcntl (sys.outfd, F_SETFL, origflags & ~O_NONBLOCK);
41 #else
42 #define write _write
43 #endif
44                 while(*text)
45                 {
46                         fs_offset_t written = (fs_offset_t)write(sys.outfd, text, (int)strlen(text));
47                         if(written <= 0)
48                                 break; // sorry, I cannot do anything about this error - without an output
49                         text += written;
50                 }
51 #ifndef WIN32
52                 fcntl (sys.outfd, F_SETFL, origflags);
53 #endif
54         }
55         //fprintf(stdout, "%s", text);
56 }
57
58 char *Sys_GetClipboardData (void)
59 {
60         return NULL;
61 }
62
63 void Sys_SDL_Init(void)
64 {
65 }
66
67 qbool sys_supportsdlgetticks = false;
68 unsigned int Sys_SDL_GetTicks (void)
69 {
70         Sys_Error("Called Sys_SDL_GetTicks on non-SDL target");
71         return 0;
72 }
73 void Sys_SDL_Delay (unsigned int milliseconds)
74 {
75         Sys_Error("Called Sys_SDL_Delay on non-SDL target");
76 }