changeset 14:0b9034112fde

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 09 Nov 2016 15:29:53 +0100
parents b1eb80ca0d2b
children da2cf3ace87a
files Framework/Orthanc/Core/HttpClient.h Framework/Orthanc/Core/Logging.h Framework/Orthanc/Core/Toolbox.cpp Framework/Orthanc/Core/Toolbox.h
diffstat 4 files changed, 64 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Orthanc/Core/HttpClient.h	Wed Nov 09 14:15:06 2016 +0100
+++ b/Framework/Orthanc/Core/HttpClient.h	Wed Nov 09 15:29:53 2016 +0100
@@ -39,6 +39,15 @@
 #include <boost/shared_ptr.hpp>
 #include <json/json.h>
 
+#if !defined(ORTHANC_ENABLE_SSL)
+#  error The macro ORTHANC_ENABLE_SSL must be defined
+#endif
+
+#if !defined(ORTHANC_ENABLE_PKCS11)
+#  error The macro ORTHANC_ENABLE_PKCS11 must be defined
+#endif
+
+
 namespace Orthanc
 {
   class HttpClient
--- a/Framework/Orthanc/Core/Logging.h	Wed Nov 09 14:15:06 2016 +0100
+++ b/Framework/Orthanc/Core/Logging.h	Wed Nov 09 15:29:53 2016 +0100
@@ -34,6 +34,10 @@
 
 #include <iostream>
 
+#if !defined(ORTHANC_ENABLE_LOGGING)
+#  error The macro ORTHANC_ENABLE_LOGGING must be defined
+#endif
+
 namespace Orthanc
 {
   namespace Logging
--- a/Framework/Orthanc/Core/Toolbox.cpp	Wed Nov 09 14:15:06 2016 +0100
+++ b/Framework/Orthanc/Core/Toolbox.cpp	Wed Nov 09 15:29:53 2016 +0100
@@ -80,13 +80,13 @@
 #include <boost/locale.hpp>
 
 
-#if !defined(ORTHANC_ENABLE_MD5) || ORTHANC_ENABLE_MD5 == 1
-#include "../Resources/ThirdParty/md5/md5.h"
+#if ORTHANC_ENABLE_MD5 == 1
+#  include "../Resources/ThirdParty/md5/md5.h"
 #endif
 
 
-#if !defined(ORTHANC_ENABLE_BASE64) || ORTHANC_ENABLE_BASE64 == 1
-#include "../Resources/ThirdParty/base64/base64.h"
+#if ORTHANC_ENABLE_BASE64 == 1
+#  include "../Resources/ThirdParty/base64/base64.h"
 #endif
 
 
@@ -123,7 +123,7 @@
   }
 
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
   static bool finish_;
   static ServerBarrierEvent barrierEvent_;
 
@@ -230,7 +230,7 @@
   }
 
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
   void Toolbox::ReadFile(std::string& content,
                          const std::string& path) 
   {
@@ -259,7 +259,7 @@
 #endif
 
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
   bool Toolbox::ReadHeader(std::string& header,
                            const std::string& path,
                            size_t headerSize)
@@ -306,7 +306,7 @@
 #endif
 
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
   void Toolbox::WriteFile(const void* content,
                           size_t size,
                           const std::string& path)
@@ -334,7 +334,7 @@
 #endif
 
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
   void Toolbox::WriteFile(const std::string& content,
                           const std::string& path)
   {
@@ -344,7 +344,7 @@
 #endif
 
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
   void Toolbox::RemoveFile(const std::string& path)
   {
     if (boost::filesystem::exists(path))
@@ -530,7 +530,7 @@
 
 
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
   uint64_t Toolbox::GetFileSize(const std::string& path)
   {
     try
@@ -545,7 +545,7 @@
 #endif
 
 
-#if !defined(ORTHANC_ENABLE_MD5) || ORTHANC_ENABLE_MD5 == 1
+#if ORTHANC_ENABLE_MD5 == 1
   static char GetHexadecimalCharacter(uint8_t value)
   {
     assert(value < 16);
@@ -602,7 +602,7 @@
 #endif
 
 
-#if !defined(ORTHANC_ENABLE_BASE64) || ORTHANC_ENABLE_BASE64 == 1
+#if ORTHANC_ENABLE_BASE64 == 1
   void Toolbox::EncodeBase64(std::string& result, 
                              const std::string& data)
   {
@@ -696,7 +696,7 @@
     return std::string(pathbuf);
   }
 
-#elif defined(ORTHANC_SANDBOXED) && ORTHANC_SANDBOXED == 1
+#elif ORTHANC_SANDBOXED == 1
   // Sandboxed Orthanc, no access to the executable
 
 #else
@@ -704,7 +704,7 @@
 #endif
 
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
   std::string Toolbox::GetPathToExecutable()
   {
     boost::filesystem::path p(GetPathToExecutableInternal());
@@ -1178,7 +1178,7 @@
   }
 
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
   void Toolbox::MakeDirectory(const std::string& path)
   {
     if (boost::filesystem::exists(path))
@@ -1199,7 +1199,7 @@
 #endif
 
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
   bool Toolbox::IsExistingFile(const std::string& path)
   {
     return boost::filesystem::exists(path);
@@ -1329,7 +1329,7 @@
 #endif
 
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
   void Toolbox::ExecuteSystemCommand(const std::string& command,
                                      const std::vector<std::string>& arguments)
   {
@@ -1498,6 +1498,7 @@
   }
 
 
+#if ORTHANC_SANDBOXED == 0
   int Toolbox::GetProcessId()
   {
 #if defined(_WIN32)
@@ -1506,9 +1507,10 @@
     return static_cast<int>(getpid());
 #endif
   }
+#endif
 
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
   bool Toolbox::IsRegularFile(const std::string& path)
   {
     namespace fs = boost::filesystem;
--- a/Framework/Orthanc/Core/Toolbox.h	Wed Nov 09 14:15:06 2016 +0100
+++ b/Framework/Orthanc/Core/Toolbox.h	Wed Nov 09 15:29:53 2016 +0100
@@ -39,6 +39,27 @@
 #include <string>
 #include <json/json.h>
 
+
+#if !defined(ORTHANC_ENABLE_BASE64)
+#  error The macro ORTHANC_ENABLE_BASE64 must be defined
+#endif
+
+#if !defined(ORTHANC_ENABLE_MD5)
+#  error The macro ORTHANC_ENABLE_MD5 must be defined
+#endif
+
+#if !defined(ORTHANC_ENABLE_PUGIXML)
+#  error The macro ORTHANC_ENABLE_PUGIXML must be defined
+#endif
+
+#if !defined(BOOST_HAS_REGEX)
+#  error The macro BOOST_HAS_REGEX must be defined
+#endif
+
+#if !defined(ORTHANC_SANDBOXED)
+#  define ORTHANC_SANDBOXED  0
+#endif
+
 namespace Orthanc
 {
   typedef std::vector<std::string> UriComponents;
@@ -51,7 +72,7 @@
   {
     void USleep(uint64_t microSeconds);
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
     ServerBarrierEvent ServerBarrier(const bool& stopFlag);
 
     ServerBarrierEvent ServerBarrier();
@@ -67,29 +88,21 @@
     void ToLowerCase(std::string& result,
                      const std::string& source);
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
     void ReadFile(std::string& content,
                   const std::string& path);
-#endif
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     bool ReadHeader(std::string& header,
                     const std::string& path,
                     size_t headerSize);
-#endif
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     void WriteFile(const std::string& content,
                    const std::string& path);
-#endif
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     void WriteFile(const void* content,
                    size_t size,
                    const std::string& path);
-#endif
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     void RemoveFile(const std::string& path);
 #endif
 
@@ -108,11 +121,11 @@
     std::string FlattenUri(const UriComponents& components,
                            size_t fromLevel = 0);
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
     uint64_t GetFileSize(const std::string& path);
 #endif
 
-#if !defined(ORTHANC_ENABLE_MD5) || ORTHANC_ENABLE_MD5 == 1
+#if ORTHANC_ENABLE_MD5 == 1
     void ComputeMD5(std::string& result,
                     const std::string& data);
 
@@ -133,7 +146,7 @@
 
     bool IsSHA1(const std::string& s);
 
-#if !defined(ORTHANC_ENABLE_BASE64) || ORTHANC_ENABLE_BASE64 == 1
+#if ORTHANC_ENABLE_BASE64 == 1
     void DecodeBase64(std::string& result, 
                       const std::string& data);
 
@@ -151,7 +164,7 @@
                              const std::string& content);
 #endif
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
     std::string GetPathToExecutable();
 
     std::string GetDirectoryOfExecutable();
@@ -190,11 +203,9 @@
                         const std::string& source,
                         char separator);
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
     void MakeDirectory(const std::string& path);
-#endif
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     bool IsExistingFile(const std::string& path);
 #endif
 
@@ -205,7 +216,7 @@
                    const std::string& arrayElement = "item");
 #endif
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
+#if ORTHANC_SANDBOXED == 0
     void ExecuteSystemCommand(const std::string& command,
                               const std::vector<std::string>& arguments);
 #endif
@@ -218,9 +229,9 @@
     bool StartsWith(const std::string& str,
                     const std::string& prefix);
 
+#if ORTHANC_SANDBOXED == 0
     int GetProcessId();
 
-#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     bool IsRegularFile(const std::string& path);
 #endif