Mercurial > hg > orthanc
view OrthancFramework/Resources/Patches/dcmtk-3.6.9.patch @ 6249:a8c0be03dae3
merged sql-opti -> default
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 15 Jul 2025 17:00:16 +0200 |
parents | 5547f4c01253 |
children |
line wrap: on
line source
diff -urEb dcmtk-3.6.9.orig/CMake/GenerateDCMTKConfigure.cmake dcmtk-3.6.9/CMake/GenerateDCMTKConfigure.cmake --- dcmtk-3.6.9.orig/CMake/GenerateDCMTKConfigure.cmake 2025-02-18 18:03:13.505405952 +0100 +++ dcmtk-3.6.9/CMake/GenerateDCMTKConfigure.cmake 2025-02-18 18:06:53.925278621 +0100 @@ -227,12 +227,15 @@ # Check the sizes of various types include (CheckTypeSize) +if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten") + # This doesn't work for wasm, Orthanc defines the macros manually CHECK_TYPE_SIZE("double" SIZEOF_DOUBLE) CHECK_TYPE_SIZE("float" SIZEOF_FLOAT) CHECK_TYPE_SIZE("int" SIZEOF_INT) CHECK_TYPE_SIZE("long" SIZEOF_LONG) CHECK_TYPE_SIZE("short" SIZEOF_SHORT) CHECK_TYPE_SIZE("void*" SIZEOF_VOID_P) +endif() # Check for include files, libraries, and functions include("${DCMTK_CMAKE_INCLUDE}CMake/dcmtkTryCompile.cmake") diff -urEb dcmtk-3.6.9.orig/dcmdata/include/dcmtk/dcmdata/dcdict.h dcmtk-3.6.9/dcmdata/include/dcmtk/dcmdata/dcdict.h --- dcmtk-3.6.9.orig/dcmdata/include/dcmtk/dcmdata/dcdict.h 2025-02-18 18:03:13.497406077 +0100 +++ dcmtk-3.6.9/dcmdata/include/dcmtk/dcmdata/dcdict.h 2025-02-18 18:06:53.925278621 +0100 @@ -163,6 +163,12 @@ /// returns an iterator to the end of the repeating groups data dictionary DcmDictEntryListIterator repeatingEnd() { return repDict.end(); } + // Function by the Orthanc project to load a dictionary from a + // memory buffer, which is necessary in sandboxed + // environments. This is an adapted version of + // DcmDataDictionary::loadDictionary(). + OFBool loadFromMemory(const std::string& content, OFBool errorIfAbsent = OFTrue); + private: /** private undefined assignment operator diff -urEb dcmtk-3.6.9.orig/dcmdata/libsrc/dcdict.cc dcmtk-3.6.9/dcmdata/libsrc/dcdict.cc --- dcmtk-3.6.9.orig/dcmdata/libsrc/dcdict.cc 2025-02-18 18:03:13.499406046 +0100 +++ dcmtk-3.6.9/dcmdata/libsrc/dcdict.cc 2025-02-18 18:06:53.926278608 +0100 @@ -904,3 +904,5 @@ wrlock().clear(); wrunlock(); } + +#include "dcdict_orthanc.cc" diff -urEb dcmtk-3.6.9.orig/dcmdata/libsrc/dcpxitem.cc dcmtk-3.6.9/dcmdata/libsrc/dcpxitem.cc --- dcmtk-3.6.9.orig/dcmdata/libsrc/dcpxitem.cc 2025-02-18 18:03:13.497406077 +0100 +++ dcmtk-3.6.9/dcmdata/libsrc/dcpxitem.cc 2025-02-18 18:06:53.926278608 +0100 @@ -31,6 +31,8 @@ #include "dcmtk/dcmdata/dcostrma.h" /* for class DcmOutputStream */ #include "dcmtk/dcmdata/dcwcache.h" /* for class DcmWriteCache */ +#undef max +#include "dcmtk/ofstd/oflimits.h" // ******************************** diff -urEb dcmtk-3.6.9.orig/dcmnet/libsrc/scu.cc dcmtk-3.6.9/dcmnet/libsrc/scu.cc --- dcmtk-3.6.9.orig/dcmnet/libsrc/scu.cc 2025-02-18 18:03:13.525405640 +0100 +++ dcmtk-3.6.9/dcmnet/libsrc/scu.cc 2025-02-18 18:06:53.927278595 +0100 @@ -19,6 +19,11 @@ * */ +#if defined(_WIN32) +# define __STDC_LIMIT_MACROS // Get access to UINT16_MAX +# include <stdint.h> +#endif + #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ #include "dcmtk/dcmdata/dcostrmf.h" /* for class DcmOutputFileStream */ diff -urEb dcmtk-3.6.9.orig/oficonv/include/dcmtk/oficonv/iconv.h dcmtk-3.6.9/oficonv/include/dcmtk/oficonv/iconv.h --- dcmtk-3.6.9.orig/oficonv/include/dcmtk/oficonv/iconv.h 2025-02-18 18:03:13.510405874 +0100 +++ dcmtk-3.6.9/oficonv/include/dcmtk/oficonv/iconv.h 2025-02-18 18:06:53.927278595 +0100 @@ -55,7 +55,12 @@ #endif struct __tag_iconv_t; + +#if defined(__LSB_VERSION__) +typedef void *iconv_t; +#else typedef struct __tag_iconv_t *iconv_t; +#endif #ifndef OFICONV_CITRUS_WC_T_DEFINED #define OFICONV_CITRUS_WC_T_DEFINED diff -urEb dcmtk-3.6.9.orig/oficonv/libsrc/citrus_csmapper.c dcmtk-3.6.9/oficonv/libsrc/citrus_csmapper.c --- dcmtk-3.6.9.orig/oficonv/libsrc/citrus_csmapper.c 2025-02-18 18:03:13.510405874 +0100 +++ dcmtk-3.6.9/oficonv/libsrc/citrus_csmapper.c 2025-02-18 18:06:53.927278595 +0100 @@ -63,7 +63,8 @@ #ifdef WITH_THREADS #ifdef HAVE_WINDOWS_H -static SRWLOCK ma_lock = SRWLOCK_INIT; +static int ma_lock_initialized = 0; +static CRITICAL_SECTION ma_lock; #elif defined(HAVE_PTHREAD_H) static pthread_rwlock_t ma_lock = PTHREAD_RWLOCK_INITIALIZER; #endif @@ -382,6 +383,14 @@ char mapper_path[OFICONV_PATH_MAX]; unsigned long norm; int ret; + +#if defined(WITH_THREADS) && defined(HAVE_WINDOWS_H) + if (ma_lock_initialized == 0) { /* Very minor risk of race condition here */ + InitializeCriticalSection(&ma_lock); + ma_lock_initialized = 1; + } +#endif + norm = 0; getCSMapperPath(mapper_path, sizeof(mapper_path), NULL); diff -urEb dcmtk-3.6.9.orig/oficonv/libsrc/citrus_iconv.c dcmtk-3.6.9/oficonv/libsrc/citrus_iconv.c --- dcmtk-3.6.9.orig/oficonv/libsrc/citrus_iconv.c 2025-02-18 18:03:13.520405718 +0100 +++ dcmtk-3.6.9/oficonv/libsrc/citrus_iconv.c 2025-02-18 18:10:35.928614598 +0100 @@ -49,7 +49,15 @@ #endif #include <limits.h> + +#if (_MSC_VER >= 1900) #include <stdbool.h> +#else +#define bool int +#define false 0 +#define true 1 +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -80,7 +88,8 @@ #ifdef WITH_THREADS #ifdef HAVE_WINDOWS_H -static SRWLOCK ci_lock = SRWLOCK_INIT; +static int ci_lock_initialized = 0; +static CRITICAL_SECTION ci_lock; #elif defined(HAVE_PTHREAD_H) static pthread_rwlock_t ci_lock = PTHREAD_RWLOCK_INITIALIZER; #endif @@ -299,14 +308,24 @@ _citrus_iconv_open(struct _citrus_iconv * * rcv, const char * src, const char * dst) { -struct _citrus_iconv *cv = NULL; +#ifdef HAVE_WINDOWS_H + char current_codepage[20]; +#endif + + struct _citrus_iconv *cv = NULL; struct _citrus_iconv_shared *ci = NULL; char realdst[OFICONV_PATH_MAX], realsrc[OFICONV_PATH_MAX]; int ret; +#if defined(WITH_THREADS) && defined(HAVE_WINDOWS_H) + if (ci_lock_initialized == 0) { /* Very minor risk of race condition here */ + InitializeCriticalSection(&ci_lock); + ci_lock_initialized = 1; + } +#endif + init_cache(); #ifdef HAVE_WINDOWS_H - char current_codepage[20]; snprintf(current_codepage, sizeof(current_codepage), "%lu", (unsigned long) GetConsoleOutputCP()); #endif diff -urEb dcmtk-3.6.9.orig/oficonv/libsrc/citrus_lock.h dcmtk-3.6.9/oficonv/libsrc/citrus_lock.h --- dcmtk-3.6.9.orig/oficonv/libsrc/citrus_lock.h 2025-02-18 18:03:13.518405749 +0100 +++ dcmtk-3.6.9/oficonv/libsrc/citrus_lock.h 2025-02-18 18:06:53.927278595 +0100 @@ -31,11 +31,11 @@ #ifdef WITH_THREADS -#ifdef HAVE_WINDOWS_H +#if defined(HAVE_WINDOWS_H) #include <windows.h> -#define WLOCK(lock) AcquireSRWLockExclusive(lock); -#define UNLOCK(lock) ReleaseSRWLockExclusive(lock); +#define WLOCK(lock) EnterCriticalSection(lock); +#define UNLOCK(lock) LeaveCriticalSection(lock); #else /* HAVE_WINDOWS_H */ diff -urEb dcmtk-3.6.9.orig/oficonv/libsrc/citrus_mapper.c dcmtk-3.6.9/oficonv/libsrc/citrus_mapper.c --- dcmtk-3.6.9.orig/oficonv/libsrc/citrus_mapper.c 2025-02-18 18:03:13.516405780 +0100 +++ dcmtk-3.6.9/oficonv/libsrc/citrus_mapper.c 2025-02-18 18:06:53.928278582 +0100 @@ -64,7 +64,8 @@ #ifdef WITH_THREADS #ifdef HAVE_WINDOWS_H -static SRWLOCK cm_lock = SRWLOCK_INIT; +static int cm_lock_initialized = 0; +static CRITICAL_SECTION cm_lock; #elif defined(HAVE_PTHREAD_H) static pthread_rwlock_t cm_lock = PTHREAD_RWLOCK_INITIALIZER; #endif @@ -355,6 +356,13 @@ const char *module, *variable; int hashval, ret; +#if defined(WITH_THREADS) && defined(HAVE_WINDOWS_H) + if (cm_lock_initialized == 0) { /* Very minor risk of race condition here */ + InitializeCriticalSection(&cm_lock); + cm_lock_initialized = 1; + } +#endif + variable = NULL; WLOCK(&cm_lock); diff -urEb dcmtk-3.6.9.orig/oflog/include/dcmtk/oflog/thread/syncpub.h dcmtk-3.6.9/oflog/include/dcmtk/oflog/thread/syncpub.h --- dcmtk-3.6.9.orig/oflog/include/dcmtk/oflog/thread/syncpub.h 2025-02-18 18:03:13.473406452 +0100 +++ dcmtk-3.6.9/oflog/include/dcmtk/oflog/thread/syncpub.h 2025-02-18 18:06:53.928278582 +0100 @@ -63,7 +63,7 @@ DCMTK_LOG4CPLUS_INLINE_EXPORT Mutex::Mutex (Mutex::Type t) - : mtx (DCMTK_LOG4CPLUS_THREADED (new impl::Mutex (t) + 0)) + : mtx (DCMTK_LOG4CPLUS_THREADED (new impl::Mutex (t))) { } @@ -106,7 +106,7 @@ DCMTK_LOG4CPLUS_INLINE_EXPORT Semaphore::Semaphore (unsigned DCMTK_LOG4CPLUS_THREADED (max), unsigned DCMTK_LOG4CPLUS_THREADED (initial)) - : sem (DCMTK_LOG4CPLUS_THREADED (new impl::Semaphore (max, initial) + 0)) + : sem (DCMTK_LOG4CPLUS_THREADED (new impl::Semaphore (max, initial))) { } @@ -190,7 +190,7 @@ DCMTK_LOG4CPLUS_INLINE_EXPORT ManualResetEvent::ManualResetEvent (bool DCMTK_LOG4CPLUS_THREADED (sig)) - : ev (DCMTK_LOG4CPLUS_THREADED (new impl::ManualResetEvent (sig) + 0)) + : ev (DCMTK_LOG4CPLUS_THREADED (new impl::ManualResetEvent (sig))) { } @@ -252,7 +252,7 @@ DCMTK_LOG4CPLUS_INLINE_EXPORT SharedMutex::SharedMutex () - : sm (DCMTK_LOG4CPLUS_THREADED (new impl::SharedMutex + 0)) + : sm (DCMTK_LOG4CPLUS_THREADED (new impl::SharedMutex)) { } diff -urEb dcmtk-3.6.9.orig/oflog/libsrc/oflog.cc dcmtk-3.6.9/oflog/libsrc/oflog.cc --- dcmtk-3.6.9.orig/oflog/libsrc/oflog.cc 2025-02-18 18:03:13.475406421 +0100 +++ dcmtk-3.6.9/oflog/libsrc/oflog.cc 2025-02-18 18:06:53.928278582 +0100 @@ -19,6 +19,11 @@ * */ + +#if defined(_WIN32) +# include <winsock2.h> +#endif + #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ #include "dcmtk/oflog/oflog.h" diff -urEb dcmtk-3.6.9.orig/ofstd/include/dcmtk/ofstd/offile.h dcmtk-3.6.9/ofstd/include/dcmtk/ofstd/offile.h --- dcmtk-3.6.9.orig/ofstd/include/dcmtk/ofstd/offile.h 2025-02-18 18:03:13.523405671 +0100 +++ dcmtk-3.6.9/ofstd/include/dcmtk/ofstd/offile.h 2025-02-18 18:06:53.929278570 +0100 @@ -569,7 +569,7 @@ */ void setlinebuf() { -#if defined(_WIN32) || defined(__hpux) +#if defined(_WIN32) || defined(__hpux) || defined(__LSB_VERSION__) this->setvbuf(NULL, _IOLBF, 0); #else :: setlinebuf(file_); diff -urEb dcmtk-3.6.9.orig/ofstd/libsrc/ofstub.cc dcmtk-3.6.9/ofstd/libsrc/ofstub.cc --- dcmtk-3.6.9.orig/ofstd/libsrc/ofstub.cc 2025-02-18 18:03:13.523405671 +0100 +++ dcmtk-3.6.9/ofstd/libsrc/ofstub.cc 2025-02-18 18:06:53.929278570 +0100 @@ -35,6 +35,10 @@ #include <windows.h> #endif /* HAVE_WINDOWS_H */ +#if defined(__LSB_VERSION__) +#include <errno.h> +#endif + #define EXITCODE_CANNOT_DETERMINE_DIR 90 #define EXITCODE_EXEC_FAILED 91 #define EXITCODE_ILLEGAL_PARAMS 92