From 11ec23bc18d762d9f1b9f1dfcfaa977e846b9dc6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 15:41:23 +0200 Subject: [PATCH] Create inet_ptrton --- libretro-common/include/net/net_compat.h | 10 ++-------- libretro-common/net/net_compat.c | 13 +++++++++++++ libretro-common/net/net_socket.c | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/libretro-common/include/net/net_compat.h b/libretro-common/include/net/net_compat.h index 690a9a1b9c..e95c203678 100644 --- a/libretro-common/include/net/net_compat.h +++ b/libretro-common/include/net/net_compat.h @@ -136,14 +136,6 @@ struct hostent #ifdef GEKKO #define sendto(s, msg, len, flags, addr, tolen) net_sendto(s, msg, len, 0, addr, 8) #define socket(domain, type, protocol) net_socket(domain, type, protocol) - -static INLINE int inet_pton(int af, const char *src, void *dst) -{ - if (af != AF_INET) - return -1; - - return inet_aton (src, dst); -} #endif static INLINE bool isagain(int bytes) @@ -213,6 +205,8 @@ struct addrinfo uint16_t inet_htons(uint16_t hostshort); +int inet_ptrton(int af, const char *src, void *dst); + int getaddrinfo_retro(const char *node, const char *service, struct addrinfo *hints, struct addrinfo **res); diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index c6d1b56dda..ce989975c8 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -326,3 +326,16 @@ uint16_t inet_htons(uint16_t hostshort) return htons(hostshort); #endif } + +int inet_ptrton(int af, const char *src, void *dst) +{ + /* TODO/FIXME - should use InetPton on Vista and later */ +#if defined(GEKKO) || defined(_WIN32) + if (af != AF_INET) + return -1; + + return inet_aton(src, dst); +#else + return inet_pton(af, src, dst); +#endif +} diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 557ccb6800..f86c04dc02 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -307,7 +307,7 @@ void socket_set_target(void *data, socket_target_t *in_addr) out_target->sin_len = 8; #endif - inet_pton(AF_INET, in_addr->server, &out_target->sin_addr); + inet_ptrton(AF_INET, in_addr->server, &out_target->sin_addr); #endif }