changeset 2715:73bc0c32547c jobs

fix embedding openssl within a DLL
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 09 Jul 2018 13:02:56 +0200
parents 28dc5bb9a7e6
children 1b4ba91fe795 d33659c28c6b 0bd1dfb14272
files Core/DicomNetworking/DicomUserConnection.cpp Core/DicomNetworking/RemoteModalityParameters.cpp Core/DicomNetworking/RemoteModalityParameters.h Resources/CMake/OpenSslConfiguration.cmake UnitTestsSources/MultiThreadingTests.cpp
diffstat 5 files changed, 36 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomNetworking/DicomUserConnection.cpp	Mon Jul 09 12:20:28 2018 +0200
+++ b/Core/DicomNetworking/DicomUserConnection.cpp	Mon Jul 09 13:02:56 2018 +0200
@@ -847,7 +847,7 @@
   {
     SetRemoteApplicationEntityTitle(parameters.GetApplicationEntityTitle());
     SetRemoteHost(parameters.GetHost());
-    SetRemotePort(parameters.GetPort());
+    SetRemotePort(parameters.GetPortNumber());
     SetRemoteManufacturer(parameters.GetManufacturer());
   }
 
@@ -1252,7 +1252,7 @@
     return (localAet_ == localAet &&
             remoteAet_ == remote.GetApplicationEntityTitle() &&
             remoteHost_ == remote.GetHost() &&
-            remotePort_ == remote.GetPort() &&
+            remotePort_ == remote.GetPortNumber() &&
             manufacturer_ == remote.GetManufacturer());
   }
 }
--- a/Core/DicomNetworking/RemoteModalityParameters.cpp	Mon Jul 09 12:20:28 2018 +0200
+++ b/Core/DicomNetworking/RemoteModalityParameters.cpp	Mon Jul 09 13:02:56 2018 +0200
@@ -58,7 +58,7 @@
   {
     SetApplicationEntityTitle(aet);
     SetHost(host);
-    SetPort(port);
+    SetPortNumber(port);
     SetManufacturer(manufacturer);
   }
 
@@ -84,13 +84,13 @@
         throw OrthancException(ErrorCode_ParameterOutOfRange);
       }
 
-      SetPort(static_cast<uint16_t>(tmp));
+      SetPortNumber(static_cast<uint16_t>(tmp));
     }
     catch (std::runtime_error /* error inside JsonCpp */)
     {
       try
       {
-        SetPort(boost::lexical_cast<uint16_t>(portValue.asString()));
+        SetPortNumber(boost::lexical_cast<uint16_t>(portValue.asString()));
       }
       catch (boost::bad_lexical_cast)
       {
@@ -118,16 +118,16 @@
     }
   }
 
+  
   void RemoteModalityParameters::ToJson(Json::Value& value) const
   {
     value = Json::arrayValue;
     value.append(GetApplicationEntityTitle());
     value.append(GetHost());
-    value.append(GetPort());
+    value.append(GetPortNumber());
     value.append(EnumerationToString(GetManufacturer()));
   }
 
-
   
   void RemoteModalityParameters::Serialize(Json::Value& target) const
   {
--- a/Core/DicomNetworking/RemoteModalityParameters.h	Mon Jul 09 12:20:28 2018 +0200
+++ b/Core/DicomNetworking/RemoteModalityParameters.h	Mon Jul 09 13:02:56 2018 +0200
@@ -79,12 +79,12 @@
       host_ = host;
     }
     
-    uint16_t GetPort() const
+    uint16_t GetPortNumber() const
     {
       return port_;
     }
 
-    void SetPort(uint16_t port)
+    void SetPortNumber(uint16_t port)
     {
       port_ = port;
     }
--- a/Resources/CMake/OpenSslConfiguration.cmake	Mon Jul 09 12:20:28 2018 +0200
+++ b/Resources/CMake/OpenSslConfiguration.cmake	Mon Jul 09 13:02:56 2018 +0200
@@ -95,8 +95,30 @@
       ${OPENSSL_SOURCES_DIR}/ssl/ssl3.h
       ${OPENSSL_SOURCES_DIR}/ssl/tls1.h
       )
