How to integrate an open source C program instead of calling its executable through a system call?

Posted by ihamer on Stack Overflow See other posts from Stack Overflow or by ihamer
Published on 2010-12-25T18:31:01Z Indexed on 2010/12/25 18:54 UTC
Read the original article Hit count: 211

Filed under:
|
|
|

I have an executable (fossil scm) that is being invoked by my program externally through ::CreateProcess windows call. The stdout and stderr are then captured. Since the source code for fossil is available, I would prefer to create a static library out of it and issue calls directly. Currently, communication to fossil is done through the command line parameters, and the communication back is through the process return code, stdout and stderr. Fossil writes to stdout/err through printf and fprintf calls.

What is the best way to solve this with minimum alteration of fossil source? Is there a reliable and cross-platform way to intercept stdout/err and send it into a memory buffer?

© Stack Overflow or respective owner

Related posts about c++

Related posts about c