session.h (978B)
1 /* see LICENSE file for copyright and license details */ 2 #ifndef ARUU_SESSION_H 3 #define ARUU_SESSION_H 4 5 #include <stdio.h> 6 #include <sys/types.h> 7 #include <time.h> 8 9 struct SessionEntry { 10 char user[64]; 11 char line[64]; 12 char host[257]; 13 time_t time; 14 int login; /* a user's session, not one of init's own records */ 15 }; 16 17 typedef int session_fn(const struct SessionEntry *e, void *arg); 18 19 /* a backend per system: the record of a login on the controlling tty 20 * that who and last read, best effort */ 21 void session_record(const char *user); 22 /* fn for every record of a utmp or wtmp file, until it returns non zero. 23 * -1 with errno set when the file cannot be read */ 24 int session_each(const char *path, session_fn *fn, void *arg); 25 /* a getty starting on line forgets every record of it */ 26 void session_clear(const char *line); 27 /* the last login of uid, from a lastlog file the caller opened */ 28 int session_lastlog(FILE *fp, uid_t uid, struct SessionEntry *e); 29 30 #endif