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

win_main.c File Reference

#include "../client/client.h"
#include "../qcommon/qcommon.h"
#include "win_local.h"
#include "resource.h"
#include <errno.h>
#include <float.h>
#include <fcntl.h>
#include <stdio.h>
#include <direct.h>
#include <io.h>
#include <conio.h>
#include <sys\stat.h>

Include dependency graph for win_main.c:

Include dependency graph

Go to the source code of this file.

Defines

#define ALT_SPANK
#define CD_BASEDIR   "quake3"
#define CD_BASEDIR_LINUX   "bin\\x86\\glibc-2.1"
#define CD_EXE   "quake3.exe"
#define CD_EXE_LINUX   "quake3"
#define MASK_QUED_EVENTS   ( MAX_QUED_EVENTS - 1 )
#define MAX_FOUND_FILES   0x1000
#define MAX_QUED_EVENTS   256
#define MEM_THRESHOLD   96*1024*1024
#define OSR2_BUILD_NUMBER   1111
#define WIN98_BUILD_NUMBER   1998

Functions

char * FS_BuildOSPath (const char *base, const char *game, const char *qpath)
void Spk_Close ()
void Spk_Open (char *name)
void Spk_Printf (const char *text,...)
qboolean strgtr (const char *s0, const char *s1)
void Sys_BeginProfiling (void)
void Sys_BeginStreamedFile (fileHandle_t f, int readAhead)
qboolean Sys_CheckCD (void)
char * Sys_Cwd (void)
char * Sys_DefaultBasePath (void)
char * Sys_DefaultCDPath (void)
void Sys_EndStreamedFile (fileHandle_t f)
void QDECL Sys_Error (const char *error,...)
void Sys_FreeFileList (char **list)
char * Sys_GetClipboardData (void)
sysEvent_t Sys_GetEvent (void)
void Sys_In_Restart_f (void)
void Sys_Init (void)
void Sys_InitStreamThread (void)
char ** Sys_ListFiles (const char *directory, const char *extension, char *filter, int *numfiles, qboolean wantsubs)
void Sys_ListFilteredFiles (const char *basedir, char *subdirs, char *filter, char **list, int *numfiles)
void *QDECL Sys_LoadDll (const char *name, char *fqpath, int(QDECL **entryPoint)(int,...), int(QDECL *systemcalls)(int,...))
qboolean Sys_LowPhysicalMemory ()
void Sys_Mkdir (const char *path)
void Sys_Net_Restart_f (void)
void Sys_Print (const char *msg)
void Sys_QueEvent (int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr)
void Sys_Quit (void)
qboolean Sys_ScanForCD (void)
void Sys_ShutdownStreamThread (void)
int Sys_StreamedRead (void *buffer, int size, int count, fileHandle_t f)
void Sys_StreamSeek (fileHandle_t f, int offset, int origin)
void Sys_UnloadDll (void *dllHandle)
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)

Variables

int countMsec
int eventHead
sysEvent_t eventQue [MAX_QUED_EVENTS]
int eventTail
int fh = 0
char sys_cmdline [MAX_STRING_CHARS]
byte sys_packetReceived [MAX_MSGLEN]
int totalMsec


Define Documentation

#define ALT_SPANK
 

Definition at line 47 of file win_main.c.

#define CD_BASEDIR   "quake3"
 

Definition at line 36 of file win_main.c.

Referenced by Sys_ScanForCD().

#define CD_BASEDIR_LINUX   "bin\\x86\\glibc-2.1"
 

Definition at line 38 of file win_main.c.

Referenced by Sys_ScanForCD().

#define CD_EXE   "quake3.exe"
 

Definition at line 37 of file win_main.c.

Referenced by Sys_ScanForCD().

#define CD_EXE_LINUX   "quake3"
 

Definition at line 39 of file win_main.c.

Referenced by Sys_ScanForCD().

#define MASK_QUED_EVENTS   ( MAX_QUED_EVENTS - 1 )
 

Definition at line 894 of file win_main.c.

#define MAX_FOUND_FILES   0x1000
 

Definition at line 217 of file win_main.c.

#define MAX_QUED_EVENTS   256
 

Definition at line 893 of file win_main.c.

#define MEM_THRESHOLD   96*1024*1024
 

Definition at line 40 of file win_main.c.

#define OSR2_BUILD_NUMBER   1111
 

