Changeset - r19640:28cbb33afbc5
[Not reviewed]
master
0 1 0
rubidium - 12 years ago 2012-10-04 15:25:57
rubidium@openttd.org
(svn r24571) -Fix: do not cast away const
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/network/core/os_abstraction.h
Show inline comments
 
@@ -36,49 +36,49 @@ typedef unsigned long in_addr_t;
 
#if !(defined(__MINGW32__) || defined(__CYGWIN__))
 
	/* Windows has some different names for some types */
 
	typedef SSIZE_T ssize_t;
 
	typedef int socklen_t;
 
#	define IPPROTO_IPV6 41
 
#else
 
#include "../../os/windows/win32.h"
 
#include "../../core/alloc_func.hpp"
 

	
 
#define AI_ADDRCONFIG   0x00000400  /* Resolution only if global address configured */
 
#define IPV6_V6ONLY 27
 

	
 
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);
 
	strncpy(host, inet_ntoa(((const struct sockaddr_in *)sa)->sin_addr), hostlen);
 
	return 0;
 
}
 
#define getnameinfo OTTDgetnameinfo
 

	
 
static inline int OTTDgetaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
 
{
 
	static int (WINAPI *getaddrinfo)(const char *, const char *, const struct addrinfo *, struct addrinfo **) = NULL;
 
	static bool first_time = true;
 

	
 
	if (first_time) {
 
		LoadLibraryList((Function*)&getaddrinfo, "ws2_32.dll\0getaddrinfo\0\0");
 
		first_time = false;
 
	}
 

	
 
	if (getaddrinfo != NULL) return getaddrinfo(nodename, servname, hints, res);
 

	
 
	*res = NULL;
 

	
 
	in_addr_t ip = inet_addr(nodename);
 
	if (ip == INADDR_NONE) {
 
		struct hostent *he = gethostbyname(nodename);
 
		if (he == NULL) return EAI_NONAME;
 
		ip = (*(struct in_addr *)he->h_addr).s_addr;
 
	}
0 comments (0 inline, 0 general)