* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char sccsid
[] = "@(#)subr.c 5.3 (Berkeley) %G%";
extern struct sgttyb tmode
;
extern struct ltchars ltc
;
gettable(name
, buf
, area
)
register struct gettystrs
*sp
;
register struct gettynums
*np
;
register struct gettyflags
*fp
;
hopcount
= 0; /* new lookup, start fresh */
if (getent(buf
, name
) != 1)
for (sp
= gettystrs
; sp
->field
; sp
++)
sp
->value
= getstr(sp
->field
, &area
);
for (np
= gettynums
; np
->field
; np
++) {
for (fp
= gettyflags
; fp
->field
; fp
++) {
fp
->value
= n
^ fp
->invrt
;
register struct gettystrs
*sp
;
register struct gettynums
*np
;
register struct gettyflags
*fp
;
for (sp
= gettystrs
; sp
->field
; sp
++)
for (np
= gettynums
; np
->field
; np
++)
for (fp
= gettyflags
; fp
->field
; fp
++)
register struct gettystrs
*sp
;
register struct gettynums
*np
;
register struct gettyflags
*fp
;
for (sp
= gettystrs
; sp
->field
; sp
++)
for (np
= gettynums
; np
->field
; np
++)
for (fp
= gettyflags
; fp
->field
; fp
++)
&ER
, &KL
, &IN
, &QU
, &XN
, &XF
, &ET
, &BK
,
&SU
, &DS
, &RP
, &FL
, &WE
, &LN
, 0
&tmode
.sg_erase
, &tmode
.sg_kill
, &tc
.t_intrc
,
&tc
.t_quitc
, &tc
.t_startc
, &tc
.t_stopc
,
&tc
.t_eofc
, &tc
.t_brkc
, <c
.t_suspc
,
<c
.t_dsuspc
, <c
.t_rprntc
, <c
.t_flushc
,
<c
.t_werasc
, <c
.t_lnextc
, 0
for (i
= 0; charnames
[i
]; i
++) {
if (n
== 1) { /* read mode flags */
unsigned delay
; /* delay in ms */
* below are random guesses, I can't be bothered checking
struct delayval crdelay
[] = {
struct delayval nldelay
[] = {
1, NL1
, /* special, calculated */
struct delayval bsdelay
[] = {
struct delayval ffdelay
[] = {
struct delayval tbdelay
[] = {
3, XTABS
, /* this is expand tabs */
f
|= adelay(ND
, nldelay
);
f
|= adelay(FD
, ffdelay
);
f
|= adelay(TD
, tbdelay
);
f
|= adelay(BD
, bsdelay
);
register struct delayval
*dp
;
while (dp
->delay
&& ms
> dp
->delay
)
register char *host
= HN
;
register char *res
= editedhost
;
if (res
== &editedhost
[sizeof editedhost
- 1]) {
strncpy(res
, host
, sizeof editedhost
- (res
- editedhost
) - 1);
editedhost
[sizeof editedhost
- 1] = '\0';
19, EXTA
, /* for people who say 19.2K */
7200, EXTB
, /* alternative */
register struct speedtab
*sp
;
for (sp
= speedtab
; sp
->speed
; sp
++)
return (B300
); /* default in impossible cases */
static char termbuf
[128] = "TERM=";
while (q
= index(q
, ',')) {
* This speed select mechanism is written for the Develcon DATASWITCH.
* The Develcon sends a string of the form "B{speed}\n" at a predefined
* baud rate. This string indicates the user's actual speed.
* The routine below returns the terminal type mapped from derived speed.
{ "B19200", "std.19200" },
char c
, baud
[20], *type
= "default";
register struct portselect
*ps
;
for (len
= 0; len
< sizeof (baud
) - 1; len
++) {
if (c
== '\n' || c
== '\r')
len
= 0; /* in case of leading garbage */
for (ps
= portspeeds
; ps
->ps_baud
; ps
++)
if (strcmp(ps
->ps_baud
, baud
) == 0) {
sleep(2); /* wait for connection to complete */
* This auto-baud speed select mechanism is written for the Micom 600
* portselector. Selection is done by looking at how the character '\r'
* is garbled at the different speeds.
char c
, *type
= "9600-baud";
ioctl(0, TIOCFLUSH
, &null
);
if (select(32, &rfds
, (int *)0, (int *)0, &timeout
) <= 0)
if (read(0, &c
, sizeof(char)) != sizeof(char))
(void) select(32, (int *)0, (int *)0, (int *)0, &timeout
);
ioctl(0, TIOCFLUSH
, &null
);
case 0200: /* 300-baud */
case 0346: /* 1200-baud */
case 015: /* 2400-baud */
case 0377: /* 9600-baud */