]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/s390/s390-32/utmp32.c
1 /* Copyright (C) 2008-2021 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, see
17 <https://www.gnu.org/licenses/>. */
19 #include <sys/types.h>
25 #include "utmp-convert.h"
27 /* Allocate a static buffer to be returned to the caller. As well as
28 with the existing version of these functions the caller has to be
29 aware that the contents of this buffer will change with subsequent
31 #define ALLOCATE_UTMP32_OUT(OUT) \
32 static struct utmp32 *OUT = NULL; \
36 OUT = malloc (sizeof (struct utmp32)); \
41 /* Perform a lookup for a utmp entry matching FIELD using function
42 FUNC. FIELD is converted to a 64 bit utmp and the result is
43 converted back to 32 bit utmp. */
44 #define ACCESS_UTMP_ENTRY(FUNC, FIELD) \
47 ALLOCATE_UTMP32_OUT (out32); \
49 utmp_convert32to64 (FIELD, &in64); \
50 out64 = FUNC (&in64); \
55 utmp_convert64to32 (out64, out32); \
59 /* Search forward from the current point in the utmp file until the
60 next entry with a ut_type matching ID->ut_type. */
62 getutid32 (const struct utmp32
*id
)
64 ACCESS_UTMP_ENTRY (__getutid
, id
)
66 symbol_version (getutid32
, getutid
, GLIBC_2
.0
);
68 /* Search forward from the current point in the utmp file until the
69 next entry with a ut_line matching LINE->ut_line. */
71 getutline32 (const struct utmp32
*line
)
73 ACCESS_UTMP_ENTRY (__getutline
, line
)
75 symbol_version (getutline32
, getutline
, GLIBC_2
.0
);
77 /* Write out entry pointed to by UTMP_PTR into the utmp file. */
79 pututline32 (const struct utmp32
*utmp_ptr
)
81 ACCESS_UTMP_ENTRY (__pututline
, utmp_ptr
)
83 symbol_version (pututline32
, pututline
, GLIBC_2
.0
);
85 /* Read next entry from a utmp-like file. */
90 ALLOCATE_UTMP32_OUT (out32
);
92 out64
= __getutent ();
96 utmp_convert64to32 (out64
, out32
);
99 symbol_version (getutent32
, getutent
, GLIBC_2
.0
);
101 /* Reentrant versions of the file for handling utmp files. */
104 getutent32_r (struct utmp32
*buffer
, struct utmp32
**result
)
110 ret
= __getutent_r (&out64
, &out64p
);
117 utmp_convert64to32 (out64p
, buffer
);
122 symbol_version (getutent32_r
, getutent_r
, GLIBC_2
.0
);
125 getutid32_r (const struct utmp32
*id
, struct utmp32
*buffer
,
126 struct utmp32
**result
)
133 utmp_convert32to64 (id
, &in64
);
135 ret
= __getutid_r (&in64
, &out64
, &out64p
);
142 utmp_convert64to32 (out64p
, buffer
);
147 symbol_version (getutid32_r
, getutid_r
, GLIBC_2
.0
);
150 getutline32_r (const struct utmp32
*line
,
151 struct utmp32
*buffer
, struct utmp32
**result
)
158 utmp_convert32to64 (line
, &in64
);
160 ret
= __getutline_r (&in64
, &out64
, &out64p
);
167 utmp_convert64to32 (out64p
, buffer
);
173 symbol_version (getutline32_r
, getutline_r
, GLIBC_2
.0
);
175 /* Append entry UTMP to the wtmp-like file WTMP_FILE. */
177 updwtmp32 (const char *wtmp_file
, const struct utmp32
*utmp
)
181 utmp_convert32to64 (utmp
, &in32
);
182 __updwtmp (wtmp_file
, &in32
);
184 symbol_version (updwtmp32
, updwtmp
, GLIBC_2
.0
);