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