2 * Copyright (c) 1985 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
7 #pragma ident "%Z%%M% %I% %E% SMI"
14 static char *TTYFILE
= "/etc/ttytab";
16 static struct _ttyentjunk
{
21 } *__ttyentjunk
, *_ttyentjunk(void);
23 static struct _ttyentjunk
*
27 if (__ttyentjunk
== 0)
28 __ttyentjunk
= (struct _ttyentjunk
*)calloc(1, sizeof (struct _ttyentjunk
));
29 return (__ttyentjunk
);
35 struct _ttyentjunk
*t
= _ttyentjunk();
40 t
->tf
= fopen(TTYFILE
, "r");
48 struct _ttyentjunk
*t
= _ttyentjunk();
61 * Skip over the current field, removing quotes,
62 * and return a pointer to the next field.
67 struct _ttyentjunk
*t
= _ttyentjunk();
74 for (; (c
= *p
) != '\0'; p
++) {
76 q
^= QUOTED
; /* obscure, but nice */
79 if (q
== QUOTED
&& *p
== '\\' && *(p
+1) == '"')
89 if (c
== '\t' || c
== ' ' || c
== '\n') {
92 while ((c
= *p
) == '\t' || c
== ' ' || c
== '\n')
104 if ((p
= index(p
,'=')) == 0)
106 p
++; /* get past the = sign */
113 struct _ttyentjunk
*t
= _ttyentjunk();
120 if ((t
->tf
= fopen(TTYFILE
, "r")) == NULL
)
124 p
= fgets(t
->line
, LINE
, t
->tf
);
127 while ((c
= *p
) == '\t' || c
== ' ' || c
== '\n')
129 } while (c
== '\0' || c
== '#');
137 t
->tty
.ty_status
= 0;
138 t
->tty
.ty_window
= NULL
;
139 for (; *p
; p
= skip(p
)) {
140 #define space(x) ((c = p[x]) == ' ' || c == '\t' || c == '\n')
141 if (strncmp(p
, "on", 2) == 0 && space(2))
142 t
->tty
.ty_status
|= TTY_ON
;
143 else if (strncmp(p
, "off", 3) == 0 && space(3))
144 t
->tty
.ty_status
&= ~TTY_ON
;
145 else if (strncmp(p
, "secure", 6) == 0 && space(6))
146 t
->tty
.ty_status
|= TTY_SECURE
;
147 else if (strncmp(p
, "local", 5) == 0 && space(5))
148 t
->tty
.ty_status
|= TTY_LOCAL
;
149 else if (strncmp(p
, "window=", 7) == 0)
150 t
->tty
.ty_window
= value(p
);
154 if (t
->zapchar
== '#' || *p
== '#')
155 while ((c
= *++p
) == ' ' || c
== '\t')
157 t
->tty
.ty_comment
= p
;
159 t
->tty
.ty_comment
= 0;
160 if (p
= index(p
, '\n'))