* Copyright (c) 1989 The Regents of the University of California.
* %sccs.include.redist.c%
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid
[] = "@(#)getttyent.c 5.10 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
register struct ttyent
*t
;
if (!strcmp(tty
, t
->ty_name
))
static struct ttyent tty
;
#define MAXLINELENGTH 100
static char line
[MAXLINELENGTH
];
static char *skip(), *value();
if (!fgets(p
= line
, sizeof(line
), tf
))
/* skip lines that are too big */
while ((c
= getc(tf
)) != '\n' && c
!= EOF
)
if (!*(tty
.ty_getty
= p
))
tty
.ty_getty
= tty
.ty_type
= NULL
;
#define scmp(e) !strncmp(p, e, sizeof(e) - 1) && isspace(p[sizeof(e) - 1])
#define vcmp(e) !strncmp(p, e, sizeof(e) - 1) && p[sizeof(e) - 1] == '='
for (; *p
; p
= skip(p
)) {
tty
.ty_status
&= ~TTY_ON
;
else if (scmp(_TTYS_SECURE
))
tty
.ty_status
|= TTY_SECURE
;
else if (vcmp(_TTYS_WINDOW
))
tty
.ty_window
= value(p
);
if (zapchar
== '#' || *p
== '#')
while ((c
= *++p
) == ' ' || c
== '\t')
* Skip over the current field, removing quotes, and return a pointer to
for (q
= 0, t
= p
; (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')
return ((p
= index(p
, '=')) ? ++p
: NULL
);
} else if (tf
= fopen(_PATH_TTYS
, "r"))
rval
= !(fclose(tf
) == EOF
);