<commit_before>.\" Copyright (c) 2010 <NAME> <<EMAIL>>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd January 8, 2010
.Os
.Dt GETUTXENT 3
.Sh NAME
.Nm endutxent ,
.Nm getutxent ,
.Nm getutxid ,
.Nm getutxline ,
.Nm getutxuser ,
.Nm pututxline ,
.Nm setutxdb ,
.Nm setutxent
.Nd user accounting database functions
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In utmpx.h
.Ft void
.Fn endutxent "void"
.Ft struct utmpx *
.Fn getutxent "void"
.Ft struct utmpx *
.Fn getutxid "const struct utmpx *id"
.Ft struct utmpx *
.Fn getutxline "const struct utmpx *line"
.Ft struct utmpx *
.Fn getutxuser "const char *user"
.Ft struct utmpx *
.Fn pututxline "const struct utmpx *utmpx"
.Ft int
.Fn setutxdb "int type" "const char *file"
.Ft void
.Fn setutxent "void"
.Sh DESCRIPTION
These functions operate on the user accounting database which stores
records of various system activities, such as user login and logouts,
but also system startups and shutdowns and modifications to the system's
clock.
The system stores these records in three databases, each having a
different purpose:
.Bl -tag -width indent
.It Pa /var/run/utx.active
Log of currently active user login sessions.
This file is similar to the traditional
.Pa utmp
file.
This file only contains process related entries, such as user login and
logout records.
.It Pa /var/log/utx.lastlogin
Log of last user login entries per user.
This file is similar to the traditional
.Pa lastlog
file.
This file only contains user login records for users who have at least
logged in once.
.It Pa /var/log/utx.log
Log of all entries, sorted by date of addition.
This file is similar to the traditional
.Pa wtmp
file.
This file may contain any type of record described below.
.El
.Pp
Each entry in these databases is defined by the structure
.Vt utmpx
found in the include file
.In utmpx.h :
.Bd -literal -offset indent
struct utmpx {
	short           ut_type;    /* Type of entry. */
	struct timeval  ut_tv;      /* Time entry was made. */
	char            ut_id[];    /* Record identifier. */
	pid_t           ut_pid;     /* Process ID. */
	char            ut_user[];  /* User login name. */
	char            ut_line[];  /* Device name. */
	char            ut_host[];  /* Remote hostname. */
};
.Ed
.Pp
The
.Fa ut_type
field indicates the type of the log entry, which can have one of the
following values:
.Bl -tag -width LOGIN_PROCESS
.It Dv EMPTY
No valid user accounting information.
.It Dv BOOT_TIME
Identifies time of system boot.
.It Dv SHUTDOWN_TIME
Identifies time of system shutdown.
.It Dv OLD_TIME
Identifies time when system clock changed.
.It Dv NEW_TIME
Identifies time after system clock changed.
.It Dv USER_PROCESS
Identifies a process.
.It Dv INIT_PROCESS
Identifies a process spawned by the init process.
.It Dv LOGIN_PROCESS
Identifies the session leader of a logged-in user.
.It Dv DEAD_PROCESS
Identifies a session leader who has exited.
.El
.Pp
Entries of type
.Dv INIT_PROCESS
and
.Dv LOGIN_PROCESS
are not processed by this implementation.
.Pp
Other fields inside the structure are:
.Bl -tag -width ut_user
.It Fa ut_tv
The time the event occured.
This field is used for all types of entries.
.It Fa ut_id
An identifier that is used to refer to the entry.
This identifier can be used to remove or replace a login entry by
writing a new entry to the database containing the same value for
.Fa ut_id .
This field is only applicable to entries of type
.Dv USER_PROCESS ,
.Dv INIT_PROCESS ,
.Dv LOGIN_PROCESS
and
.Dv DEAD_PROCESS .
.It Fa ut_pid
The process identifier of the session leader of the login session.
This field is only applicable to entries of type
.Dv USER_PROCESS ,
.Dv INIT_PROCESS ,
.Dv LOGIN_PROCESS
and
.Dv DEAD_PROCESS .
.It Fa ut_user<commit_msg>EMPTY records don't have a timestamp.<commit_after>.\" Copyright (c) 2010 <NAME> <<EMAIL>>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd January 8, 2010
.Os
.Dt GETUTXENT 3
.Sh NAME
.Nm endutxent ,
.Nm getutxent ,
.Nm getutxid ,
.Nm getutxline ,
.Nm getutxuser ,
.Nm pututxline ,
.Nm setutxdb ,
.Nm setutxent
.Nd user accounting database functions
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In utmpx.h
.Ft void
.Fn endutxent "void"
.Ft struct utmpx *
.Fn getutxent "void"
.Ft struct utmpx *
.Fn getutxid "const struct utmpx *id"
.Ft struct utmpx *
.Fn getutxline "const struct utmpx *line"
.Ft struct utmpx *
.Fn getutxuser "const char *user"
.Ft struct utmpx *
.Fn pututxline "const struct utmpx *utmpx"
.Ft int
.Fn setutxdb "int type" "const char *file"
.Ft void
.Fn setutxent "void"
.Sh DESCRIPTION
These functions operate on the user accounting database which stores
records of various system activities, such as user login and logouts,
but also system startups and shutdowns and modifications to the system's
clock.
The system stores these records in three databases, each having a
different purpose:
.Bl -tag -width indent
.It Pa /var/run/utx.active
Log of currently active user login sessions.
This file is similar to the traditional
.Pa utmp
file.
This file only contains process related entries, such as user login and
logout records.
.It Pa /var/log/utx.lastlogin
Log of last user login entries per user.
This file is similar to the traditional
.Pa lastlog
file.
This file only contains user login records for users who have at least
logged in once.
.It Pa /var/log/utx.log
Log of all entries, sorted by date of addition.
This file is similar to the traditional
.Pa wtmp
file.
This file may contain any type of record described below.
.El
.Pp
Each entry in these databases is defined by the structure
.Vt utmpx
found in the include file
.In utmpx.h :
.Bd -literal -offset indent
struct utmpx {
	short           ut_type;    /* Type of entry. */
	struct timeval  ut_tv;      /* Time entry was made. */
	char            ut_id[];    /* Record identifier. */
	pid_t           ut_pid;     /* Process ID. */
	char            ut_user[];  /* User login name. */
	char            ut_line[];  /* Device name. */
	char            ut_host[];  /* Remote hostname. */
};
.Ed
.Pp
The
.Fa ut_type
field indicates the type of the log entry, which can have one of the
following values:
.Bl -tag -width LOGIN_PROCESS
.It Dv EMPTY
No valid user accounting information.
.It Dv BOOT_TIME
Identifies time of system boot.
.It Dv SHUTDOWN_TIME
Identifies time of system shutdown.
.It Dv OLD_TIME
Identifies time when system clock changed.
.It Dv NEW_TIME
Identifies time after system clock changed.
.It Dv USER_PROCESS
Identifies a process.
.It Dv INIT_PROCESS
Identifies a process spawned by the init process.
.It Dv LOGIN_PROCESS
Identifies the session leader of a logged-in user.
.It Dv DEAD_PROCESS
Identifies a session leader who has exited.
.El
.Pp
Entries of type
.Dv INIT_PROCESS
and
.Dv LOGIN_PROCESS
are not processed by this implementation.
.Pp
Other fields inside the structure are:
.Bl -tag -width ut_user
.It Fa ut_tv
The time the event occured.
This field is used for all types of entries, except
.Dv EMPTY .
.It Fa ut_id
An identifier that is used to refer to the entry.
This identifier can be used to remove or replace a login entry by
writing a new entry to the database containing the same value for
.Fa ut_id .
This field is only applicable to entries of type
.Dv USER_PROCESS ,
.Dv INIT_PROCESS ,
.Dv LOGIN_PROCESS
and
.Dv DEAD_PROCESS .
.It Fa ut_pid
The process identifier of the session leader of the login session.
This field is only applicable to entries of type
.Dv USER_PROCESS ,
.Dv INIT_PROCESS ,
.Dv LOGIN_PROCESS
and
.Dv DEAD_PROCESS .
.It Fa ut_user
{'fraction_non_alphanumeric': 0.07208634518269136, 'fraction_numerical': 0.002376472918110704, 'mean_word_length': 3.49288256227758, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5751932', 'n_tokens_mistral': 3233, 'n_tokens_neox': 3030, 'n_words': 1505}