mirror of
https://github.com/libretro/RetroArch
synced 2025-03-01 07:13:35 +00:00
(net_compat.c) Style nits
This commit is contained in:
parent
1974a3051d
commit
9b4a99d506
@ -20,6 +20,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <net/net_compat.h>
|
||||
#include <compat/strl.h>
|
||||
|
||||
#if defined(VITA)
|
||||
static void *_net_compat_net_memory = NULL;
|
||||
@ -29,23 +30,22 @@ static void *_net_compat_net_memory = NULL;
|
||||
|
||||
typedef uint32_t in_addr_t;
|
||||
|
||||
struct in_addr {
|
||||
struct in_addr
|
||||
{
|
||||
in_addr_t s_addr;
|
||||
};
|
||||
|
||||
char *inet_ntoa(struct SceNetInAddr in)
|
||||
{
|
||||
static char ip_addr[INET_ADDRSTRLEN+1];
|
||||
static char ip_addr[INET_ADDRSTRLEN + 1];
|
||||
|
||||
if(sceNetInetNtop(AF_INET, &in, ip_addr, INET_ADDRSTRLEN) == NULL)
|
||||
{
|
||||
strcpy(ip_addr, "Invalid");
|
||||
}
|
||||
strlcpy(ip_addr, "Invalid", sizeof(ip_addr));
|
||||
|
||||
return ip_addr;
|
||||
}
|
||||
|
||||
struct SceNetInAddr inet_aton(const char * ip_addr)
|
||||
struct SceNetInAddr inet_aton(const char *ip_addr)
|
||||
{
|
||||
SceNetInAddr inaddr;
|
||||
|
||||
@ -60,28 +60,22 @@ unsigned int inet_addr(const char *cp)
|
||||
|
||||
struct hostent *gethostbyname(const char *name)
|
||||
{
|
||||
int err;
|
||||
static struct hostent ent;
|
||||
static char sname[MAX_NAME] = "";
|
||||
static struct SceNetInAddr saddr = { 0 };
|
||||
static char *addrlist[2] = { (char *) &saddr, NULL };
|
||||
int rid;
|
||||
int rid = sceNetResolverCreate("resolver", NULL, 0);
|
||||
|
||||
|
||||
int err;
|
||||
rid = sceNetResolverCreate("resolver", NULL, 0);
|
||||
if(rid < 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
err = sceNetResolverStartNtoa(rid, name, &saddr, 0,0,0);
|
||||
sceNetResolverDestroy(rid);
|
||||
if(err < 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
addrlist[0]=inet_ntoa(saddr);
|
||||
addrlist[0] = inet_ntoa(saddr);
|
||||
ent.h_name = sname;
|
||||
ent.h_aliases = 0;
|
||||
ent.h_addrtype = AF_INET;
|
||||
@ -194,19 +188,19 @@ int socket_select(int nfds, fd_set *readfs, fd_set *writefds,
|
||||
#if defined(__CELLOS_LV2__)
|
||||
return socketselect(nfds, readfs, writefds, errorfds, timeout);
|
||||
#elif defined(VITA)
|
||||
int i = 0;
|
||||
SceNetEpollEvent ev = {0};
|
||||
|
||||
ev.events = PSP2_NET_EPOLLIN | PSP2_NET_EPOLLHUP;
|
||||
ev.data.fd = nfds;
|
||||
|
||||
int i = 0;
|
||||
if((i = sceNetEpollControl(rarch_epoll_fd, PSP2_NET_EPOLL_CTL_ADD, nfds, &ev))){
|
||||
if((i = sceNetEpollControl(rarch_epoll_fd, PSP2_NET_EPOLL_CTL_ADD, nfds, &ev)))
|
||||
{
|
||||
int ret = sceNetEpollWait(rarch_epoll_fd, &ev, 1, 0);
|
||||
sceNetEpollControl(rarch_epoll_fd, PSP2_NET_EPOLL_CTL_DEL, nfds, NULL);
|
||||
return ret;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return select(nfds, readfs, writefds, errorfds, timeout);
|
||||
#endif
|
||||
@ -274,7 +268,8 @@ bool network_init(void)
|
||||
#elif defined(VITA)
|
||||
SceNetInitParam initparam;
|
||||
/* Init Net */
|
||||
if (sceNetShowNetstat() == PSP2_NET_ERROR_ENOTINIT) {
|
||||
if (sceNetShowNetstat() == PSP2_NET_ERROR_ENOTINIT)
|
||||
{
|
||||
_net_compat_net_memory = malloc(COMPAT_NET_INIT_SIZE);
|
||||
|
||||
initparam.memory = _net_compat_net_memory;
|
||||
@ -286,7 +281,9 @@ bool network_init(void)
|
||||
|
||||
/* Init NetCtl */
|
||||
sceNetCtlInit();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//printf("Net is already initialized.\n");
|
||||
}
|
||||
|
||||
@ -316,7 +313,8 @@ void network_deinit(void)
|
||||
sceNetCtlTerm();
|
||||
sceNetTerm();
|
||||
|
||||
if (_net_compat_net_memory) {
|
||||
if (_net_compat_net_memory)
|
||||
{
|
||||
free(_net_compat_net_memory);
|
||||
_net_compat_net_memory = NULL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user