| 1 |
/* |
| 2 |
=========================================================================== |
| 3 |
Copyright (C) 2009 Karl Kuglin |
| 4 |
Copyright (C) 2004-2006 Tony J. White |
| 5 |
|
| 6 |
This file is part of the Open Arena source code. |
| 7 |
Portions copied/modified from Tremulous under GPL version 2 including any |
| 8 |
later versions. |
| 9 |
|
| 10 |
Open Arena source code is free software; you can redistribute it |
| 11 |
and/or modify it under the terms of the GNU General Public License as |
| 12 |
published by the Free Software Foundation; either version 2 of the License, |
| 13 |
or (at your option) any later version. |
| 14 |
|
| 15 |
Open Arena source code is distributed in the hope that it will be |
| 16 |
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
GNU General Public License for more details. |
| 19 |
|
| 20 |
You should have received a copy of the GNU General Public License |
| 21 |
along with Open Arena source code; if not, write to the Free Software |
| 22 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 23 |
=========================================================================== |
| 24 |
*/ |
| 25 |
|
| 26 |
#include "g_local.h" |
| 27 |
|
| 28 |
/* |
| 29 |
================ |
| 30 |
readFile_int |
| 31 |
This parses an integer for the "tag" specified (cnf) |
| 32 |
================ |
| 33 |
*/ |
| 34 |
void readFile_int( char **cnf, int *v ) |
| 35 |
{ |
| 36 |
char *t; |
| 37 |
|
| 38 |
//COM_MatchToken(cnf, "="); |
| 39 |
t = COM_ParseExt( cnf, qfalse ); |
| 40 |
if( !strcmp( t, "=" ) ) |
| 41 |
{ |
| 42 |
t = COM_ParseExt( cnf, qfalse ); |
| 43 |
} |
| 44 |
else |
| 45 |
{ |
| 46 |
COM_ParseWarning( "expected '=' before \"%s\"", t ); |
| 47 |
} |
| 48 |
*v = atoi( t ); |
| 49 |
} |
| 50 |
|
| 51 |
/* |
| 52 |
================ |
| 53 |
readFile_string |
| 54 |
This parses a literal string for the "tag" specified |
| 55 |
Color characters and escape sequences are parsed as well. |
| 56 |
================ |
| 57 |
*/ |
| 58 |
void readFile_string( char **cnf, char *s, int size ) |
| 59 |
{ |
| 60 |
char *t; |
| 61 |
|
| 62 |
//COM_MatchToken(cnf, "="); |
| 63 |
s[ 0 ] = '\0'; |
| 64 |
t = COM_ParseExt( cnf, qfalse ); |
| 65 |
if( strcmp( t, "=" ) ) |
| 66 |
{ |
| 67 |
COM_ParseWarning( "expected '=' before \"%s\"", t ); |
| 68 |
Q_strncpyz( s, t, size ); |
| 69 |
} |
| 70 |
while( 1 ) |
| 71 |
{ |
| 72 |
t = COM_ParseExt( cnf, qfalse ); |
| 73 |
if( !*t ) |
| 74 |
break; |
| 75 |
if( strlen( t ) + strlen( s ) >= size ) |
| 76 |
break; |
| 77 |
if( *s ) |
| 78 |
Q_strcat( s, size, " " ); |
| 79 |
Q_strcat( s, size, t ); |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
/* |
| 84 |
================ |
| 85 |
writeFile_int |
| 86 |
This writes an integer to the file. |
| 87 |
Since there is no logic as to where it writes, it must be called "just-in-time." |
| 88 |
================ |
| 89 |
*/ |
| 90 |
void writeFile_int( int v, fileHandle_t f ) |
| 91 |
{ |
| 92 |
char buf[ 32 ]; |
| 93 |
|
| 94 |
Com_sprintf( buf, sizeof( buf ), "%d", v ); |
| 95 |
trap_FS_Write( buf, strlen( buf ), f ); |
| 96 |
trap_FS_Write( "\n", 1, f ); |
| 97 |
} |
| 98 |
|
| 99 |
/* |
| 100 |
================ |
| 101 |
writeFile_string |
| 102 |
This writes a string to the file. |
| 103 |
Since there is no logic as to where it writes, it must be called "just-in-time." |
| 104 |
================ |
| 105 |
*/ |
| 106 |
void writeFile_string( char *s, fileHandle_t f ) |
| 107 |
{ |
| 108 |
char buf[ MAX_STRING_CHARS ]; |
| 109 |
|
| 110 |
buf[ 0 ] = '\0'; |
| 111 |
if( s[ 0 ] ) |
| 112 |
{ |
| 113 |
//Q_strcat(buf, sizeof(buf), s); |
| 114 |
Q_strncpyz( buf, s, sizeof( buf ) ); |
| 115 |
trap_FS_Write( buf, strlen( buf ), f ); |
| 116 |
} |
| 117 |
trap_FS_Write( "\n", 1, f ); |
| 118 |
} |
| 119 |
|