workaround for windows compiler without inet_ntop
This commit is contained in:
@@ -203,6 +203,15 @@ AC_TYPE_SIZE_T
|
|||||||
AC_TYPE_UINT16_T
|
AC_TYPE_UINT16_T
|
||||||
AC_CHECK_DECLS([SO_NOSIGPIPE], [], [], [#include <sys/socket.h>])
|
AC_CHECK_DECLS([SO_NOSIGPIPE], [], [], [#include <sys/socket.h>])
|
||||||
AC_CHECK_DECLS([MSG_NOSIGNAL], [], [], [#include <sys/socket.h>])
|
AC_CHECK_DECLS([MSG_NOSIGNAL], [], [], [#include <sys/socket.h>])
|
||||||
|
if test "${WIN32}" = "yes"
|
||||||
|
then
|
||||||
|
saved_CPPFLAGS="$CPPFLAGS"
|
||||||
|
CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0600"
|
||||||
|
AC_CHECK_DECLS([inet_ntop], [], [], [#include <ws2tcpip.h>])
|
||||||
|
CPPFLAGS="$saved_CPPFLAGS"
|
||||||
|
else
|
||||||
|
AC_CHECK_DECLS([inet_ntop], [], [], [#include <arpa/inet.h>])
|
||||||
|
fi
|
||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_FUNC_MALLOC
|
AC_FUNC_MALLOC
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
EXTRA_DIST = qransi.c
|
EXTRA_DIST = qransi.c inet_ntop.c
|
||||||
|
|
||||||
bin_PROGRAMS = vpcd-config
|
bin_PROGRAMS = vpcd-config
|
||||||
|
|
||||||
|
|||||||
15
virtualsmartcard/src/vpcd-config/inet_ntop.c
Normal file
15
virtualsmartcard/src/vpcd-config/inet_ntop.c
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
/* Taken from https://memset.wordpress.com/2010/10/09/inet_ntop-for-win32/ */
|
||||||
|
|
||||||
|
const char* inet_ntop(int af, const void* src, char* dst, int cnt){
|
||||||
|
|
||||||
|
struct sockaddr_in srcaddr;
|
||||||
|
|
||||||
|
memset(&srcaddr, 0, sizeof(struct sockaddr_in));
|
||||||
|
memcpy(&(srcaddr.sin_addr), src, sizeof(srcaddr.sin_addr));
|
||||||
|
|
||||||
|
srcaddr.sin_family = af;
|
||||||
|
if (WSAAddressToString((struct sockaddr*) &srcaddr, sizeof(struct sockaddr_in), 0, dst, (LPDWORD) &cnt) != 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
@@ -5,6 +5,9 @@
|
|||||||
* Use getsockname and a udp connection
|
* Use getsockname and a udp connection
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
#include<stdio.h> //printf
|
#include<stdio.h> //printf
|
||||||
#include<string.h> //memset
|
#include<string.h> //memset
|
||||||
#include<errno.h> //errno
|
#include<errno.h> //errno
|
||||||
@@ -12,6 +15,9 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include<winsock2.h>
|
#include<winsock2.h>
|
||||||
#include<ws2tcpip.h>
|
#include<ws2tcpip.h>
|
||||||
|
#if defined(HAVE_DECL_INET_NTOP) && ! HAVE_DECL_INET_NTOP
|
||||||
|
#include"inet_ntop.c"
|
||||||
|
#endif
|
||||||
#define close(s) closesocket(s)
|
#define close(s) closesocket(s)
|
||||||
#else
|
#else
|
||||||
#include<sys/socket.h> //socket
|
#include<sys/socket.h> //socket
|
||||||
|
|||||||
Reference in New Issue
Block a user