/
LIB3/
LIB3/D/ADMIN/
LIB3/D/ADMIN/OBJ/
LIB3/D/ADMIN/ROOM/W/
LIB3/D/HOME/
LIB3/D/HOME/CITY/ARENA/
LIB3/D/HOME/CITY/ITEMS/
LIB3/D/HOME/CITY/POSTOFFI/
LIB3/DOC/
LIB3/GLOBAL/SPECIAL/
LIB3/GLOBAL/VIRTUAL/
LIB3/NET/
LIB3/NET/CONFIG/
LIB3/NET/DAEMON/CHARS/
LIB3/NET/GOPHER/
LIB3/NET/INHERIT/
LIB3/NET/OBJ/
LIB3/NET/SAVE/
LIB3/NET/VIRTUAL/
LIB3/OBJ/B_DAY/
LIB3/OBJ/HANDLERS/TERM_TYP/
LIB3/PLAYERS/B/
LIB3/PLAYERS/N/
LIB3/ROOM/
LIB3/SAVE/
LIB3/SAVE/BOARDS/
LIB3/SAVE/ENVIRON/
LIB3/SAVE/POST/
LIB3/STD/COMMANDS/SHADOWS/
LIB3/STD/CREATOR/
LIB3/STD/DOM/
LIB3/STD/EFFECTS/
LIB3/STD/EFFECTS/HEALING/
LIB3/STD/EFFECTS/OTHER/
LIB3/STD/EFFECTS/POISONS/
LIB3/STD/ENVIRON/
LIB3/STD/GUILDS/
LIB3/STD/LIQUIDS/
LIB3/STD/ROOM/
LIB3/STD/TRIGGER/SHADOW/
LIB3/W/
LIB3/W/BANNOR/
LIB3/W/NEWSTYLE/
string  mtime( int i )
{
    string  str;

    str = efun::ctime( i );
    return str[ 0..strlen( str ) - 9 ];
}
string  stime( int i )
{
    return efun ::ctime( i )[ 11..15 ];
}

string  ntime( int i )
{
    return sprintf( "%02d:%02d", ( i / 3600 ), ( i / 60 ) % 60 );
}


int     last( string str )
{
    string  file, s1, s2, s3, s4, s5, *sarr;
    int     time, t2, i;
    int     lines, fsize;

    if( !str || str == "" )
    {
	notify_fail( "Usage: last -N <name>\n" );
	return 0;
    }
    if( sscanf( str, "-%s %s", s1, str ) == 2 )
	sscanf( s1, "%d", lines );
    if( str == "reboot" )
    {
	fsize = file_length( "/log/REBOOT" );
	if( lines )
	    file = read_file( "/log/REBOOT", fsize - lines, fsize );
	else
	    file = read_file( "/log/REBOOT" );
	sarr = explode( file, "\n" );
	for( i = 0; i < sizeof( sarr ); i++ )
	    if( sscanf( sarr[ i ], "%s[%d]%s", s1, time, s2 ) == 3 )
		printf( "%15-s %s\n", "reboot", mtime( time ) );
	return 1;
    }
    fsize = file_length( "/log/ENTER" );
    if( lines )
	file = read_file( "/log/ENTER", fsize - lines, fsize );
    else
	file = read_file( "/log/ENTER" );
    if( !file )
    {
	notify_fail( "Log file non existant, or bad things are happening.  " +
		     "(Bad vibes man!)\n" );
	return 0;
    }
    str = (string)this_player()->expand_nickname( str );
    while( sscanf( file, "%sEnter : " + str + "%s[%d]%s", s1, s3, time, s2 ) == 4 )
    {
	file = s2;
	if( sscanf( file, "%sExit  : " + str + "%s[%d]%s", s1, s5, t2, s2 ) != 4 )
	    if( !find_player( str ) )
		printf( "%15-s %s - Destd (??:??)\n", str, mtime( time ) );
	    else
		printf( "%15-s %s - Not logged off\n", str, mtime( time ) );
	else
	{
	    if( sscanf( file, "%sEnter : " + str + "%s", s3, s4 ) == 2 )
		if( strlen( s1 ) > strlen( s3 ) )
		{
		    printf( "%15-s %s - %s (%s)\n", str, mtime( time ), "Destd", "??:??" );
		    continue;
		}
	    printf( "%15-s %s - %s (%s)\n", str, mtime( time ), stime( t2 ), ntime( t2 - time ) );
	    file = s2;
	}
    }
    return 1;
}