]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/s390/s390-32/utmp-convert.h
877cbc4517d3051d97411725066b02dff6b4e0d4
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-32 / utmp-convert.h
1 /* Copyright (C) 2008-2018 Free Software Foundation, Inc.
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
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19
20 /* This file provides functions converting between the 32 and 64 bit
21 struct utmp variants. */
22
23 #ifndef _UTMP_CONVERT_H
24 #define _UTMP_CONVERT_H 1
25
26 #include <string.h>
27
28 #include "utmp32.h"
29
30 /* Convert the 64 bit struct utmp value in FROM to the 32 bit version
31 returned in TO. */
32 static inline void
33 utmp_convert64to32 (const struct utmp *from, struct utmp32 *to)
34 {
35 #if _HAVE_UT_TYPE - 0
36 to->ut_type = from->ut_type;
37 #endif
38 #if _HAVE_UT_PID - 0
39 to->ut_pid = from->ut_pid;
40 #endif
41 memcpy (to->ut_line, from->ut_line, UT_LINESIZE);
42 memcpy (to->ut_user, from->ut_user, UT_NAMESIZE);
43 #if _HAVE_UT_ID - 0
44 memcpy (to->ut_id, from->ut_id, 4);
45 #endif
46 #if _HAVE_UT_HOST - 0
47 memcpy (to->ut_host, from->ut_host, UT_HOSTSIZE);
48 #endif
49 to->ut_exit = from->ut_exit;
50 to->ut_session = (int32_t) from->ut_session;
51 #if _HAVE_UT_TV - 0
52 to->ut_tv.tv_sec = (int32_t) from->ut_tv.tv_sec;
53 to->ut_tv.tv_usec = (int32_t) from->ut_tv.tv_usec;
54 #endif
55 memcpy (to->ut_addr_v6, from->ut_addr_v6, 4 * 4);
56 }
57
58 /* Convert the 32 bit struct utmp value in FROM to the 64 bit version
59 returned in TO. */
60 static inline void
61 utmp_convert32to64 (const struct utmp32 *from, struct utmp *to)
62 {
63 #if _HAVE_UT_TYPE - 0
64 to->ut_type = from->ut_type;
65 #endif
66 #if _HAVE_UT_PID - 0
67 to->ut_pid = from->ut_pid;
68 #endif
69 memcpy (to->ut_line, from->ut_line, UT_LINESIZE);
70 memcpy (to->ut_user, from->ut_user, UT_NAMESIZE);
71 #if _HAVE_UT_ID - 0
72 memcpy (to->ut_id, from->ut_id, 4);
73 #endif
74 #if _HAVE_UT_HOST - 0
75 memcpy (to->ut_host, from->ut_host, UT_HOSTSIZE);
76 #endif
77 to->ut_exit = from->ut_exit;
78 to->ut_session = (int64_t) from->ut_session;
79 #if _HAVE_UT_TV - 0
80 to->ut_tv.tv_sec = (int64_t) from->ut_tv.tv_sec;
81 to->ut_tv.tv_usec = (int64_t) from->ut_tv.tv_usec;
82 #endif
83 memcpy (to->ut_addr_v6, from->ut_addr_v6, 4 * 4);
84 }
85
86 #endif /* utmp-convert.h */