[Libreoffice-commits] core.git: sal/osl sd/source

Michael Stahl mstahl at redhat.com
Mon Jan 26 02:54:49 PST 2015


 sal/osl/w32/socket.cxx                          |   22 ++++++++++++++++++++++
 sal/osl/w32/system.h                            |    1 +
 sd/source/ui/remotecontrol/DiscoveryService.cxx |   11 +++++++++++
 3 files changed, 34 insertions(+)

New commits:
commit c106f83da16726506962e19bcbc3d4c25415b81a
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Jan 23 16:38:46 2015 +0100

    sal,sd: Windows SDK 8.1 deprecates inet_addr()
    
    Change-Id: I443f73fab48f1b66b38e2c77af0fe89f99ee4cd0
    Reviewed-on: https://gerrit.libreoffice.org/14142
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sal/osl/w32/socket.cxx b/sal/osl/w32/socket.cxx
index 86f455e..a6487fa 100644
--- a/sal/osl/w32/socket.cxx
+++ b/sal/osl/w32/socket.cxx
@@ -584,6 +584,15 @@ oslSocketAddr SAL_CALL osl_createInetBroadcastAddr (
 
     if (strDottedAddr && strDottedAddr->length)
     {
+// the Win32 SDK 8.1 deprecates inet_addr()
+#ifdef _WIN32_WINNT_WINBLUE
+        IN_ADDR addr;
+        INT ret = InetPtonW(AF_INET, strDottedAddr->buffer, & addr);
+        if (1 == ret)
+        {
+            nAddr = addr.S_un.S_addr;
+        }
+#else
         /* Dotted host address for limited broadcast */
         rtl_String *pDottedAddr = NULL;
 
@@ -592,7 +601,9 @@ oslSocketAddr SAL_CALL osl_createInetBroadcastAddr (
             RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS);
 
         nAddr = inet_addr (pDottedAddr->buffer);
+
         rtl_string_release (pDottedAddr);
+#endif
     }
 
     if (nAddr != OSL_INADDR_NONE)
@@ -635,6 +646,16 @@ oslSocketAddr SAL_CALL osl_createInetSocketAddr (
     sal_Int32    Port)
 {
     sal_uInt32 Addr;
+
+// the Win32 SDK 8.1 deprecates inet_addr()
+#ifdef _WIN32_WINNT_WINBLUE
+    IN_ADDR addr;
+    INT ret = InetPtonW(AF_INET, strDottedAddr->buffer, & addr);
+    if (1 == ret)
+    {
+        Addr = addr.S_un.S_addr;
+    }
+#else
     rtl_String  *pDottedAddr=NULL;
 
     rtl_uString2String(
@@ -643,6 +664,7 @@ oslSocketAddr SAL_CALL osl_createInetSocketAddr (
 
     Addr= inet_addr (pDottedAddr->buffer);
     rtl_string_release (pDottedAddr);
+#endif
 
     oslSocketAddr pAddr = 0;
     if(Addr != OSL_INADDR_NONE)
diff --git a/sal/osl/w32/system.h b/sal/osl/w32/system.h
index 57a7a0f..e461ad9 100644
--- a/sal/osl/w32/system.h
+++ b/sal/osl/w32/system.h
@@ -68,6 +68,7 @@
     #pragma warning(disable:4917)
     #include <winsock2.h>
     #include <wsipx.h>
+    #include <ws2tcpip.h>
     #include <shlobj.h>
     #ifndef NO_DEBUG_CRT
         #include <crtdbg.h>
diff --git a/sd/source/ui/remotecontrol/DiscoveryService.cxx b/sd/source/ui/remotecontrol/DiscoveryService.cxx
index 04ef5e7..5cd9907 100644
--- a/sd/source/ui/remotecontrol/DiscoveryService.cxx
+++ b/sd/source/ui/remotecontrol/DiscoveryService.cxx
@@ -122,7 +122,18 @@ void DiscoveryService::setupSockets()
 
     struct ip_mreq multicastRequest;
 
+// the Win32 SDK 8.1 deprecates inet_addr()
+#ifdef _WIN32_WINNT_WINBLUE
+    IN_ADDR addr;
+    OUString const saddr("239.0.0.1");
+    INT ret = InetPtonW(AF_INET, saddr.getStr(), & addr);
+    if (1 == ret)
+    {
+        multicastRequest.imr_multiaddr.s_addr = addr.S_un.S_addr;
+    }
+#else
     multicastRequest.imr_multiaddr.s_addr = inet_addr( "239.0.0.1" );
+#endif
     multicastRequest.imr_interface.s_addr = htonl(INADDR_ANY);
 
     rc = setsockopt( mSocket, IPPROTO_IP, IP_ADD_MEMBERSHIP,


More information about the Libreoffice-commits mailing list