Mercurial > hg > orthanc
diff OrthancServer/DicomProtocol/DicomServer.cpp @ 376:2cef9c2d4148
separate path for SQLite index, manual loading of external dictionaries
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 17 Apr 2013 11:13:51 +0200 |
parents | 8d3a0db39967 |
children | 4d5f0857ec9c |
line wrap: on
line diff
--- a/OrthancServer/DicomProtocol/DicomServer.cpp Tue Apr 16 17:33:44 2013 +0200 +++ b/OrthancServer/DicomProtocol/DicomServer.cpp Wed Apr 17 11:13:51 2013 +0200 @@ -39,9 +39,14 @@ #include "EmbeddedResources.h" #include <boost/thread.hpp> +#include <boost/filesystem.hpp> #include <dcmtk/dcmdata/dcdict.h> #include <glog/logging.h> +#if defined(__linux) +#include <cstdlib> +#endif + namespace Orthanc { @@ -70,17 +75,31 @@ } + static void LoadExternalDictionary(DcmDataDictionary& dictionary, + const std::string& directory, + const std::string& filename) + { + boost::filesystem::path p = directory; + p = p / filename; + + if (!dictionary.loadDictionary(p.string().c_str())) + { + throw OrthancException(ErrorCode_InternalError); + } + } + + void DicomServer::ServerThread(DicomServer* server) { /* Disable "gethostbyaddr" (which results in memory leaks) and use raw IP addresses */ dcmDisableGethostbyaddr.set(OFTrue); -#if DCMTK_USE_EMBEDDED_DICTIONARIES == 1 - LOG(WARNING) << "Loading the embedded dictionaries"; dcmDataDict.clear(); DcmDataDictionary& d = dcmDataDict.wrlock(); +#if DCMTK_USE_EMBEDDED_DICTIONARIES == 1 + LOG(WARNING) << "Loading the embedded dictionaries"; /** * Do not load DICONDE dictionary, it breaks the other tags. The * command "strace storescu 2>&1 |grep dic" shows that DICONDE @@ -90,8 +109,24 @@ LoadEmbeddedDictionary(d, EmbeddedResources::DICTIONARY_DICOM); LoadEmbeddedDictionary(d, EmbeddedResources::DICTIONARY_PRIVATE); + +#elif defined(__linux) + std::string path = "/usr/share/dcmtk"; + + const char* env = std::getenv(DCM_DICT_ENVIRONMENT_VARIABLE); + if (env != NULL) + { + path = std::string(env); + } + + LoadExternalDictionary(d, path, "dicom.dic"); + LoadExternalDictionary(d, path, "private.dic"); + +#else +#error Support your platform here +#endif + dcmDataDict.unlock(); -#endif /* make sure data dictionary is loaded */ if (!dcmDataDict.isDictionaryLoaded())