utmp.h 3.4 KB

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