Debian Codegraph @

tools/quake2/extra/common/cmdlib.h

raw symbols SCIP
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 // May be already defined with some compilers on Windows
60 #ifndef strupr
61 char *strupr (char *start);
62 #endif
63
64 char *strlower (char *start);
65 int Q_strncasecmp (char *s1, char *s2, int n);
66 int Q_strcasecmp (char *s1, char *s2);
67 void Q_getwd (char *out);
68
69 int Q_filelength (FILE *f);
70 int FileTime (char *path);
71
72 void Q_mkdir (char *path);
73
74 extern char qdir[1024];
75 extern char gamedir[1024];
76 void SetQdirFromPath (char *path);
77 char *ExpandArg (char *path); // from cmd line
78 char *ExpandPath (char *path); // from scripts
79 char *ExpandPathAndArchive (char *path);
80
81
82 double I_FloatTime (void);
83
84 void Error (char *error, ...);
85 int CheckParm (char *check);
86
87 FILE *SafeOpenWrite (char *filename);
88 FILE *SafeOpenRead (char *filename);
89 void SafeRead (FILE *f, void *buffer, int count);
90 void SafeWrite (FILE *f, void *buffer, int count);
91
92 int LoadFile (char *filename, void **bufferptr);
93 int TryLoadFile (char *filename, void **bufferptr);
94 void SaveFile (char *filename, void *buffer, int count);
95 qboolean FileExists (char *filename);
96
97 void DefaultExtension (char *path, char *extension);
98 void DefaultPath (char *path, char *basepath);
99 void StripFilename (char *path);
100 void StripExtension (char *path);
101
102 void ExtractFilePath (char *path, char *dest);
103 void ExtractFileBase (char *path, char *dest);
104 void ExtractFileExtension (char *path, char *dest);
105
106 int ParseNum (char *str);
107
108 short BigShort (short l);
109 short LittleShort (short l);
110 int BigLong (int l);
111 int LittleLong (int l);
112 float BigFloat (float l);
113 float LittleFloat (float l);
114
115
116 char *COM_Parse (char *data);
117
118 extern char com_token[1024];
119 extern qboolean com_eof;
120
121 char *copystring(char *s);
122
123
124 void CRC_Init(unsigned short *crcvalue);
125 void CRC_ProcessByte(unsigned short *crcvalue, byte data);
126 unsigned short CRC_Value(unsigned short crcvalue);
127
128 void CreatePath (char *path);
129 void QCopyFile (char *from, char *to);
130
131 extern qboolean archive;
132 extern char archivedir[1024];
133
134
135 extern qboolean verbose;
136 void qprintf (char *format, ...);
137
138 void ExpandWildcards (int *argc, char ***argv);
139
140
141 // for compression routines
142 typedef struct
143 {
144 byte *data;
145 int count;
146 } cblock_t;
147
148
149 #endif