1.\" $NetBSD: getlastlogx.3,v 1.1 2003/08/26 17:37:51 wiz Exp $ 2.\" 3.\" Copyright (c) 2003 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.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd August 26, 2003 38.Dt GETLASTLOGX 3 39.Os 40.Sh NAME 41.Nm getlastlogx , 42.Nm getutmp , 43.Nm getutmpx , 44.Nm updlastlogx , 45.Nm updwtmpx , 46.Nm utmpxname 47.Nd user accounting database functions 48.Sh LIBRARY 49.Lb libc 50.Sh SYNOPSIS 51.In utmpx.h 52.Ft struct lastlogx * 53.Fn getlastlogx "const char *fname" "uid_t uid" "struct lastlogx *ll" 54.Ft void 55.Fn getutmp "const struct utmpx *ux" "struct utmp *u" 56.Ft void 57.Fn getutmpx "const struct utmp *u" "struct utmpx *ux" 58.Ft int 59.Fn updlastlogx "const char *fname" "uid_t uid" "struct lastlogx *ll" 60.Ft int 61.Fn updwtmpx "const char *file" "const struct utmpx *utx" 62.Ft int 63.Fn utmpxname "const char *fname" 64.Sh DESCRIPTION 65The 66.Fn getlastlogx 67function looks up the entry for the user with user id 68.Fa uid 69in the 70.Xr lastlogx 5 71file given by 72.Fa fname 73and returns it in 74.Fa \&ll . 75If the provided 76.Fa \&ll 77is 78.Dv NULL , 79the necessary space will be allocated by 80.Fn getlastlogx 81and should be 82.Fn free Ns d 83by the caller. 84.Pp 85The 86.Fn getutmp 87function fills out the entries in the struct utmp 88.Fa u 89with the data provided in the struct utmpx 90.Fa ux . 91.Fn getutmpx 92does the opposite, filling out the entries in the struct utmpx 93.Fa ux 94with the data provided in the struct utmp 95.Fa u , 96and initializing all the unknown fields to 0. 97The sole exception is the 98.Fa ut_type 99field, which will be initialized to 100.Dv USER_PROCESS . 101.Pp 102The 103.Fn updlastlogx 104function tries to update the information for the user with the user id 105.Fa uid 106in the 107.Xr lastlogx 5 108file given by 109.Fa fname 110with the data supplied in 111.Fa \&ll . 112A 113.Ft struct lastlogx 114is defined like this: 115.Bd -literal 116struct lastlogx { 117 struct timeval ll_tv; /* time entry was created */ 118 char ll_line[_UTX_LINESIZE]; /* tty name */ 119 char ll_host[_UTX_HOSTSIZE]; /* host name */ 120 struct sockaddr_storage ll_ss; /* address where entry was made from */ 121}; 122.Ed 123All the fields should be filled out by the caller. 124.Pp 125The 126.Fn updwtmpx 127function updates the 128.Xr wtmpx 5 129file 130.Fa file 131with the 132.Xr utmpx 5 133entry 134.Fa utx . 135.Pp 136The 137.Fn utmpxname 138function sets the default 139.Xr utmpx 5 140database file name to 141.Fa fname . 142.Sh RETURN VALUES 143.Fn getlastlogx 144returns the found entry on success, or 145.Dv NULL 146if it could not open the database, could not find an entry matching 147.Fa uid 148in there, or could not allocate the necessary space (in case 149.Fa \&ll 150was 151.Dv NULL ) . 152.Pp 153.Fn utmpxname 154returns 1 on success, or 0 if the supplied file name was too long or 155did not end with 156.Sq x . 157.Pp 158.Fn updlastlogx 159and 160.Fn updwtmpx 161return 0 on success, or \-1 in case the database or file respectively 162could not be opened or the data not written into it. 163.Sh SEE ALSO 164.Xr endutxent 3 , 165.Xr loginx 3 , 166.Xr utmpx 5 167.Sh HISTORY 168The functions 169.Fn getutmp , 170.Fn getutmpx , 171.Fn updwtmpx , 172and 173.Fn utmpxname 174first appeared in 175.Tn Solaris . 176.Nm getlastlogx 177and 178.Nm updlastlogx 179first appeared in 180.Nx 2.0 . 181