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
20 #include <sys/types.h>
23 #include <libc-symbols.h>
26 #include "utmp-convert.h"
29 #include "utmpx-convert.h"
31 /* Allocate a static buffer to be returned to the caller. As well as
32 with the existing version of these functions the caller has to be
33 aware that the contents of this buffer will change with subsequent
35 #define ALLOCATE_UTMPX32_OUT(OUT) \
36 static struct utmpx32 *OUT = NULL; \
40 OUT = malloc (sizeof (struct utmpx32)); \
45 /* Perform a lookup for a utmpx entry matching FIELD using function
46 FUNC. FIELD is converted to a 64 bit utmpx and the result is
47 converted back to 32 bit utmpx. */
48 #define ACCESS_UTMPX_ENTRY(FUNC, FIELD) \
50 struct utmpx *out64; \
51 ALLOCATE_UTMPX32_OUT (out32); \
53 utmpx_convert32to64 (FIELD, &in64); \
54 out64 = FUNC (&in64); \
59 utmpx_convert64to32 (out64, out32); \
64 /* Get the next entry from the user accounting database. */
69 ALLOCATE_UTMPX32_OUT (out32
);
75 utmpx_convert64to32 (out64
, out32
);
79 symbol_version (getutxent32
, getutxent
, GLIBC_2
.1
);
81 /* Get the user accounting database entry corresponding to ID. */
83 getutxid32 (const struct utmpx32
*id
)
85 ACCESS_UTMPX_ENTRY (getutxid
, id
);
87 symbol_version (getutxid32
, getutxid
, GLIBC_2
.1
);
89 /* Get the user accounting database entry corresponding to LINE. */
91 getutxline32 (const struct utmpx32
*line
)
93 ACCESS_UTMPX_ENTRY (getutxline
, line
);
95 symbol_version (getutxline32
, getutxline
, GLIBC_2
.1
);
97 /* Write the entry UTMPX into the user accounting database. */
99 pututxline32 (const struct utmpx32
*utmpx
)
101 ACCESS_UTMPX_ENTRY (pututxline
, utmpx
);
103 symbol_version (pututxline32
, pututxline
, GLIBC_2
.1
);
105 /* Append entry UTMP to the wtmpx-like file WTMPX_FILE. */
107 updwtmpx32 (const char *wtmpx_file
, const struct utmpx32
*utmpx
)
111 utmpx_convert32to64 (utmpx
, &in64
);
112 updwtmpx (wtmpx_file
, &in64
);
114 symbol_version (updwtmpx32
, updwtmpx
, GLIBC_2
.1
);
116 /* Copy the information in UTMPX to UTMP. */
118 getutmp32 (const struct utmpx32
*utmpx
, struct utmp32
*utmp
)
123 utmpx_convert32to64 (utmpx
, &in64
);
124 getutmp (&in64
, &out64
);
125 utmp_convert64to32 (&out64
, utmp
);
127 symbol_version (getutmp32
, getutmp
, GLIBC_2
.1
.1);
129 /* Copy the information in UTMP to UTMPX. */
131 getutmpx32 (const struct utmp32
*utmp
, struct utmpx32
*utmpx
)
136 utmp_convert32to64 (utmp
, &in64
);
137 getutmpx (&in64
, &out64
);
138 utmpx_convert64to32 (&out64
, utmpx
);
140 symbol_version (getutmpx32
, getutmpx
, GLIBC_2
.1
.1);