1 /* Copyright (C) 1996-2015 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 <http://www.gnu.org/licenses/>. */
19 #include <bits/libc-lock.h>
24 /*******************************************************************\
25 |* Here we assume several symbols to be defined: *|
27 |* LOOKUP_TYPE - the return type of the function *|
29 |* GETFUNC_NAME - name of the non-reentrant getXXXent function *|
31 |* BUFLEN - size of static buffer *|
33 |* Optionally the following vars can be defined: *|
35 |* NEED_H_ERRNO - an extra parameter will be passed to point to *|
36 |* the global `h_errno' variable. *|
38 \*******************************************************************/
40 /* To make the real sources a bit prettier. */
41 #define REENTRANT_GETNAME APPEND_R (GETFUNC_NAME)
42 #define APPEND_R(name) APPEND_R1 (name)
43 #define APPEND_R1(name) name##_r
44 #define INTERNAL(name) INTERNAL1 (name)
45 #define INTERNAL1(name) __##name
47 /* Sometimes we need to store error codes in the `h_errno' variable. */
49 # define H_ERRNO_PARM , int *h_errnop
50 # define H_ERRNO_VAR &h_errno
53 # define H_ERRNO_VAR NULL
56 /* Prototype of the reentrant version. */
57 extern int INTERNAL (REENTRANT_GETNAME
) (LOOKUP_TYPE
*resbuf
, char *buffer
,
58 size_t buflen
, LOOKUP_TYPE
**result
61 /* We need to protect the dynamic buffer handling. */
62 __libc_lock_define_initialized (static, lock
);
64 /* This points to the static buffer used. */
65 libc_freeres_ptr (static char *buffer
);
71 static size_t buffer_size
;
81 __libc_lock_lock (lock
);
83 result
= (LOOKUP_TYPE
*)
84 __nss_getent ((getent_r_function
) INTERNAL (REENTRANT_GETNAME
),
85 &resbuf
.ptr
, &buffer
, BUFLEN
, &buffer_size
,
89 __libc_lock_unlock (lock
);
94 nss_interface_function (GETFUNC_NAME
)