1 /* finduser.c Copyright Michael Temari 07/22/1996 All Rights Reserved */
11 #include <net/gen/in.h>
16 int find_user(name
, tty
)
24 /* Now find out if the requested user is logged in. */
25 if((fd
= open(UTMP
, O_RDONLY
)) < 0) {
26 perror("talkd: opening UTMP file");
32 while(read(fd
, &utmp
, sizeof(struct utmp
)) == sizeof(struct utmp
)) {
33 if(utmp
.ut_type
!= USER_PROCESS
) continue;
34 if(strncmp(utmp
.ut_user
, name
, sizeof(utmp
.ut_user
))) continue;
35 if(*tty
&& strncmp(utmp
.ut_line
, tty
, sizeof(utmp
.ut_line
))) continue;
36 strcpy(tty
, utmp
.ut_line
);