Definition at line 1044 of file win_main.c.

#define WIN98_BUILD_NUMBER   1998
 

Definition at line 1045 of file win_main.c.


Function Documentation

char* FS_BuildOSPath const char *  base,
const char *  game,
const char *  qpath
 

Definition at line 467 of file files.c.

References Com_sprintf(), and FS_ReplaceSeparators().

Referenced by FS_AddGameDirectory(), FS_FileExists(), FS_FOpenFileAppend(), FS_FOpenFileRead(), FS_FOpenFileWrite(), FS_GetModList(), FS_ListFilteredFiles(), FS_Rename(), FS_SV_FileExists(), FS_SV_FOpenFileRead(), FS_SV_FOpenFileWrite(), FS_SV_Rename(), and Sys_LoadDll().

00467                                                                               {
00468     char    temp[MAX_OSPATH];
00469     static char ospath[2][MAX_OSPATH];
00470     static int toggle;
00471     
00472     toggle ^= 1;        // flip-flop to allow two returns without clash
00473 
00474     if( !game || !game[0] ) {
00475         game = fs_gamedir;
00476     }
00477 
00478     Com_sprintf( temp, sizeof(temp), "/%s/%s", game, qpath );
00479     FS_ReplaceSeparators( temp );   
00480     Com_sprintf( ospath[toggle], sizeof( ospath[0] ), "%s%s", base, temp );
00481     
00482     return ospath[toggle];
00483 }

Here is the call graph for this function:

void Spk_Close  ) 
 

Definition at line 59 of file win_main.c.

References close(), and fh.

00060 {
00061   if (!fh)
00062     return;
00063 
00064   close( fh );
00065   fh = 0;
00066 }

Here is the call graph for this function:

void Spk_Open char *  name  ) 
 

Definition at line 54 of file win_main.c.

References fh, name, and open().

00055 {
00056   fh = open( name, O_TRUNC | O_CREAT | O_WRONLY, S_IREAD | S_IWRITE );
00057 };

Here is the call graph for this function:

void Spk_Printf const char *  text,
  ...
 

Definition at line 68 of file win_main.c.

References fh, strlen(), va_end, va_list, va_start, vsprintf(), and write().

00069 {
00070   va_list argptr;
00071   char buf[32768];
00072 
00073   if (!fh)
00074     return;
00075 
00076   va_start (argptr,text);
00077   vsprintf (buf, text, argptr);
00078   write(fh, buf, strlen(buf));
00079   _commit(fh);
00080   va_end (argptr);
00081 
00082 };

Here is the call graph for this function:

qboolean strgtr const char *  s0,
const char *  s1
[static]
 

Definition at line 266 of file win_main.c.

References i, qboolean, and strlen().

Referenced by Sys_ListFiles().

00266                                                        {
00267     int l0, l1, i;
00268 
00269     l0 = strlen(s0);
00270     l1 = strlen(s1);
00271 
00272     if (l1<l0) {
00273         l0 = l1;
00274     }
00275 
00276     for(i=0;i<l0;i++) {
00277         if (s1[i] > s0[i]) {
00278             return qtrue;
00279         }
00280         if (s1[i] < s0[i]) {
00281             return qfalse;
00282         }
00283     }
00284     return qfalse;
00285 }

Here is the call graph for this function:

void Sys_BeginProfiling void   ) 
 

Definition at line 102 of file win_main.c.

00102                                 {
00103     // this is just used on the mac build
00104 }

void Sys_BeginStreamedFile fileHandle_t  f,
int  readAhead
 

Definition at line 638 of file win_main.c.

Referenced by CIN_PlayCinematic(), FS_FOpenFileByMode(), RoQReset(), and S_StartBackgroundTrack().

00638                                                             {
00639 }

qboolean Sys_CheckCD void   ) 
 

Definition at line 457 of file win_main.c.

References f_type, fprintf(), perror(), qboolean, stderr, strrchr(), Sys_IsCDROMDevice(), and Sys_SetDefaultCDPath().

00457                                 {
00458   // FIXME: mission pack
00459   return qtrue;
00460     //return Sys_ScanForCD();
00461 }

Here is the call graph for this function:

char* Sys_Cwd void   ) 
 

Definition at line 182 of file win_main.c.

References MAX_OSPATH.

