From: H.G.Muller Date: Fri, 27 Nov 2015 20:01:22 +0000 (+0100) Subject: Allow debug output to go to child process (WB) X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=f782a1290bdcdaa972d7a7e0d059908d9eee04e2 Allow debug output to go to child process (WB) A -debugfile name starting with tree slashes will not be interpreted as a file to write on, but (after stripping the slashes) as an executable to run, and send the output to. This could be used by an external broadcasting agaent. --- diff --git a/winboard/winboard.c b/winboard/winboard.c index 5b57ba3..ba6933f 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -1106,6 +1106,8 @@ InitGeometry() screenGeometry.bottom = screenGeometry.top + screenHeight; } +ChessProgramState broadcast; + BOOL InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) { @@ -1138,7 +1140,18 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) appData.ringBellAfterMoves = TRUE; } if (appData.debugMode) { - debugFP = fopen(appData.nameOfDebugFile, "w"); + char *c = appData.nameOfDebugFile; + if(strstr(c, "///") == c) { + broadcast.which = "broadcaster"; + broadcast.pr = NoProc; + broadcast.isr = NULL; + broadcast.prog = c + 3; + broadcast.dir = "."; + broadcast.host = "localhost"; + StartChessProgram(&broadcast); + debugFP = (FILE*) _fdopen(_open_osfhandle((long)(((ChildProc*)(broadcast.pr))->hTo), _O_WRONLY), "w"); + } else + debugFP = fopen(c, "w"); setbuf(debugFP, NULL); }