home *** CD-ROM | disk | FTP | other *** search
- /*------ setraw.lc ----------------------------------------------
- Lattice C routines which get and set the current raw/cooked state
- of a file, given its Lattice file descriptor.
- Useful when trying to obtain high console output speeds.
- ----------------------------------------------------------------*/
-
- #include <dos.h>
-
- #define CARRY 0x1
- #define ERROR (-1)
- #define TRUE 1
- #define FALSE 0
-
- extern _oserr;
-
- /*---- getraw --------------------------------------------------
- Returns TRUE if file fd is a device in raw mode; FALSE otherwise.
- Returns ERROR, puts errorcode in _oserr, if DOS error.
- ----------------------------------------------------------------*/
- getraw(fd)
- int fd;
- {
- union REGS inregs;
- union REGS outregs;
- int flags;
-
- inregs.x.bx = fd;
- inregs.x.ax = 0x4400; /* get file attributes */
- flags = intdos( &inregs, &outregs );
- return (outregs.x.dx & 0x20) ? TRUE : FALSE;
- }
-
- /*---- setraw --------------------------------------------------
- Sets Raw state of file fd to raw_on (if file is not a device, does nothing).
- Returns zero if successful.
- Returns ERROR & errorcode in _oserr if DOS error.
- ----------------------------------------------------------------*/
- setraw(fd, raw_on)
- int fd, raw_on;
- {
- union REGS inregs;
- union REGS outregs;
- int flags;
-
- inregs.x.ax = 0x4400; /* get file attributes */
- inregs.x.bx = fd;
- flags = intdos(&inregs, &outregs);
- if ((outregs.x.ax & 0x80) == 0) /* return zero if not device */
- return 0;
-
- outregs.x.ax = 0x4401; /* set file attributes */
- outregs.x.bx = fd;
- outregs.x.dx &= 0xcf; /* clear old raw bit & hi byte */
- if (raw_on) outregs.x.dx |= 0x20; /* maybe set new raw bit */
- flags = intdos(&outregs, &inregs);
- return 0;
- }
- /*-- end of setraw.lc --*/
-