utmp.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * internal helper for utmp and utmpx handling
  4. *
  5. * Copyright (C) 2015 by Bernhard Reutner-Fischer
  6. *
  7. * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  8. */
  9. #ifndef __INTERNAL_UTMP_H
  10. #define __INTERNAL_UTMP_H
  11. #include <utmpx.h>
  12. #include <utmp.h>
  13. /* Note: _PATH_UTMPX == _PATH_UTMP */
  14. #if (defined __UCLIBC_HAS_UTMPX__ && defined __UCLIBC_HAS_UTMP__) \
  15. || !defined __UCLIBC_HAS_UTMP__
  16. /* implement the X and alias the non-X */
  17. # define __set_unlocked __setutxent_unlocked
  18. # define set setutxent
  19. # define __get_unlocked __getutxent_unlocked
  20. # define get getutxent
  21. # define end endutxent
  22. # define __getid_unlocked __getutxid_unlocked
  23. # define getid getutxid
  24. # define getline getutxline
  25. # define putline pututxline
  26. # define name utmpxname
  27. # define updw updwtmpx
  28. # define UT utmpx
  29. # ifndef __DEFAULT_PATH_UTMP
  30. # define __DEFAULT_PATH_UTMP _PATH_UTMPX
  31. # endif
  32. # if defined __UCLIBC_HAS_UTMP__
  33. # define other(n,a) strong_alias_untyped(n,a)
  34. # else
  35. # define other(n,a) /* nothing */
  36. # endif
  37. #elif defined __UCLIBC_HAS_UTMP__
  38. # define __set_unlocked __setutent_unlocked
  39. # define set setutent
  40. # define __get_unlocked __getutent_unlocked
  41. # define get getutent
  42. # define end endutent
  43. # define __getid_unlocked __getutid_unlocked
  44. # define getid getutid
  45. # define getline getutline
  46. # define putline pututline
  47. # define name utmpname
  48. # define updw updwtmp
  49. # define UT utmp
  50. # ifndef __DEFAULT_PATH_UTMP
  51. # define __DEFAULT_PATH_UTMP _PATH_UTMP
  52. # endif
  53. # define other(n,a) /* nothing */
  54. #else
  55. #error You are supposed to either have UTMP or UTMPX or both here
  56. #endif
  57. /* not used in libc_hidden_proto(setutxent) */
  58. /* not used in libc_hidden_proto(endutxent) */
  59. /* not used in libc_hidden_proto(getutxent) */
  60. /* not used in libc_hidden_proto(getutxid) */
  61. /* not used in libc_hidden_proto(getutxline) */
  62. /* not used in libc_hidden_proto(pututxline) */
  63. /* not used in libc_hidden_proto(utmpxname) */
  64. /* not used in libc_hidden_proto(updwtmpx) */
  65. /* not used in libc_hidden_proto(setutent) */
  66. /* not used in libc_hidden_proto(endutent) */
  67. /* not used in libc_hidden_proto(getutent) */
  68. /* not used in libc_hidden_proto(getutid) */
  69. /* not used in libc_hidden_proto(getutline) */
  70. /* not used in libc_hidden_proto(pututline) */
  71. /* not used in libc_hidden_proto(utmpname) */
  72. /* not used in libc_hidden_proto(updwtmp) */
  73. #ifdef IS_IN_libutil
  74. # if (defined __UCLIBC_HAS_UTMPX__ && defined __UCLIBC_HAS_UTMP__) \
  75. || !defined __UCLIBC_HAS_UTMP__
  76. /* monkey-patch to use the POSIX interface */
  77. # define setutent setutxent
  78. # define getutline getutxline
  79. # define pututline pututxline
  80. # define endutent endutxent
  81. # define updwtmp updwtmpx
  82. # endif
  83. #endif /* IS_IN_libutil */
  84. #endif /* __INTERNAL_UTMP_H */