From 039b4e0454e9485eb2eff235628145dbcd24e49c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 29 Aug 2015 18:57:07 +0200 Subject: [PATCH] Move code back to logger.c --- Makefile.griffin | 4 -- libretro-common/include/net/net_compat.h | 5 -- libretro-common/net/net_compat.c | 59 --------------------- logger/netlogger/logger.c | 67 ++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 68 deletions(-) diff --git a/Makefile.griffin b/Makefile.griffin index 35377bf5b0..ac5e473104 100644 --- a/Makefile.griffin +++ b/Makefile.griffin @@ -104,10 +104,6 @@ endif LIBS := -lfat $(WHOLE_START) -lretro_wii $(WHOLE_END) -logc -lwiiuse -lbte ifeq ($(USBGECKO), 1) LIBS += -ldb -endif -ifeq ($(HAVE_LOGGER), 1) - HAVE_NETWORKING=1 - HAVE_NETPLAY=1 endif APP_BOOTER_DIR = wii/app_booter PLATOBJS := $(APP_BOOTER_DIR)/app_booter.binobj diff --git a/libretro-common/include/net/net_compat.h b/libretro-common/include/net/net_compat.h index 9f07dae808..4b6044cf7d 100644 --- a/libretro-common/include/net/net_compat.h +++ b/libretro-common/include/net/net_compat.h @@ -192,10 +192,5 @@ bool network_init(void); **/ void network_deinit(void); -int network_interface_up(struct sockaddr_in *target, int index, - const char *ip_address, unsigned udp_port, int *s); - -int network_interface_down(struct sockaddr_in *target, int *s); - #endif diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index 158e49426f..b0cfbf6920 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -201,62 +201,3 @@ void network_deinit(void) cellSysmoduleUnloadModule(CELL_SYSMODULE_NET); #endif } - -int network_interface_up(struct sockaddr_in *target, int index, - const char *ip_address, unsigned udp_port, int *s) -{ - int ret = 0; - - (void)index; - -#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) - int state, timeout_count = 10; - ret = cellNetCtlInit(); - if (ret < 0) - return -1; - - for (;;) - { - ret = cellNetCtlGetState(&state); - if (ret < 0) - return -1; - - if (state == CELL_NET_CTL_STATE_IPObtained) - break; - - rarch_sleep(500); - timeout_count--; - if (index && timeout_count < 0) - return 0; - } -#elif defined(GEKKO) - char t[16]; - if (if_config(t, NULL, NULL, TRUE) < 0) - ret = -1; -#endif - if (ret < 0) - return -1; - - *s = socket(AF_INET, SOCK_DGRAM, 0); - - target->sin_family = AF_INET; - target->sin_port = htons(udp_port); -#ifdef GEKKO - target->sin_len = 8; -#endif - - inet_pton(AF_INET, ip_address, &target->sin_addr); - - return 0; -} - -int network_interface_down(struct sockaddr_in *target, int *s) -{ - socket_close(*s); -#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) - cellNetCtlTerm(); -#elif defined(GEKKO) && !defined(HW_DOL) - net_deinit(); -#endif - return 0; -} diff --git a/logger/netlogger/logger.c b/logger/netlogger/logger.c index fefd0416d4..23591605bb 100644 --- a/logger/netlogger/logger.c +++ b/logger/netlogger/logger.c @@ -41,6 +41,73 @@ static int sock; static struct sockaddr_in target; static char sendbuf[4096]; +static int network_interface_up(struct sockaddr_in *target, int index, + const char *ip_address, unsigned udp_port, int *s) +{ + int ret = 0; + + (void)index; + +#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) + int state, timeout_count = 10; + ret = cellNetCtlInit(); + if (ret < 0) + return -1; + + for (;;) + { + ret = cellNetCtlGetState(&state); + if (ret < 0) + return -1; + + if (state == CELL_NET_CTL_STATE_IPObtained) + break; + + rarch_sleep(500); + timeout_count--; + if (index && timeout_count < 0) + return 0; + } +#elif defined(GEKKO) + char t[16]; + if (if_config(t, NULL, NULL, TRUE) < 0) + ret = -1; +#endif + if (ret < 0) + return -1; + + *s = socket(AF_INET, SOCK_DGRAM, 0); + + target->sin_family = AF_INET; + target->sin_port = htons(udp_port); +#ifdef GEKKO + target->sin_len = 8; +#endif + + inet_pton(AF_INET, ip_address, &target->sin_addr); + + return 0; +} + +static int network_interface_down(struct sockaddr_in *target, int *s) +{ + int ret = 0; +#if defined(_WIN32) && !defined(_XBOX360) + /* WinSock has headers from the stone age. */ + ret = closesocket(*s); +#elif defined(__CELLOS_LV2__) + ret = socketclose(*s); +#else + ret = close(*s); +#endif +#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) + cellNetCtlTerm(); +#elif defined(GEKKO) && !defined(HW_DOL) + net_deinit(); +#endif + return ret; +} + void logger_init (void) { if (network_interface_up(&target, 1,