Move code back to logger.c

This commit is contained in:
twinaphex 2015-08-29 18:57:07 +02:00
parent 3336849e80
commit 039b4e0454
4 changed files with 67 additions and 68 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -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,