CompuServe Thread

C question–redirection

5 messages in this thread
#8160From: SyndesisAug 27, 1988 1:52 PM
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
#8321From: CHIP MATTSONAug 28, 1988 2:45 AM
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
#8355From: A. Caleb GattegnoAug 28, 1988 4:41 AM
In Manx you could probably do: if (stdin == Input()) keyboard = 1; else keyboard = 0; where keyboard is a flag. ACG
#8394From: SyndesisAug 28, 1988 11:48 AM
For example, Manx's 'ls' checks to see if output has been redirected. If it has, it puts the files on separate lines, so you can easily turn it into a script/execute/.BAT file, or feed it to a program that digests that kind of a stream of names…
#8354From: A. Caleb GattegnoAug 28, 1988 4:40 AM
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.