Back to index

glibc  2.9
utmp.h
Go to the documentation of this file.
00001 /* The `struct utmp' type, describing entries in the utmp file.  GNU version.
00002    Copyright (C) 1993, 1996, 1997, 1998, 1999, 2002
00003    Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #ifndef _UTMP_H
00022 # error "Never include <bits/utmp.h> directly; use <utmp.h> instead."
00023 #endif
00024 
00025 #include <paths.h>
00026 #include <sys/time.h>
00027 #include <sys/types.h>
00028 #include <bits/wordsize.h>
00029 
00030 
00031 #define UT_LINESIZE  32
00032 #define UT_NAMESIZE  32
00033 #define UT_HOSTSIZE  256
00034 
00035 
00036 /* The structure describing an entry in the database of
00037    previous logins.  */
00038 struct lastlog
00039   {
00040 #if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
00041     int32_t ll_time;
00042 #else
00043     __time_t ll_time;
00044 #endif
00045     char ll_line[UT_LINESIZE];
00046     char ll_host[UT_HOSTSIZE];
00047   };
00048 
00049 
00050 /* The structure describing the status of a terminated process.  This
00051    type is used in `struct utmp' below.  */
00052 struct exit_status
00053   {
00054     short int e_termination;       /* Process termination status.  */
00055     short int e_exit;              /* Process exit status.  */
00056   };
00057 
00058 
00059 /* The structure describing an entry in the user accounting database.  */
00060 struct utmp
00061 {
00062   short int ut_type;        /* Type of login.  */
00063   pid_t ut_pid;                    /* Process ID of login process.  */
00064   char ut_line[UT_LINESIZE];       /* Devicename.  */
00065   char ut_id[4];            /* Inittab ID.  */
00066   char ut_user[UT_NAMESIZE];       /* Username.  */
00067   char ut_host[UT_HOSTSIZE];       /* Hostname for remote login.  */
00068   struct exit_status ut_exit;      /* Exit status of a process marked
00069                                as DEAD_PROCESS.  */
00070 /* The ut_session and ut_tv fields must be the same size when compiled
00071    32- and 64-bit.  This allows data files and shared memory to be
00072    shared between 32- and 64-bit applications.  */
00073 #if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
00074   int32_t ut_session;              /* Session ID, used for windowing.  */
00075   struct
00076   {
00077     int32_t tv_sec;         /* Seconds.  */
00078     int32_t tv_usec;        /* Microseconds.  */
00079   } ut_tv;                  /* Time entry was made.  */
00080 #else
00081   long int ut_session;             /* Session ID, used for windowing.  */
00082   struct timeval ut_tv;            /* Time entry was made.  */
00083 #endif
00084 
00085   int32_t ut_addr_v6[4];    /* Internet address of remote host.  */
00086   char __unused[20];        /* Reserved for future use.  */
00087 };
00088 
00089 /* Backwards compatibility hacks.  */
00090 #define ut_name             ut_user
00091 #ifndef _NO_UT_TIME
00092 /* We have a problem here: `ut_time' is also used otherwise.  Define
00093    _NO_UT_TIME if the compiler complains.  */
00094 # define ut_time     ut_tv.tv_sec
00095 #endif
00096 #define ut_xtime     ut_tv.tv_sec
00097 #define ut_addr             ut_addr_v6[0]
00098 
00099 
00100 /* Values for the `ut_type' field of a `struct utmp'.  */
00101 #define EMPTY        0      /* No valid user accounting information.  */
00102 
00103 #define RUN_LVL             1      /* The system's runlevel.  */
00104 #define BOOT_TIME    2      /* Time of system boot.  */
00105 #define NEW_TIME     3      /* Time after system clock changed.  */
00106 #define OLD_TIME     4      /* Time when system clock changed.  */
00107 
00108 #define INIT_PROCESS 5      /* Process spawned by the init process.  */
00109 #define LOGIN_PROCESS       6      /* Session leader of a logged in user.  */
00110 #define USER_PROCESS 7      /* Normal process.  */
00111 #define DEAD_PROCESS 8      /* Terminated process.  */
00112 
00113 #define ACCOUNTING   9
00114 
00115 /* Old Linux name for the EMPTY type.  */
00116 #define UT_UNKNOWN   EMPTY
00117 
00118 
00119 /* Tell the user that we have a modern system with UT_HOST, UT_PID,
00120    UT_TYPE, UT_ID and UT_TV fields.  */
00121 #define _HAVE_UT_TYPE       1
00122 #define _HAVE_UT_PID 1
00123 #define _HAVE_UT_ID  1
00124 #define _HAVE_UT_TV  1
00125 #define _HAVE_UT_HOST       1