* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)key.c 8.1 (Berkeley) %G%";
void f_all
__P((struct info
*));
void f_cbreak
__P((struct info
*));
void f_columns
__P((struct info
*));
void f_dec
__P((struct info
*));
void f_everything
__P((struct info
*));
void f_extproc
__P((struct info
*));
void f_ispeed
__P((struct info
*));
void f_nl
__P((struct info
*));
void f_ospeed
__P((struct info
*));
void f_raw
__P((struct info
*));
void f_rows
__P((struct info
*));
void f_sane
__P((struct info
*));
void f_size
__P((struct info
*));
void f_speed
__P((struct info
*));
void f_tty
__P((struct info
*));
void (*f
) __P((struct info
*)); /* function */
#define F_NEEDARG 0x01 /* needs an argument */
#define F_OFFOK 0x02 /* can turn off */
{ "cbreak", f_cbreak
, F_OFFOK
},
{ "cols", f_columns
, F_NEEDARG
},
{ "columns", f_columns
, F_NEEDARG
},
{ "everything", f_everything
, 0 },
{ "extproc", f_extproc
, F_OFFOK
},
{ "ispeed", f_ispeed
, F_NEEDARG
},
{ "ospeed", f_ospeed
, F_NEEDARG
},
{ "raw", f_raw
, F_OFFOK
},
{ "rows", f_rows
, F_NEEDARG
},
static int c_key
__P((const void *, const void *));
if (!(kp
= (struct key
*)bsearch(&tmp
, keys
,
sizeof(keys
)/sizeof(struct key
), sizeof(struct key
), c_key
)))
if (!(kp
->flags
& F_OFFOK
) && ip
->off
) {
errx(1, "illegal option -- %s", name
);
if (kp
->flags
& F_NEEDARG
&& !(ip
->arg
= *++*argvp
)) {
errx(1, "option requires an argument -- %s", name
);
return (strcmp(((struct key
*)a
)->name
, ((struct key
*)b
)->name
));
print(&ip
->t
, &ip
->win
, ip
->ldisc
, BSD
);
ip
->t
.c_iflag
|= BRKINT
|IXON
|IMAXBEL
;
ip
->t
.c_lflag
|= ISIG
|IEXTEN
;
ip
->t
.c_lflag
&= ~ICANON
;
ip
->win
.ws_col
= atoi(ip
->arg
);
ip
->t
.c_cc
[VERASE
] = (u_char
)0177;
ip
->t
.c_cc
[VKILL
] = CTRL('u');
ip
->t
.c_cc
[VINTR
] = CTRL('c');
ip
->t
.c_lflag
&= ~ECHOPRT
;
ip
->t
.c_lflag
|= ECHOE
|ECHOKE
|ECHOCTL
;
print(&ip
->t
, &ip
->win
, ip
->ldisc
, BSD
);
(void)ioctl(ip
->fd
, TIOCEXT
, &tmp
);
(void)ioctl(ip
->fd
, TIOCEXT
, &tmp
);
cfsetispeed(&ip
->t
, atoi(ip
->arg
));
cfsetospeed(&ip
->t
, atoi(ip
->arg
));
ip
->t
.c_cflag
&= ~(CSIZE
|PARENB
);
ip
->win
.ws_row
= atoi(ip
->arg
);
ip
->t
.c_cflag
= TTYDEF_CFLAG
| (ip
->t
.c_cflag
& CLOCAL
);
ip
->t
.c_iflag
= TTYDEF_IFLAG
;
/* preserve user-preference flags in lflag */
#define LKEEP (ECHOKE|ECHOE|ECHOK|ECHOPRT|ECHOCTL|ALTWERASE|TOSTOP|NOFLSH)
ip
->t
.c_lflag
= TTYDEF_LFLAG
| (ip
->t
.c_lflag
& LKEEP
);
ip
->t
.c_oflag
= TTYDEF_OFLAG
;
(void)printf("%d %d\n", ip
->win
.ws_row
, ip
->win
.ws_col
);
(void)printf("%d\n", cfgetospeed(&ip
->t
));
if (ioctl(0, TIOCSETD
, &tmp
) < 0)