FreeRDP/FreeRDP — Issue #372: Compile Error on XP SP3(VS2010)
Author: yoonzh
Created: 2012-01-27 04:56:28+00:00
State: open

libfreerdp-core/listner.c

There is no inet_ntop() on XP.

So, i added two functions as below.

#if defined(_WIN32) && _WIN32_WINNT <= 0x0600
const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
{
if (af == AF_INET)
{
struct sockaddr_in in;
memset(&in, 0, sizeof(in));
in.sin_family = AF_INET;
memcpy(&in.sin_addr, src, sizeof(struct in_addr));
getnameinfo((struct sockaddr *)&in, sizeof(struct
sockaddr_in), dst, cnt, NULL, 0, NI_NUMERICHOST);
return dst;
}
else if (af == AF_INET6)
{
struct sockaddr_in6 in;
memset(&in, 0, sizeof(in));
in.sin6_family = AF_INET6;
memcpy(&in.sin6_addr, src, sizeof(struct in_addr6));
getnameinfo((struct sockaddr *)&in, sizeof(struct
sockaddr_in6), dst, cnt, NULL, 0, NI_NUMERICHOST);
return dst;
}
return NULL;
}

int inet_pton(int af, const char *src, void *dst)
{
struct addrinfo hints, *res, *ressave;

memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = af;

if (getaddrinfo(src, NULL, &hints, &res) != 0)
{
// Commented out because dolog and LOG_ERR are not defined...
// dolog(LOG_ERR, "Couldn't resolve host %s", src);
return -1;
}

ressave = res;

while (res)
{
memcpy(dst, res->ai_addr, res->ai_addrlen);
res = res->ai_next;
}

freeaddrinfo(ressave);
return 0;
}
#endif

And, modify CMakeList.txt as below

if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd /MT")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /O2 /Ob2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_X86_")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_UNICODE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFREERDP_EXPORTS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_WIN32_WINNT=0x0502") # Added (min req. 2003 SP1 or XP SP2)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
endif()