From: H.G. Muller Date: Wed, 22 Feb 2012 17:27:40 +0000 (+0100) Subject: Implement -serverFile option X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=d628e1610653266459dfec9aad86aa6615ea886a;p=xboard.git Implement -serverFile option This writs an extra debug file with only engine communiation on it, for the benifit of programs like TLCS. --- diff --git a/args.h b/args.h index 9c746f6..613f0a4 100644 --- a/args.h +++ b/args.h @@ -699,6 +699,7 @@ ArgDescriptor argDescriptors[] = { /* [HGM] options for broadcasting and time odds */ { "chatBoxes", ArgString, (void *) &appData.chatBoxes, !XBOARD, (ArgIniType) NULL }, { "serverMoves", ArgString, (void *) &appData.serverMovesName, FALSE, (ArgIniType) NULL }, + { "serverFile", ArgString, (void *) &appData.serverFileName, FALSE, (ArgIniType) NULL }, { "suppressLoadMoves", ArgBoolean, (void *) &appData.suppressLoadMoves, FALSE, (ArgIniType) FALSE }, { "serverPause", ArgInt, (void *) &appData.serverPause, FALSE, (ArgIniType) 15 }, { "firstTimeOdds", ArgInt, (void *) &appData.firstTimeOdds, FALSE, (ArgIniType) 1 }, diff --git a/backend.c b/backend.c index 06c3145..59103ed 100644 --- a/backend.c +++ b/backend.c @@ -392,7 +392,7 @@ PosFlags (index) return flags; } -FILE *gameFileFP, *debugFP; +FILE *gameFileFP, *debugFP, *serverFP; char *currentDebugFile; // [HGM] debug split: to remember name /* @@ -10083,6 +10083,12 @@ NextMatchGame () fclose(debugFP); debugFP = f; } + if(appData.serverFileName) { + if(serverFP) fclose(serverFP); + serverFP = fopen(appData.serverFileName, "w"); + if(serverFP && first.pr != NoProc) fprintf(serverFP, "StartChildProcess (dir=\".\") .\\%s\n", first.tidy); + if(serverFP && second.pr != NoProc) fprintf(serverFP, "StartChildProcess (dir=\".\") .\\%s\n", second.tidy); + } } } firstWhite = appData.firstPlaysBlack ^ (matchGame & 1 | appData.sameColorGames > 1); // non-incremental default @@ -15023,6 +15029,10 @@ SendToProgram (char *message, ChessProgramState *cps) fprintf(debugFP, "%ld >%-6s: %s", SubtractTimeMarks(&now, &programStartTime), cps->which, message); + if(serverFP) + fprintf(serverFP, "%ld >%-6s: %s", + SubtractTimeMarks(&now, &programStartTime), + cps->which, message), fflush(serverFP); } count = strlen(message); @@ -15124,6 +15134,11 @@ ReceiveFromProgram (InputSourceRef isr, VOIDSTAR closure, char *message, int cou SubtractTimeMarks(&now, &programStartTime), cps->which, quote, message); + if(serverFP) + fprintf(serverFP, "%ld <%-6s: %s%s\n", + SubtractTimeMarks(&now, &programStartTime), cps->which, + quote, + message), fflush(serverFP); } } diff --git a/common.h b/common.h index 9e1c3dd..b433e68 100644 --- a/common.h +++ b/common.h @@ -623,6 +623,7 @@ typedef struct { Boolean lowTimeWarning; /* [HGM] low time */ char *lowTimeWarningColor; + char *serverFileName; char *serverMovesName; Boolean suppressLoadMoves; int serverPause;