Merge pull request #174 from FluidSynth/mingw_build

check for inet_ntop()
This commit is contained in:
Tom M 2017-07-15 18:08:28 +02:00 committed by GitHub
commit 9079974c59
4 changed files with 40 additions and 16 deletions

View file

@ -101,6 +101,7 @@ include ( DefaultDirs )
# Basic C library checks
include ( CheckSTDC )
include ( CheckIncludeFile )
include ( CheckFunctionExists )
check_include_file ( string.h HAVE_STRING_H )
check_include_file ( stdlib.h HAVE_STDLIB_H )
check_include_file ( stdio.h HAVE_STDIO_H )
@ -224,6 +225,16 @@ if ( ${CMAKE_SYSTEM} MATCHES "Darwin" )
endif ( enable-framework )
endif ( ${CMAKE_SYSTEM} MATCHES "Darwin" )
unset ( HAVE_INETNTOP CACHE )
unset ( IPV6_SUPPORT CACHE )
CHECK_FUNCTION_EXISTS ( "inet_ntop" HAVE_INETNTOP )
if ( enable-ipv6 )
if ( HAVE_INETNTOP )
set ( IPV6_SUPPORT 1 )
endif ( HAVE_INETNTOP )
endif ( enable-ipv6 )
unset ( WITH_FLOAT CACHE )
if ( enable-floats )
set ( WITH_FLOAT 1 )
@ -389,12 +400,6 @@ else ( enable-dbus )
unset_pkg_config ( DBUS )
endif ( enable-dbus )
unset ( IPV6_SUPPORT CACHE )
if ( enable-ipv6 )
set ( IPV6 1 )
set ( IPV6_SUPPORT 1 )
endif ( enable-ipv6 )
# General configuration file
configure_file ( ${CMAKE_SOURCE_DIR}/src/config.cmake
${CMAKE_BINARY_DIR}/config.h )

View file

@ -133,6 +133,9 @@
/* Define to 1 if you have the <getopt.h> header file. */
#cmakedefine HAVE_GETOPT_H @HAVE_GETOPT_H@
/* Define to 1 if you have the inet_ntop() function. */
#cmakedefine HAVE_INETNTOP @HAVE_INETNTOP@
/* Define to enable JACK driver */
#cmakedefine JACK_SUPPORT @JACK_SUPPORT@
@ -140,7 +143,7 @@
#cmakedefine LADSPA @LADSPA_SUPPORT@
/* Define to enable IPV6 support */
#cmakedefine IPV6 @IPV6_SUPPORT@
#cmakedefine IPV6_SUPPORT @IPV6_SUPPORT@
/* libsndfile has ogg vorbis support */
#cmakedefine LIBSNDFILE_HASVORBIS @LIBSNDFILE_HASVORBIS@

View file

@ -981,7 +981,7 @@ fluid_server_socket_run (void *data)
{
fluid_server_socket_t *server_socket = (fluid_server_socket_t *)data;
fluid_socket_t client_socket;
#ifdef IPV6
#ifdef IPV6_SUPPORT
struct sockaddr_in6 addr;
char straddr[INET6_ADDRSTRLEN];
#else
@ -1008,13 +1008,20 @@ fluid_server_socket_run (void *data)
server_socket->cont = 0;
return;
} else {
#ifdef IPV6
#ifdef HAVE_INETNTOP
#ifdef IPV6_SUPPORT
inet_ntop(AF_INET6, &addr.sin6_addr, straddr, sizeof(straddr));
#else
inet_ntop(AF_INET, &addr.sin_addr, straddr, sizeof(straddr));
#endif
#endif
#ifdef HAVE_INETNTOP
retval = server_socket->func (server_socket->data, client_socket,
straddr);
#else
retval = server_socket->func (server_socket->data, client_socket,
inet_ntoa (addr.sin_addr));
#endif
if (retval != 0)
fluid_socket_close(client_socket);
@ -1028,7 +1035,7 @@ fluid_server_socket_t*
new_fluid_server_socket(int port, fluid_server_func_t func, void* data)
{
fluid_server_socket_t* server_socket;
#ifdef IPV6
#ifdef IPV6_SUPPORT
struct sockaddr_in6 addr;
#else
struct sockaddr_in addr;
@ -1036,7 +1043,7 @@ new_fluid_server_socket(int port, fluid_server_func_t func, void* data)
fluid_socket_t sock;
g_return_val_if_fail (func != NULL, NULL);
#ifdef IPV6
#ifdef IPV6_SUPPORT
sock = socket(AF_INET6, SOCK_STREAM, 0);
if (sock == INVALID_SOCKET) {
FLUID_LOG(FLUID_ERR, "Failed to create server socket");
@ -1136,12 +1143,14 @@ static void fluid_server_socket_run (void *data)
{
fluid_server_socket_t *server_socket = (fluid_server_socket_t *)data;
fluid_socket_t client_socket;
#ifdef IPV6
#ifdef IPV6_SUPPORT
struct sockaddr_in6 addr;
char straddr[INET6_ADDRSTRLEN];
#else
struct sockaddr_in addr;
#ifdef HAVE_INETNTOP
char straddr[INET_ADDRSTRLEN];
#endif
#endif
socklen_t addrlen = sizeof (addr);
int r;
@ -1165,13 +1174,20 @@ static void fluid_server_socket_run (void *data)
}
else
{
#ifdef IPV6
#ifdef HAVE_INETNTOP
#ifdef IPV6_SUPPORT
inet_ntop(AF_INET6, &addr.sin6_addr, straddr, sizeof(straddr));
#else
inet_ntop(AF_INET, &addr.sin_addr, straddr, sizeof(straddr));
#endif
#endif
#ifdef HAVE_INETNTOP
r = server_socket->func (server_socket->data, client_socket,
straddr);
#else
r = server_socket->func (server_socket->data, client_socket,
inet_ntoa (addr.sin_addr));
#endif
if (r != 0)
fluid_socket_close (client_socket);
}
@ -1184,7 +1200,7 @@ fluid_server_socket_t*
new_fluid_server_socket(int port, fluid_server_func_t func, void* data)
{
fluid_server_socket_t* server_socket;
#ifdef IPV6
#ifdef IPV6_SUPPORT
struct sockaddr_in6 addr;
#else
struct sockaddr_in addr;
@ -1204,7 +1220,7 @@ new_fluid_server_socket(int port, fluid_server_func_t func, void* data)
FLUID_LOG(FLUID_ERR, "Server socket creation error: WSAStartup failed: %d", retval);
return NULL;
}
#ifdef IPV6
#ifdef IPV6_SUPPORT
sock = socket (AF_INET6, SOCK_STREAM, 0);
if (sock == INVALID_SOCKET)
{

View file

@ -112,7 +112,7 @@
#include <io.h>
#endif
#if HAVE_WINDOWS_H
#if defined(WIN32) && HAVE_WINDOWS_H
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>