diff OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 4961:1b76853e1797 more-tags

DbOptimizer plugin
author Alain Mazy <am@osimis.io>
date Wed, 23 Mar 2022 11:56:28 +0100
parents 8785d8442f90
children 501411a67f10
line wrap: on
line diff
--- a/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Wed Mar 23 11:52:19 2022 +0100
+++ b/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Wed Mar 23 11:56:28 2022 +0100
@@ -1546,24 +1546,18 @@
              " is required)");
   }
 
-
-  bool CheckMinimalOrthancVersion(unsigned int major,
-                                  unsigned int minor,
-                                  unsigned int revision)
+  bool CheckMinimalVersion(const char* version,
+                           unsigned int major,
+                           unsigned int minor,
+                           unsigned int revision)
   {
-    if (!HasGlobalContext())
-    {
-      LogError("Bad Orthanc context in the plugin");
-      return false;
-    }
-
-    if (!strcmp(GetGlobalContext()->orthancVersion, "mainline"))
+    if (!strcmp(version, "mainline"))
     {
       // Assume compatibility with the mainline
       return true;
     }
 
-    // Parse the version of the Orthanc core
+    // Parse the version
     int aa, bb, cc;
     if (
 #ifdef _MSC_VER
@@ -1571,7 +1565,7 @@
 #else
       sscanf
 #endif
-      (GetGlobalContext()->orthancVersion, "%4d.%4d.%4d", &aa, &bb, &cc) != 3 ||
+      (version, "%4d.%4d.%4d", &aa, &bb, &cc) != 3 ||
       aa < 0 ||
       bb < 0 ||
       cc < 0)
@@ -1595,7 +1589,6 @@
       return false;
     }
 
-
     // Check the minor version number
     assert(a == major);
 
@@ -1623,6 +1616,21 @@
   }
 
 
+  bool CheckMinimalOrthancVersion(unsigned int major,
+                                  unsigned int minor,
+                                  unsigned int revision)
+  {
+    if (!HasGlobalContext())
+    {
+      LogError("Bad Orthanc context in the plugin");
+      return false;
+    }
+
+    return CheckMinimalVersion(GetGlobalContext()->orthancVersion,
+                               major, minor, revision);
+  }
+
+
 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 0)
   const char* AutodetectMimeType(const std::string& path)
   {