122122Smckusick /* 2*61111Sbostic * Copyright (c) 1988, 1993 3*61111Sbostic * The Regents of the University of California. All rights reserved. 435452Sbostic * 542627Sbostic * %sccs.include.redist.c% 622122Smckusick */ 716277Ssam 826608Sdonn #if defined(LIBC_SCCS) && !defined(lint) 9*61111Sbostic static char sccsid[] = "@(#)ttyslot.c 8.1 (Berkeley) 06/04/93"; 1035452Sbostic #endif /* LIBC_SCCS and not lint */ 1122122Smckusick 1216422Sralph #include <ttyent.h> 1335452Sbostic #include <stdio.h> 1446597Sdonn #include <string.h> 1546597Sdonn #include <unistd.h> 161995Swnj 1746597Sdonn int ttyslot()181995Swnjttyslot() 191995Swnj { 2035452Sbostic register struct ttyent *ttyp; 2135452Sbostic register int slot; 2235452Sbostic register char *p; 2335452Sbostic int cnt; 2446597Sdonn char *name; 251995Swnj 2640662Smckusick setttyent(); 2735452Sbostic for (cnt = 0; cnt < 3; ++cnt) 2835452Sbostic if (name = ttyname(cnt)) { 2935452Sbostic if (p = rindex(name, '/')) 3035452Sbostic ++p; 3135452Sbostic else 3235452Sbostic p = name; 3335452Sbostic for (slot = 1; ttyp = getttyent(); ++slot) 3435452Sbostic if (!strcmp(ttyp->ty_name, p)) { 3535452Sbostic endttyent(); 3635452Sbostic return(slot); 3735452Sbostic } 3835452Sbostic break; 391995Swnj } 4016422Sralph endttyent(); 4135452Sbostic return(0); 421995Swnj } 43