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
28 #include "globaldefs.h"
30 #if GDEF_COMPILER_MSVC
31 #pragma warning(disable : 4244) // MIPS
32 #pragma warning(disable : 4136) // X86
33 #pragma warning(disable : 4051) // ALPHA
35 #pragma warning(disable : 4018) // signed/unsigned mismatch
36 #pragma warning(disable : 4305) // truncate from double to float
38 #pragma check_stack(off)
50 #if GDEF_COMPILER_MSVC
52 #pragma intrinsic( memset, memcpy )
58 #define MAX_OS_PATH PATH_MAX
60 #define MAX_OS_PATH 4096
62 #define MEM_BLOCKSIZE 4096
64 // the dec offsetof macro doesnt work very well...
65 #define myoffsetof( type,identifier ) ( (size_t)& ( (type *)0 )->identifier )
67 void *safe_malloc( size_t size );
68 void *safe_malloc_info( size_t size, char* info );
69 void *safe_malloc0( size_t size );
70 void *safe_malloc0_info( size_t size, char* info );
72 // set these before calling CheckParm
76 char *strlower( char *in );
77 int Q_strncasecmp( const char *s1, const char *s2, int n );
78 int Q_stricmp( const char *s1, const char *s2 );
79 void Q_getwd( char *out );
81 int Q_filelength( FILE *f );
82 int FileTime( const char *path );
84 void Q_mkdir( const char *path );
86 extern char qdir[1024];
87 extern char gamedir[1024];
88 extern char writedir[1024];
89 extern char *moddirparam;
90 void SetQdirFromPath( const char *path );
91 char *ExpandArg( const char *path ); // from cmd line
92 char *ExpandPath( const char *path ); // from scripts
93 void ExpandWildcards( int *argc, char ***argv );
96 double I_FloatTime( void );
98 void Error( const char *error, ... ) GDEF_ATTRIBUTE_NORETURN;
99 int CheckParm( const char *check );
101 FILE *SafeOpenWrite( const char *filename );
102 FILE *SafeOpenRead( const char *filename );
103 void SafeRead( FILE *f, void *buffer, int count );
104 void SafeWrite( FILE *f, const void *buffer, int count );
106 int LoadFile( const char *filename, void **bufferptr );
107 int LoadFileBlock( const char *filename, void **bufferptr );
108 int TryLoadFile( const char *filename, void **bufferptr );
109 void SaveFile( const char *filename, const void *buffer, int count );
110 qboolean FileExists( const char *filename );
112 void DefaultExtension( char *path, const char *extension );
113 void DefaultPath( char *path, const char *basepath );
114 void StripFilename( char *path );
115 void StripExtension( char *path );
117 void ExtractFilePath( const char *path, char *dest );
118 void ExtractFileBase( const char *path, char *dest );
119 void ExtractFileExtension( const char *path, char *dest );
121 int ParseNum( const char *str );
123 short BigShort( short l );
124 short LittleShort( short l );
125 int BigLong( int l );
126 int LittleLong( int l );
127 float BigFloat( float l );
128 float LittleFloat( float l );
131 char *COM_Parse( char *data );
133 extern char com_token[1024];
134 extern qboolean com_eof;
136 char *copystring( const char *s );
139 void CRC_Init( unsigned short *crcvalue );
140 void CRC_ProcessByte( unsigned short *crcvalue, byte data );
141 unsigned short CRC_Value( unsigned short crcvalue );
143 void CreatePath( const char *path );
144 void QCopyFile( const char *from, const char *to );
146 extern qboolean archive;
147 extern char archivedir[1024];
149 // sleep for the given amount of milliseconds
150 void Sys_Sleep( int n );
152 // for compression routines
156 int count, width, height;