Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

q_shared.c File Reference

#include "q_shared.h"

Include dependency graph for q_shared.c:

Include dependency graph

Go to the source code of this file.

Data Structures

union  _FloatByteUnion

Functions

void COM_BeginParseSession (const char *name)
float Com_Clamp (float min, float max, float value)
int COM_Compress (char *data_p)
void COM_DefaultExtension (char *path, int maxSize, const char *extension)
int COM_GetCurrentParseLine (void)
void COM_MatchToken (char **buf_p, char *match)
char * COM_Parse (char **data_p)
void COM_ParseError (char *format,...)
char * COM_ParseExt (char **data_p, qboolean allowLineBreaks)
void COM_ParseWarning (char *format,...)
char * COM_SkipPath (char *pathname)
void QDECL Com_sprintf (char *dest, int size, const char *fmt,...)
void COM_StripExtension (const char *in, char *out)
float FloatNoSwap (const float *f)
float FloatSwap (const float *f)
void Info_NextPair (const char **head, char *key, char *value)
void Info_RemoveKey (char *s, const char *key)
void Info_RemoveKey_Big (char *s, const char *key)
void Info_SetValueForKey (char *s, const char *key, const char *value)
void Info_SetValueForKey_Big (char *s, const char *key, const char *value)
qboolean Info_Validate (const char *s)
char * Info_ValueForKey (const char *s, const char *key)
qint64 Long64NoSwap (qint64 ll)
qint64 Long64Swap (qint64 ll)
int LongNoSwap (int l)
int LongSwap (int l)
void Parse1DMatrix (char **buf_p, int x, float *m)
void Parse2DMatrix (char **buf_p, int y, int x, float *m)
void Parse3DMatrix (char **buf_p, int z, int y, int x, float *m)
char * Q_CleanStr (char *string)
int Q_isalpha (int c)
int Q_islower (int c)
int Q_isprint (int c)
int Q_isupper (int c)
int Q_PrintStrlen (const char *string)
void Q_strcat (char *dest, int size, const char *src)
int Q_stricmp (const char *s1, const char *s2)
int Q_stricmpn (const char *s1, const char *s2, int n)
char * Q_strlwr (char *s1)
int Q_strncmp (const char *s1, const char *s2, int n)
void Q_strncpyz (char *dest, const char *src, int destsize)
char * Q_strrchr (const char *string, int c)
char * Q_strupr (char *s1)
short ShortNoSwap (short l)
short ShortSwap (short l)
void SkipBracedSection (char **program)
void SkipRestOfLine (char **data)
char * SkipWhitespace (char *data, qboolean *hasNewLines)
char *QDECL va (char *format,...)

Variables

int com_lines
char com_parsename [MAX_TOKEN_CHARS]
char com_token [MAX_TOKEN_CHARS]


Function Documentation

void COM_BeginParseSession const char *  name  ) 
 

Definition at line 246 of file q_shared.c.

References com_lines, com_parsename, Com_sprintf(), and name.

00247 {
00248     com_lines = 0;
00249     Com_sprintf(com_parsename, sizeof(com_parsename), "%s", name);
00250 }

Here is the call graph for this function:

float Com_Clamp float  min,
float  max,
float  value
 

Definition at line 26 of file q_shared.c.

Referenced by ServerOptions_SetMenuItems().

00026                                                      {
00027     if ( value < min ) {
00028         return min;
00029     }
00030     if ( value > max ) {
00031         return max;
00032     }
00033     return value;
00034 }

int COM_Compress char *  data_p  ) 
 

Definition at line 315 of file q_shared.c.

References c, in, qboolean, and strlen().

Referenced by LoadScriptFile(), ScanAndLoadShaderFiles(), UI_LoadBotsFromFile(), and UI_ParseAnimationFile().

