ENDUTENT(3) Library Functions Manual ENDUTENT(3)

endutent, getutent, getutline, pututline, setutent
user accounting database functions

Standard C Library (libc, -lc)

#include <utmp.h>

void
endutent(void);

struct utmp *
getutent(void);

struct utmpx *
getutline(const struct utmp *);

struct utmp *
pututline(const struct utmp *);

void
setutent(void);

These functions provide access to the utmp(5) user accounting database.

These interfaces are only provided for compatibility purpuses and have been superseeded by endutxent(3), utmpx(5).

getutent() reads the next entry from the database; if the database was not yet open, it also opens it. setutent() resets the database, so that the next getutent() call will get the first entry. endutent() closes the database.

getutline() returns the next entry which has the same name as specified in the ut_line field, or NULL if no match is found.

pututline() adds the argument utmp(5) entry line to the accounting database, replacing a previous entry for the same user if it exists.

The utmp structure has the following definition:
struct utmp {
        char ut_line[UT_LINESIZE];    /* tty name */
        char ut_name[UT_USERSIZE];    /* login name */
        char ut_host[UT_HOSTSIZE];    /* host name */
	time_t ut_time;		      /* time entry was created */
};

getutent() returns the next entry, or NULL on failure (end of database or problems reading from the database). getutline() returns the matching structure on success, or NULL if no match was found. pututline() returns the structure that was successfully written, or NULL.

logwtmp(3), utmp(5)

The endutent(), getutent(), getutline(), pututline(), setutent() functions all conform to X/Open Portability Guide Issue 4, Version 2 (“XPG4.2”).
February 25, 2021 NetBSD 10.1