Referenced by Sys_DefaultBasePath(), Sys_DefaultInstallPath(), and Sys_LoadDll().

00182                       {
00183     static char cwd[MAX_OSPATH];
00184 
00185     _getcwd( cwd, sizeof( cwd ) - 1 );
00186     cwd[MAX_OSPATH-1] = 0;
00187 
00188     return cwd;
00189 }

char* Sys_DefaultBasePath void   ) 
 

Definition at line 205 of file win_main.c.

References Sys_Cwd().

00205                                   {
00206     return Sys_Cwd();
00207 }

Here is the call graph for this function:

char* Sys_DefaultCDPath void   ) 
 

Definition at line 196 of file win_main.c.

Referenced by FS_Startup().

00196                                 {
00197     return "";
00198 }

void Sys_EndStreamedFile fileHandle_t  f  ) 
 

Definition at line 641 of file win_main.c.

Referenced by FS_FCloseFile(), RoQReset(), RoQShutdown(), S_StartBackgroundTrack(), S_StopBackgroundTrack(), and S_UpdateBackgroundTrack().

00641                                            {
00642 }

void QDECL Sys_Error const char *  error,
  ...
 

Definition at line 113 of file win_main.c.

References Com_Quit_f(), Conbuf_AppendText(), error(), exit(), IN_Shutdown(), NULL, QDECL, qtrue, Sys_DestroyConsole(), Sys_Quit(), Sys_SetErrorText(), Sys_ShowConsole(), Sys_Shutdown(), va_end, va_list, va_start, and vsprintf().

Referenced by Com_Error(), Com_Init(), Sys_DefaultHomePath(), Sys_DisplayToUse(), Sys_Init(), Sys_PreventMouseMovement(), Sys_ReenableMouseMovement(), Sys_ShowConsole(), and Sys_StoreGammaTables().

00113                                                {
00114     va_list     argptr;
00115     char        text[4096];
00116     MSG        msg;
00117 
00118     va_start (argptr, error);
00119     vsprintf (text, error, argptr);
00120     va_end (argptr);
00121 
00122     Conbuf_AppendText( text );
00123     Conbuf_AppendText( "\n" );
00124 
00125     Sys_SetErrorText( text );
00126     Sys_ShowConsole( 1, qtrue );
00127 
00128     timeEndPeriod( 1 );
00129 
00130     IN_Shutdown();
00131 
00132     // wait for the user to quit
00133     while ( 1 ) {
00134         if (!GetMessage (&msg, NULL, 0, 0))
00135             Com_Quit_f ();
00136         TranslateMessage (&msg);
00137         DispatchMessage (&msg);
00138     }
00139 
00140     Sys_DestroyConsole();
00141 
00142     exit (1);
00143 }

Here is the call graph for this function:

void Sys_FreeFileList char **  list  ) 
 

Definition at line 382 of file win_main.c.

References i, and Z_Free().

Referenced by FS_AddGameDirectory(), FS_GetModList(), and FS_ListFilteredFiles().

00382                                         {
00383     int     i;
00384 
00385     if ( !list ) {
00386         return;
00387     }
00388 
00389     for ( i = 0 ; list[i] ; i++ ) {
00390         Z_Free( list[i] );
00391     }
00392 
00393     Z_Free( list );
00394 }

Here is the call graph for this function:

char* Sys_GetClipboardData void   ) 
 

Definition at line 470 of file win_main.c.

References data, GetClipboardData(), NULL, Q_strncpyz(), strtok(), and Z_Malloc().

00470                                    {
00471     char *data = NULL;
00472     char *cliptext;
00473 
00474     if ( OpenClipboard( NULL ) != 0 ) {
00475         HANDLE hClipboardData;
00476 
00477         if ( ( hClipboardData = GetClipboardData( CF_TEXT ) ) != 0 ) {
00478             if ( ( cliptext = GlobalLock( hClipboardData ) ) != 0 ) {
00479                 data = Z_Malloc( GlobalSize( hClipboardData ) + 1 );
00480                 Q_strncpyz( data, cliptext, GlobalSize( hClipboardData ) );
00481                 GlobalUnlock( hClipboardData );
00482                 
00483                 strtok( data, "\n\r\b" );
00484             }
00485         }
00486         CloseClipboard();
00487     }
00488     return data;
00489 }

Here is the call graph for this function:

sysEvent_t Sys_GetEvent void   ) 
 

