123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #define _GNU_SOURCE
- #include <features.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- #include <string.h>
- #include <stddef.h>
- #include <errno.h>
- #include <assert.h>
- #include <ctype.h>
- #include <pwd.h>
- #include <grp.h>
- #include <paths.h>
- #ifdef __HAS_SHADOW__
- #include <shadow.h>
- #endif
- #ifdef __UCLIBC_HAS_THREADS__
- #include <pthread.h>
- #endif
- #define PWD_BUFFER_SIZE 256
- #define GRP_BUFFER_SIZE 256
- #ifndef GETXXKEY_R_FUNC
- #error GETXXKEY_R_FUNC is not defined!
- #endif
- #ifdef GETXXKEY_R_FUNC
- libc_hidden_proto(GETXXKEY_R_FUNC)
- int GETXXKEY_R_FUNC(DO_GETXXKEY_R_KEYTYPE key,
- GETXXKEY_R_ENTTYPE *__restrict resultbuf,
- char *__restrict buffer, size_t buflen,
- GETXXKEY_R_ENTTYPE **__restrict result)
- {
- FILE *stream;
- int rv;
- *result = NULL;
- if (!(stream = fopen(DO_GETXXKEY_R_PATHNAME, "r"))) {
- rv = errno;
- } else {
- __STDIO_SET_USER_LOCKING(stream);
- do {
- if (!(rv = __pgsreader(GETXXKEY_R_PARSER, resultbuf,
- buffer, buflen, stream))
- ) {
- if (GETXXKEY_R_TEST(resultbuf)) {
- *result = resultbuf;
- break;
- }
- } else {
- if (rv == ENOENT) {
- rv = 0;
- }
- break;
- }
- } while (1);
- fclose(stream);
- }
- return rv;
- }
- libc_hidden_def(GETXXKEY_R_FUNC)
- #endif
- #undef GETXXKEY_R_FUNC_HIDDEN
- #undef GETXXKEY_R_FUNC
- #undef GETXXKEY_R_PARSER
- #undef GETXXKEY_R_ENTTYPE
- #undef GETXXKEY_R_TEST
- #undef DO_GETXXKEY_R_KEYTYPE
- #undef DO_GETXXKEY_R_PATHNAME
|