2 * Copyright (C) 2003 Manuel Novoa III <mjn3@uclibc.org>
3 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
5 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8 /* Nov 6, 2003 Initial version.
10 * NOTE: This implementation is quite strict about requiring all
11 * field seperators. It also does not allow leading whitespace
12 * except when processing the numeric fields. glibc is more
13 * lenient. See the various glibc difference comments below.
16 * Move to dynamic allocation of (currently statically allocated)
17 * buffers; especially for the group-related functions since
18 * large group member lists will cause error returns.
35 #ifdef __UCLIBC_HAS_SHADOW__
39 /**********************************************************************/
40 /* Prototypes for internal functions. */
42 #if !defined(GETXXKEY_R_FUNC) && !defined(GETXXKEY_FUNC)
43 #error GETXXKEY_R_FUNC/GETXXKEY_FUNC are not defined!
45 /**********************************************************************/
46 #ifdef GETXXKEY_R_FUNC
48 libc_hidden_proto(GETXXKEY_R_FUNC
)
49 int GETXXKEY_R_FUNC(DO_GETXXKEY_R_KEYTYPE key
,
50 GETXXKEY_R_ENTTYPE
*__restrict resultbuf
,
51 char *__restrict buffer
, size_t buflen
,
52 GETXXKEY_R_ENTTYPE
**__restrict result
)
59 if (!(stream
= fopen(DO_GETXXKEY_R_PATHNAME
, "r"))) {
62 __STDIO_SET_USER_LOCKING(stream
);
64 if (!(rv
= __pgsreader(GETXXKEY_R_PARSER
, resultbuf
,
65 buffer
, buflen
, stream
))
67 if (GETXXKEY_R_TEST(resultbuf
)) { /* Found key? */
72 if (rv
== ENOENT
) { /* end-of-file encountered. */
83 libc_hidden_def(GETXXKEY_R_FUNC
)
85 #endif /* GETXXKEY_R_FUNC */
87 /**********************************************************************/
90 #define REENTRANT_NAME APPEND_R(GETXXKEY_FUNC)
91 #define APPEND_R(name) APPEND_R1(name)
92 #define APPEND_R1(name) name##_r
94 GETXXKEY_ENTTYPE
*GETXXKEY_FUNC(GETXXKEY_ADD_PARAMS
)
96 static char *buffer
= NULL
;
97 static GETXXKEY_ENTTYPE resultbuf
;
98 GETXXKEY_ENTTYPE
*result
;
101 buffer
= (char *)__uc_malloc(GETXXKEY_BUFLEN
);
103 # ifdef GETXXKEY_ADD_VARIABLES
104 REENTRANT_NAME(GETXXKEY_ADD_VARIABLES
, &resultbuf
, buffer
, GETXXKEY_BUFLEN
, &result
);
106 REENTRANT_NAME(&resultbuf
, buffer
, GETXXKEY_BUFLEN
, &result
);
110 #ifdef GETXXKEY_FUNC_HIDDEN
111 libc_hidden_def(GETXXKEY_FUNC
)
114 #undef REENTRANT_NAME
117 #endif /* GETXXKEY_FUNC */
119 /**********************************************************************/
121 #undef GETXXKEY_ENTTYPE
122 #undef GETXXKEY_BUFLEN
123 #undef GETXXKEY_FUNC_HIDDEN
124 #undef GETXXKEY_ADD_PARAMS
125 #undef GETXXKEY_ADD_VARIABLES
126 #undef GETXXKEY_R_FUNC
127 #undef GETXXKEY_R_PARSER
128 #undef GETXXKEY_R_ENTTYPE
129 #undef GETXXKEY_R_TEST
130 #undef DO_GETXXKEY_R_KEYTYPE
131 #undef DO_GETXXKEY_R_PATHNAME