00315                                  {
00316     char *in, *out;
00317     int c;
00318     qboolean newline = qfalse, whitespace = qfalse;
00319 
00320     in = out = data_p;
00321     if (in) {
00322         while ((c = *in) != 0) {
00323             // skip double slash comments
00324             if ( c == '/' && in[1] == '/' ) {
00325                 while (*in && *in != '\n') {
00326                     in++;
00327                 }
00328             // skip /* */ comments
00329             } else if ( c == '/' && in[1] == '*' ) {
00330                 while ( *in && ( *in != '*' || in[1] != '/' ) ) 
00331                     in++;
00332                 if ( *in ) 
00333                     in += 2;
00334                         // record when we hit a newline
00335                         } else if ( c == '\n' || c == '\r' ) {
00336                             newline = qtrue;
00337                             in++;
00338                         // record when we hit whitespace
00339                         } else if ( c == ' ' || c == '\t') {
00340                             whitespace = qtrue;
00341                             in++;
00342                         // an actual token
00343             } else {
00344                             // if we have a pending newline, emit it (and it counts as whitespace)
00345                             if (newline) {
00346                                 *out++ = '\n';
00347                                 newline = qfalse;
00348                                 whitespace = qfalse;
00349                             } if (whitespace) {
00350                                 *out++ = ' ';
00351                                 whitespace = qfalse;
00352                             }
00353                             
00354                             // copy quoted strings unmolested
00355                             if (c == '"') {
00356                                     *out++ = c;
00357                                     in++;
00358                                     while (1) {
00359                                         c = *in;
00360                                         if (c && c != '"') {
00361                                             *out++ = c;
00362                                             in++;
00363                                         } else {
00364                                             break;
00365                                         }
00366                                     }
00367                                     if (c == '"') {
00368                                         *out++ = c;
00369                                         in++;
00370                                     }
00371                             } else {
00372                                 *out = c;
00373                                 out++;
00374                                 in++;
00375                             }
00376             }
00377         }
00378     }
00379     *out = 0;
00380     return out - data_p;
00381 }

Here is the call graph for this function:

void COM_DefaultExtension char *  path,
int  maxSize,
const char *  extension
 

Definition at line 74 of file q_shared.c.

References Com_sprintf(), Q_strncpyz(), src, and strlen().

Referenced by Cmd_Exec_f(), Com_WriteConfig_f(), R_FindShader(), and S_StartBackgroundTrack().

00074                                                                             {
00075     char    oldPath[MAX_QPATH];
00076     char    *src;
00077 
00078 //
00079 // if path doesn't have a .EXT, append extension
00080 // (extension should include the .)
00081 //
00082     src = path + strlen(path) - 1;
00083 
00084     while (*src != '/' && src != path) {
00085         if ( *src == '.' ) {
00086             return;                 // it has an extension
00087         }
00088         src--;
00089     }
00090 
00091     Q_strncpyz( oldPath, path, sizeof( oldPath ) );
00092     Com_sprintf( path, maxSize, "%s%s", oldPath, extension );
00093 }

Here is the call graph for this function:

int COM_GetCurrentParseLine void   ) 
 

Definition at line 252 of file q_shared.c.

00253 {
00254     return com_lines;
00255 }

void COM_MatchToken char **  buf_p,
char *  match
 

Definition at line 551 of file q_shared.c.

References Com_Error(), COM_Parse(), ERR_DROP, match(), strcmp(), and token.

Referenced by Parse1DMatrix(), Parse2DMatrix(), and Parse3DMatrix().

00551                                                  {
00552     char    *token;
00553 
00554     token = COM_Parse( buf_p );
00555     if ( strcmp( token, match ) ) {
00556         Com_Error( ERR_DROP, "MatchToken: %s != %s", token, match );
00557     }
00558 }

Here is the call graph for this function:

char* COM_Parse char **  data_p  ) 
 

Definition at line 257 of file q_shared.c.

00258 {
00259     return COM_ParseExt( data_p, qtrue );
00260 }

void COM_ParseError char *  format,
  ...
 

Definition at line 262 of file q_shared.c.

References com_lines, com_parsename, Com_Printf(), format, string(), va_end, va_list, va_start, and vsprintf().

00263 {
00264     va_list argptr;
00265     static char string[4096];
00266 
00267     va_start (argptr, format);
00268     vsprintf (string, format, argptr);
00269     va_end (argptr);
00270 
00271     Com_Printf("ERROR: %s, line %d: %s\n", com_parsename, com_lines, string);
00272 }

Here is the call graph for this function:

char* COM_ParseExt char **  data_p,
qboolean  allowLineBreaks
 

Definition at line 383 of file q_shared.c.

