]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/common/cmdlib.h
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / tools / quake2 / common / cmdlib.h
1 /*\r
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.\r
4 \r
5 This file is part of GtkRadiant.\r
6 \r
7 GtkRadiant is free software; you can redistribute it and/or modify\r
8 it under the terms of the GNU General Public License as published by\r
9 the Free Software Foundation; either version 2 of the License, or\r
10 (at your option) any later version.\r
11 \r
12 GtkRadiant is distributed in the hope that it will be useful,\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15 GNU General Public License for more details.\r
16 \r
17 You should have received a copy of the GNU General Public License\r
18 along with GtkRadiant; if not, write to the Free Software\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
20 */\r
21 \r
22 // cmdlib.h\r
23 \r
24 #ifndef __CMDLIB__\r
25 #define __CMDLIB__\r
26 \r
27 #include <stdio.h>\r
28 #include <string.h>\r
29 #include <stdlib.h>\r
30 #include <errno.h>\r
31 #include <ctype.h>\r
32 #include <time.h>\r
33 #include <stdarg.h>\r
34 \r
35 #ifdef _WIN32\r
36         #ifdef NDEBUG                                                   // Don't show in a Release build\r
37                 #pragma warning(disable : 4305)     // truncate from double to float\r
38                 #pragma warning(disable : 4244)     // conversion from double to float\r
39                 #pragma warning(disable : 4018)     // signed/unsigned mismatch\r
40         #endif\r
41 #endif\r
42 \r
43 #ifdef _WIN32\r
44         #pragma intrinsic( memset, memcpy )\r
45 #endif\r
46 \r
47 #ifndef __BYTEBOOL__\r
48   #define __BYTEBOOL__\r
49   typedef enum {false, true} qboolean;\r
50   typedef unsigned char byte;\r
51 #endif\r
52 \r
53 #define MAX_OS_PATH             1024\r
54 #define MEM_BLOCKSIZE 4096\r
55 \r
56 /*\r
57 extern  qboolean verbose;\r
58 #define SYS_VRB 0 // verbose support (on/off)\r
59 #define SYS_STD 1 // standard print level\r
60 #define SYS_WRN 2 // warnings\r
61 #define SYS_ERR 3 // error\r
62 */\r
63 \r
64 // the dec offsetof macro doesnt work very well...\r
65 #define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier)\r
66 \r
67 #define SAFE_MALLOC\r
68 #ifdef SAFE_MALLOC\r
69 void *safe_malloc( size_t size );\r
70 void *safe_malloc_info( size_t size, char* info );\r
71 #else\r
72 #define safe_malloc(a) malloc(a)\r
73 #endif /* SAFE_MALLOC */\r
74 \r
75 // set these before calling CheckParm\r
76 extern int myargc;\r
77 extern char **myargv;\r
78 \r
79 char *strlower (char *in);\r
80 int Q_strncasecmp( const char *s1, const char *s2, int n );\r
81 int Q_strcasecmp( const char *s1, const char *s2 );\r
82 int Q_stricmp( const char *s1, const char *s2 );\r
83 void Q_getwd( char *out );\r
84 \r
85 int Q_filelength (FILE *f);\r
86 int     FileTime( const char *path );\r
87 \r
88 void    Q_mkdir( const char *path );\r
89 \r
90 extern  char            qdir[1024];\r
91 extern  char            gamedir[1024];\r
92 extern  char            writedir[1024];\r
93 extern  char    *moddirparam;\r
94 void SetQdirFromPath( const char *path);\r
95 char *ExpandArg( const char *path );    // from cmd line\r
96 char *ExpandPath( const char *path );   // from scripts\r
97 char *ExpandGamePath (const char *path);\r
98 char *ExpandPathAndArchive( const char *path );\r
99 void ExpandWildcards( int *argc, char ***argv );\r
100 \r
101 \r
102 double I_FloatTime( void );\r
103 \r
104 int             CheckParm( const char *check );\r
105 \r
106 FILE    *SafeOpenWrite( const char *filename );\r
107 FILE    *SafeOpenRead( const char *filename );\r
108 void    SafeRead (FILE *f, void *buffer, int count);\r
109 void    SafeWrite (FILE *f, const void *buffer, int count);\r
110 \r
111 int             LoadFile( const char *filename, void **bufferptr );\r
112 int   LoadFileBlock( const char *filename, void **bufferptr );\r
113 int             TryLoadFile( const char *filename, void **bufferptr );\r
114 void    SaveFile( const char *filename, const void *buffer, int count );\r
115 qboolean        FileExists( const char *filename );\r
116 \r
117 void    DefaultExtension( char *path, const char *extension );\r
118 void    DefaultPath( char *path, const char *basepath );\r
119 void    StripFilename( char *path );\r
120 void    StripExtension( char *path );\r
121 \r
122 void    ExtractFilePath( const char *path, char *dest );\r
123 void    ExtractFileBase( const char *path, char *dest );\r
124 void    ExtractFileExtension( const char *path, char *dest );\r
125 \r
126 int     ParseNum (const char *str);\r
127 \r
128 //void Sys_Printf (const char *text, ...);\r
129 //void Sys_FPrintf (int flag, const char *text, ...);\r
130 //void  Error( const char *error, ... );\r
131 \r
132 short   BigShort (short l);\r
133 short   LittleShort (short l);\r
134 int             BigLong (int l);\r
135 int             LittleLong (int l);\r
136 float   BigFloat (float l);\r
137 float   LittleFloat (float l);\r
138 \r
139 \r
140 char *COM_Parse (char *data);\r
141 \r
142 extern  char            com_token[1024];\r
143 extern  qboolean        com_eof;\r
144 \r
145 char *copystring(const char *s);\r
146 \r
147 \r
148 void CRC_Init(unsigned short *crcvalue);\r
149 void CRC_ProcessByte(unsigned short *crcvalue, byte data);\r
150 unsigned short CRC_Value(unsigned short crcvalue);\r
151 \r
152 void    CreatePath( const char *path );\r
153 void    QCopyFile( const char *from, const char *to );\r
154 \r
155 extern  qboolean                archive;\r
156 extern  char                    archivedir[1024];\r
157 \r
158 // sleep for the given amount of milliseconds\r
159 void Sys_Sleep(int n);\r
160 \r
161 // for compression routines\r
162 typedef struct\r
163 {\r
164         byte    *data;\r
165         int             count;\r
166 } cblock_t;\r
167 \r
168 extern  char    game[64];\r
169 \r
170 #endif\r