.\" $NetBSD: endutent.3,v 1.2 2021/02/26 06:39:14 wiz Exp $
.\"
.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Thomas Klausner.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd February 25, 2021
.Dt ENDUTENT 3
.Os
.Sh NAME
.Nm endutent ,
.Nm getutent ,
.Nm getutline ,
.Nm pututline ,
.Nm setutent
.Nd user accounting database functions
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In utmp.h
.Ft void
.Fn endutent void
.Ft struct utmp *
.Fn getutent void
.Ft struct utmpx *
.Fn getutline "const struct utmp *"
.Ft struct utmp *
.Fn pututline "const struct utmp *"
.Ft void
.Fn setutent void
.Sh DESCRIPTION
These functions provide access to the
.Xr utmp 5
user accounting database.
.Pp
These interfaces are only provided for compatibility purpuses and
have been superseeded by
.Xr endutxent 3 ,
.Xr utmpx 5 .
.Pp
.Fn getutent
reads the next entry from the database;
if the database was not yet open, it also opens it.
.Fn setutent
resets the database, so that the next
.Fn getutent
call will get the first entry.
.Fn endutent
closes the database.
.Pp
.Fn getutline
returns the next
entry which has the same name as specified in the
.Va ut_line
field, or
.Dv NULL
if no match is found.
.Pp
.Fn pututline
adds the argument
.Xr utmp 5
entry line to the accounting database, replacing a previous entry for
the same user if it exists.
.Ss The utmp structure
The
.Nm utmp
structure has the following definition:
.Bd -literal
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 */
};
.Ed
.Sh RETURN VALUES
.Fn getutent
returns the next entry, or
.Dv NULL
on failure (end of database or problems reading from the database).
.Fn getutline
returns the matching structure on success, or
.Dv NULL
if no match was found.
.Fn pututline
returns the structure that was successfully written, or
.Dv NULL .
.Sh SEE ALSO
.Xr logwtmp 3 ,
.Xr utmp 5
.Sh STANDARDS
The
.Fn endutent ,
.Fn getutent ,
.Fn getutline ,
.Fn pututline ,
.Fn setutent
functions all conform to
.St -xpg4.2 .