changeset 14:e1b24c9a9bd8

patch Orthanc 1.5.6
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 Mar 2019 16:48:25 +0100
parents df314d38a4e0
children 3eb5ccd37e31 2452e15d7746
files CMakeLists.txt Resources/Patches/orthanc-1.5.6.patch
diffstat 2 files changed, 161 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Mon Mar 04 16:14:15 2019 +0100
+++ b/CMakeLists.txt	Mon Mar 04 16:48:25 2019 +0100
@@ -26,6 +26,9 @@
 else()
   set(ORTHANC_FRAMEWORK_VERSION "1.5.6")
   set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web")
+
+  # diff --new-file -urEb Orthanc-1.5.6.orig/ Orthanc-1.5.6 > orthanc-1.5.6.patch
+  set(ORTHANC_FRAMEWORK_PATCH "${CMAKE_SOURCE_DIR}/Resources/Patches/orthanc-1.5.6.patch")
 endif()
 
 
@@ -55,6 +58,21 @@
 include_directories(${ORTHANC_ROOT})
 
 
+# Possibly patch the Orthanc framework
+if (DEFINED ORTHANC_FRAMEWORK_PATCH AND
+    NOT EXISTS "${ORTHANC_ROOT}/patched")
+  execute_process(
+    COMMAND ${PATCH_EXECUTABLE} -p0 -N -i ${ORTHANC_FRAMEWORK_PATCH}
+    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+    RESULT_VARIABLE Failure
+    )
+
+  if (Failure)
+    message(FATAL_ERROR "Error while patching a file")
+  endif()
+endif()
+
+
 # Check that the Orthanc SDK headers are available
 if (STATIC_BUILD OR NOT USE_SYSTEM_ORTHANC_SDK)
   if (ORTHANC_SDK_VERSION STREQUAL "1.4.2")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/Patches/orthanc-1.5.6.patch	Mon Mar 04 16:48:25 2019 +0100
