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

common.c File Reference

#include "../game/q_shared.h"
#include "qcommon.h"
#include <setjmp.h>
#include <winsock.h>

Include dependency graph for common.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  hunkblock_s
struct  hunkHeader_t
struct  hunkUsed_t
struct  memblock_s
struct  memstatic_s
struct  memzone_t
struct  zonedebug_s

Defines

#define DEF_COMHUNKMEGS   "56"
#define DEF_COMZONEMEGS   "16"
#define HUNK_FREE_MAGIC   0x89537893
#define HUNK_MAGIC   0x89537892
#define MAX_CONSOLE_LINES   32
#define MAX_NUM_ARGVS   50
#define MAX_PUSHED_EVENTS   1024
#define MIN_COMHUNKMEGS   56
#define MIN_DEDICATED_COMHUNKMEGS   1
#define MINFRAGMENT   64
#define ZONEID   0x1d4a11

Typedefs

typedef hunkblock_s hunkblock_t
typedef memblock_s memblock_t
typedef memstatic_s memstatic_t
typedef zonedebug_s zonedebug_t

Functions

void CIN_CloseAllVideos ()
qboolean CL_CDKeyValidate (const char *key, const char *checksum)
void CL_ShutdownCGame (void)
void CL_ShutdownUI (void)
qboolean Com_AddStartupCommands (void)
void Com_AppendCDKey (const char *filename)
void Com_BeginRedirect (char *buffer, int buffersize, void(*flush)(char *))
void Com_Crash_f (void)
void QDECL Com_DPrintf (const char *fmt,...)
void Com_EndRedirect (void)
void QDECL Com_Error (int code, const char *fmt,...)
void Com_Error_f (void)
int Com_EventLoop (void)
int Com_Filter (char *filter, char *name, int casesensitive)
int Com_FilterPath (char *filter, char *name, int casesensitive)
void Com_Frame (void)
void Com_Freeze_f (void)
sysEvent_t Com_GetEvent (void)
sysEvent_t Com_GetRealEvent (void)
int Com_HashKey (char *string, int maxlen)
void Com_Init (char *commandLine)
void Com_InitHunkMemory (void)
void Com_InitJournaling (void)
void Com_InitPushEvent (void)
void Com_InitSmallZoneMemory (void)
void Com_InitZoneMemory (void)
void Com_Memcpy (void *dest, const void *src, const size_t count)
void Com_Meminfo_f (void)
void Com_Memset (void *dest, const int val, const size_t count)
int Com_Milliseconds (void)
int Com_ModifyMsec (int msec)
void Com_ParseCommandLine (char *commandLine)
void QDECL Com_Printf (const char *fmt,...)
void Com_PushEvent (sysEvent_t *event)
void Com_Quit_f (void)
void Com_ReadCDKey (const char *filename)
int Com_RealTime (qtime_t *qtime)
void Com_RunAndTimeServerPacket (netadr_t *evFrom, msg_t *buf)
qboolean Com_SafeMode (void)
void Com_Shutdown (void)
void Com_StartupVariable (const char *match)
char * Com_StringContains (char *str1, char *str2, int casesensitive)
void Com_TouchMemory (void)
void Com_WriteCDKey (const char *filename, const char *ikey)
void Com_WriteConfig_f (void)
void Com_WriteConfigToFile (const char *filename)
void Com_WriteConfiguration (void)
void ConcatRemaining (const char *src, const char *start)
char * CopyString (const char *in)
void Field_Clear (field_t *edit)
void Field_CompleteCommand (field_t *field)
void FindMatches (const char *s)
void * Hunk_Alloc (int size, ha_pref preference)
void * Hunk_AllocateTempMemory (int size)
qboolean Hunk_CheckMark (void)
void Hunk_Clear (void)
void Hunk_ClearTempMemory (void)
void Hunk_ClearToMark (void)
void Hunk_FreeTempMemory (void *buf)
void Hunk_Log (void)
int Hunk_MemoryRemaining (void)
void Hunk_SetMark (void)
void Hunk_SmallLog (void)
void Hunk_SwapBanks (void)
void Hunk_Trash (void)
void Info_Print (const char *s)
void keyConcatArgs (void)
void PrintMatches (const char *s)
float Q_acos (float c)
void * S_Malloc (int size)
void SV_ShutdownGameProgs (void)
int Z_AvailableMemory (void)
int Z_AvailableZoneMemory (memzone_t *zone)
void Z_CheckHeap (void)
void Z_ClearZone (memzone_t *zone, int size)
void Z_Free (void *ptr)
void Z_FreeTags (int tag)
void Z_LogHeap (void)
void Z_LogZoneHeap (memzone_t *zone, char *name)
void * Z_Malloc (int size)
void * Z_TagMalloc (int size, int tag)

