Home | History | Annotate | Line # | Download | only in include
utmpx.h revision 1.10
      1  1.10     bjh21 /*	$NetBSD: utmpx.h,v 1.10 2003/04/28 23:16:15 bjh21 Exp $	 */
      2   1.1  christos 
      3   1.1  christos /*-
      4   1.1  christos  * Copyright (c) 2002 The NetBSD Foundation, Inc.
      5   1.1  christos  * All rights reserved.
      6   1.1  christos  *
      7   1.1  christos  * This code is derived from software contributed to The NetBSD Foundation
      8   1.1  christos  * by Christos Zoulas.
      9   1.1  christos  *
     10   1.1  christos  * Redistribution and use in source and binary forms, with or without
     11   1.1  christos  * modification, are permitted provided that the following conditions
     12   1.1  christos  * are met:
     13   1.1  christos  * 1. Redistributions of source code must retain the above copyright
     14   1.1  christos  *    notice, this list of conditions and the following disclaimer.
     15   1.1  christos  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1  christos  *    notice, this list of conditions and the following disclaimer in the
     17   1.1  christos  *    documentation and/or other materials provided with the distribution.
     18   1.1  christos  * 3. All advertising materials mentioning features or use of this software
     19   1.1  christos  *    must display the following acknowledgement:
     20   1.1  christos  *        This product includes software developed by the NetBSD
     21   1.1  christos  *        Foundation, Inc. and its contributors.
     22   1.1  christos  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23   1.1  christos  *    contributors may be used to endorse or promote products derived
     24   1.1  christos  *    from this software without specific prior written permission.
     25   1.1  christos  *
     26   1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27   1.1  christos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28   1.1  christos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29   1.1  christos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30   1.1  christos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31   1.1  christos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32   1.1  christos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33   1.1  christos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34   1.1  christos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35   1.1  christos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36   1.1  christos  * POSSIBILITY OF SUCH DAMAGE.
     37   1.1  christos  */
     38   1.1  christos #ifndef	_UTMPX_H_
     39   1.1  christos #define	_UTMPX_H_
     40   1.1  christos 
     41  1.10     bjh21 #include <sys/featuretest.h>
     42   1.2  christos #include <sys/socket.h>
     43   1.4      tron #include <sys/time.h>
     44   1.2  christos 
     45   1.1  christos #define	_PATH_UTMPX		"/var/run/utmpx"
     46   1.1  christos #define	_PATH_WTMPX		"/var/log/wtmpx"
     47   1.2  christos #define	_PATH_LASTLOGX		"/var/log/lastlogx"
     48   1.1  christos #define	_PATH_UTMP_UPDATE	"/usr/libexec/utmp_update"
     49   1.1  christos 
     50   1.3  christos #define _UTX_USERSIZE	32
     51   1.1  christos #define _UTX_LINESIZE	32
     52   1.1  christos #define	_UTX_IDSIZE	4
     53   1.1  christos #define _UTX_HOSTSIZE	256
     54   1.1  christos 
     55  1.10     bjh21 #if defined(_NETBSD_SOURCE)
     56   1.3  christos #define UTX_USERSIZE	_UTX_USERSIZE
     57   1.1  christos #define UTX_LINESIZE	_UTX_LINESIZE
     58   1.1  christos #define	UTX_IDSIZE	_UTX_IDSIZE
     59   1.1  christos #define UTX_HOSTSIZE	_UTX_HOSTSIZE
     60   1.1  christos #endif
     61   1.1  christos 
     62   1.1  christos #define EMPTY		0
     63   1.1  christos #define RUN_LVL		1
     64   1.1  christos #define BOOT_TIME	2
     65   1.1  christos #define OLD_TIME	3
     66   1.1  christos #define NEW_TIME	4
     67   1.1  christos #define INIT_PROCESS	5
     68   1.1  christos #define LOGIN_PROCESS	6
     69   1.1  christos #define USER_PROCESS	7
     70   1.1  christos #define DEAD_PROCESS	8
     71   1.1  christos 
     72  1.10     bjh21 #if defined(_NETBSD_SOURCE)
     73   1.1  christos #define ACCOUNTING	9
     74   1.1  christos #define SIGNATURE	10
     75   1.1  christos #endif
     76   1.1  christos 
     77   1.1  christos /*
     78   1.1  christos  * The following structure describes the fields of the utmpx entries
     79   1.1  christos  * stored in _PATH_UTMPX or _PATH_WTMPX. This is not the format the
     80   1.1  christos  * entries are stored in the files, and application should only access
     81   1.1  christos  * entries using routines described in getutxent(3).
     82   1.1  christos  */
     83   1.5  christos 
     84   1.6  christos #define ut_user ut_name
     85   1.5  christos #define ut_xtime ut_tv.tv_sec
     86   1.5  christos 
     87   1.1  christos struct utmpx {
     88   1.6  christos 	char ut_name[_UTX_USERSIZE];	/* login name */
     89   1.1  christos 	char ut_id[_UTX_IDSIZE];	/* inittab id */
     90   1.1  christos 	char ut_line[_UTX_LINESIZE];	/* tty name */
     91   1.1  christos 	char ut_host[_UTX_HOSTSIZE];	/* host name */
     92   1.1  christos 	uint16_t ut_session;		/* session id used for windowing */
     93   1.1  christos 	uint16_t ut_type;		/* type of this entry */
     94   1.1  christos 	pid_t ut_pid;			/* process id creating the entry */
     95   1.1  christos 	struct {
     96   1.1  christos 		uint16_t e_termination;	/* process termination signal */
     97   1.1  christos 		uint16_t e_exit;	/* process exit status */
     98   1.1  christos 	} ut_exit;
     99   1.1  christos 	struct sockaddr_storage ut_ss;	/* address where entry was made from */
    100   1.1  christos 	struct timeval ut_tv;		/* time entry was created */
    101   1.1  christos 	uint32_t ut_pad[10];		/* reserved for future use */
    102   1.1  christos };
    103   1.1  christos 
    104  1.10     bjh21 #if defined(_NETBSD_SOURCE)
    105   1.1  christos struct lastlogx {
    106   1.8  christos 	struct timeval ll_tv;		/* time entry was created */
    107   1.1  christos 	char ll_line[_UTX_LINESIZE];	/* tty name */
    108   1.1  christos 	char ll_host[_UTX_HOSTSIZE];	/* host name */
    109   1.1  christos 	struct sockaddr_storage ll_ss;	/* address where entry was made from */
    110   1.1  christos };
    111   1.1  christos #endif	/* !_XOPEN_SOURCE */
    112   1.1  christos 
    113   1.1  christos __BEGIN_DECLS
    114   1.1  christos 
    115   1.9  christos void setutxent __P((void));
    116   1.9  christos void endutxent __P((void));
    117   1.9  christos struct utmpx *getutxent __P((void));
    118   1.9  christos struct utmpx *getutxid __P((const struct utmpx *));
    119   1.9  christos struct utmpx *getutxline __P((const struct utmpx *));
    120   1.9  christos struct utmpx *pututxline __P((const struct utmpx *));
    121   1.1  christos 
    122  1.10     bjh21 #if defined(_NETBSD_SOURCE)
    123   1.9  christos int updwtmpx __P((const char *, const struct utmpx *));
    124   1.9  christos int lastlogxname __P((const char *));
    125   1.9  christos struct lastlogx *getlastlogx __P((uid_t, struct lastlogx *));
    126   1.9  christos int updlastlogx __P((const char *, uid_t, struct lastlogx *));
    127   1.7  christos struct utmp;
    128   1.9  christos void getutmp __P((const struct utmpx *, struct utmp *));
    129   1.9  christos void getutmpx __P((const struct utmp *, struct utmpx *));
    130   1.1  christos 
    131   1.9  christos int utmpxname __P((const char *));
    132   1.1  christos 
    133  1.10     bjh21 #endif /* _NETBSD_SOURCE */
    134   1.1  christos 
    135   1.1  christos __END_DECLS
    136   1.1  christos 
    137   1.1  christos #endif /* !_UTMPX_H_ */
    138