ack/mach/minixST/libsys/ioctl.c

69 lines
1.7 KiB
C
Raw Normal View History

1988-04-19 09:34:37 +00:00
#include "lib.h"
#include <minix/com.h>
#include <sgtty.h>
PUBLIC int ioctl(fd, request, u)
int fd;
int request;
union {
struct sgttyb *argp;
struct tchars *argt;
} u;
{
1989-11-03 09:25:46 +00:00
int n, ispeed, ospeed;
long erase, kill, intr, quit, xon, xoff, eof, brk, speed;
1988-04-19 09:34:37 +00:00
M.TTY_REQUEST = request;
M.TTY_LINE = fd;
switch(request) {
case TIOCSETP:
1989-11-03 09:25:46 +00:00
erase = u.argp->sg_erase & BYTE;
kill = u.argp->sg_kill & BYTE;
1988-04-19 09:34:37 +00:00
M.TTY_SPEK = (erase << 8) | kill;
M.TTY_FLAGS = u.argp->sg_flags;
1989-11-03 09:25:46 +00:00
M.TTY_SPEED = (u.argp->sg_ospeed << 8) | u.argp->sg_ispeed;
1988-04-19 09:34:37 +00:00
n = callx(FS, IOCTL);
return(n);
case TIOCSETC:
1989-11-03 09:25:46 +00:00
intr = u.argt->t_intrc & BYTE;
quit = u.argt->t_quitc & BYTE;
xon = u.argt->t_startc & BYTE;
xoff = u.argt->t_stopc & BYTE;
eof = u.argt->t_eofc & BYTE;
brk = u.argt->t_brkc & BYTE; /* not used at the moment */
1988-04-19 09:34:37 +00:00
M.TTY_SPEK = (intr<<24) | (quit<<16) | (xon<<8) | (xoff<<0);
M.TTY_FLAGS = (eof<<8) | (brk<<0);
n = callx(FS, IOCTL);
return(n);
case TIOCGETP:
n = callx(FS, IOCTL);
1989-11-03 09:25:46 +00:00
u.argp->sg_erase = (M.TTY_SPEK >> 8) & BYTE;
u.argp->sg_kill = (M.TTY_SPEK >> 0) & BYTE;
u.argp->sg_flags = M.TTY_FLAGS & 0xFFFF;
speed = (M.TTY_FLAGS >> 16) & 0xFFFFL;
u.argp->sg_ispeed = speed & BYTE;
u.argp->sg_ospeed = (speed >> 8) & BYTE;
1988-04-19 09:34:37 +00:00
return(n);
case TIOCGETC:
n = callx(FS, IOCTL);
1989-11-03 09:25:46 +00:00
u.argt->t_intrc = (M.TTY_SPEK >> 24) & BYTE;
u.argt->t_quitc = (M.TTY_SPEK >> 16) & BYTE;
u.argt->t_startc = (M.TTY_SPEK >> 8) & BYTE;
u.argt->t_stopc = (M.TTY_SPEK >> 0) & BYTE;
u.argt->t_eofc = (M.TTY_FLAGS >> 8) & BYTE;
u.argt->t_brkc = (M.TTY_FLAGS >> 8) & BYTE;
1988-04-19 09:34:37 +00:00
return(n);
default:
n = -1;
errno = -(EINVAL);
return(n);
}
}