diff options
author | eihrul <eihrul> | 2006-03-14 23:21:50 +0000 |
---|---|---|
committer | eihrul <eihrul> | 2006-03-14 23:21:50 +0000 |
commit | 550d23e25d731abf9c8d400b5ef45b00b0cd2f1e (patch) | |
tree | 2ddb0715e0f9cc0d269b07a2977a073949d482a8 /unix.c | |
parent | 102f1e22cf02bb19ef53a824e31d34c766ebb2a7 (diff) | |
download | enet-550d23e25d731abf9c8d400b5ef45b00b0cd2f1e.tar.gz enet-550d23e25d731abf9c8d400b5ef45b00b0cd2f1e.zip |
1.0 stuff
Diffstat (limited to 'unix.c')
-rw-r--r-- | unix.c | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -8,6 +8,7 @@ #include <sys/socket.h> #include <sys/ioctl.h> #include <sys/time.h> +#include <arpa/inet.h> #include <netdb.h> #include <unistd.h> #include <string.h> @@ -21,6 +22,10 @@ #include <fcntl.h> #endif +#ifdef __APPLE__ +#undef HAS_POLL +#endif + #ifdef HAS_POLL #include <sys/poll.h> #endif @@ -86,7 +91,15 @@ enet_address_set_host (ENetAddress * address, const char * name) if (hostEntry == NULL || hostEntry -> h_addrtype != AF_INET) - return -1; + { +#ifdef HAS_INET_PTON + if (! inet_pton (AF_INET, name, & address -> host)) +#else + if (! inet_aton (name, (struct in_addr *) & address -> host)) +#endif + return -1; + return 0; + } address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0]; @@ -117,7 +130,18 @@ enet_address_get_host (const ENetAddress * address, char * name, size_t nameLeng #endif if (hostEntry == NULL) - return -1; + { +#ifdef HAS_INET_NTOP + if (inet_ntop (AF_INET, & address -> host, name, nameLength) == NULL) +#else + char * addr = inet_ntoa (* (struct in_addr *) & address -> host); + if (addr != NULL) + strncpy (name, addr, nameLength); + else +#endif + return -1; + return 0; + } strncpy (name, hostEntry -> h_name, nameLength); |