]>
Commit | Line | Data |
---|---|---|
04277e02 | 1 | /* Copyright (C) 2008-2019 Free Software Foundation, Inc. |
4057dc45 UD |
2 | Contributed by Andreas Krebbel <Andreas.Krebbel@de.ibm.com>. |
3 | This file is part of the GNU C Library. | |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
59ba27a6 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
4057dc45 UD |
18 | |
19 | ||
20 | /* This file provides functions converting between the 32 and 64 bit | |
21 | struct utmp variants. */ | |
22 | ||
23 | #ifndef _UTMPX_CONVERT_H | |
24 | #define _UTMPX_CONVERT_H 1 | |
25 | ||
26 | #include <string.h> | |
27 | #include "utmpx32.h" | |
28 | ||
29 | /* Convert the 64 bit struct utmpx value in FROM to the 32 bit version | |
30 | returned in TO. */ | |
31 | static inline void | |
32 | utmpx_convert64to32 (const struct utmpx *from, struct utmpx32 *to) | |
33 | { | |
34 | #if _HAVE_UT_TYPE - 0 | |
35 | to->ut_type = from->ut_type; | |
36 | #endif | |
37 | #if _HAVE_UT_PID - 0 | |
38 | to->ut_pid = from->ut_pid; | |
39 | #endif | |
40 | memcpy (to->ut_line, from->ut_line, __UT_LINESIZE); | |
41 | memcpy (to->ut_user, from->ut_user, __UT_NAMESIZE); | |
42 | #if _HAVE_UT_ID - 0 | |
43 | memcpy (to->ut_id, from->ut_id, 4); | |
44 | #endif | |
45 | #if _HAVE_UT_HOST - 0 | |
46 | memcpy (to->ut_host, from->ut_host, __UT_HOSTSIZE); | |
47 | #endif | |
48 | to->ut_exit = from->ut_exit; | |
49 | to->ut_session = (int32_t) from->ut_session; | |
50 | #if _HAVE_UT_TV - 0 | |
51 | to->ut_tv.tv_sec = (int32_t) from->ut_tv.tv_sec; | |
52 | to->ut_tv.tv_usec = (int32_t) from->ut_tv.tv_usec; | |
53 | #endif | |
54 | memcpy (to->ut_addr_v6, from->ut_addr_v6, 4 * 4); | |
55 | } | |
56 | ||
57 | /* Convert the 32 bit struct utmpx value in FROM to the 64 bit version | |
58 | returned in TO. */ | |
59 | static inline void | |
60 | utmpx_convert32to64 (const struct utmpx32 *from, struct utmpx *to) | |
61 | { | |
62 | #if _HAVE_UT_TYPE - 0 | |
63 | to->ut_type = from->ut_type; | |
64 | #endif | |
65 | #if _HAVE_UT_PID - 0 | |
66 | to->ut_pid = from->ut_pid; | |
67 | #endif | |
68 | memcpy (to->ut_line, from->ut_line, __UT_LINESIZE); | |
69 | memcpy (to->ut_user, from->ut_user, __UT_NAMESIZE); | |
70 | #if _HAVE_UT_ID - 0 | |
71 | memcpy (to->ut_id, from->ut_id, 4); | |
72 | #endif | |
73 | #if _HAVE_UT_HOST - 0 | |
74 | memcpy (to->ut_host, from->ut_host, __UT_HOSTSIZE); | |
75 | #endif | |
76 | to->ut_exit = from->ut_exit; | |
77 | to->ut_session = (int64_t) from->ut_session; | |
78 | #if _HAVE_UT_TV - 0 | |
79 | to->ut_tv.tv_sec = (int64_t) from->ut_tv.tv_sec; | |
80 | to->ut_tv.tv_usec = (int64_t) from->ut_tv.tv_usec; | |
81 | #endif | |
82 | memcpy (to->ut_addr_v6, from->ut_addr_v6, 4 * 4); | |
83 | } | |
84 | ||
85 | #endif /* utmpx-convert.h */ |