Definition at line 942 of file win_main.c.

References b, com_dedicated, Com_Quit_f(), msg_t::cursize, msg_t::data, eventHead, eventQue, eventTail, sysEvent_t::evTime, g_wv, in_nomouse, cvar_s::integer, memcpy(), memset(), mouseactive, MSG_Init(), NULL, Q_strncpyz(), msg_t::readcount, s, SE_CONSOLE, SE_PACKET, strcpy(), strlen(), Sys_ConsoleInput(), Sys_GetPacket(), Sys_Milliseconds(), sys_packetReceived, Sys_QueEvent(), Sys_SendKeyEvents(), Sys_StartMouseInput(), Sys_StopMouseInput(), WinVars_t::sysMsgTime, and Z_Malloc().

00942                                 {
00943     MSG         msg;
00944     sysEvent_t  ev;
00945     char        *s;
00946     msg_t       netmsg;
00947     netadr_t    adr;
00948 
00949     // return if we have data
00950     if ( eventHead > eventTail ) {
00951         eventTail++;
00952         return eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ];
00953     }
00954 
00955     // pump the message loop
00956     while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) {
00957         if ( !GetMessage (&msg, NULL, 0, 0) ) {
00958             Com_Quit_f();
00959         }
00960 
00961         // save the msg time, because wndprocs don't have access to the timestamp
00962         g_wv.sysMsgTime = msg.time;
00963 
00964         TranslateMessage (&msg);
00965         DispatchMessage (&msg);
00966     }
00967 
00968     // check for console commands
00969     s = Sys_ConsoleInput();
00970     if ( s ) {
00971         char    *b;
00972         int     len;
00973 
00974         len = strlen( s ) + 1;
00975         b = Z_Malloc( len );
00976         Q_strncpyz( b, s, len-1 );
00977         Sys_QueEvent( 0, SE_CONSOLE, 0, 0, len, b );
00978     }
00979 
00980     // check for network packets
00981     MSG_Init( &netmsg, sys_packetReceived, sizeof( sys_packetReceived ) );
00982     if ( Sys_GetPacket ( &adr, &netmsg ) ) {
00983         netadr_t        *buf;
00984         int             len;
00985 
00986         // copy out to a seperate buffer for qeueing
00987         // the readcount stepahead is for SOCKS support
00988         len = sizeof( netadr_t ) + netmsg.cursize - netmsg.readcount;
00989         buf = Z_Malloc( len );
00990         *buf = adr;
00991         memcpy( buf+1, &netmsg.data[netmsg.readcount], netmsg.cursize - netmsg.readcount );
00992         Sys_QueEvent( 0, SE_PACKET, 0, 0, len, buf );
00993     }
00994 
00995     // return if we have data
00996     if ( eventHead > eventTail ) {
00997         eventTail++;
00998         return eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ];
00999     }
01000 
01001     // create an empty event to return
01002 
01003     memset( &ev, 0, sizeof( ev ) );
01004     ev.evTime = timeGetTime();
01005 
01006     return ev;
01007 }

Here is the call graph for this function:

void Sys_In_Restart_f void   ) 
 

Definition at line 1018 of file win_main.c.

References IN_Init(), and IN_Shutdown().

01018                               {
01019     IN_Shutdown();
01020     IN_Init();
01021 }

Here is the call graph for this function:

void Sys_Init void   ) 
 

Definition at line 1047 of file win_main.c.

References Cmd_AddCommand(), Com_Error(), Com_Printf(), CPUID_AMD_3DNOW, CPUID_AXP, CPUID_GENERIC, CPUID_INTEL_KATMAI, CPUID_INTEL_MMX, CPUID_INTEL_PENTIUM, CPUID_INTEL_UNSUPPORTED, Cvar_Get(), CVAR_ROM, Cvar_Set(), Cvar_SetValue(), Cvar_VariableString(), ERR_FATAL, g_wv, WinVars_t::hInstance, IN_Init(), MainWndProc(), NET_Init(), WinVars_t::osversion, Q_stricmp(), Sys_Error(), Sys_GetCurrentUser(), Sys_GetProcessorId(), Sys_In_Restart_f(), Sys_InitInput(), Sys_Net_Restart_f(), and va().

