diff options
author | davidn <davidn@FreeBSD.org> | 1997-04-13 15:16:03 +0000 |
---|---|---|
committer | davidn <davidn@FreeBSD.org> | 1997-04-13 15:16:03 +0000 |
commit | 77f2b2acb55da534446a8624a498892b398bc81d (patch) | |
tree | e3921e438f02c376ff2c94702eae3c5f03f9b159 /lib/libc/gen/getttyent.c | |
parent | e20e33863e423d446bb3517ea426bc0229734ef9 (diff) | |
download | FreeBSD-src-77f2b2acb55da534446a8624a498892b398bc81d.zip FreeBSD-src-77f2b2acb55da534446a8624a498892b398bc81d.tar.gz |
Implement two new keywords and status flags for entries in /etc/ttys;
TTY_NETWORK (network), TTY_DIALUP (dialup), which determine a basic
connection type. TTY_DIALUP in particular will replace the old out of
date heuristic "tty[dD]*" in login.c (and better than the current
hard-coded method).
Diffstat (limited to 'lib/libc/gen/getttyent.c')
-rw-r--r-- | lib/libc/gen/getttyent.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/lib/libc/gen/getttyent.c b/lib/libc/gen/getttyent.c index ca0413c..1fb1960 100644 --- a/lib/libc/gen/getttyent.c +++ b/lib/libc/gen/getttyent.c @@ -57,6 +57,8 @@ getttynam(tty) { register struct ttyent *t; + if (strnchr(tty, "/dev/", 5) == 0) + tty += 5; setttyent(); while ( (t = getttyent()) ) if (!strcmp(tty, t->ty_name)) @@ -96,6 +98,9 @@ getttyent() break; } +#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] == '=' + zapchar = 0; tty.ty_name = p; p = skip(p); @@ -105,15 +110,19 @@ getttyent() p = skip(p); if (!*(tty.ty_type = p)) tty.ty_type = NULL; - else + else { + /* compatibility kludge: handle network/dialup specially */ + if (scmp(_TTYS_DIALUP)) + tty.ty_status |= TTY_DIALUP; + else if (scmp(_TTYS_NETWORK)) + tty.ty_status |= TTY_NETWORK; p = skip(p); + } } tty.ty_status = 0; tty.ty_window = NULL; tty.ty_group = _TTYS_NOGROUP; -#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)) { if (scmp(_TTYS_OFF)) tty.ty_status &= ~TTY_ON; @@ -123,6 +132,10 @@ getttyent() tty.ty_status |= TTY_SECURE; else if (scmp(_TTYS_INSECURE)) tty.ty_status &= ~TTY_SECURE; + else if (scmp(_TTYS_DIALUP)) + tty.ty_status |= TTY_DIALUP; + else if (scmp(_TTYS_NETWORK)) + tty.ty_status |= TTY_NETWORK; else if (vcmp(_TTYS_WINDOW)) tty.ty_window = value(p); else if (vcmp(_TTYS_GROUP)) @@ -223,3 +236,29 @@ endttyent() } return (1); } + +static int +isttystat(tty, flag) + const char *tty; + int flag; +{ + register struct ttyent *t; + + return ((t = getttynam(tty)) == NULL) ? 0 : !!(t->ty_status & flag); +} + + +int +isdialuptty(tty) + const char *tty; +{ + + return isttystat(tty, TTY_DIALUP); +} + +int isnettty(tty) + const char *tty; +{ + + return isttystat(tty, TTY_NETWORK); +} |