References c, com_lines, com_token, data, qboolean, and SkipWhitespace().

Referenced by Alias_Parse(), CG_HeadModelVoiceChats(), CG_ParseVoiceChats(), Character_Parse(), COM_Parse(), FindShaderInShaderText(), Float_Parse(), G_ParseInfos(), GameType_Parse(), GametypeBits(), Int_Parse(), MapList_Parse(), ParseDeform(), ParseShader(), ParseSkyParms(), ParseSort(), ParseStage(), ParseSurfaceParm(), ParseTexMod(), ParseVector(), ParseWaveForm(), R_LoadEntities(), ScanAndLoadShaderFiles(), SkipBracedSection(), String_Parse(), Team_Parse(), UI_ParseGameInfo(), UI_ParseInfos(), and UI_ParseTeamInfo().

00384 {
00385     int c = 0, len;
00386     qboolean hasNewLines = qfalse;
00387     char *data;
00388 
00389     data = *data_p;
00390     len = 0;
00391     com_token[0] = 0;
00392 
00393     // make sure incoming data is valid
00394     if ( !data )
00395     {
00396         *data_p = NULL;
00397         return com_token;
00398     }
00399 
00400     while ( 1 )
00401     {
00402         // skip whitespace
00403         data = SkipWhitespace( data, &hasNewLines );
00404         if ( !data )
00405         {
00406             *data_p = NULL;
00407             return com_token;
00408         }
00409         if ( hasNewLines && !allowLineBreaks )
00410         {
00411             *data_p = data;
00412             return com_token;
00413         }
00414 
00415         c = *data;
00416 
00417         // skip double slash comments
00418         if ( c == '/' && data[1] == '/' )
00419         {
00420             data += 2;
00421             while (*data && *data != '\n') {
00422                 data++;
00423             }
00424         }
00425         // skip /* */ comments
00426         else if ( c=='/' && data[1] == '*' ) 
00427         {
00428             data += 2;
00429             while ( *data && ( *data != '*' || data[1] != '/' ) ) 
00430             {
00431                 data++;
00432             }
00433             if ( *data ) 
00434             {
00435                 data += 2;
00436             }
00437         }
00438         else
00439         {
00440             break;
00441         }
00442     }
00443 
00444     // handle quoted strings
00445     if (c == '\"')
00446     {
00447         data++;
00448         while (1)
00449         {
00450             c = *data++;
00451             if (c=='\"' || !c)
00452             {
00453                 com_token[len] = 0;
00454                 *data_p = ( char * ) data;
00455                 return com_token;
00456             }
00457             if (len < MAX_TOKEN_CHARS)
00458             {
00459                 com_token[len] = c;
00460                 len++;
00461             }
00462         }
00463     }
00464 
00465     // parse a regular word
00466     do
00467     {
00468         if (len < MAX_TOKEN_CHARS)
00469         {
00470             com_token[len] = c;
00471             len++;
00472         }
00473         data++;
00474         c = *data;
00475         if ( c == '\n' )
00476             com_lines++;
00477     } while (c>32);
00478 
00479     if (len == MAX_TOKEN_CHARS)
00480     {
00481 //      Com_Printf ("Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS);
00482         len = 0;
00483     }
00484     com_token[len] = 0;
00485 
00486     *data_p = ( char * ) data;
00487     return com_token;
00488 }

Here is the call graph for this function:

void COM_ParseWarning char *  format,
  ...
 

Definition at line 274 of file q_shared.c.

References com_lines, com_parsename, Com_Printf(), format, string(), va_end, va_list, va_start, and vsprintf().

00275 {
00276     va_list argptr;
00277     static char string[4096];
00278 
00279     va_start (argptr, format);
00280     vsprintf (string, format, argptr);
00281     va_end (argptr);
00282 
00283     Com_Printf("WARNING: %s, line %d: %s\n", com_parsename, com_lines, string);
00284 }

Here is the call graph for this function:

char* COM_SkipPath char *  pathname  ) 
 

Definition at line 42 of file q_shared.c.

Referenced by RE_LoadWorldMap().

00043 {
00044     char    *last;
00045     
00046     last = pathname;
00047     while (*pathname)
00048     {
00049         if (*pathname=='/')
00050             last = pathname+1;
00051         pathname++;
00052     }
00053     return last;
00054 }

