122122Smckusick /* 2*35452Sbostic * Copyright (c) 1988 The Regents of the University of California. 3*35452Sbostic * All rights reserved. 4*35452Sbostic * 5*35452Sbostic * Redistribution and use in source and binary forms are permitted 6*35452Sbostic * provided that the above copyright notice and this paragraph are 7*35452Sbostic * duplicated in all such forms and that any documentation, 8*35452Sbostic * advertising materials, and other materials related to such 9*35452Sbostic * distribution and use acknowledge that the software was developed 10*35452Sbostic * by the University of California, Berkeley. The name of the 11*35452Sbostic * University may not be used to endorse or promote products derived 12*35452Sbostic * from this software without specific prior written permission. 13*35452Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14*35452Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15*35452Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1622122Smckusick */ 1716277Ssam 1826608Sdonn #if defined(LIBC_SCCS) && !defined(lint) 19*35452Sbostic static char sccsid[] = "@(#)ttyslot.c 5.3 (Berkeley) 08/31/88"; 20*35452Sbostic #endif /* LIBC_SCCS and not lint */ 2122122Smckusick 2216422Sralph #include <ttyent.h> 23*35452Sbostic #include <stdio.h> 241995Swnj 251995Swnj ttyslot() 261995Swnj { 27*35452Sbostic register struct ttyent *ttyp; 28*35452Sbostic register int slot; 29*35452Sbostic register char *p; 30*35452Sbostic int cnt; 31*35452Sbostic char *name, *rindex(), *ttyname(); 321995Swnj 33*35452Sbostic for (cnt = 0; cnt < 3; ++cnt) 34*35452Sbostic if (name = ttyname(cnt)) { 35*35452Sbostic if (p = rindex(name, '/')) 36*35452Sbostic ++p; 37*35452Sbostic else 38*35452Sbostic p = name; 39*35452Sbostic for (slot = 1; ttyp = getttyent(); ++slot) 40*35452Sbostic if (!strcmp(ttyp->ty_name, p)) { 41*35452Sbostic endttyent(); 42*35452Sbostic return(slot); 43*35452Sbostic } 44*35452Sbostic break; 451995Swnj } 4616422Sralph endttyent(); 47*35452Sbostic return(0); 481995Swnj } 49