OLD | NEW |
1 #define _GNU_SOURCE | 1 #define _GNU_SOURCE |
2 | 2 |
3 #include <sys/socket.h> | 3 #include <sys/socket.h> |
4 #include <netdb.h> | 4 #include <netdb.h> |
5 #include <string.h> | 5 #include <string.h> |
6 #include <netinet/in.h> | 6 #include <netinet/in.h> |
7 | 7 |
8 struct hostent *gethostbyname(const char *name) | 8 struct hostent* gethostbyname(const char* name) { |
9 { | 9 return gethostbyname2(name, AF_INET); |
10 » return gethostbyname2(name, AF_INET); | |
11 } | 10 } |
12 | 11 |
13 #if 0 | 12 #if 0 |
14 struct hostent *gethostbyname(const char *name) | 13 struct hostent *gethostbyname(const char *name) |
15 { | 14 { |
16 static struct hostent h; | 15 static struct hostent h; |
17 static char *h_aliases[3]; | 16 static char *h_aliases[3]; |
18 static char h_canon[256]; | 17 static char h_canon[256]; |
19 static char *h_addr_list[10]; | 18 static char *h_addr_list[10]; |
20 static char h_addr_data[10][4]; | 19 static char h_addr_data[10][4]; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 h.h_addr_list[i] = h_addr_data[i]; | 53 h.h_addr_list[i] = h_addr_data[i]; |
55 memcpy(h.h_addr_list[i], | 54 memcpy(h.h_addr_list[i], |
56 &((struct sockaddr_in *)p->ai_addr)->sin_addr, 4); | 55 &((struct sockaddr_in *)p->ai_addr)->sin_addr, 4); |
57 } | 56 } |
58 h.h_addr_list[i] = 0; | 57 h.h_addr_list[i] = 0; |
59 h.h_addrtype = AF_INET; | 58 h.h_addrtype = AF_INET; |
60 freeaddrinfo(ai); | 59 freeaddrinfo(ai); |
61 return &h; | 60 return &h; |
62 } | 61 } |
63 #endif | 62 #endif |
OLD | NEW |