1: #if defined(LIBC_SCCS) && !defined(lint)
   2: static char sccsid[] = "@(#)getlogin.c	5.3 (Berkeley) 5/9/86";
   3: #endif LIBC_SCCS and not lint
   4: 
   5: #include <utmp.h>
   6: 
   7: static  char UTMP[] = "/etc/utmp";
   8: static  struct utmp ubuf;
   9: 
  10: char *
  11: getlogin()
  12: {
  13:     register int me, uf;
  14:     register char *cp;
  15: 
  16:     if (!(me = ttyslot()))
  17:         return(0);
  18:     if ((uf = open(UTMP, 0)) < 0)
  19:         return (0);
  20:     lseek (uf, (long)(me*sizeof(ubuf)), 0);
  21:     if (read(uf, (char *)&ubuf, sizeof (ubuf)) != sizeof (ubuf)) {
  22:         close(uf);
  23:         return (0);
  24:     }
  25:     close(uf);
  26:     if (ubuf.ut_name[0] == '\0')
  27:         return (0);
  28:     ubuf.ut_name[sizeof (ubuf.ut_name)] = ' ';
  29:     for (cp = ubuf.ut_name; *cp++ != ' '; )
  30:         ;
  31:     *--cp = '\0';
  32:     return (ubuf.ut_name);
  33: }

Defined functions

Defined variables

UTMP defined in line 7; used 1 times
  • in line 18
sccsid defined in line 2; never used
ubuf defined in line 8; used 9 times
Last modified: 1986-05-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 667
Valid CSS Valid XHTML 1.0 Strict