ll2_read_all3
Reads all entries from database and calls the callback function for each entry.
Usage
#include <lastlog2.h> int ll2_read_all (struct ll2_context *context, int (*callback)(const char *user, int64_t ll_time, const char *tty, const char *rhost, const char *pam_service, const char *cb_error), char **error);
Overview
Reads all entries from database, defined in context, and calls callback function callback for each entry. If context is NULL, the default database, defined in LL2_DEFAULT_DATABASE, will be taken.
char *error = NULL;
const char *user = "root";
static int
callback (const char *res_user, int64_t ll_time, const char *res_tty,
const char *res_rhost, const char *res_service, const char *cb_error)
{
/* returning != 0 if no further entry has to be handled by the callback */
return 0;
}
int ret = ll2_read_all (NULL, callback, &error);
Return value
Returns 0 on success, -ENOMEM or -1 on other failure. error contains an error string if the return value is -1. error is not guaranteed to contain an error string, could also be NULL. error should be freed by the caller. If lastlog2 database does not exist at all, the errno ENOENT is set and can be checked.
Releases
2 releases since Debian 13 (Trixie); the text changed 1 time.