How can I temporarily redirect printf output to a c-string?

Posted by Ben S on Stack Overflow See other posts from Stack Overflow or by Ben S
Published on 2010-04-01T18:34:19Z Indexed on 2010/04/01 18:53 UTC
Read the original article Hit count: 308

Filed under:
|
|
|
|

I'm writing an assignment which involves adding some functionality to PostgreSQL on a Solaris box. As part of the assignment, we need to print some information on the client side (i.e.: using elog.)

PostgreSQL already has lots of helper methods which print out the required information, however, the helper methods are packed with hundreds of printf calls, and the elog method only works with c-style strings.

Is there I way that I could temporarily redirect printf calls to a buffer so I could easily send it over elog to the client?

If that's not possible, what would be the simplest way to modify the helper methods to end up with a buffer as output?

© Stack Overflow or respective owner

Related posts about c

    Related posts about printf