reading output produced by an archive 
Author Message
 reading output produced by an archive

I have a C program that links with an archive that sends its
output to stdout.  Is there a way to capture this output and
use it in my program?

I have thought of reopening stdout using freopen but that
closes stdout.  I need stdout because my final output is
expected to be printed to stdout.  I guess I need to redirect
stdout to stdin or a file and then reset it back to how it
was originally.  Is there a simple way to do that?

Bruce
--



Mon, 22 Oct 2001 03:00:00 GMT  
 reading output produced by an archive

Bruce schrieb in Nachricht ...

Quote:
>I have a C program that links with an archive that sends its
>output to stdout.  Is there a way to capture this output and
>use it in my program?

>I have thought of reopening stdout using freopen but that
>closes stdout.  I need stdout because my final output is
>expected to be printed to stdout.  I guess I need to redirect
>stdout to stdin or a file and then reset it back to how it
>was originally.  Is there a simple way to do that?

>Bruce
>--


Some weeks ago a wrote a little c-tool TEE (like UNIX tool) but under DOS.
It does do the following:

old call:    my_prog > my_arc
tee call:    my_prog | tee > my_arc

tee takes the input inside a pipe and gives it to stderr (or another file)
and writes it to stdout. If you wants to work with pipes under DOS I can
mail you the source an binary of tee

Regards

    Georg

--



Tue, 23 Oct 2001 03:00:00 GMT  
 reading output produced by an archive


Quote:
> I have a C program that links with an archive that sends its
> output to stdout.  Is there a way to capture this output and
> use it in my program?

> I have thought of reopening stdout using freopen but that
> closes stdout.  I need stdout because my final output is
> expected to be printed to stdout.  I guess I need to redirect
> stdout to stdin or a file and then reset it back to how it
> was originally.  Is there a simple way to do that?

This is all OS-specific stuff. If you're on a Posix system, then you can
run the vital functions in a subprocess, with stdout changed to a pipe.
If you're running DOS, you're probably doomed. I don't know about Windows.
You *may* be able to assign stdout to something else, if your system
allows that. I don't think there's a portable way of doing it that doesn't
involve multiple processes.

The alternative solution involves getting a large shotgun and going to
look for the programmer who wrote the library.

--
+- David Given ---------------McQ-+ According to the latest official figures,


+- http://wired.st-and.ac.uk/~dg -+
--



Tue, 23 Oct 2001 03:00:00 GMT  
 reading output produced by an archive

Quote:


>> I have a C program that links with an archive that sends its
>> output to stdout.  Is there a way to capture this output and
>> use it in my program?

>> I have thought of reopening stdout using freopen but that
>> closes stdout.  I need stdout because my final output is
>> expected to be printed to stdout.  I guess I need to redirect
>> stdout to stdin or a file and then reset it back to how it
>> was originally.  Is there a simple way to do that?

>This is all OS-specific stuff. If you're on a Posix system, then you can
>run the vital functions in a subprocess, with stdout changed to a pipe.
>If you're running DOS, you're probably doomed. I don't know about Windows.
>You *may* be able to assign stdout to something else, if your system
>allows that. I don't think there's a portable way of doing it that doesn't
>involve multiple processes.

I am on a Sun Solaris machine so the subprocess sounds like it
just might work.  I was hoping to do something to the file pointers
which I have done until I find a better solution.  Currently I am doing

        svfp = *stdio;
        *stdio = *fp; /* where fp is a file that was opened earlier */
        runfunc();
        *stdio = svfp;

but this can't be very portable.

Quote:
>The alternative solution involves getting a large shotgun and going to
>look for the programmer who wrote the library.

If it were only that easy!  :)
--



Tue, 23 Oct 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. reading output (stdout) produced by an archive

2. read a file than produce 2 output files(HELP)

3. read a file than produce 2 output files(HELP)

4. building parser and produce SQL output

5. How to produce a % in output?

6. Printing produces very small output

7. Richtext control that produce html output

8. q: reading wmi produces "System.UnauthorizedAccessException"

9. Source to read Archives?

10. Reading an archive with CSocketFile

11. Please Help: Reading & Writing from/to a Unicode File produces garbage in output file

12. fgets reading a configuration file: compiles OK but output wrong

 

 
Powered by phpBB® Forum Software