1 /* 2 * Copyright (c) 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #if defined(LIBC_SCCS) && !defined(lint) 9 static char sccsid[] = "@(#)ttyslot.c 8.1 (Berkeley) 06/04/93"; 10 #endif /* LIBC_SCCS and not lint */ 11 12 #include <ttyent.h> 13 #include <stdio.h> 14 #include <string.h> 15 #include <unistd.h> 16 17 int 18 ttyslot() 19 { 20 register struct ttyent *ttyp; 21 register int slot; 22 register char *p; 23 int cnt; 24 char *name; 25 26 setttyent(); 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; 39 } 40 endttyent(); 41 return(0); 42 } 43