Re: Any way to capture stdcout output to memory?



In article <raDSj.3$xb2.2@xxxxxxxxxxxx>,
Jim Langston <tazmaster@xxxxxxxxxxxxxx> wrote:
....
".. modify your source..."

If I was able to modify the source I'd have it write to a memory buffer in
the first place. The problem is the actual output is being produced deep
inside a library call. This right now is not an option, although I may have
to make it an option if I can't find a good way to do it. I think one of
the methods of redirecting stdout will work, although it looks like I'll
have to use a thread which I don't like but *shrug*

I, too, have hit this issue. First comment: You (Jim) have made it
clear that the platforms is Windows, not Unix, right? I think some of
the posters are assuming Unix. Unix would simplify things, since these
sorts of things are always easier there. Things like dup(), etc,
although often implemented in Windows, often don't work quite the same
under Windows as under Unix.

On Windows, I was able to solve the problem (very OT for clc, of course)
by diddling with the elements of the the FILE structure. The basic
trick is that you set the buffersize very high, so that it _never_ gets
written out. Then, your main program extracts the information out of
the stdout buffer (pointed to by one of the elements in the FILE
structure). I did this using the MinGW compiler - but I would imagine
it is doable with most compilers.

I think that the thread solution is actually better, but is, as you say,
complicated to implement. I wish somebody would do it, though, and make
the code publicly available.

P.S. Note that even if source is available and that modifying it to
call different functions was an option, it is possible that doing so
would be too difficult - if, for example, the existing code makes many,
many calls to stdout, intermixing different functions, etc.

.



Relevant Pages

  • Re: Programming Language Productivity: The Stupidity of Programmers
    ... Windows into Something Else). ... or modify it but *don't* want the copy buffer disturbed. ... I'm a dedicated True Geek and love unix! ... > not have used Linux, ...
    (comp.programming)
  • Re: CEPC Bootload Errors
    ... Did you have to modify the buffer length settings as suggested in the ... status windows of Windows CE at bootup. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Embedded TCL and Single File Executables
    ... Windows, .so files under UNIX). ... This requires you to modify your application so that it first copies the dynamic library to the run-time file system prior to using it. ... Typically most people would write a standard pkgIndex.tcl file for their dynamic library, and then [package require] it in their code. ...
    (comp.lang.tcl)
  • Re: hyperterminal
    ... Putty is Unix weird, and Ht is Windows weird. ... buffer. ...
    (sci.electronics.design)
  • Re: fromdos dos2unix in ruby
    ... On Aug 18, 2009, at 11:21 AM, Robert Klemme wrote: ... endings with unix ones and write to the output file. ... Windows d is a file with 0 bytes ...
    (comp.lang.ruby)