]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/extra/common/cmdlib.h
Merge branch 'fix-fast' into 'master'
[xonotic/netradiant.git] / tools / quake2 / extra / common / cmdlib.h
1 /*
2 ===========================================================================
3 Copyright (C) 1997-2006 Id Software, Inc.
4
5 This file is part of Quake 2 Tools source code.
6
7 Quake 2 Tools source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake 2 Tools source code is distributed in the hope that it will be
13 useful, 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 Quake 2 Tools source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 ===========================================================================
21 */
22
23 // cmdlib.h
24
25 #ifndef __CMDLIB__
26 #define __CMDLIB__
27
28 #if GDEF_COMPILER_MSVC
29 #pragma warning(disable : 4244)     // MIPS
30 #pragma warning(disable : 4136)     // X86
31 #pragma warning(disable : 4051)     // ALPHA
32
33 #pragma warning(disable : 4018)     // signed/unsigned mismatch
34 #pragma warning(disable : 4305)     // truncate from double to float
35 #endif
36
37 #include <stdio.h>
38 #include <string.h>
39 #include <stdlib.h>
40 #include <errno.h>
41 #include <ctype.h>
42 #include <time.h>
43 #include <stdarg.h>
44
45 #ifndef __BYTEBOOL__
46 #define __BYTEBOOL__
47 typedef enum {false, true} qboolean;
48 typedef unsigned char byte;
49 #endif
50
51 // the dec offsetof macro doesnt work very well...
52 #define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier)
53
54
55 // set these before calling CheckParm
56 extern int myargc;
57 extern char **myargv;
58
59 char *strupr (char *in);
60 char *strlower (char *in);
61 int Q_strncasecmp (char *s1, char *s2, int n);
62 int Q_strcasecmp (char *s1, char *s2);
63 void Q_getwd (char *out);
64
65 int Q_filelength (FILE *f);
66 int     FileTime (char *path);
67
68 void    Q_mkdir (char *path);
69
70 extern  char            qdir[1024];
71 extern  char            gamedir[1024];
72 void SetQdirFromPath (char *path);
73 char *ExpandArg (char *path);   // from cmd line
74 char *ExpandPath (char *path);  // from scripts
75 char *ExpandPathAndArchive (char *path);
76
77
78 double I_FloatTime (void);
79
80 void    Error (char *error, ...);
81 int             CheckParm (char *check);
82
83 FILE    *SafeOpenWrite (char *filename);
84 FILE    *SafeOpenRead (char *filename);
85 void    SafeRead (FILE *f, void *buffer, int count);
86 void    SafeWrite (FILE *f, void *buffer, int count);
87
88 int             LoadFile (char *filename, void **bufferptr);
89 int             TryLoadFile (char *filename, void **bufferptr);
90 void    SaveFile (char *filename, void *buffer, int count);
91 qboolean        FileExists (char *filename);
92
93 void    DefaultExtension (char *path, char *extension);
94 void    DefaultPath (char *path, char *basepath);
95 void    StripFilename (char *path);
96 void    StripExtension (char *path);
97
98 void    ExtractFilePath (char *path, char *dest);
99 void    ExtractFileBase (char *path, char *dest);
100 void    ExtractFileExtension (char *path, char *dest);
101
102 int     ParseNum (char *str);
103
104 short   BigShort (short l);
105 short   LittleShort (short l);
106 int             BigLong (int l);
107 int             LittleLong (int l);
108 float   BigFloat (float l);
109 float   LittleFloat (float l);
110
111
112 char *COM_Parse (char *data);
113
114 extern  char            com_token[1024];
115 extern  qboolean        com_eof;
116
117 char *copystring(char *s);
118
119
120 void CRC_Init(unsigned short *crcvalue);
121 void CRC_ProcessByte(unsigned short *crcvalue, byte data);
122 unsigned short CRC_Value(unsigned short crcvalue);
123
124 void    CreatePath (char *path);
125 void    QCopyFile (char *from, char *to);
126
127 extern  qboolean                archive;
128 extern  char                    archivedir[1024];
129
130
131 extern  qboolean verbose;
132 void qprintf (char *format, ...);
133
134 void ExpandWildcards (int *argc, char ***argv);
135
136
137 // for compression routines
138 typedef struct
139 {
140         byte    *data;
141         int             count;
142 } cblock_t;
143
144
145 #endif