2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #if GDEF_COMPILER_MSVC
28 #pragma warning(disable : 4244) // MIPS
29 #pragma warning(disable : 4136) // X86
30 #pragma warning(disable : 4051) // ALPHA
32 #pragma warning(disable : 4018) // signed/unsigned mismatch
33 #pragma warning(disable : 4305) // truncate from double to float
35 #pragma check_stack(off)
47 #if GDEF_COMPILER_MSVC
49 #pragma intrinsic( memset, memcpy )
55 //typedef enum {false, true} qboolean;
56 //typedef unsigned char byte;
57 #include "q_typedef.h"
61 #define MAX_OS_PATH PATH_MAX
63 #define MAX_OS_PATH 1024
65 #define MEM_BLOCKSIZE 4096
67 extern qboolean verbose;
68 #define SYS_VRB 0 // verbose support (on/off)
69 #define SYS_STD 1 // standard print level
70 #define SYS_WRN 2 // warnings
71 #define SYS_ERR 3 // error
73 // the dec offsetof macro doesnt work very well...
74 #define myoffsetof( type,identifier ) ( (size_t)& ( (type *)0 )->identifier )
78 void *safe_malloc( size_t size );
79 void *safe_malloc_info( size_t size, char* info );
81 #define safe_malloc( a ) malloc( a )
82 #endif /* SAFE_MALLOC */
84 // set these before calling CheckParm
88 char *strlower( char *in );
89 int Q_strncasecmp( const char *s1, const char *s2, int n );
90 int Q_stricmp( const char *s1, const char *s2 );
91 int Q_strcasecmp( const char *s1, const char *s2 );
92 void Q_getwd( char *out );
94 int Q_filelength( FILE *f );
95 int FileTime( const char *path );
97 void Q_mkdir( const char *path );
99 extern char qdir[1024];
100 extern char gamedir[1024];
101 extern char writedir[1024];
102 extern char *moddirparam;
103 void SetQdirFromPath( const char *path );
104 char *ExpandArg( const char *path ); // from cmd line
105 char *ExpandPath( const char *path ); // from scripts
106 char *ExpandGamePath( const char *path );
107 char *ExpandPathAndArchive( const char *path );
108 void ExpandWildcards( int *argc, char ***argv );
111 double I_FloatTime( void );
113 int CheckParm( const char *check );
115 void *SafeMalloc( size_t n, char *desc );
116 FILE *SafeOpenWrite( const char *filename );
117 FILE *SafeOpenRead( const char *filename );
118 void SafeRead( FILE *f, void *buffer, int count );
119 void SafeWrite( FILE *f, const void *buffer, int count );
121 int LoadFile( const char *filename, void **bufferptr );
122 int LoadFileBlock( const char *filename, void **bufferptr );
123 int TryLoadFile( const char *filename, void **bufferptr );
124 void SaveFile( const char *filename, const void *buffer, int count );
125 qboolean FileExists( const char *filename );
127 void DefaultExtension( char *path, const char *extension );
128 void DefaultPath( char *path, const char *basepath );
129 void StripFilename( char *path );
130 void StripExtension( char *path );
132 void ExtractFilePath( const char *path, char *dest );
133 void ExtractFileBase( const char *path, char *dest );
134 void ExtractFileExtension( const char *path, char *dest );
136 int ParseNum( const char *str );
138 void Sys_Printf (const char *text, ...);
139 void Sys_FPrintf (int flag, const char *text, ...);
140 void Error( const char *error, ... );
142 short BigShort( short l );
143 short LittleShort( short l );
144 int BigLong( int l );
145 int LittleLong( int l );
146 float BigFloat( float l );
147 float LittleFloat( float l );
150 char *COM_Parse( char *data );
152 extern char com_token[1024];
153 extern qboolean com_eof;
155 char *copystring( const char *s );
158 void CRC_Init( unsigned short *crcvalue );
159 void CRC_ProcessByte( unsigned short *crcvalue, byte data );
160 unsigned short CRC_Value( unsigned short crcvalue );
162 void CreatePath( const char *path );
163 void QCopyFile( const char *from, const char *to );
165 extern qboolean archive;
166 extern char archivedir[1024];
168 extern qboolean g_dokeypress;
170 // sleep for the given amount of milliseconds
171 void Sys_Sleep( int n );
173 // for compression routines