]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/common/cmdlib.h
Remove -Wno-sign-compare
[xonotic/netradiant.git] / tools / quake2 / common / cmdlib.h
1 /*
2    Copyright (C) 1999-2006 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 <stdio.h>
28 #include <string.h>
29 #include <stdlib.h>
30 #include <errno.h>
31 #include <ctype.h>
32 #include <time.h>
33 #include <stdarg.h>
34
35 #ifdef WIN32
36         #ifdef NDEBUG                           // Don't show in a Release build
37                 #pragma warning(disable : 4305)     // truncate from double to float
38                 #pragma warning(disable : 4244)     // conversion from double to float
39                 #pragma warning(disable : 4018)     // signed/unsigned mismatch
40         #endif
41 #endif
42
43 #ifdef WIN32
44         #pragma intrinsic( memset, memcpy )
45 #endif
46
47 #ifndef __BYTEBOOL__
48   #define __BYTEBOOL__
49 typedef enum {false, true} qboolean;
50 typedef unsigned char byte;
51 #endif
52
53 #ifdef PATH_MAX
54 #define MAX_OS_PATH     PATH_MAX
55 #else
56 #define MAX_OS_PATH     1024
57 #endif
58 #define MEM_BLOCKSIZE 4096
59
60 /*
61    extern       qboolean verbose;
62    #define SYS_VRB 0 // verbose support (on/off)
63    #define SYS_STD 1 // standard print level
64    #define SYS_WRN 2 // warnings
65    #define SYS_ERR 3 // error
66  */
67
68 // the dec offsetof macro doesnt work very well...
69 #define myoffsetof( type,identifier ) ( (size_t)& ( (type *)0 )->identifier )
70
71 #define SAFE_MALLOC
72 #ifdef SAFE_MALLOC
73 void *safe_malloc( size_t size );
74 void *safe_malloc_info( size_t size, char* info );
75 #else
76 #define safe_malloc( a ) malloc( a )
77 #endif /* SAFE_MALLOC */
78
79 // set these before calling CheckParm
80 extern int myargc;
81 extern char **myargv;
82
83 char *strlower( char *in );
84 int Q_strncasecmp( const char *s1, const char *s2, int n );
85 int Q_strcasecmp( const char *s1, const char *s2 );
86 int Q_stricmp( const char *s1, const char *s2 );
87 void Q_getwd( char *out );
88
89 int Q_filelength( FILE *f );
90 int FileTime( const char *path );
91
92 void    Q_mkdir( const char *path );
93
94 extern char qdir[1024];
95 extern char gamedir[1024];
96 extern char writedir[1024];
97 extern char    *moddirparam;
98 void SetQdirFromPath( const char *path );
99 char *ExpandArg( const char *path );    // from cmd line
100 char *ExpandPath( const char *path );   // from scripts
101 char *ExpandGamePath( const char *path );
102 char *ExpandPathAndArchive( const char *path );
103 void ExpandWildcards( int *argc, char ***argv );
104
105
106 double I_FloatTime( void );
107
108 int     CheckParm( const char *check );
109
110 FILE    *SafeOpenWrite( const char *filename );
111 FILE    *SafeOpenRead( const char *filename );
112 void    SafeRead( FILE *f, void *buffer, int count );
113 void    SafeWrite( FILE *f, const void *buffer, int count );
114
115 int     LoadFile( const char *filename, void **bufferptr );
116 int   LoadFileBlock( const char *filename, void **bufferptr );
117 int     TryLoadFile( const char *filename, void **bufferptr );
118 void    SaveFile( const char *filename, const void *buffer, int count );
119 qboolean    FileExists( const char *filename );
120
121 void    DefaultExtension( char *path, const char *extension );
122 void    DefaultPath( char *path, const char *basepath );
123 void    StripFilename( char *path );
124 void    StripExtension( char *path );
125
126 void    ExtractFilePath( const char *path, char *dest );
127 void    ExtractFileBase( const char *path, char *dest );
128 void    ExtractFileExtension( const char *path, char *dest );
129
130 int     ParseNum( const char *str );
131
132 //void Sys_Printf (const char *text, ...);
133 //void Sys_FPrintf (int flag, const char *text, ...);
134 //void  Error( const char *error, ... );
135
136 short   BigShort( short l );
137 short   LittleShort( short l );
138 int     BigLong( int l );
139 int     LittleLong( int l );
140 float   BigFloat( float l );
141 float   LittleFloat( float l );
142
143
144 char *COM_Parse( char *data );
145
146 extern char com_token[1024];
147 extern qboolean com_eof;
148
149 char *copystring( const char *s );
150
151
152 void CRC_Init( unsigned short *crcvalue );
153 void CRC_ProcessByte( unsigned short *crcvalue, byte data );
154 unsigned short CRC_Value( unsigned short crcvalue );
155
156 void    CreatePath( const char *path );
157 void    QCopyFile( const char *from, const char *to );
158
159 extern qboolean archive;
160 extern char archivedir[1024];
161
162 // sleep for the given amount of milliseconds
163 void Sys_Sleep( int n );
164
165 // for compression routines
166 typedef struct
167 {
168         byte    *data;
169         int count;
170 } cblock_t;
171
172 extern char game[64];
173
174 #endif