2 * Copyright (C) 2003 Manuel Novoa III
4 * Licensed under LGPL v2.1, see the file COPYING.LIB in this tarball for details.
7 /* Nov 6, 2003 Initial version.
9 * NOTE: This implementation is quite strict about requiring all
10 * field seperators. It also does not allow leading whitespace
11 * except when processing the numeric fields. glibc is more
12 * lenient. See the various glibc difference comments below.
15 * Move to dynamic allocation of (currently staticly allocated)
16 * buffers; especially for the group-related functions since
17 * large group member lists will cause error returns.
37 #ifdef __UCLIBC_HAS_THREADS__
41 /**********************************************************************/
42 /* Sizes for staticly allocated buffers. */
44 /* If you change these values, also change _SC_GETPW_R_SIZE_MAX and
45 * _SC_GETGR_R_SIZE_MAX in libc/unistd/sysconf.c to match */
46 #define PWD_BUFFER_SIZE 256
47 #define GRP_BUFFER_SIZE 256
49 /**********************************************************************/
50 /* Prototypes for internal functions. */
52 #ifndef GETXXKEY_R_FUNC
53 #error GETXXKEY_R_FUNC is not defined!
55 /**********************************************************************/
56 #ifdef GETXXKEY_R_FUNC
58 int GETXXKEY_R_FUNC(DO_GETXXKEY_R_KEYTYPE key,
59 GETXXKEY_R_ENTTYPE *__restrict resultbuf,
60 char *__restrict buffer, size_t buflen,
61 GETXXKEY_R_ENTTYPE **__restrict result)
68 if (!(stream = fopen(DO_GETXXKEY_R_PATHNAME, "r"))) {
71 __STDIO_SET_USER_LOCKING(stream);
73 if (!(rv = __pgsreader(GETXXKEY_R_PARSER, resultbuf,
74 buffer, buflen, stream))
76 if (GETXXKEY_R_TEST(resultbuf)) { /* Found key? */
81 if (rv == ENOENT) { /* end-of-file encountered. */
92 libc_hidden_proto(GETXXKEY_R_FUNC)
93 libc_hidden_def(GETXXKEY_R_FUNC)
96 /**********************************************************************/
97 #undef GETXXKEY_R_FUNC_HIDDEN
98 #undef GETXXKEY_R_FUNC
99 #undef GETXXKEY_R_PARSER
100 #undef GETXXKEY_R_ENTTYPE
101 #undef GETXXKEY_R_TEST
102 #undef DO_GETXXKEY_R_KEYTYPE
103 #undef DO_GETXXKEY_R_PATHNAME