1 /* Copyright (C) 2008-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
19 /* This file provides functions converting between the 32 and 64 bit
20 struct utmp variants. */
22 #ifndef _UTMP_CONVERT_H
23 #define _UTMP_CONVERT_H 1
29 /* Convert the 64 bit struct utmp value in FROM to the 32 bit version
32 utmp_convert64to32 (const struct utmp
*from
, struct utmp32
*to
)
35 to
->ut_type
= from
->ut_type
;
38 to
->ut_pid
= from
->ut_pid
;
40 memcpy (to
->ut_line
, from
->ut_line
, UT_LINESIZE
);
41 memcpy (to
->ut_user
, from
->ut_user
, UT_NAMESIZE
);
43 memcpy (to
->ut_id
, from
->ut_id
, 4);
46 memcpy (to
->ut_host
, from
->ut_host
, UT_HOSTSIZE
);
48 to
->ut_exit
= from
->ut_exit
;
49 to
->ut_session
= (int32_t) from
->ut_session
;
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
;
54 memcpy (to
->ut_addr_v6
, from
->ut_addr_v6
, 4 * 4);
57 /* Convert the 32 bit struct utmp value in FROM to the 64 bit version
60 utmp_convert32to64 (const struct utmp32
*from
, struct utmp
*to
)
63 to
->ut_type
= from
->ut_type
;
66 to
->ut_pid
= from
->ut_pid
;
68 memcpy (to
->ut_line
, from
->ut_line
, UT_LINESIZE
);
69 memcpy (to
->ut_user
, from
->ut_user
, UT_NAMESIZE
);
71 memcpy (to
->ut_id
, from
->ut_id
, 4);
74 memcpy (to
->ut_host
, from
->ut_host
, UT_HOSTSIZE
);
76 to
->ut_exit
= from
->ut_exit
;
77 to
->ut_session
= (int64_t) from
->ut_session
;
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
;
82 memcpy (to
->ut_addr_v6
, from
->ut_addr_v6
, 4 * 4);
85 #endif /* utmp-convert.h */