Variables

jmp_buf abortframe
char cl_cdkey [34] = " "
cvar_tcl_paused
int com_argc
char * com_argv [MAX_NUM_ARGVS+1]
cvar_tcom_blood
cvar_tcom_buildScript
cvar_tcom_cameraMode
cvar_tcom_cl_running
char * com_consoleLines [MAX_CONSOLE_LINES]
cvar_tcom_dedicated
cvar_tcom_developer
cvar_tcom_dropsim
qboolean com_errorEntered
char com_errorMessage [MAXPRINTMSG]
cvar_tcom_fixedtime
int com_frameMsec
int com_frameNumber
int com_frameTime
qboolean com_fullyInitialized
cvar_tcom_introPlayed
cvar_tcom_journal
fileHandle_t com_journalDataFile
fileHandle_t com_journalFile
cvar_tcom_logfile
cvar_tcom_maxfps
int com_numConsoleLines
sysEvent_t com_pushedEvents [MAX_PUSHED_EVENTS]
int com_pushedEventsHead = 0
int com_pushedEventsTail = 0
cvar_tcom_showtrace
cvar_tcom_speeds
cvar_tcom_sv_running
cvar_tcom_timedemo
cvar_tcom_timescale
cvar_tcom_version
cvar_tcom_viewlog
field_tcompletionField
const char * completionString
FILEdebuglogfile
int demo_protocols []
memstatic_t emptystring
hunkUsed_t hunk_high
hunkUsed_t hunk_low
hunkUsed_thunk_permanent
hunkUsed_thunk_temp
hunkblock_thunkblocks
fileHandle_t logfile
memzone_tmainzone
int matchCount
memstatic_t numberstring []
char * rd_buffer
int rd_buffersize
void(* rd_flush )(char *buffer)
bytes_hunkData = NULL
int s_hunkTotal
int s_smallZoneTotal
int s_zoneTotal
char shortestMatch [MAX_TOKEN_CHARS]
memzone_tsmallzone
cvar_tsv_paused
int time_backend
int time_frontend
int time_game


Define Documentation

#define DEF_COMHUNKMEGS   "56"
 

Definition at line 48 of file common.c.

Referenced by Com_InitHunkMemory().

#define DEF_COMZONEMEGS   "16"
 

Definition at line 49 of file common.c.

Referenced by Com_InitZoneMemory().

#define HUNK_FREE_MAGIC   0x89537893
 

Definition at line 1194 of file common.c.

#define HUNK_MAGIC   0x89537892
 

Definition at line 1193 of file common.c.

#define MAX_CONSOLE_LINES   32
 

Definition at line 353 of file common.c.

#define MAX_NUM_ARGVS   50
 

Definition at line 40 of file common.c.

#define MAX_PUSHED_EVENTS   1024
 

Definition at line 1891 of file common.c.

Referenced by Com_GetEvent(), and Com_PushEvent().

#define MIN_COMHUNKMEGS   56
 

Definition at line 43 of file common.c.

#define MIN_DEDICATED_COMHUNKMEGS   1
 

Definition at line 42 of file common.c.

#define MINFRAGMENT   64
 

Definition at line 723 of file common.c.

#define ZONEID   0x1d4a11
 

Definition at line 722 of file common.c.


Typedef Documentation

typedef struct hunkblock_s hunkblock_t
 

Referenced by Hunk_Alloc(), Hunk_Log(), and Hunk_SmallLog().

typedef struct memblock_s memblock_t
 

Referenced by Com_Meminfo_f(), Com_TouchMemory(), CopyString(), Z_CheckHeap(), Z_ClearZone(), Z_Free(), Z_LogZoneHeap(), and Z_TagMalloc().

typedef struct memstatic_s memstatic_t
 

