#include "cmdlib.h"
#include "scriplib.h"
Include dependency graph for scriplib.c:

Go to the source code of this file.
Data Structures | |
| struct | script_t |
Defines | |
| #define | MAX_INCLUDES 8 |
Functions | |
| void | AddScriptToStack (const char *filename) |
| qboolean | EndOfScript (qboolean crossline) |
| qboolean | GetToken (qboolean crossline) |
| void | LoadScriptFile (const char *filename) |
| void | MatchToken (char *match) |
| void | Parse1DMatrix (int x, vec_t *m) |
| void | Parse2DMatrix (int y, int x, vec_t *m) |
| void | Parse3DMatrix (int z, int y, int x, vec_t *m) |
| void | ParseFromMemory (char *buffer, int size) |
| qboolean | TokenAvailable (void) |
| void | UnGetToken (void) |
| void | Write1DMatrix (FILE *f, int x, vec_t *m) |
| void | Write2DMatrix (FILE *f, int y, int x, vec_t *m) |
| void | Write3DMatrix (FILE *f, int z, int y, int x, vec_t *m) |
Variables | |
| qboolean | endofscript |
| script_t * | script |
| int | scriptline |
| script_t | scriptstack [MAX_INCLUDES] |
| char | token [MAXTOKEN] |
| qboolean | tokenready |
|
|
Definition at line 42 of file scriplib.c. |
|
|
Definition at line 56 of file scriplib.c. References script_t::buffer, script_t::end_p, Error(), ExpandPath(), script_t::filename, script_t::line, LoadFile(), printf(), script, script_t::script_p, scriptstack, and strcpy(). Referenced by GetToken(), and LoadScriptFile(). 00056 {
00057 int size;
00058
00059 script++;
00060 if (script == &scriptstack[MAX_INCLUDES])
00061 Error ("script file exceeded MAX_INCLUDES");
00062 strcpy (script->filename, ExpandPath (filename) );
00063
00064 size = LoadFile (script->filename, (void **)&script->buffer);
00065
00066 printf ("entering %s\n", script->filename);
00067
00068 script->line = 1;
00069
00070 script->script_p = script->buffer;
00071 script->end_p = script->buffer + size;
00072 }
|
Here is the call graph for this function:

|
|
Definition at line 132 of file scriplib.c. References script_t::buffer, endofscript, Error(), script_t::filename, free(), GetToken(), script_t::line, printf(), qboolean, script, scriptline, scriptstack, and strcmp(). Referenced by GetToken(), and PC_ReadSourceToken(). 00133 {
00134 if (!crossline)
00135 Error ("Line %i is incomplete\n",scriptline);
00136
00137 if (!strcmp (script->filename, "memory buffer"))
00138 {
00139 endofscript = qtrue;
00140 return qfalse;
00141 }
00142
00143 free (script->buffer);
00144 if (script == scriptstack+1)
00145 {
00146 endofscript = qtrue;
00147 return qfalse;
00148 }
00149 script--;
00150 scriptline = script->line;
00151 printf ("returning to %s\n", script->filename);
00152 return GetToken (crossline);
00153 }
|
Here is the call graph for this function:

