[comp.sys.mac.programmer] Help Needed: ThinkC's standard libraries

dks@ccvr1.ncsu.edu (D. K. Smith) (12/21/89)

Hi,

I got a programming problem that (in my estimation) is barely 
worth a post to the net... BUT I got a deadline to meet and 
need a clean, simple solution really soon.

Here's what I'm using:

THINK C 3.0 and the Standard C Libraries,

Steve Adams' "Unix main.c" module for the /* cheesy :-) */
command line interface with i/o redirection.  

Herein lies my problem:

It seems that my _FILE structs like stdin, stdout get all mixed up
about what their job is once they have been redirected once.
Once I invoke some command with i/o redir, upon returning to 
the next prompt and gets(...), my stdin (in this case) is 
screwed up 'cuz the StdStream bit in the _FILE has been reset.  
I have kludged it a couple of times by manually setting the StdStream 
bit before I return to the "unix main.c" module and it worked... "that
time".  However, that method seems very ineloquent.  One thing I thought
may cause a side affect is the fact that the refno and filebuf ptr that
was related to the redirection was left as it was when I set the
StdStream bit myself.  I feel that this is not a complete solution...
there has got to be a better way than this!

Another aspect of this same problem is when I redirect the output.
When I am done writing the file which was redir'ed via the "unix main.c"
func I need to close it.  But if I fclose(stdout) I feel like I
may be screwing up the the _FILE[1] struct just before going back
to the command line prompt.  

I realize that all *four* structs (stdin, stdout, stderr, AND
_console_ are very interrelated, however I have not yet been
able to tie it all together yet. ("Master of the Obvious")

Any (speedy) advice would really be appreciated.  Thanks very much.


And please... no funny cracks about 'why am I using this command
              line prompt thing on the Mac's GUI?'  Save it for
              the Interface wars on comp.sys.mac!  ;-)

----------------------------------------------------------------------
dk smith    (dks@shumv1.ncsu.edu) | (ude.uscn.1vmuhs@skd)    htims kd
-my opinions reflect my opinions. | .snoinipo ym tcelfer snoinipo ym-
----------------------------------------------------------------------
----------------------------------------------------------------------
dk smith                          |                          htims kd
-my opinions reflect my opinions. | .snoinipo ym tcelfer snoinipo ym-
----------------------------------------------------------------------