@@ -0,0 +1,143 @@
+diff --new-file -urEb Orthanc-1.5.6.orig/patched Orthanc-1.5.6/patched
+--- Orthanc-1.5.6.orig/patched	1970-01-01 01:00:00.000000000 +0100
++++ Orthanc-1.5.6/patched	2019-03-04 16:41:37.532734849 +0100
+@@ -0,0 +1 @@
++patched
+diff --new-file -urEb Orthanc-1.5.6.orig/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Orthanc-1.5.6/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
+--- Orthanc-1.5.6.orig/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	2019-03-04 16:19:10.126165813 +0100
++++ Orthanc-1.5.6/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	2019-03-04 16:19:39.330128951 +0100
+@@ -145,6 +145,13 @@
+   }
+ 
+ 
++  void MemoryBuffer::Swap(MemoryBuffer& other)
++  {
++    std::swap(buffer_.data, other.buffer_.data);
++    std::swap(buffer_.size, other.buffer_.size);
++  }
++
++
+   OrthancPluginMemoryBuffer MemoryBuffer::Release()
+   {
+     OrthancPluginMemoryBuffer result = buffer_;
+@@ -1024,11 +1031,11 @@
+   {
+     CheckImageAvailable();
+ 
+-    OrthancPluginMemoryBuffer tmp;
+-    OrthancPluginCompressPngImage(GetGlobalContext(), &tmp, GetPixelFormat(),
++    OrthancPlugins::MemoryBuffer answer;
++    OrthancPluginCompressPngImage(GetGlobalContext(), *answer, GetPixelFormat(),
+                                   GetWidth(), GetHeight(), GetPitch(), GetBuffer());
+ 
+-    target.Assign(tmp);
++    target.Swap(answer);
+   }
+ 
+ 
+@@ -1037,11 +1044,11 @@
+   {
+     CheckImageAvailable();
+ 
+-    OrthancPluginMemoryBuffer tmp;
+-    OrthancPluginCompressJpegImage(GetGlobalContext(), &tmp, GetPixelFormat(),
++    OrthancPlugins::MemoryBuffer answer;
++    OrthancPluginCompressJpegImage(GetGlobalContext(), *answer, GetPixelFormat(),
+                                    GetWidth(), GetHeight(), GetPitch(), GetBuffer(), quality);
+ 
+-    target.Assign(tmp);
++    target.Swap(answer);
+   }
+ 
+ 
+@@ -1580,16 +1587,16 @@
+       ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
+     }
+ 
+-    OrthancPluginMemoryBuffer answer;
++    OrthancPlugins::MemoryBuffer answer;
+     uint16_t status;
+     OrthancPluginErrorCode code = OrthancPluginCallPeerApi
+-        (GetGlobalContext(), &answer, NULL, &status, peers_,
++        (GetGlobalContext(), *answer, NULL, &status, peers_,
+          static_cast<uint32_t>(index), OrthancPluginHttpMethod_Get, uri.c_str(),
+          0, NULL, NULL, NULL, 0, timeout_);
+ 
+     if (code == OrthancPluginErrorCode_Success)
+     {
+-      target.Assign(answer);
++      target.Swap(answer);
+       return (status == 200);
+     }
+     else
+@@ -1704,16 +1711,16 @@
+       ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
+     }
+ 
+-    OrthancPluginMemoryBuffer answer;
++    OrthancPlugins::MemoryBuffer answer;
+     uint16_t status;
+     OrthancPluginErrorCode code = OrthancPluginCallPeerApi
+-        (GetGlobalContext(), &answer, NULL, &status, peers_,
++        (GetGlobalContext(), *answer, NULL, &status, peers_,
+          static_cast<uint32_t>(index), OrthancPluginHttpMethod_Post, uri.c_str(),
+          0, NULL, NULL, body.empty() ? NULL : body.c_str(), body.size(), timeout_);
+ 
+     if (code == OrthancPluginErrorCode_Success)
+     {
+-      target.Assign(answer);
++      target.Swap(answer);
+       return (status == 200);
+     }
+     else
+@@ -1732,16 +1739,15 @@
+       ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
+     }
+ 
+-    OrthancPluginMemoryBuffer answer;
++    OrthancPlugins::MemoryBuffer answer;
+     uint16_t status;
+     OrthancPluginErrorCode code = OrthancPluginCallPeerApi
+-        (GetGlobalContext(), &answer, NULL, &status, peers_,
++        (GetGlobalContext(), *answer, NULL, &status, peers_,
+          static_cast<uint32_t>(index), OrthancPluginHttpMethod_Put, uri.c_str(),
+          0, NULL, NULL, body.empty() ? NULL : body.c_str(), body.size(), timeout_);
+ 
+     if (code == OrthancPluginErrorCode_Success)
+     {
+-      OrthancPluginFreeMemoryBuffer(GetGlobalContext(), &answer);
+       return (status == 200);
+     }
+     else
+@@ -1769,16 +1775,15 @@
+       ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
+     }
+ 
+-    OrthancPluginMemoryBuffer answer;
++    OrthancPlugins::MemoryBuffer answer;
+     uint16_t status;
+     OrthancPluginErrorCode code = OrthancPluginCallPeerApi
+-        (GetGlobalContext(), &answer, NULL, &status, peers_,
+-         static_cast<uint32_t>(index), OrthancPluginHttpMethod_Put, uri.c_str(),
++      (GetGlobalContext(), *answer, NULL, &status, peers_,
++       static_cast<uint32_t>(index), OrthancPluginHttpMethod_Delete, uri.c_str(),
+          0, NULL, NULL, NULL, 0, timeout_);
+ 
+     if (code == OrthancPluginErrorCode_Success)
+     {
+-      OrthancPluginFreeMemoryBuffer(GetGlobalContext(), &answer);
+       return (status == 200);
+     }
+     else
+diff --new-file -urEb Orthanc-1.5.6.orig/Plugins/Samples/Common/OrthancPluginCppWrapper.h Orthanc-1.5.6/Plugins/Samples/Common/OrthancPluginCppWrapper.h
+--- Orthanc-1.5.6.orig/Plugins/Samples/Common/OrthancPluginCppWrapper.h	2019-03-04 16:19:10.126165813 +0100
++++ Orthanc-1.5.6/Plugins/Samples/Common/OrthancPluginCppWrapper.h	2019-03-04 16:19:42.018125583 +0100
+@@ -129,6 +129,8 @@
+     // This transfers ownership from "other" to "this"
+     void Assign(OrthancPluginMemoryBuffer& other);
+ 
++    void Swap(MemoryBuffer& other);
++
+     OrthancPluginMemoryBuffer Release();
+ 
+     const char* GetData() const