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