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