Commit | Line | Data |
---|---|---|
b8f253e8 | 1 | /* |
81627469 KB |
2 | * Copyright (c) 1988 The Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
269a7923 | 5 | * %sccs.include.redist.c% |
b8f253e8 KM |
6 | */ |
7 | ||
2ce81398 | 8 | #if defined(LIBC_SCCS) && !defined(lint) |
c5980113 | 9 | static char sccsid[] = "@(#)ttyslot.c 5.6 (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 | 17 | int |
2bbb9f0d BJ |
18 | ttyslot() |
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 | } |