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

Side by Side Diff: fusl/src/network/gethostbyname.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/gethostbyaddr_r.c ('k') | fusl/src/network/gethostbyname2.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 #define _GNU_SOURCE
2
3 #include <sys/socket.h>
4 #include <netdb.h>
5 #include <string.h>
6 #include <netinet/in.h>
7
8 struct hostent *gethostbyname(const char *name)
9 {
10 return gethostbyname2(name, AF_INET);
11 }
12
13 #if 0
14 struct hostent *gethostbyname(const char *name)
15 {
16 static struct hostent h;
17 static char *h_aliases[3];
18 static char h_canon[256];
19 static char *h_addr_list[10];
20 static char h_addr_data[10][4];
21 static const struct addrinfo hint = {
22 .ai_family = AF_INET, .ai_flags = AI_CANONNAME
23 };
24 struct addrinfo *ai, *p;
25 int i;
26
27 switch (getaddrinfo(name, 0, &hint, &ai)) {
28 case EAI_NONAME:
29 h_errno = HOST_NOT_FOUND;
30 break;
31 case EAI_AGAIN:
32 h_errno = TRY_AGAIN;
33 break;
34 case EAI_FAIL:
35 h_errno = NO_RECOVERY;
36 break;
37 default:
38 case EAI_MEMORY:
39 case EAI_SYSTEM:
40 h_errno = NO_DATA;
41 break;
42 case 0:
43 break;
44 }
45
46 strcpy(h_canon, ai->ai_canonname);
47 h.h_name = h_canon;
48 h.h_aliases = h_aliases;
49 h.h_aliases[0] = h_canon;
50 h.h_aliases[1] = strcmp(h_canon, name) ? (char *)name : 0;
51 h.h_length = 4;
52 h.h_addr_list = h_addr_list;
53 for (i=0, p=ai; i<sizeof h_addr_data/4 && p; i++, p=p->ai_next) {
54 h.h_addr_list[i] = h_addr_data[i];
55 memcpy(h.h_addr_list[i],
56 &((struct sockaddr_in *)p->ai_addr)->sin_addr, 4);
57 }
58 h.h_addr_list[i] = 0;
59 h.h_addrtype = AF_INET;
60 freeaddrinfo(ai);
61 return &h;
62 }
63 #endif
OLDNEW
« no previous file with comments | « fusl/src/network/gethostbyaddr_r.c ('k') | fusl/src/network/gethostbyname2.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698