#include <utmpx.h> void endutxent(void); struct utmpx *getutxent(void); struct utmpx *getutxid(const struct utmpx *id); struct utmpx *getutxline(const struct utmpx *line); struct utmpx *pututxline(const struct utmpx *utmpx); void setutxent(void);
The getutxent() function shall read the next entry from the user accounting database. If the database is not already open, it shall open it. If it reaches the end of the database, it shall fail.
The getutxid() function shall search forward from the current point in the database. If the ut_type value of the utmpx structure pointed to by id is BOOT_TIME, OLD_TIME, or NEW_TIME, then it shall stop when it finds an entry with a matching ut_type value. If the ut_type value is INIT_PROCESS, LOGIN_PROCESS, USER_PROCESS, or DEAD_PROCESS, then it shall stop when it finds an entry whose type is one of these four and whose ut_id member matches the ut_id member of the utmpx structure pointed to by id. If the end of the database is reached without a match, getutxid() shall fail.
The getutxline() function shall search forward from the current point in the database until it finds an entry of the type LOGIN_PROCESS or USER_PROCESS which also has a ut_line value matching that in the utmpx structure pointed to by line. If the end of the database is reached without a match, getutxline() shall fail.
The getutxid() or getutxline() function may cache data. For this reason, to use getutxline() to search for multiple occurrences, the application shall zero out the static data after each success, or getutxline() may return a pointer to the same utmpx structure.
There is one exception to the rule about clearing the structure before further reads are done. The implicit read done by pututxline() (if it finds that it is not already at the correct place in the user accounting database) shall not modify the static structure returned by getutxent(), getutxid(), or getutxline(), if the application has modified this structure and passed the pointer back to pututxline().
For all entries that match a request, the ut_type member indicates the type of the entry. Other members of the entry shall contain meaningful data based on the value of the ut_type member as follows:
An implementation that provides extended security controls may impose implementation-defined restrictions on accessing the user accounting database. In particular, the system may deny the existence of some or all of the user accounting database entries associated with users other than the caller.
If the process has appropriate privileges, the pututxline() function shall write out the structure into the user accounting database. It shall search for a record as if by getutxid() that satisfies the request. If this search succeeds, then the entry shall be replaced. Otherwise, a new entry shall be made at the end of the user accounting database.
The endutxent() function shall close the user accounting database.
The setutxent() function shall reset the input to the beginning of the database. This should be done before each search for a new entry if it is desired that the entire database be examined.
The return value may point to a static area which is overwritten by a subsequent call to getutxid() or getutxline().
Upon successful completion, pututxline() shall return a pointer to a utmpx structure containing a copy of the entry added to the user accounting database. Otherwise, a null pointer shall be returned.
The pututxline() function may fail if:
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .