From 791312e7259153e1235f14a9a9e5cc6055ce8dfc Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 8 Mar 2001 16:45:24 +0000 Subject: Reworked the password stuff to be reentrant. Group stuff is still needing to be reworked. -Erik --- libc/pwd_grp/fgetpwent.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'libc/pwd_grp/fgetpwent.c') 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 #include -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; } -- cgit v1.2.3