Mercurial > hg > orthanc
changeset 2407:5edec967055e
fix sandboxed builds
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 20 Sep 2017 17:02:27 +0200 |
parents | f0cfacd0c9b8 |
children | 26a0cc24d48d |
files | Core/Cache/SharedArchive.h Core/Endianness.h Core/Enumerations.cpp Core/FileStorage/FilesystemStorage.h Core/FileStorage/StorageAccessor.h Core/Images/Font.cpp Core/Images/Font.h Core/Images/FontRegistry.cpp Core/Images/FontRegistry.h Core/Images/JpegWriter.cpp Core/Images/PngWriter.cpp Resources/CMake/OrthancFrameworkConfiguration.cmake |
diffstat | 12 files changed, 68 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/Cache/SharedArchive.h Wed Sep 20 16:28:27 2017 +0200 +++ b/Core/Cache/SharedArchive.h Wed Sep 20 17:02:27 2017 +0200 @@ -33,6 +33,14 @@ #pragma once +#if !defined(ORTHANC_SANDBOXED) +# error The macro ORTHANC_SANDBOXED must be defined +#endif + +#if ORTHANC_SANDBOXED == 1 +# error The class SharedArchive cannot be used in sandboxed environments +#endif + #include "LeastRecentlyUsedIndex.h" #include "../IDynamicObject.h"
--- a/Core/Endianness.h Wed Sep 20 16:28:27 2017 +0200 +++ b/Core/Endianness.h Wed Sep 20 17:02:27 2017 +0200 @@ -35,10 +35,10 @@ /******************************************************************** - ** LINUX ARCHITECTURES + ** LINUX-LIKE ARCHITECTURES ********************************************************************/ -#if defined(__linux__) +#if defined(__linux__) || defined(__EMSCRIPTEN__) # define ORTHANC_HAS_BUILTIN_BYTE_SWAP 1 # include <endian.h> #endif
--- a/Core/Enumerations.cpp Wed Sep 20 16:28:27 2017 +0200 +++ b/Core/Enumerations.cpp Wed Sep 20 17:02:27 2017 +0200 @@ -38,6 +38,7 @@ #include "Toolbox.h" #include "Logging.h" +#include <boost/thread/mutex.hpp> #include <string.h> #include <cassert>
--- a/Core/FileStorage/FilesystemStorage.h Wed Sep 20 16:28:27 2017 +0200 +++ b/Core/FileStorage/FilesystemStorage.h Wed Sep 20 17:02:27 2017 +0200 @@ -33,6 +33,14 @@ #pragma once +#if !defined(ORTHANC_SANDBOXED) +# error The macro ORTHANC_SANDBOXED must be defined +#endif + +#if ORTHANC_SANDBOXED == 1 +# error The class FilesystemStorage cannot be used in sandboxed environments +#endif + #include "IStorageArea.h" #include <stdint.h>
--- a/Core/FileStorage/StorageAccessor.h Wed Sep 20 16:28:27 2017 +0200 +++ b/Core/FileStorage/StorageAccessor.h Wed Sep 20 17:02:27 2017 +0200 @@ -33,6 +33,14 @@ #pragma once +#if !defined(ORTHANC_SANDBOXED) +# error The macro ORTHANC_SANDBOXED must be defined +#endif + +#if ORTHANC_SANDBOXED == 1 +# error The class StorageAccessor cannot be used in sandboxed environments +#endif + #if !defined(ORTHANC_ENABLE_CIVETWEB) # error Macro ORTHANC_ENABLE_CIVETWEB must be defined to use this file #endif
--- a/Core/Images/Font.cpp Wed Sep 20 16:28:27 2017 +0200 +++ b/Core/Images/Font.cpp Wed Sep 20 17:02:27 2017 +0200 @@ -38,7 +38,10 @@ # error ORTHANC_ENABLE_LOCALE must be defined to use this file #endif -#include "../SystemToolbox.h" +#if ORTHANC_SANDBOXED == 0 +# include "../SystemToolbox.h" +#endif + #include "../Toolbox.h" #include "../OrthancException.h" @@ -138,12 +141,14 @@ } +#if ORTHANC_SANDBOXED == 0 void Font::LoadFromFile(const std::string& path) { std::string font; SystemToolbox::ReadFile(font, path); LoadFromMemory(font); } +#endif static unsigned int MyMin(unsigned int a,
--- a/Core/Images/Font.h Wed Sep 20 16:28:27 2017 +0200 +++ b/Core/Images/Font.h Wed Sep 20 17:02:27 2017 +0200 @@ -84,7 +84,9 @@ void LoadFromMemory(const std::string& font); +#if ORTHANC_SANDBOXED == 0 void LoadFromFile(const std::string& path); +#endif const std::string& GetName() const {
--- a/Core/Images/FontRegistry.cpp Wed Sep 20 16:28:27 2017 +0200 +++ b/Core/Images/FontRegistry.cpp Wed Sep 20 17:02:27 2017 +0200 @@ -57,12 +57,14 @@ } +#if ORTHANC_SANDBOXED == 0 void FontRegistry::AddFromFile(const std::string& path) { std::auto_ptr<Font> f(new Font); f->LoadFromFile(path); fonts_.push_back(f.release()); } +#endif #if ORTHANC_HAS_EMBEDDED_RESOURCES == 1
--- a/Core/Images/FontRegistry.h Wed Sep 20 16:28:27 2017 +0200 +++ b/Core/Images/FontRegistry.h Wed Sep 20 17:02:27 2017 +0200 @@ -57,7 +57,9 @@ void AddFromMemory(const std::string& font); +#if ORTHANC_SANDBOXED == 0 void AddFromFile(const std::string& path); +#endif #if ORTHANC_HAS_EMBEDDED_RESOURCES == 1 void AddFromResource(EmbeddedResources::FileResourceId resource);
--- a/Core/Images/JpegWriter.cpp Wed Sep 20 16:28:27 2017 +0200 +++ b/Core/Images/JpegWriter.cpp Wed Sep 20 17:02:27 2017 +0200 @@ -162,6 +162,7 @@ #endif +#if ORTHANC_SANDBOXED == 0 void JpegWriter::WriteToMemoryInternal(std::string& jpeg, unsigned int width, unsigned int height, @@ -206,4 +207,5 @@ jpeg.assign(reinterpret_cast<const char*>(data), size); free(data); } +#endif }
--- a/Core/Images/PngWriter.cpp Wed Sep 20 16:28:27 2017 +0200 +++ b/Core/Images/PngWriter.cpp Wed Sep 20 17:02:27 2017 +0200 @@ -248,6 +248,7 @@ +#if ORTHANC_SANDBOXED == 0 void PngWriter::WriteToMemoryInternal(std::string& png, unsigned int width, unsigned int height, @@ -271,4 +272,5 @@ chunks.Flatten(png); } +#endif }
--- a/Resources/CMake/OrthancFrameworkConfiguration.cmake Wed Sep 20 16:28:27 2017 +0200 +++ b/Resources/CMake/OrthancFrameworkConfiguration.cmake Wed Sep 20 17:02:27 2017 +0200 @@ -32,7 +32,6 @@ set(ORTHANC_CORE_SOURCES_INTERNAL ${ORTHANC_ROOT}/Core/Cache/MemoryCache.cpp - ${ORTHANC_ROOT}/Core/Cache/SharedArchive.cpp ${ORTHANC_ROOT}/Core/ChunkedBuffer.cpp ${ORTHANC_ROOT}/Core/Compression/DeflateBaseCompressor.cpp ${ORTHANC_ROOT}/Core/Compression/GzipCompressor.cpp @@ -47,8 +46,6 @@ ${ORTHANC_ROOT}/Core/DicomFormat/DicomTag.cpp ${ORTHANC_ROOT}/Core/DicomFormat/DicomValue.cpp ${ORTHANC_ROOT}/Core/Enumerations.cpp - ${ORTHANC_ROOT}/Core/FileStorage/FilesystemStorage.cpp - ${ORTHANC_ROOT}/Core/FileStorage/StorageAccessor.cpp ${ORTHANC_ROOT}/Core/Images/Font.cpp ${ORTHANC_ROOT}/Core/Images/FontRegistry.cpp ${ORTHANC_ROOT}/Core/Images/IImageWriter.cpp @@ -57,14 +54,6 @@ ${ORTHANC_ROOT}/Core/Images/ImageBuffer.cpp ${ORTHANC_ROOT}/Core/Images/ImageProcessing.cpp ${ORTHANC_ROOT}/Core/Logging.cpp - ${ORTHANC_ROOT}/Core/MultiThreading/BagOfTasksProcessor.cpp - ${ORTHANC_ROOT}/Core/MultiThreading/Mutex.cpp - ${ORTHANC_ROOT}/Core/MultiThreading/ReaderWriterLock.cpp - ${ORTHANC_ROOT}/Core/MultiThreading/RunnableWorkersPool.cpp - ${ORTHANC_ROOT}/Core/MultiThreading/Semaphore.cpp - ${ORTHANC_ROOT}/Core/MultiThreading/SharedMessageQueue.cpp - ${ORTHANC_ROOT}/Core/SystemToolbox.cpp - ${ORTHANC_ROOT}/Core/TemporaryFile.cpp ${ORTHANC_ROOT}/Core/Toolbox.cpp ${ORTHANC_ROOT}/Core/WebServiceParameters.cpp ) @@ -398,8 +387,6 @@ -DORTHANC_DATABASE_VERSION=${ORTHANC_DATABASE_VERSION} -DORTHANC_DEFAULT_DICOM_ENCODING=Encoding_Latin1 -DORTHANC_ENABLE_BASE64=1 - -DORTHANC_ENABLE_LOGGING=1 - -DORTHANC_ENABLE_LOGGING_PLUGIN=0 -DORTHANC_ENABLE_MD5=1 -DORTHANC_MAXIMUM_TAG_LENGTH=256 -DORTHANC_VERSION="${ORTHANC_VERSION}" @@ -407,9 +394,32 @@ if (ORTHANC_SANDBOXED) - add_definitions(-DORTHANC_SANDBOXED=1) + add_definitions( + -DORTHANC_SANDBOXED=1 + -DORTHANC_ENABLE_LOGGING=0 + -DORTHANC_ENABLE_LOGGING_PLUGIN=0 + ) + else() - add_definitions(-DORTHANC_SANDBOXED=0) + add_definitions( + -DORTHANC_SANDBOXED=0 + -DORTHANC_ENABLE_LOGGING=1 + -DORTHANC_ENABLE_LOGGING_PLUGIN=0 + ) + + list(APPEND ORTHANC_CORE_SOURCES_INTERNAL + ${ORTHANC_ROOT}/Core/Cache/SharedArchive.cpp + ${ORTHANC_ROOT}/Core/FileStorage/FilesystemStorage.cpp + ${ORTHANC_ROOT}/Core/FileStorage/StorageAccessor.cpp + ${ORTHANC_ROOT}/Core/MultiThreading/BagOfTasksProcessor.cpp + ${ORTHANC_ROOT}/Core/MultiThreading/Mutex.cpp + ${ORTHANC_ROOT}/Core/MultiThreading/ReaderWriterLock.cpp + ${ORTHANC_ROOT}/Core/MultiThreading/RunnableWorkersPool.cpp + ${ORTHANC_ROOT}/Core/MultiThreading/Semaphore.cpp + ${ORTHANC_ROOT}/Core/MultiThreading/SharedMessageQueue.cpp + ${ORTHANC_ROOT}/Core/SystemToolbox.cpp + ${ORTHANC_ROOT}/Core/TemporaryFile.cpp + ) endif()