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.
34 #ifdef __UCLIBC_HAS_SHADOW__
38 /**********************************************************************/
39 /* Sizes for statically allocated buffers. */
41 /* If you change these values, also change _SC_GETPW_R_SIZE_MAX and
42 * _SC_GETGR_R_SIZE_MAX in libc/unistd/sysconf.c to match */
43 #define PWD_BUFFER_SIZE 256
44 #define GRP_BUFFER_SIZE 256
46 /**********************************************************************/
47 /* Prototypes for internal functions. */
49 #ifndef GETXXKEY_R_FUNC
50 #error GETXXKEY_R_FUNC is not defined!
52 /**********************************************************************/
53 #ifdef GETXXKEY_R_FUNC
55 libc_hidden_proto(GETXXKEY_R_FUNC)
56 int GETXXKEY_R_FUNC(DO_GETXXKEY_R_KEYTYPE key,
57 GETXXKEY_R_ENTTYPE *__restrict resultbuf,
58 char *__restrict buffer, size_t buflen,
59 GETXXKEY_R_ENTTYPE **__restrict result)
66 if (!(stream = fopen(DO_GETXXKEY_R_PATHNAME, "r"))) {
69 __STDIO_SET_USER_LOCKING(stream);
71 if (!(rv = __pgsreader(GETXXKEY_R_PARSER, resultbuf,
72 buffer, buflen, stream))
74 if (GETXXKEY_R_TEST(resultbuf)) { /* Found key? */
79 if (rv == ENOENT) { /* end-of-file encountered. */
90 libc_hidden_def(GETXXKEY_R_FUNC)
93 /**********************************************************************/
94 #undef GETXXKEY_R_FUNC_HIDDEN
95 #undef GETXXKEY_R_FUNC
96 #undef GETXXKEY_R_PARSER
97 #undef GETXXKEY_R_ENTTYPE
98 #undef GETXXKEY_R_TEST
99 #undef DO_GETXXKEY_R_KEYTYPE
100 #undef DO_GETXXKEY_R_PATHNAME