Merge pull request #2506 from comex/enet-build-fixes
ENet fixes (build fixes, upgrade)
This commit is contained in:
commit
49a0adb2e9
|
@ -6,6 +6,7 @@ project(dolphin-emu)
|
|||
|
||||
option(USE_EGL "Enables EGL OpenGL Interface" OFF)
|
||||
option(TRY_X11 "Enables X11 Support" ON)
|
||||
option(USE_SHARED_ENET "Use shared libenet if found rather than Dolphin's soon-to-compatibly-diverge version" OFF)
|
||||
option(USE_UPNP "Enables UPnP port mapping support" ON)
|
||||
option(DISABLE_WX "Disable wxWidgets (use Qt or CLI interface)" OFF)
|
||||
option(ENABLE_QT "Enable Qt (use the experimental Qt interface)" OFF)
|
||||
|
@ -246,12 +247,6 @@ if(APPLE)
|
|||
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};/usr")
|
||||
endif()
|
||||
|
||||
# Some of our code contains Objective C constructs.
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -x objective-c -stdlib=libc++")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++ -stdlib=libc++")
|
||||
# Avoid mistaking an object file for a source file on the link command line.
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -x none")
|
||||
|
||||
# Identify the target system:
|
||||
# Ask for 64-bit binary.
|
||||
set(TARGET_FLAGS "-arch x86_64")
|
||||
|
@ -395,7 +390,7 @@ if(NOT ANDROID)
|
|||
message("ALSA NOT found, disabling ALSA sound backend")
|
||||
endif(ALSA_FOUND)
|
||||
|
||||
check_lib(AO ao QUIET)
|
||||
check_lib(AO ao ao QUIET)
|
||||
if(AO_FOUND)
|
||||
add_definitions(-DHAVE_AO=1)
|
||||
message("ao found, enabling ao sound backend")
|
||||
|
@ -404,7 +399,7 @@ if(NOT ANDROID)
|
|||
message("ao NOT found, disabling ao sound backend")
|
||||
endif(AO_FOUND)
|
||||
|
||||
check_lib(BLUEZ bluez QUIET)
|
||||
check_lib(BLUEZ bluez bluez QUIET)
|
||||
if(BLUEZ_FOUND)
|
||||
add_definitions(-DHAVE_BLUEZ=1)
|
||||
message("bluez found, enabling bluetooth support")
|
||||
|
@ -413,7 +408,7 @@ if(NOT ANDROID)
|
|||
message("bluez NOT found, disabling bluetooth support")
|
||||
endif(BLUEZ_FOUND)
|
||||
|
||||
check_lib(PULSEAUDIO libpulse QUIET)
|
||||
check_lib(PULSEAUDIO libpulse pulse QUIET)
|
||||
if(PULSEAUDIO_FOUND)
|
||||
add_definitions(-DHAVE_PULSEAUDIO=1)
|
||||
message("PulseAudio found, enabling PulseAudio sound backend")
|
||||
|
@ -467,7 +462,7 @@ if(NOT ANDROID)
|
|||
endif()
|
||||
|
||||
if(USE_X11)
|
||||
check_lib(XRANDR Xrandr)
|
||||
check_lib(XRANDR xrandr Xrandr)
|
||||
if(XRANDR_FOUND)
|
||||
add_definitions(-DHAVE_XRANDR=1)
|
||||
else()
|
||||
|
@ -507,8 +502,8 @@ if(NOT ANDROID)
|
|||
endif(PORTAUDIO)
|
||||
|
||||
if(OPROFILING)
|
||||
check_lib(OPROFILE opagent opagent.h)
|
||||
check_lib(BFD bfd bfd.h)
|
||||
check_lib(OPROFILE "(no .pc for opagent)" opagent opagent.h)
|
||||
check_lib(BFD "(no .pc for bfd)" bfd bfd.h)
|
||||
if(OPROFILE_FOUND AND BFD_FOUND)
|
||||
message("oprofile found, enabling profiling support")
|
||||
add_definitions(-DUSE_OPROFILE=1)
|
||||
|
@ -541,11 +536,27 @@ include_directories(Source/Core)
|
|||
add_subdirectory(Externals/Bochs_disasm)
|
||||
include_directories(Externals/Bochs_disasm)
|
||||
|
||||
if(NOT APPLE AND NOT ANDROID)
|
||||
check_lib(ENET enet enet/enet.h QUIET)
|
||||
if(NOT ANDROID AND USE_SHARED_ENET)
|
||||
check_lib(ENET libenet enet enet/enet.h QUIET)
|
||||
include(CheckSymbolExists)
|
||||
if (ENET_FOUND)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${ENET_INCLUDE_DIRS})
|
||||
# hack: LDFLAGS already contains -lenet but all flags but the first are
|
||||
# dropped; ugh, cmake
|
||||
set(CMAKE_REQUIRED_FLAGS ${ENET_LDFLAGS})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${ENET_LIBRARIES})
|
||||
CHECK_SYMBOL_EXISTS(enet_socket_get_address enet/enet.h ENET_HAVE_SGA)
|
||||
set(CMAKE_REQUIRED_INCLUDES)
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
if (NOT ENET_HAVE_SGA)
|
||||
# enet is too old
|
||||
set(ENET_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if (ENET_FOUND)
|
||||
message("Using shared enet")
|
||||
message("Using shared enet")
|
||||
else()
|
||||
message("Using static enet from Externals")
|
||||
include_directories(Externals/enet/include)
|
||||
|
@ -576,7 +587,7 @@ else(ZLIB_FOUND)
|
|||
endif(ZLIB_FOUND)
|
||||
|
||||
if(NOT APPLE AND NOT ANDROID)
|
||||
check_lib(LZO lzo2 lzo/lzo1x.h QUIET)
|
||||
check_lib(LZO "(no .pc for lzo2)" lzo2 lzo/lzo1x.h QUIET)
|
||||
endif()
|
||||
if(LZO_FOUND)
|
||||
message("Using shared lzo")
|
||||
|
@ -589,7 +600,7 @@ endif()
|
|||
list(APPEND LIBS ${LZO})
|
||||
|
||||
if(NOT APPLE AND NOT ANDROID)
|
||||
check_lib(PNG png png.h QUIET)
|
||||
check_lib(PNG libpng png png.h QUIET)
|
||||
endif()
|
||||
if (PNG_FOUND)
|
||||
message("Using shared libpng")
|
||||
|
@ -602,7 +613,7 @@ endif()
|
|||
|
||||
if(OPENAL_FOUND)
|
||||
if(NOT APPLE)
|
||||
check_lib(SOUNDTOUCH SoundTouch soundtouch/SoundTouch.h QUIET)
|
||||
check_lib(SOUNDTOUCH soundtouch SoundTouch soundtouch/SoundTouch.h QUIET)
|
||||
endif()
|
||||
if (SOUNDTOUCH_FOUND)
|
||||
message("Using shared soundtouch")
|
||||
|
@ -687,7 +698,7 @@ else()
|
|||
endif()
|
||||
|
||||
if(NOT APPLE AND NOT ANDROID)
|
||||
check_lib(SOIL SOIL SOIL/SOIL.h QUIET)
|
||||
check_lib(SOIL "(no .pc for SOIL)" SOIL SOIL/SOIL.h QUIET)
|
||||
endif()
|
||||
if(SOIL_FOUND)
|
||||
message("Using shared SOIL")
|
||||
|
@ -746,7 +757,7 @@ if(NOT DISABLE_WX AND NOT ANDROID)
|
|||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}
|
||||
VERSION_EQUAL 2.8.2 OR "${DIST_NAME}" STREQUAL "natty")
|
||||
check_lib(GTK2 gtk+-2.0 gtk.h REQUIRED)
|
||||
check_lib(GTK2 gtk+-2.0 gtk+-2.0 gtk.h REQUIRED)
|
||||
else()
|
||||
include(FindGTK2)
|
||||
if(GTK2_FOUND)
|
||||
|
@ -772,8 +783,8 @@ if(NOT DISABLE_WX AND NOT ANDROID)
|
|||
add_definitions(-D__WXGTK__)
|
||||
|
||||
# Check for required libs
|
||||
check_lib(GTHREAD2 gthread-2.0 glib/gthread.h REQUIRED)
|
||||
check_lib(PANGOCAIRO pangocairo pango/pangocairo.h REQUIRED)
|
||||
check_lib(GTHREAD2 gthread-2.0 gthread-2.0 glib/gthread.h REQUIRED)
|
||||
check_lib(PANGOCAIRO pangocairo pangocairo pango/pangocairo.h REQUIRED)
|
||||
elseif(WIN32)
|
||||
add_definitions(-D__WXMSW__)
|
||||
else()
|
||||
|
@ -844,6 +855,15 @@ add_definitions(-std=gnu++0x)
|
|||
# but some dependencies require them (LLVM, libav).
|
||||
add_definitions(-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS)
|
||||
|
||||
# Do this at the last minute because try_compile ignores linker flags. Yay...
|
||||
if(APPLE)
|
||||
# Some of our code contains Objective C constructs.
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -x objective-c -stdlib=libc++")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++ -stdlib=libc++")
|
||||
# Avoid mistaking an object file for a source file on the link command line.
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -x none")
|
||||
endif()
|
||||
|
||||
add_subdirectory(Source)
|
||||
|
||||
|
||||
|
@ -889,4 +909,3 @@ list(APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_BINARY_DIR}")
|
|||
# CPack must be included after the CPACK_* variables are set in order for those
|
||||
# variables to take effect.
|
||||
Include(CPack)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ macro(_internal_message msg)
|
|||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(check_lib var lib)
|
||||
macro(check_lib var pc lib)
|
||||
set(_is_required 0)
|
||||
set(_is_quiet 0)
|
||||
set(_arg_list ${ARGN})
|
||||
|
@ -22,8 +22,7 @@ macro(check_lib var lib)
|
|||
endforeach()
|
||||
|
||||
if(PKG_CONFIG_FOUND AND NOT ${var}_FOUND)
|
||||
string(TOLOWER ${lib} lower_lib)
|
||||
pkg_search_module(${var} QUIET ${lower_lib})
|
||||
pkg_search_module(${var} QUIET ${pc})
|
||||
endif()
|
||||
|
||||
if(${var}_FOUND)
|
||||
|
|
|
@ -8,6 +8,8 @@ include(CheckStructHasMember)
|
|||
include(CheckTypeSize)
|
||||
check_function_exists("fcntl" HAS_FCNTL)
|
||||
check_function_exists("poll" HAS_POLL)
|
||||
check_function_exists("getaddrinfo" HAS_GETADDRINFO)
|
||||
check_function_exists("getnameinfo" HAS_GETNAMEINFO)
|
||||
check_function_exists("gethostbyname_r" HAS_GETHOSTBYNAME_R)
|
||||
check_function_exists("gethostbyaddr_r" HAS_GETHOSTBYADDR_R)
|
||||
check_function_exists("inet_pton" HAS_INET_PTON)
|
||||
|
@ -23,6 +25,12 @@ endif()
|
|||
if(HAS_POLL)
|
||||
add_definitions(-DHAS_POLL=1)
|
||||
endif()
|
||||
if(HAS_GETNAMEINFO)
|
||||
add_definitions(-DHAS_GETNAMEINFO=1)
|
||||
endif()
|
||||
if(HAS_GETADDRINFO)
|
||||
add_definitions(-DHAS_GETADDRINFO=1)
|
||||
endif()
|
||||
if(HAS_GETHOSTBYNAME_R)
|
||||
add_definitions(-DHAS_GETHOSTBYNAME_R=1)
|
||||
endif()
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
* use getaddrinfo and getnameinfo where available
|
||||
|
||||
ENet 1.3.13 (April 30, 2015):
|
||||
|
||||
* miscellaneous bug fixes
|
||||
* added premake and cmake support
|
||||
* miscellaneous documentation cleanups
|
||||
|
||||
ENet 1.3.12 (April 24, 2014):
|
||||
|
||||
* added maximumPacketSize and maximumWaitingData fields to ENetHost to limit the amount of
|
||||
|
|
|
@ -38,7 +38,7 @@ PROJECT_NAME = "ENet"
|
|||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = v1.3.12
|
||||
PROJECT_NUMBER = v1.3.13
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
|
|
@ -16,7 +16,7 @@ enetinclude_HEADERS = \
|
|||
lib_LTLIBRARIES = libenet.la
|
||||
libenet_la_SOURCES = callbacks.c compress.c host.c list.c packet.c peer.c protocol.c unix.c win32.c
|
||||
# see info '(libtool) Updating version info' before making a release
|
||||
libenet_la_LDFLAGS = $(AM_LDFLAGS) -version-info 7:0:0
|
||||
libenet_la_LDFLAGS = $(AM_LDFLAGS) -version-info 7:1:0
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include
|
||||
|
||||
ACLOCAL_AMFLAGS = -Im4
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
AC_INIT([libenet], [1.3.12])
|
||||
AC_INIT([libenet], [1.3.13])
|
||||
AC_CONFIG_SRCDIR([include/enet/enet.h])
|
||||
AM_INIT_AUTOMAKE([foreign])
|
||||
|
||||
|
@ -7,6 +7,8 @@ AC_CONFIG_MACRO_DIR([m4])
|
|||
AC_PROG_CC
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
AC_CHECK_FUNC(getaddrinfo, [AC_DEFINE(HAS_GETADDRINFO)])
|
||||
AC_CHECK_FUNC(getnameinfo, [AC_DEFINE(HAS_GETNAMEINFO)])
|
||||
AC_CHECK_FUNC(gethostbyaddr_r, [AC_DEFINE(HAS_GETHOSTBYADDR_R)])
|
||||
AC_CHECK_FUNC(gethostbyname_r, [AC_DEFINE(HAS_GETHOSTBYNAME_R)])
|
||||
AC_CHECK_FUNC(poll, [AC_DEFINE(HAS_POLL)])
|
||||
|
|
|
@ -36,7 +36,7 @@ portable, and easily embeddable.
|
|||
You can retrieve the source to ENet by downloading it in either .tar.gz form
|
||||
or accessing the github distribution directly.
|
||||
|
||||
The most recent stable release (1.3.12) can be downloaded <a class="el" href="download/enet-1.3.12.tar.gz">here</a>.
|
||||
The most recent stable release (1.3.13) can be downloaded <a class="el" href="download/enet-1.3.13.tar.gz">here</a>.
|
||||
The last release that is protocol compatible with the 1.2 series or earlier (1.2.5) can be downloaded <a class="el" href="download/enet-1.2.5.tar.gz">here</a>.
|
||||
|
||||
You can find the most recent ENet source at <a class="el" href="https://github.com/lsalzman/enet">the github repository</a>.
|
||||
|
|
|
@ -13,19 +13,19 @@ extern "C"
|
|||
#include <stdlib.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "win32.h"
|
||||
#include "enet/win32.h"
|
||||
#else
|
||||
#include "unix.h"
|
||||
#include "enet/unix.h"
|
||||
#endif
|
||||
|
||||
#include "types.h"
|
||||
#include "protocol.h"
|
||||
#include "list.h"
|
||||
#include "callbacks.h"
|
||||
#include "enet/types.h"
|
||||
#include "enet/protocol.h"
|
||||
#include "enet/list.h"
|
||||
#include "enet/callbacks.h"
|
||||
|
||||
#define ENET_VERSION_MAJOR 1
|
||||
#define ENET_VERSION_MINOR 3
|
||||
#define ENET_VERSION_PATCH 12
|
||||
#define ENET_VERSION_PATCH 13
|
||||
#define ENET_VERSION_CREATE(major, minor, patch) (((major)<<16) | ((minor)<<8) | (patch))
|
||||
#define ENET_VERSION_GET_MAJOR(version) (((version)>>16)&0xFF)
|
||||
#define ENET_VERSION_GET_MINOR(version) (((version)>>8)&0xFF)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef __ENET_PROTOCOL_H__
|
||||
#define __ENET_PROTOCOL_H__
|
||||
|
||||
#include "types.h"
|
||||
#include "enet/types.h"
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -764,6 +764,10 @@ enet_protocol_handle_bandwidth_limit (ENetHost * host, ENetPeer * peer, const EN
|
|||
|
||||
if (peer -> incomingBandwidth == 0 && host -> outgoingBandwidth == 0)
|
||||
peer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE;
|
||||
else
|
||||
if (peer -> incomingBandwidth == 0 || host -> outgoingBandwidth == 0)
|
||||
peer -> windowSize = (ENET_MAX (peer -> incomingBandwidth, host -> outgoingBandwidth) /
|
||||
ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE;
|
||||
else
|
||||
peer -> windowSize = (ENET_MIN (peer -> incomingBandwidth, host -> outgoingBandwidth) /
|
||||
ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE;
|
||||
|
@ -1486,7 +1490,7 @@ enet_protocol_send_reliable_outgoing_commands (ENetHost * host, ENetPeer * peer)
|
|||
! (outgoingCommand -> reliableSequenceNumber % ENET_PEER_RELIABLE_WINDOW_SIZE) &&
|
||||
(channel -> reliableWindows [(reliableWindow + ENET_PEER_RELIABLE_WINDOWS - 1) % ENET_PEER_RELIABLE_WINDOWS] >= ENET_PEER_RELIABLE_WINDOW_SIZE ||
|
||||
channel -> usedReliableWindows & ((((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) << reliableWindow) |
|
||||
(((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) >> (ENET_PEER_RELIABLE_WINDOW_SIZE - reliableWindow)))))
|
||||
(((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) >> (ENET_PEER_RELIABLE_WINDOWS - reliableWindow)))))
|
||||
windowWrap = 1;
|
||||
if (windowWrap)
|
||||
{
|
||||
|
|
|
@ -38,6 +38,12 @@
|
|||
#ifndef HAS_SOCKLEN_T
|
||||
#define HAS_SOCKLEN_T 1
|
||||
#endif
|
||||
#ifndef HAS_GETADDRINFO
|
||||
#define HAS_GETADDRINFO 1
|
||||
#endif
|
||||
#ifndef HAS_GETNAMEINFO
|
||||
#define HAS_GETNAMEINFO 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAS_FCNTL
|
||||
|
@ -98,6 +104,32 @@ enet_time_set (enet_uint32 newTimeBase)
|
|||
int
|
||||
enet_address_set_host (ENetAddress * address, const char * name)
|
||||
{
|
||||
#ifdef HAS_GETADDRINFO
|
||||
struct addrinfo hints, * resultList = NULL, * result = NULL;
|
||||
|
||||
memset (& hints, 0, sizeof (hints));
|
||||
hints.ai_family = AF_INET;
|
||||
|
||||
if (getaddrinfo (name, NULL, NULL, & resultList) != 0)
|
||||
return -1;
|
||||
|
||||
for (result = resultList; result != NULL; result = result -> ai_next)
|
||||
{
|
||||
if (result -> ai_family == AF_INET && result -> ai_addr != NULL && result -> ai_addrlen >= sizeof (struct sockaddr_in))
|
||||
{
|
||||
struct sockaddr_in * sin = (struct sockaddr_in *) result -> ai_addr;
|
||||
|
||||
address -> host = sin -> sin_addr.s_addr;
|
||||
|
||||
freeaddrinfo (resultList);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (resultList != NULL)
|
||||
freeaddrinfo (resultList);
|
||||
#else
|
||||
struct hostent * hostEntry = NULL;
|
||||
#ifdef HAS_GETHOSTBYNAME_R
|
||||
struct hostent hostData;
|
||||
|
@ -113,19 +145,20 @@ enet_address_set_host (ENetAddress * address, const char * name)
|
|||
hostEntry = gethostbyname (name);
|
||||
#endif
|
||||
|
||||
if (hostEntry == NULL ||
|
||||
hostEntry -> h_addrtype != AF_INET)
|
||||
if (hostEntry != NULL && hostEntry -> h_addrtype == AF_INET)
|
||||
{
|
||||
#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;
|
||||
address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0];
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0];
|
||||
#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;
|
||||
}
|
||||
|
@ -153,6 +186,26 @@ enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameL
|
|||
int
|
||||
enet_address_get_host (const ENetAddress * address, char * name, size_t nameLength)
|
||||
{
|
||||
#ifdef HAS_GETNAMEINFO
|
||||
struct sockaddr_in sin;
|
||||
int err;
|
||||
|
||||
memset (& sin, 0, sizeof (struct sockaddr_in));
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = ENET_HOST_TO_NET_16 (address -> port);
|
||||
sin.sin_addr.s_addr = address -> host;
|
||||
|
||||
err = getnameinfo ((struct sockaddr *) & sin, sizeof (sin), name, nameLength, NULL, 0, NI_NAMEREQD);
|
||||
if (! err)
|
||||
{
|
||||
if (name != NULL && nameLength > 0 && ! memchr (name, '\0', nameLength))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
if (err != EAI_NONAME)
|
||||
return 0;
|
||||
#else
|
||||
struct in_addr in;
|
||||
struct hostent * hostEntry = NULL;
|
||||
#ifdef HAS_GETHOSTBYADDR_R
|
||||
|
@ -173,17 +226,17 @@ enet_address_get_host (const ENetAddress * address, char * name, size_t nameLeng
|
|||
hostEntry = gethostbyaddr ((char *) & in, sizeof (struct in_addr), AF_INET);
|
||||
#endif
|
||||
|
||||
if (hostEntry == NULL)
|
||||
return enet_address_get_host_ip (address, name, nameLength);
|
||||
else
|
||||
if (hostEntry != NULL)
|
||||
{
|
||||
size_t hostLen = strlen (hostEntry -> h_name);
|
||||
if (hostLen >= nameLength)
|
||||
return -1;
|
||||
memcpy (name, hostEntry -> h_name, hostLen + 1);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return enet_address_get_host_ip (address, name, nameLength);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in New Issue