add getvfsbyname
[unix-history] / usr / src / lib / libc / gen / ttyslot.c
CommitLineData
b8f253e8 1/*
74155b62
KB
2 * Copyright (c) 1988, 1993
3 * The Regents of the University of California. All rights reserved.
81627469 4 *
269a7923 5 * %sccs.include.redist.c%
b8f253e8
KM
6 */
7
2ce81398 8#if defined(LIBC_SCCS) && !defined(lint)
74155b62 9static char sccsid[] = "@(#)ttyslot.c 8.1 (Berkeley) %G%";
81627469 10#endif /* LIBC_SCCS and not lint */
66bba310 11
fb7ebc6b 12#include <ttyent.h>
81627469 13#include <stdio.h>
c5980113
DS
14#include <string.h>
15#include <unistd.h>
2bbb9f0d 16
c5980113 17int
2bbb9f0d
BJ
18ttyslot()
19{
81627469
KB
20 register struct ttyent *ttyp;
21 register int slot;
22 register char *p;
23 int cnt;
c5980113 24 char *name;
2bbb9f0d 25
68ee1bce 26 setttyent();
81627469
KB
27 for (cnt = 0; cnt < 3; ++cnt)
28 if (name = ttyname(cnt)) {
29 if (p = rindex(name, '/'))
30 ++p;
31 else
32 p = name;
33 for (slot = 1; ttyp = getttyent(); ++slot)
34 if (!strcmp(ttyp->ty_name, p)) {
35 endttyent();
36 return(slot);
37 }
38 break;
2bbb9f0d 39 }
fb7ebc6b 40 endttyent();
81627469 41 return(0);
2bbb9f0d 42}