Annotation of 3BSD/libc/gen/getlogin.c, revision 1.1

1.1     ! root        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: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.