PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

include/utmpx.h

http://www.minix3.org/
C Header | 159 lines | 94 code | 21 blank | 44 comment | 0 complexity | bb361e927b201ebb0be46264bed6fa7c MD5 | raw file
Possible License(s): MIT, WTFPL, AGPL-1.0, BSD-3-Clause, GPL-3.0, LGPL-2.0, JSON, 0BSD
  1. /* $NetBSD: utmpx.h,v 1.17 2009/01/11 19:09:29 christos Exp $ */
  2. /*-
  3. * Copyright (c) 2002 The NetBSD Foundation, Inc.
  4. * All rights reserved.
  5. *
  6. * This code is derived from software contributed to The NetBSD Foundation
  7. * by Christos Zoulas.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  19. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  20. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  21. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  22. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  23. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  24. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  25. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  26. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  28. * POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef _UTMPX_H_
  31. #define _UTMPX_H_
  32. #include <sys/cdefs.h>
  33. #include <sys/featuretest.h>
  34. #include <sys/socket.h>
  35. #include <sys/time.h>
  36. #define _PATH_UTMPX "/var/run/utmpx"
  37. #define _PATH_WTMPX "/var/log/wtmpx"
  38. #define _PATH_LASTLOGX "/var/log/lastlogx"
  39. #define _PATH_UTMP_UPDATE "/usr/libexec/utmp_update"
  40. #define _UTX_USERSIZE 32
  41. #define _UTX_LINESIZE 32
  42. #define _UTX_IDSIZE 4
  43. #define _UTX_HOSTSIZE 256
  44. #if defined(_NETBSD_SOURCE)
  45. #define UTX_USERSIZE _UTX_USERSIZE
  46. #define UTX_LINESIZE _UTX_LINESIZE
  47. #define UTX_IDSIZE _UTX_IDSIZE
  48. #define UTX_HOSTSIZE _UTX_HOSTSIZE
  49. #endif
  50. #define EMPTY 0
  51. #define RUN_LVL 1
  52. #define BOOT_TIME 2
  53. #define OLD_TIME 3
  54. #define NEW_TIME 4
  55. #define INIT_PROCESS 5
  56. #define LOGIN_PROCESS 6
  57. #define USER_PROCESS 7
  58. #define DEAD_PROCESS 8
  59. #if defined(_NETBSD_SOURCE)
  60. #define ACCOUNTING 9
  61. #define SIGNATURE 10
  62. #define DOWN_TIME 11
  63. /*
  64. * Strings placed in the ut_line field to indicate special type entries
  65. */
  66. #define RUNLVL_MSG "run-level %c"
  67. #define BOOT_MSG "system boot"
  68. #define OTIME_MSG "old time"
  69. #define NTIME_MSG "new time"
  70. #define DOWN_MSG "system down"
  71. #endif
  72. /*
  73. * The following structure describes the fields of the utmpx entries
  74. * stored in _PATH_UTMPX or _PATH_WTMPX. This is not the format the
  75. * entries are stored in the files, and application should only access
  76. * entries using routines described in getutxent(3).
  77. */
  78. #define ut_user ut_name
  79. #define ut_xtime ut_tv.tv_sec
  80. /*
  81. * This should be:
  82. * 40 - (sizeof(struct timeval) - sizeof(struct { long s; long u; })))
  83. * but g++ does not like it, to retain size compatibility with v1.00,
  84. * so we do it manually.
  85. */
  86. #ifdef _LP64
  87. #define _UTX_PADSIZE 36
  88. #else
  89. #define _UTX_PADSIZE 40
  90. #endif
  91. struct utmpx {
  92. char ut_name[_UTX_USERSIZE]; /* login name */
  93. char ut_id[_UTX_IDSIZE]; /* inittab id */
  94. char ut_line[_UTX_LINESIZE]; /* tty name */
  95. char ut_host[_UTX_HOSTSIZE]; /* host name */
  96. uint16_t ut_session; /* session id used for windowing */
  97. uint16_t ut_type; /* type of this entry */
  98. pid_t ut_pid; /* process id creating the entry */
  99. struct {
  100. uint16_t e_termination; /* process termination signal */
  101. uint16_t e_exit; /* process exit status */
  102. } ut_exit;
  103. struct sockaddr_storage ut_ss; /* address where entry was made from */
  104. struct timeval ut_tv; /* time entry was created */
  105. uint8_t ut_pad[_UTX_PADSIZE]; /* reserved for future use */
  106. };
  107. #if defined(_NETBSD_SOURCE)
  108. struct lastlogx {
  109. struct timeval ll_tv; /* time entry was created */
  110. char ll_line[_UTX_LINESIZE]; /* tty name */
  111. char ll_host[_UTX_HOSTSIZE]; /* host name */
  112. struct sockaddr_storage ll_ss; /* address where entry was made from */
  113. };
  114. #endif /* !_XOPEN_SOURCE */
  115. __BEGIN_DECLS
  116. void setutxent(void);
  117. void endutxent(void);
  118. #ifndef __LIBC12_SOURCE__
  119. struct utmpx *getutxent(void) __RENAME(__getutxent50);
  120. struct utmpx *getutxid(const struct utmpx *) __RENAME(__getutxid50);
  121. struct utmpx *getutxline(const struct utmpx *) __RENAME(__getutxline50);
  122. struct utmpx *pututxline(const struct utmpx *) __RENAME(__pututxline50);
  123. #endif
  124. #if defined(_NETBSD_SOURCE)
  125. #ifndef __LIBC12_SOURCE__
  126. int updwtmpx(const char *, const struct utmpx *) __RENAME(__updwtmpx50);
  127. struct lastlogx *getlastlogx(const char *, uid_t, struct lastlogx *)
  128. __RENAME(__getlastlogx50);
  129. int updlastlogx(const char *, uid_t, struct lastlogx *)
  130. __RENAME(__updlastlogx50);
  131. struct utmp;
  132. void getutmp(const struct utmpx *, struct utmp *) __RENAME(__getutmp50);
  133. void getutmpx(const struct utmp *, struct utmpx *) __RENAME(__getutmpx50);
  134. #endif
  135. int utmpxname(const char *);
  136. #endif /* _NETBSD_SOURCE */
  137. __END_DECLS
  138. #endif /* !_UTMPX_H_ */