Mercurial > hg > openttd
changeset 11554:2a8e3e39662f draft
(svn r15919) -Fix (r15916): mingw doesn't know getnameinfo() (unless you compile for XP SP2+). Also fix a MSVC warning.
author | glx <glx@openttd.org> |
---|---|
date | Thu, 02 Apr 2009 23:22:59 +0000 |
parents | c45b1260a1a1 |
children | e33ab0599ab6 |
files | src/network/core/os_abstraction.h src/network/core/tcp_content.h |
diffstat | 2 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/network/core/os_abstraction.h +++ b/src/network/core/os_abstraction.h @@ -23,6 +23,25 @@ /* Windows has some different names for some types */ typedef SSIZE_T ssize_t; typedef int socklen_t; +#else +#include "../../win32.h" + +static inline int OTTDgetnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, DWORD hostlen, char *serv, DWORD servlen, int flags) +{ + static int (WINAPI *getnameinfo)(const struct sockaddr *, socklen_t, char *, DWORD, char *, DWORD, int) = NULL; + static bool first_time = true; + + if (first_time) { + LoadLibraryList((Function*)&getnameinfo, "ws2_32.dll\0getnameinfo\0\0"); + first_time = false; + } + + if (getnameinfo != NULL) return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags); + + strncpy(host, inet_ntoa(((struct sockaddr_in *)sa)->sin_addr), hostlen); + return 0; +} +#define getnameinfo OTTDgetnameinfo #endif #define GET_LAST_ERROR() WSAGetLastError()
--- a/src/network/core/tcp_content.h +++ b/src/network/core/tcp_content.h @@ -101,7 +101,7 @@ /** Base socket handler for all Content TCP sockets */ class NetworkContentSocketHandler : public NetworkTCPSocketHandler { protected: - struct NetworkAddress client_addr; ///< The address we're connected to. + NetworkAddress client_addr; ///< The address we're connected to. virtual void Close(); /**