-    file(COPY ${header} DESTINATION ${OPENSSL_SOURCES_DIR}/include/openssl)
+      file(COPY ${header} DESTINATION ${OPENSSL_SOURCES_DIR}/include/openssl)
     endforeach()
+
+    file(RENAME
+      ${OPENSSL_SOURCES_DIR}/include/openssl/e_os2.h
+      ${OPENSSL_SOURCES_DIR}/include/openssl/e_os2_source.h)
+
+    # The following patch of "e_os2.h" prevents from building OpenSSL
+    # as a DLL under Windows. Otherwise, symbols have inconsistent
+    # linkage if ${OPENSSL_SOURCES} is used to create a DLL (notably
+    # if building an Orthanc plugin such as MySQL).
+    file(WRITE ${OPENSSL_SOURCES_DIR}/include/openssl/e_os2.h "
+#include \"e_os2_source.h\"
+#if defined(_WIN32)
+#  undef OPENSSL_EXPORT
+#  undef OPENSSL_IMPORT
+#  undef OPENSSL_EXTERN
+#  undef OPENSSL_GLOBAL
+#  define OPENSSL_EXPORT
+#  define OPENSSL_IMPORT
+#  define OPENSSL_EXTERN extern
+#  define OPENSSL_GLOBAL
+#endif
+")
   endif()
   
   add_definitions(
--- a/UnitTestsSources/MultiThreadingTests.cpp	Mon Jul 09 12:20:28 2018 +0200
+++ b/UnitTestsSources/MultiThreadingTests.cpp	Mon Jul 09 13:02:56 2018 +0200
@@ -1304,7 +1304,7 @@
     RemoteModalityParameters modality;
     modality.SetApplicationEntityTitle("REMOTE");
     modality.SetHost("192.168.1.1");
-    modality.SetPort(1000);
+    modality.SetPortNumber(1000);
     modality.SetManufacturer(ModalityManufacturer_StoreScp);
 
     StoreScuOperation operation("TEST", modality);
@@ -1319,7 +1319,7 @@
     const StoreScuOperation& tmp = dynamic_cast<StoreScuOperation&>(*operation);
     ASSERT_EQ("REMOTE", tmp.GetRemoteModality().GetApplicationEntityTitle());
     ASSERT_EQ("192.168.1.1", tmp.GetRemoteModality().GetHost());
-    ASSERT_EQ(1000, tmp.GetRemoteModality().GetPort());
+    ASSERT_EQ(1000, tmp.GetRemoteModality().GetPortNumber());
     ASSERT_EQ(ModalityManufacturer_StoreScp, tmp.GetRemoteModality().GetManufacturer());
     ASSERT_EQ("TEST", tmp.GetLocalAet());
   }
@@ -1390,7 +1390,7 @@
     RemoteModalityParameters modality;
     modality.SetApplicationEntityTitle("REMOTE");
     modality.SetHost("192.168.1.1");
-    modality.SetPort(1000);
+    modality.SetPortNumber(1000);
     modality.SetManufacturer(ModalityManufacturer_StoreScp);
 
     DicomModalityStoreJob job(GetContext());
@@ -1410,7 +1410,7 @@
     ASSERT_EQ("LOCAL", tmp.GetLocalAet());
     ASSERT_EQ("REMOTE", tmp.GetRemoteModality().GetApplicationEntityTitle());
     ASSERT_EQ("192.168.1.1", tmp.GetRemoteModality().GetHost());
-    ASSERT_EQ(1000, tmp.GetRemoteModality().GetPort());
+    ASSERT_EQ(1000, tmp.GetRemoteModality().GetPortNumber());
     ASSERT_EQ(ModalityManufacturer_StoreScp, tmp.GetRemoteModality().GetManufacturer());
     ASSERT_TRUE(tmp.HasMoveOriginator());
     ASSERT_EQ("MOVESCU", tmp.GetMoveOriginatorAet());