mirror of
https://github.com/ReactionQuake3/reaction.git
synced 2024-11-23 04:32:28 +00:00
IOQ3 commit 1921
This commit is contained in:
parent
1fc197a557
commit
df219f819b
5 changed files with 118 additions and 0 deletions
|
@ -50,6 +50,7 @@ jmp_buf abortframe; // an ERR_DROP occured, exit the entire frame
|
|||
|
||||
|
||||
FILE *debuglogfile;
|
||||
static fileHandle_t pipefile;
|
||||
static fileHandle_t logfile;
|
||||
fileHandle_t com_journalFile; // events are written here
|
||||
fileHandle_t com_journalDataFile; // config files are written here
|
||||
|
@ -66,6 +67,7 @@ cvar_t *com_timedemo;
|
|||
cvar_t *com_sv_running;
|
||||
cvar_t *com_cl_running;
|
||||
cvar_t *com_logfile; // 1 = buffer log, 2 = flush after each print
|
||||
cvar_t *com_pipefile;
|
||||
cvar_t *com_showtrace;
|
||||
cvar_t *com_version;
|
||||
cvar_t *com_blood;
|
||||
|
@ -2768,9 +2770,36 @@ void Com_Init( char *commandLine ) {
|
|||
Com_Printf ("Altivec support is %s\n", com_altivec->integer ? "enabled" : "disabled");
|
||||
#endif
|
||||
|
||||
com_pipefile = Cvar_Get( "com_pipefile", "", CVAR_ARCHIVE|CVAR_LATCH );
|
||||
if( com_pipefile->string[0] )
|
||||
{
|
||||
pipefile = FS_FCreateOpenPipeFile( com_pipefile->string );
|
||||
}
|
||||
|
||||
Com_Printf ("--- Common Initialization Complete ---\n");
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
Com_ReadFromPipe
|
||||
|
||||
Read whatever is in com_pipefile, if anything, and execute it
|
||||
===============
|
||||
*/
|
||||
void Com_ReadFromPipe( void )
|
||||
{
|
||||
char buffer[MAX_STRING_CHARS] = {""};
|
||||
qboolean read;
|
||||
|
||||
if( !pipefile )
|
||||
return;
|
||||
|
||||
read = FS_Read( buffer, sizeof( buffer ), pipefile );
|
||||
if( read )
|
||||
Cbuf_ExecuteText( EXEC_APPEND, buffer );
|
||||
}
|
||||
|
||||
|
||||
//==================================================================
|
||||
|
||||
void Com_WriteConfigToFile( const char *filename ) {
|
||||
|
@ -3097,6 +3126,8 @@ void Com_Frame( void ) {
|
|||
c_pointcontents = 0;
|
||||
}
|
||||
|
||||
Com_ReadFromPipe( );
|
||||
|
||||
com_frameNumber++;
|
||||
}
|
||||
|
||||
|
@ -3116,6 +3147,11 @@ void Com_Shutdown (void) {
|
|||
com_journalFile = 0;
|
||||
}
|
||||
|
||||
if( pipefile ) {
|
||||
FS_FCloseFile( pipefile );
|
||||
FS_HomeRemove( com_pipefile->string );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
|
|
@ -905,6 +905,50 @@ fileHandle_t FS_FOpenFileAppend( const char *filename ) {
|
|||
return f;
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
FS_FCreateOpenPipeFile
|
||||
|
||||
===========
|
||||
*/
|
||||
fileHandle_t FS_FCreateOpenPipeFile( const char *filename ) {
|
||||
char *ospath;
|
||||
FILE *fifo;
|
||||
fileHandle_t f;
|
||||
|
||||
if ( !fs_searchpaths ) {
|
||||
Com_Error( ERR_FATAL, "Filesystem call made without initialization\n" );
|
||||
}
|
||||
|
||||
f = FS_HandleForFile();
|
||||
fsh[f].zipFile = qfalse;
|
||||
|
||||
Q_strncpyz( fsh[f].name, filename, sizeof( fsh[f].name ) );
|
||||
|
||||
// don't let sound stutter
|
||||
S_ClearSoundBuffer();
|
||||
|
||||
ospath = FS_BuildOSPath( fs_homepath->string, fs_gamedir, filename );
|
||||
|
||||
if ( fs_debug->integer ) {
|
||||
Com_Printf( "FS_FCreateOpenPipeFile: %s\n", ospath );
|
||||
}
|
||||
|
||||
FS_CheckFilenameIsNotExecutable( ospath, __func__ );
|
||||
|
||||
fifo = Sys_Mkfifo( ospath );
|
||||
if( fifo ) {
|
||||
fsh[f].handleFiles.file.o = fifo;
|
||||
fsh[f].handleSync = qfalse;
|
||||
}
|
||||
else
|
||||
{
|
||||
f = 0;
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
FS_FilenameCompare
|
||||
|
|
|
@ -626,6 +626,7 @@ int FS_GetModList( char *listbuf, int bufsize );
|
|||
|
||||
fileHandle_t FS_FOpenFileWrite( const char *qpath );
|
||||
fileHandle_t FS_FOpenFileAppend( const char *filename );
|
||||
fileHandle_t FS_FCreateOpenPipeFile( const char *filename );
|
||||
// will properly create any needed paths and deal with seperater character issues
|
||||
|
||||
fileHandle_t FS_SV_FOpenFileWrite( const char *filename );
|
||||
|
@ -1094,6 +1095,7 @@ qboolean Sys_IsLANAddress (netadr_t adr);
|
|||
void Sys_ShowIP(void);
|
||||
|
||||
qboolean Sys_Mkdir( const char *path );
|
||||
FILE *Sys_Mkfifo( const char *ospath );
|
||||
char *Sys_Cwd( void );
|
||||
void Sys_SetDefaultInstallPath(const char *path);
|
||||
char *Sys_DefaultInstallPath(void);
|
||||
|
|
|
@ -247,6 +247,31 @@ qboolean Sys_Mkdir( const char *path )
|
|||
return qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Sys_Mkfifo
|
||||
==================
|
||||
*/
|
||||
FILE *Sys_Mkfifo( const char *ospath )
|
||||
{
|
||||
FILE *fifo;
|
||||
int result;
|
||||
int fn;
|
||||
|
||||
result = mkfifo( ospath, 0600 );
|
||||
if( result != 0 )
|
||||
return NULL;
|
||||
|
||||
fifo = fopen( ospath, "w+" );
|
||||
if( fifo )
|
||||
{
|
||||
fn = fileno( fifo );
|
||||
fcntl( fn, F_SETFL, O_NONBLOCK );
|
||||
}
|
||||
|
||||
return fifo;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Sys_Cwd
|
||||
|
|
|
@ -320,6 +320,17 @@ qboolean Sys_Mkdir( const char *path )
|
|||
return qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Sys_Mkfifo
|
||||
Noop on windows because named pipes do not function the same way
|
||||
==================
|
||||
*/
|
||||
FILE *Sys_Mkfifo( const char *ospath )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
Sys_Cwd
|
||||
|
|
Loading…
Reference in a new issue