]> code.citadel.org Git - citadel.git/blob - citadel/getutline.c
* configure.in, Makefile.in, getutline.c: replace getutline() on
[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 #ifdef HAVE_UTMP_H
9 #include <stdio.h>
10 #include <utmp.h>
11 #include <paths.h>
12
13 struct utmp *getutline(const struct utmp *ut)
14 {
15   static struct utmp retval;
16   FILE *utmp;
17
18   if ((utmp = fopen(_PATH_UTMP, "rb")) == NULL)
19     return NULL;
20
21   do
22     if (!fread(&retval, sizeof retval, 1, utmp))
23       {
24         fclose(utmp);
25         return NULL;
26       }
27   while (ut->ut_line != retval.ut_line);
28
29   fclose(utmp);
30   return retval;
31 }
32 #endif /* HAVE_UTMP_H */