utxent.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * utexent.c : Support for accessing user accounting database.
  3. * Copyright (C) 2010 STMicroelectronics Ltd.
  4. *
  5. * Author: Salvatore Cro <salvatore.cro@st.com>
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. *
  9. */
  10. #include <features.h>
  11. #include <string.h>
  12. #include <utmpx.h>
  13. #include <utmp.h>
  14. #if 0 /* moved to utent.c */
  15. void setutxent(void)
  16. {
  17. setutent ();
  18. }
  19. void endutxent(void)
  20. {
  21. endutent ();
  22. }
  23. struct utmpx *getutxent(void)
  24. {
  25. return (struct utmpx *) getutent ();
  26. }
  27. struct utmpx *getutxid(const struct utmpx *utmp_entry)
  28. {
  29. return (struct utmpx *) getutid ((const struct utmp *) utmp_entry);
  30. }
  31. struct utmpx *getutxline(const struct utmpx *utmp_entry)
  32. {
  33. return (struct utmpx *) getutline ((const struct utmp *) utmp_entry);
  34. }
  35. struct utmpx *pututxline (const struct utmpx *utmp_entry)
  36. {
  37. return (struct utmpx *) pututline ((const struct utmp *) utmp_entry);
  38. }
  39. int utmpxname (const char *new_ut_name)
  40. {
  41. return utmpname (new_ut_name);
  42. }
  43. /* moved to wtent.c */
  44. void updwtmpx (const char *wtmpx_file, const struct utmpx *utmpx)
  45. {
  46. updwtmp (wtmpx_file, (const struct utmp *) utmpx);
  47. }
  48. #endif
  49. /* Copy the information in UTMPX to UTMP. */
  50. void getutmp (const struct utmpx *utmpx, struct utmp *utmp)
  51. {
  52. #if _HAVE_UT_TYPE - 0
  53. utmp->ut_type = utmpx->ut_type;
  54. #endif
  55. #if _HAVE_UT_PID - 0
  56. utmp->ut_pid = utmpx->ut_pid;
  57. #endif
  58. memcpy (utmp->ut_line, utmpx->ut_line, sizeof (utmp->ut_line));
  59. memcpy (utmp->ut_user, utmpx->ut_user, sizeof (utmp->ut_user));
  60. #if _HAVE_UT_ID - 0
  61. memcpy (utmp->ut_id, utmpx->ut_id, sizeof (utmp->ut_id));
  62. #endif
  63. #if _HAVE_UT_HOST - 0
  64. memcpy (utmp->ut_host, utmpx->ut_host, sizeof (utmp->ut_host));
  65. #endif
  66. #if _HAVE_UT_TV - 0
  67. utmp->ut_tv.tv_sec = utmpx->ut_tv.tv_sec;
  68. utmp->ut_tv.tv_usec = utmpx->ut_tv.tv_usec;
  69. #else
  70. utmp->ut_time = utmpx->ut_time;
  71. #endif
  72. }
  73. /* Copy the information in UTMP to UTMPX. */
  74. void getutmpx (const struct utmp *utmp, struct utmpx *utmpx)
  75. {
  76. memset (utmpx, 0, sizeof (struct utmpx));
  77. #if _HAVE_UT_TYPE - 0
  78. utmpx->ut_type = utmp->ut_type;
  79. #endif
  80. #if _HAVE_UT_PID - 0
  81. utmpx->ut_pid = utmp->ut_pid;
  82. #endif
  83. memcpy (utmpx->ut_line, utmp->ut_line, sizeof (utmp->ut_line));
  84. memcpy (utmpx->ut_user, utmp->ut_user, sizeof (utmp->ut_user));
  85. #if _HAVE_UT_ID - 0
  86. memcpy (utmpx->ut_id, utmp->ut_id, sizeof (utmp->ut_id));
  87. #endif
  88. #if _HAVE_UT_HOST - 0
  89. memcpy (utmpx->ut_host, utmp->ut_host, sizeof (utmp->ut_host));
  90. #endif
  91. #if _HAVE_UT_TV - 0
  92. utmpx->ut_tv.tv_sec = utmp->ut_tv.tv_sec;
  93. utmpx->ut_tv.tv_usec = utmp->ut_tv.tv_usec;
  94. #else
  95. utmpx->ut_time = utmp->ut_time;
  96. #endif
  97. }