Debian Codegraph @

code/botlib/l_precomp.h

raw symbols SCIP
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena 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 III Arena 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 III Arena 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 /*****************************************************************************
24 * name: l_precomp.h
25 *
26 * desc: pre compiler
27 *
28 * $Archive: /source/code/botlib/l_precomp.h $
29 *
30 *****************************************************************************/
31
32 #ifndef PATH_SEPERATORSTR
33 #if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)
34 #define PATHSEPERATOR_STR "\\"
35 #else
36 #define PATHSEPERATOR_STR "/"
37 #endif
38 #endif
39 #ifndef PATH_SEPERATORCHAR
40 #if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__)
41 #define PATHSEPERATOR_CHAR '\\'
42 #else
43 #define PATHSEPERATOR_CHAR '/'
44 #endif
45 #endif
46
47 #if defined(BSPC) && !defined(QDECL)
48 #define QDECL
49 #endif
50
51
52 #define DEFINE_FIXED 0x0001
53
54 #define BUILTIN_LINE 1
55 #define BUILTIN_FILE 2
56 #define BUILTIN_DATE 3
57 #define BUILTIN_TIME 4
58 #define BUILTIN_STDC 5
59
60 #define INDENT_IF 0x0001
61 #define INDENT_ELSE 0x0002
62 #define INDENT_ELIF 0x0004
63 #define INDENT_IFDEF 0x0008
64 #define INDENT_IFNDEF 0x0010
65
66 //macro definitions
67 typedef struct define_s
68 {
69 char *name; //define name
70 int flags; //define flags
71 int builtin; // > 0 if builtin define
72 int numparms; //number of define parameters
73 token_t *parms; //define parameters
74 token_t *tokens; //macro tokens (possibly containing parm tokens)
75 struct define_s *next; //next defined macro in a list
76 struct define_s *hashnext; //next define in the hash chain
77 } define_t;
78
79 //indents
80 //used for conditional compilation directives:
81 //#if, #else, #elif, #ifdef, #ifndef
82 typedef struct indent_s
83 {
84 int type; //indent type
85 int skip; //true if skipping current indent
86 script_t *script; //script the indent was in
87 struct indent_s *next; //next indent on the indent stack
88 } indent_t;
89
90 //source file
91 typedef struct source_s
92 {
93 char filename[1024]; //file name of the script
94 char includepath[1024]; //path to include files
95 punctuation_t *punctuations; //punctuations to use
96 script_t *scriptstack; //stack with scripts of the source
97 token_t *tokens; //tokens to read first
98 define_t *defines; //list with macro definitions
99 define_t **definehash; //hash chain with defines
100 indent_t *indentstack; //stack with indents
101 int skip; // > 0 if skipping conditional code
102 token_t token; //last read token
103 } source_t;
104
105
106 //read a token from the source
107 int PC_ReadToken(source_t *source, token_t *token);
108 //expect a certain token
109 int PC_ExpectTokenString(source_t *source, char *string);
110 //expect a certain token type
111 int PC_ExpectTokenType(source_t *source, int type, int subtype, token_t *token);
112 //expect a token
113 int PC_ExpectAnyToken(source_t *source, token_t *token);
114 //returns true when the token is available
115 int PC_CheckTokenString(source_t *source, char *string);
116 //returns true and reads the token when a token with the given type is available
117 int PC_CheckTokenType(source_t *source, int type, int subtype, token_t *token);
118 //skip tokens until the given token string is read
119 int PC_SkipUntilString(source_t *source, char *string);
120 //unread the last token read from the script
121 void PC_UnreadLastToken(source_t *source);
122 //unread the given token
123 void PC_UnreadToken(source_t *source, token_t *token);
124 //read a token only if on the same line, lines are concatenated with a slash
125 int PC_ReadLine(source_t *source, token_t *token);
126 //returns true if there was a white space in front of the token
127 int PC_WhiteSpaceBeforeToken(token_t *token);
128 //add a define to the source
129 int PC_AddDefine(source_t *source, char *string);
130 //add a globals define that will be added to all opened sources
131 int PC_AddGlobalDefine(char *string);
132 //remove the given global define
133 int PC_RemoveGlobalDefine(char *name);
134 //remove all globals defines
135 void PC_RemoveAllGlobalDefines(void);
136 //add builtin defines
137 void PC_AddBuiltinDefines(source_t *source);
138 //set the source include path
139 void PC_SetIncludePath(source_t *source, char *path);
140 //set the punction set
141 void PC_SetPunctuations(source_t *source, punctuation_t *p);
142 //set the base folder to load files from
143 void PC_SetBaseFolder(char *path);
144 //load a source file
145 source_t *LoadSourceFile(const char *filename);
146 //load a source from memory
147 source_t *LoadSourceMemory(char *ptr, int length, char *name);
148 //free the given source
149 void FreeSource(source_t *source);
150 //print a source error
151 void QDECL SourceError(source_t *source, char *str, ...) Q_PRINTF_FUNC(2, 3);
152 //print a source warning
153 void QDECL SourceWarning(source_t *source, char *str, ...) Q_PRINTF_FUNC(2, 3);
154
155 #ifdef BSPC
156 // some of BSPC source does include game/q_shared.h and some does not
157 // we define pc_token_s pc_token_t if needed (yes, it's ugly)
158 #ifndef __Q_SHARED_H
159 #define MAX_TOKENLENGTH 1024
160 typedef struct pc_token_s
161 {
162 int type;
163 int subtype;
164 int intvalue;
165 float floatvalue;
166 char string[MAX_TOKENLENGTH];
167 } pc_token_t;
168 #endif //!_Q_SHARED_H
169 #endif //BSPC
170
171 //
172 int PC_LoadSourceHandle(const char *filename);
173 int PC_FreeSourceHandle(int handle);
174 int PC_ReadTokenHandle(int handle, pc_token_t *pc_token);
175 int PC_SourceFileAndLine(int handle, char *filename, int *line);
176 void PC_CheckOpenSourceHandles(void);