24 #include <sys/errno.h> 27 static FILE *utmp = 0;
29 #define CHECK_UTMP_FILE(badval) \ 34 utmp = fopen(UTMP_FILE, "r+"); \ 55 struct utmpx *getutxent(
void)
57 static struct utmpx ut;
61 size_t n = fread(&ut,
sizeof(
struct utmpx), 1, utmp);
71 struct utmpx *getutxid(
const struct utmpx *ut)
73 if ((!ut) || (ut->ut_type == EMPTY))
88 if ((ut->ut_type >= RUN_LVL && ut->ut_type <= NEW_TIME) &&
89 (p->ut_type == ut->ut_type))
93 else if (!strcmp(p->ut_id, ut->ut_id))
106 struct utmpx *getutxline(
const struct utmpx *ut)
122 if ((p->ut_type == LOGIN_PROCESS) || (p->ut_type == USER_PROCESS))
124 if (!strcmp(ut->ut_line, p->ut_line))
136 struct utmpx *pututxline(
const struct utmpx *ut)
147 struct utmpx *p = getutxid(ut);
151 fseek(utmp, -
sizeof(
struct utmpx), SEEK_CUR);
152 fwrite(ut,
sizeof(
struct utmpx), 1, utmp);
156 fseek(utmp, 0, SEEK_END);
157 fwrite(ut,
sizeof(
struct utmpx), 1, utmp);
170 fseek(utmp, 0, SEEK_SET);