159a92d18SAlex Hornung /* $NetBSD: utmpentry.h,v 1.6 2008/04/28 20:24:15 martin Exp $ */ 259a92d18SAlex Hornung 359a92d18SAlex Hornung /*- 459a92d18SAlex Hornung * Copyright (c) 2002 The NetBSD Foundation, Inc. 559a92d18SAlex Hornung * All rights reserved. 659a92d18SAlex Hornung * 759a92d18SAlex Hornung * This code is derived from software contributed to The NetBSD Foundation 859a92d18SAlex Hornung * by Christos Zoulas. 959a92d18SAlex Hornung * 1059a92d18SAlex Hornung * Redistribution and use in source and binary forms, with or without 1159a92d18SAlex Hornung * modification, are permitted provided that the following conditions 1259a92d18SAlex Hornung * are met: 1359a92d18SAlex Hornung * 1. Redistributions of source code must retain the above copyright 1459a92d18SAlex Hornung * notice, this list of conditions and the following disclaimer. 1559a92d18SAlex Hornung * 2. Redistributions in binary form must reproduce the above copyright 1659a92d18SAlex Hornung * notice, this list of conditions and the following disclaimer in the 1759a92d18SAlex Hornung * documentation and/or other materials provided with the distribution. 1859a92d18SAlex Hornung * 1959a92d18SAlex Hornung * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2059a92d18SAlex Hornung * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2159a92d18SAlex Hornung * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2259a92d18SAlex Hornung * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2359a92d18SAlex Hornung * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2459a92d18SAlex Hornung * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2559a92d18SAlex Hornung * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2659a92d18SAlex Hornung * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2759a92d18SAlex Hornung * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2859a92d18SAlex Hornung * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2959a92d18SAlex Hornung * POSSIBILITY OF SUCH DAMAGE. 3059a92d18SAlex Hornung */ 3159a92d18SAlex Hornung 3259a92d18SAlex Hornung #include <utmpx.h> 3359a92d18SAlex Hornung #define WHO_NAME_LEN _UTX_USERSIZE 3459a92d18SAlex Hornung #define WHO_LINE_LEN _UTX_LINESIZE 3559a92d18SAlex Hornung #define WHO_HOST_LEN _UTX_HOSTSIZE 3659a92d18SAlex Hornung 3759a92d18SAlex Hornung 3859a92d18SAlex Hornung struct utmpentry { 3959a92d18SAlex Hornung char name[WHO_NAME_LEN + 1]; 4059a92d18SAlex Hornung char line[WHO_LINE_LEN + 1]; 4159a92d18SAlex Hornung char host[WHO_HOST_LEN + 1]; 4259a92d18SAlex Hornung struct timeval tv; 4359a92d18SAlex Hornung pid_t pid; 4459a92d18SAlex Hornung uint16_t term; 4559a92d18SAlex Hornung uint16_t exit; 4659a92d18SAlex Hornung uint16_t sess; 4714f65205SSascha Wildner short type; 4859a92d18SAlex Hornung struct utmpentry *next; 4959a92d18SAlex Hornung }; 5059a92d18SAlex Hornung 5159a92d18SAlex Hornung extern int maxname, maxline, maxhost; 5259a92d18SAlex Hornung extern int etype; 5359a92d18SAlex Hornung 5459a92d18SAlex Hornung /* 5559a92d18SAlex Hornung * getutentries provides a linked list of struct utmpentry and returns 5659a92d18SAlex Hornung * the number of entries. The first argument, if not null, names an 57*25606b42SSascha Wildner * alternate utmpx file to look in. 5859a92d18SAlex Hornung * 5959a92d18SAlex Hornung * The memory returned by getutentries belongs to getutentries. The 6059a92d18SAlex Hornung * list returned (or elements of it) may be returned again later if 61*25606b42SSascha Wildner * utmpx hasn't changed in the meantime. 6259a92d18SAlex Hornung * 6359a92d18SAlex Hornung * endutentries clears and frees the cached data. 6459a92d18SAlex Hornung */ 6559a92d18SAlex Hornung 6659a92d18SAlex Hornung int getutentries(const char *, struct utmpentry **); 6759a92d18SAlex Hornung void endutentries(void); 68