utmp.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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, see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef _UTMP_H
  17. # error "Never include <bits/utmp.h> directly; use <utmp.h> instead."
  18. #endif
  19. #include <paths.h>
  20. #include <sys/time.h>
  21. #include <sys/types.h>
  22. #include <bits/wordsize.h>
  23. #define UT_LINESIZE 32
  24. #define UT_NAMESIZE 32
  25. #define UT_HOSTSIZE 256
  26. /* The structure describing an entry in the database of
  27. previous logins. */
  28. struct lastlog
  29. {
  30. #ifdef __WORDSIZE_TIME64_COMPAT32
  31. int32_t ll_time;
  32. #else
  33. __time_t ll_time;
  34. #endif
  35. char ll_line[UT_LINESIZE];
  36. char ll_host[UT_HOSTSIZE];
  37. };
  38. /* The structure describing the status of a terminated process. This
  39. type is used in `struct utmp' below. */
  40. struct exit_status
  41. {
  42. short int e_termination; /* Process termination status. */
  43. short int e_exit; /* Process exit status. */
  44. };
  45. /* The structure describing an entry in the user accounting database. */
  46. struct utmp
  47. {
  48. short int ut_type; /* Type of login. */
  49. pid_t ut_pid; /* Process ID of login process. */
  50. char ut_line[UT_LINESIZE]; /* Devicename. */
  51. char ut_id[4]; /* Inittab ID. */
  52. char ut_user[UT_NAMESIZE]; /* Username. */
  53. char ut_host[UT_HOSTSIZE]; /* Hostname for remote login. */
  54. struct exit_status ut_exit; /* Exit status of a process marked
  55. as DEAD_PROCESS. */
  56. /* The ut_session and ut_tv fields must be the same size when compiled
  57. 32- and 64-bit. This allows data files and shared memory to be
  58. shared between 32- and 64-bit applications. */
  59. #ifdef __WORDSIZE_TIME64_COMPAT32
  60. int32_t ut_session; /* Session ID, used for windowing. */
  61. struct
  62. {
  63. int32_t tv_sec; /* Seconds. */
  64. int32_t tv_usec; /* Microseconds. */
  65. } ut_tv; /* Time entry was made. */
  66. #else
  67. long int ut_session; /* Session ID, used for windowing. */
  68. struct timeval ut_tv; /* Time entry was made. */
  69. #endif
  70. int32_t ut_addr_v6[4]; /* Internet address of remote host. */
  71. char __uclibc_unused[20]; /* Reserved for future use. */
  72. };
  73. /* Backwards compatibility hacks. */
  74. #define ut_name ut_user
  75. #ifndef _NO_UT_TIME
  76. /* We have a problem here: `ut_time' is also used otherwise. Define
  77. _NO_UT_TIME if the compiler complains. */
  78. # define ut_time ut_tv.tv_sec
  79. #endif
  80. #define ut_xtime ut_tv.tv_sec
  81. #define ut_addr ut_addr_v6[0]
  82. /* Values for the `ut_type' field of a `struct utmp'. */
  83. #define EMPTY 0 /* No valid user accounting information. */
  84. #define RUN_LVL 1 /* The system's runlevel. */
  85. #define BOOT_TIME 2 /* Time of system boot. */
  86. #define NEW_TIME 3 /* Time after system clock changed. */
  87. #define OLD_TIME 4 /* Time when system clock changed. */
  88. #define INIT_PROCESS 5 /* Process spawned by the init process. */
  89. #define LOGIN_PROCESS 6 /* Session leader of a logged in user. */
  90. #define USER_PROCESS 7 /* Normal process. */
  91. #define DEAD_PROCESS 8 /* Terminated process. */
  92. #define ACCOUNTING 9
  93. /* Old Linux name for the EMPTY type. */
  94. #define UT_UNKNOWN EMPTY
  95. /* Tell the user that we have a modern system with UT_HOST, UT_PID,
  96. UT_TYPE, UT_ID and UT_TV fields. */
  97. #define _HAVE_UT_TYPE 1
  98. #define _HAVE_UT_PID 1
  99. #define _HAVE_UT_ID 1
  100. #define _HAVE_UT_TV 1
  101. #define _HAVE_UT_HOST 1