| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#ifndef _UTMPX_CONVERT_H |
| 23 |
#define _UTMPX_CONVERT_H 1 |
| 24 |
|
| 25 |
#include <string.h> |
| 26 |
#include "utmpx32.h" |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
static inline void |
| 31 |
utmpx_convert64to32 (const struct utmpx *from, struct utmpx32 *to) |
| 32 |
{ |
| 33 |
#if _HAVE_UT_TYPE - 0 |
| 34 |
to->ut_type = from->ut_type; |
| 35 |
#endif |
| 36 |
#if _HAVE_UT_PID - 0 |
| 37 |
to->ut_pid = from->ut_pid; |
| 38 |
#endif |
| 39 |
memcpy (to->ut_line, from->ut_line, __UT_LINESIZE); |
| 40 |
memcpy (to->ut_user, from->ut_user, __UT_NAMESIZE); |
| 41 |
#if _HAVE_UT_ID - 0 |
| 42 |
memcpy (to->ut_id, from->ut_id, 4); |
| 43 |
#endif |
| 44 |
#if _HAVE_UT_HOST - 0 |
| 45 |
memcpy (to->ut_host, from->ut_host, __UT_HOSTSIZE); |
| 46 |
#endif |
| 47 |
to->ut_exit = from->ut_exit; |
| 48 |
to->ut_session = (int32_t) from->ut_session; |
| 49 |
#if _HAVE_UT_TV - 0 |
| 50 |
to->ut_tv.tv_sec = (int32_t) from->ut_tv.tv_sec; |
| 51 |
to->ut_tv.tv_usec = (int32_t) from->ut_tv.tv_usec; |
| 52 |
#endif |
| 53 |
memcpy (to->ut_addr_v6, from->ut_addr_v6, 4 * 4); |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
static inline void |
| 59 |
utmpx_convert32to64 (const struct utmpx32 *from, struct utmpx *to) |
| 60 |
{ |
| 61 |
#if _HAVE_UT_TYPE - 0 |
| 62 |
to->ut_type = from->ut_type; |
| 63 |
#endif |
| 64 |
#if _HAVE_UT_PID - 0 |
| 65 |
to->ut_pid = from->ut_pid; |
| 66 |
#endif |
| 67 |
memcpy (to->ut_line, from->ut_line, __UT_LINESIZE); |
| 68 |
memcpy (to->ut_user, from->ut_user, __UT_NAMESIZE); |
| 69 |
#if _HAVE_UT_ID - 0 |
| 70 |
memcpy (to->ut_id, from->ut_id, 4); |
| 71 |
#endif |
| 72 |
#if _HAVE_UT_HOST - 0 |
| 73 |
memcpy (to->ut_host, from->ut_host, __UT_HOSTSIZE); |
| 74 |
#endif |
| 75 |
to->ut_exit = from->ut_exit; |
| 76 |
to->ut_session = (int64_t) from->ut_session; |
| 77 |
#if _HAVE_UT_TV - 0 |
| 78 |
to->ut_tv.tv_sec = (int64_t) from->ut_tv.tv_sec; |
| 79 |
to->ut_tv.tv_usec = (int64_t) from->ut_tv.tv_usec; |
| 80 |
#endif |
| 81 |
memcpy (to->ut_addr_v6, from->ut_addr_v6, 4 * 4); |
| 82 |
} |
| 83 |
|
| 84 |
#endif |