typedef struct zonedebug_s zonedebug_t
 

Referenced by Z_LogZoneHeap().


Function Documentation

void CIN_CloseAllVideos  ) 
 

Definition at line 143 of file cl_cin.c.

References CIN_StopCinematic(), cinTable, cin_cache::fileName, and i.

Referenced by Hunk_Clear().

00143                               {
00144     int     i;
00145 
00146     for ( i = 0 ; i < MAX_VIDEO_HANDLES ; i++ ) {
00147         if (cinTable[i].fileName[0] != 0 ) {
00148             CIN_StopCinematic(i);
00149         }
00150     }
00151 }

Here is the call graph for this function:

qboolean CL_CDKeyValidate const char *  key,
const char *  checksum
 

Definition at line 3265 of file cl_main.c.

References byte, ch, i, Q_stricmp(), qboolean, sprintf(), and strlen().

Referenced by CL_UISystemCalls(), Com_AppendCDKey(), Com_ReadCDKey(), and Com_WriteCDKey().

03265                                                                    {
03266     char    ch;
03267     byte    sum;
03268     char    chs[3];
03269     int i, len;
03270 
03271     len = strlen(key);
03272     if( len != CDKEY_LEN ) {
03273         return qfalse;
03274     }
03275 
03276     if( checksum && strlen( checksum ) != CDCHKSUM_LEN ) {
03277         return qfalse;
03278     }
03279 
03280     sum = 0;
03281     // for loop gets rid of conditional assignment warning
03282     for (i = 0; i < len; i++) {
03283         ch = *key++;
03284         if (ch>='a' && ch<='z') {
03285             ch -= 32;
03286         }
03287         switch( ch ) {
03288         case '2':
03289         case '3':
03290         case '7':
03291         case 'A':
03292         case 'B':
03293         case 'C':
03294         case 'D':
03295         case 'G':
03296         case 'H':
03297         case 'J':
03298         case 'L':
03299         case 'P':
03300         case 'R':
03301         case 'S':
03302         case 'T':
03303         case 'W':
03304             sum += ch;
03305             continue;
03306         default:
03307             return qfalse;
03308         }
03309     }
03310 
03311     sprintf(chs, "%02x", sum);
03312     
03313     if (checksum && !Q_stricmp(chs, checksum)) {
03314         return qtrue;
03315     }
03316 
03317     if (!checksum) {
03318         return qtrue;
03319     }
03320 
03321     return qfalse;
03322 }

Here is the call graph for this function:

void CL_ShutdownCGame void   ) 
 

Definition at line 389 of file cl_cgame.c.

References CG_SHUTDOWN, clientStatic_t::cgameStarted, cgvm, cls, clientStatic_t::keyCatchers, VM_Call(), and VM_Free().

Referenced by CL_ShutdownAll(), CL_Vid_Restart_f(), and Hunk_Clear().

00389                               {
00390     cls.keyCatchers &= ~KEYCATCH_CGAME;
00391     cls.cgameStarted = qfalse;
00392     if ( !cgvm ) {
00393         return;
00394     }
00395     VM_Call( cgvm, CG_SHUTDOWN );
00396     VM_Free( cgvm );
00397     cgvm = NULL;
00398 }

Here is the call graph for this function:

void CL_ShutdownUI void   ) 
 

Definition at line 1127 of file cl_ui.c.

References cls, clientStatic_t::keyCatchers, UI_SHUTDOWN, clientStatic_t::uiStarted, uivm, VM_Call(), and VM_Free().

Referenced by CL_Shutdown(), CL_ShutdownAll(), CL_Vid_Restart_f(), and Hunk_Clear().

01127                            {
01128     cls.keyCatchers &= ~KEYCATCH_UI;
01129     cls.uiStarted = qfalse;
01130     if ( !uivm ) {
01131         return;
01132     }
01133     VM_Call( uivm, UI_SHUTDOWN );
01134     VM_Free( uivm );
01135     uivm = NULL;
01136 }

Here is the call graph for this function:

qboolean Com_AddStartupCommands void   ) 
 

Definition at line 455 of file common.c.

References Cbuf_AddText(), com_consoleLines, i, Q_stricmpn(), and qboolean.

Referenced by Com_Init().

