home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource3 / 163_01 / fbinary.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-02-01  |  640 b   |  17 lines

  1. /*
  2. ** set stream to binary mode (CRMOD off)
  3. */
  4. #include <sgtty.h>
  5. #define FILE int
  6. #define EOF (-1)
  7. extern fileno(), _ioctl();
  8.  
  9. fbinary(stream) FILE stream; {
  10.   int fd;
  11.   char sgttyb[SG_SIZE];
  12.   if((fd = fileno(stream)) == 0) return EOF;
  13.   _ioctl(fd, TIOCGETP, sgttyb);
  14.   sgttyb[SG_FLGS] &= ~'\020'; /* turn off CR/LF conversion */
  15.   _ioctl(fd, TIOCSETP, sgttyb);
  16.   }
  17.