I am in need to write a program that will interact with another program, the project is to analyze chess games using a chess engine. I do not have to write the chess engine.
If I were to do it manually this is what would happen in console
// Start the engine
$ chess-engine
// Engine reports its name
> Hello I am the chess engine
// Tell the engine in which mode to run. At this point it is like
// an FTP client
> uci
I don't know the solution. I'm just bumping the thread.
I do have one idea though (using WinAPI). CreateProcess function accepts (through STARTUPINFO structure) HANDLEs to stdin, stdout and stderr streams that the process will use. If there was a way to create temporary streams and pass their HANDLEs to CreateProcess, you could use them to communicate as if you were using the command line. I don't know how to do that though. Maybe creating a couple of files could work. Although it's a bit ugly.
Crete two half-duplex UNIX pipes with pipe(), fork(), dup2(), exec() -
one for stdout of your program => stdin of engine
and another for stdout of engine => stdin of your program.