Debian Codegraph @

tools/quake2/common/cmdlib.h

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