diff options
| author | Rich Felker <dalias@aerifal.cx> | 2011-02-12 00:22:29 -0500 | 
|---|---|---|
| committer | Rich Felker <dalias@aerifal.cx> | 2011-02-12 00:22:29 -0500 | 
| commit | 0b44a0315b47dd8eced9f3b7f31580cf14bbfc01 (patch) | |
| tree | 6eaef0d8a720fa3da580de87b647fff796fe80b3 /src/passwd/getpwent_a.c | |
| download | musl-0b44a0315b47dd8eced9f3b7f31580cf14bbfc01.tar.gz | |
initial check-in, version 0.5.0v0.5.0
Diffstat (limited to 'src/passwd/getpwent_a.c')
| -rw-r--r-- | src/passwd/getpwent_a.c | 37 | 
1 files changed, 37 insertions, 0 deletions
| diff --git a/src/passwd/getpwent_a.c b/src/passwd/getpwent_a.c new file mode 100644 index 00000000..aaf84edd --- /dev/null +++ b/src/passwd/getpwent_a.c @@ -0,0 +1,37 @@ +#include "pwf.h" + +struct passwd *__getpwent_a(FILE *f, struct passwd *pw, char **line, size_t *size) +{ +	ssize_t l; +	char *s; +	for (;;) { +		if ((l=getline(line, size, f)) < 0) { +			free(*line); +			*line = 0; +			return 0; +		} +		line[0][l-1] = 0; + +		s = line[0]; +		pw->pw_name = s++; +		if (!(s = strchr(s, ':'))) continue; + +		*s++ = 0; pw->pw_passwd = s; +		if (!(s = strchr(s, ':'))) continue; + +		*s++ = 0; pw->pw_uid = atoi(s); +		if (!(s = strchr(s, ':'))) continue; + +		*s++ = 0; pw->pw_gid = atoi(s); +		if (!(s = strchr(s, ':'))) continue; + +		*s++ = 0; pw->pw_gecos = s; +		if (!(s = strchr(s, ':'))) continue; + +		*s++ = 0; pw->pw_dir = s; +		if (!(s = strchr(s, ':'))) continue; + +		*s++ = 0; pw->pw_shell = s; +		return pw; +	} +} | 
