Mail Archives: djgpp/1998/03/07/11:59:49
At 05:05 3/7/1998 +1300, Eric Gillespie wrote:
>Hi all - have a wee problem that I can't find anything in the FAQ about.
>I believe pipes under DJGPP are simulated by using temporary files in the
>%TEMP% directory. The problem I have is this - I wish to handle stdin with a
>program of mine, and I sometimes cat the output towards my program through a
>pipe. Only thing is, hexdump runs out of bytes way before cat has finished.
>
>I.E brick:~$ cat hexdump.o | hexdump (hexdump.o is about 27k)
>
>hexdump displays about 3.5k of file, and I can't fseek within the pipe - the
>program locks up when I try to do this, though I can display all bytes from
>the beginning to the end of what hexdump has (all 3.5k of them...)
>
>I wish this was a little clearer, but I'd have to post about 650-700 lines of
>code to show you what I meant...how can I get a pipe to display the ENTIRE
>contents of what I pass to it? Is it something to do with cat, or with my
>programming, or just the limitations of the OpenDOS environment?
Your problem is probably that `stdin' is by default open in text mode. This
means, among other things, that it assumes EOF when it encounters a ^Z
character. Since you have a binary file, that probably happens. Also, it
converts CR/LF pairs to bare LF, so your output is probably wrong too. To
fix, do this before you start to read:
#include <io.h>
#include <fcntl.h>
...
setmode(fileno(stdin), O_BINARY);
Nate Eldredge
eldredge AT ap DOT net
- Raw text -