lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 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 | |
| 11 | #include <features.h> |
| 12 | #include <string.h> |
| 13 | #include <utmpx.h> |
| 14 | #include <utmp.h> |
| 15 | |
| 16 | void setutxent(void) |
| 17 | { |
| 18 | setutent (); |
| 19 | } |
| 20 | |
| 21 | void endutxent(void) |
| 22 | { |
| 23 | endutent (); |
| 24 | } |
| 25 | |
| 26 | struct utmpx *getutxent(void) |
| 27 | { |
| 28 | return (struct utmpx *) getutent (); |
| 29 | } |
| 30 | |
| 31 | struct utmpx *getutxid(const struct utmpx *utmp_entry) |
| 32 | { |
| 33 | return (struct utmpx *) getutid ((const struct utmp *) utmp_entry); |
| 34 | } |
| 35 | |
| 36 | struct utmpx *getutxline(const struct utmpx *utmp_entry) |
| 37 | { |
| 38 | return (struct utmpx *) getutline ((const struct utmp *) utmp_entry); |
| 39 | } |
| 40 | |
| 41 | struct utmpx *pututxline (const struct utmpx *utmp_entry) |
| 42 | { |
| 43 | return (struct utmpx *) pututline ((const struct utmp *) utmp_entry); |
| 44 | } |
| 45 | |
| 46 | int utmpxname (const char *new_ut_name) |
| 47 | { |
| 48 | return utmpname (new_ut_name); |
| 49 | } |
| 50 | |
| 51 | void updwtmpx (const char *wtmpx_file, const struct utmpx *utmpx) |
| 52 | { |
| 53 | updwtmp (wtmpx_file, (const struct utmp *) utmpx); |
| 54 | } |
| 55 | |
| 56 | /* Copy the information in UTMPX to UTMP. */ |
| 57 | void getutmp (const struct utmpx *utmpx, struct utmp *utmp) |
| 58 | { |
| 59 | #if _HAVE_UT_TYPE - 0 |
| 60 | utmp->ut_type = utmpx->ut_type; |
| 61 | #endif |
| 62 | #if _HAVE_UT_PID - 0 |
| 63 | utmp->ut_pid = utmpx->ut_pid; |
| 64 | #endif |
| 65 | memcpy (utmp->ut_line, utmpx->ut_line, sizeof (utmp->ut_line)); |
| 66 | memcpy (utmp->ut_user, utmpx->ut_user, sizeof (utmp->ut_user)); |
| 67 | #if _HAVE_UT_ID - 0 |
| 68 | memcpy (utmp->ut_id, utmpx->ut_id, sizeof (utmp->ut_id)); |
| 69 | #endif |
| 70 | #if _HAVE_UT_HOST - 0 |
| 71 | memcpy (utmp->ut_host, utmpx->ut_host, sizeof (utmp->ut_host)); |
| 72 | #endif |
| 73 | #if _HAVE_UT_TV - 0 |
| 74 | utmp->ut_tv.tv_sec = utmpx->ut_tv.tv_sec; |
| 75 | utmp->ut_tv.tv_usec = utmpx->ut_tv.tv_usec; |
| 76 | #else |
| 77 | utmp->ut_time = utmpx->ut_time; |
| 78 | #endif |
| 79 | } |
| 80 | |
| 81 | /* Copy the information in UTMP to UTMPX. */ |
| 82 | void getutmpx (const struct utmp *utmp, struct utmpx *utmpx) |
| 83 | { |
| 84 | memset (utmpx, 0, sizeof (struct utmpx)); |
| 85 | |
| 86 | #if _HAVE_UT_TYPE - 0 |
| 87 | utmpx->ut_type = utmp->ut_type; |
| 88 | #endif |
| 89 | #if _HAVE_UT_PID - 0 |
| 90 | utmpx->ut_pid = utmp->ut_pid; |
| 91 | #endif |
| 92 | memcpy (utmpx->ut_line, utmp->ut_line, sizeof (utmp->ut_line)); |
| 93 | memcpy (utmpx->ut_user, utmp->ut_user, sizeof (utmp->ut_user)); |
| 94 | #if _HAVE_UT_ID - 0 |
| 95 | memcpy (utmpx->ut_id, utmp->ut_id, sizeof (utmp->ut_id)); |
| 96 | #endif |
| 97 | #if _HAVE_UT_HOST - 0 |
| 98 | memcpy (utmpx->ut_host, utmp->ut_host, sizeof (utmp->ut_host)); |
| 99 | #endif |
| 100 | #if _HAVE_UT_TV - 0 |
| 101 | utmpx->ut_tv.tv_sec = utmp->ut_tv.tv_sec; |
| 102 | utmpx->ut_tv.tv_usec = utmp->ut_tv.tv_usec; |
| 103 | #else |
| 104 | utmpx->ut_time = utmp->ut_time; |
| 105 | #endif |
| 106 | } |
| 107 | |