122122Smckusick /* 235452Sbostic * Copyright (c) 1988 The Regents of the University of California. 335452Sbostic * All rights reserved. 435452Sbostic * 5*42627Sbostic * %sccs.include.redist.c% 622122Smckusick */ 716277Ssam 826608Sdonn #if defined(LIBC_SCCS) && !defined(lint) 9*42627Sbostic static char sccsid[] = "@(#)ttyslot.c 5.5 (Berkeley) 06/01/90"; 1035452Sbostic #endif /* LIBC_SCCS and not lint */ 1122122Smckusick 1216422Sralph #include <ttyent.h> 1335452Sbostic #include <stdio.h> 141995Swnj 151995Swnj ttyslot() 161995Swnj { 1735452Sbostic register struct ttyent *ttyp; 1835452Sbostic register int slot; 1935452Sbostic register char *p; 2035452Sbostic int cnt; 2135452Sbostic char *name, *rindex(), *ttyname(); 221995Swnj 2340662Smckusick setttyent(); 2435452Sbostic for (cnt = 0; cnt < 3; ++cnt) 2535452Sbostic if (name = ttyname(cnt)) { 2635452Sbostic if (p = rindex(name, '/')) 2735452Sbostic ++p; 2835452Sbostic else 2935452Sbostic p = name; 3035452Sbostic for (slot = 1; ttyp = getttyent(); ++slot) 3135452Sbostic if (!strcmp(ttyp->ty_name, p)) { 3235452Sbostic endttyent(); 3335452Sbostic return(slot); 3435452Sbostic } 3535452Sbostic break; 361995Swnj } 3716422Sralph endttyent(); 3835452Sbostic return(0); 391995Swnj } 40