Article View: alt.msdos.programmer
Article #191Creating your own stream
From: Eric A. Raymond
Date: Tue, 15 Aug 1989 07:05
Date: Tue, 15 Aug 1989 07:05
32 lines
1686 bytes
1686 bytes
Having built a windowing system of sorts, I would like to create
streams which would replace the stdio, stdout, and stderr streams.
That is, given a set of primitive I/O functions, can I create a
file-like device which will call these routines? Then I can redirect
I/O as I please.
For instance:
my_stream = make_stream(my_getc, my_putc, my_printstring);
^
+-- for efficiency
redirect_stream(stderr,my_stream);
printf(my_stream,"Hello World.\n");
Unfortunately, me thinks this is highly system/compiler dependent (or
rather language dependent; it's a snap in common lisp).
Failing that, can I temporarily (only during program execution)
install a device driver which is part of the program to handle DOS's
stdout/stderr (I believe they're one in the same for DOS) streams?
Failing that, can I suppose I can clobber printf with my own routine
which uses vsprintf. Similarly with putc.
Flailing that :-), I can just live with using "special versions" of
I/O functions.
--
Eric A. Raymond (raymond@ptolemy.arc.nasa.gov)
G7 C7 G7 G#7 G7 G+13 C7 GM7 Am7 Bm7 Bd7 Am7 C7 Do13 G7 C7 G7 D+13: Elmore James
Technical Details
Message-ID:
<1961@ptolemy.arc.nasa.gov>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!ucbvax!pasteur!agate!eos!ptolemy!raymondShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!ucbvax!pasteur!agate!eos!ptolemy!raymond From: raymond@ptolemy.arc.nasa.gov (Eric A. Raymond) Newsgroups: alt.msdos.programmer,comp.binaries.ibm.pc.d,comp.sys.ibm.pc Subject: Creating your own stream Message-ID: <1961@ptolemy.arc.nasa.gov> Date: 15 Aug 89 07:05:22 GMT Reply-To: raymond@ptolemy.arc.nasa.gov (Eric A. Raymond) Organization: NASA Ames Research Center Lines: 32