void QDECL Com_sprintf char *  dest,
int  size,
const char *  fmt,
  ...
 

Definition at line 870 of file q_shared.c.

00870                                                                     {
00871     int     len;
00872     va_list     argptr;
00873     char    bigbuffer[32000];   // big, but small enough to fit in PPC stack
00874 
00875     va_start (argptr,fmt);
00876     len = vsprintf (bigbuffer,fmt,argptr);
00877     va_end (argptr);
00878     if ( len >= sizeof( bigbuffer ) ) {
00879         Com_Error( ERR_FATAL, "Com_sprintf: overflowed bigbuffer" );
00880     }
00881     if (len >= size) {
00882         Com_Printf ("Com_sprintf: overflow of %i in %i\n", len, size);
00883 #ifdef  _DEBUG
00884         __asm {
00885             int 3;
00886         }
00887 #endif
00888     }
00889     Q_strncpyz (dest, bigbuffer, size );
00890 }

void COM_StripExtension const char *  in,
char *  out
 

Definition at line 61 of file q_shared.c.

References in.

Referenced by CG_RegisterWeapon(), PlayerModel_BuildList(), R_FindShader(), R_FindShaderByName(), R_RemapShader(), RE_LoadWorldMap(), UI_BuildQ3Model_List(), UI_PlayerInfo_SetWeapon(), UI_SaveConfigMenu_SaveEvent(), and VM_LoadSymbols().

00061                                                      {
00062     while ( *in && *in != '.' ) {
00063         *out++ = *in++;
00064     }
00065     *out = 0;
00066 }

float FloatNoSwap const float *  f  ) 
 

Definition at line 192 of file q_shared.c.

00193 {
00194     return *f;
00195 }

float FloatSwap const float *  f  ) 
 

Definition at line 182 of file q_shared.c.

00182                                  {
00183     const _FloatByteUnion *in;
00184     _FloatByteUnion out;
00185 
00186     in = (_FloatByteUnion *)f;
00187     out.i = LongSwap(in->i);
00188 
00189     return out.f;
00190 }

void Info_NextPair const char **  head,
char *  key,
char *  value
 

Definition at line 993 of file q_shared.c.

00993                                                                 {
00994     char    *o;
00995     const char  *s;
00996 
00997     s = *head;
00998 
00999     if ( *s == '\\' ) {
01000         s++;
01001     }
01002     key[0] = 0;
01003     value[0] = 0;
01004 
01005     o = key;
01006     while ( *s != '\\' ) {
01007         if ( !*s ) {
01008             *o = 0;
01009             *head = s;
01010             return;
01011         }
01012         *o++ = *s++;
01013     }
01014     *o = 0;
01015     s++;
01016 
01017     o = value;
01018     while ( *s != '\\' && *s ) {
01019         *o++ = *s++;
01020     }
01021     *o = 0;
01022 
01023     *head = s;
01024 }

void Info_RemoveKey char *  s,
const char *  key
 

Definition at line 1032 of file q_shared.c.

01032                                                 {
01033     char    *start;
01034     char    pkey[MAX_INFO_KEY];
01035     char    value[MAX_INFO_VALUE];
01036     char    *o;
01037 
01038     if ( strlen( s ) >= MAX_INFO_STRING ) {
01039         Com_Error( ERR_DROP, "Info_RemoveKey: oversize infostring" );
01040     }
01041 
01042     if (strchr (key, '\\')) {
01043         return;
01044     }
01045 
01046     while (1)
01047     {
01048         start = s;
01049         if (*s == '\\')
01050             s++;
01051         o = pkey;
01052         while (*s != '\\')
01053         {
01054             if (!*s)
01055                 return;
01056             *o++ = *s++;
01057         }
01058         *o = 0;
01059         s++;
01060 
01061         o = value;
01062         while (*s != '\\' && *s)
01063         {
01064             if (!*s)
01065                 return;
01066             *o++ = *s++;
01067         }
01068         *o = 0;
01069 
01070         if (!strcmp (key, pkey) )
01071         {
01072             strcpy (start, s);  // remove this part
01073             return;
01074         }
01075 
01076         if (!*s)
01077             return;
01078     }
01079 
01080 }

