not using visual studio in windows
| 57 | #ifndef _MSC_VER |
| 58 | // not using visual studio in windows |
| 59 | inline 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 |