01047                       {
01048     int cpuid;
01049 
01050     // make sure the timer is high precision, otherwise
01051     // NT gets 18ms resolution
01052     timeBeginPeriod( 1 );
01053 
01054     Cmd_AddCommand ("in_restart", Sys_In_Restart_f);
01055     Cmd_AddCommand ("net_restart", Sys_Net_Restart_f);
01056 
01057     g_wv.osversion.dwOSVersionInfoSize = sizeof( g_wv.osversion );
01058 
01059     if (!GetVersionEx (&g_wv.osversion))
01060         Sys_Error ("Couldn't get OS info");
01061 
01062     if (g_wv.osversion.dwMajorVersion < 4)
01063         Sys_Error ("Quake3 requires Windows version 4 or greater");
01064     if (g_wv.osversion.dwPlatformId == VER_PLATFORM_WIN32s)
01065         Sys_Error ("Quake3 doesn't run on Win32s");
01066 
01067     if ( g_wv.osversion.dwPlatformId == VER_PLATFORM_WIN32_NT )
01068     {
01069         Cvar_Set( "arch", "winnt" );
01070     }
01071     else if ( g_wv.osversion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
01072     {
01073         if ( LOWORD( g_wv.osversion.dwBuildNumber ) >= WIN98_BUILD_NUMBER )
01074         {
01075             Cvar_Set( "arch", "win98" );
01076         }
01077         else if ( LOWORD( g_wv.osversion.dwBuildNumber ) >= OSR2_BUILD_NUMBER )
01078         {
01079             Cvar_Set( "arch", "win95 osr2.x" );
01080         }
01081         else
01082         {
01083             Cvar_Set( "arch", "win95" );
01084         }
01085     }
01086     else
01087     {
01088         Cvar_Set( "arch", "unknown Windows variant" );
01089     }
01090 
01091     // save out a couple things in rom cvars for the renderer to access
01092     Cvar_Get( "win_hinstance", va("%i", (int)g_wv.hInstance), CVAR_ROM );
01093     Cvar_Get( "win_wndproc", va("%i", (int)MainWndProc), CVAR_ROM );
01094 
01095     //
01096     // figure out our CPU
01097     //
01098     Cvar_Get( "sys_cpustring", "detect", 0 );
01099     if ( !Q_stricmp( Cvar_VariableString( "sys_cpustring"), "detect" ) )
01100     {
01101         Com_Printf( "...detecting CPU, found " );
01102 
01103         cpuid = Sys_GetProcessorId();
01104 
01105         switch ( cpuid )
01106         {
01107         case CPUID_GENERIC:
01108             Cvar_Set( "sys_cpustring", "generic" );
01109             break;
01110         case CPUID_INTEL_UNSUPPORTED:
01111             Cvar_Set( "sys_cpustring", "x86 (pre-Pentium)" );
01112             break;
01113         case CPUID_INTEL_PENTIUM:
01114             Cvar_Set( "sys_cpustring", "x86 (P5/PPro, non-MMX)" );
01115             break;
01116         case CPUID_INTEL_MMX:
01117             Cvar_Set( "sys_cpustring", "x86 (P5/Pentium2, MMX)" );
01118             break;
01119         case CPUID_INTEL_KATMAI:
01120             Cvar_Set( "sys_cpustring", "Intel Pentium III" );
01121             break;
01122         case CPUID_AMD_3DNOW:
01123             Cvar_Set( "sys_cpustring", "AMD w/ 3DNow!" );
01124             break;
01125         case CPUID_AXP:
01126             Cvar_Set( "sys_cpustring", "Alpha AXP" );
01127             break;
01128         default:
01129             Com_Error( ERR_FATAL, "Unknown cpu type %d\n", cpuid );
01130             break;
01131         }
01132     }
01133     else
01134     {
01135         Com_Printf( "...forcing CPU type to " );
01136         if ( !Q_stricmp( Cvar_VariableString( "sys_cpustring" ), "generic" ) )
01137         {
01138             cpuid = CPUID_GENERIC;
01139         }
01140         else if ( !Q_stricmp( Cvar_VariableString( "sys_cpustring" ), "x87" ) )
01141         {
01142             cpuid = CPUID_INTEL_PENTIUM;
01143         }
01144         else if ( !Q_stricmp( Cvar_VariableString( "sys_cpustring" ), "mmx" ) )
01145         {
01146             cpuid = CPUID_INTEL_MMX;
01147         }
01148         else if ( !Q_stricmp( Cvar_VariableString( "sys_cpustring" ), "3dnow" ) )
01149         {
01150             cpuid = CPUID_AMD_3DNOW;
01151         }
01152         else if ( !Q_stricmp( Cvar_VariableString( "sys_cpustring" ), "PentiumIII" ) )
01153         {
01154             cpuid = CPUID_INTEL_KATMAI;
01155         }
01156         else if ( !Q_stricmp( Cvar_VariableString( "sys_cpustring" ), "axp" ) )
01157         {
01158             cpuid = CPUID_AXP;
01159         }
01160         else
01161         {
01162             Com_Printf( "WARNING: unknown sys_cpustring '%s'\n", Cvar_VariableString( "sys_cpustring" ) );
01163             cpuid = CPUID_GENERIC;
01164         }
01165     }
01166     Cvar_SetValue( "sys_cpuid", cpuid );
01167     Com_Printf( "%s\n", Cvar_VariableString( "sys_cpustring" ) );
01168 
01169     Cvar_Set( "username", Sys_GetCurrentUser() );
01170 
01171     IN_Init();      // FIXME: not in dedicated?
01172 }

Here is the call graph for this function:

void Sys_InitStreamThread void   ) 
 