00455                                         {
00456     int     i;
00457     qboolean    added;
00458 
00459     added = qfalse;
00460     // quote every token, so args with semicolons can work
00461     for (i=0 ; i < com_numConsoleLines ; i++) {
00462         if ( !com_consoleLines[i] || !com_consoleLines[i][0] ) {
00463             continue;
00464         }
00465 
00466         // set commands won't override menu startup
00467         if ( Q_stricmpn( com_consoleLines[i], "set", 3 ) ) {
00468             added = qtrue;
00469         }
00470         Cbuf_AddText( com_consoleLines[i] );
00471         Cbuf_AddText( "\n" );
00472     }
00473 
00474     return added;
00475 }

Here is the call graph for this function:

void Com_AppendCDKey const char *  filename  ) 
 

Definition at line 2283 of file common.c.

References buffer, cl_cdkey, CL_CDKeyValidate(), Com_Memset(), f, fileHandle_t, FS_FCloseFile(), FS_Read(), FS_SV_FOpenFileRead(), NULL, Q_strncpyz(), sprintf(), and strcat().

Referenced by FS_Startup().

02283                                              {
02284     fileHandle_t    f;
02285     char            buffer[33];
02286     char            fbuffer[MAX_OSPATH];
02287 
02288     sprintf(fbuffer, "%s/q3key", filename);
02289 
02290     FS_SV_FOpenFileRead( fbuffer, &f );
02291     if (!f) {
02292         Q_strncpyz( &cl_cdkey[16], "                ", 17 );
02293         return;
02294     }
02295 
02296     Com_Memset( buffer, 0, sizeof(buffer) );
02297 
02298     FS_Read( buffer, 16, f );
02299     FS_FCloseFile( f );
02300 
02301     if (CL_CDKeyValidate(buffer, NULL)) {
02302         strcat( &cl_cdkey[16], buffer );
02303     } else {
02304         Q_strncpyz( &cl_cdkey[16], "                ", 17 );
02305     }
02306 }

Here is the call graph for this function:

void Com_BeginRedirect char *  buffer,
int  buffersize,
void(*)(char *)  flush
 

Definition at line 111 of file common.c.

References buffer, rd_buffer, rd_buffersize, and rd_flush.

Referenced by SVC_RemoteCommand().

00112 {
00113     if (!buffer || !buffersize || !flush)
00114         return;
00115     rd_buffer = buffer;
00116     rd_buffersize = buffersize;
00117     rd_flush = flush;
00118 
00119     *rd_buffer = 0;
00120 }

void Com_Crash_f void   )  [static]
 

Definition at line 2234 of file common.c.

Referenced by Com_Init().

02234                                 {
02235     * ( int * ) 0 = 0x12345678;
02236 }

void QDECL Com_DPrintf const char *  fmt,
  ...
 

Definition at line 209 of file common.c.

00209                                               {
00210     va_list     argptr;
00211     char        msg[MAXPRINTMSG];
00212         
00213     if ( !com_developer || !com_developer->integer ) {
00214         return;         // don't confuse non-developers with techie stuff...
00215     }
00216 
00217     va_start (argptr,fmt);  
00218     Q_vsnprintf (msg, sizeof(msg), fmt, argptr);
00219     va_end (argptr);
00220     
00221     Com_Printf ("%s", msg);
00222 }

void Com_EndRedirect void   ) 
 

Definition at line 122 of file common.c.

References rd_buffer, rd_buffersize, and rd_flush.

Referenced by SVC_RemoteCommand().

00123 {
00124     if ( rd_flush ) {
00125         rd_flush(rd_buffer);
00126     }
00127 
00128     rd_buffer = NULL;
00129     rd_buffersize = 0;
00130     rd_flush = NULL;
00131 }

void QDECL Com_Error int  code,
const char *  fmt,
  ...
 

Definition at line 232 of file common.c.

References abortframe, CL_CDDialog(), CL_Disconnect(), CL_FlushMemory(), CL_Shutdown(), code, com_buildScript, com_cl_running, com_errorEntered, com_errorMessage, Com_Printf(), Com_Shutdown(), Cvar_Set(), ERR_DISCONNECT, ERR_DROP, errorCount, FS_PureServerSetLoadedPaks(), cvar_s::integer, longjmp(), QDECL, qtrue, SV_Shutdown(), Sys_Error(), Sys_Milliseconds(), va(), va_end, va_list, va_start, and vsprintf().

