FreeBSD/usr.bin/write/write.c
/*
 * utmp_chk - checks that the given user is actually logged in on
 *     the given tty
 */
checks that the given user is actually logged in on
the given tty
checks that the given user is actually logged in on the given tty
int
utmp_chk(char *user, char *tty)
{
	struct utmpx lu, *u;
	strncpy(lu.ut_line, tty, sizeof lu.ut_line);
	setutxent();
	while ((u = getutxline(&lu)) != NULL)
		if (u->ut_type == USER_PROCESS &&
		    strcmp(user, u->ut_user) == 0) {
			endutxent();
			return(0);
		}
	endutxent();
	return(1);
}
int utmp_chk ( char * user , char * tty ) { struct utmpx lu , * u ; strncpy ( lu . ut_line , tty , sizeof lu . ut_line ) ; setutxent ( ) ; while ( ( u = getutxline ( & lu ) ) != NULL ) if ( u -> ut_type == USER_PROCESS && strcmp ( user , u -> ut_user ) == 0 ) { endutxent ( ) ; return ( 0 ) ; } endutxent ( ) ; return ( 1 ) ; }
utmp_chk - checks that the given user is actually logged in on
     the given tty
utmp_chk - checks that the given user is actually logged in on the given tty