Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: fusl/src/passwd/getpwent_a.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/passwd/getpwent.c ('k') | fusl/src/passwd/getspent.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "pwf.h"
2 #include <pthread.h>
3
4 static unsigned atou(char **s)
5 {
6 unsigned x;
7 for (x=0; **s-'0'<10U; ++*s) x=10*x+(**s-'0');
8 return x;
9 }
10
11 int __getpwent_a(FILE *f, struct passwd *pw, char **line, size_t *size, struct p asswd **res)
12 {
13 ssize_t l;
14 char *s;
15 int rv = 0;
16 int cs;
17 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
18 for (;;) {
19 if ((l=getline(line, size, f)) < 0) {
20 rv = ferror(f) ? errno : 0;
21 free(*line);
22 *line = 0;
23 pw = 0;
24 break;
25 }
26 line[0][l-1] = 0;
27
28 s = line[0];
29 pw->pw_name = s++;
30 if (!(s = strchr(s, ':'))) continue;
31
32 *s++ = 0; pw->pw_passwd = s;
33 if (!(s = strchr(s, ':'))) continue;
34
35 *s++ = 0; pw->pw_uid = atou(&s);
36 if (*s != ':') continue;
37
38 *s++ = 0; pw->pw_gid = atou(&s);
39 if (*s != ':') continue;
40
41 *s++ = 0; pw->pw_gecos = s;
42 if (!(s = strchr(s, ':'))) continue;
43
44 *s++ = 0; pw->pw_dir = s;
45 if (!(s = strchr(s, ':'))) continue;
46
47 *s++ = 0; pw->pw_shell = s;
48 break;
49 }
50 pthread_setcancelstate(cs, 0);
51 *res = pw;
52 if (rv) errno = rv;
53 return rv;
54 }
OLDNEW
« no previous file with comments | « fusl/src/passwd/getpwent.c ('k') | fusl/src/passwd/getspent.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698