mirror of https://github.com/mgba-emu/mgba.git
Util: More buildfixes
This commit is contained in:
parent
536170c331
commit
d4b3bcde0f
|
@ -466,21 +466,28 @@ static inline int SocketResolveHost(const char* addrString, struct Address* dest
|
|||
if (!host) {
|
||||
return errno;
|
||||
}
|
||||
family = host->h_addrtype;
|
||||
if (host->h_addrtype == AF_INET && host->h_length == 4) {
|
||||
destAddress->version = IPV4;
|
||||
destAddress->ipv4 = ntohl(*host->h_addr_list[0]);
|
||||
} else if (host->h_addrtype == AF_INET6 && host->h_length == 16) {
|
||||
}
|
||||
#ifdef HAS_IPV6
|
||||
else if (host->h_addrtype == AF_INET6 && host->h_length == 16) {
|
||||
destAddress->version = IPV6;
|
||||
memcpy(destAddress->ipv6, host->h_addr_list[0], 16);
|
||||
} else {
|
||||
result = NO_DATA;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
#ifdef GEKKO
|
||||
result = errno;
|
||||
#else
|
||||
result = -h_errno;
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
struct addrinfo* addr = NULL;
|
||||
result = getaddrinfo(addrString, NULL, NULL, &addr);
|
||||
if (result) {
|
||||
#ifndef _WIN32
|
||||
#ifdef EAI_SYSTEM
|
||||
if (result == EAI_SYSTEM) {
|
||||
result = errno;
|
||||
}
|
||||
|
@ -491,15 +498,19 @@ static inline int SocketResolveHost(const char* addrString, struct Address* dest
|
|||
struct sockaddr_in* addr4 = (struct sockaddr_in*) addr->ai_addr;
|
||||
destAddress->version = IPV4;
|
||||
destAddress->ipv4 = ntohl(addr4->sin_addr.s_addr);
|
||||
} else if (addr->ai_family == AF_INET6 && addr->ai_addrlen == sizeof(struct sockaddr_in6)) {
|
||||
}
|
||||
#ifdef HAS_IPV6
|
||||
else if (addr->ai_family == AF_INET6 && addr->ai_addrlen == sizeof(struct sockaddr_in6)) {
|
||||
struct sockaddr_in6* addr6 = (struct sockaddr_in6*) addr->ai_addr;
|
||||
destAddress->version = IPV6;
|
||||
memcpy(destAddress->ipv6, addr6->sin6_addr.s6_addr, 16);
|
||||
} else {
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
#ifdef _WIN32
|
||||
result = WSANO_DATA;
|
||||
#else
|
||||
result = EAI_NODATA;
|
||||
result = EAI_NONAME;
|
||||
#endif
|
||||
}
|
||||
error:
|
||||
|
|
|
@ -47,7 +47,9 @@ static const struct _mScriptSocketErrorMapping {
|
|||
#else
|
||||
{ EAI_AGAIN, mSCRIPT_SOCKERR_AGAIN },
|
||||
{ EAI_FAIL, mSCRIPT_SOCKERR_FAILED },
|
||||
#ifdef EAI_NODATA
|
||||
{ EAI_NODATA, mSCRIPT_SOCKERR_NO_DATA },
|
||||
#endif
|
||||
{ EAI_NONAME, mSCRIPT_SOCKERR_NOT_FOUND },
|
||||
{ EAI_MEMORY, mSCRIPT_SOCKERR_OUT_OF_MEMORY },
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue