-
- endutent();
- return (utmped = NOTOK);
-}
-#else
-static int
-logged_in(void)
-{
- struct utmp ut;
- FILE *uf;
-
- if (utmped)
- return utmped;
-
- if ((uf = fopen(UTMP_FILE, "r")) == NULL)
- return NOTOK;
-
- while (fread((char *) &ut, sizeof(ut), 1, uf) == 1) {
- if (ut.ut_name[0] != 0 &&
- strncmp(user, ut.ut_name, sizeof(ut.ut_name))
- == 0) {
- if (debug)
- continue;
- fclose(uf);
- return (utmped = DONE);
- }
- }
-
- fclose(uf);
- return (utmped = NOTOK);
-}
-#endif
-
-#define check(t,a,b) if (t < a || t > b) return -1
-#define cmpar(h1,m1,h2,m2) if (h1 < h2 || (h1 == h2 && m1 < m2)) return 0
-
-static int
-timely(char *t1, char *t2)
-{
- int t1hours, t1mins, t2hours, t2mins;
-
- if (sscanf(t1, "%d:%d", &t1hours, &t1mins) != 2)
- return -1;
- check(t1hours, 0, 23);
- check(t1mins, 0, 59);
-
- if (sscanf(t2, "%d:%d", &t2hours, &t2mins) != 2)
- return -1;
- check(t2hours, 0, 23);
- check(t2mins, 0, 59);
-
- cmpar(now->tw_hour, now->tw_min, t1hours, t1mins);
- cmpar(t2hours, t2mins, now->tw_hour, now->tw_min);
-
- return -1;