utmpx.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Structures and definitions for the user accounting database. GNU version.
  17. Copyright (C) 1997-2026 Free Software Foundation, Inc.
  18. This file is part of the GNU C Library.
  19. The GNU C Library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU Lesser General Public
  21. License as published by the Free Software Foundation; either
  22. version 2.1 of the License, or (at your option) any later version.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <https://www.gnu.org/licenses/>. */
  30. #ifndef _UTMPX_H
  31. # error "Never include <bits/utmpx.h> directly; use <utmpx.h> instead."
  32. #endif
  33. #include <bits/types.h>
  34. #include <sys/time.h>
  35. #include <bits/wordsize.h>
  36. #ifdef __USE_GNU
  37. # include <paths.h>
  38. # define _PATH_UTMPX _PATH_UTMP
  39. # define _PATH_WTMPX _PATH_WTMP
  40. #endif
  41. #define __UT_LINESIZE 32
  42. #define __UT_NAMESIZE 32
  43. #define __UT_HOSTSIZE 256
  44. /* The structure describing the status of a terminated process. This
  45. type is used in `struct utmpx' below. */
  46. struct __exit_status
  47. {
  48. #ifdef __USE_GNU
  49. short int e_termination; /* Process termination status. */
  50. short int e_exit; /* Process exit status. */
  51. #else
  52. short int __e_termination; /* Process termination status. */
  53. short int __e_exit; /* Process exit status. */
  54. #endif
  55. };
  56. /* The structure describing an entry in the user accounting database. */
  57. struct utmpx
  58. {
  59. short int ut_type; /* Type of login. */
  60. __pid_t ut_pid; /* Process ID of login process. */
  61. char ut_line[__UT_LINESIZE]
  62. __attribute_nonstring__; /* Devicename. */
  63. char ut_id[4]
  64. __attribute_nonstring__; /* Inittab ID. */
  65. char ut_user[__UT_NAMESIZE]
  66. __attribute_nonstring__; /* Username. */
  67. char ut_host[__UT_HOSTSIZE]
  68. __attribute_nonstring__; /* Hostname for remote login. */
  69. struct __exit_status ut_exit; /* Exit status of a process marked
  70. as DEAD_PROCESS. */
  71. /* The fields ut_session and ut_tv must be the same size when compiled
  72. 32- and 64-bit. This allows files and shared memory to be shared
  73. between 32- and 64-bit applications. */
  74. #if __WORDSIZE_TIME64_COMPAT32
  75. __int32_t ut_session; /* Session ID, used for windowing. */
  76. struct
  77. {
  78. __uint32_t tv_sec; /* Seconds. */
  79. __int32_t tv_usec; /* Microseconds. */
  80. } ut_tv; /* Time entry was made. */
  81. #else
  82. long int ut_session; /* Session ID, used for windowing. */
  83. struct timeval ut_tv; /* Time entry was made. */
  84. #endif
  85. __int32_t ut_addr_v6[4]; /* Internet address of remote host. */
  86. char __glibc_reserved[20]; /* Reserved for future use. */
  87. };
  88. /* Values for the `ut_type' field of a `struct utmpx'. */
  89. #define EMPTY 0 /* No valid user accounting information. */
  90. #ifdef __USE_GNU
  91. # define RUN_LVL 1 /* The system's runlevel. */
  92. #endif
  93. #define BOOT_TIME 2 /* Time of system boot. */
  94. #define NEW_TIME 3 /* Time after system clock changed. */
  95. #define OLD_TIME 4 /* Time when system clock changed. */
  96. #define INIT_PROCESS 5 /* Process spawned by the init process. */
  97. #define LOGIN_PROCESS 6 /* Session leader of a logged in user. */
  98. #define USER_PROCESS 7 /* Normal process. */
  99. #define DEAD_PROCESS 8 /* Terminated process. */
  100. #ifdef __USE_GNU
  101. # define ACCOUNTING 9 /* System accounting. */
  102. #endif