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

Side by Side Diff: fusl/src/network/inet_aton.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/network/inet_addr.c ('k') | fusl/src/network/inet_legacy.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 <ctype.h>
2 #include <sys/socket.h>
3 #include <netinet/in.h>
4 #include <arpa/inet.h>
5 #include "libc.h"
6
7 int __inet_aton(const char *s0, struct in_addr *dest)
8 {
9 const char *s = s0;
10 unsigned char *d = (void *)dest;
11 unsigned long a[4] = { 0 };
12 char *z;
13 int i;
14
15 for (i=0; i<4; i++) {
16 a[i] = strtoul(s, &z, 0);
17 if (z==s || (*z && *z != '.') || !isdigit(*s))
18 return 0;
19 if (!*z) break;
20 s=z+1;
21 }
22 if (i==4) return 0;
23 switch (i) {
24 case 0:
25 a[1] = a[0] & 0xffffff;
26 a[0] >>= 24;
27 case 1:
28 a[2] = a[1] & 0xffff;
29 a[1] >>= 16;
30 case 2:
31 a[3] = a[2] & 0xff;
32 a[2] >>= 8;
33 }
34 for (i=0; i<4; i++) {
35 if (a[i] > 255) return 0;
36 d[i] = a[i];
37 }
38 return 1;
39 }
40
41 weak_alias(__inet_aton, inet_aton);
OLDNEW
« no previous file with comments | « fusl/src/network/inet_addr.c ('k') | fusl/src/network/inet_legacy.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698