fixes for BSDI. see ChangeLog.
[citadel.git] / citadel / getutline.c
1 /*
2  * getutline.c: not-quite-compatible replacement for getutline(3)
3  * by nathan bryant, feb 1999
4  *
5  * $Id$
6  */
7
8 #include "sysdep.h"
9 #ifdef HAVE_UTMP_H
10 #include <stdio.h>
11 #include <utmp.h>
12 #include <paths.h>
13 #include <string.h>
14
15 struct utmp *getutline(struct utmp *ut)
16 {
17   static struct utmp retval;
18   FILE *utmp;
19
20   if ((utmp = fopen(_PATH_UTMP, "rb")) == NULL)
21     return NULL;
22
23   do
24     if (!fread(&retval, sizeof retval, 1, utmp))
25       {
26         fclose(utmp);
27         return NULL;
28       }
29   while (strcmp(ut->ut_line, retval.ut_line));
30
31   fclose(utmp);
32   return &retval;
33 }
34 #endif /* HAVE_UTMP_H */