utmp.h 2.7 KB

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