|
|
Definition at line 160 of file scriplib.c. 00161 {
00162 char *token_p;
00163
00164 if (tokenready) // is a token allready waiting?
00165 {
00166 tokenready = qfalse;
00167 return qtrue;
00168 }
00169
00170 if (script->script_p >= script->end_p)
00171 return EndOfScript (crossline);
00172
00173 //
00174 // skip space
00175 //
00176 skipspace:
00177 while (*script->script_p <= 32)
00178 {
00179 if (script->script_p >= script->end_p)
00180 return EndOfScript (crossline);
00181 if (*script->script_p++ == '\n')
00182 {
00183 if (!crossline)
00184 Error ("Line %i is incomplete\n",scriptline);
00185 scriptline = script->line++;
00186 }
00187 }
00188
00189 if (script->script_p >= script->end_p)
00190 return EndOfScript (crossline);
00191
00192 // ; # // comments
00193 if (*script->script_p == ';' || *script->script_p == '#'
00194 || ( script->script_p[0] == '/' && script->script_p[1] == '/') )
00195 {
00196 if (!crossline)
00197 Error ("Line %i is incomplete\n",scriptline);
00198 while (*script->script_p++ != '\n')
00199 if (script->script_p >= script->end_p)
00200 return EndOfScript (crossline);
00201 scriptline = script->line++;
00202 goto skipspace;
00203 }
00204
00205 // /* */ comments
00206 if (script->script_p[0] == '/' && script->script_p[1] == '*')
00207 {
00208 if (!crossline)
00209 Error ("Line %i is incomplete\n",scriptline);
00210 script->script_p+=2;
00211 while (script->script_p[0] != '*' && script->script_p[1] != '/')
00212 {
00213 if ( *script->script_p == '\n' ) {
00214 scriptline = script->line++;
00215 }
00216 script->script_p++;
00217 if (script->script_p >= script->end_p)
00218 return EndOfScript (crossline);
00219 }
00220 script->script_p += 2;
00221 goto skipspace;
00222 }
00223
00224 //
00225 // copy token
00226 //
00227 token_p = token;
00228
00229 if (*script->script_p == '"')
00230 {
00231 // quoted token
00232 script->script_p++;
00233 while (*script->script_p != '"')
00234 {
00235 *token_p++ = *script->script_p++;
00236 if (script->script_p == script->end_p)
00237 break;
00238 if (token_p == &token[MAXTOKEN])
00239 Error ("Token too large on line %i\n",scriptline);
00240 }
00241 script->script_p++;
00242 }
00243 else // regular token
00244 while ( *script->script_p > 32 && *script->script_p != ';')
00245 {
00246 *token_p++ = *script->script_p++;
00247 if (script->script_p == script->end_p)
00248 break;
00249 if (token_p == &token[MAXTOKEN])
00250 Error ("Token too large on line %i\n",scriptline);
00251 }
00252
00253 *token_p = 0;
00254
00255 if (!strcmp (token, "$include"))
00256 {
00257 GetToken (qfalse);
00258 AddScriptToStack (token);
00259 return GetToken (crossline);
00260 }
00261
00262 return qtrue;
00263 }
|
|
|
Definition at line 80 of file scriplib.c. References AddScriptToStack(), basefolder, botimport, buffer, script_t::buffer, COM_Compress(), Com_Memset(), Com_sprintf(), script_t::end_p, endofscript, fclose(), fileHandle_t, FileLength(), script_t::filename, fopen(), fp, fread(), FreeMemory(), botlib_import_s::FS_FCloseFile, botlib_import_s::FS_FOpenFile, FS_READ, botlib_import_s::FS_Read, GetClearedMemory(), length(), script_t::line, NULL, script, script_t::script_p, script_t, SetScriptPunctuations(), strcpy(), strlen(), and tokenready. Referenced by LoadMapFile(), LoadShaderInfo(), LoadSourceFile(), ParseShaderFile(), PC_Directive_include(), and Q2_LoadMapFile(). 00080 {
00081 script = scriptstack;
00082 AddScriptToStack (filename);
00083
00084 endofscript = qfalse;
00085 tokenready = qfalse;
00086 }
|
Here is the call graph for this function:

