Mercurial > hg > orthanc
annotate Core/OrthancFramework.cpp @ 4042:f5c86a00cae0
moving DownloadOrthancFramework.cmake to Resources/CMake/
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 10 Jun 2020 16:44:29 +0200 |
parents | 100fbe970762 |
children |
rev | line source |
---|---|
4029
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU General Public License as |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * published by the Free Software Foundation, either version 3 of the |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * License, or (at your option) any later version. |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * In addition, as a special exception, the copyright holders of this |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * program give permission to link the code of its release with the |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * that use the same license as the "OpenSSL" library), and distribute |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * the linked executables. You must obey the GNU General Public License |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * in all respects for all of the code used other than "OpenSSL". If you |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * modify file(s) with this exception, you may extend this exception to |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * your version of the file(s), but you are not obligated to do so. If |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * you do not wish to do so, delete this exception statement from your |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * version. If you delete this exception statement from all source files |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * in the program, then also delete it here. |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * This program is distributed in the hope that it will be useful, but |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 * WITHOUT ANY WARRANTY; without even the implied warranty of |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * General Public License for more details. |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * You should have received a copy of the GNU General Public License |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 **/ |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 #include "PrecompiledHeaders.h" |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 #include "OrthancFramework.h" |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 #if !defined(ORTHANC_ENABLE_CURL) |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 # error Macro ORTHANC_ENABLE_CURL must be defined |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 #endif |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 #if !defined(ORTHANC_ENABLE_SSL) |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 # error Macro ORTHANC_ENABLE_SSL must be defined |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 #endif |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 #if !defined(ORTHANC_ENABLE_DCMTK) |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 # error Macro ORTHANC_ENABLE_DCMTK must be defined |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 #endif |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 #if !defined(ORTHANC_ENABLE_DCMTK_NETWORKING) |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 # error Macro ORTHANC_ENABLE_DCMTK_NETWORKING must be defined |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 #endif |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 #if ORTHANC_ENABLE_CURL == 1 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 # include "HttpClient.h" |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 #endif |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 #if ORTHANC_ENABLE_DCMTK == 1 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 # include "DicomParsing/FromDcmtkBridge.h" |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 # if ORTHANC_ENABLE_DCMTK_NETWORKING == 1 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 # include <dcmtk/dcmnet/dul.h> |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 # endif |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 #endif |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 #include "Logging.h" |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 #include "Toolbox.h" |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 namespace Orthanc |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 { |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 void InitializeFramework(const std::string& locale, |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 bool loadPrivateDictionary) |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 { |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 Logging::Initialize(); |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 |
4030
100fbe970762
DANGEROUS commit: removing HAS_EMBEDDED_RESOURCES
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4029
diff
changeset
|
75 #if (ORTHANC_ENABLE_LOCALE == 1) && !defined(__EMSCRIPTEN__) // No global locale in wasm/asm.js |
4029
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 if (locale.empty()) |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 { |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 Toolbox::InitializeGlobalLocale(NULL); |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 } |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 else |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 { |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 Toolbox::InitializeGlobalLocale(locale.c_str()); |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 } |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 #endif |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 Toolbox::InitializeOpenSsl(); |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 #if ORTHANC_ENABLE_CURL == 1 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 HttpClient::GlobalInitialize(); |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 #endif |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 #if ORTHANC_ENABLE_DCMTK == 1 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 FromDcmtkBridge::InitializeDictionary(true); |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 FromDcmtkBridge::InitializeCodecs(); |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 #endif |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 #if (ORTHANC_ENABLE_DCMTK == 1 && \ |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 ORTHANC_ENABLE_DCMTK_NETWORKING == 1) |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 /* Disable "gethostbyaddr" (which results in memory leaks) and use raw IP addresses */ |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 dcmDisableGethostbyaddr.set(OFTrue); |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 #endif |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 } |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 void FinalizeFramework() |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 { |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 #if ORTHANC_ENABLE_DCMTK == 1 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 FromDcmtkBridge::FinalizeCodecs(); |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 #endif |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 #if ORTHANC_ENABLE_CURL == 1 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 HttpClient::GlobalFinalize(); |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 #endif |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 Toolbox::FinalizeOpenSsl(); |
4030
100fbe970762
DANGEROUS commit: removing HAS_EMBEDDED_RESOURCES
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4029
diff
changeset
|
116 |
100fbe970762
DANGEROUS commit: removing HAS_EMBEDDED_RESOURCES
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4029
diff
changeset
|
117 #if (ORTHANC_ENABLE_LOCALE == 1) && !defined(__EMSCRIPTEN__) |
4029
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 Toolbox::FinalizeGlobalLocale(); |
4030
100fbe970762
DANGEROUS commit: removing HAS_EMBEDDED_RESOURCES
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4029
diff
changeset
|
119 #endif |
100fbe970762
DANGEROUS commit: removing HAS_EMBEDDED_RESOURCES
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4029
diff
changeset
|
120 |
4029
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 Logging::Finalize(); |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 } |
156fece692e3
missing OrthancFramework.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 } |