2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-32 / utmp-convert.h
blob4fb77faa9a6623111f769eac6229fb685ac8b134
1 /* Copyright (C) 2008 Free Software Foundation, Inc.
2 Contributed by Andreas Krebbel <Andreas.Krebbel@de.ibm.com>.
3 This file is part of the GNU C Library.
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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
22 /* This file provides functions converting between the 32 and 64 bit
23 struct utmp variants. */
25 #ifndef _UTMP_CONVERT_H
26 #define _UTMP_CONVERT_H 1
28 #include <string.h>
30 #include "utmp32.h"
32 /* Convert the 64 bit struct utmp value in FROM to the 32 bit version
33 returned in TO. */
34 static inline void
35 utmp_convert64to32 (__const struct utmp *from, struct utmp32 *to)
37 #if _HAVE_UT_TYPE - 0
38 to->ut_type = from->ut_type;
39 #endif
40 #if _HAVE_UT_PID - 0
41 to->ut_pid = from->ut_pid;
42 #endif
43 memcpy (to->ut_line, from->ut_line, UT_LINESIZE);
44 memcpy (to->ut_user, from->ut_user, UT_NAMESIZE);
45 #if _HAVE_UT_ID - 0
46 memcpy (to->ut_id, from->ut_id, 4);
47 #endif
48 #if _HAVE_UT_HOST - 0
49 memcpy (to->ut_host, from->ut_host, UT_HOSTSIZE);
50 #endif
51 to->ut_exit = from->ut_exit;
52 to->ut_session = (int32_t) from->ut_session;
53 #if _HAVE_UT_TV - 0
54 to->ut_tv.tv_sec = (int32_t) from->ut_tv.tv_sec;
55 to->ut_tv.tv_usec = (int32_t) from->ut_tv.tv_usec;
56 #endif
57 memcpy (to->ut_addr_v6, from->ut_addr_v6, 4 * 4);
60 /* Convert the 32 bit struct utmp value in FROM to the 64 bit version
61 returned in TO. */
62 static inline void
63 utmp_convert32to64 (__const struct utmp32 *from, struct utmp *to)
65 #if _HAVE_UT_TYPE - 0
66 to->ut_type = from->ut_type;
67 #endif
68 #if _HAVE_UT_PID - 0
69 to->ut_pid = from->ut_pid;
70 #endif
71 memcpy (to->ut_line, from->ut_line, UT_LINESIZE);
72 memcpy (to->ut_user, from->ut_user, UT_NAMESIZE);
73 #if _HAVE_UT_ID - 0
74 memcpy (to->ut_id, from->ut_id, 4);
75 #endif
76 #if _HAVE_UT_HOST - 0
77 memcpy (to->ut_host, from->ut_host, UT_HOSTSIZE);
78 #endif
79 to->ut_exit = from->ut_exit;
80 to->ut_session = (int64_t) from->ut_session;
81 #if _HAVE_UT_TV - 0
82 to->ut_tv.tv_sec = (int64_t) from->ut_tv.tv_sec;
83 to->ut_tv.tv_usec = (int64_t) from->ut_tv.tv_usec;
84 #endif
85 memcpy (to->ut_addr_v6, from->ut_addr_v6, 4 * 4);
88 #endif /* utmp-convert.h */