1202188Sed/*-
2202188Sed * Copyright (c) 2010 Ed Schouten <ed@FreeBSD.org>
3202188Sed * All rights reserved.
4202188Sed *
5202188Sed * Redistribution and use in source and binary forms, with or without
6202188Sed * modification, are permitted provided that the following conditions
7202188Sed * are met:
8202188Sed * 1. Redistributions of source code must retain the above copyright
9202188Sed *    notice, this list of conditions and the following disclaimer.
10202188Sed * 2. Redistributions in binary form must reproduce the above copyright
11202188Sed *    notice, this list of conditions and the following disclaimer in the
12202188Sed *    documentation and/or other materials provided with the distribution.
13202188Sed *
14202188Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15202188Sed * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16202188Sed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17202188Sed * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18202188Sed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19202188Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20202188Sed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21202188Sed * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22202188Sed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23202188Sed * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24202188Sed * SUCH DAMAGE.
25202188Sed *
26202188Sed * $FreeBSD$
27202188Sed */
28202188Sed
29202188Sed#ifndef _UTXDB_H_
30202188Sed#define	_UTXDB_H_
31202188Sed
32202188Sed#include <stdint.h>
33202188Sed
34202188Sed#define	_PATH_UTX_ACTIVE	"/var/run/utx.active"
35202188Sed#define	_PATH_UTX_LASTLOGIN	"/var/log/utx.lastlogin"
36202188Sed#define	_PATH_UTX_LOG		"/var/log/utx.log"
37202188Sed
38202188Sed/*
39202188Sed * Entries in struct futx are ordered by how often they are used.  In
40202188Sed * utx.log only entries will be written until the last non-zero byte,
41202188Sed * which means we want to put the hostname at the end. Most primitive
42202188Sed * records only store a ut_type and ut_tv, which means we want to store
43202188Sed * those at the front.
44202188Sed */
45202188Sed
46202188Sedstruct utmpx;
47202188Sed
48202188Sedstruct futx {
49202188Sed	uint8_t		fu_type;
50202188Sed	uint64_t	fu_tv;
51202188Sed	char		fu_id[8];
52202188Sed	uint32_t	fu_pid;
53202188Sed	char		fu_user[32];
54202188Sed	char		fu_line[16];
55202188Sed	char		fu_host[128];
56202188Sed} __packed;
57202188Sed
58202188Sedvoid	utx_to_futx(const struct utmpx *, struct futx *);
59202530Sedstruct utmpx *futx_to_utx(const struct futx *);
60202188Sed
61202188Sed#endif /* !_UTXDB_H_ */
62