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

Defined functions

Defined variables

UTMP defined in line 4; used 1 times
  • in line 15
ubuf defined in line 5; used 7 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 650
Valid CSS Valid XHTML 1.0 Strict