forked from haithun/CoD4X17a_testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq_shared.h
269 lines (192 loc) · 7.18 KB
/
q_shared.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/*
===========================================================================
Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of CoD4X17a-Server source code.
CoD4X17a-Server source code is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
CoD4X17a-Server source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
===========================================================================
*/
// server.h
//#include "../game/q_shared.h"
//#include "../qcommon/qcommon.h"
//#include "../game/g_public.h"
//#include "../game/bg_public.h"
//=============================================================================
#ifndef __Q_SHARED_H__
#define __Q_SHARED_H__
#include <stdio.h>
#pragma pack(1)
#ifndef __stdcall
#define __stdcall __attribute__((stdcall))
#endif
#ifndef __cdecl
#define __cdecl __attribute__((cdecl))
#endif
#define DLL_PUBLIC __attribute__ ((visibility ("default")))
#define DLL_LOCAL __attribute__ ((visibility ("hidden")))
#define __optimize2 __attribute__ ((optimize("-O2")))
#define __optimize3 __attribute__ ((optimize("-O2"))) __attribute__ ((noinline))
#define REGPARM(X) __attribute__ ((regparm(X)))
#ifndef QDECL
#define QDECL
#endif
#ifndef __fastcall
#define __fastcall __attribute__((fastcall))
#endif
#ifndef __regparm1
#define __regparm1 __attribute__((regparm(1)))
#endif
#ifndef __regparm2
#define __regparm2 __attribute__((regparm(2)))
#endif
#ifndef __regparm3
#define __regparm3 __attribute__((regparm(3)))
#endif
typedef unsigned int long DWORD;
typedef unsigned short WORD;
#ifndef LOWORD
#define LOWORD(a) ((WORD)(a))
#endif
#ifndef HIWORD
#define HIWORD(a) ((WORD)(((DWORD)(a) >> 16) & 0xFFFF))
#endif
typedef unsigned char byte;
typedef enum {qfalse, qtrue} qboolean;
#ifndef STDCALL
#define STDCALL __attribute__((stdcall))
#endif
#define HOMEPATH_NAME_UNIX ".callofduty4"
#define MAX_STRING_TOKENS 1024 // max tokens resulting from Cmd_TokenizeString
#define MAX_STRING_CHARS 1024
#ifndef Q_vsnprintf
#define Q_vsnprintf vsnprintf
#endif
#define true '1'
#define false '0'
#define Q_COLOR_ESCAPE '^'
#define Q_IsColorString(p) ( p && *(p) == Q_COLOR_ESCAPE && *((p)+1) && *((p)+1) != Q_COLOR_ESCAPE )
#define COLOR_BLACK '0'
#define COLOR_RED '1'
#define COLOR_GREEN '2'
#define COLOR_YELLOW '3'
#define COLOR_BLUE '4'
#define COLOR_CYAN '5'
#define COLOR_MAGENTA '6'
#define COLOR_WHITE '7'
#define ColorIndex(c) ( ( (c) - '0' ) & 7 )
#define S_COLOR_BLACK "^0"
#define S_COLOR_RED "^1"
#define S_COLOR_GREEN "^2"
#define S_COLOR_YELLOW "^3"
#define S_COLOR_BLUE "^4"
#define S_COLOR_CYAN "^5"
#define S_COLOR_MAGENTA "^6"
#define S_COLOR_WHITE "^7"
#define MAX_OSPATH 256
#define MAX_INFO_STRING 1024
#define MAX_INFO_KEY 1024
#define MAX_INFO_VALUE 1024
#define MAX_STRING_CHARS 1024 // max length of a string passed to Cmd_TokenizeString
#define MAX_NAME_LENGTH 16 // max length of a client name
#define MAX_QPATH 64 // max length of a quake game pathname
#define BIG_INFO_STRING 8192 // used for system info key only
#define BIG_INFO_KEY 8192
#define BIG_INFO_VALUE 8192
#define TRUNCATE_LENGTH 64
#define LIBRARY_ADDRESS_BY_HANDLE(dlhandle)((NULL == dlhandle) ? NULL :(void*)*(size_t const*)(dlhandle))
#define Com_Memset memset
#define Com_Memcpy memcpy
short ShortSwap (short l);
short ShortNoSwap (short l);
int LongSwap (int l);
int LongNoSwap (int l);
int tolower( int c );
int toupper( int c );
int Q_isprint( int c );
int Q_islower( int c );
int Q_isupper( int c );
int Q_isalpha( int c );
qboolean Q_isanumber( const char *s );
qboolean Q_isintegral( float f );
qboolean Q_isprintstring( char* s );
#ifdef _MSC_VER
int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap);
#endif
void Q_strncpyz( char *dest, const char *src, int destsize );
int Q_stricmpn (const char *s1, const char *s2, int n);
int Q_strncmp (const char *s1, const char *s2, int n);
int Q_stricmp (const char *s1, const char *s2);
char *Q_strlwr( char *s1 );
char *Q_strupr( char *s1 );
void Q_bstrcpy(char* dest, char* src);
void Q_strcat( char *dest, int size, const char *src );
void Q_strlcat( char *dest, size_t size, const char *src, int cpylimit);
void Q_strnrepl( char *dest, size_t size, const char *src, const char* find, const char* replacement);
const char *Q_stristr( const char *s, const char *find);
int Q_strichr( const char *s, char find);
int Q_PrintStrlen( const char *string );
char *Q_CleanStr( char *string );
int Q_CountChar(const char *string, char tocount);
int QDECL Com_sprintf(char *dest, int size, const char *fmt, ...);
void Q_strchrrepl(char *string, char torepl, char repl);
char* Q_BitConv(int val);
char * QDECL va( char *format, ... );
void Com_TruncateLongString( char *buffer, const char *s );
qboolean Info_Validate( const char *s );
char *Info_ValueForKey( const char *s, const char *key );
void Info_SetValueForKey( char *s, const char *key, const char *value );
void BigInfo_SetValueForKey( char *s, const char *key, const char *value );
void Info_Print( const char *s );
int SV_Cmd_Argc( void );
int Cmd_Argc( void );
char *SV_Cmd_Argv( int arg );
void SV_Cmd_ArgvBuffer( int arg, char *buffer, int bufferLength );
char *Cmd_Argv( int arg );
char *Cmd_Args( char* buff, int bufsize );
char *Cmd_Argsv( int arg, char* buff, int bufsize );
char *SV_ExpandNewlines( char *in );
/*****************************************************
*** Parsing files ***
*****************************************************/
void Com_ParseReset();
char* Com_ParseGetToken(char* line);
int Com_ParseTokenLength(char* token);
qboolean isNumeric(const char* string, int size);
/*
=====================================================================
Functions to operate onto a stack in lifo mode
=====================================================================
*/
void stack_init(void *array[], size_t size);
qboolean stack_push(void *array[], int size, void* pointer);
void* stack_pop(void *array[], int size);
/*
=====================================================================
Writing XML STRINGS
=====================================================================
*/
typedef struct{
int parents;
qboolean last;
void *stack[48];
char *buffer;
char *encoding;
size_t buffersize;
}xml_t;
void XML_Init( xml_t *base, char *s, int size, char* encoding);
void XML_Escape( char* buffer, size_t size, const char* string);
qboolean QDECL XML_OpenTag( xml_t *base, char* root, int count,... );
void XML_CloseTag(xml_t *base);
char *Com_SkipCharset( char *s, char *sep );
char *Com_SkipTokens( char *s, int numTokens, char *sep );
void COM_DefaultExtension( char *path, int maxSize, const char *extension );
#endif