|
|
Definition at line 293 of file scriplib.c. References Error(), GetToken(), match(), qtrue, scriptline, strcmp(), and token. Referenced by Parse1DMatrix(), Parse2DMatrix(), Parse3DMatrix(), ParsePatch(), ParseRawBrush(), ParseShaderFile(), and ParseTerrain(). 00293 {
00294 GetToken( qtrue );
00295
00296 if ( strcmp( token, match ) ) {
00297 Error( "MatchToken( \"%s\" ) failed at line %i", match, scriptline );
00298 }
00299 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 302 of file scriplib.c. 00302 {
00303 int i;
00304
00305 MatchToken( "(" );
00306
00307 for (i = 0 ; i < x ; i++) {
00308 GetToken( qfalse );
00309 m[i] = atof(token);
00310 }
00311
00312 MatchToken( ")" );
00313 }
|
|
||||||||||||||||
|
Definition at line 315 of file scriplib.c. 00315 {
00316 int i;
00317
00318 MatchToken( "(" );
00319
00320 for (i = 0 ; i < y ; i++) {
00321 Parse1DMatrix (x, m + i * x);
00322 }
00323
00324 MatchToken( ")" );
00325 }
|
|
||||||||||||||||||||
|
Definition at line 327 of file scriplib.c. 00327 {
00328 int i;
00329
00330 MatchToken( "(" );
00331
00332 for (i = 0 ; i < z ; i++) {
00333 Parse2DMatrix (y, x, m + i * x*y);
00334 }
00335
00336 MatchToken( ")" );
00337 }
|
|
||||||||||||
|
Definition at line 94 of file scriplib.c. References script_t::buffer, script_t::end_p, endofscript, Error(), script_t::filename, script_t::line, script, script_t::script_p, scriptstack, strcpy(), and tokenready. Referenced by ParseEntities(). 00095 {
00096 script = scriptstack;
00097 script++;
00098 if (script == &scriptstack[MAX_INCLUDES])
00099 Error ("script file exceeded MAX_INCLUDES");
00100 strcpy (script->filename, "memory buffer" );
00101
00102 script->buffer = buffer;
00103 script->line = 1;
00104 script->script_p = script->buffer;
00105 script->end_p = script->buffer + size;
00106
00107 endofscript = qfalse;
00108 tokenready = qfalse;
00109 }
|
Here is the call graph for this function:

|
|
Definition at line 273 of file scriplib.c. Referenced by Brush_Parse(), BrushPrimit_Parse(), ParseRawBrush(), ParseShaderFile(), and Terrain_ParseFace(). 00273 {
00274 int oldLine;
00275 qboolean r;
00276
00277 oldLine = script->line;
00278 r = GetToken( qtrue );
00279 if ( !r ) {
00280 return qfalse;
00281 }
00282 UnGetToken();
00283 if ( oldLine == script->line ) {
00284 return qtrue;
00285 }
00286 return qfalse;
00287 }
|
|
|
Definition at line 126 of file scriplib.c. References tokenready. Referenced by ParseMapEntity(), ParsePatch(), ParseRawBrush(), and TokenAvailable(). 00127 {
00128 tokenready = qtrue;
00129 }
|
|
||||||||||||||||
|
Definition at line 340 of file scriplib.c. References f, fprintf(), i, and m. Referenced by Write2DMatrix(). 00340 {
00341 int i;
00342
00343 fprintf (f, "( ");
00344 for (i = 0 ; i < x ; i++) {
00345 if (m[i] == (int)m[i] ) {
00346 fprintf (f, "%i ", (int)m[i]);
00347 } else {
00348 fprintf (f, "%f ", m[i]);
00349 }
00350 }
00351 fprintf (f, ")");
00352 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 354 of file scriplib.c. References f, fprintf(), i, m, Write1DMatrix(), and x. Referenced by Write3DMatrix(). 00354 {
00355 int i;
00356
00357 fprintf (f, "( ");
00358 for (i = 0 ; i < y ; i++) {
00359 Write1DMatrix (f, x, m + i*x);
00360 fprintf (f, " ");
00361 }
00362 fprintf (f, ")\n");
00363 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||
|
Definition at line 366 of file scriplib.c. References f, fprintf(), i, m, Write2DMatrix(), x, and y. 00366 {
00367 int i;
00368
00369 fprintf (f, "(\n");
00370 for (i = 0 ; i < z ; i++) {
00371 Write2DMatrix (f, y, x, m + i*(x*y) );
00372 }
00373 fprintf (f, ")\n");
00374 }
|
Here is the call graph for this function:

|
|
Definition at line 48 of file scriplib.c. Referenced by EndOfScript(), LoadScriptFile(), and ParseFromMemory(). |
|
|
|
Definition at line 45 of file scriplib.c. Referenced by EndOfScript(), GetToken(), MatchToken(), ParseMapEntity(), and StartTokenParsing(). |
|
|
Definition at line 43 of file scriplib.c. Referenced by AddScriptToStack(), EndOfScript(), ParseFromMemory(), and PC_CheckOpenSourceHandles(). |
|
|
|
Definition at line 49 of file scriplib.c. Referenced by GetToken(), LoadScriptFile(), ParseFromMemory(), and UnGetToken(). |
1.3.9.1