| 1 |
'\" t |
| 2 |
.\" Title: ll2_read_all |
| 3 |
.\" Author: [see the "AUTHOR(S)" section] |
| 4 |
.\" Generator: Asciidoctor 2.0.20 |
| 5 |
.\" Date: 2026-04-28 |
| 6 |
.\" Manual: Programmer's Manual |
| 7 |
.\" Source: util-linux 2.42.1 |
| 8 |
.\" Language: English |
| 9 |
.\" |
| 10 |
.TH "LL2_READ_ALL" "3" "2026-04-28" "util\-linux 2.42.1" "Programmer\*(Aqs Manual" |
| 11 |
.ie \n(.g .ds Aq \(aq |
| 12 |
.el .ds Aq ' |
| 13 |
.ss \n[.ss] 0 |
| 14 |
.nh |
| 15 |
.ad l |
| 16 |
.de URL |
| 17 |
\fI\\$2\fP <\\$1>\\$3 |
| 18 |
.. |
| 19 |
.als MTO URL |
| 20 |
.if \n[.g] \{\ |
| 21 |
. mso www.tmac |
| 22 |
. am URL |
| 23 |
. ad l |
| 24 |
. . |
| 25 |
. am MTO |
| 26 |
. ad l |
| 27 |
. . |
| 28 |
. LINKSTYLE blue R < > |
| 29 |
.\} |
| 30 |
.SH "NAME" |
| 31 |
ll2_read_all \- Reads all entries from database and calls the callback function for each entry. |
| 32 |
.SH "SYNOPSIS" |
| 33 |
.sp |
| 34 |
\fB#include <lastlog2.h>\fP |
| 35 |
\fBint ll2_read_all (struct ll2_context *\fIcontext\fP, |
| 36 |
int (*\fIcallback\fP)(const char *\fIuser\fP, int64_t \fIll_time\fP, |
| 37 |
const char *\fItty\fP, const char *\fIrhost\fP, |
| 38 |
const char *\fIpam_service\fP, const char *\fIcb_error\fP), |
| 39 |
char **\fIerror\fP);\fP |
| 40 |
.SH "DESCRIPTION" |
| 41 |
.sp |
| 42 |
Reads all entries from database, defined in \fIcontext\fP, and calls callback function \fIcallback\fP for each entry. |
| 43 |
If \fIcontext\fP is NULL, the default database, defined in \fILL2_DEFAULT_DATABASE\fP, will be taken. |
| 44 |
.sp |
| 45 |
.if n .RS 4 |
| 46 |
.nf |
| 47 |
.fam C |
| 48 |
char *error = NULL; |
| 49 |
const char *user = "root"; |
| 50 |
|
| 51 |
static int |
| 52 |
callback (const char *res_user, int64_t ll_time, const char *res_tty, |
| 53 |
const char *res_rhost, const char *res_service, const char *cb_error) |
| 54 |
{ |
| 55 |
/* returning != 0 if no further entry has to be handled by the callback */ |
| 56 |
return 0; |
| 57 |
} |
| 58 |
|
| 59 |
int ret = ll2_read_all (NULL, callback, &error); |
| 60 |
.fam |
| 61 |
.fi |
| 62 |
.if n .RE |
| 63 |
.SH "RETURN VALUE" |
| 64 |
.sp |
| 65 |
Returns 0 on success, \-ENOMEM or \-1 on other failure. |
| 66 |
\fIerror\fP contains an error string if the return value is \-1. |
| 67 |
\fIerror\fP is not guaranteed to contain an error string, could also be NULL. |
| 68 |
\fIerror\fP should be freed by the caller. |
| 69 |
If lastlog2 database does not exist at all, the errno ENOENT is set |
| 70 |
and can be checked. |
| 71 |
.SH "AUTHORS" |
| 72 |
.sp |
| 73 |
.MTO "kukuk\(atsuse.de" "Thorsten Kukuk" "" |
| 74 |
.SH "SEE ALSO" |
| 75 |
.sp |
| 76 |
\fBlastlog2\fP(3), |
| 77 |
\fBll2_new_context\fP(3), |
| 78 |
\fBll2_unref_context\fP(3), |
| 79 |
\fBll2_write_entry\fP(3), |
| 80 |
\fBll2_read_entry\fP(3), |
| 81 |
\fBll2_update_login_time\fP(3), |
| 82 |
\fBll2_remove_entry\fP(3), |
| 83 |
\fBll2_rename_user\fP(3), |
| 84 |
\fBll2_import_lastlog\fP(3) |
| 85 |
.SH "REPORTING BUGS" |
| 86 |
.sp |
| 87 |
For bug reports, use the \c |
| 88 |
.URL "https://github.com/util\-linux/util\-linux/issues" "issue tracker" "." |
| 89 |
.SH "AVAILABILITY" |
| 90 |
.sp |
| 91 |
The \fBliblastlog2\fP library is part of the util\-linux package since version 2.40. It can be downloaded from \c |
| 92 |
.URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "." |