1.\" $NetBSD: endutent.3,v 1.2 2021/02/26 06:39:14 wiz Exp $ 2.\" 3.\" Copyright (c) 2002 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Thomas Klausner. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd February 25, 2021 31.Dt ENDUTENT 3 32.Os 33.Sh NAME 34.Nm endutent , 35.Nm getutent , 36.Nm getutline , 37.Nm pututline , 38.Nm setutent 39.Nd user accounting database functions 40.Sh LIBRARY 41.Lb libc 42.Sh SYNOPSIS 43.In utmp.h 44.Ft void 45.Fn endutent void 46.Ft struct utmp * 47.Fn getutent void 48.Ft struct utmpx * 49.Fn getutline "const struct utmp *" 50.Ft struct utmp * 51.Fn pututline "const struct utmp *" 52.Ft void 53.Fn setutent void 54.Sh DESCRIPTION 55These functions provide access to the 56.Xr utmp 5 57user accounting database. 58.Pp 59These interfaces are only provided for compatibility purpuses and 60have been superseeded by 61.Xr endutxent 3 , 62.Xr utmpx 5 . 63.Pp 64.Fn getutent 65reads the next entry from the database; 66if the database was not yet open, it also opens it. 67.Fn setutent 68resets the database, so that the next 69.Fn getutent 70call will get the first entry. 71.Fn endutent 72closes the database. 73.Pp 74.Fn getutline 75returns the next 76entry which has the same name as specified in the 77.Va ut_line 78field, or 79.Dv NULL 80if no match is found. 81.Pp 82.Fn pututline 83adds the argument 84.Xr utmp 5 85entry line to the accounting database, replacing a previous entry for 86the same user if it exists. 87.Ss The utmp structure 88The 89.Nm utmp 90structure has the following definition: 91.Bd -literal 92struct utmp { 93 char ut_line[UT_LINESIZE]; /* tty name */ 94 char ut_name[UT_USERSIZE]; /* login name */ 95 char ut_host[UT_HOSTSIZE]; /* host name */ 96 time_t ut_time; /* time entry was created */ 97}; 98.Ed 99.Sh RETURN VALUES 100.Fn getutent 101returns the next entry, or 102.Dv NULL 103on failure (end of database or problems reading from the database). 104.Fn getutline 105returns the matching structure on success, or 106.Dv NULL 107if no match was found. 108.Fn pututline 109returns the structure that was successfully written, or 110.Dv NULL . 111.Sh SEE ALSO 112.Xr logwtmp 3 , 113.Xr utmp 5 114.Sh STANDARDS 115The 116.Fn endutent , 117.Fn getutent , 118.Fn getutline , 119.Fn pututline , 120.Fn setutent 121functions all conform to 122.St -xpg4.2 . 123