Create inet_ptrton

This commit is contained in:
twinaphex 2016-05-08 15:41:23 +02:00
parent c3676a07b1
commit 11ec23bc18
3 changed files with 16 additions and 9 deletions

View File

@ -136,14 +136,6 @@ struct hostent
#ifdef GEKKO
#define sendto(s, msg, len, flags, addr, tolen) net_sendto(s, msg, len, 0, addr, 8)
#define socket(domain, type, protocol) net_socket(domain, type, protocol)
static INLINE int inet_pton(int af, const char *src, void *dst)
{
if (af != AF_INET)
return -1;
return inet_aton (src, dst);
}
#endif
static INLINE bool isagain(int bytes)
@ -213,6 +205,8 @@ struct addrinfo
uint16_t inet_htons(uint16_t hostshort);
int inet_ptrton(int af, const char *src, void *dst);
int getaddrinfo_retro(const char *node, const char *service,
struct addrinfo *hints, struct addrinfo **res);

View File

@ -326,3 +326,16 @@ uint16_t inet_htons(uint16_t hostshort)
return htons(hostshort);
#endif
}
int inet_ptrton(int af, const char *src, void *dst)
{
/* TODO/FIXME - should use InetPton on Vista and later */
#if defined(GEKKO) || defined(_WIN32)
if (af != AF_INET)
return -1;
return inet_aton(src, dst);
#else
return inet_pton(af, src, dst);
#endif
}

View File

@ -307,7 +307,7 @@ void socket_set_target(void *data, socket_target_t *in_addr)
out_target->sin_len = 8;
#endif
inet_pton(AF_INET, in_addr->server, &out_target->sin_addr);
inet_ptrton(AF_INET, in_addr->server, &out_target->sin_addr);
#endif
}