This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Data Structures | |
| struct | fielddef_s |
| struct | structdef_s |
Defines | |
| #define | FT_ARRAY 0x0100 |
| #define | FT_BOUNDED 0x0200 |
| #define | FT_CHAR 1 |
| #define | FT_FLOAT 3 |
| #define | FT_INT 2 |
| #define | FT_STRING 4 |
| #define | FT_STRUCT 6 |
| #define | FT_TYPE 0x00FF |
| #define | FT_UNSIGNED 0x0400 |
| #define | MAX_STRINGFIELD 80 |
Typedefs | |
| typedef fielddef_s | fielddef_t |
| typedef structdef_s | structdef_t |
Functions | |
| int | ReadStructure (source_t *source, structdef_t *def, char *structure) |
| int | WriteFloat (FILE *fp, float value) |
| int | WriteIndent (FILE *fp, int indent) |
| int | WriteStructure (FILE *fp, structdef_t *def, char *structure) |
|
|
Definition at line 43 of file l_struct.h. |
|
|
Definition at line 44 of file l_struct.h. |
|
|
Definition at line 35 of file l_struct.h. Referenced by ReadNumber(), ReadStructure(), and WriteStructWithIndent(). |
|
|
Definition at line 37 of file l_struct.h. Referenced by ReadStructure(), and WriteStructWithIndent(). |
|
|
Definition at line 36 of file l_struct.h. Referenced by ReadStructure(), and WriteStructWithIndent(). |
|
|
Definition at line 38 of file l_struct.h. Referenced by ReadStructure(), and WriteStructWithIndent(). |
|
|
Definition at line 39 of file l_struct.h. Referenced by ReadStructure(), and WriteStructWithIndent(). |
|
|
Definition at line 41 of file l_struct.h. |
|
|
Definition at line 45 of file l_struct.h. |
|
|
Definition at line 33 of file l_struct.h. Referenced by ReadString(). |
|
|
Referenced by FindField(), ReadChar(), ReadNumber(), ReadString(), ReadStructure(), and WriteStructWithIndent(). |
|
|
Referenced by ReadStructure(), WriteStructure(), and WriteStructWithIndent(). |
|
||||||||||||||||
|
Definition at line 236 of file l_struct.c. References fielddef_t, structdef_s::fields, FindField(), FT_CHAR, FT_FLOAT, FT_INT, FT_STRING, FT_STRUCT, fielddef_s::maxarray, fielddef_s::offset, p, PC_CheckTokenString(), PC_ExpectAnyToken(), PC_ExpectTokenString(), ReadChar(), ReadNumber(), ReadString(), structdef_s::size, source, source_t, SourceError(), strcmp(), token_s::string, structdef_t, fielddef_s::substruct, token, token_t, and fielddef_s::type. Referenced by LoadCfgFile(), LoadItemConfig(), and LoadWeaponConfig(). 00237 {
00238 token_t token;
00239 fielddef_t *fd;
00240 void *p;
00241 int num;
00242
00243 if (!PC_ExpectTokenString(source, "{")) return 0;
00244 while(1)
00245 {
00246 if (!PC_ExpectAnyToken(source, &token)) return qfalse;
00247 //if end of structure
00248 if (!strcmp(token.string, "}")) break;
00249 //find the field with the name
00250 fd = FindField(def->fields, token.string);
00251 if (!fd)
00252 {
00253 SourceError(source, "unknown structure field %s", token.string);
00254 return qfalse;
00255 } //end if
00256 if (fd->type & FT_ARRAY)
00257 {
00258 num = fd->maxarray;
00259 if (!PC_ExpectTokenString(source, "{")) return qfalse;
00260 } //end if
00261 else
00262 {
00263 num = 1;
00264 } //end else
00265 p = (void *)(structure + fd->offset);
00266 while (num-- > 0)
00267 {
00268 if (fd->type & FT_ARRAY)
00269 {
00270 if (PC_CheckTokenString(source, "}")) break;
00271 } //end if
00272 switch(fd->type & FT_TYPE)
00273 {
00274 case FT_CHAR:
00275 {
00276 if (!ReadChar(source, fd, p)) return qfalse;
00277 p = (char *) p + sizeof(char);
00278 break;
00279 } //end case
00280 case FT_INT:
00281 {
00282 if (!ReadNumber(source, fd, p)) return qfalse;
00283 p = (char *) p + sizeof(int);
00284 break;
00285 } //end case
00286 case FT_FLOAT:
00287 {
00288 if (!ReadNumber(source, fd, p)) return qfalse;
00289 p = (char *) p + sizeof(float);
00290 break;
00291 } //end case
00292 case FT_STRING:
00293 {
00294 if (!ReadString(source, fd, p)) return qfalse;
00295 p = (char *) p + MAX_STRINGFIELD;
00296 break;
00297 } //end case
00298 case FT_STRUCT:
00299 {
00300 if (!fd->substruct)
00301 {
00302 SourceError(source, "BUG: no sub structure defined");
00303 return qfalse;
00304 } //end if
00305 ReadStructure(source, fd->substruct, (char *) p);
00306 p = (char *) p + fd->substruct->size;
00307 break;
00308 } //end case
00309 } //end switch
00310 if (fd->type & FT_ARRAY)
00311 {
00312 if (!PC_ExpectAnyToken(source, &token)) return qfalse;
00313 if (!strcmp(token.string, "}")) break;
00314 if (strcmp(token.string, ","))
00315 {
00316 SourceError(source, "expected a comma, found %s", token.string);
00317 return qfalse;
00318 } //end if
00319 } //end if
00320 } //end while
00321 } //end while
00322 return qtrue;
00323 } //end of the function ReadStructure
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 344 of file l_struct.c. References fp, fprintf(), l, sprintf(), strlen(), and value. 00345 {
00346 char buf[128];
00347 int l;
00348
00349 sprintf(buf, "%f", value);
00350 l = strlen(buf);
00351 //strip any trailing zeros
00352 while(l-- > 1)
00353 {
00354 if (buf[l] != '0' && buf[l] != '.') break;
00355 if (buf[l] == '.')
00356 {
00357 buf[l] = 0;
00358 break;
00359 } //end if
00360 buf[l] = 0;
00361 } //end while
00362 //write the float to file
00363 if (fprintf(fp, "%s", buf) < 0) return 0;
00364 return 1;
00365 } //end of the function WriteFloat
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 330 of file l_struct.c. Referenced by WriteStructWithIndent(). 00331 {
00332 while(indent-- > 0)
00333 {
00334 if (fprintf(fp, "\t") < 0) return qfalse;
00335 } //end while
00336 return qtrue;
00337 } //end of the function WriteIndent
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 458 of file l_struct.c. References fp, structdef_t, and WriteStructWithIndent(). 00459 {
00460 return WriteStructWithIndent(fp, def, structure, 0);
00461 } //end of the function WriteStructure
|
Here is the call graph for this function:

1.3.9.1