#include "aux_lu.h" #include #include #include #include /* * Get the value of type from the given entity * returns string */ char* aux_lu_get_str(struct lu_ent* ent, char* type) { return g_value_get_string(g_value_array_get_nth(lu_ent_get(ent, type), 0)); } /* * Get the value of type from the given entity * returns long int */ long aux_lu_get_long(struct lu_ent* ent, char* type) { return g_value_get_long(g_value_array_get_nth(lu_ent_get(ent, type), 0)); } /* * Get the latest login time for given user name * return value greater than 0 on success * return 0 when not found * return -1 on error and errno properly set */ time_t aux_utmp_latest(const char* name) { time_t last = 0, check = 0; unsigned int found = 0; struct utmp *rec = NULL; if (utmpname(WTMP_FILE)) { return -1; } setutent(); while ((rec = getutent()) != NULL) { if (rec->ut_type == USER_PROCESS && strcmp(rec->ut_user, name) == 0) { found = 1; check = rec->ut_tv.tv_sec; last = last > check ? last : check; } } endutent(); return found ? last : -1; }