1 /* Copyright (C) 1996-2015 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@cygnus.com>
4 and Paul Janzen <pcj@primenet.com>, 1996.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #include <libc-lock.h>
24 #include "utmp-private.h"
27 /* Functions defined here. */
28 static int setutent_unknown (void);
29 static int getutent_r_unknown (struct utmp
*buffer
, struct utmp
**result
);
30 static int getutid_r_unknown (const struct utmp
*line
, struct utmp
*buffer
,
31 struct utmp
**result
);
32 static int getutline_r_unknown (const struct utmp
*id
, struct utmp
*buffer
,
33 struct utmp
**result
);
34 static struct utmp
*pututline_unknown (const struct utmp
*data
);
35 static void endutent_unknown (void);
37 /* Initial Jump table. */
38 const struct utfuncs __libc_utmp_unknown_functions
=
49 /* Currently selected backend. */
50 const struct utfuncs
*__libc_utmp_jump_table
= &__libc_utmp_unknown_functions
;
52 /* We need to protect the opening of the file. */
53 __libc_lock_define_initialized (, __libc_utmp_lock attribute_hidden
)
57 setutent_unknown (void)
61 result
= (*__libc_utmp_file_functions
.setutent
) ();
63 __libc_utmp_jump_table
= &__libc_utmp_file_functions
;
70 getutent_r_unknown (struct utmp
*buffer
, struct utmp
**result
)
72 /* The backend was not yet initialized. */
73 if (setutent_unknown ())
74 return (*__libc_utmp_jump_table
->getutent_r
) (buffer
, result
);
83 getutid_r_unknown (const struct utmp
*id
, struct utmp
*buffer
,
86 /* The backend was not yet initialized. */
87 if (setutent_unknown ())
88 return (*__libc_utmp_jump_table
->getutid_r
) (id
, buffer
, result
);
97 getutline_r_unknown (const struct utmp
*line
, struct utmp
*buffer
,
100 /* The backend was not yet initialized. */
101 if (setutent_unknown ())
102 return (*__libc_utmp_jump_table
->getutline_r
) (line
, buffer
, result
);
111 pututline_unknown (const struct utmp
*data
)
113 /* The backend was not yet initialized. */
114 if (setutent_unknown ())
115 return (*__libc_utmp_jump_table
->pututline
) (data
);
123 endutent_unknown (void)
132 __libc_lock_lock (__libc_utmp_lock
);
134 (*__libc_utmp_jump_table
->setutent
) ();
136 __libc_lock_unlock (__libc_utmp_lock
);
138 weak_alias (__setutent
, setutent
)
142 __getutent_r (struct utmp
*buffer
, struct utmp
**result
)
146 __libc_lock_lock (__libc_utmp_lock
);
148 retval
= (*__libc_utmp_jump_table
->getutent_r
) (buffer
, result
);
150 __libc_lock_unlock (__libc_utmp_lock
);
154 weak_alias (__getutent_r
, getutent_r
)
158 __pututline (const struct utmp
*data
)
162 __libc_lock_lock (__libc_utmp_lock
);
164 buffer
= (*__libc_utmp_jump_table
->pututline
) (data
);
166 __libc_lock_unlock (__libc_utmp_lock
);
170 weak_alias (__pututline
, pututline
)
176 __libc_lock_lock (__libc_utmp_lock
);
178 (*__libc_utmp_jump_table
->endutent
) ();
179 __libc_utmp_jump_table
= &__libc_utmp_unknown_functions
;
181 __libc_lock_unlock (__libc_utmp_lock
);
183 weak_alias (__endutent
, endutent
)