pci: don't do sanity check for missing pci bus, the check can misfire.
[minix.git] / commands / talkd / finduser.c
blob82049cd86002cbfb11b00fd268c200a46858e312
1 /* finduser.c Copyright Michael Temari 07/22/1996 All Rights Reserved */
3 #include <sys/types.h>
4 #include <stdio.h>
5 #include <string.h>
6 #include <unistd.h>
7 #include <stdlib.h>
8 #include <fcntl.h>
9 #include <time.h>
10 #include <utmp.h>
11 #include <net/gen/in.h>
13 #include "talk.h"
14 #include "finduser.h"
16 int find_user(name, tty)
17 char *name;
18 char *tty;
20 int fd;
21 int ret;
22 struct utmp utmp;
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");
27 return(FAILED);
30 ret = NOT_HERE;
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);
37 ret = SUCCESS;
38 break;
41 close(fd);
43 return(ret);