]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/qdata_heretic2/common/cmdlib.h
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / tools / quake2 / qdata_heretic2 / common / cmdlib.h
1 /*\r
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.\r
4 \r
5 This file is part of GtkRadiant.\r
6 \r
7 GtkRadiant is free software; you can redistribute it and/or modify\r
8 it under the terms of the GNU General Public License as published by\r
9 the Free Software Foundation; either version 2 of the License, or\r
10 (at your option) any later version.\r
11 \r
12 GtkRadiant is distributed in the hope that it will be useful,\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15 GNU General Public License for more details.\r
16 \r
17 You should have received a copy of the GNU General Public License\r
18 along with GtkRadiant; if not, write to the Free Software\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
20 */\r
21 \r
22 // cmdlib.h\r
23 \r
24 #ifndef __CMDLIB__\r
25 #define __CMDLIB__\r
26 \r
27 #ifdef _WIN32\r
28 #pragma warning(disable : 4244)     // MIPS\r
29 #pragma warning(disable : 4136)     // X86\r
30 #pragma warning(disable : 4051)     // ALPHA\r
31 \r
32 #pragma warning(disable : 4018)     // signed/unsigned mismatch\r
33 #pragma warning(disable : 4305)     // truncate from double to float\r
34 \r
35 #pragma check_stack(off)\r
36 \r
37 #endif\r
38 \r
39 #include <stdio.h>\r
40 #include <string.h>\r
41 #include <stdlib.h>\r
42 #include <errno.h>\r
43 #include <ctype.h>\r
44 #include <time.h>\r
45 #include <stdarg.h>\r
46 \r
47 #ifdef _WIN32\r
48 \r
49 #pragma intrinsic( memset, memcpy )\r
50 \r
51 #endif\r
52 \r
53 #ifndef __BYTEBOOL__\r
54   #define __BYTEBOOL__\r
55   //typedef enum {false, true} qboolean;\r
56   //typedef unsigned char byte;\r
57   #include "q_typedef.h"\r
58 #endif\r
59 \r
60 #define MAX_OS_PATH             1024\r
61 #define MEM_BLOCKSIZE 4096\r
62 /*\r
63 extern  qboolean verbose;\r
64 #define SYS_VRB 0 // verbose support (on/off)\r
65 #define SYS_STD 1 // standard print level\r
66 #define SYS_WRN 2 // warnings\r
67 #define SYS_ERR 3 // error\r
68 */\r
69 // the dec offsetof macro doesnt work very well...\r
70 #define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier)\r
71 \r
72 #define SAFE_MALLOC\r
73 #ifdef SAFE_MALLOC\r
74 void *safe_malloc( size_t size );\r
75 void *safe_malloc_info( size_t size, char* info );\r
76 #else\r
77 #define safe_malloc(a) malloc(a)\r
78 #endif /* SAFE_MALLOC */\r
79 \r
80 // set these before calling CheckParm\r
81 extern int myargc;\r
82 extern char **myargv;\r
83 \r
84 char *strlower (char *in);\r
85 int Q_strncasecmp( const char *s1, const char *s2, int n );\r
86 int Q_stricmp( const char *s1, const char *s2 );\r
87 int Q_strcasecmp( const char *s1, const char *s2 );\r
88 void Q_getwd( char *out );\r
89 \r
90 int Q_filelength (FILE *f);\r
91 int     FileTime( const char *path );\r
92 \r
93 void    Q_mkdir( const char *path );\r
94 \r
95 extern  char            qdir[1024];\r
96 extern  char            gamedir[1024];\r
97 extern  char            writedir[1024];\r
98 extern  char    *moddirparam;\r
99 void SetQdirFromPath( const char *path);\r
100 char *ExpandArg( const char *path );    // from cmd line\r
101 char *ExpandPath( const char *path );   // from scripts\r
102 char *ExpandGamePath (const char *path);\r
103 char *ExpandPathAndArchive( const char *path );\r
104 void ExpandWildcards( int *argc, char ***argv );\r
105 \r
106 \r
107 double I_FloatTime( void );\r
108 \r
109 int             CheckParm( const char *check );\r
110 \r
111 void    *SafeMalloc(size_t n, char *desc);\r
112 FILE    *SafeOpenWrite( const char *filename );\r
113 FILE    *SafeOpenRead( const char *filename );\r
114 void    SafeRead (FILE *f, void *buffer, int count);\r
115 void    SafeWrite (FILE *f, const void *buffer, int count);\r
116 \r
117 int             LoadFile( const char *filename, void **bufferptr );\r
118 int   LoadFileBlock( const char *filename, void **bufferptr );\r
119 int             TryLoadFile( const char *filename, void **bufferptr );\r
120 void    SaveFile( const char *filename, const void *buffer, int count );\r
121 qboolean        FileExists( const char *filename );\r
122 \r
123 void    DefaultExtension( char *path, const char *extension );\r
124 void    DefaultPath( char *path, const char *basepath );\r
125 void    StripFilename( char *path );\r
126 void    StripExtension( char *path );\r
127 \r
128 void    ExtractFilePath( const char *path, char *dest );\r
129 void    ExtractFileBase( const char *path, char *dest );\r
130 void    ExtractFileExtension( const char *path, char *dest );\r
131 \r
132 int     ParseNum (const char *str);\r
133 /*\r
134 void Sys_Printf (const char *text, ...);\r
135 void Sys_FPrintf (int flag, const char *text, ...);\r
136 void    Error( const char *error, ... );\r
137 */\r
138 short   BigShort (short l);\r
139 short   LittleShort (short l);\r
140 int             BigLong (int l);\r
141 int             LittleLong (int l);\r
142 float   BigFloat (float l);\r
143 float   LittleFloat (float l);\r
144 \r
145 \r
146 char *COM_Parse (char *data);\r
147 \r
148 extern  char            com_token[1024];\r
149 extern  qboolean        com_eof;\r
150 \r
151 char *copystring(const char *s);\r
152 \r
153 \r
154 void CRC_Init(unsigned short *crcvalue);\r
155 void CRC_ProcessByte(unsigned short *crcvalue, byte data);\r
156 unsigned short CRC_Value(unsigned short crcvalue);\r
157 \r
158 void    CreatePath( const char *path );\r
159 void    QCopyFile( const char *from, const char *to );\r
160 \r
161 extern  qboolean                archive;\r
162 extern  char                    archivedir[1024];\r
163 \r
164 extern  qboolean        g_dokeypress;\r
165 \r
166 // sleep for the given amount of milliseconds\r
167 void Sys_Sleep(int n);\r
168 \r
169 // for compression routines\r
170 typedef struct\r
171 {\r
172         byte    *data;\r
173         int             count;\r
174 } cblock_t;\r
175 \r
176 \r
177 #endif\r