]> code.citadel.org Git - citadel.git/blob - citadel/getutline.c
oops
[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
14 struct utmp *getutline(struct utmp *ut)
15 {
16   static struct utmp retval;
17   FILE *utmp;
18
19   if ((utmp = fopen(_PATH_UTMP, "rb")) == NULL)
20     return NULL;
21
22   do
23     if (!fread(&retval, sizeof retval, 1, utmp))
24       {
25         fclose(utmp);
26         return NULL;
27       }
28   while (ut->ut_line != retval.ut_line);
29
30   fclose(utmp);
31   return &retval;
32 }
33 #endif /* HAVE_UTMP_H */