]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake3/common/cmdlib.h
reduce more diff noise
[xonotic/netradiant.git] / tools / quake3 / common / cmdlib.h
1 /*
2    Copyright (C) 1999-2007 id Software, Inc. and contributors.
3    For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5    This file is part of GtkRadiant.
6
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.
11
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.
16
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
20  */
21
22 // cmdlib.h
23
24 #ifndef __CMDLIB__
25 #define __CMDLIB__
26
27 #include "bytebool.h"
28 #include "globaldefs.h"
29
30 #if GDEF_COMPILER_MSVC
31 #pragma warning(disable : 4244)     // MIPS
32 #pragma warning(disable : 4136)     // X86
33 #pragma warning(disable : 4051)     // ALPHA
34
35 #pragma warning(disable : 4018)     // signed/unsigned mismatch
36 #pragma warning(disable : 4305)     // truncate from double to float
37
38 #pragma check_stack(off)
39
40 #endif
41
42 #include <stdio.h>
43 #include <string.h>
44 #include <stdlib.h>
45 #include <errno.h>
46 #include <ctype.h>
47 #include <time.h>
48 #include <stdarg.h>
49
50 #if GDEF_COMPILER_MSVC
51
52 #pragma intrinsic( memset, memcpy )
53
54 #endif
55
56
57 #ifdef PATH_MAX
58 #define MAX_OS_PATH     PATH_MAX
59 #else
60 #define MAX_OS_PATH     4096
61 #endif
62 #define MEM_BLOCKSIZE 4096
63
64 // the dec offsetof macro doesnt work very well...
65 #define myoffsetof( type,identifier ) ( (size_t)& ( (type *)0 )->identifier )
66
67 #define SAFE_MALLOC
68 #ifdef SAFE_MALLOC
69 void *safe_malloc( size_t size );
70 void *safe_malloc_info( size_t size, char* info );
71 #else
72 #define safe_malloc( a ) malloc( a )
73 #endif /* SAFE_MALLOC */
74
75 // set these before calling CheckParm
76 extern int myargc;
77 extern char **myargv;
78
79 char *strlower( char *in );
80 int Q_strncasecmp( const char *s1, const char *s2, int n );
81 int Q_stricmp( const char *s1, const char *s2 );
82 void Q_getwd( char *out );
83
84 int Q_filelength( FILE *f );
85 int FileTime( const char *path );
86
87 void    Q_mkdir( const char *path );
88
89 extern char qdir[1024];
90 extern char gamedir[1024];
91 extern char writedir[1024];
92 extern char    *moddirparam;
93 void SetQdirFromPath( const char *path );
94 char *ExpandArg( const char *path );    // from cmd line
95 char *ExpandPath( const char *path );   // from scripts
96 void ExpandWildcards( int *argc, char ***argv );
97
98
99 double I_FloatTime( void );
100
101 void    Error( const char *error, ... ) GDEF_ATTRIBUTE_NORETURN;
102 int     CheckParm( const char *check );
103
104 FILE    *SafeOpenWrite( const char *filename );
105 FILE    *SafeOpenRead( const char *filename );
106 void    SafeRead( FILE *f, void *buffer, int count );
107 void    SafeWrite( FILE *f, const void *buffer, int count );
108
109 int     LoadFile( const char *filename, void **bufferptr );
110 int   LoadFileBlock( const char *filename, void **bufferptr );
111 int     TryLoadFile( const char *filename, void **bufferptr );
112 void    SaveFile( const char *filename, const void *buffer, int count );
113 qboolean    FileExists( const char *filename );
114
115 void    DefaultExtension( char *path, const char *extension );
116 void    DefaultPath( char *path, const char *basepath );
117 void    StripFilename( char *path );
118 void    StripExtension( char *path );
119
120 void    ExtractFilePath( const char *path, char *dest );
121 void    ExtractFileBase( const char *path, char *dest );
122 void    ExtractFileExtension( const char *path, char *dest );
123
124 int     ParseNum( const char *str );
125
126 short   BigShort( short l );
127 short   LittleShort( short l );
128 int     BigLong( int l );
129 int     LittleLong( int l );
130 float   BigFloat( float l );
131 float   LittleFloat( float l );
132
133
134 char *COM_Parse( char *data );
135
136 extern char com_token[1024];
137 extern qboolean com_eof;
138
139 char *copystring( const char *s );
140
141
142 void CRC_Init( unsigned short *crcvalue );
143 void CRC_ProcessByte( unsigned short *crcvalue, byte data );
144 unsigned short CRC_Value( unsigned short crcvalue );
145
146 void    CreatePath( const char *path );
147 void    QCopyFile( const char *from, const char *to );
148
149 extern qboolean archive;
150 extern char archivedir[1024];
151
152 // sleep for the given amount of milliseconds
153 void Sys_Sleep( int n );
154
155 // for compression routines
156 typedef struct
157 {
158         void    *data;
159         int count, width, height;
160 } cblock_t;
161
162
163 #endif