1: /*
   2:  * Copyright (c) 1984 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #if defined(LIBC_SCCS) && !defined(lint)
   8: static char sccsid[] = "@(#)ttyslot.c	5.2 (Berkeley) 3/9/86";
   9: #endif LIBC_SCCS and not lint
  10: 
  11: /*
  12:  * Return the number of the slot in the utmp file
  13:  * corresponding to the current user: try for file 0, 1, 2.
  14:  * Definition is the line number in the /etc/ttys file.
  15:  */
  16: #include <ttyent.h>
  17: 
  18: char    *ttyname();
  19: char    *rindex();
  20: 
  21: #define NULL    0
  22: 
  23: ttyslot()
  24: {
  25:     register struct ttyent *ty;
  26:     register char *tp, *p;
  27:     register s;
  28: 
  29:     if ((tp = ttyname(0)) == NULL &&
  30:         (tp = ttyname(1)) == NULL &&
  31:         (tp = ttyname(2)) == NULL)
  32:         return(0);
  33:     if ((p = rindex(tp, '/')) == NULL)
  34:         p = tp;
  35:     else
  36:         p++;
  37:     setttyent();
  38:     s = 0;
  39:     while ((ty = getttyent()) != NULL) {
  40:         s++;
  41:         if (strcmp(ty->ty_name, p) == 0) {
  42:             endttyent();
  43:             return (s);
  44:         }
  45:     }
  46:     endttyent();
  47:     return (0);
  48: }

Defined functions

Defined variables

sccsid defined in line 8; never used

Defined macros

NULL defined in line 21; used 5 times
Last modified: 1986-03-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 535
Valid CSS Valid XHTML 1.0 Strict