Mercurial > hg > orthanc
changeset 2512:4dcafa8d6633
SystemToolbox::GenerateUuid moved to Toolbox::GenerateUuid
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 28 Mar 2018 15:20:50 +0200 |
parents | 8a0d3044ef53 |
children | 97a74f0eac7a |
files | Core/Cache/SharedArchive.cpp Core/DicomParsing/FromDcmtkBridge.cpp Core/DicomParsing/ParsedDicomFile.cpp Core/DicomParsing/ParsedDicomFile.h Core/DicomParsing/ToDcmtkBridge.cpp Core/FileStorage/StorageAccessor.cpp Core/HttpServer/HttpOutput.cpp Core/SystemToolbox.cpp Core/SystemToolbox.h Core/TemporaryFile.cpp Core/Toolbox.cpp Core/Toolbox.h OrthancServer/Scheduler/ServerJob.cpp Plugins/Engine/OrthancPlugins.cpp Resources/CMake/BoostConfiguration.cmake Resources/CMake/DcmtkConfiguration.cmake Resources/CMake/OrthancFrameworkConfiguration.cmake UnitTestsSources/FileStorageTests.cpp UnitTestsSources/ServerIndexTests.cpp UnitTestsSources/StreamTests.cpp UnitTestsSources/UnitTestsMain.cpp |
diffstat | 21 files changed, 85 insertions(+), 71 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/Cache/SharedArchive.cpp Wed Mar 28 14:18:02 2018 +0200 +++ b/Core/Cache/SharedArchive.cpp Wed Mar 28 15:20:50 2018 +0200 @@ -34,7 +34,7 @@ #include "../PrecompiledHeaders.h" #include "SharedArchive.h" -#include "../SystemToolbox.h" +#include "../Toolbox.h" namespace Orthanc @@ -100,7 +100,7 @@ RemoveInternal(oldest); } - std::string id = SystemToolbox::GenerateUuid(); + std::string id = Toolbox::GenerateUuid(); RemoveInternal(id); // Should never be useful because of UUID archive_[id] = obj; lru_.Add(id);
--- a/Core/DicomParsing/FromDcmtkBridge.cpp Wed Mar 28 14:18:02 2018 +0200 +++ b/Core/DicomParsing/FromDcmtkBridge.cpp Wed Mar 28 15:20:50 2018 +0200 @@ -37,14 +37,21 @@ #define NOMINMAX #endif +#if !defined(ORTHANC_SANDBOXED) +# error The macro ORTHANC_SANDBOXED must be defined +#endif + #include "FromDcmtkBridge.h" #include "ToDcmtkBridge.h" #include "../Logging.h" -#include "../SystemToolbox.h" #include "../Toolbox.h" -#include "../TemporaryFile.h" #include "../OrthancException.h" +#if ORTHANC_SANDBOXED == 0 +# include "../SystemToolbox.h" +# include "../TemporaryFile.h" +#endif + #include <list> #include <limits> @@ -1151,7 +1158,7 @@ // The "PatientID" field is of type LO (Long String), 64 // Bytes Maximum. An UUID is of length 36, thus it can be used // as a random PatientID. - return SystemToolbox::GenerateUuid(); + return Toolbox::GenerateUuid(); case ResourceType_Instance: return dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT);
--- a/Core/DicomParsing/ParsedDicomFile.cpp Wed Mar 28 14:18:02 2018 +0200 +++ b/Core/DicomParsing/ParsedDicomFile.cpp Wed Mar 28 15:20:50 2018 +0200 @@ -87,7 +87,10 @@ #include "../Logging.h" #include "../OrthancException.h" #include "../Toolbox.h" -#include "../SystemToolbox.h" + +#if ORTHANC_SANDBOXED == 0 +# include "../SystemToolbox.h" +#endif #if ORTHANC_ENABLE_JPEG == 1 # include "../Images/JpegReader.h" @@ -885,6 +888,7 @@ } +#if ORTHANC_SANDBOXED == 0 void ParsedDicomFile::SaveToFile(const std::string& path) { // TODO Avoid using a temporary memory buffer, write directly on disk @@ -892,6 +896,7 @@ SaveToMemoryBuffer(content); SystemToolbox::WriteFile(content, path); } +#endif ParsedDicomFile::ParsedDicomFile(bool createIdentifiers) : pimpl_(new PImpl)
--- a/Core/DicomParsing/ParsedDicomFile.h Wed Mar 28 14:18:02 2018 +0200 +++ b/Core/DicomParsing/ParsedDicomFile.h Wed Mar 28 15:20:50 2018 +0200 @@ -49,6 +49,10 @@ # error Macro ORTHANC_ENABLE_MONGOOSE must be defined to use this file #endif +#if !defined(ORTHANC_SANDBOXED) +# error The macro ORTHANC_SANDBOXED must be defined +#endif + #include "ITagVisitor.h" #include "../DicomFormat/DicomInstanceHasher.h" #include "../Images/ImageAccessor.h" @@ -160,7 +164,9 @@ void SaveToMemoryBuffer(std::string& buffer); +#if ORTHANC_SANDBOXED == 0 void SaveToFile(const std::string& path); +#endif void EmbedContent(const std::string& dataUriScheme);
--- a/Core/DicomParsing/ToDcmtkBridge.cpp Wed Mar 28 14:18:02 2018 +0200 +++ b/Core/DicomParsing/ToDcmtkBridge.cpp Wed Mar 28 15:20:50 2018 +0200 @@ -35,7 +35,6 @@ #include "ToDcmtkBridge.h" #include <memory> -#include <dcmtk/dcmnet/diutil.h> #include "../OrthancException.h"
--- a/Core/FileStorage/StorageAccessor.cpp Wed Mar 28 14:18:02 2018 +0200 +++ b/Core/FileStorage/StorageAccessor.cpp Wed Mar 28 15:20:50 2018 +0200 @@ -37,7 +37,7 @@ #include "../Compression/ZlibCompressor.h" #include "../OrthancException.h" #include "../Toolbox.h" -#include "../SystemToolbox.h" +#include "../Toolbox.h" #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1 # include "../HttpServer/HttpStreamTranscoder.h" @@ -51,7 +51,7 @@ CompressionType compression, bool storeMd5) { - std::string uuid = SystemToolbox::GenerateUuid(); + std::string uuid = Toolbox::GenerateUuid(); std::string md5;
--- a/Core/HttpServer/HttpOutput.cpp Wed Mar 28 14:18:02 2018 +0200 +++ b/Core/HttpServer/HttpOutput.cpp Wed Mar 28 15:20:50 2018 +0200 @@ -36,7 +36,6 @@ #include "../Logging.h" #include "../OrthancException.h" -#include "../SystemToolbox.h" #include "../Toolbox.h" #include "../Compression/GzipCompressor.h" #include "../Compression/ZlibCompressor.h" @@ -440,7 +439,7 @@ header += *it; } - multipartBoundary_ = SystemToolbox::GenerateUuid(); + multipartBoundary_ = Toolbox::GenerateUuid(); multipartContentType_ = contentType; header += "Content-Type: multipart/" + subType + "; type=" + contentType + "; boundary=" + multipartBoundary_ + "\r\n\r\n";
--- a/Core/SystemToolbox.cpp Wed Mar 28 14:18:02 2018 +0200 +++ b/Core/SystemToolbox.cpp Wed Mar 28 15:20:50 2018 +0200 @@ -62,19 +62,6 @@ #endif -// Inclusions for UUID -// http://stackoverflow.com/a/1626302 - -extern "C" -{ -#if defined(_WIN32) -# include <rpc.h> -#else -# include <uuid/uuid.h> -#endif -} - - #include "Logging.h" #include "OrthancException.h" #include "Toolbox.h" @@ -539,28 +526,6 @@ } - std::string SystemToolbox::GenerateUuid() - { -#ifdef WIN32 - UUID uuid; - UuidCreate ( &uuid ); - - unsigned char * str; - UuidToStringA ( &uuid, &str ); - - std::string s( ( char* ) str ); - - RpcStringFreeA ( &str ); -#else - uuid_t uuid; - uuid_generate_random ( uuid ); - char s[37]; - uuid_unparse ( uuid, s ); -#endif - return s; - } - - static boost::posix_time::ptime GetNow(bool utc) { if (utc)
--- a/Core/SystemToolbox.h Wed Mar 28 14:18:02 2018 +0200 +++ b/Core/SystemToolbox.h Wed Mar 28 15:20:50 2018 +0200 @@ -93,8 +93,6 @@ FILE* OpenFile(const std::string& path, FileMode mode); - std::string GenerateUuid(); - std::string GetNowIsoString(bool utc); void GetNowDicom(std::string& date,
--- a/Core/TemporaryFile.cpp Wed Mar 28 14:18:02 2018 +0200 +++ b/Core/TemporaryFile.cpp Wed Mar 28 15:20:50 2018 +0200 @@ -52,7 +52,7 @@ #endif // We use UUID to create unique path to temporary files - std::string filename = "Orthanc-" + Orthanc::SystemToolbox::GenerateUuid(); + std::string filename = "Orthanc-" + Orthanc::Toolbox::GenerateUuid(); if (extension != NULL) {
--- a/Core/Toolbox.cpp Wed Mar 28 14:18:02 2018 +0200 +++ b/Core/Toolbox.cpp Wed Mar 28 15:20:50 2018 +0200 @@ -87,6 +87,20 @@ #endif +// Inclusions for UUID +// http://stackoverflow.com/a/1626302 + +extern "C" +{ +#if defined(_WIN32) +# include <rpc.h> +#else +# include <uuid/uuid.h> +#endif +} + + + namespace Orthanc { void Toolbox::ToUpperCase(std::string& s) @@ -1376,4 +1390,26 @@ return boost::locale::conv::utf_to_utf<char>(w); } #endif + + + std::string Toolbox::GenerateUuid() + { +#ifdef WIN32 + UUID uuid; + UuidCreate ( &uuid ); + + unsigned char * str; + UuidToStringA ( &uuid, &str ); + + std::string s( ( char* ) str ); + + RpcStringFreeA ( &str ); +#else + uuid_t uuid; + uuid_generate_random ( uuid ); + char s[37]; + uuid_unparse ( uuid, s ); +#endif + return s; + } }
--- a/Core/Toolbox.h Wed Mar 28 14:18:02 2018 +0200 +++ b/Core/Toolbox.h Wed Mar 28 15:20:50 2018 +0200 @@ -214,5 +214,7 @@ std::string ToUpperCaseWithAccents(const std::string& source); #endif + + std::string GenerateUuid(); } }
--- a/OrthancServer/Scheduler/ServerJob.cpp Wed Mar 28 14:18:02 2018 +0200 +++ b/OrthancServer/Scheduler/ServerJob.cpp Wed Mar 28 15:20:50 2018 +0200 @@ -35,7 +35,6 @@ #include "ServerJob.h" #include "../../Core/OrthancException.h" -#include "../../Core/SystemToolbox.h" #include "../../Core/Toolbox.h" namespace Orthanc @@ -97,7 +96,7 @@ ServerJob::ServerJob() : - jobId_(SystemToolbox::GenerateUuid()), + jobId_(Toolbox::GenerateUuid()), submitted_(false), description_("no description") {
--- a/Plugins/Engine/OrthancPlugins.cpp Wed Mar 28 14:18:02 2018 +0200 +++ b/Plugins/Engine/OrthancPlugins.cpp Wed Mar 28 15:20:50 2018 +0200 @@ -2601,7 +2601,7 @@ case _OrthancPluginService_GenerateUuid: { *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result = - CopyString(SystemToolbox::GenerateUuid()); + CopyString(Toolbox::GenerateUuid()); return true; }
--- a/Resources/CMake/BoostConfiguration.cmake Wed Mar 28 14:18:02 2018 +0200 +++ b/Resources/CMake/BoostConfiguration.cmake Wed Mar 28 15:20:50 2018 +0200 @@ -233,6 +233,7 @@ ) if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR + CMAKE_SYSTEM_NAME STREQUAL "Emscripten" OR # For WebAssembly or asm.js CMAKE_SYSTEM_VERSION STREQUAL "LinuxStandardBase") list(APPEND BOOST_SOURCES ${BOOST_SOURCES_DIR}/libs/locale/src/std/codecvt.cpp
--- a/Resources/CMake/DcmtkConfiguration.cmake Wed Mar 28 14:18:02 2018 +0200 +++ b/Resources/CMake/DcmtkConfiguration.cmake Wed Mar 28 15:20:50 2018 +0200 @@ -237,7 +237,8 @@ ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR - ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") + ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" OR + ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") list(REMOVE_ITEM DCMTK_SOURCES ${DCMTK_SOURCES_DIR}/oflog/libsrc/clfsap.cc ${DCMTK_SOURCES_DIR}/oflog/libsrc/windebap.cc
--- a/Resources/CMake/OrthancFrameworkConfiguration.cmake Wed Mar 28 14:18:02 2018 +0200 +++ b/Resources/CMake/OrthancFrameworkConfiguration.cmake Wed Mar 28 15:20:50 2018 +0200 @@ -359,10 +359,7 @@ ##################################################################### include(${CMAKE_CURRENT_LIST_DIR}/JsonCppConfiguration.cmake) - -if (NOT ORTHANC_SANDBOXED) - include(${CMAKE_CURRENT_LIST_DIR}/UuidConfiguration.cmake) -endif() +include(${CMAKE_CURRENT_LIST_DIR}/UuidConfiguration.cmake) # We put Boost as the last dependency, as it is the heaviest to # configure, which allows to quickly spot problems when configuring @@ -396,7 +393,6 @@ endif() set(ORTHANC_DICOM_SOURCES_INTERNAL - ${ORTHANC_ROOT}/Core/DicomParsing/DicomDirWriter.cpp ${ORTHANC_ROOT}/Core/DicomParsing/DicomModification.cpp ${ORTHANC_ROOT}/Core/DicomParsing/FromDcmtkBridge.cpp ${ORTHANC_ROOT}/Core/DicomParsing/ParsedDicomFile.cpp @@ -477,6 +473,7 @@ list(APPEND ORTHANC_CORE_SOURCES_INTERNAL ${ORTHANC_ROOT}/Core/Cache/SharedArchive.cpp + ${ORTHANC_ROOT}/Core/DicomParsing/DicomDirWriter.cpp ${ORTHANC_ROOT}/Core/FileStorage/FilesystemStorage.cpp ${ORTHANC_ROOT}/Core/FileStorage/StorageAccessor.cpp ${ORTHANC_ROOT}/Core/MultiThreading/BagOfTasksProcessor.cpp
--- a/UnitTestsSources/FileStorageTests.cpp Wed Mar 28 14:18:02 2018 +0200 +++ b/UnitTestsSources/FileStorageTests.cpp Wed Mar 28 15:20:50 2018 +0200 @@ -61,8 +61,8 @@ { FilesystemStorage s("UnitTestsStorage"); - std::string data = SystemToolbox::GenerateUuid(); - std::string uid = SystemToolbox::GenerateUuid(); + std::string data = Toolbox::GenerateUuid(); + std::string uid = Toolbox::GenerateUuid(); s.Create(uid.c_str(), &data[0], data.size(), FileContentType_Unknown); std::string d; s.Read(d, uid, FileContentType_Unknown); @@ -76,8 +76,8 @@ FilesystemStorage s("UnitTestsStorage"); std::vector<uint8_t> data; - StringToVector(data, SystemToolbox::GenerateUuid()); - std::string uid = SystemToolbox::GenerateUuid(); + StringToVector(data, Toolbox::GenerateUuid()); + std::string uid = Toolbox::GenerateUuid(); s.Create(uid.c_str(), &data[0], data.size(), FileContentType_Unknown); std::string d; s.Read(d, uid, FileContentType_Unknown); @@ -94,8 +94,8 @@ std::list<std::string> u; for (unsigned int i = 0; i < 10; i++) { - std::string t = SystemToolbox::GenerateUuid(); - std::string uid = SystemToolbox::GenerateUuid(); + std::string t = Toolbox::GenerateUuid(); + std::string uid = Toolbox::GenerateUuid(); s.Create(uid.c_str(), &t[0], t.size(), FileContentType_Unknown); u.push_back(uid); }
--- a/UnitTestsSources/ServerIndexTests.cpp Wed Mar 28 14:18:02 2018 +0200 +++ b/UnitTestsSources/ServerIndexTests.cpp Wed Mar 28 15:20:50 2018 +0200 @@ -824,7 +824,7 @@ for (size_t i = 0; i < ids.size(); i++) { - FileInfo info(SystemToolbox::GenerateUuid(), FileContentType_Dicom, 1, "md5"); + FileInfo info(Toolbox::GenerateUuid(), FileContentType_Dicom, 1, "md5"); index.AddAttachment(info, ids[i]); index.ComputeStatistics(tmp);
--- a/UnitTestsSources/StreamTests.cpp Wed Mar 28 14:18:02 2018 +0200 +++ b/UnitTestsSources/StreamTests.cpp Wed Mar 28 15:20:50 2018 +0200 @@ -35,7 +35,6 @@ #include "gtest/gtest.h" #include "../Core/SystemToolbox.h" -#include "../Core/SystemToolbox.h" #include "../Core/Toolbox.h" #include "../Core/OrthancException.h" #include "../Core/HttpServer/BufferHttpSender.h" @@ -115,7 +114,7 @@ TEST(Zlib, Basic) { - std::string s = SystemToolbox::GenerateUuid(); + std::string s = Toolbox::GenerateUuid(); s = s + s + s + s; std::string compressed, compressed2; @@ -132,7 +131,7 @@ TEST(Zlib, Level) { - std::string s = SystemToolbox::GenerateUuid(); + std::string s = Toolbox::GenerateUuid(); s = s + s + s + s; std::string compressed, compressed2; @@ -149,7 +148,7 @@ TEST(Zlib, DISABLED_Corrupted) // Disabled because it may result in a crash { - std::string s = SystemToolbox::GenerateUuid(); + std::string s = Toolbox::GenerateUuid(); s = s + s + s + s; std::string compressed; @@ -254,7 +253,7 @@ { ZlibCompressor compressor; - const std::string s = "Hello world " + SystemToolbox::GenerateUuid(); + const std::string s = "Hello world " + Toolbox::GenerateUuid(); std::string t; IBufferCompressor::Compress(t, compressor, s);
--- a/UnitTestsSources/UnitTestsMain.cpp Wed Mar 28 14:18:02 2018 +0200 +++ b/UnitTestsSources/UnitTestsMain.cpp Wed Mar 28 15:20:50 2018 +0200 @@ -54,7 +54,7 @@ { for (int i = 0; i < 10; i++) { - std::string s = SystemToolbox::GenerateUuid(); + std::string s = Toolbox::GenerateUuid(); ASSERT_TRUE(Toolbox::IsUuid(s)); } }