diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-03-08 16:45:24 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-03-08 16:45:24 +0000 |
commit | 791312e7259153e1235f14a9a9e5cc6055ce8dfc (patch) | |
tree | 81f07808e6af9d42e92a4bba911b3b425f589516 /libc/pwd_grp/fgetpwent.c | |
parent | bfb8f8f6ea438e632e808868c44af2bff196cc18 (diff) |
Reworked the password stuff to be reentrant. Group stuff is
still needing to be reworked.
-Erik
Diffstat (limited to 'libc/pwd_grp/fgetpwent.c')
-rw-r--r-- | libc/pwd_grp/fgetpwent.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/libc/pwd_grp/fgetpwent.c b/libc/pwd_grp/fgetpwent.c index cd8742d80..74c59427c 100644 --- a/libc/pwd_grp/fgetpwent.c +++ b/libc/pwd_grp/fgetpwent.c @@ -22,12 +22,26 @@ #include <stdio.h> #include <pwd.h> -struct passwd *fgetpwent(FILE * file) +#define PWD_BUFFER_SIZE 256 + +/* file descriptor for the password file currently open */ +static char line_buff[PWD_BUFFER_SIZE]; +static struct passwd pwd; + +int fgetpwent_r (FILE *file, struct passwd *password, + char *buff, size_t buflen, struct passwd **crap) { if (file == NULL) { errno = EINTR; - return NULL; + return -1; } + return(__getpwent_r(password, buff, buflen, fileno(file))); +} - return __getpwent(fileno(file)); +struct passwd *fgetpwent(FILE * file) +{ + if (fgetpwent_r(file, &pwd, line_buff, PWD_BUFFER_SIZE, NULL) != -1) { + return &pwd; + } + return NULL; } |