Replace FSF snail mail address with URLs.
[glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-32 / utmpx32.c
bloba302cf32d0d6f9d36487d890d202a18fe0f7beaa
1 /* Copyright (C) 2008, 2010 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 <http://www.gnu.org/licenses/>. */
19 #include <sys/types.h>
20 #include <utmp.h>
21 #include <errno.h>
22 #include <libc-symbols.h>
24 #include "utmp32.h"
25 #include "utmp-convert.h"
27 #include "utmpx32.h"
28 #include "utmpx-convert.h"
30 /* Allocate a static buffer to be returned to the caller. As well as
31 with the existing version of these functions the caller has to be
32 aware that the contents of this buffer will change with subsequent
33 calls. */
34 #define ALLOCATE_UTMPX32_OUT(OUT) \
35 static struct utmpx32 *OUT = NULL; \
37 if (OUT == NULL) \
38 { \
39 OUT = malloc (sizeof (struct utmpx32)); \
40 if (OUT == NULL) \
41 return NULL; \
44 /* Perform a lookup for a utmpx entry matching FIELD using function
45 FUNC. FIELD is converted to a 64 bit utmpx and the result is
46 converted back to 32 bit utmpx. */
47 #define ACCESS_UTMPX_ENTRY(FUNC, FIELD) \
48 struct utmpx in64; \
49 struct utmpx *out64; \
50 ALLOCATE_UTMPX32_OUT (out32); \
52 utmpx_convert32to64 (FIELD, &in64); \
53 out64 = FUNC (&in64); \
55 if (out64 == NULL) \
56 return NULL; \
58 utmpx_convert64to32 (out64, out32); \
60 return out32;
63 /* Get the next entry from the user accounting database. */
64 struct utmpx32 *
65 getutxent32 (void)
67 struct utmpx *out64;
68 ALLOCATE_UTMPX32_OUT (out32);
70 out64 = __getutxent ();
71 if (!out64)
72 return NULL;
74 utmpx_convert64to32 (out64, out32);
75 return out32;
78 symbol_version (getutxent32, getutxent, GLIBC_2.1);
80 /* Get the user accounting database entry corresponding to ID. */
81 struct utmpx32 *
82 getutxid32 (const struct utmpx32 *id)
84 ACCESS_UTMPX_ENTRY (__getutxid, id);
86 symbol_version (getutxid32, getutxid, GLIBC_2.1);
88 /* Get the user accounting database entry corresponding to LINE. */
89 struct utmpx32 *
90 getutxline32 (const struct utmpx32 *line)
92 ACCESS_UTMPX_ENTRY (__getutxline, line);
94 symbol_version (getutxline32, getutxline, GLIBC_2.1);
96 /* Write the entry UTMPX into the user accounting database. */
97 struct utmpx32 *
98 pututxline32 (const struct utmpx32 *utmpx)
100 ACCESS_UTMPX_ENTRY (__pututxline, utmpx);
102 symbol_version (pututxline32, pututxline, GLIBC_2.1);
104 /* Append entry UTMP to the wtmpx-like file WTMPX_FILE. */
105 void
106 updwtmpx32 (const char *wtmpx_file, const struct utmpx32 *utmpx)
108 struct utmpx in64;
110 utmpx_convert32to64 (utmpx, &in64);
111 __updwtmpx (wtmpx_file, &in64);
113 symbol_version (updwtmpx32, updwtmpx, GLIBC_2.1);
115 /* Copy the information in UTMPX to UTMP. */
116 void
117 getutmp32 (const struct utmpx32 *utmpx, struct utmp32 *utmp)
119 struct utmpx in64;
120 struct utmp out64;
122 utmpx_convert32to64 (utmpx, &in64);
123 __getutmp (&in64, &out64);
124 utmp_convert64to32 (&out64, utmp);
126 symbol_version (getutmp32, getutmp, GLIBC_2.1.1);
128 /* Copy the information in UTMP to UTMPX. */
129 void
130 getutmpx32 (const struct utmp32 *utmp, struct utmpx32 *utmpx)
132 struct utmp in64;
133 struct utmpx out64;
135 utmp_convert32to64 (utmp, &in64);
136 __getutmpx (&in64, &out64);
137 utmpx_convert64to32 (&out64, utmpx);
139 symbol_version (getutmpx32, getutmpx, GLIBC_2.1.1);