# HG changeset patch # User Sebastien Jodogne # Date 1591713188 -7200 # Node ID 3a77d4073adf7891c78ac33fb9d1398a64ce2be5 # Parent 05a363186da6c7f7d14ae5e9f520969bcf11c6b4# Parent 52bc28f8ac8c7a5733ac194ab919b276b3050ffe merge diff -r 52bc28f8ac8c -r 3a77d4073adf Core/Compression/HierarchicalZipWriter.h --- a/Core/Compression/HierarchicalZipWriter.h Tue Jun 09 12:21:03 2020 +0200 +++ b/Core/Compression/HierarchicalZipWriter.h Tue Jun 09 16:33:08 2020 +0200 @@ -53,7 +53,7 @@ #endif private: - class Index + class ORTHANC_PUBLIC Index { private: struct Directory diff -r 52bc28f8ac8c -r 3a77d4073adf Core/HttpClient.h --- a/Core/HttpClient.h Tue Jun 09 12:21:03 2020 +0200 +++ b/Core/HttpClient.h Tue Jun 09 16:33:08 2020 +0200 @@ -42,6 +42,14 @@ #include #include +#if !defined(ORTHANC_ENABLE_CURL) +# error The macro ORTHANC_ENABLE_CURL must be defined +#endif + +#if ORTHANC_ENABLE_CURL != 1 +# error Support for curl is disabled, cannot use this file +#endif + #if !defined(ORTHANC_ENABLE_SSL) # error The macro ORTHANC_ENABLE_SSL must be defined #endif diff -r 52bc28f8ac8c -r 3a77d4073adf Core/Logging.cpp --- a/Core/Logging.cpp Tue Jun 09 12:21:03 2020 +0200 +++ b/Core/Logging.cpp Tue Jun 09 16:33:08 2020 +0200 @@ -537,7 +537,11 @@ void Initialize() { boost::mutex::scoped_lock lock(loggingStreamsMutex_); - loggingStreamsContext_.reset(new LoggingStreamsContext); + + if (loggingStreamsContext_.get() == NULL) + { + loggingStreamsContext_.reset(new LoggingStreamsContext); + } } void Finalize() diff -r 52bc28f8ac8c -r 3a77d4073adf Core/Lua/LuaContext.cpp --- a/Core/Lua/LuaContext.cpp Tue Jun 09 12:21:03 2020 +0200 +++ b/Core/Lua/LuaContext.cpp Tue Jun 09 16:33:08 2020 +0200 @@ -167,6 +167,7 @@ } +#if ORTHANC_ENABLE_CURL == 1 int LuaContext::SetHttpCredentials(lua_State *state) { LuaContext& that = GetLuaContext(state); @@ -189,8 +190,10 @@ return 0; } +#endif +#if ORTHANC_ENABLE_CURL == 1 bool LuaContext::AnswerHttpQuery(lua_State* state) { std::string str; @@ -209,8 +212,10 @@ return true; } +#endif +#if ORTHANC_ENABLE_CURL == 1 void LuaContext::SetHttpHeaders(int top) { std::map headers; @@ -223,9 +228,11 @@ { httpClient_.AddHeader(it->first, it->second); } - } + } +#endif +#if ORTHANC_ENABLE_CURL == 1 int LuaContext::CallHttpGet(lua_State *state) { LuaContext& that = GetLuaContext(state); @@ -256,8 +263,10 @@ return 1; } +#endif +#if ORTHANC_ENABLE_CURL == 1 int LuaContext::CallHttpPostOrPut(lua_State *state, HttpMethod method) { @@ -308,20 +317,26 @@ return 1; } +#endif + - +#if ORTHANC_ENABLE_CURL == 1 int LuaContext::CallHttpPost(lua_State *state) { return CallHttpPostOrPut(state, HttpMethod_Post); } +#endif +#if ORTHANC_ENABLE_CURL == 1 int LuaContext::CallHttpPut(lua_State *state) { return CallHttpPostOrPut(state, HttpMethod_Put); } +#endif +#if ORTHANC_ENABLE_CURL == 1 int LuaContext::CallHttpDelete(lua_State *state) { LuaContext& that = GetLuaContext(state); @@ -356,6 +371,7 @@ return 1; } +#endif void LuaContext::PushJson(const Json::Value& value) @@ -554,11 +570,14 @@ lua_register(lua_, "print", PrintToLog); lua_register(lua_, "ParseJson", ParseJson); lua_register(lua_, "DumpJson", DumpJson); + +#if ORTHANC_ENABLE_CURL == 1 lua_register(lua_, "HttpGet", CallHttpGet); lua_register(lua_, "HttpPost", CallHttpPost); lua_register(lua_, "HttpPut", CallHttpPut); lua_register(lua_, "HttpDelete", CallHttpDelete); lua_register(lua_, "SetHttpCredentials", SetHttpCredentials); +#endif SetGlobalVariable("_LuaContext", this); } diff -r 52bc28f8ac8c -r 3a77d4073adf Core/Lua/LuaContext.h --- a/Core/Lua/LuaContext.h Tue Jun 09 12:21:03 2020 +0200 +++ b/Core/Lua/LuaContext.h Tue Jun 09 16:33:08 2020 +0200 @@ -44,6 +44,10 @@ # error Macro ORTHANC_HAS_EMBEDDED_RESOURCES must be defined #endif +#if !defined(ORTHANC_ENABLE_CURL) +# error Macro ORTHANC_ENABLE_CURL must be defined +#endif + #if ORTHANC_ENABLE_LUA == 0 # error The Lua support is disabled, cannot include this file #endif @@ -52,7 +56,9 @@ # include // Autogenerated file #endif -#include "../HttpClient.h" +#if ORTHANC_ENABLE_CURL == 1 +# include "../HttpClient.h" +#endif extern "C" { @@ -60,6 +66,7 @@ } #include +#include namespace Orthanc { @@ -70,20 +77,24 @@ lua_State *lua_; std::string log_; + +#if ORTHANC_ENABLE_CURL == 1 HttpClient httpClient_; +#endif static int PrintToLog(lua_State *state); static int ParseJson(lua_State *state); static int DumpJson(lua_State *state); +#if ORTHANC_ENABLE_CURL == 1 static int SetHttpCredentials(lua_State *state); - static int CallHttpPostOrPut(lua_State *state, HttpMethod method); static int CallHttpGet(lua_State *state); static int CallHttpPost(lua_State *state); static int CallHttpPut(lua_State *state); static int CallHttpDelete(lua_State *state); +#endif bool AnswerHttpQuery(lua_State* state); @@ -122,11 +133,13 @@ bool IsExistingFunction(const char* name); +#if ORTHANC_ENABLE_CURL == 1 void SetHttpCredentials(const char* username, const char* password) { httpClient_.SetCredentials(username, password); } +#endif void RegisterFunction(const char* name, lua_CFunction func); diff -r 52bc28f8ac8c -r 3a77d4073adf Core/MetricsRegistry.h --- a/Core/MetricsRegistry.h Tue Jun 09 12:21:03 2020 +0200 +++ b/Core/MetricsRegistry.h Tue Jun 09 16:33:08 2020 +0200 @@ -113,7 +113,7 @@ void ExportPrometheusText(std::string& s); - class SharedMetrics : public boost::noncopyable + class ORTHANC_PUBLIC SharedMetrics : public boost::noncopyable { private: boost::mutex mutex_; @@ -135,7 +135,7 @@ }; - class ActiveCounter : public boost::noncopyable + class ORTHANC_PUBLIC ActiveCounter : public boost::noncopyable { private: SharedMetrics& metrics_; @@ -154,7 +154,7 @@ }; - class Timer : public boost::noncopyable + class ORTHANC_PUBLIC Timer : public boost::noncopyable { private: MetricsRegistry& registry_; diff -r 52bc28f8ac8c -r 3a77d4073adf Core/OrthancFramework.h --- a/Core/OrthancFramework.h Tue Jun 09 12:21:03 2020 +0200 +++ b/Core/OrthancFramework.h Tue Jun 09 16:33:08 2020 +0200 @@ -41,8 +41,8 @@ #ifndef __ORTHANC_FRAMEWORK_H #define __ORTHANC_FRAMEWORK_H -#if !defined(ORTHANC_FRAMEWORK_BUILDING_LIBRARY) -# define ORTHANC_FRAMEWORK_BUILDING_LIBRARY 0 +#if !defined(ORTHANC_BUILDING_FRAMEWORK_LIBRARY) +# error The macro ORTHANC_BUILDING_FRAMEWORK_LIBRARY must be defined #endif /** @@ -51,7 +51,7 @@ * common "BUILDING_DLL" * construction. https://gcc.gnu.org/wiki/Visibility **/ -#if ORTHANC_FRAMEWORK_BUILDING_LIBRARY == 1 +#if ORTHANC_BUILDING_FRAMEWORK_LIBRARY == 1 # if defined(_WIN32) || defined (__CYGWIN__) # define ORTHANC_PUBLIC __declspec(dllexport) # define ORTHANC_LOCAL @@ -70,4 +70,16 @@ # define ORTHANC_LOCAL #endif + +#include + +namespace Orthanc +{ + ORTHANC_PUBLIC void InitializeFramework(const std::string& locale, + bool loadPrivateDictionary); + + ORTHANC_PUBLIC void FinalizeFramework(); +} + + #endif /* __ORTHANC_FRAMEWORK_H */ diff -r 52bc28f8ac8c -r 3a77d4073adf Core/RestApi/RestApiHierarchy.h --- a/Core/RestApi/RestApiHierarchy.h Tue Jun 09 12:21:03 2020 +0200 +++ b/Core/RestApi/RestApiHierarchy.h Tue Jun 09 16:33:08 2020 +0200 @@ -45,7 +45,7 @@ class ORTHANC_PUBLIC RestApiHierarchy : public boost::noncopyable { public: - class Resource : public boost::noncopyable + class ORTHANC_PUBLIC Resource : public boost::noncopyable { private: RestApiGetCall::Handler getHandler_; diff -r 52bc28f8ac8c -r 3a77d4073adf Core/Toolbox.cpp --- a/Core/Toolbox.cpp Tue Jun 09 12:21:03 2020 +0200 +++ b/Core/Toolbox.cpp Tue Jun 09 16:33:08 2020 +0200 @@ -2226,7 +2226,7 @@ bool OrthancLinesIterator_GetLine(std::string& target, - const OrthancLinesIterator* iterator) + const OrthancLinesIterator* iterator) { if (iterator != NULL) { diff -r 52bc28f8ac8c -r 3a77d4073adf Core/Toolbox.h --- a/Core/Toolbox.h Tue Jun 09 12:21:03 2020 +0200 +++ b/Core/Toolbox.h Tue Jun 09 16:33:08 2020 +0200 @@ -58,6 +58,10 @@ # error The macro ORTHANC_ENABLE_PUGIXML must be defined #endif +#if !defined(ORTHANC_ENABLE_SSL) +# error The macro ORTHANC_ENABLE_SSL must be defined +#endif + /** * NOTE: GUID vs. UUID @@ -85,7 +89,7 @@ class ORTHANC_PUBLIC Toolbox { public: - class LinesIterator + class ORTHANC_PUBLIC LinesIterator { private: const std::string& content_; @@ -243,7 +247,7 @@ #endif static void InitializeOpenSsl(); - + static void FinalizeOpenSsl(); static std::string GenerateUuid(); @@ -272,8 +276,8 @@ /** * The plain C, opaque data structure "OrthancLinesIterator" is a thin * wrapper around Orthanc::Toolbox::LinesIterator, and is only used by - * "../Resources/WebAssembly/dcdict.cc", in order to avoid code - * duplication + * "../Resources/Patches/dcmtk-dcdict_orthanc.cc", in order to avoid + * code duplication **/ struct OrthancLinesIterator; diff -r 52bc28f8ac8c -r 3a77d4073adf OrthancServer/OrthancInitialization.cpp --- a/OrthancServer/OrthancInitialization.cpp Tue Jun 09 12:21:03 2020 +0200 +++ b/OrthancServer/OrthancInitialization.cpp Tue Jun 09 16:33:08 2020 +0200 @@ -225,22 +225,24 @@ { OrthancConfiguration::WriterLock lock; - Toolbox::InitializeOpenSsl(); - InitializeServerEnumerations(); // Read the user-provided configuration lock.GetConfiguration().Read(configurationFile); - if (lock.GetJson().isMember("Locale")) { - std::string locale = lock.GetConfiguration().GetStringParameter("Locale", ""); - Toolbox::InitializeGlobalLocale(lock.GetJson()["Locale"].asCString()); + std::string locale; + + if (lock.GetJson().isMember("Locale")) + { + locale = lock.GetConfiguration().GetStringParameter("Locale", ""); + } + + bool loadPrivate = lock.GetConfiguration().GetBooleanParameter("LoadPrivateDictionary", true); + Orthanc::InitializeFramework(locale, loadPrivate); } - else - { - Toolbox::InitializeGlobalLocale(NULL); - } + + // The Orthanc framework is now initialized if (lock.GetJson().isMember("DefaultEncoding")) { @@ -257,21 +259,12 @@ ConfigurePkcs11(lock.GetJson()["Pkcs11"]); } - HttpClient::GlobalInitialize(); - RegisterUserMetadata(lock.GetJson()); RegisterUserContentType(lock.GetJson()); - bool loadPrivate = lock.GetConfiguration().GetBooleanParameter("LoadPrivateDictionary", true); - FromDcmtkBridge::InitializeDictionary(loadPrivate); LoadCustomDictionary(lock.GetJson()); - FromDcmtkBridge::InitializeCodecs(); - lock.GetConfiguration().RegisterFont(EmbeddedResources::FONT_UBUNTU_MONO_BOLD_16); - - /* Disable "gethostbyaddr" (which results in memory leaks) and use raw IP addresses */ - dcmDisableGethostbyaddr.set(OFTrue); } @@ -279,11 +272,7 @@ void OrthancFinalize() { OrthancConfiguration::WriterLock lock; - - HttpClient::GlobalFinalize(); - FromDcmtkBridge::FinalizeCodecs(); - Toolbox::FinalizeOpenSsl(); - Toolbox::FinalizeGlobalLocale(); + Orthanc::FinalizeFramework(); } diff -r 52bc28f8ac8c -r 3a77d4073adf OrthancServer/main.cpp --- a/OrthancServer/main.cpp Tue Jun 09 12:21:03 2020 +0200 +++ b/OrthancServer/main.cpp Tue Jun 09 16:33:08 2020 +0200 @@ -1710,11 +1710,9 @@ status = -1; } - OrthancFinalize(); - LOG(WARNING) << "Orthanc has stopped"; - Logging::Finalize(); + OrthancFinalize(); return status; } diff -r 52bc28f8ac8c -r 3a77d4073adf Resources/CMake/BoostConfiguration.cmake --- a/Resources/CMake/BoostConfiguration.cmake Tue Jun 09 12:21:03 2020 +0200 +++ b/Resources/CMake/BoostConfiguration.cmake Tue Jun 09 16:33:08 2020 +0200 @@ -108,17 +108,29 @@ BEFORE ${BOOST_SOURCES_DIR} ) + if (ORTHANC_BUILDING_FRAMEWORK_LIBRARY) + add_definitions( + # Packaging Boost inside the Orthanc Framework DLL + -DBOOST_ALL_DYN_LINK + -DBOOST_THREAD_BUILD_DLL + #-DBOOST_REGEX_BUILD_DLL + ) + else() + add_definitions( + # Static build of Boost (this was the only possibility in + # Orthanc <= 1.7.1) + -DBOOST_ALL_NO_LIB + -DBOOST_ALL_NOLIB + -DBOOST_DATE_TIME_NO_LIB + -DBOOST_THREAD_BUILD_LIB + -DBOOST_PROGRAM_OPTIONS_NO_LIB + -DBOOST_REGEX_NO_LIB + -DBOOST_SYSTEM_NO_LIB + -DBOOST_LOCALE_NO_LIB + ) + endif() + add_definitions( - # Static build of Boost - -DBOOST_ALL_NO_LIB - -DBOOST_ALL_NOLIB - -DBOOST_DATE_TIME_NO_LIB - -DBOOST_THREAD_BUILD_LIB - -DBOOST_PROGRAM_OPTIONS_NO_LIB - -DBOOST_REGEX_NO_LIB - -DBOOST_SYSTEM_NO_LIB - -DBOOST_LOCALE_NO_LIB - # In static builds, explicitly prevent Boost from using the system # locale in lexical casts. This is notably important if # "boost::lexical_cast()" is applied to strings containing diff -r 52bc28f8ac8c -r 3a77d4073adf Resources/CMake/DcmtkConfigurationStatic-3.6.0.cmake --- a/Resources/CMake/DcmtkConfigurationStatic-3.6.0.cmake Tue Jun 09 12:21:03 2020 +0200 +++ b/Resources/CMake/DcmtkConfigurationStatic-3.6.0.cmake Tue Jun 09 16:33:08 2020 +0200 @@ -173,9 +173,3 @@ endif() endif() endif() - - -list(REMOVE_ITEM DCMTK_SOURCES - ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/mkdictbi.cc - ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/mkdeftag.cc - ) diff -r 52bc28f8ac8c -r 3a77d4073adf Resources/CMake/DcmtkConfigurationStatic-3.6.4.cmake --- a/Resources/CMake/DcmtkConfigurationStatic-3.6.4.cmake Tue Jun 09 12:21:03 2020 +0200 +++ b/Resources/CMake/DcmtkConfigurationStatic-3.6.4.cmake Tue Jun 09 16:33:08 2020 +0200 @@ -166,12 +166,6 @@ endif() -list(REMOVE_ITEM DCMTK_SOURCES - ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/mkdictbi.cc - ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/mkdeftag.cc - ) - - # Starting with DCMTK 3.6.2, the Nagle algorithm is not disabled by # default since this does not seem to be appropriate (anymore) for # most modern operating systems. In order to change this default, the diff -r 52bc28f8ac8c -r 3a77d4073adf Resources/CMake/DcmtkConfigurationStatic-3.6.5.cmake --- a/Resources/CMake/DcmtkConfigurationStatic-3.6.5.cmake Tue Jun 09 12:21:03 2020 +0200 +++ b/Resources/CMake/DcmtkConfigurationStatic-3.6.5.cmake Tue Jun 09 16:33:08 2020 +0200 @@ -166,12 +166,6 @@ endif() -list(REMOVE_ITEM DCMTK_SOURCES - ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/mkdictbi.cc - ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/mkdeftag.cc - ) - - # Starting with DCMTK 3.6.2, the Nagle algorithm is not disabled by # default since this does not seem to be appropriate (anymore) for # most modern operating systems. In order to change this default, the diff -r 52bc28f8ac8c -r 3a77d4073adf Resources/CMake/OrthancFrameworkConfiguration.cmake --- a/Resources/CMake/OrthancFrameworkConfiguration.cmake Tue Jun 09 12:21:03 2020 +0200 +++ b/Resources/CMake/OrthancFrameworkConfiguration.cmake Tue Jun 09 16:33:08 2020 +0200 @@ -137,6 +137,7 @@ ${ORTHANC_ROOT}/Core/HttpServer/MultipartStreamReader.cpp ${ORTHANC_ROOT}/Core/HttpServer/StringMatcher.cpp ${ORTHANC_ROOT}/Core/Logging.cpp + ${ORTHANC_ROOT}/Core/OrthancFramework.cpp ${ORTHANC_ROOT}/Core/SerializationToolbox.cpp ${ORTHANC_ROOT}/Core/Toolbox.cpp ${ORTHANC_ROOT}/Core/WebServiceParameters.cpp @@ -541,6 +542,13 @@ ) +if (ORTHANC_BUILDING_FRAMEWORK_LIBRARY) + add_definitions(-DORTHANC_BUILDING_FRAMEWORK_LIBRARY=1) +else() + add_definitions(-DORTHANC_BUILDING_FRAMEWORK_LIBRARY=0) +endif() + + if (ORTHANC_SANDBOXED) add_definitions( -DORTHANC_SANDBOXED=1 diff -r 52bc28f8ac8c -r 3a77d4073adf Resources/CMake/OrthancFrameworkParameters.cmake --- a/Resources/CMake/OrthancFrameworkParameters.cmake Tue Jun 09 12:21:03 2020 +0200 +++ b/Resources/CMake/OrthancFrameworkParameters.cmake Tue Jun 09 16:33:08 2020 +0200 @@ -112,6 +112,8 @@ set(ORTHANC_SANDBOXED OFF CACHE INTERNAL "Whether Orthanc runs inside a sandboxed environment (such as Google NaCl or WebAssembly)") +set(ORTHANC_BUILDING_FRAMEWORK_LIBRARY OFF CACHE INTERNAL + "Whether we are in the process of building the Orthanc Framework shared library") # # These options can be used to turn off some modules of the Orthanc diff -r 52bc28f8ac8c -r 3a77d4073adf UnitTestsSources/VersionsTests.cpp --- a/UnitTestsSources/VersionsTests.cpp Tue Jun 09 12:21:03 2020 +0200 +++ b/UnitTestsSources/VersionsTests.cpp Tue Jun 09 16:33:08 2020 +0200 @@ -31,10 +31,6 @@ **/ -#if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1 -# include -#endif - #include "PrecompiledHeadersUnitTests.h" #include "gtest/gtest.h"