C question–redirection
5 messages in this thread
Depending on the level of file I/O you're using, if the input or output has
been redirected, the 'stdin' and 'stdout' file handles have been changed from
their defaults values, to something else. In Manx, 'stdin' is (&Cbuffs[0]),
the address of the zeroth element in Cbuffs[], which I presume is used to hold
all the file handles. I'd look at the example _main startup code to see what
values are stored here. Sorry, I don't have the Manx library source code on my
hard disk right now… and Lattice probably does it differently, but the same
technique should work.
Timestamp: synd24 51 0 0/sec 2304:57 08-27-88
01 24 23:04 0:00 24576 1:2400 8n >cis0827.txt
Last access: 13:00 27-Aug-88
I'd like the program to be able to tell if the user is redirecting the input
from a file, so it will only print the input prompts when input is from the
keyboard. The fscanf's I use for the input work OK with input from a file, but
the prompts aren't needed when the input is redirected.
In Lattice, I know that stdin and stdout are defined as (&_iob[0]) and
(&_iob[1]) respectively. _iob[] is an array of 'struct _iobuf' (type FILE). I
can't really tell what is different when redirection is used, but I think it
has something to do with the elements in the _iob[] array.
I need to talk with someone who knows how _iob[] changes when I/O is
redirected.
Thanks,
Chip Mattson
72017,442
In Manx you could probably do: if (stdin == Input()) keyboard = 1; else
keyboard = 0; where keyboard is a flag.
ACG
stdin is defined to be the result of Input() stdout is the result of Output()
both are dos.library functions. I don't remember what stderr is.