void Info_RemoveKey_Big char *  s,
const char *  key
 

Definition at line 1087 of file q_shared.c.

References Com_Error(), ERR_DROP, s, strchr(), strcmp(), strcpy(), and strlen().

Referenced by Info_SetValueForKey_Big().

01087                                                     {
01088     char    *start;
01089     char    pkey[BIG_INFO_KEY];
01090     char    value[BIG_INFO_VALUE];
01091     char    *o;
01092 
01093     if ( strlen( s ) >= BIG_INFO_STRING ) {
01094         Com_Error( ERR_DROP, "Info_RemoveKey_Big: oversize infostring" );
01095     }
01096 
01097     if (strchr (key, '\\')) {
01098         return;
01099     }
01100 
01101     while (1)
01102     {
01103         start = s;
01104         if (*s == '\\')
01105             s++;
01106         o = pkey;
01107         while (*s != '\\')
01108         {
01109             if (!*s)
01110                 return;
01111             *o++ = *s++;
01112         }
01113         *o = 0;
01114         s++;
01115 
01116         o = value;
01117         while (*s != '\\' && *s)
01118         {
01119             if (!*s)
01120                 return;
01121             *o++ = *s++;
01122         }
01123         *o = 0;
01124 
01125         if (!strcmp (key, pkey) )
01126         {
01127             strcpy (start, s);  // remove this part
01128             return;
01129         }
01130 
01131         if (!*s)
01132             return;
01133     }
01134 
01135 }

Here is the call graph for this function:

void Info_SetValueForKey char *  s,
const char *  key,
const char *  value
 

Definition at line 1165 of file q_shared.c.

01165                                                                         {
01166     char    newi[MAX_INFO_STRING];
01167 
01168     if ( strlen( s ) >= MAX_INFO_STRING ) {
01169         Com_Error( ERR_DROP, "Info_SetValueForKey: oversize infostring" );
01170     }
01171 
01172     if (strchr (key, '\\') || strchr (value, '\\'))
01173     {
01174         Com_Printf ("Can't use keys or values with a \\\n");
01175         return;
01176     }
01177 
01178     if (strchr (key, ';') || strchr (value, ';'))
01179     {
01180         Com_Printf ("Can't use keys or values with a semicolon\n");
01181         return;
01182     }
01183 
01184     if (strchr (key, '\"') || strchr (value, '\"'))
01185     {
01186         Com_Printf ("Can't use keys or values with a \"\n");
01187         return;
01188     }
01189 
01190     Info_RemoveKey (s, key);
01191     if (!value || !strlen(value))
01192         return;
01193 
01194     Com_sprintf (newi, sizeof(newi), "\\%s\\%s", key, value);
01195 
01196     if (strlen(newi) + strlen(s) > MAX_INFO_STRING)
01197     {
01198         Com_Printf ("Info string length exceeded\n");
01199         return;
01200     }
01201 
01202     strcat (newi, s);
01203     strcpy (s, newi);
01204 }

void Info_SetValueForKey_Big char *  s,
const char *  key,
const char *  value
 

Definition at line 1213 of file q_shared.c.

References Com_Error(), Com_Printf(), Com_sprintf(), ERR_DROP, Info_RemoveKey_Big(), s, strcat(), strchr(), strlen(), and value.

Referenced by Cvar_InfoString_Big().

01213                                                                             {
01214     char    newi[BIG_INFO_STRING];
01215 
01216     if ( strlen( s ) >= BIG_INFO_STRING ) {
01217         Com_Error( ERR_DROP, "Info_SetValueForKey: oversize infostring" );
01218     }
01219 
01220     if (strchr (key, '\\') || strchr (value, '\\'))
01221     {
01222         Com_Printf ("Can't use keys or values with a \\\n");
01223         return;
01224     }
01225 
01226     if (strchr (key, ';') || strchr (value, ';'))
01227     {
01228         Com_Printf ("Can't use keys or values with a semicolon\n");
01229         return;
01230     }
01231 
01232     if (strchr (key, '\"') || strchr (value, '\"'))
01233     {
01234         Com_Printf ("Can't use keys or values with a \"\n");
01235         return;
01236     }
01237 
01238     Info_RemoveKey_Big (s, key);
01239     if (!value || !strlen(value))
01240         return;
01241 
01242     Com_sprintf (newi, sizeof(newi), "\\%s\\%s", key, value);
01243 
01244     if (strlen(newi) + strlen(s) > BIG_INFO_STRING)
01245     {
01246         Com_Printf ("BIG Info string length exceeded\n");
01247         return;
01248     }
01249 
01250     strcat (s, newi);
01251 }

