utmp.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* The `struct utmp' type, describing entries in the utmp file. GNU version.
  2. Copyright (C) 1993, 1996, 1997, 1998, 1999, 2002
  3. Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. #ifndef _UTMP_H
  18. # error "Never include <bits/utmp.h> directly; use <utmp.h> instead."
  19. #endif
  20. #include <paths.h>
  21. #include <sys/time.h>
  22. #include <sys/types.h>
  23. #include <bits/wordsize.h>
  24. #define UT_LINESIZE 32
  25. #define UT_NAMESIZE 32
  26. #define UT_HOSTSIZE 256
  27. /* The structure describing an entry in the database of
  28. previous logins. */
  29. struct lastlog
  30. {
  31. #if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
  32. int32_t ll_time;
  33. #else
  34. __time_t ll_time;
  35. #endif
  36. char ll_line[UT_LINESIZE];
  37. char ll_host[UT_HOSTSIZE];
  38. };
  39. /* The structure describing the status of a terminated process. This
  40. type is used in `struct utmp' below. */
  41. struct exit_status
  42. {
  43. short int e_termination; /* Process termination status. */
  44. short int e_exit; /* Process exit status. */
  45. };
  46. /* The structure describing an entry in the user accounting database. */
  47. struct utmp
  48. {
  49. short int ut_type; /* Type of login. */
  50. pid_t ut_pid; /* Process ID of login process. */
  51. char ut_line[UT_LINESIZE]; /* Devicename. */
  52. char ut_id[4]; /* Inittab ID. */
  53. char ut_user[UT_NAMESIZE]; /* Username. */
  54. char ut_host[UT_HOSTSIZE]; /* Hostname for remote login. */
  55. struct exit_status ut_exit; /* Exit status of a process marked
  56. as DEAD_PROCESS. */
  57. /* The ut_session and ut_tv fields must be the same size when compiled
  58. 32- and 64-bit. This allows data files and shared memory to be
  59. shared between 32- and 64-bit applications. */
  60. #if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
  61. int32_t ut_session; /* Session ID, used for windowing. */
  62. struct
  63. {
  64. int32_t tv_sec; /* Seconds. */
  65. int32_t tv_usec; /* Microseconds. */
  66. } ut_tv; /* Time entry was made. */
  67. #else
  68. long int ut_session; /* Session ID, used for windowing. */
  69. struct timeval ut_tv; /* Time entry was made. */
  70. #endif
  71. int32_t ut_addr_v6[4]; /* Internet address of remote host. */
  72. char __unused[20]; /* Reserved for future use. */
  73. };
  74. /* Backwards compatibility hacks. */
  75. #define ut_name ut_user
  76. #ifndef _NO_UT_TIME
  77. /* We have a problem here: `ut_time' is also used otherwise. Define
  78. _NO_UT_TIME if the compiler complains. */
  79. # define ut_time ut_tv.tv_sec
  80. #endif
  81. #define ut_xtime ut_tv.tv_sec
  82. #define ut_addr ut_addr_v6[0]
  83. /* Values for the `ut_type' field of a `struct utmp'. */
  84. #define EMPTY 0 /* No valid user accounting information. */
  85. #define RUN_LVL 1 /* The system's runlevel. */
  86. #define BOOT_TIME 2 /* Time of system boot. */
  87. #define NEW_TIME 3 /* Time after system clock changed. */
  88. #define OLD_TIME 4 /* Time when system clock changed. */
  89. #define INIT_PROCESS 5 /* Process spawned by the init process. */
  90. #define LOGIN_PROCESS 6 /* Session leader of a logged in user. */
  91. #define USER_PROCESS 7 /* Normal process. */
  92. #define DEAD_PROCESS 8 /* Terminated process. */
  93. #define ACCOUNTING 9
  94. /* Old Linux name for the EMPTY type. */
  95. #define UT_UNKNOWN EMPTY
  96. /* Tell the user that we have a modern system with UT_HOST, UT_PID,
  97. UT_TYPE, UT_ID and UT_TV fields. */
  98. #define _HAVE_UT_TYPE 1
  99. #define _HAVE_UT_PID 1
  100. #define _HAVE_UT_ID 1
  101. #define _HAVE_UT_TV 1
  102. #define _HAVE_UT_HOST 1