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
21 /* This file provides functions converting between the 32 and 64 bit
22 struct utmp variants. */
24 #ifndef _UTMPX_CONVERT_H
25 #define _UTMPX_CONVERT_H 1
30 /* Convert the 64 bit struct utmpx value in FROM to the 32 bit version
33 utmpx_convert64to32 (const struct utmpx
*from
, struct utmpx32
*to
)
36 to
->ut_type
= from
->ut_type
;
39 to
->ut_pid
= from
->ut_pid
;
41 memcpy (to
->ut_line
, from
->ut_line
, __UT_LINESIZE
);
42 memcpy (to
->ut_user
, from
->ut_user
, __UT_NAMESIZE
);
44 memcpy (to
->ut_id
, from
->ut_id
, 4);
47 memcpy (to
->ut_host
, from
->ut_host
, __UT_HOSTSIZE
);
49 to
->ut_exit
= from
->ut_exit
;
50 to
->ut_session
= (int32_t) from
->ut_session
;
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
;
55 memcpy (to
->ut_addr_v6
, from
->ut_addr_v6
, 4 * 4);
58 /* Convert the 32 bit struct utmpx value in FROM to the 64 bit version
61 utmpx_convert32to64 (const struct utmpx32
*from
, struct utmpx
*to
)
64 to
->ut_type
= from
->ut_type
;
67 to
->ut_pid
= from
->ut_pid
;
69 memcpy (to
->ut_line
, from
->ut_line
, __UT_LINESIZE
);
70 memcpy (to
->ut_user
, from
->ut_user
, __UT_NAMESIZE
);
72 memcpy (to
->ut_id
, from
->ut_id
, 4);
75 memcpy (to
->ut_host
, from
->ut_host
, __UT_HOSTSIZE
);
77 to
->ut_exit
= from
->ut_exit
;
78 to
->ut_session
= (int64_t) from
->ut_session
;
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
;
83 memcpy (to
->ut_addr_v6
, from
->ut_addr_v6
, 4 * 4);
86 #endif /* utmpx-convert.h */