Definition at line 632 of file win_main.c.

00632                                   {
00633 }

char** Sys_ListFiles const char *  directory,
const char *  extension,
char *  filter,
int *  numfiles,
qboolean  wantsubs
 

Definition at line 287 of file win_main.c.

References Com_sprintf(), CopyString(), i, MAX_FOUND_FILES, strgtr(), Sys_ListFilteredFiles(), and Z_Malloc().

Referenced by FS_AddGameDirectory(), FS_GetModList(), and FS_ListFilteredFiles().

00287                                                                                                                      {
00288     char        search[MAX_OSPATH];
00289     int         nfiles;
00290     char        **listCopy;
00291     char        *list[MAX_FOUND_FILES];
00292     struct _finddata_t findinfo;
00293     int         findhandle;
00294     int         flag;
00295     int         i;
00296 
00297     if (filter) {
00298 
00299         nfiles = 0;
00300         Sys_ListFilteredFiles( directory, "", filter, list, &nfiles );
00301 
00302         list[ nfiles ] = 0;
00303         *numfiles = nfiles;
00304 
00305         if (!nfiles)
00306             return NULL;
00307 
00308         listCopy = Z_Malloc( ( nfiles + 1 ) * sizeof( *listCopy ) );
00309         for ( i = 0 ; i < nfiles ; i++ ) {
00310             listCopy[i] = list[i];
00311         }
00312         listCopy[i] = NULL;
00313 
00314         return listCopy;
00315     }
00316 
00317     if ( !extension) {
00318         extension = "";
00319     }
00320 
00321     // passing a slash as extension will find directories
00322     if ( extension[0] == '/' && extension[1] == 0 ) {
00323         extension = "";
00324         flag = 0;
00325     } else {
00326         flag = _A_SUBDIR;
00327     }
00328 
00329     Com_sprintf( search, sizeof(search), "%s\\*%s", directory, extension );
00330 
00331     // search
00332     nfiles = 0;
00333 
00334     findhandle = _findfirst (search, &findinfo);
00335     if (findhandle == -1) {
00336         *numfiles = 0;
00337         return NULL;
00338     }
00339 
00340     do {
00341         if ( (!wantsubs && flag ^ ( findinfo.attrib & _A_SUBDIR )) || (wantsubs && findinfo.attrib & _A_SUBDIR) ) {
00342             if ( nfiles == MAX_FOUND_FILES - 1 ) {
00343                 break;
00344             }
00345             list[ nfiles ] = CopyString( findinfo.name );
00346             nfiles++;
00347         }
00348     } while ( _findnext (findhandle, &findinfo) != -1 );
00349 
00350     list[ nfiles ] = 0;
00351 
00352     _findclose (findhandle);
00353 
00354     // return a copy of the list
00355     *numfiles = nfiles;
00356 
00357     if ( !nfiles ) {
00358         return NULL;
00359     }
00360 
00361     listCopy = Z_Malloc( ( nfiles + 1 ) * sizeof( *listCopy ) );
00362     for ( i = 0 ; i < nfiles ; i++ ) {
00363         listCopy[i] = list[i];
00364     }
00365     listCopy[i] = NULL;
00366 
00367     do {
00368         flag = 0;
00369         for(i=1; i<nfiles; i++) {
00370             if (strgtr(listCopy[i-1], listCopy[i])) {
00371                 char *temp = listCopy[i];
00372                 listCopy[i] = listCopy[i-1];
00373                 listCopy[i-1] = temp;
00374                 flag = 1;
00375             }
00376         }
00377     } while(flag);
00378 
00379     return listCopy;
00380 }

