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