00232                                                        {
00233     va_list     argptr;
00234     static int  lastErrorTime;
00235     static int  errorCount;
00236     int         currentTime;
00237 
00238 #if defined(_WIN32) && defined(_DEBUG)
00239     if ( code != ERR_DISCONNECT && code != ERR_NEED_CD ) {
00240         if (!com_noErrorInterrupt->integer) {
00241             __asm {
00242                 int 0x03
00243             }
00244         }
00245     }
00246 #endif
00247 
00248     // when we are running automated scripts, make sure we
00249     // know if anything failed
00250     if ( com_buildScript && com_buildScript->integer ) {
00251         code = ERR_FATAL;
00252     }
00253 
00254     // make sure we can get at our local stuff
00255     FS_PureServerSetLoadedPaks( "", "" );
00256 
00257     // if we are getting a solid stream of ERR_DROP, do an ERR_FATAL
00258     currentTime = Sys_Milliseconds();
00259     if ( currentTime - lastErrorTime < 100 ) {
00260         if ( ++errorCount > 3 ) {
00261             code = ERR_FATAL;
00262         }
00263     } else {
00264         errorCount = 0;
00265     }
00266     lastErrorTime = currentTime;
00267 
00268     if ( com_errorEntered ) {
00269         Sys_Error( "recursive error after: %s", com_errorMessage );
00270     }
00271     com_errorEntered = qtrue;
00272 
00273     va_start (argptr,fmt);
00274     vsprintf (com_errorMessage,fmt,argptr);
00275     va_end (argptr);
00276 
00277     if ( code != ERR_DISCONNECT && code != ERR_NEED_CD ) {
00278         Cvar_Set("com_errorMessage", com_errorMessage);
00279     }
00280 
00281     if ( code == ERR_SERVERDISCONNECT ) {
00282         CL_Disconnect( qtrue );
00283         CL_FlushMemory( );
00284         com_errorEntered = qfalse;
00285         longjmp (abortframe, -1);
00286     } else if ( code == ERR_DROP || code == ERR_DISCONNECT ) {
00287         Com_Printf ("********************\nERROR: %s\n********************\n", com_errorMessage);
00288         SV_Shutdown (va("Server crashed: %s\n",  com_errorMessage));
00289         CL_Disconnect( qtrue );
00290         CL_FlushMemory( );
00291         com_errorEntered = qfalse;
00292         longjmp (abortframe, -1);
00293     } else if ( code == ERR_NEED_CD ) {
00294         SV_Shutdown( "Server didn't have CD\n" );
00295         if ( com_cl_running && com_cl_running->integer ) {
00296             CL_Disconnect( qtrue );
00297             CL_FlushMemory( );
00298             com_errorEntered = qfalse;
00299             CL_CDDialog();
00300         } else {
00301             Com_Printf("Server didn't have CD\n" );
00302         }
00303         longjmp (abortframe, -1);
00304     } else {
00305         CL_Shutdown ();
00306         SV_Shutdown (va("Server fatal crashed: %s\n", com_errorMessage));
00307     }
00308 
00309     Com_Shutdown ();
00310 
00311     Sys_Error ("%s", com_errorMessage);
00312 }

Here is the call graph for this function:

void Com_Error_f void   )  [static]
 

Definition at line 2190 of file common.c.

References Cmd_Argc(), Com_Error(), ERR_DROP, and ERR_FATAL.

Referenced by Com_Init().

02190                                {
02191     if ( Cmd_Argc() > 1 ) {
02192         Com_Error( ERR_DROP, "Testing drop error" );
02193     } else {
02194         Com_Error( ERR_FATAL, "Testing fatal error" );
02195     }
02196 }

Here is the call graph for this function:

int Com_EventLoop void   ) 
 

Definition at line 2065 of file common.c.