Here is the call graph for this function:

void Sys_ListFilteredFiles const char *  basedir,
char *  subdirs,
char *  filter,
char **  list,
int *  numfiles
 

Definition at line 219 of file win_main.c.

References Com_FilterPath(), Com_sprintf(), CopyString(), MAX_FOUND_FILES, Q_stricmp(), qfalse, and strlen().

Referenced by Sys_ListFiles(), and Sys_ListFilteredFiles().

00219                                                                                                            {
00220     char        search[MAX_OSPATH], newsubdirs[MAX_OSPATH];
00221     char        filename[MAX_OSPATH];
00222     int         findhandle;
00223     struct _finddata_t findinfo;
00224 
00225     if ( *numfiles >= MAX_FOUND_FILES - 1 ) {
00226         return;
00227     }
00228 
00229     if (strlen(subdirs)) {
00230         Com_sprintf( search, sizeof(search), "%s\\%s\\*", basedir, subdirs );
00231     }
00232     else {
00233         Com_sprintf( search, sizeof(search), "%s\\*", basedir );
00234     }
00235 
00236     findhandle = _findfirst (search, &findinfo);
00237     if (findhandle == -1) {
00238         return;
00239     }
00240 
00241     do {
00242         if (findinfo.attrib & _A_SUBDIR) {
00243             if (Q_stricmp(findinfo.name, ".") && Q_stricmp(findinfo.name, "..")) {
00244                 if (strlen(subdirs)) {
00245                     Com_sprintf( newsubdirs, sizeof(newsubdirs), "%s\\%s", subdirs, findinfo.name);
00246                 }
00247                 else {
00248                     Com_sprintf( newsubdirs, sizeof(newsubdirs), "%s", findinfo.name);
00249                 }
00250                 Sys_ListFilteredFiles( basedir, newsubdirs, filter, list, numfiles );
00251             }
00252         }
00253         if ( *numfiles >= MAX_FOUND_FILES - 1 ) {
00254             break;
00255         }
00256         Com_sprintf( filename, sizeof(filename), "%s\\%s", subdirs, findinfo.name );
00257         if (!Com_FilterPath( filter, filename, qfalse ))
00258             continue;
00259         list[ *numfiles ] = CopyString( filename );
00260         (*numfiles)++;
00261     } while ( _findnext (findhandle, &findinfo) != -1 );
00262 
00263     _findclose (findhandle);
00264 }

Here is the call graph for this function:

void* QDECL Sys_LoadDll const char *  name,
char *  fqpath,
int(QDECL **entryPoint)(int,...)  ,
int(QDECL *systemcalls)(int,...) 
 

Definition at line 529 of file win_main.c.

References basepath(), Com_Printf(), Com_sprintf(), Cvar_VariableIntegerValue(), Cvar_VariableString(), dllEntry(), FS_BuildOSPath(), FS_FileExists(), gamedir, int(), MAX_QPATH, name, NULL, Q_strncpyz(), QDECL, Sys_Milliseconds(), and void().

Referenced by VM_Create().

