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