* Copyright (c) 1985 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid
[] = "@(#)getttyent.c 5.4 (Berkeley) 5/19/86";
#endif LIBC_SCCS and not lint
static char TTYFILE
[] = "/etc/ttys";
static struct ttyent tty
;
tf
= fopen(TTYFILE
, "r");
* Skip over the current field, removing quotes,
* and return a pointer to the next field.
for (; (c
= *p
) != '\0'; p
++) {
q
^= QUOTED
; /* obscure, but nice */
if (q
== QUOTED
&& *p
== '\\' && *(p
+1) == '"')
if (c
== '\t' || c
== ' ' || c
== '\n') {
while ((c
= *p
) == '\t' || c
== ' ' || c
== '\n')
if ((p
= index(p
,'=')) == 0)
p
++; /* get past the = sign */
if ((tf
= fopen(TTYFILE
, "r")) == NULL
)
p
= fgets(line
, LINE
, tf
);
while ((c
= *p
) == '\t' || c
== ' ' || c
== '\n')
} while (c
== '\0' || c
== '#');
for (; *p
; p
= skip(p
)) {
#define space(x) ((c = p[x]) == ' ' || c == '\t' || c == '\n')
if (strncmp(p
, "on", 2) == 0 && space(2))
else if (strncmp(p
, "off", 3) == 0 && space(3))
tty
.ty_status
&= ~TTY_ON
;
else if (strncmp(p
, "secure", 6) == 0 && space(6))
tty
.ty_status
|= TTY_SECURE
;
else if (strncmp(p
, "window=", 7) == 0)
tty
.ty_window
= value(p
);
if (zapchar
== '#' || *p
== '#')
while ((c
= *++p
) == ' ' || c
== '\t')