00530                                                        {
00531     static int  lastWarning = 0;
00532     HINSTANCE   libHandle;
00533     void    (QDECL *dllEntry)( int (QDECL *syscallptr)(int, ...) );
00534     char    *basepath;
00535     char    *cdpath;
00536     char    *gamedir;
00537     char    *fn;
00538 #ifdef NDEBUG
00539     int     timestamp;
00540   int   ret;
00541 #endif
00542     char    filename[MAX_QPATH];
00543 
00544     *fqpath = 0 ;       // added 7/20/02 by T.Ray
00545 
00546     Com_sprintf( filename, sizeof( filename ), "%sx86.dll", name );
00547 
00548 #ifdef NDEBUG
00549     timestamp = Sys_Milliseconds();
00550     if( ((timestamp - lastWarning) > (5 * 60000)) && !Cvar_VariableIntegerValue( "dedicated" )
00551         && !Cvar_VariableIntegerValue( "com_blindlyLoadDLLs" ) ) {
00552         if (FS_FileExists(filename)) {
00553             lastWarning = timestamp;
00554             ret = MessageBoxEx( NULL, "You are about to load a .DLL executable that\n"
00555                   "has not been verified for use with Quake III Arena.\n"
00556                   "This type of file can compromise the security of\n"
00557                   "your computer.\n\n"
00558                   "Select 'OK' if you choose to load it anyway.",
00559                   "Security Warning", MB_OKCANCEL | MB_ICONEXCLAMATION | MB_DEFBUTTON2 | MB_TOPMOST | MB_SETFOREGROUND,
00560                   MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ) );
00561             if( ret != IDOK ) {
00562                 return NULL;
00563             }
00564         }
00565     }
00566 #endif
00567 
00568 #ifndef NDEBUG
00569     libHandle = LoadLibrary( filename );
00570   if (libHandle)
00571     Com_Printf("LoadLibrary '%s' ok\n", filename);
00572   else
00573     Com_Printf("LoadLibrary '%s' failed\n", filename);
00574     if ( !libHandle ) {
00575 #endif
00576     basepath = Cvar_VariableString( "fs_basepath" );
00577     cdpath = Cvar_VariableString( "fs_cdpath" );
00578     gamedir = Cvar_VariableString( "fs_game" );
00579 
00580     fn = FS_BuildOSPath( basepath, gamedir, filename );
00581     libHandle = LoadLibrary( fn );
00582 #ifndef NDEBUG
00583   if (libHandle)
00584     Com_Printf("LoadLibrary '%s' ok\n", fn);
00585   else
00586     Com_Printf("LoadLibrary '%s' failed\n", fn);
00587 #endif
00588 
00589     if ( !libHandle ) {
00590         if( cdpath[0] ) {
00591             fn = FS_BuildOSPath( cdpath, gamedir, filename );
00592             libHandle = LoadLibrary( fn );
00593 #ifndef NDEBUG
00594       if (libHandle)
00595         Com_Printf("LoadLibrary '%s' ok\n", fn);
00596       else
00597         Com_Printf("LoadLibrary '%s' failed\n", fn);
00598 #endif
00599         }
00600 
00601         if ( !libHandle ) {
00602             return NULL;
00603         }
00604     }
00605 #ifndef NDEBUG
00606     }
00607 #endif
00608 
00609     dllEntry = ( void (QDECL *)( int (QDECL *)( int, ... ) ) )GetProcAddress( libHandle, "dllEntry" ); 
00610     *entryPoint = (int (QDECL *)(int,...))GetProcAddress( libHandle, "vmMain" );
00611     if ( !*entryPoint || !dllEntry ) {
00612         FreeLibrary( libHandle );
00613         return NULL;
00614     }
00615     dllEntry( systemcalls );
00616 
00617     if ( libHandle ) Q_strncpyz ( fqpath , filename , MAX_QPATH ) ;     // added 7/20/02 by T.Ray
00618     return libHandle;
00619 }

Here is the call graph for this function:

qboolean Sys_LowPhysicalMemory  ) 
 

Definition at line 91 of file win_main.c.

References qboolean, and qtrue.

00091                                  {
00092     MEMORYSTATUS stat;
00093   GlobalMemoryStatus (&stat);
00094     return (stat.dwTotalPhys <= MEM_THRESHOLD) ? qtrue : qfalse;
00095 }

void Sys_Mkdir const char *  path  ) 
 

Definition at line 173 of file win_main.c.

Referenced by FS_CreatePath().

00173                                    {
00174     _mkdir (path);
00175 }

void Sys_Net_Restart_f void   ) 
 

Definition at line 1031 of file win_main.c.

References NET_Restart().

Referenced by Sys_Init().

01031                                {
01032     NET_Restart();
01033 }

Here is the call graph for this function:

void Sys_Print const char *  msg  ) 
 

Definition at line 163 of file win_main.c.

References ansiColors, ColorIndex, Conbuf_AppendText(), fputs(), fwrite(), Q_IsColorString, and stdout.

Referenced by Com_Printf(), and InputLineWndProc().

00163                                   {
00164     Conbuf_AppendText( msg );
00165 }

Here is the call graph for this function: