From be222904954f711fb865c2c0734a15855c065dce Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 17 May 2017 07:00:47 +0200 Subject: [PATCH] Rename to inet_ntop_compat --- libretro-common/include/net/net_compat.h | 4 +--- libretro-common/net/net_compat.c | 4 +--- menu/cbs/menu_cbs_ok.c | 15 +++------------ 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/libretro-common/include/net/net_compat.h b/libretro-common/include/net/net_compat.h index 89bff49b53..dd7a1d5c81 100644 --- a/libretro-common/include/net/net_compat.h +++ b/libretro-common/include/net/net_compat.h @@ -238,8 +238,6 @@ bool network_init(void); **/ void network_deinit(void); -#ifdef _WIN32 -const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt); -#endif +const char *inet_ntop_compat(int af, const void *src, char *dst, socklen_t cnt); #endif diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index addb17ec6a..e315bbe67a 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -355,8 +355,7 @@ int inet_ptrton(int af, const char *src, void *dst) #endif } -#ifdef _WIN32 -const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt) +const char *inet_ntop_compat(int af, const void *src, char *dst, socklen_t cnt) { if (af == AF_INET) { @@ -380,4 +379,3 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt) } return NULL; } -#endif diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 6c2d81c43b..a4a75f923d 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3502,6 +3502,7 @@ finish: if (lan_room_count != 0) { struct netplay_host *host = NULL; + for (host = &lan_hosts->hosts[k]; i < netplay_room_count + lan_room_count; i++) { struct sockaddr *address = NULL; @@ -3512,28 +3513,18 @@ finish: address = &host->addr; -#ifdef INET6_ADDRSTRLEN - /* TODO/FIXME - inet_ntop is not portable. Need to create - * a wrapper function in libretro-common which will wrap - * this and ensure that it will work on most platforms. - */ if (address->sa_family == AF_INET) { struct sockaddr_in *sin = (struct sockaddr_in *) address; - inet_ntop(AF_INET, &sin->sin_addr, + inet_ntop_compat(AF_INET, &sin->sin_addr, netplay_room_list[i].address, INET6_ADDRSTRLEN); } else if (address->sa_family == AF_INET6) { struct sockaddr_in6 *sin = (struct sockaddr_in6 *) address; - inet_ntop(AF_INET6, &sin->sin6_addr, + inet_ntop_compat(AF_INET6, &sin->sin6_addr, netplay_room_list[i].address, INET6_ADDRSTRLEN); } -#else - strlcpy(netplay_room_list[i].address, - inet_ntoa(((struct sockaddr_in*)(address))->sin_addr), - sizeof(netplay_room_list[i].address)); -#endif strlcpy(netplay_room_list[i].corename, host->core,