References byte, Cbuf_AddText(), CL_CharEvent(), CL_JoystickEvent(), CL_KeyEvent(), CL_MouseEvent(), CL_PacketEvent(), com_dropsim, Com_Error(), Com_GetEvent(), Com_Memcpy(), Com_Printf(), Com_RunAndTimeServerPacket(), com_sv_running, msg_t::cursize, msg_t::data, ERR_FATAL, sysEvent_t::evPtr, sysEvent_t::evPtrLength, sysEvent_t::evTime, sysEvent_t::evType, sysEvent_t::evValue, sysEvent_t::evValue2, cvar_s::integer, msg_t::maxsize, MSG_Init(), NET_GetLoopPacket(), NS_CLIENT, NS_SERVER, Q_random(), SE_CHAR, SE_CONSOLE, SE_JOYSTICK_AXIS, SE_KEY, SE_MOUSE, SE_NONE, SE_PACKET, cvar_s::value, and Z_Free().

Referenced by CL_DownloadsComplete(), and Com_Frame().

02065                           {
02066     sysEvent_t  ev;
02067     netadr_t    evFrom;
02068     byte        bufData[MAX_MSGLEN];
02069     msg_t       buf;
02070 
02071     MSG_Init( &buf, bufData, sizeof( bufData ) );
02072 
02073     while ( 1 ) {
02074         ev = Com_GetEvent();
02075 
02076         // if no more events are available
02077         if ( ev.evType == SE_NONE ) {
02078             // manually send packet events for the loopback channel
02079             while ( NET_GetLoopPacket( NS_CLIENT, &evFrom, &buf ) ) {
02080                 CL_PacketEvent( evFrom, &buf );
02081             }
02082 
02083             while ( NET_GetLoopPacket( NS_SERVER, &evFrom, &buf ) ) {
02084                 // if the server just shut down, flush the events
02085                 if ( com_sv_running->integer ) {
02086                     Com_RunAndTimeServerPacket( &evFrom, &buf );
02087                 }
02088             }
02089 
02090             return ev.evTime;
02091         }
02092 
02093 
02094         switch ( ev.evType ) {
02095         default:
02096           // bk001129 - was ev.evTime
02097             Com_Error( ERR_FATAL, "Com_EventLoop: bad event type %i", ev.evType );
02098             break;
02099         case SE_NONE:
02100             break;
02101         case SE_KEY:
02102             CL_KeyEvent( ev.evValue, ev.evValue2, ev.evTime );
02103             break;
02104         case SE_CHAR:
02105             CL_CharEvent( ev.evValue );
02106             break;
02107         case SE_MOUSE:
02108             CL_MouseEvent( ev.evValue, ev.evValue2, ev.evTime );
02109             break;
02110         case SE_JOYSTICK_AXIS:
02111             CL_JoystickEvent( ev.evValue, ev.evValue2, ev.evTime );
02112             break;
02113         case SE_CONSOLE:
02114             Cbuf_AddText( (char *)ev.evPtr );
02115             Cbuf_AddText( "\n" );
02116             break;
02117         case SE_PACKET:
02118             // this cvar allows simulation of connections that
02119             // drop a lot of packets.  Note that loopback connections
02120             // don't go through here at all.
02121             if ( com_dropsim->value > 0 ) {
02122                 static int seed;
02123 
02124                 if ( Q_random( &seed ) < com_dropsim->value ) {
02125                     break;      // drop this packet
02126                 }
02127             }
02128 
02129             evFrom = *(netadr_t *)ev.evPtr;
02130             buf.cursize = ev.evPtrLength - sizeof( evFrom );
02131 
02132             // we must copy the contents of the message out, because
02133             // the event buffers are only large enough to hold the
02134             // exact payload, but channel messages need to be large
02135             // enough to hold fragment reassembly
02136             if ( (unsigned)buf.cursize > buf.maxsize ) {
02137                 Com_Printf("Com_EventLoop: oversize packet\n");
02138                 continue;
02139             }
02140             Com_Memcpy( buf.data, (byte *)((netadr_t *)ev.evPtr + 1), buf.cursize );
02141             if ( com_sv_running->integer ) {
02142                 Com_RunAndTimeServerPacket( &evFrom, &buf );
02143             } else {
02144                 CL_PacketEvent( evFrom, &buf );
02145             }
02146             break;
02147         }
02148 
02149         // free any block data
02150         if ( ev.evPtr ) {
02151             Z_Free( ev.evPtr );
02152         }
02153     }
02154 
02155     return 0;   // never reached
02156 }

Here is the call graph for this function:

