Home | History | Annotate | Line # | Download | only in include
      1 /*	$NetBSD: utmpx.h,v 1.3 2009/01/11 02:46:25 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 
     36 struct 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 
     53 struct 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 
     62 static __inline void
     63 utmpx50_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 
     69 static __inline void
     70 utmpx_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 
     76 struct utmpx50 *getutxent(void);
     77 struct utmpx *__getutxent50(void);
     78 struct utmpx50 *getutxid(const struct utmpx50 *);
     79 struct utmpx *__getutxid50(const struct utmpx *);
     80 struct utmpx50 *getutxline(const struct utmpx50 *);
     81 struct utmpx *__getutxline50(const struct utmpx *);
     82 struct utmpx50 *pututxline(const struct utmpx50 *);
     83 struct utmpx *__pututxline50(const struct utmpx *);
     84 int updwtmpx(const char *, const struct utmpx50 *);
     85 int __updwtmpx50(const char *, const struct utmpx *);
     86 int updlastlogx(const char *, uid_t, struct lastlogx50 *);
     87 int __updlastlogx50(const char *, uid_t, struct lastlogx *);
     88 struct utmp;
     89 void getutmp(const struct utmpx50 *, struct utmp *);
     90 void __getutmp50(const struct utmpx *, struct utmp *);
     91 void getutmpx(const struct utmp *, struct utmpx50 *);
     92 void __getutmpx50(const struct utmp *, struct utmpx *);
     93 
     94 int lastlogxname(const char *);
     95 struct lastlogx50 *getlastlogx(uid_t, struct lastlogx50 *);
     96 struct lastlogx50 *__getlastlogx13(const char *, uid_t, struct lastlogx50 *);
     97 struct lastlogx *__getlastlogx50(const char *, uid_t, struct lastlogx *);
     98 
     99 __END_DECLS
    100 
    101 #endif /* !_COMPAT_UTMPX_H_ */
    102