Here is the call graph for this function:

qboolean Info_Validate const char *  s  ) 
 

Definition at line 1148 of file q_shared.c.

01148                                         {
01149     if ( strchr( s, '\"' ) ) {
01150         return qfalse;
01151     }
01152     if ( strchr( s, ';' ) ) {
01153         return qfalse;
01154     }
01155     return qtrue;
01156 }

char* Info_ValueForKey const char *  s,
const char *  key
 

Definition at line 936 of file q_shared.c.

Referenced by ArenaServers_Insert(), CG_ParseServerinfo(), CL_SetServerInfo(), ClientUserinfoChanged(), G_BotConnect(), G_CheckBotSpawn(), StartServer_Cache(), StartServer_GametypeEvent(), SV_SetUserinfo(), SV_UserinfoChanged(), UI_AddBotsMenu_SetBotNames(), UI_BotSelectMenu_UpdateGrid(), UI_BuildFindPlayerList(), UI_BuildPlayerList(), UI_RemoveBotsMenu_SetBotNames(), UI_SPLevelMenu_SetBots(), and UI_TeamOrdersMenu_BuildBotList().

00936                                                          {
00937     char    pkey[BIG_INFO_KEY];
00938     static  char value[2][BIG_INFO_VALUE];  // use two buffers so compares
00939                                             // work without stomping on each other
00940     static  int valueindex = 0;
00941     char    *o;
00942     
00943     if ( !s || !key ) {
00944         return "";
00945     }
00946 
00947     if ( strlen( s ) >= BIG_INFO_STRING ) {
00948         Com_Error( ERR_DROP, "Info_ValueForKey: oversize infostring" );
00949     }
00950 
00951     valueindex ^= 1;
00952     if (*s == '\\')
00953         s++;
00954     while (1)
00955     {
00956         o = pkey;
00957         while (*s != '\\')
00958         {
00959             if (!*s)
00960                 return "";
00961             *o++ = *s++;
00962         }
00963         *o = 0;
00964         s++;
00965 
00966         o = value[valueindex];
00967 
00968         while (*s != '\\' && *s)
00969         {
00970             *o++ = *s++;
00971         }
00972         *o = 0;
00973 
00974         if (!Q_stricmp (key, pkey) )
00975             return value[valueindex];
00976 
00977         if (!*s)
00978             break;
00979         s++;
00980     }
00981 
00982     return "";
00983 }

qint64 Long64NoSwap qint64  ll  ) 
 

Definition at line 172 of file q_shared.c.

00173 {
00174     return ll;
00175 }

qint64 Long64Swap qint64  ll  ) 
 

Definition at line 156 of file q_shared.c.

References qint64::b0, qint64::b1, qint64::b2, qint64::b3, qint64::b4, qint64::b5, qint64::b6, and qint64::b7.

00157 {
00158     qint64  result;
00159 
00160     result.b0 = ll.b7;
00161     result.b1 = ll.b6;
00162     result.b2 = ll.b5;
00163     result.b3 = ll.b4;
00164     result.b4 = ll.b3;
00165     result.b5 = ll.b2;
00166     result.b6 = ll.b1;
00167     result.b7 = ll.b0;
00168 
00169     return result;
00170 }

int LongNoSwap int  l  ) 
 

Definition at line 151 of file q_shared.c.

00152 {
00153     return l;
00154 }

int LongSwap int  l  ) 
 

Definition at line 139 of file q_shared.c.

00140 {
00141     byte    b1,b2,b3,b4;
00142 
00143     b1 = l&255;
00144     b2 = (l>>8)&255;
00145     b3 = (l>>16)&255;
00146     b4 = (l>>24)&255;
00147 
00148     return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
00149 }

void Parse1DMatrix char **  buf_p,
int  x,
float *  m
 