int Com_Filter char *  filter,
char *  name,
int  casesensitive
 

Definition at line 556 of file common.c.

00557 {
00558     char buf[MAX_TOKEN_CHARS];
00559     char *ptr;
00560     int i, found;
00561 
00562     while(*filter) {
00563         if (*filter == '*') {
00564             filter++;
00565             for (i = 0; *filter; i++) {
00566                 if (*filter == '*' || *filter == '?') break;
00567                 buf[i] = *filter;
00568                 filter++;
00569             }
00570             buf[i] = '\0';
00571             if (strlen(buf)) {
00572                 ptr = Com_StringContains(name, buf, casesensitive);
00573                 if (!ptr) return qfalse;
00574                 name = ptr + strlen(buf);
00575             }
00576         }
00577         else if (*filter == '?') {
00578             filter++;
00579             name++;
00580         }
00581         else if (*filter == '[' && *(filter+1) == '[') {
00582             filter++;
00583         }
00584         else if (*filter == '[') {
00585             filter++;
00586             found = qfalse;
00587             while(*filter && !found) {
00588                 if (*filter == ']' && *(filter+1) != ']') break;
00589                 if (*(filter+1) == '-' && *(filter+2) && (*(filter+2) != ']' || *(filter+3) == ']')) {
00590                     if (casesensitive) {
00591                         if (*name >= *filter && *name <= *(filter+2)) found = qtrue;
00592                     }
00593                     else {
00594                         if (toupper(*name) >= toupper(*filter) &&
00595                             toupper(*name) <= toupper(*(filter+2))) found = qtrue;
00596                     }
00597                     filter += 3;
00598                 }
00599                 else {
00600                     if (casesensitive) {
00601                         if (*filter == *name) found = qtrue;
00602                     }
00603                     else {
00604                         if (toupper(*filter) == toupper(*name)) found = qtrue;
00605                     }
00606                     filter++;
00607                 }
00608             }
00609             if (!found) return qfalse;
00610             while(*filter) {
00611                 if (*filter == ']' && *(filter+1) != ']') break;
00612                 filter++;
00613             }
00614             filter++;
00615             name++;
00616         }
00617         else {
00618             if (casesensitive) {
00619                 if (*filter != *name) return qfalse;
00620             }
00621             else {
00622                 if (toupper(*filter) != toupper(*name)) return qfalse;
00623             }
00624             filter++;
00625             name++;
00626         }
00627     }
00628     return qtrue;
00629 }

int Com_FilterPath char *  filter,
char *  name,
int  casesensitive
 

Definition at line 636 of file common.c.

References Com_Filter(), i, MAX_QPATH, and name.

Referenced by FS_ListFilteredFiles(), and Sys_ListFilteredFiles().

00637 {
00638     int i;
00639     char new_filter[MAX_QPATH];
00640     char new_name[MAX_QPATH];
00641 
00642     for (i = 0; i < MAX_QPATH-1 && filter[i]; i++) {
00643         if ( filter[i] == '\\' || filter[i] == ':' ) {
00644             new_filter[i] = '/';
00645         }
00646         else {
00647             new_filter[i] = filter[i];
00648         }
00649     }
00650     new_filter[i] = '\0';
00651     for (i = 0; i < MAX_QPATH-1 && name[i]; i++) {
00652         if ( name[i] == '\\' || name[i] == ':' ) {
00653             new_name[i] = '/';
00654         }
00655         else {
00656             new_name[i] = name[i];
00657         }
00658     }
00659     new_name[i] = '\0';
00660     return Com_Filter(new_filter, new_name, casesensitive);
00661 }

Here is the call graph for this function:

void Com_Frame void   ) 
 

Definition at line 2635 of file common.c.

References abortframe, c_brush_traces, c_patch_traces, c_pointcontents, c_traces, Cbuf_Execute(), cl, CL_Frame(), CL_Init(), CL_Shutdown(), com_dedicated, Com_EventLoop(), com_frameMsec, com_frameNumber, com_frameTime, com_maxfps, Com_ModifyMsec(), Com_Printf(), com_showtrace, com_speeds, com_timedemo, com_viewlog, Com_WriteConfiguration(), Cvar_Get(), cvar_s::integer, cvar_s::modified, qfalse, qtrue, setjmp(),