1/*	$NetBSD: utmpx.h,v 1.2.8.2 2008/12/28 01:18:38 christos Exp $	 */
2
3/*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31#ifndef	_COMPAT_UTMPX_H_
32#define	_COMPAT_UTMPX_H_
33
34#include <compat/sys/time.h>
35
36struct utmpx50 {
37	char ut_name[_UTX_USERSIZE];	/* login name */
38	char ut_id[_UTX_IDSIZE];	/* inittab id */
39	char ut_line[_UTX_LINESIZE];	/* tty name */
40	char ut_host[_UTX_HOSTSIZE];	/* host name */
41	uint16_t ut_session;		/* session id used for windowing */
42	uint16_t ut_type;		/* type of this entry */
43	pid_t ut_pid;			/* process id creating the entry */
44	struct {
45		uint16_t e_termination;	/* process termination signal */
46		uint16_t e_exit;	/* process exit status */
47	} ut_exit;
48	struct sockaddr_storage ut_ss;	/* address where entry was made from */
49	struct timeval50 ut_tv;		/* time entry was created */
50	uint32_t ut_pad[10];		/* reserved for future use */
51};
52
53struct lastlogx50 {
54	struct timeval50 ll_tv;		/* time entry was created */
55	char ll_line[_UTX_LINESIZE];	/* tty name */
56	char ll_host[_UTX_HOSTSIZE];	/* host name */
57	struct sockaddr_storage ll_ss;	/* address where entry was made from */
58};
59
60__BEGIN_DECLS
61
62static __inline void
63utmpx50_to_utmpx(const struct utmpx50 *ut50, struct utmpx *ut)
64{
65	(void)memcpy(ut, ut50, sizeof(*ut));
66	timeval50_to_timeval(&ut50->ut_tv, &ut->ut_tv);
67}
68
69static __inline void
70utmpx_to_utmpx50(const struct utmpx *ut, struct utmpx50 *ut50)
71{
72	(void)memcpy(ut50, ut, sizeof(*ut50));
73	timeval_to_timeval50(&ut->ut_tv, &ut50->ut_tv);
74}
75
76struct utmpx50 *getutxent(void);
77struct utmpx *__getutxent50(void);
78struct utmpx50 *getutxid(const struct utmpx50 *);
79struct utmpx *__getutxid50(const struct utmpx *);
80struct utmpx50 *getutxline(const struct utmpx50 *);
81struct utmpx *__getutxline50(const struct utmpx *);
82struct utmpx50 *pututxline(const struct utmpx50 *);
83struct utmpx *__pututxline50(const struct utmpx *);
84int updwtmpx(const char *, const struct utmpx50 *);
85int __updwtmpx50(const char *, const struct utmpx *);
86int updlastlogx(const char *, uid_t, struct lastlogx50 *);
87int __updlastlogx50(const char *, uid_t, struct lastlogx *);
88struct utmp;
89void getutmp(const struct utmpx50 *, struct utmp *);
90void __getutmp50(const struct utmpx *, struct utmp *);
91void getutmpx(const struct utmp *, struct utmpx50 *);
92void __getutmpx50(const struct utmp *, struct utmpx *);
93
94int lastlogxname(const char *);
95struct lastlogx50 *getlastlogx(uid_t, struct lastlogx50 *);
96struct lastlogx50 *__getlastlogx13(const char *, uid_t, struct lastlogx50 *);
97struct lastlogx *__getlastlogx50(const char *, uid_t, struct lastlogx *);
98
99__END_DECLS
100
101#endif /* !_COMPAT_UTMPX_H_ */
102