MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / inet_pton

Function inet_pton

src/network/socket_wrapper.hpp:59–80  ·  view source on GitHub ↗

not using visual studio in windows

Source from the content-addressed store, hash-verified

57#ifndef _MSC_VER
58// not using visual studio in windows
59inline int inet_pton(int af, const char *src, void *dst) {
60 struct sockaddr_storage ss;
61 int size = sizeof(ss);
62 char src_copy[INET6_ADDRSTRLEN + 1];
63
64 ZeroMemory(&ss, sizeof(ss));
65 /* stupid non-const API */
66 strncpy(src_copy, src, INET6_ADDRSTRLEN + 1);
67 src_copy[INET6_ADDRSTRLEN] = 0;
68
69 if (WSAStringToAddress(src_copy, af, NULL, (struct sockaddr *)&ss, &size) == 0) {
70 switch (af) {
71 case AF_INET:
72 *(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr;
73 return 1;
74 case AF_INET6:
75 *(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr;
76 return 1;
77 }
78 }
79 return 0;
80}
81#endif
82#endif
83

Callers 1

GetAddressMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected