(#4925) - com_pipefile to create a named pipe for sending commands from other processes, patch by Chris Schwarz
This commit is contained in:
parent
a3def2744f
commit
3bf8ec2dab
6 changed files with 122 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 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue