]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - sys.h
9a1fe32fbe77e8fd70b21eea7737e74b7495da59
[xonotic/darkplaces.git] / sys.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20 // sys.h -- non-portable functions
21
22 #ifndef SYS_H
23 #define SYS_H
24
25 typedef struct sys_s
26 {
27         int argc;
28         const char **argv;
29         int selffd;
30         int outfd;
31 } sys_t;
32
33 extern sys_t sys;
34
35 extern cvar_t sys_usenoclockbutbenchmark;
36
37 //
38 // DLL management
39 //
40
41 // Win32 specific
42 #ifdef WIN32
43 # include <windows.h>
44 typedef HMODULE dllhandle_t;
45
46 // Other platforms
47 #else
48   typedef void* dllhandle_t;
49 #endif
50
51 typedef struct dllfunction_s
52 {
53         const char *name;
54         void **funcvariable;
55 }
56 dllfunction_t;
57
58 /*! Loads a library. 
59  * \param dllnames a NULL terminated array of possible names for the DLL you want to load.
60  * \param handle
61  * \param fcts
62  */
63 qboolean Sys_LoadLibrary (const char** dllnames, dllhandle_t* handle, const dllfunction_t *fcts);
64 void Sys_UnloadLibrary (dllhandle_t* handle);
65 void* Sys_GetProcAddress (dllhandle_t handle, const char* name);
66
67 /// called early in Host_Init
68 void Sys_InitConsole (void);
69 /// called after command system is initialized but before first Con_Print
70 void Sys_Init_Commands (void);
71
72
73 /// \returns current timestamp
74 char *Sys_TimeString(const char *timeformat);
75
76 //
77 // system IO interface (these are the sys functions that need to be implemented in a new driver atm)
78 //
79
80 /// an error will cause the entire program to exit
81 void Sys_Error (const char *error, ...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN;
82
83 /// (may) output text to terminal which launched program
84 void Sys_PrintToTerminal(const char *text);
85 void Sys_PrintfToTerminal(const char *fmt, ...);
86
87 /// INFO: This is only called by Host_Shutdown so we dont need testing for recursion
88 void Sys_Shutdown (void);
89 void Sys_Quit (int returnvalue);
90
91 /*! on some build/platform combinations (such as Linux gcc with the -pg
92  * profiling option) this can turn on/off profiling, used primarily to limit
93  * profiling to certain areas of the code, such as ingame performance without
94  * regard for loading/shutdown performance (-profilegameonly on commandline)
95  */
96 #ifdef __cplusplus
97 extern "C"
98 #endif
99 void Sys_AllowProfiling (qboolean enable);
100
101 typedef struct sys_cleantime_s
102 {
103         double dirtytime; // last value gotten from Sys_DirtyTime()
104         double cleantime; // sanitized linearly increasing time since app start
105 }
106 sys_cleantime_t;
107
108 double Sys_DirtyTime(void);
109
110 void Sys_ProvideSelfFD (void);
111
112 char *Sys_ConsoleInput (void);
113
114 /// called to yield for a little bit so as not to hog cpu when paused or debugging
115 void Sys_Sleep(int microseconds);
116
117 /// Perform Key_Event () callbacks until the input que is empty
118 void Sys_SendKeyEvents (void);
119
120 char *Sys_GetClipboardData (void);
121
122 extern qboolean sys_supportsdlgetticks;
123 unsigned int Sys_SDL_GetTicks (void); // wrapper to call SDL_GetTicks
124 void Sys_SDL_Delay (unsigned int milliseconds); // wrapper to call SDL_Delay
125
126 /// called to set process priority for dedicated servers
127 void Sys_InitProcessNice (void);
128 void Sys_MakeProcessNice (void);
129 void Sys_MakeProcessMean (void);
130
131 #endif
132