1: #include <utmp.h>
   2: 
   3: static  char    UTMP[]  = "/etc/utmp";
   4: static  struct  utmp ubuf;
   5: 
   6: char *
   7: getlogin()
   8: {
   9:     register me, uf;
  10:     register char *cp;
  11: 
  12:     if( !(me = ttyslot()) )
  13:         return(0);
  14:     if( (uf = open( UTMP, 0 )) < 0 )
  15:         return(0);
  16:     lseek( uf, (long)(me*sizeof(ubuf)), 0 );
  17:     if (read(uf, (char *)&ubuf, sizeof(ubuf)) != sizeof(ubuf))
  18:         return(0);
  19:     close(uf);
  20:     ubuf.ut_name[8] = ' ';
  21:     for (cp=ubuf.ut_name; *cp++!=' ';)
  22:         ;
  23:     *--cp = '\0';
  24:     return( ubuf.ut_name );
  25: }

Defined functions

Defined variables

UTMP defined in line 3; used 1 times
  • in line 14
ubuf defined in line 4; used 7 times
Last modified: 1979-01-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 461
Valid CSS Valid XHTML 1.0 Strict