From b4f13c62518254325154926867dd20facedb62a2 Mon Sep 17 00:00:00 2001 From: Thomas Krennwallner Date: Mon, 29 Aug 2016 14:58:13 +0200 Subject: [PATCH] add MS Visual Studio solution and windows sockets --- README | 17 +++ artnet/artnet.c | 2 +- artnet/artnet.h | 12 +- artnet/network.c | 8 +- artnet/private.h | 10 +- msvc/libartnet/libartnet.sln | 28 ++++ msvc/libartnet/libartnet.vcxproj | 175 +++++++++++++++++++++++ msvc/libartnet/libartnet.vcxproj.filters | 57 ++++++++ 8 files changed, 294 insertions(+), 15 deletions(-) create mode 100644 msvc/libartnet/libartnet.sln create mode 100644 msvc/libartnet/libartnet.vcxproj create mode 100644 msvc/libartnet/libartnet.vcxproj.filters diff --git a/README b/README index 2767c2b..7d33e56 100644 --- a/README +++ b/README @@ -12,3 +12,20 @@ for a 64-bit build: --host=x86_64-w64-mingw32 for a 32-bit build: --host=i686-w64-mingw32 ./configure ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes --host=x86_64-w64-mingw32 --prefix=/some/path/prefix + + +Building libartnet with MS Visual Studio: + +either open msvc\libartnet\libartnet.sln with devenv.exe or use msbuild: + +for 64-bit build: "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 +for 32-bit build: "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 + +build libartnet: + +cd msvc\libartnet + +for 64-bit Release build: msbuild libartnet.sln /t:libartnet /p:Configuration=Release /p:Platform=x64 +for 32-bit Release build: msbuild libartnet.sln /t:libartnet /p:Configuration=Release /p:Platform=x86 +for 64-bit Debug build: msbuild libartnet.sln /t:libartnet /p:Configuration=Debug /p:Platform=x64 +for 32-bit Debug build: msbuild libartnet.sln /t:libartnet /p:Configuration=Debug /p:Platform=x86 diff --git a/artnet/artnet.c b/artnet/artnet.c index 6efa91f..fc016ad 100644 --- a/artnet/artnet.c +++ b/artnet/artnet.c @@ -1387,7 +1387,7 @@ int artnet_dump_config(artnet_node vn) { * @param socket the index of the socket descriptor to fetch (0 or 1) * @return the socket descriptor */ -int artnet_get_sd(artnet_node vn) { +artnet_socket_t artnet_get_sd(artnet_node vn) { node n = (node) vn; check_nullnode(vn); diff --git a/artnet/artnet.h b/artnet/artnet.h index 90dca02..2b79134 100644 --- a/artnet/artnet.h +++ b/artnet/artnet.h @@ -25,7 +25,7 @@ // order is important here for osx #include -#ifndef WIN32 +#if !defined(WIN32) && !defined(_MSC_VER) #include #else #include @@ -210,6 +210,12 @@ typedef void *artnet_node; /** A list of remote ArtNet nodes */ typedef void *artnet_node_list; +#if !defined(WIN32) && !defined(_MSC_VER) +typedef int artnet_socket_t; +#else +typedef SOCKET artnet_socket_t; +#endif + // node control functions EXTERN artnet_node artnet_new(const char *ip, int verbose); EXTERN int artnet_setoem(artnet_node vn, uint8_t hi, uint8_t lo); @@ -334,10 +340,10 @@ EXTERN int artnet_nl_get_length(artnet_node_list nl); // misc EXTERN int artnet_dump_config(artnet_node n); EXTERN int artnet_get_config(artnet_node n, artnet_node_config_t *config); -EXTERN int artnet_get_sd(artnet_node n); +EXTERN artnet_socket_t artnet_get_sd(artnet_node n); EXTERN int artnet_set_fdset(artnet_node vn, fd_set *fdset); -char *artnet_strerror(); +EXTERN char *artnet_strerror(); #ifdef __cplusplus } diff --git a/artnet/network.c b/artnet/network.c index 791f53c..1653f91 100644 --- a/artnet/network.c +++ b/artnet/network.c @@ -21,7 +21,7 @@ #include -#ifndef WIN32 +#if !defined(WIN32) && !defined(_MSC_VER) #include // socket before net/if.h for mac #include #include @@ -480,7 +480,7 @@ e_return : * Start listening on the socket */ int artnet_net_start(node n) { - int sock; + artnet_socket_t sock; struct sockaddr_in servAddr; int true_flag = TRUE; node tmp; @@ -501,7 +501,7 @@ int artnet_net_start(node n) { // create socket sock = socket(PF_INET, SOCK_DGRAM, 0); - if (sock < 0) { + if (sock == INVALID_SOCKET) { artnet_error("Could not create socket %s", artnet_net_last_error()); return ARTNET_ENET; } @@ -715,7 +715,7 @@ int artnet_net_set_fdset(node n, fd_set *fdset) { /* * Close a socket */ -int artnet_net_close(int sock) { +int artnet_net_close(artnet_socket_t sock) { #ifdef WIN32 shutdown(sock, SD_BOTH); closesocket(sock); diff --git a/artnet/private.h b/artnet/private.h index 6c4a538..cc1be11 100644 --- a/artnet/private.h +++ b/artnet/private.h @@ -22,7 +22,7 @@ # include #endif -#ifndef WIN32 +#if !defined(WIN32) && !defined(_MSC_VER) #include #include #include @@ -445,11 +445,7 @@ typedef struct { * The main node structure */ typedef struct artnet_node_s{ - #ifdef WIN32 - SOCKET sd; - #else - int sd; // the two sockets - #endif + artnet_socket_t sd; // the two sockets node_state_t state; // the state struct node_callbacks_t callbacks; // the callbacks struct struct ports_s { @@ -501,7 +497,7 @@ int artnet_net_send(node n, artnet_packet p); int artnet_net_set_non_block(node n); int artnet_net_init(node n, const char *ip); int artnet_net_start(node n); -int artnet_net_close(int sock); +int artnet_net_close(artnet_socket_t sock); int artnet_net_join(node n1, node n2); int artnet_net_set_fdset(node n, fd_set *fdset); int artnet_net_inet_aton(const char *ip_address, struct in_addr *address); diff --git a/msvc/libartnet/libartnet.sln b/msvc/libartnet/libartnet.sln new file mode 100644 index 0000000..5c8d5f6 --- /dev/null +++ b/msvc/libartnet/libartnet.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25123.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libartnet", "libartnet.vcxproj", "{DD027993-DEB3-4224-AB3A-3F86585A8913}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DD027993-DEB3-4224-AB3A-3F86585A8913}.Debug|x64.ActiveCfg = Debug|x64 + {DD027993-DEB3-4224-AB3A-3F86585A8913}.Debug|x64.Build.0 = Debug|x64 + {DD027993-DEB3-4224-AB3A-3F86585A8913}.Debug|x86.ActiveCfg = Debug|Win32 + {DD027993-DEB3-4224-AB3A-3F86585A8913}.Debug|x86.Build.0 = Debug|Win32 + {DD027993-DEB3-4224-AB3A-3F86585A8913}.Release|x64.ActiveCfg = Release|x64 + {DD027993-DEB3-4224-AB3A-3F86585A8913}.Release|x64.Build.0 = Release|x64 + {DD027993-DEB3-4224-AB3A-3F86585A8913}.Release|x86.ActiveCfg = Release|Win32 + {DD027993-DEB3-4224-AB3A-3F86585A8913}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/msvc/libartnet/libartnet.vcxproj b/msvc/libartnet/libartnet.vcxproj new file mode 100644 index 0000000..e739342 --- /dev/null +++ b/msvc/libartnet/libartnet.vcxproj @@ -0,0 +1,175 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {DD027993-DEB3-4224-AB3A-3F86585A8913} + Win32Proj + libartnet + 8.1 + + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBARTNET_EXPORTS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;MSW;%(PreprocessorDefinitions) + true + $(ProjectDir)\..\..\;%(AdditionalIncludeDirectories) + + + Windows + true + ws2_32.lib;IPHLPAPI.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;LIBARTNET_EXPORTS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;MSW;%(PreprocessorDefinitions) + true + $(ProjectDir)\..\..\;%(AdditionalIncludeDirectories) + + + Windows + true + ws2_32.lib;IPHLPAPI.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBARTNET_EXPORTS;MSW;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + true + $(ProjectDir)\..\..\;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + ws2_32.lib;IPHLPAPI.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_WINDOWS;_USRDLL;LIBARTNET_EXPORTS;MSW;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + true + $(ProjectDir)\..\..\;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + ws2_32.lib;IPHLPAPI.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/msvc/libartnet/libartnet.vcxproj.filters b/msvc/libartnet/libartnet.vcxproj.filters new file mode 100644 index 0000000..b28c65c --- /dev/null +++ b/msvc/libartnet/libartnet.vcxproj.filters @@ -0,0 +1,57 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file