Definition at line 609 of file q_shared.c.

00609                                                    {
00610     char    *token;
00611     int     i;
00612 
00613     COM_MatchToken( buf_p, "(" );
00614 
00615     for (i = 0 ; i < x ; i++) {
00616         token = COM_Parse(buf_p);
00617         m[i] = atof(token);
00618     }
00619 
00620     COM_MatchToken( buf_p, ")" );
00621 }

void Parse2DMatrix char **  buf_p,
int  y,
int  x,
float *  m
 

Definition at line 623 of file q_shared.c.

00623                                                           {
00624     int     i;
00625 
00626     COM_MatchToken( buf_p, "(" );
00627 
00628     for (i = 0 ; i < y ; i++) {
00629         Parse1DMatrix (buf_p, x, m + i * x);
00630     }
00631 
00632     COM_MatchToken( buf_p, ")" );
00633 }

void Parse3DMatrix char **  buf_p,
int  z,
int  y,
int  x,
float *  m
 

Definition at line 635 of file q_shared.c.

00635                                                                  {
00636     int     i;
00637 
00638     COM_MatchToken( buf_p, "(" );
00639 
00640     for (i = 0 ; i < z ; i++) {
00641         Parse2DMatrix (buf_p, y, x, m + i * x*y);
00642     }
00643 
00644     COM_MatchToken( buf_p, ")" );
00645 }

char* Q_CleanStr char *  string  ) 
 

Definition at line 848 of file q_shared.c.

00848                                  {
00849     char*   d;
00850     char*   s;
00851     int     c;
00852 
00853     s = string;
00854     d = string;
00855     while ((c = *s) != 0 ) {
00856         if ( Q_IsColorString( s ) ) {
00857             s++;
00858         }       
00859         else if ( c >= 0x20 && c <= 0x7E ) {
00860             *d++ = c;
00861         }
00862         s++;
00863     }
00864     *d = '\0';
00865 
00866     return string;
00867 }

int Q_isalpha int  c  ) 
 

Definition at line 677 of file q_shared.c.

00678 {
00679     if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
00680         return ( 1 );
00681     return ( 0 );
00682 }

int Q_islower int  c  ) 
 

Definition at line 663 of file q_shared.c.

00664 {
00665     if (c >= 'a' && c <= 'z')
00666         return ( 1 );
00667     return ( 0 );
00668 }

int Q_isprint int  c  ) 
 

Definition at line 656 of file q_shared.c.

00657 {
00658     if ( c >= 0x20 && c <= 0x7E )
00659         return ( 1 );
00660     return ( 0 );
00661 }

int Q_isupper int  c  ) 
 

Definition at line 670 of file q_shared.c.

00671 {
00672     if (c >= 'A' && c <= 'Z')
00673         return ( 1 );
00674     return ( 0 );
00675 }

int Q_PrintStrlen const char *  string  ) 
 

Definition at line 825 of file q_shared.c.

00825                                         {
00826     int         len;
00827     const char  *p;
00828 
00829     if( !string ) {
00830         return 0;
00831     }
00832 
00833     len = 0;
00834     p = string;
00835     while( *p ) {
00836         if( Q_IsColorString( p ) ) {
00837             p += 2;
00838             continue;
00839         }
00840         p++;
00841         len++;
00842     }
00843 
00844     return len;
00845 }

void Q_strcat char *  dest,
int  size,
const char *  src
 

Definition at line 814 of file q_shared.c.

00814                                                        {
00815     int     l1;
00816 
00817     l1 = strlen( dest );
00818     if ( l1 >= size ) {
00819         Com_Error( ERR_FATAL, "Q_strcat: already overflowed" );
00820     }
00821     Q_strncpyz( dest + l1, src, size - l1 );
00822 }

int Q_stricmp const char *  s1,
const char *  s2
 

Definition at line 785 of file q_shared.c.

00785                                                {
00786     return (s1 && s2) ? Q_stricmpn (s1, s2, 99999) : -1;
00787 }

int Q_stricmpn const char *  s1,
const char *  s2,
int  n
 

Definition at line 727 of file q_shared.c.

00727                                                        {
00728     int     c1, c2;
00729 
00730     // bk001129 - moved in 1.17 fix not in id codebase
00731