Mercurial > hg > orthanc-python
comparison Resources/Orthanc/Sdk-1.10.0/orthanc/OrthancCPlugin.h @ 107:461dfb859ac7
upgrade to Orthanc SDK 1.10.0
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Feb 2022 17:45:42 +0100 |
parents | |
children | cc0765aae484 |
comparison
equal
deleted
inserted
replaced
106:5094e2d8f043 | 107:461dfb859ac7 |
---|---|
1 /** | |
2 * \mainpage | |
3 * | |
4 * This C/C++ SDK allows external developers to create plugins that | |
5 * can be loaded into Orthanc to extend its functionality. Each | |
6 * Orthanc plugin must expose 4 public functions with the following | |
7 * signatures: | |
8 * | |
9 * -# <tt>int32_t OrthancPluginInitialize(const OrthancPluginContext* context)</tt>: | |
10 * This function is invoked by Orthanc when it loads the plugin on startup. | |
11 * The plugin must: | |
12 * - Check its compatibility with the Orthanc version using | |
13 * ::OrthancPluginCheckVersion(). | |
14 * - Store the context pointer so that it can use the plugin | |
15 * services of Orthanc. | |
16 * - Register all its REST callbacks using ::OrthancPluginRegisterRestCallback(). | |
17 * - Possibly register its callback for received DICOM instances using ::OrthancPluginRegisterOnStoredInstanceCallback(). | |
18 * - Possibly register its callback for changes to the DICOM store using ::OrthancPluginRegisterOnChangeCallback(). | |
19 * - Possibly register a custom storage area using ::OrthancPluginRegisterStorageArea2(). | |
20 * - Possibly register a custom database back-end area using OrthancPluginRegisterDatabaseBackendV3(). | |
21 * - Possibly register a handler for C-Find SCP using OrthancPluginRegisterFindCallback(). | |
22 * - Possibly register a handler for C-Find SCP against DICOM worklists using OrthancPluginRegisterWorklistCallback(). | |
23 * - Possibly register a handler for C-Move SCP using OrthancPluginRegisterMoveCallback(). | |
24 * - Possibly register a custom decoder for DICOM images using OrthancPluginRegisterDecodeImageCallback(). | |
25 * - Possibly register a callback to filter incoming HTTP requests using OrthancPluginRegisterIncomingHttpRequestFilter2(). | |
26 * - Possibly register a callback to unserialize jobs using OrthancPluginRegisterJobsUnserializer(). | |
27 * - Possibly register a callback to refresh its metrics using OrthancPluginRegisterRefreshMetricsCallback(). | |
28 * - Possibly register a callback to answer chunked HTTP transfers using ::OrthancPluginRegisterChunkedRestCallback(). | |
29 * - Possibly register a callback for Storage Commitment SCP using ::OrthancPluginRegisterStorageCommitmentScpCallback(). | |
30 * - Possibly register a callback to keep/discard/modify incoming DICOM instances using OrthancPluginRegisterReceivedInstanceCallback(). | |
31 * - Possibly register a custom transcoder for DICOM images using OrthancPluginRegisterTranscoderCallback(). | |
32 * - Possibly register a callback to discard instances received through DICOM C-STORE using OrthancPluginRegisterIncomingCStoreInstanceFilter(). | |
33 * -# <tt>void OrthancPluginFinalize()</tt>: | |
34 * This function is invoked by Orthanc during its shutdown. The plugin | |
35 * must free all its memory. | |
36 * -# <tt>const char* OrthancPluginGetName()</tt>: | |
37 * The plugin must return a short string to identify itself. | |
38 * -# <tt>const char* OrthancPluginGetVersion()</tt>: | |
39 * The plugin must return a string containing its version number. | |
40 * | |
41 * The name and the version of a plugin is only used to prevent it | |
42 * from being loaded twice. Note that, in C++, it is mandatory to | |
43 * declare these functions within an <tt>extern "C"</tt> section. | |
44 * | |
45 * To ensure multi-threading safety, the various REST callbacks are | |
46 * guaranteed to be executed in mutual exclusion since Orthanc | |
47 * 0.8.5. If this feature is undesired (notably when developing | |
48 * high-performance plugins handling simultaneous requests), use | |
49 * ::OrthancPluginRegisterRestCallbackNoLock(). | |
50 **/ | |
51 | |
52 | |
53 | |
54 /** | |
55 * @defgroup Images Images and compression | |
56 * @brief Functions to deal with images and compressed buffers. | |
57 * | |
58 * @defgroup REST REST | |
59 * @brief Functions to answer REST requests in a callback. | |
60 * | |
61 * @defgroup Callbacks Callbacks | |
62 * @brief Functions to register and manage callbacks by the plugins. | |
63 * | |
64 * @defgroup DicomCallbacks DicomCallbacks | |
65 * @brief Functions to register and manage DICOM callbacks (worklists, C-FIND, C-MOVE, storage commitment). | |
66 * | |
67 * @defgroup Orthanc Orthanc | |
68 * @brief Functions to access the content of the Orthanc server. | |
69 * | |
70 * @defgroup DicomInstance DicomInstance | |
71 * @brief Functions to access DICOM images that are managed by the Orthanc core. | |
72 **/ | |
73 | |
74 | |
75 | |
76 /** | |
77 * @defgroup Toolbox Toolbox | |
78 * @brief Generic functions to help with the creation of plugins. | |
79 **/ | |
80 | |
81 | |
82 | |
83 /** | |
84 * Orthanc - A Lightweight, RESTful DICOM Store | |
85 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
86 * Department, University Hospital of Liege, Belgium | |
87 * Copyright (C) 2017-2022 Osimis S.A., Belgium | |
88 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
89 * | |
90 * This program is free software: you can redistribute it and/or | |
91 * modify it under the terms of the GNU General Public License as | |
92 * published by the Free Software Foundation, either version 3 of the | |
93 * License, or (at your option) any later version. | |
94 * | |
95 * This program is distributed in the hope that it will be useful, but | |
96 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
97 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
98 * General Public License for more details. | |
99 * | |
100 * You should have received a copy of the GNU General Public License | |
101 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
102 **/ | |
103 | |
104 | |
105 | |
106 #pragma once | |
107 | |
108 | |
109 #include <stdio.h> | |
110 #include <string.h> | |
111 | |
112 #ifdef WIN32 | |
113 # define ORTHANC_PLUGINS_API __declspec(dllexport) | |
114 #elif __GNUC__ >= 4 | |
115 # define ORTHANC_PLUGINS_API __attribute__ ((visibility ("default"))) | |
116 #else | |
117 # define ORTHANC_PLUGINS_API | |
118 #endif | |
119 | |
120 #define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 1 | |
121 #define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 10 | |
122 #define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 0 | |
123 | |
124 | |
125 #if !defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) | |
126 #define ORTHANC_PLUGINS_VERSION_IS_ABOVE(major, minor, revision) \ | |
127 (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER > major || \ | |
128 (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == major && \ | |
129 (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER > minor || \ | |
130 (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER == minor && \ | |
131 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER >= revision)))) | |
132 #endif | |
133 | |
134 | |
135 | |
136 /******************************************************************** | |
137 ** Check that function inlining is properly supported. The use of | |
138 ** inlining is required, to avoid the duplication of object code | |
139 ** between two compilation modules that would use the Orthanc Plugin | |
140 ** API. | |
141 ********************************************************************/ | |
142 | |
143 /* If the auto-detection of the "inline" keyword below does not work | |
144 automatically and that your compiler is known to properly support | |
145 inlining, uncomment the following #define and adapt the definition | |
146 of "static inline". */ | |
147 | |
148 /* #define ORTHANC_PLUGIN_INLINE static inline */ | |
149 | |
150 #ifndef ORTHANC_PLUGIN_INLINE | |
151 # if __STDC_VERSION__ >= 199901L | |
152 /* This is C99 or above: http://predef.sourceforge.net/prestd.html */ | |
153 # define ORTHANC_PLUGIN_INLINE static inline | |
154 # elif defined(__cplusplus) | |
155 /* This is C++ */ | |
156 # define ORTHANC_PLUGIN_INLINE static inline | |
157 # elif defined(__GNUC__) | |
158 /* This is GCC running in C89 mode */ | |
159 # define ORTHANC_PLUGIN_INLINE static __inline | |
160 # elif defined(_MSC_VER) | |
161 /* This is Visual Studio running in C89 mode */ | |
162 # define ORTHANC_PLUGIN_INLINE static __inline | |
163 # else | |
164 # error Your compiler is not known to support the "inline" keyword | |
165 # endif | |
166 #endif | |
167 | |
168 | |
169 | |
170 /******************************************************************** | |
171 ** Inclusion of standard libraries. | |
172 ********************************************************************/ | |
173 | |
174 /** | |
175 * For Microsoft Visual Studio, a compatibility "stdint.h" can be | |
176 * downloaded at the following URL: | |
177 * https://hg.orthanc-server.com/orthanc/raw-file/tip/Resources/ThirdParty/VisualStudio/stdint.h | |
178 **/ | |
179 #include <stdint.h> | |
180 | |
181 #include <stdlib.h> | |
182 | |
183 | |
184 | |
185 /******************************************************************** | |
186 ** Definition of the Orthanc Plugin API. | |
187 ********************************************************************/ | |
188 | |
189 /** @{ */ | |
190 | |
191 #ifdef __cplusplus | |
192 extern "C" | |
193 { | |
194 #endif | |
195 | |
196 /** | |
197 * The various error codes that can be returned by the Orthanc core. | |
198 **/ | |
199 typedef enum | |
200 { | |
201 OrthancPluginErrorCode_InternalError = -1 /*!< Internal error */, | |
202 OrthancPluginErrorCode_Success = 0 /*!< Success */, | |
203 OrthancPluginErrorCode_Plugin = 1 /*!< Error encountered within the plugin engine */, | |
204 OrthancPluginErrorCode_NotImplemented = 2 /*!< Not implemented yet */, | |
205 OrthancPluginErrorCode_ParameterOutOfRange = 3 /*!< Parameter out of range */, | |
206 OrthancPluginErrorCode_NotEnoughMemory = 4 /*!< The server hosting Orthanc is running out of memory */, | |
207 OrthancPluginErrorCode_BadParameterType = 5 /*!< Bad type for a parameter */, | |
208 OrthancPluginErrorCode_BadSequenceOfCalls = 6 /*!< Bad sequence of calls */, | |
209 OrthancPluginErrorCode_InexistentItem = 7 /*!< Accessing an inexistent item */, | |
210 OrthancPluginErrorCode_BadRequest = 8 /*!< Bad request */, | |
211 OrthancPluginErrorCode_NetworkProtocol = 9 /*!< Error in the network protocol */, | |
212 OrthancPluginErrorCode_SystemCommand = 10 /*!< Error while calling a system command */, | |
213 OrthancPluginErrorCode_Database = 11 /*!< Error with the database engine */, | |
214 OrthancPluginErrorCode_UriSyntax = 12 /*!< Badly formatted URI */, | |
215 OrthancPluginErrorCode_InexistentFile = 13 /*!< Inexistent file */, | |
216 OrthancPluginErrorCode_CannotWriteFile = 14 /*!< Cannot write to file */, | |
217 OrthancPluginErrorCode_BadFileFormat = 15 /*!< Bad file format */, | |
218 OrthancPluginErrorCode_Timeout = 16 /*!< Timeout */, | |
219 OrthancPluginErrorCode_UnknownResource = 17 /*!< Unknown resource */, | |
220 OrthancPluginErrorCode_IncompatibleDatabaseVersion = 18 /*!< Incompatible version of the database */, | |
221 OrthancPluginErrorCode_FullStorage = 19 /*!< The file storage is full */, | |
222 OrthancPluginErrorCode_CorruptedFile = 20 /*!< Corrupted file (e.g. inconsistent MD5 hash) */, | |
223 OrthancPluginErrorCode_InexistentTag = 21 /*!< Inexistent tag */, | |
224 OrthancPluginErrorCode_ReadOnly = 22 /*!< Cannot modify a read-only data structure */, | |
225 OrthancPluginErrorCode_IncompatibleImageFormat = 23 /*!< Incompatible format of the images */, | |
226 OrthancPluginErrorCode_IncompatibleImageSize = 24 /*!< Incompatible size of the images */, | |
227 OrthancPluginErrorCode_SharedLibrary = 25 /*!< Error while using a shared library (plugin) */, | |
228 OrthancPluginErrorCode_UnknownPluginService = 26 /*!< Plugin invoking an unknown service */, | |
229 OrthancPluginErrorCode_UnknownDicomTag = 27 /*!< Unknown DICOM tag */, | |
230 OrthancPluginErrorCode_BadJson = 28 /*!< Cannot parse a JSON document */, | |
231 OrthancPluginErrorCode_Unauthorized = 29 /*!< Bad credentials were provided to an HTTP request */, | |
232 OrthancPluginErrorCode_BadFont = 30 /*!< Badly formatted font file */, | |
233 OrthancPluginErrorCode_DatabasePlugin = 31 /*!< The plugin implementing a custom database back-end does not fulfill the proper interface */, | |
234 OrthancPluginErrorCode_StorageAreaPlugin = 32 /*!< Error in the plugin implementing a custom storage area */, | |
235 OrthancPluginErrorCode_EmptyRequest = 33 /*!< The request is empty */, | |
236 OrthancPluginErrorCode_NotAcceptable = 34 /*!< Cannot send a response which is acceptable according to the Accept HTTP header */, | |
237 OrthancPluginErrorCode_NullPointer = 35 /*!< Cannot handle a NULL pointer */, | |
238 OrthancPluginErrorCode_DatabaseUnavailable = 36 /*!< The database is currently not available (probably a transient situation) */, | |
239 OrthancPluginErrorCode_CanceledJob = 37 /*!< This job was canceled */, | |
240 OrthancPluginErrorCode_BadGeometry = 38 /*!< Geometry error encountered in Stone */, | |
241 OrthancPluginErrorCode_SslInitialization = 39 /*!< Cannot initialize SSL encryption, check out your certificates */, | |
242 OrthancPluginErrorCode_DiscontinuedAbi = 40 /*!< Calling a function that has been removed from the Orthanc Framework */, | |
243 OrthancPluginErrorCode_BadRange = 41 /*!< Incorrect range request */, | |
244 OrthancPluginErrorCode_DatabaseCannotSerialize = 42 /*!< Database could not serialize access due to concurrent update, the transaction should be retried */, | |
245 OrthancPluginErrorCode_Revision = 43 /*!< A bad revision number was provided, which might indicate conflict between multiple writers */, | |
246 OrthancPluginErrorCode_SQLiteNotOpened = 1000 /*!< SQLite: The database is not opened */, | |
247 OrthancPluginErrorCode_SQLiteAlreadyOpened = 1001 /*!< SQLite: Connection is already open */, | |
248 OrthancPluginErrorCode_SQLiteCannotOpen = 1002 /*!< SQLite: Unable to open the database */, | |
249 OrthancPluginErrorCode_SQLiteStatementAlreadyUsed = 1003 /*!< SQLite: This cached statement is already being referred to */, | |
250 OrthancPluginErrorCode_SQLiteExecute = 1004 /*!< SQLite: Cannot execute a command */, | |
251 OrthancPluginErrorCode_SQLiteRollbackWithoutTransaction = 1005 /*!< SQLite: Rolling back a nonexistent transaction (have you called Begin()?) */, | |
252 OrthancPluginErrorCode_SQLiteCommitWithoutTransaction = 1006 /*!< SQLite: Committing a nonexistent transaction */, | |
253 OrthancPluginErrorCode_SQLiteRegisterFunction = 1007 /*!< SQLite: Unable to register a function */, | |
254 OrthancPluginErrorCode_SQLiteFlush = 1008 /*!< SQLite: Unable to flush the database */, | |
255 OrthancPluginErrorCode_SQLiteCannotRun = 1009 /*!< SQLite: Cannot run a cached statement */, | |
256 OrthancPluginErrorCode_SQLiteCannotStep = 1010 /*!< SQLite: Cannot step over a cached statement */, | |
257 OrthancPluginErrorCode_SQLiteBindOutOfRange = 1011 /*!< SQLite: Bing a value while out of range (serious error) */, | |
258 OrthancPluginErrorCode_SQLitePrepareStatement = 1012 /*!< SQLite: Cannot prepare a cached statement */, | |
259 OrthancPluginErrorCode_SQLiteTransactionAlreadyStarted = 1013 /*!< SQLite: Beginning the same transaction twice */, | |
260 OrthancPluginErrorCode_SQLiteTransactionCommit = 1014 /*!< SQLite: Failure when committing the transaction */, | |
261 OrthancPluginErrorCode_SQLiteTransactionBegin = 1015 /*!< SQLite: Cannot start a transaction */, | |
262 OrthancPluginErrorCode_DirectoryOverFile = 2000 /*!< The directory to be created is already occupied by a regular file */, | |
263 OrthancPluginErrorCode_FileStorageCannotWrite = 2001 /*!< Unable to create a subdirectory or a file in the file storage */, | |
264 OrthancPluginErrorCode_DirectoryExpected = 2002 /*!< The specified path does not point to a directory */, | |
265 OrthancPluginErrorCode_HttpPortInUse = 2003 /*!< The TCP port of the HTTP server is privileged or already in use */, | |
266 OrthancPluginErrorCode_DicomPortInUse = 2004 /*!< The TCP port of the DICOM server is privileged or already in use */, | |
267 OrthancPluginErrorCode_BadHttpStatusInRest = 2005 /*!< This HTTP status is not allowed in a REST API */, | |
268 OrthancPluginErrorCode_RegularFileExpected = 2006 /*!< The specified path does not point to a regular file */, | |
269 OrthancPluginErrorCode_PathToExecutable = 2007 /*!< Unable to get the path to the executable */, | |
270 OrthancPluginErrorCode_MakeDirectory = 2008 /*!< Cannot create a directory */, | |
271 OrthancPluginErrorCode_BadApplicationEntityTitle = 2009 /*!< An application entity title (AET) cannot be empty or be longer than 16 characters */, | |
272 OrthancPluginErrorCode_NoCFindHandler = 2010 /*!< No request handler factory for DICOM C-FIND SCP */, | |
273 OrthancPluginErrorCode_NoCMoveHandler = 2011 /*!< No request handler factory for DICOM C-MOVE SCP */, | |
274 OrthancPluginErrorCode_NoCStoreHandler = 2012 /*!< No request handler factory for DICOM C-STORE SCP */, | |
275 OrthancPluginErrorCode_NoApplicationEntityFilter = 2013 /*!< No application entity filter */, | |
276 OrthancPluginErrorCode_NoSopClassOrInstance = 2014 /*!< DicomUserConnection: Unable to find the SOP class and instance */, | |
277 OrthancPluginErrorCode_NoPresentationContext = 2015 /*!< DicomUserConnection: No acceptable presentation context for modality */, | |
278 OrthancPluginErrorCode_DicomFindUnavailable = 2016 /*!< DicomUserConnection: The C-FIND command is not supported by the remote SCP */, | |
279 OrthancPluginErrorCode_DicomMoveUnavailable = 2017 /*!< DicomUserConnection: The C-MOVE command is not supported by the remote SCP */, | |
280 OrthancPluginErrorCode_CannotStoreInstance = 2018 /*!< Cannot store an instance */, | |
281 OrthancPluginErrorCode_CreateDicomNotString = 2019 /*!< Only string values are supported when creating DICOM instances */, | |
282 OrthancPluginErrorCode_CreateDicomOverrideTag = 2020 /*!< Trying to override a value inherited from a parent module */, | |
283 OrthancPluginErrorCode_CreateDicomUseContent = 2021 /*!< Use \"Content\" to inject an image into a new DICOM instance */, | |
284 OrthancPluginErrorCode_CreateDicomNoPayload = 2022 /*!< No payload is present for one instance in the series */, | |
285 OrthancPluginErrorCode_CreateDicomUseDataUriScheme = 2023 /*!< The payload of the DICOM instance must be specified according to Data URI scheme */, | |
286 OrthancPluginErrorCode_CreateDicomBadParent = 2024 /*!< Trying to attach a new DICOM instance to an inexistent resource */, | |
287 OrthancPluginErrorCode_CreateDicomParentIsInstance = 2025 /*!< Trying to attach a new DICOM instance to an instance (must be a series, study or patient) */, | |
288 OrthancPluginErrorCode_CreateDicomParentEncoding = 2026 /*!< Unable to get the encoding of the parent resource */, | |
289 OrthancPluginErrorCode_UnknownModality = 2027 /*!< Unknown modality */, | |
290 OrthancPluginErrorCode_BadJobOrdering = 2028 /*!< Bad ordering of filters in a job */, | |
291 OrthancPluginErrorCode_JsonToLuaTable = 2029 /*!< Cannot convert the given JSON object to a Lua table */, | |
292 OrthancPluginErrorCode_CannotCreateLua = 2030 /*!< Cannot create the Lua context */, | |
293 OrthancPluginErrorCode_CannotExecuteLua = 2031 /*!< Cannot execute a Lua command */, | |
294 OrthancPluginErrorCode_LuaAlreadyExecuted = 2032 /*!< Arguments cannot be pushed after the Lua function is executed */, | |
295 OrthancPluginErrorCode_LuaBadOutput = 2033 /*!< The Lua function does not give the expected number of outputs */, | |
296 OrthancPluginErrorCode_NotLuaPredicate = 2034 /*!< The Lua function is not a predicate (only true/false outputs allowed) */, | |
297 OrthancPluginErrorCode_LuaReturnsNoString = 2035 /*!< The Lua function does not return a string */, | |
298 OrthancPluginErrorCode_StorageAreaAlreadyRegistered = 2036 /*!< Another plugin has already registered a custom storage area */, | |
299 OrthancPluginErrorCode_DatabaseBackendAlreadyRegistered = 2037 /*!< Another plugin has already registered a custom database back-end */, | |
300 OrthancPluginErrorCode_DatabaseNotInitialized = 2038 /*!< Plugin trying to call the database during its initialization */, | |
301 OrthancPluginErrorCode_SslDisabled = 2039 /*!< Orthanc has been built without SSL support */, | |
302 OrthancPluginErrorCode_CannotOrderSlices = 2040 /*!< Unable to order the slices of the series */, | |
303 OrthancPluginErrorCode_NoWorklistHandler = 2041 /*!< No request handler factory for DICOM C-Find Modality SCP */, | |
304 OrthancPluginErrorCode_AlreadyExistingTag = 2042 /*!< Cannot override the value of a tag that already exists */, | |
305 OrthancPluginErrorCode_NoStorageCommitmentHandler = 2043 /*!< No request handler factory for DICOM N-ACTION SCP (storage commitment) */, | |
306 OrthancPluginErrorCode_NoCGetHandler = 2044 /*!< No request handler factory for DICOM C-GET SCP */, | |
307 OrthancPluginErrorCode_UnsupportedMediaType = 3000 /*!< Unsupported media type */, | |
308 | |
309 _OrthancPluginErrorCode_INTERNAL = 0x7fffffff | |
310 } OrthancPluginErrorCode; | |
311 | |
312 | |
313 /** | |
314 * Forward declaration of one of the mandatory functions for Orthanc | |
315 * plugins. | |
316 **/ | |
317 ORTHANC_PLUGINS_API const char* OrthancPluginGetName(); | |
318 | |
319 | |
320 /** | |
321 * The various HTTP methods for a REST call. | |
322 **/ | |
323 typedef enum | |
324 { | |
325 OrthancPluginHttpMethod_Get = 1, /*!< GET request */ | |
326 OrthancPluginHttpMethod_Post = 2, /*!< POST request */ | |
327 OrthancPluginHttpMethod_Put = 3, /*!< PUT request */ | |
328 OrthancPluginHttpMethod_Delete = 4, /*!< DELETE request */ | |
329 | |
330 _OrthancPluginHttpMethod_INTERNAL = 0x7fffffff | |
331 } OrthancPluginHttpMethod; | |
332 | |
333 | |
334 /** | |
335 * @brief The parameters of a REST request. | |
336 * @ingroup Callbacks | |
337 **/ | |
338 typedef struct | |
339 { | |
340 /** | |
341 * @brief The HTTP method. | |
342 **/ | |
343 OrthancPluginHttpMethod method; | |
344 | |
345 /** | |
346 * @brief The number of groups of the regular expression. | |
347 **/ | |
348 uint32_t groupsCount; | |
349 | |
350 /** | |
351 * @brief The matched values for the groups of the regular expression. | |
352 **/ | |
353 const char* const* groups; | |
354 | |
355 /** | |
356 * @brief For a GET request, the number of GET parameters. | |
357 **/ | |
358 uint32_t getCount; | |
359 | |
360 /** | |
361 * @brief For a GET request, the keys of the GET parameters. | |
362 **/ | |
363 const char* const* getKeys; | |
364 | |
365 /** | |
366 * @brief For a GET request, the values of the GET parameters. | |
367 **/ | |
368 const char* const* getValues; | |
369 | |
370 /** | |
371 * @brief For a PUT or POST request, the content of the body. | |
372 **/ | |
373 const void* body; | |
374 | |
375 /** | |
376 * @brief For a PUT or POST request, the number of bytes of the body. | |
377 **/ | |
378 uint32_t bodySize; | |
379 | |
380 | |
381 /* -------------------------------------------------- | |
382 New in version 0.8.1 | |
383 -------------------------------------------------- */ | |
384 | |
385 /** | |
386 * @brief The number of HTTP headers. | |
387 **/ | |
388 uint32_t headersCount; | |
389 | |
390 /** | |
391 * @brief The keys of the HTTP headers (always converted to low-case). | |
392 **/ | |
393 const char* const* headersKeys; | |
394 | |
395 /** | |
396 * @brief The values of the HTTP headers. | |
397 **/ | |
398 const char* const* headersValues; | |
399 | |
400 } OrthancPluginHttpRequest; | |
401 | |
402 | |
403 typedef enum | |
404 { | |
405 /* Generic services */ | |
406 _OrthancPluginService_LogInfo = 1, | |
407 _OrthancPluginService_LogWarning = 2, | |
408 _OrthancPluginService_LogError = 3, | |
409 _OrthancPluginService_GetOrthancPath = 4, | |
410 _OrthancPluginService_GetOrthancDirectory = 5, | |
411 _OrthancPluginService_GetConfigurationPath = 6, | |
412 _OrthancPluginService_SetPluginProperty = 7, | |
413 _OrthancPluginService_GetGlobalProperty = 8, | |
414 _OrthancPluginService_SetGlobalProperty = 9, | |
415 _OrthancPluginService_GetCommandLineArgumentsCount = 10, | |
416 _OrthancPluginService_GetCommandLineArgument = 11, | |
417 _OrthancPluginService_GetExpectedDatabaseVersion = 12, | |
418 _OrthancPluginService_GetConfiguration = 13, | |
419 _OrthancPluginService_BufferCompression = 14, | |
420 _OrthancPluginService_ReadFile = 15, | |
421 _OrthancPluginService_WriteFile = 16, | |
422 _OrthancPluginService_GetErrorDescription = 17, | |
423 _OrthancPluginService_CallHttpClient = 18, | |
424 _OrthancPluginService_RegisterErrorCode = 19, | |
425 _OrthancPluginService_RegisterDictionaryTag = 20, | |
426 _OrthancPluginService_DicomBufferToJson = 21, | |
427 _OrthancPluginService_DicomInstanceToJson = 22, | |
428 _OrthancPluginService_CreateDicom = 23, | |
429 _OrthancPluginService_ComputeMd5 = 24, | |
430 _OrthancPluginService_ComputeSha1 = 25, | |
431 _OrthancPluginService_LookupDictionary = 26, | |
432 _OrthancPluginService_CallHttpClient2 = 27, | |
433 _OrthancPluginService_GenerateUuid = 28, | |
434 _OrthancPluginService_RegisterPrivateDictionaryTag = 29, | |
435 _OrthancPluginService_AutodetectMimeType = 30, | |
436 _OrthancPluginService_SetMetricsValue = 31, | |
437 _OrthancPluginService_EncodeDicomWebJson = 32, | |
438 _OrthancPluginService_EncodeDicomWebXml = 33, | |
439 _OrthancPluginService_ChunkedHttpClient = 34, /* New in Orthanc 1.5.7 */ | |
440 _OrthancPluginService_GetTagName = 35, /* New in Orthanc 1.5.7 */ | |
441 _OrthancPluginService_EncodeDicomWebJson2 = 36, /* New in Orthanc 1.7.0 */ | |
442 _OrthancPluginService_EncodeDicomWebXml2 = 37, /* New in Orthanc 1.7.0 */ | |
443 _OrthancPluginService_CreateMemoryBuffer = 38, /* New in Orthanc 1.7.0 */ | |
444 _OrthancPluginService_GenerateRestApiAuthorizationToken = 39, /* New in Orthanc 1.8.1 */ | |
445 _OrthancPluginService_CreateMemoryBuffer64 = 40, /* New in Orthanc 1.9.0 */ | |
446 _OrthancPluginService_CreateDicom2 = 41, /* New in Orthanc 1.9.0 */ | |
447 | |
448 /* Registration of callbacks */ | |
449 _OrthancPluginService_RegisterRestCallback = 1000, | |
450 _OrthancPluginService_RegisterOnStoredInstanceCallback = 1001, | |
451 _OrthancPluginService_RegisterStorageArea = 1002, | |
452 _OrthancPluginService_RegisterOnChangeCallback = 1003, | |
453 _OrthancPluginService_RegisterRestCallbackNoLock = 1004, | |
454 _OrthancPluginService_RegisterWorklistCallback = 1005, | |
455 _OrthancPluginService_RegisterDecodeImageCallback = 1006, | |
456 _OrthancPluginService_RegisterIncomingHttpRequestFilter = 1007, | |
457 _OrthancPluginService_RegisterFindCallback = 1008, | |
458 _OrthancPluginService_RegisterMoveCallback = 1009, | |
459 _OrthancPluginService_RegisterIncomingHttpRequestFilter2 = 1010, | |
460 _OrthancPluginService_RegisterRefreshMetricsCallback = 1011, | |
461 _OrthancPluginService_RegisterChunkedRestCallback = 1012, /* New in Orthanc 1.5.7 */ | |
462 _OrthancPluginService_RegisterStorageCommitmentScpCallback = 1013, | |
463 _OrthancPluginService_RegisterIncomingDicomInstanceFilter = 1014, | |
464 _OrthancPluginService_RegisterTranscoderCallback = 1015, /* New in Orthanc 1.7.0 */ | |
465 _OrthancPluginService_RegisterStorageArea2 = 1016, /* New in Orthanc 1.9.0 */ | |
466 _OrthancPluginService_RegisterIncomingCStoreInstanceFilter = 1017, /* New in Orthanc 1.10.0 */ | |
467 _OrthancPluginService_RegisterReceivedInstanceCallback = 1018, /* New in Orthanc 1.10.0 */ | |
468 | |
469 /* Sending answers to REST calls */ | |
470 _OrthancPluginService_AnswerBuffer = 2000, | |
471 _OrthancPluginService_CompressAndAnswerPngImage = 2001, /* Unused as of Orthanc 0.9.4 */ | |
472 _OrthancPluginService_Redirect = 2002, | |
473 _OrthancPluginService_SendHttpStatusCode = 2003, | |
474 _OrthancPluginService_SendUnauthorized = 2004, | |
475 _OrthancPluginService_SendMethodNotAllowed = 2005, | |
476 _OrthancPluginService_SetCookie = 2006, | |
477 _OrthancPluginService_SetHttpHeader = 2007, | |
478 _OrthancPluginService_StartMultipartAnswer = 2008, | |
479 _OrthancPluginService_SendMultipartItem = 2009, | |
480 _OrthancPluginService_SendHttpStatus = 2010, | |
481 _OrthancPluginService_CompressAndAnswerImage = 2011, | |
482 _OrthancPluginService_SendMultipartItem2 = 2012, | |
483 _OrthancPluginService_SetHttpErrorDetails = 2013, | |
484 | |
485 /* Access to the Orthanc database and API */ | |
486 _OrthancPluginService_GetDicomForInstance = 3000, | |
487 _OrthancPluginService_RestApiGet = 3001, | |
488 _OrthancPluginService_RestApiPost = 3002, | |
489 _OrthancPluginService_RestApiDelete = 3003, | |
490 _OrthancPluginService_RestApiPut = 3004, | |
491 _OrthancPluginService_LookupPatient = 3005, | |
492 _OrthancPluginService_LookupStudy = 3006, | |
493 _OrthancPluginService_LookupSeries = 3007, | |
494 _OrthancPluginService_LookupInstance = 3008, | |
495 _OrthancPluginService_LookupStudyWithAccessionNumber = 3009, | |
496 _OrthancPluginService_RestApiGetAfterPlugins = 3010, | |
497 _OrthancPluginService_RestApiPostAfterPlugins = 3011, | |
498 _OrthancPluginService_RestApiDeleteAfterPlugins = 3012, | |
499 _OrthancPluginService_RestApiPutAfterPlugins = 3013, | |
500 _OrthancPluginService_ReconstructMainDicomTags = 3014, | |
501 _OrthancPluginService_RestApiGet2 = 3015, | |
502 _OrthancPluginService_CallRestApi = 3016, /* New in Orthanc 1.9.2 */ | |
503 | |
504 /* Access to DICOM instances */ | |
505 _OrthancPluginService_GetInstanceRemoteAet = 4000, | |
506 _OrthancPluginService_GetInstanceSize = 4001, | |
507 _OrthancPluginService_GetInstanceData = 4002, | |
508 _OrthancPluginService_GetInstanceJson = 4003, | |
509 _OrthancPluginService_GetInstanceSimplifiedJson = 4004, | |
510 _OrthancPluginService_HasInstanceMetadata = 4005, | |
511 _OrthancPluginService_GetInstanceMetadata = 4006, | |
512 _OrthancPluginService_GetInstanceOrigin = 4007, | |
513 _OrthancPluginService_GetInstanceTransferSyntaxUid = 4008, | |
514 _OrthancPluginService_HasInstancePixelData = 4009, | |
515 _OrthancPluginService_CreateDicomInstance = 4010, /* New in Orthanc 1.7.0 */ | |
516 _OrthancPluginService_FreeDicomInstance = 4011, /* New in Orthanc 1.7.0 */ | |
517 _OrthancPluginService_GetInstanceFramesCount = 4012, /* New in Orthanc 1.7.0 */ | |
518 _OrthancPluginService_GetInstanceRawFrame = 4013, /* New in Orthanc 1.7.0 */ | |
519 _OrthancPluginService_GetInstanceDecodedFrame = 4014, /* New in Orthanc 1.7.0 */ | |
520 _OrthancPluginService_TranscodeDicomInstance = 4015, /* New in Orthanc 1.7.0 */ | |
521 _OrthancPluginService_SerializeDicomInstance = 4016, /* New in Orthanc 1.7.0 */ | |
522 _OrthancPluginService_GetInstanceAdvancedJson = 4017, /* New in Orthanc 1.7.0 */ | |
523 _OrthancPluginService_GetInstanceDicomWebJson = 4018, /* New in Orthanc 1.7.0 */ | |
524 _OrthancPluginService_GetInstanceDicomWebXml = 4019, /* New in Orthanc 1.7.0 */ | |
525 | |
526 /* Services for plugins implementing a database back-end */ | |
527 _OrthancPluginService_RegisterDatabaseBackend = 5000, /* New in Orthanc 0.8.6 */ | |
528 _OrthancPluginService_DatabaseAnswer = 5001, | |
529 _OrthancPluginService_RegisterDatabaseBackendV2 = 5002, /* New in Orthanc 0.9.4 */ | |
530 _OrthancPluginService_StorageAreaCreate = 5003, | |
531 _OrthancPluginService_StorageAreaRead = 5004, | |
532 _OrthancPluginService_StorageAreaRemove = 5005, | |
533 _OrthancPluginService_RegisterDatabaseBackendV3 = 5006, /* New in Orthanc 1.9.2 */ | |
534 | |
535 /* Primitives for handling images */ | |
536 _OrthancPluginService_GetImagePixelFormat = 6000, | |
537 _OrthancPluginService_GetImageWidth = 6001, | |
538 _OrthancPluginService_GetImageHeight = 6002, | |
539 _OrthancPluginService_GetImagePitch = 6003, | |
540 _OrthancPluginService_GetImageBuffer = 6004, | |
541 _OrthancPluginService_UncompressImage = 6005, | |
542 _OrthancPluginService_FreeImage = 6006, | |
543 _OrthancPluginService_CompressImage = 6007, | |
544 _OrthancPluginService_ConvertPixelFormat = 6008, | |
545 _OrthancPluginService_GetFontsCount = 6009, | |
546 _OrthancPluginService_GetFontInfo = 6010, | |
547 _OrthancPluginService_DrawText = 6011, | |
548 _OrthancPluginService_CreateImage = 6012, | |
549 _OrthancPluginService_CreateImageAccessor = 6013, | |
550 _OrthancPluginService_DecodeDicomImage = 6014, | |
551 | |
552 /* Primitives for handling C-Find, C-Move and worklists */ | |
553 _OrthancPluginService_WorklistAddAnswer = 7000, | |
554 _OrthancPluginService_WorklistMarkIncomplete = 7001, | |
555 _OrthancPluginService_WorklistIsMatch = 7002, | |
556 _OrthancPluginService_WorklistGetDicomQuery = 7003, | |
557 _OrthancPluginService_FindAddAnswer = 7004, | |
558 _OrthancPluginService_FindMarkIncomplete = 7005, | |
559 _OrthancPluginService_GetFindQuerySize = 7006, | |
560 _OrthancPluginService_GetFindQueryTag = 7007, | |
561 _OrthancPluginService_GetFindQueryTagName = 7008, | |
562 _OrthancPluginService_GetFindQueryValue = 7009, | |
563 _OrthancPluginService_CreateFindMatcher = 7010, | |
564 _OrthancPluginService_FreeFindMatcher = 7011, | |
565 _OrthancPluginService_FindMatcherIsMatch = 7012, | |
566 | |
567 /* Primitives for accessing Orthanc Peers (new in 1.4.2) */ | |
568 _OrthancPluginService_GetPeers = 8000, | |
569 _OrthancPluginService_FreePeers = 8001, | |
570 _OrthancPluginService_GetPeersCount = 8003, | |
571 _OrthancPluginService_GetPeerName = 8004, | |
572 _OrthancPluginService_GetPeerUrl = 8005, | |
573 _OrthancPluginService_CallPeerApi = 8006, | |
574 _OrthancPluginService_GetPeerUserProperty = 8007, | |
575 | |
576 /* Primitives for handling jobs (new in 1.4.2) */ | |
577 _OrthancPluginService_CreateJob = 9000, | |
578 _OrthancPluginService_FreeJob = 9001, | |
579 _OrthancPluginService_SubmitJob = 9002, | |
580 _OrthancPluginService_RegisterJobsUnserializer = 9003, | |
581 | |
582 _OrthancPluginService_INTERNAL = 0x7fffffff | |
583 } _OrthancPluginService; | |
584 | |
585 | |
586 typedef enum | |
587 { | |
588 _OrthancPluginProperty_Description = 1, | |
589 _OrthancPluginProperty_RootUri = 2, | |
590 _OrthancPluginProperty_OrthancExplorer = 3, | |
591 | |
592 _OrthancPluginProperty_INTERNAL = 0x7fffffff | |
593 } _OrthancPluginProperty; | |
594 | |
595 | |
596 | |
597 /** | |
598 * The memory layout of the pixels of an image. | |
599 * @ingroup Images | |
600 **/ | |
601 typedef enum | |
602 { | |
603 /** | |
604 * @brief Graylevel 8bpp image. | |
605 * | |
606 * The image is graylevel. Each pixel is unsigned and stored in | |
607 * one byte. | |
608 **/ | |
609 OrthancPluginPixelFormat_Grayscale8 = 1, | |
610 | |
611 /** | |
612 * @brief Graylevel, unsigned 16bpp image. | |
613 * | |
614 * The image is graylevel. Each pixel is unsigned and stored in | |
615 * two bytes. | |
616 **/ | |
617 OrthancPluginPixelFormat_Grayscale16 = 2, | |
618 | |
619 /** | |
620 * @brief Graylevel, signed 16bpp image. | |
621 * | |
622 * The image is graylevel. Each pixel is signed and stored in two | |
623 * bytes. | |
624 **/ | |
625 OrthancPluginPixelFormat_SignedGrayscale16 = 3, | |
626 | |
627 /** | |
628 * @brief Color image in RGB24 format. | |
629 * | |
630 * This format describes a color image. The pixels are stored in 3 | |
631 * consecutive bytes. The memory layout is RGB. | |
632 **/ | |
633 OrthancPluginPixelFormat_RGB24 = 4, | |
634 | |
635 /** | |
636 * @brief Color image in RGBA32 format. | |
637 * | |
638 * This format describes a color image. The pixels are stored in 4 | |
639 * consecutive bytes. The memory layout is RGBA. | |
640 **/ | |
641 OrthancPluginPixelFormat_RGBA32 = 5, | |
642 | |
643 OrthancPluginPixelFormat_Unknown = 6, /*!< Unknown pixel format */ | |
644 | |
645 /** | |
646 * @brief Color image in RGB48 format. | |
647 * | |
648 * This format describes a color image. The pixels are stored in 6 | |
649 * consecutive bytes. The memory layout is RRGGBB. | |
650 **/ | |
651 OrthancPluginPixelFormat_RGB48 = 7, | |
652 | |
653 /** | |
654 * @brief Graylevel, unsigned 32bpp image. | |
655 * | |
656 * The image is graylevel. Each pixel is unsigned and stored in | |
657 * four bytes. | |
658 **/ | |
659 OrthancPluginPixelFormat_Grayscale32 = 8, | |
660 | |
661 /** | |
662 * @brief Graylevel, floating-point 32bpp image. | |
663 * | |
664 * The image is graylevel. Each pixel is floating-point and stored | |
665 * in four bytes. | |
666 **/ | |
667 OrthancPluginPixelFormat_Float32 = 9, | |
668 | |
669 /** | |
670 * @brief Color image in BGRA32 format. | |
671 * | |
672 * This format describes a color image. The pixels are stored in 4 | |
673 * consecutive bytes. The memory layout is BGRA. | |
674 **/ | |
675 OrthancPluginPixelFormat_BGRA32 = 10, | |
676 | |
677 /** | |
678 * @brief Graylevel, unsigned 64bpp image. | |
679 * | |
680 * The image is graylevel. Each pixel is unsigned and stored in | |
681 * eight bytes. | |
682 **/ | |
683 OrthancPluginPixelFormat_Grayscale64 = 11, | |
684 | |
685 _OrthancPluginPixelFormat_INTERNAL = 0x7fffffff | |
686 } OrthancPluginPixelFormat; | |
687 | |
688 | |
689 | |
690 /** | |
691 * The content types that are supported by Orthanc plugins. | |
692 **/ | |
693 typedef enum | |
694 { | |
695 OrthancPluginContentType_Unknown = 0, /*!< Unknown content type */ | |
696 OrthancPluginContentType_Dicom = 1, /*!< DICOM */ | |
697 OrthancPluginContentType_DicomAsJson = 2, /*!< JSON summary of a DICOM file */ | |
698 OrthancPluginContentType_DicomUntilPixelData = 3, /*!< DICOM Header till pixel data */ | |
699 | |
700 _OrthancPluginContentType_INTERNAL = 0x7fffffff | |
701 } OrthancPluginContentType; | |
702 | |
703 | |
704 | |
705 /** | |
706 * The supported types of DICOM resources. | |
707 **/ | |
708 typedef enum | |
709 { | |
710 OrthancPluginResourceType_Patient = 0, /*!< Patient */ | |
711 OrthancPluginResourceType_Study = 1, /*!< Study */ | |
712 OrthancPluginResourceType_Series = 2, /*!< Series */ | |
713 OrthancPluginResourceType_Instance = 3, /*!< Instance */ | |
714 OrthancPluginResourceType_None = 4, /*!< Unavailable resource type */ | |
715 | |
716 _OrthancPluginResourceType_INTERNAL = 0x7fffffff | |
717 } OrthancPluginResourceType; | |
718 | |
719 | |
720 | |
721 /** | |
722 * The supported types of changes that can be signaled to the change callback. | |
723 * @ingroup Callbacks | |
724 **/ | |
725 typedef enum | |
726 { | |
727 OrthancPluginChangeType_CompletedSeries = 0, /*!< Series is now complete */ | |
728 OrthancPluginChangeType_Deleted = 1, /*!< Deleted resource */ | |
729 OrthancPluginChangeType_NewChildInstance = 2, /*!< A new instance was added to this resource */ | |
730 OrthancPluginChangeType_NewInstance = 3, /*!< New instance received */ | |
731 OrthancPluginChangeType_NewPatient = 4, /*!< New patient created */ | |
732 OrthancPluginChangeType_NewSeries = 5, /*!< New series created */ | |
733 OrthancPluginChangeType_NewStudy = 6, /*!< New study created */ | |
734 OrthancPluginChangeType_StablePatient = 7, /*!< Timeout: No new instance in this patient */ | |
735 OrthancPluginChangeType_StableSeries = 8, /*!< Timeout: No new instance in this series */ | |
736 OrthancPluginChangeType_StableStudy = 9, /*!< Timeout: No new instance in this study */ | |
737 OrthancPluginChangeType_OrthancStarted = 10, /*!< Orthanc has started */ | |
738 OrthancPluginChangeType_OrthancStopped = 11, /*!< Orthanc is stopping */ | |
739 OrthancPluginChangeType_UpdatedAttachment = 12, /*!< Some user-defined attachment has changed for this resource */ | |
740 OrthancPluginChangeType_UpdatedMetadata = 13, /*!< Some user-defined metadata has changed for this resource */ | |
741 OrthancPluginChangeType_UpdatedPeers = 14, /*!< The list of Orthanc peers has changed */ | |
742 OrthancPluginChangeType_UpdatedModalities = 15, /*!< The list of DICOM modalities has changed */ | |
743 OrthancPluginChangeType_JobSubmitted = 16, /*!< New Job submitted */ | |
744 OrthancPluginChangeType_JobSuccess = 17, /*!< A Job has completed successfully */ | |
745 OrthancPluginChangeType_JobFailure = 18, /*!< A Job has failed */ | |
746 | |
747 _OrthancPluginChangeType_INTERNAL = 0x7fffffff | |
748 } OrthancPluginChangeType; | |
749 | |
750 | |
751 /** | |
752 * The compression algorithms that are supported by the Orthanc core. | |
753 * @ingroup Images | |
754 **/ | |
755 typedef enum | |
756 { | |
757 OrthancPluginCompressionType_Zlib = 0, /*!< Standard zlib compression */ | |
758 OrthancPluginCompressionType_ZlibWithSize = 1, /*!< zlib, prefixed with uncompressed size (uint64_t) */ | |
759 OrthancPluginCompressionType_Gzip = 2, /*!< Standard gzip compression */ | |
760 OrthancPluginCompressionType_GzipWithSize = 3, /*!< gzip, prefixed with uncompressed size (uint64_t) */ | |
761 | |
762 _OrthancPluginCompressionType_INTERNAL = 0x7fffffff | |
763 } OrthancPluginCompressionType; | |
764 | |
765 | |
766 /** | |
767 * The image formats that are supported by the Orthanc core. | |
768 * @ingroup Images | |
769 **/ | |
770 typedef enum | |
771 { | |
772 OrthancPluginImageFormat_Png = 0, /*!< Image compressed using PNG */ | |
773 OrthancPluginImageFormat_Jpeg = 1, /*!< Image compressed using JPEG */ | |
774 OrthancPluginImageFormat_Dicom = 2, /*!< Image compressed using DICOM */ | |
775 | |
776 _OrthancPluginImageFormat_INTERNAL = 0x7fffffff | |
777 } OrthancPluginImageFormat; | |
778 | |
779 | |
780 /** | |
781 * The value representations present in the DICOM standard (version 2013). | |
782 * @ingroup Toolbox | |
783 **/ | |
784 typedef enum | |
785 { | |
786 OrthancPluginValueRepresentation_AE = 1, /*!< Application Entity */ | |
787 OrthancPluginValueRepresentation_AS = 2, /*!< Age String */ | |
788 OrthancPluginValueRepresentation_AT = 3, /*!< Attribute Tag */ | |
789 OrthancPluginValueRepresentation_CS = 4, /*!< Code String */ | |
790 OrthancPluginValueRepresentation_DA = 5, /*!< Date */ | |
791 OrthancPluginValueRepresentation_DS = 6, /*!< Decimal String */ | |
792 OrthancPluginValueRepresentation_DT = 7, /*!< Date Time */ | |
793 OrthancPluginValueRepresentation_FD = 8, /*!< Floating Point Double */ | |
794 OrthancPluginValueRepresentation_FL = 9, /*!< Floating Point Single */ | |
795 OrthancPluginValueRepresentation_IS = 10, /*!< Integer String */ | |
796 OrthancPluginValueRepresentation_LO = 11, /*!< Long String */ | |
797 OrthancPluginValueRepresentation_LT = 12, /*!< Long Text */ | |
798 OrthancPluginValueRepresentation_OB = 13, /*!< Other Byte String */ | |
799 OrthancPluginValueRepresentation_OF = 14, /*!< Other Float String */ | |
800 OrthancPluginValueRepresentation_OW = 15, /*!< Other Word String */ | |
801 OrthancPluginValueRepresentation_PN = 16, /*!< Person Name */ | |
802 OrthancPluginValueRepresentation_SH = 17, /*!< Short String */ | |
803 OrthancPluginValueRepresentation_SL = 18, /*!< Signed Long */ | |
804 OrthancPluginValueRepresentation_SQ = 19, /*!< Sequence of Items */ | |
805 OrthancPluginValueRepresentation_SS = 20, /*!< Signed Short */ | |
806 OrthancPluginValueRepresentation_ST = 21, /*!< Short Text */ | |
807 OrthancPluginValueRepresentation_TM = 22, /*!< Time */ | |
808 OrthancPluginValueRepresentation_UI = 23, /*!< Unique Identifier (UID) */ | |
809 OrthancPluginValueRepresentation_UL = 24, /*!< Unsigned Long */ | |
810 OrthancPluginValueRepresentation_UN = 25, /*!< Unknown */ | |
811 OrthancPluginValueRepresentation_US = 26, /*!< Unsigned Short */ | |
812 OrthancPluginValueRepresentation_UT = 27, /*!< Unlimited Text */ | |
813 | |
814 _OrthancPluginValueRepresentation_INTERNAL = 0x7fffffff | |
815 } OrthancPluginValueRepresentation; | |
816 | |
817 | |
818 /** | |
819 * The possible output formats for a DICOM-to-JSON conversion. | |
820 * @ingroup Toolbox | |
821 * @see OrthancPluginDicomToJson() | |
822 **/ | |
823 typedef enum | |
824 { | |
825 OrthancPluginDicomToJsonFormat_Full = 1, /*!< Full output, with most details */ | |
826 OrthancPluginDicomToJsonFormat_Short = 2, /*!< Tags output as hexadecimal numbers */ | |
827 OrthancPluginDicomToJsonFormat_Human = 3, /*!< Human-readable JSON */ | |
828 | |
829 _OrthancPluginDicomToJsonFormat_INTERNAL = 0x7fffffff | |
830 } OrthancPluginDicomToJsonFormat; | |
831 | |
832 | |
833 /** | |
834 * Flags to customize a DICOM-to-JSON conversion. By default, binary | |
835 * tags are formatted using Data URI scheme. | |
836 * @ingroup Toolbox | |
837 **/ | |
838 typedef enum | |
839 { | |
840 OrthancPluginDicomToJsonFlags_None = 0, | |
841 OrthancPluginDicomToJsonFlags_IncludeBinary = (1 << 0), /*!< Include the binary tags */ | |
842 OrthancPluginDicomToJsonFlags_IncludePrivateTags = (1 << 1), /*!< Include the private tags */ | |
843 OrthancPluginDicomToJsonFlags_IncludeUnknownTags = (1 << 2), /*!< Include the tags unknown by the dictionary */ | |
844 OrthancPluginDicomToJsonFlags_IncludePixelData = (1 << 3), /*!< Include the pixel data */ | |
845 OrthancPluginDicomToJsonFlags_ConvertBinaryToAscii = (1 << 4), /*!< Output binary tags as-is, dropping non-ASCII */ | |
846 OrthancPluginDicomToJsonFlags_ConvertBinaryToNull = (1 << 5), /*!< Signal binary tags as null values */ | |
847 OrthancPluginDicomToJsonFlags_StopAfterPixelData = (1 << 6), /*!< Stop processing after pixel data (new in 1.9.1) */ | |
848 OrthancPluginDicomToJsonFlags_SkipGroupLengths = (1 << 7), /*!< Skip tags whose element is zero (new in 1.9.1) */ | |
849 | |
850 _OrthancPluginDicomToJsonFlags_INTERNAL = 0x7fffffff | |
851 } OrthancPluginDicomToJsonFlags; | |
852 | |
853 | |
854 /** | |
855 * Flags to the creation of a DICOM file. | |
856 * @ingroup Toolbox | |
857 * @see OrthancPluginCreateDicom() | |
858 **/ | |
859 typedef enum | |
860 { | |
861 OrthancPluginCreateDicomFlags_None = 0, | |
862 OrthancPluginCreateDicomFlags_DecodeDataUriScheme = (1 << 0), /*!< Decode fields encoded using data URI scheme */ | |
863 OrthancPluginCreateDicomFlags_GenerateIdentifiers = (1 << 1), /*!< Automatically generate DICOM identifiers */ | |
864 | |
865 _OrthancPluginCreateDicomFlags_INTERNAL = 0x7fffffff | |
866 } OrthancPluginCreateDicomFlags; | |
867 | |
868 | |
869 /** | |
870 * The constraints on the DICOM identifiers that must be supported | |
871 * by the database plugins. | |
872 * @deprecated Plugins using OrthancPluginConstraintType will be faster | |
873 **/ | |
874 typedef enum | |
875 { | |
876 OrthancPluginIdentifierConstraint_Equal = 1, /*!< Equal */ | |
877 OrthancPluginIdentifierConstraint_SmallerOrEqual = 2, /*!< Less or equal */ | |
878 OrthancPluginIdentifierConstraint_GreaterOrEqual = 3, /*!< More or equal */ | |
879 OrthancPluginIdentifierConstraint_Wildcard = 4, /*!< Case-sensitive wildcard matching (with * and ?) */ | |
880 | |
881 _OrthancPluginIdentifierConstraint_INTERNAL = 0x7fffffff | |
882 } OrthancPluginIdentifierConstraint; | |
883 | |
884 | |
885 /** | |
886 * The constraints on the tags (main DICOM tags and identifier tags) | |
887 * that must be supported by the database plugins. | |
888 **/ | |
889 typedef enum | |
890 { | |
891 OrthancPluginConstraintType_Equal = 1, /*!< Equal */ | |
892 OrthancPluginConstraintType_SmallerOrEqual = 2, /*!< Less or equal */ | |
893 OrthancPluginConstraintType_GreaterOrEqual = 3, /*!< More or equal */ | |
894 OrthancPluginConstraintType_Wildcard = 4, /*!< Wildcard matching */ | |
895 OrthancPluginConstraintType_List = 5, /*!< List of values */ | |
896 | |
897 _OrthancPluginConstraintType_INTERNAL = 0x7fffffff | |
898 } OrthancPluginConstraintType; | |
899 | |
900 | |
901 /** | |
902 * The origin of a DICOM instance that has been received by Orthanc. | |
903 **/ | |
904 typedef enum | |
905 { | |
906 OrthancPluginInstanceOrigin_Unknown = 1, /*!< Unknown origin */ | |
907 OrthancPluginInstanceOrigin_DicomProtocol = 2, /*!< Instance received through DICOM protocol */ | |
908 OrthancPluginInstanceOrigin_RestApi = 3, /*!< Instance received through REST API of Orthanc */ | |
909 OrthancPluginInstanceOrigin_Plugin = 4, /*!< Instance added to Orthanc by a plugin */ | |
910 OrthancPluginInstanceOrigin_Lua = 5, /*!< Instance added to Orthanc by a Lua script */ | |
911 OrthancPluginInstanceOrigin_WebDav = 6, /*!< Instance received through WebDAV (new in 1.8.0) */ | |
912 | |
913 _OrthancPluginInstanceOrigin_INTERNAL = 0x7fffffff | |
914 } OrthancPluginInstanceOrigin; | |
915 | |
916 | |
917 /** | |
918 * The possible status for one single step of a job. | |
919 **/ | |
920 typedef enum | |
921 { | |
922 OrthancPluginJobStepStatus_Success = 1, /*!< The job has successfully executed all its steps */ | |
923 OrthancPluginJobStepStatus_Failure = 2, /*!< The job has failed while executing this step */ | |
924 OrthancPluginJobStepStatus_Continue = 3 /*!< The job has still data to process after this step */ | |
925 } OrthancPluginJobStepStatus; | |
926 | |
927 | |
928 /** | |
929 * Explains why the job should stop and release the resources it has | |
930 * allocated. This is especially important to disambiguate between | |
931 * the "paused" condition and the "final" conditions (success, | |
932 * failure, or canceled). | |
933 **/ | |
934 typedef enum | |
935 { | |
936 OrthancPluginJobStopReason_Success = 1, /*!< The job has succeeded */ | |
937 OrthancPluginJobStopReason_Paused = 2, /*!< The job was paused, and will be resumed later */ | |
938 OrthancPluginJobStopReason_Failure = 3, /*!< The job has failed, and might be resubmitted later */ | |
939 OrthancPluginJobStopReason_Canceled = 4 /*!< The job was canceled, and might be resubmitted later */ | |
940 } OrthancPluginJobStopReason; | |
941 | |
942 | |
943 /** | |
944 * The available types of metrics. | |
945 **/ | |
946 typedef enum | |
947 { | |
948 OrthancPluginMetricsType_Default = 0, /*!< Default metrics */ | |
949 | |
950 /** | |
951 * This metrics represents a time duration. Orthanc will keep the | |
952 * maximum value of the metrics over a sliding window of ten | |
953 * seconds, which is useful if the metrics is sampled frequently. | |
954 **/ | |
955 OrthancPluginMetricsType_Timer = 1 | |
956 } OrthancPluginMetricsType; | |
957 | |
958 | |
959 /** | |
960 * The available modes to export a binary DICOM tag into a DICOMweb | |
961 * JSON or XML document. | |
962 **/ | |
963 typedef enum | |
964 { | |
965 OrthancPluginDicomWebBinaryMode_Ignore = 0, /*!< Don't include binary tags */ | |
966 OrthancPluginDicomWebBinaryMode_InlineBinary = 1, /*!< Inline encoding using Base64 */ | |
967 OrthancPluginDicomWebBinaryMode_BulkDataUri = 2 /*!< Use a bulk data URI field */ | |
968 } OrthancPluginDicomWebBinaryMode; | |
969 | |
970 | |
971 /** | |
972 * The available values for the Failure Reason (0008,1197) during | |
973 * storage commitment. | |
974 * http://dicom.nema.org/medical/dicom/2019e/output/chtml/part03/sect_C.14.html#sect_C.14.1.1 | |
975 **/ | |
976 typedef enum | |
977 { | |
978 OrthancPluginStorageCommitmentFailureReason_Success = 0, | |
979 /*!< Success: The DICOM instance is properly stored in the SCP */ | |
980 | |
981 OrthancPluginStorageCommitmentFailureReason_ProcessingFailure = 1, | |
982 /*!< 0110H: A general failure in processing the operation was encountered */ | |
983 | |
984 OrthancPluginStorageCommitmentFailureReason_NoSuchObjectInstance = 2, | |
985 /*!< 0112H: One or more of the elements in the Referenced SOP | |
986 Instance Sequence was not available */ | |
987 | |
988 OrthancPluginStorageCommitmentFailureReason_ResourceLimitation = 3, | |
989 /*!< 0213H: The SCP does not currently have enough resources to | |
990 store the requested SOP Instance(s) */ | |
991 | |
992 OrthancPluginStorageCommitmentFailureReason_ReferencedSOPClassNotSupported = 4, | |
993 /*!< 0122H: Storage Commitment has been requested for a SOP | |
994 Instance with a SOP Class that is not supported by the SCP */ | |
995 | |
996 OrthancPluginStorageCommitmentFailureReason_ClassInstanceConflict = 5, | |
997 /*!< 0119H: The SOP Class of an element in the Referenced SOP | |
998 Instance Sequence did not correspond to the SOP class registered | |
999 for this SOP Instance at the SCP */ | |
1000 | |
1001 OrthancPluginStorageCommitmentFailureReason_DuplicateTransactionUID = 6 | |
1002 /*!< 0131H: The Transaction UID of the Storage Commitment Request | |
1003 is already in use */ | |
1004 } OrthancPluginStorageCommitmentFailureReason; | |
1005 | |
1006 | |
1007 /** | |
1008 * The action to be taken after ReceivedInstanceCallback is triggered | |
1009 **/ | |
1010 typedef enum | |
1011 { | |
1012 OrthancPluginReceivedInstanceAction_KeepAsIs = 1, /*!< Keep the instance as is */ | |
1013 OrthancPluginReceivedInstanceAction_Modify = 2, /*!< Modify the instance */ | |
1014 OrthancPluginReceivedInstanceAction_Discard = 3, /*!< Discard the instance */ | |
1015 | |
1016 _OrthancPluginReceivedInstanceAction_INTERNAL = 0x7fffffff | |
1017 } OrthancPluginReceivedInstanceAction; | |
1018 | |
1019 | |
1020 /** | |
1021 * @brief A 32-bit memory buffer allocated by the core system of Orthanc. | |
1022 * | |
1023 * A memory buffer allocated by the core system of Orthanc. When the | |
1024 * content of the buffer is not useful anymore, it must be free by a | |
1025 * call to ::OrthancPluginFreeMemoryBuffer(). | |
1026 **/ | |
1027 typedef struct | |
1028 { | |
1029 /** | |
1030 * @brief The content of the buffer. | |
1031 **/ | |
1032 void* data; | |
1033 | |
1034 /** | |
1035 * @brief The number of bytes in the buffer. | |
1036 **/ | |
1037 uint32_t size; | |
1038 } OrthancPluginMemoryBuffer; | |
1039 | |
1040 | |
1041 | |
1042 /** | |
1043 * @brief A 64-bit memory buffer allocated by the core system of Orthanc. | |
1044 * | |
1045 * A memory buffer allocated by the core system of Orthanc. When the | |
1046 * content of the buffer is not useful anymore, it must be free by a | |
1047 * call to ::OrthancPluginFreeMemoryBuffer64(). | |
1048 **/ | |
1049 typedef struct | |
1050 { | |
1051 /** | |
1052 * @brief The content of the buffer. | |
1053 **/ | |
1054 void* data; | |
1055 | |
1056 /** | |
1057 * @brief The number of bytes in the buffer. | |
1058 **/ | |
1059 uint64_t size; | |
1060 } OrthancPluginMemoryBuffer64; | |
1061 | |
1062 | |
1063 | |
1064 | |
1065 /** | |
1066 * @brief Opaque structure that represents the HTTP connection to the client application. | |
1067 * @ingroup Callback | |
1068 **/ | |
1069 typedef struct _OrthancPluginRestOutput_t OrthancPluginRestOutput; | |
1070 | |
1071 | |
1072 | |
1073 /** | |
1074 * @brief Opaque structure that represents a DICOM instance that is managed by the Orthanc core. | |
1075 * @ingroup DicomInstance | |
1076 **/ | |
1077 typedef struct _OrthancPluginDicomInstance_t OrthancPluginDicomInstance; | |
1078 | |
1079 | |
1080 | |
1081 /** | |
1082 * @brief Opaque structure that represents an image that is uncompressed in memory. | |
1083 * @ingroup Images | |
1084 **/ | |
1085 typedef struct _OrthancPluginImage_t OrthancPluginImage; | |
1086 | |
1087 | |
1088 | |
1089 /** | |
1090 * @brief Opaque structure that represents the storage area that is actually used by Orthanc. | |
1091 * @ingroup Images | |
1092 **/ | |
1093 typedef struct _OrthancPluginStorageArea_t OrthancPluginStorageArea; | |
1094 | |
1095 | |
1096 | |
1097 /** | |
1098 * @brief Opaque structure to an object that represents a C-Find query for worklists. | |
1099 * @ingroup DicomCallbacks | |
1100 **/ | |
1101 typedef struct _OrthancPluginWorklistQuery_t OrthancPluginWorklistQuery; | |
1102 | |
1103 | |
1104 | |
1105 /** | |
1106 * @brief Opaque structure to an object that represents the answers to a C-Find query for worklists. | |
1107 * @ingroup DicomCallbacks | |
1108 **/ | |
1109 typedef struct _OrthancPluginWorklistAnswers_t OrthancPluginWorklistAnswers; | |
1110 | |
1111 | |
1112 | |
1113 /** | |
1114 * @brief Opaque structure to an object that represents a C-Find query. | |
1115 * @ingroup DicomCallbacks | |
1116 **/ | |
1117 typedef struct _OrthancPluginFindQuery_t OrthancPluginFindQuery; | |
1118 | |
1119 | |
1120 | |
1121 /** | |
1122 * @brief Opaque structure to an object that represents the answers to a C-Find query for worklists. | |
1123 * @ingroup DicomCallbacks | |
1124 **/ | |
1125 typedef struct _OrthancPluginFindAnswers_t OrthancPluginFindAnswers; | |
1126 | |
1127 | |
1128 | |
1129 /** | |
1130 * @brief Opaque structure to an object that can be used to check whether a DICOM instance matches a C-Find query. | |
1131 * @ingroup Toolbox | |
1132 **/ | |
1133 typedef struct _OrthancPluginFindMatcher_t OrthancPluginFindMatcher; | |
1134 | |
1135 | |
1136 | |
1137 /** | |
1138 * @brief Opaque structure to the set of remote Orthanc Peers that are known to the local Orthanc server. | |
1139 * @ingroup Toolbox | |
1140 **/ | |
1141 typedef struct _OrthancPluginPeers_t OrthancPluginPeers; | |
1142 | |
1143 | |
1144 | |
1145 /** | |
1146 * @brief Opaque structure to a job to be executed by Orthanc. | |
1147 * @ingroup Toolbox | |
1148 **/ | |
1149 typedef struct _OrthancPluginJob_t OrthancPluginJob; | |
1150 | |
1151 | |
1152 | |
1153 /** | |
1154 * @brief Opaque structure that represents a node in a JSON or XML | |
1155 * document used in DICOMweb. | |
1156 * @ingroup Toolbox | |
1157 **/ | |
1158 typedef struct _OrthancPluginDicomWebNode_t OrthancPluginDicomWebNode; | |
1159 | |
1160 | |
1161 | |
1162 /** | |
1163 * @brief Signature of a callback function that answers to a REST request. | |
1164 * @ingroup Callbacks | |
1165 **/ | |
1166 typedef OrthancPluginErrorCode (*OrthancPluginRestCallback) ( | |
1167 OrthancPluginRestOutput* output, | |
1168 const char* url, | |
1169 const OrthancPluginHttpRequest* request); | |
1170 | |
1171 | |
1172 | |
1173 /** | |
1174 * @brief Signature of a callback function that is triggered when Orthanc stores a new DICOM instance. | |
1175 * @ingroup Callbacks | |
1176 **/ | |
1177 typedef OrthancPluginErrorCode (*OrthancPluginOnStoredInstanceCallback) ( | |
1178 const OrthancPluginDicomInstance* instance, | |
1179 const char* instanceId); | |
1180 | |
1181 | |
1182 | |
1183 /** | |
1184 * @brief Signature of a callback function that is triggered when a change happens to some DICOM resource. | |
1185 * @ingroup Callbacks | |
1186 **/ | |
1187 typedef OrthancPluginErrorCode (*OrthancPluginOnChangeCallback) ( | |
1188 OrthancPluginChangeType changeType, | |
1189 OrthancPluginResourceType resourceType, | |
1190 const char* resourceId); | |
1191 | |
1192 | |
1193 | |
1194 /** | |
1195 * @brief Signature of a callback function to decode a DICOM instance as an image. | |
1196 * @ingroup Callbacks | |
1197 **/ | |
1198 typedef OrthancPluginErrorCode (*OrthancPluginDecodeImageCallback) ( | |
1199 OrthancPluginImage** target, | |
1200 const void* dicom, | |
1201 const uint32_t size, | |
1202 uint32_t frameIndex); | |
1203 | |
1204 | |
1205 | |
1206 /** | |
1207 * @brief Signature of a function to free dynamic memory. | |
1208 * @ingroup Callbacks | |
1209 **/ | |
1210 typedef void (*OrthancPluginFree) (void* buffer); | |
1211 | |
1212 | |
1213 | |
1214 /** | |
1215 * @brief Signature of a function to set the content of a node | |
1216 * encoding a binary DICOM tag, into a JSON or XML document | |
1217 * generated for DICOMweb. | |
1218 * @ingroup Callbacks | |
1219 **/ | |
1220 typedef void (*OrthancPluginDicomWebSetBinaryNode) ( | |
1221 OrthancPluginDicomWebNode* node, | |
1222 OrthancPluginDicomWebBinaryMode mode, | |
1223 const char* bulkDataUri); | |
1224 | |
1225 | |
1226 | |
1227 /** | |
1228 * @brief Callback for writing to the storage area. | |
1229 * | |
1230 * Signature of a callback function that is triggered when Orthanc writes a file to the storage area. | |
1231 * | |
1232 * @param uuid The UUID of the file. | |
1233 * @param content The content of the file. | |
1234 * @param size The size of the file. | |
1235 * @param type The content type corresponding to this file. | |
1236 * @return 0 if success, other value if error. | |
1237 * @ingroup Callbacks | |
1238 **/ | |
1239 typedef OrthancPluginErrorCode (*OrthancPluginStorageCreate) ( | |
1240 const char* uuid, | |
1241 const void* content, | |
1242 int64_t size, | |
1243 OrthancPluginContentType type); | |
1244 | |
1245 | |
1246 | |
1247 /** | |
1248 * @brief Callback for reading from the storage area. | |
1249 * | |
1250 * Signature of a callback function that is triggered when Orthanc reads a file from the storage area. | |
1251 * | |
1252 * @param content The content of the file (output). | |
1253 * @param size The size of the file (output). | |
1254 * @param uuid The UUID of the file of interest. | |
1255 * @param type The content type corresponding to this file. | |
1256 * @return 0 if success, other value if error. | |
1257 * @ingroup Callbacks | |
1258 * @deprecated New plugins should use OrthancPluginStorageRead2 | |
1259 * | |
1260 * @warning The "content" buffer *must* have been allocated using | |
1261 * the "malloc()" function of your C standard library (i.e. nor | |
1262 * "new[]", neither a pointer to a buffer). The "free()" function of | |
1263 * your C standard library will automatically be invoked on the | |
1264 * "content" pointer. | |
1265 **/ | |
1266 typedef OrthancPluginErrorCode (*OrthancPluginStorageRead) ( | |
1267 void** content, | |
1268 int64_t* size, | |
1269 const char* uuid, | |
1270 OrthancPluginContentType type); | |
1271 | |
1272 | |
1273 | |
1274 /** | |
1275 * @brief Callback for reading a whole file from the storage area. | |
1276 * | |
1277 * Signature of a callback function that is triggered when Orthanc | |
1278 * reads a whole file from the storage area. | |
1279 * | |
1280 * @param target Memory buffer where to store the content of the file. It must be allocated by the | |
1281 * plugin using OrthancPluginCreateMemoryBuffer64(). The core of Orthanc will free it. | |
1282 * @param uuid The UUID of the file of interest. | |
1283 * @param type The content type corresponding to this file. | |
1284 * @ingroup Callbacks | |
1285 **/ | |
1286 typedef OrthancPluginErrorCode (*OrthancPluginStorageReadWhole) ( | |
1287 OrthancPluginMemoryBuffer64* target, | |
1288 const char* uuid, | |
1289 OrthancPluginContentType type); | |
1290 | |
1291 | |
1292 | |
1293 /** | |
1294 * @brief Callback for reading a range of a file from the storage area. | |
1295 * | |
1296 * Signature of a callback function that is triggered when Orthanc | |
1297 * reads a portion of a file from the storage area. Orthanc | |
1298 * indicates the start position and the length of the range. | |
1299 * | |
1300 * @param target Memory buffer where to store the content of the range. | |
1301 * The memory buffer is allocated and freed by Orthanc. The length of the range | |
1302 * of interest corresponds to the size of this buffer. | |
1303 * @param uuid The UUID of the file of interest. | |
1304 * @param type The content type corresponding to this file. | |
1305 * @param rangeStart Start position of the requested range in the file. | |
1306 * @return 0 if success, other value if error. | |
1307 * @ingroup Callbacks | |
1308 **/ | |
1309 typedef OrthancPluginErrorCode (*OrthancPluginStorageReadRange) ( | |
1310 OrthancPluginMemoryBuffer64* target, | |
1311 const char* uuid, | |
1312 OrthancPluginContentType type, | |
1313 uint64_t rangeStart); | |
1314 | |
1315 | |
1316 | |
1317 /** | |
1318 * @brief Callback for removing a file from the storage area. | |
1319 * | |
1320 * Signature of a callback function that is triggered when Orthanc deletes a file from the storage area. | |
1321 * | |
1322 * @param uuid The UUID of the file to be removed. | |
1323 * @param type The content type corresponding to this file. | |
1324 * @return 0 if success, other value if error. | |
1325 * @ingroup Callbacks | |
1326 **/ | |
1327 typedef OrthancPluginErrorCode (*OrthancPluginStorageRemove) ( | |
1328 const char* uuid, | |
1329 OrthancPluginContentType type); | |
1330 | |
1331 | |
1332 | |
1333 /** | |
1334 * @brief Callback to handle the C-Find SCP requests for worklists. | |
1335 * | |
1336 * Signature of a callback function that is triggered when Orthanc | |
1337 * receives a C-Find SCP request against modality worklists. | |
1338 * | |
1339 * @param answers The target structure where answers must be stored. | |
1340 * @param query The worklist query. | |
1341 * @param issuerAet The Application Entity Title (AET) of the modality from which the request originates. | |
1342 * @param calledAet The Application Entity Title (AET) of the modality that is called by the request. | |
1343 * @return 0 if success, other value if error. | |
1344 * @ingroup DicomCallbacks | |
1345 **/ | |
1346 typedef OrthancPluginErrorCode (*OrthancPluginWorklistCallback) ( | |
1347 OrthancPluginWorklistAnswers* answers, | |
1348 const OrthancPluginWorklistQuery* query, | |
1349 const char* issuerAet, | |
1350 const char* calledAet); | |
1351 | |
1352 | |
1353 | |
1354 /** | |
1355 * @brief Callback to filter incoming HTTP requests received by Orthanc. | |
1356 * | |
1357 * Signature of a callback function that is triggered whenever | |
1358 * Orthanc receives an HTTP/REST request, and that answers whether | |
1359 * this request should be allowed. If the callback returns "0" | |
1360 * ("false"), the server answers with HTTP status code 403 | |
1361 * (Forbidden). | |
1362 * | |
1363 * Pay attention to the fact that this function may be invoked | |
1364 * concurrently by different threads of the Web server of | |
1365 * Orthanc. You must implement proper locking if applicable. | |
1366 * | |
1367 * @param method The HTTP method used by the request. | |
1368 * @param uri The URI of interest. | |
1369 * @param ip The IP address of the HTTP client. | |
1370 * @param headersCount The number of HTTP headers. | |
1371 * @param headersKeys The keys of the HTTP headers (always converted to low-case). | |
1372 * @param headersValues The values of the HTTP headers. | |
1373 * @return 0 if forbidden access, 1 if allowed access, -1 if error. | |
1374 * @ingroup Callback | |
1375 * @deprecated Please instead use OrthancPluginIncomingHttpRequestFilter2() | |
1376 **/ | |
1377 typedef int32_t (*OrthancPluginIncomingHttpRequestFilter) ( | |
1378 OrthancPluginHttpMethod method, | |
1379 const char* uri, | |
1380 const char* ip, | |
1381 uint32_t headersCount, | |
1382 const char* const* headersKeys, | |
1383 const char* const* headersValues); | |
1384 | |
1385 | |
1386 | |
1387 /** | |
1388 * @brief Callback to filter incoming HTTP requests received by Orthanc. | |
1389 * | |
1390 * Signature of a callback function that is triggered whenever | |
1391 * Orthanc receives an HTTP/REST request, and that answers whether | |
1392 * this request should be allowed. If the callback returns "0" | |
1393 * ("false"), the server answers with HTTP status code 403 | |
1394 * (Forbidden). | |
1395 * | |
1396 * Pay attention to the fact that this function may be invoked | |
1397 * concurrently by different threads of the Web server of | |
1398 * Orthanc. You must implement proper locking if applicable. | |
1399 * | |
1400 * @param method The HTTP method used by the request. | |
1401 * @param uri The URI of interest. | |
1402 * @param ip The IP address of the HTTP client. | |
1403 * @param headersCount The number of HTTP headers. | |
1404 * @param headersKeys The keys of the HTTP headers (always converted to low-case). | |
1405 * @param headersValues The values of the HTTP headers. | |
1406 * @param getArgumentsCount The number of GET arguments (only for the GET HTTP method). | |
1407 * @param getArgumentsKeys The keys of the GET arguments (only for the GET HTTP method). | |
1408 * @param getArgumentsValues The values of the GET arguments (only for the GET HTTP method). | |
1409 * @return 0 if forbidden access, 1 if allowed access, -1 if error. | |
1410 * @ingroup Callback | |
1411 **/ | |
1412 typedef int32_t (*OrthancPluginIncomingHttpRequestFilter2) ( | |
1413 OrthancPluginHttpMethod method, | |
1414 const char* uri, | |
1415 const char* ip, | |
1416 uint32_t headersCount, | |
1417 const char* const* headersKeys, | |
1418 const char* const* headersValues, | |
1419 uint32_t getArgumentsCount, | |
1420 const char* const* getArgumentsKeys, | |
1421 const char* const* getArgumentsValues); | |
1422 | |
1423 | |
1424 | |
1425 /** | |
1426 * @brief Callback to handle incoming C-Find SCP requests. | |
1427 * | |
1428 * Signature of a callback function that is triggered whenever | |
1429 * Orthanc receives a C-Find SCP request not concerning modality | |
1430 * worklists. | |
1431 * | |
1432 * @param answers The target structure where answers must be stored. | |
1433 * @param query The worklist query. | |
1434 * @param issuerAet The Application Entity Title (AET) of the modality from which the request originates. | |
1435 * @param calledAet The Application Entity Title (AET) of the modality that is called by the request. | |
1436 * @return 0 if success, other value if error. | |
1437 * @ingroup DicomCallbacks | |
1438 **/ | |
1439 typedef OrthancPluginErrorCode (*OrthancPluginFindCallback) ( | |
1440 OrthancPluginFindAnswers* answers, | |
1441 const OrthancPluginFindQuery* query, | |
1442 const char* issuerAet, | |
1443 const char* calledAet); | |
1444 | |
1445 | |
1446 | |
1447 /** | |
1448 * @brief Callback to handle incoming C-Move SCP requests. | |
1449 * | |
1450 * Signature of a callback function that is triggered whenever | |
1451 * Orthanc receives a C-Move SCP request. The callback receives the | |
1452 * type of the resource of interest (study, series, instance...) | |
1453 * together with the DICOM tags containing its identifiers. In turn, | |
1454 * the plugin must create a driver object that will be responsible | |
1455 * for driving the successive move suboperations. | |
1456 * | |
1457 * @param resourceType The type of the resource of interest. Note | |
1458 * that this might be set to ResourceType_None if the | |
1459 * QueryRetrieveLevel (0008,0052) tag was not provided by the | |
1460 * issuer (i.e. the originator modality). | |
1461 * @param patientId Content of the PatientID (0x0010, 0x0020) tag of the resource of interest. Might be NULL. | |
1462 * @param accessionNumber Content of the AccessionNumber (0x0008, 0x0050) tag. Might be NULL. | |
1463 * @param studyInstanceUid Content of the StudyInstanceUID (0x0020, 0x000d) tag. Might be NULL. | |
1464 * @param seriesInstanceUid Content of the SeriesInstanceUID (0x0020, 0x000e) tag. Might be NULL. | |
1465 * @param sopInstanceUid Content of the SOPInstanceUID (0x0008, 0x0018) tag. Might be NULL. | |
1466 * @param originatorAet The Application Entity Title (AET) of the | |
1467 * modality from which the request originates. | |
1468 * @param sourceAet The Application Entity Title (AET) of the | |
1469 * modality that should send its DICOM files to another modality. | |
1470 * @param targetAet The Application Entity Title (AET) of the | |
1471 * modality that should receive the DICOM files. | |
1472 * @param originatorId The Message ID issued by the originator modality, | |
1473 * as found in tag (0000,0110) of the DICOM query emitted by the issuer. | |
1474 * | |
1475 * @return The NULL value if the plugin cannot deal with this query, | |
1476 * or a pointer to the driver object that is responsible for | |
1477 * handling the successive move suboperations. | |
1478 * | |
1479 * @note If targetAet equals sourceAet, this is actually a query/retrieve operation. | |
1480 * @ingroup DicomCallbacks | |
1481 **/ | |
1482 typedef void* (*OrthancPluginMoveCallback) ( | |
1483 OrthancPluginResourceType resourceType, | |
1484 const char* patientId, | |
1485 const char* accessionNumber, | |
1486 const char* studyInstanceUid, | |
1487 const char* seriesInstanceUid, | |
1488 const char* sopInstanceUid, | |
1489 const char* originatorAet, | |
1490 const char* sourceAet, | |
1491 const char* targetAet, | |
1492 uint16_t originatorId); | |
1493 | |
1494 | |
1495 /** | |
1496 * @brief Callback to read the size of a C-Move driver. | |
1497 * | |
1498 * Signature of a callback function that returns the number of | |
1499 * C-Move suboperations that are to be achieved by the given C-Move | |
1500 * driver. This driver is the return value of a previous call to the | |
1501 * OrthancPluginMoveCallback() callback. | |
1502 * | |
1503 * @param moveDriver The C-Move driver of interest. | |
1504 * @return The number of suboperations. | |
1505 * @ingroup DicomCallbacks | |
1506 **/ | |
1507 typedef uint32_t (*OrthancPluginGetMoveSize) (void* moveDriver); | |
1508 | |
1509 | |
1510 /** | |
1511 * @brief Callback to apply one C-Move suboperation. | |
1512 * | |
1513 * Signature of a callback function that applies the next C-Move | |
1514 * suboperation that os to be achieved by the given C-Move | |
1515 * driver. This driver is the return value of a previous call to the | |
1516 * OrthancPluginMoveCallback() callback. | |
1517 * | |
1518 * @param moveDriver The C-Move driver of interest. | |
1519 * @return 0 if success, or the error code if failure. | |
1520 * @ingroup DicomCallbacks | |
1521 **/ | |
1522 typedef OrthancPluginErrorCode (*OrthancPluginApplyMove) (void* moveDriver); | |
1523 | |
1524 | |
1525 /** | |
1526 * @brief Callback to free one C-Move driver. | |
1527 * | |
1528 * Signature of a callback function that releases the resources | |
1529 * allocated by the given C-Move driver. This driver is the return | |
1530 * value of a previous call to the OrthancPluginMoveCallback() | |
1531 * callback. | |
1532 * | |
1533 * @param moveDriver The C-Move driver of interest. | |
1534 * @ingroup DicomCallbacks | |
1535 **/ | |
1536 typedef void (*OrthancPluginFreeMove) (void* moveDriver); | |
1537 | |
1538 | |
1539 /** | |
1540 * @brief Callback to finalize one custom job. | |
1541 * | |
1542 * Signature of a callback function that releases all the resources | |
1543 * allocated by the given job. This job is the argument provided to | |
1544 * OrthancPluginCreateJob(). | |
1545 * | |
1546 * @param job The job of interest. | |
1547 * @ingroup Toolbox | |
1548 **/ | |
1549 typedef void (*OrthancPluginJobFinalize) (void* job); | |
1550 | |
1551 | |
1552 /** | |
1553 * @brief Callback to check the progress of one custom job. | |
1554 * | |
1555 * Signature of a callback function that returns the progress of the | |
1556 * job. | |
1557 * | |
1558 * @param job The job of interest. | |
1559 * @return The progress, as a floating-point number ranging from 0 to 1. | |
1560 * @ingroup Toolbox | |
1561 **/ | |
1562 typedef float (*OrthancPluginJobGetProgress) (void* job); | |
1563 | |
1564 | |
1565 /** | |
1566 * @brief Callback to retrieve the content of one custom job. | |
1567 * | |
1568 * Signature of a callback function that returns human-readable | |
1569 * statistics about the job. This statistics must be formatted as a | |
1570 * JSON object. This information is notably displayed in the "Jobs" | |
1571 * tab of "Orthanc Explorer". | |
1572 * | |
1573 * @param job The job of interest. | |
1574 * @return The statistics, as a JSON object encoded as a string. | |
1575 * @ingroup Toolbox | |
1576 **/ | |
1577 typedef const char* (*OrthancPluginJobGetContent) (void* job); | |
1578 | |
1579 | |
1580 /** | |
1581 * @brief Callback to serialize one custom job. | |
1582 * | |
1583 * Signature of a callback function that returns a serialized | |
1584 * version of the job, formatted as a JSON object. This | |
1585 * serialization is stored in the Orthanc database, and is used to | |
1586 * reload the job on the restart of Orthanc. The "unserialization" | |
1587 * callback (with OrthancPluginJobsUnserializer signature) will | |
1588 * receive this serialized object. | |
1589 * | |
1590 * @param job The job of interest. | |
1591 * @return The serialized job, as a JSON object encoded as a string. | |
1592 * @see OrthancPluginRegisterJobsUnserializer() | |
1593 * @ingroup Toolbox | |
1594 **/ | |
1595 typedef const char* (*OrthancPluginJobGetSerialized) (void* job); | |
1596 | |
1597 | |
1598 /** | |
1599 * @brief Callback to execute one step of a custom job. | |
1600 * | |
1601 * Signature of a callback function that executes one step in the | |
1602 * job. The jobs engine of Orthanc will make successive calls to | |
1603 * this method, as long as it returns | |
1604 * OrthancPluginJobStepStatus_Continue. | |
1605 * | |
1606 * @param job The job of interest. | |
1607 * @return The status of execution. | |
1608 * @ingroup Toolbox | |
1609 **/ | |
1610 typedef OrthancPluginJobStepStatus (*OrthancPluginJobStep) (void* job); | |
1611 | |
1612 | |
1613 /** | |
1614 * @brief Callback executed once one custom job leaves the "running" state. | |
1615 * | |
1616 * Signature of a callback function that is invoked once a job | |
1617 * leaves the "running" state. This can happen if the previous call | |
1618 * to OrthancPluginJobStep has failed/succeeded, if the host Orthanc | |
1619 * server is being stopped, or if the user manually tags the job as | |
1620 * paused/canceled. This callback allows the plugin to free | |
1621 * resources allocated for running this custom job (e.g. to stop | |
1622 * threads, or to remove temporary files). | |
1623 * | |
1624 * Note that handling pauses might involves a specific treatment | |
1625 * (such a stopping threads, but keeping temporary files on the | |
1626 * disk). This "paused" situation can be checked by looking at the | |
1627 * "reason" parameter. | |
1628 * | |
1629 * @param job The job of interest. | |
1630 * @param reason The reason for leaving the "running" state. | |
1631 * @return 0 if success, or the error code if failure. | |
1632 * @ingroup Toolbox | |
1633 **/ | |
1634 typedef OrthancPluginErrorCode (*OrthancPluginJobStop) (void* job, | |
1635 OrthancPluginJobStopReason reason); | |
1636 | |
1637 | |
1638 /** | |
1639 * @brief Callback executed once one stopped custom job is started again. | |
1640 * | |
1641 * Signature of a callback function that is invoked once a job | |
1642 * leaves the "failure/canceled" state, to be started again. This | |
1643 * function will typically reset the progress to zero. Note that | |
1644 * before being actually executed, the job would first be tagged as | |
1645 * "pending" in the Orthanc jobs engine. | |
1646 * | |
1647 * @param job The job of interest. | |
1648 * @return 0 if success, or the error code if failure. | |
1649 * @ingroup Toolbox | |
1650 **/ | |
1651 typedef OrthancPluginErrorCode (*OrthancPluginJobReset) (void* job); | |
1652 | |
1653 | |
1654 /** | |
1655 * @brief Callback executed to unserialize a custom job. | |
1656 * | |
1657 * Signature of a callback function that unserializes a job that was | |
1658 * saved in the Orthanc database. | |
1659 * | |
1660 * @param jobType The type of the job, as provided to OrthancPluginCreateJob(). | |
1661 * @param serialized The serialization of the job, as provided by OrthancPluginJobGetSerialized. | |
1662 * @return The unserialized job (as created by OrthancPluginCreateJob()), or NULL | |
1663 * if this unserializer cannot handle this job type. | |
1664 * @see OrthancPluginRegisterJobsUnserializer() | |
1665 * @ingroup Callbacks | |
1666 **/ | |
1667 typedef OrthancPluginJob* (*OrthancPluginJobsUnserializer) (const char* jobType, | |
1668 const char* serialized); | |
1669 | |
1670 | |
1671 | |
1672 /** | |
1673 * @brief Callback executed to update the metrics of the plugin. | |
1674 * | |
1675 * Signature of a callback function that is called by Orthanc | |
1676 * whenever a monitoring tool (such as Prometheus) asks the current | |
1677 * values of the metrics. This callback gives the plugin a chance to | |
1678 * update its metrics, by calling OrthancPluginSetMetricsValue(). | |
1679 * This is typically useful for metrics that are expensive to | |
1680 * acquire. | |
1681 * | |
1682 * @see OrthancPluginRegisterRefreshMetrics() | |
1683 * @ingroup Callbacks | |
1684 **/ | |
1685 typedef void (*OrthancPluginRefreshMetricsCallback) (); | |
1686 | |
1687 | |
1688 | |
1689 /** | |
1690 * @brief Callback executed to encode a binary tag in DICOMweb. | |
1691 * | |
1692 * Signature of a callback function that is called by Orthanc | |
1693 * whenever a DICOM tag that contains a binary value must be written | |
1694 * to a JSON or XML node, while a DICOMweb document is being | |
1695 * generated. The value representation (VR) of the DICOM tag can be | |
1696 * OB, OD, OF, OL, OW, or UN. | |
1697 * | |
1698 * @see OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml() | |
1699 * @param node The node being generated, as provided by Orthanc. | |
1700 * @param setter The setter to be used to encode the content of the node. If | |
1701 * the setter is not called, the binary tag is not written to the output document. | |
1702 * @param levelDepth The depth of the node in the DICOM hierarchy of sequences. | |
1703 * This parameter gives the number of elements in the "levelTagGroup", | |
1704 * "levelTagElement", and "levelIndex" arrays. | |
1705 * @param levelTagGroup The group of the parent DICOM tags in the hierarchy. | |
1706 * @param levelTagElement The element of the parent DICOM tags in the hierarchy. | |
1707 * @param levelIndex The index of the node in the parent sequences of the hierarchy. | |
1708 * @param tagGroup The group of the DICOM tag of interest. | |
1709 * @param tagElement The element of the DICOM tag of interest. | |
1710 * @param vr The value representation of the binary DICOM node. | |
1711 * @ingroup Callbacks | |
1712 **/ | |
1713 typedef void (*OrthancPluginDicomWebBinaryCallback) ( | |
1714 OrthancPluginDicomWebNode* node, | |
1715 OrthancPluginDicomWebSetBinaryNode setter, | |
1716 uint32_t levelDepth, | |
1717 const uint16_t* levelTagGroup, | |
1718 const uint16_t* levelTagElement, | |
1719 const uint32_t* levelIndex, | |
1720 uint16_t tagGroup, | |
1721 uint16_t tagElement, | |
1722 OrthancPluginValueRepresentation vr); | |
1723 | |
1724 | |
1725 | |
1726 /** | |
1727 * @brief Callback executed to encode a binary tag in DICOMweb. | |
1728 * | |
1729 * Signature of a callback function that is called by Orthanc | |
1730 * whenever a DICOM tag that contains a binary value must be written | |
1731 * to a JSON or XML node, while a DICOMweb document is being | |
1732 * generated. The value representation (VR) of the DICOM tag can be | |
1733 * OB, OD, OF, OL, OW, or UN. | |
1734 * | |
1735 * @see OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml() | |
1736 * @param node The node being generated, as provided by Orthanc. | |
1737 * @param setter The setter to be used to encode the content of the node. If | |
1738 * the setter is not called, the binary tag is not written to the output document. | |
1739 * @param levelDepth The depth of the node in the DICOM hierarchy of sequences. | |
1740 * This parameter gives the number of elements in the "levelTagGroup", | |
1741 * "levelTagElement", and "levelIndex" arrays. | |
1742 * @param levelTagGroup The group of the parent DICOM tags in the hierarchy. | |
1743 * @param levelTagElement The element of the parent DICOM tags in the hierarchy. | |
1744 * @param levelIndex The index of the node in the parent sequences of the hierarchy. | |
1745 * @param tagGroup The group of the DICOM tag of interest. | |
1746 * @param tagElement The element of the DICOM tag of interest. | |
1747 * @param vr The value representation of the binary DICOM node. | |
1748 * @param payload The user payload. | |
1749 * @ingroup Callbacks | |
1750 **/ | |
1751 typedef void (*OrthancPluginDicomWebBinaryCallback2) ( | |
1752 OrthancPluginDicomWebNode* node, | |
1753 OrthancPluginDicomWebSetBinaryNode setter, | |
1754 uint32_t levelDepth, | |
1755 const uint16_t* levelTagGroup, | |
1756 const uint16_t* levelTagElement, | |
1757 const uint32_t* levelIndex, | |
1758 uint16_t tagGroup, | |
1759 uint16_t tagElement, | |
1760 OrthancPluginValueRepresentation vr, | |
1761 void* payload); | |
1762 | |
1763 | |
1764 | |
1765 /** | |
1766 * @brief Data structure that contains information about the Orthanc core. | |
1767 **/ | |
1768 typedef struct _OrthancPluginContext_t | |
1769 { | |
1770 void* pluginsManager; | |
1771 const char* orthancVersion; | |
1772 OrthancPluginFree Free; | |
1773 OrthancPluginErrorCode (*InvokeService) (struct _OrthancPluginContext_t* context, | |
1774 _OrthancPluginService service, | |
1775 const void* params); | |
1776 } OrthancPluginContext; | |
1777 | |
1778 | |
1779 | |
1780 /** | |
1781 * @brief An entry in the dictionary of DICOM tags. | |
1782 **/ | |
1783 typedef struct | |
1784 { | |
1785 uint16_t group; /*!< The group of the tag */ | |
1786 uint16_t element; /*!< The element of the tag */ | |
1787 OrthancPluginValueRepresentation vr; /*!< The value representation of the tag */ | |
1788 uint32_t minMultiplicity; /*!< The minimum multiplicity of the tag */ | |
1789 uint32_t maxMultiplicity; /*!< The maximum multiplicity of the tag (0 means arbitrary) */ | |
1790 } OrthancPluginDictionaryEntry; | |
1791 | |
1792 | |
1793 | |
1794 /** | |
1795 * @brief Free a string. | |
1796 * | |
1797 * Free a string that was allocated by the core system of Orthanc. | |
1798 * | |
1799 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
1800 * @param str The string to be freed. | |
1801 **/ | |
1802 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeString( | |
1803 OrthancPluginContext* context, | |
1804 char* str) | |
1805 { | |
1806 if (str != NULL) | |
1807 { | |
1808 context->Free(str); | |
1809 } | |
1810 } | |
1811 | |
1812 | |
1813 /** | |
1814 * @brief Check that the version of the hosting Orthanc is above a given version. | |
1815 * | |
1816 * This function checks whether the version of the Orthanc server | |
1817 * running this plugin, is above the given version. Contrarily to | |
1818 * OrthancPluginCheckVersion(), it is up to the developer of the | |
1819 * plugin to make sure that all the Orthanc SDK services called by | |
1820 * the plugin are actually implemented in the given version of | |
1821 * Orthanc. | |
1822 * | |
1823 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
1824 * @param expectedMajor Expected major version. | |
1825 * @param expectedMinor Expected minor version. | |
1826 * @param expectedRevision Expected revision. | |
1827 * @return 1 if and only if the versions are compatible. If the | |
1828 * result is 0, the initialization of the plugin should fail. | |
1829 * @see OrthancPluginCheckVersion | |
1830 * @ingroup Callbacks | |
1831 **/ | |
1832 ORTHANC_PLUGIN_INLINE int OrthancPluginCheckVersionAdvanced( | |
1833 OrthancPluginContext* context, | |
1834 int expectedMajor, | |
1835 int expectedMinor, | |
1836 int expectedRevision) | |
1837 { | |
1838 int major, minor, revision; | |
1839 | |
1840 if (sizeof(int32_t) != sizeof(OrthancPluginErrorCode) || | |
1841 sizeof(int32_t) != sizeof(OrthancPluginHttpMethod) || | |
1842 sizeof(int32_t) != sizeof(_OrthancPluginService) || | |
1843 sizeof(int32_t) != sizeof(_OrthancPluginProperty) || | |
1844 sizeof(int32_t) != sizeof(OrthancPluginPixelFormat) || | |
1845 sizeof(int32_t) != sizeof(OrthancPluginContentType) || | |
1846 sizeof(int32_t) != sizeof(OrthancPluginResourceType) || | |
1847 sizeof(int32_t) != sizeof(OrthancPluginChangeType) || | |
1848 sizeof(int32_t) != sizeof(OrthancPluginCompressionType) || | |
1849 sizeof(int32_t) != sizeof(OrthancPluginImageFormat) || | |
1850 sizeof(int32_t) != sizeof(OrthancPluginValueRepresentation) || | |
1851 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFormat) || | |
1852 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFlags) || | |
1853 sizeof(int32_t) != sizeof(OrthancPluginCreateDicomFlags) || | |
1854 sizeof(int32_t) != sizeof(OrthancPluginIdentifierConstraint) || | |
1855 sizeof(int32_t) != sizeof(OrthancPluginInstanceOrigin) || | |
1856 sizeof(int32_t) != sizeof(OrthancPluginJobStepStatus) || | |
1857 sizeof(int32_t) != sizeof(OrthancPluginConstraintType) || | |
1858 sizeof(int32_t) != sizeof(OrthancPluginMetricsType) || | |
1859 sizeof(int32_t) != sizeof(OrthancPluginDicomWebBinaryMode) || | |
1860 sizeof(int32_t) != sizeof(OrthancPluginStorageCommitmentFailureReason) || | |
1861 sizeof(int32_t) != sizeof(OrthancPluginReceivedInstanceAction)) | |
1862 { | |
1863 /* Mismatch in the size of the enumerations */ | |
1864 return 0; | |
1865 } | |
1866 | |
1867 /* Assume compatibility with the mainline */ | |
1868 if (!strcmp(context->orthancVersion, "mainline")) | |
1869 { | |
1870 return 1; | |
1871 } | |
1872 | |
1873 /* Parse the version of the Orthanc core */ | |
1874 if ( | |
1875 #ifdef _MSC_VER | |
1876 sscanf_s | |
1877 #else | |
1878 sscanf | |
1879 #endif | |
1880 (context->orthancVersion, "%4d.%4d.%4d", &major, &minor, &revision) != 3) | |
1881 { | |
1882 return 0; | |
1883 } | |
1884 | |
1885 /* Check the major number of the version */ | |
1886 | |
1887 if (major > expectedMajor) | |
1888 { | |
1889 return 1; | |
1890 } | |
1891 | |
1892 if (major < expectedMajor) | |
1893 { | |
1894 return 0; | |
1895 } | |
1896 | |
1897 /* Check the minor number of the version */ | |
1898 | |
1899 if (minor > expectedMinor) | |
1900 { | |
1901 return 1; | |
1902 } | |
1903 | |
1904 if (minor < expectedMinor) | |
1905 { | |
1906 return 0; | |
1907 } | |
1908 | |
1909 /* Check the revision number of the version */ | |
1910 | |
1911 if (revision >= expectedRevision) | |
1912 { | |
1913 return 1; | |
1914 } | |
1915 else | |
1916 { | |
1917 return 0; | |
1918 } | |
1919 } | |
1920 | |
1921 | |
1922 /** | |
1923 * @brief Check the compatibility of the plugin wrt. the version of its hosting Orthanc. | |
1924 * | |
1925 * This function checks whether the version of the Orthanc server | |
1926 * running this plugin, is above the version of the current Orthanc | |
1927 * SDK header. This guarantees that the plugin is compatible with | |
1928 * the hosting Orthanc (i.e. it will not call unavailable services). | |
1929 * The result of this function should always be checked in the | |
1930 * OrthancPluginInitialize() entry point of the plugin. | |
1931 * | |
1932 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
1933 * @return 1 if and only if the versions are compatible. If the | |
1934 * result is 0, the initialization of the plugin should fail. | |
1935 * @see OrthancPluginCheckVersionAdvanced | |
1936 * @ingroup Callbacks | |
1937 **/ | |
1938 ORTHANC_PLUGIN_INLINE int OrthancPluginCheckVersion( | |
1939 OrthancPluginContext* context) | |
1940 { | |
1941 return OrthancPluginCheckVersionAdvanced( | |
1942 context, | |
1943 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, | |
1944 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, | |
1945 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); | |
1946 } | |
1947 | |
1948 | |
1949 /** | |
1950 * @brief Free a memory buffer. | |
1951 * | |
1952 * Free a memory buffer that was allocated by the core system of Orthanc. | |
1953 * | |
1954 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
1955 * @param buffer The memory buffer to release. | |
1956 **/ | |
1957 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeMemoryBuffer( | |
1958 OrthancPluginContext* context, | |
1959 OrthancPluginMemoryBuffer* buffer) | |
1960 { | |
1961 context->Free(buffer->data); | |
1962 } | |
1963 | |
1964 | |
1965 /** | |
1966 * @brief Free a memory buffer. | |
1967 * | |
1968 * Free a memory buffer that was allocated by the core system of Orthanc. | |
1969 * | |
1970 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
1971 * @param buffer The memory buffer to release. | |
1972 **/ | |
1973 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeMemoryBuffer64( | |
1974 OrthancPluginContext* context, | |
1975 OrthancPluginMemoryBuffer64* buffer) | |
1976 { | |
1977 context->Free(buffer->data); | |
1978 } | |
1979 | |
1980 | |
1981 /** | |
1982 * @brief Log an error. | |
1983 * | |
1984 * Log an error message using the Orthanc logging system. | |
1985 * | |
1986 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
1987 * @param message The message to be logged. | |
1988 **/ | |
1989 ORTHANC_PLUGIN_INLINE void OrthancPluginLogError( | |
1990 OrthancPluginContext* context, | |
1991 const char* message) | |
1992 { | |
1993 context->InvokeService(context, _OrthancPluginService_LogError, message); | |
1994 } | |
1995 | |
1996 | |
1997 /** | |
1998 * @brief Log a warning. | |
1999 * | |
2000 * Log a warning message using the Orthanc logging system. | |
2001 * | |
2002 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2003 * @param message The message to be logged. | |
2004 **/ | |
2005 ORTHANC_PLUGIN_INLINE void OrthancPluginLogWarning( | |
2006 OrthancPluginContext* context, | |
2007 const char* message) | |
2008 { | |
2009 context->InvokeService(context, _OrthancPluginService_LogWarning, message); | |
2010 } | |
2011 | |
2012 | |
2013 /** | |
2014 * @brief Log an information. | |
2015 * | |
2016 * Log an information message using the Orthanc logging system. | |
2017 * | |
2018 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2019 * @param message The message to be logged. | |
2020 **/ | |
2021 ORTHANC_PLUGIN_INLINE void OrthancPluginLogInfo( | |
2022 OrthancPluginContext* context, | |
2023 const char* message) | |
2024 { | |
2025 context->InvokeService(context, _OrthancPluginService_LogInfo, message); | |
2026 } | |
2027 | |
2028 | |
2029 | |
2030 typedef struct | |
2031 { | |
2032 const char* pathRegularExpression; | |
2033 OrthancPluginRestCallback callback; | |
2034 } _OrthancPluginRestCallback; | |
2035 | |
2036 /** | |
2037 * @brief Register a REST callback. | |
2038 * | |
2039 * This function registers a REST callback against a regular | |
2040 * expression for a URI. This function must be called during the | |
2041 * initialization of the plugin, i.e. inside the | |
2042 * OrthancPluginInitialize() public function. | |
2043 * | |
2044 * Each REST callback is guaranteed to run in mutual exclusion. | |
2045 * | |
2046 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2047 * @param pathRegularExpression Regular expression for the URI. May contain groups. | |
2048 * @param callback The callback function to handle the REST call. | |
2049 * @see OrthancPluginRegisterRestCallbackNoLock() | |
2050 * | |
2051 * @note | |
2052 * The regular expression is case sensitive and must follow the | |
2053 * [Perl syntax](https://www.boost.org/doc/libs/1_67_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html). | |
2054 * | |
2055 * @ingroup Callbacks | |
2056 **/ | |
2057 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallback( | |
2058 OrthancPluginContext* context, | |
2059 const char* pathRegularExpression, | |
2060 OrthancPluginRestCallback callback) | |
2061 { | |
2062 _OrthancPluginRestCallback params; | |
2063 params.pathRegularExpression = pathRegularExpression; | |
2064 params.callback = callback; | |
2065 context->InvokeService(context, _OrthancPluginService_RegisterRestCallback, ¶ms); | |
2066 } | |
2067 | |
2068 | |
2069 | |
2070 /** | |
2071 * @brief Register a REST callback, without locking. | |
2072 * | |
2073 * This function registers a REST callback against a regular | |
2074 * expression for a URI. This function must be called during the | |
2075 * initialization of the plugin, i.e. inside the | |
2076 * OrthancPluginInitialize() public function. | |
2077 * | |
2078 * Contrarily to OrthancPluginRegisterRestCallback(), the callback | |
2079 * will NOT be invoked in mutual exclusion. This can be useful for | |
2080 * high-performance plugins that must handle concurrent requests | |
2081 * (Orthanc uses a pool of threads, one thread being assigned to | |
2082 * each incoming HTTP request). Of course, if using this function, | |
2083 * it is up to the plugin to implement the required locking | |
2084 * mechanisms. | |
2085 * | |
2086 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2087 * @param pathRegularExpression Regular expression for the URI. May contain groups. | |
2088 * @param callback The callback function to handle the REST call. | |
2089 * @see OrthancPluginRegisterRestCallback() | |
2090 * | |
2091 * @note | |
2092 * The regular expression is case sensitive and must follow the | |
2093 * [Perl syntax](https://www.boost.org/doc/libs/1_67_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html). | |
2094 * | |
2095 * @ingroup Callbacks | |
2096 **/ | |
2097 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallbackNoLock( | |
2098 OrthancPluginContext* context, | |
2099 const char* pathRegularExpression, | |
2100 OrthancPluginRestCallback callback) | |
2101 { | |
2102 _OrthancPluginRestCallback params; | |
2103 params.pathRegularExpression = pathRegularExpression; | |
2104 params.callback = callback; | |
2105 context->InvokeService(context, _OrthancPluginService_RegisterRestCallbackNoLock, ¶ms); | |
2106 } | |
2107 | |
2108 | |
2109 | |
2110 typedef struct | |
2111 { | |
2112 OrthancPluginOnStoredInstanceCallback callback; | |
2113 } _OrthancPluginOnStoredInstanceCallback; | |
2114 | |
2115 /** | |
2116 * @brief Register a callback for received instances. | |
2117 * | |
2118 * This function registers a callback function that is called | |
2119 * whenever a new DICOM instance is stored into the Orthanc core. | |
2120 * | |
2121 * @warning Your callback function will be called synchronously with | |
2122 * the core of Orthanc. This implies that deadlocks might emerge if | |
2123 * you call other core primitives of Orthanc in your callback (such | |
2124 * deadlocks are particularly visible in the presence of other plugins | |
2125 * or Lua scripts). It is thus strongly advised to avoid any call to | |
2126 * the REST API of Orthanc in the callback. If you have to call | |
2127 * other primitives of Orthanc, you should make these calls in a | |
2128 * separate thread, passing the pending events to be processed | |
2129 * through a message queue. | |
2130 * | |
2131 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2132 * @param callback The callback function. | |
2133 * @ingroup Callbacks | |
2134 **/ | |
2135 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterOnStoredInstanceCallback( | |
2136 OrthancPluginContext* context, | |
2137 OrthancPluginOnStoredInstanceCallback callback) | |
2138 { | |
2139 _OrthancPluginOnStoredInstanceCallback params; | |
2140 params.callback = callback; | |
2141 | |
2142 context->InvokeService(context, _OrthancPluginService_RegisterOnStoredInstanceCallback, ¶ms); | |
2143 } | |
2144 | |
2145 | |
2146 | |
2147 typedef struct | |
2148 { | |
2149 OrthancPluginRestOutput* output; | |
2150 const void* answer; | |
2151 uint32_t answerSize; | |
2152 const char* mimeType; | |
2153 } _OrthancPluginAnswerBuffer; | |
2154 | |
2155 /** | |
2156 * @brief Answer to a REST request. | |
2157 * | |
2158 * This function answers to a REST request with the content of a memory buffer. | |
2159 * | |
2160 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2161 * @param output The HTTP connection to the client application. | |
2162 * @param answer Pointer to the memory buffer containing the answer. | |
2163 * @param answerSize Number of bytes of the answer. | |
2164 * @param mimeType The MIME type of the answer. | |
2165 * @ingroup REST | |
2166 **/ | |
2167 ORTHANC_PLUGIN_INLINE void OrthancPluginAnswerBuffer( | |
2168 OrthancPluginContext* context, | |
2169 OrthancPluginRestOutput* output, | |
2170 const void* answer, | |
2171 uint32_t answerSize, | |
2172 const char* mimeType) | |
2173 { | |
2174 _OrthancPluginAnswerBuffer params; | |
2175 params.output = output; | |
2176 params.answer = answer; | |
2177 params.answerSize = answerSize; | |
2178 params.mimeType = mimeType; | |
2179 context->InvokeService(context, _OrthancPluginService_AnswerBuffer, ¶ms); | |
2180 } | |
2181 | |
2182 | |
2183 typedef struct | |
2184 { | |
2185 OrthancPluginRestOutput* output; | |
2186 OrthancPluginPixelFormat format; | |
2187 uint32_t width; | |
2188 uint32_t height; | |
2189 uint32_t pitch; | |
2190 const void* buffer; | |
2191 } _OrthancPluginCompressAndAnswerPngImage; | |
2192 | |
2193 typedef struct | |
2194 { | |
2195 OrthancPluginRestOutput* output; | |
2196 OrthancPluginImageFormat imageFormat; | |
2197 OrthancPluginPixelFormat pixelFormat; | |
2198 uint32_t width; | |
2199 uint32_t height; | |
2200 uint32_t pitch; | |
2201 const void* buffer; | |
2202 uint8_t quality; | |
2203 } _OrthancPluginCompressAndAnswerImage; | |
2204 | |
2205 | |
2206 /** | |
2207 * @brief Answer to a REST request with a PNG image. | |
2208 * | |
2209 * This function answers to a REST request with a PNG image. The | |
2210 * parameters of this function describe a memory buffer that | |
2211 * contains an uncompressed image. The image will be automatically compressed | |
2212 * as a PNG image by the core system of Orthanc. | |
2213 * | |
2214 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2215 * @param output The HTTP connection to the client application. | |
2216 * @param format The memory layout of the uncompressed image. | |
2217 * @param width The width of the image. | |
2218 * @param height The height of the image. | |
2219 * @param pitch The pitch of the image (i.e. the number of bytes | |
2220 * between 2 successive lines of the image in the memory buffer). | |
2221 * @param buffer The memory buffer containing the uncompressed image. | |
2222 * @ingroup REST | |
2223 **/ | |
2224 ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerPngImage( | |
2225 OrthancPluginContext* context, | |
2226 OrthancPluginRestOutput* output, | |
2227 OrthancPluginPixelFormat format, | |
2228 uint32_t width, | |
2229 uint32_t height, | |
2230 uint32_t pitch, | |
2231 const void* buffer) | |
2232 { | |
2233 _OrthancPluginCompressAndAnswerImage params; | |
2234 params.output = output; | |
2235 params.imageFormat = OrthancPluginImageFormat_Png; | |
2236 params.pixelFormat = format; | |
2237 params.width = width; | |
2238 params.height = height; | |
2239 params.pitch = pitch; | |
2240 params.buffer = buffer; | |
2241 params.quality = 0; /* No quality for PNG */ | |
2242 context->InvokeService(context, _OrthancPluginService_CompressAndAnswerImage, ¶ms); | |
2243 } | |
2244 | |
2245 | |
2246 | |
2247 typedef struct | |
2248 { | |
2249 OrthancPluginMemoryBuffer* target; | |
2250 const char* instanceId; | |
2251 } _OrthancPluginGetDicomForInstance; | |
2252 | |
2253 /** | |
2254 * @brief Retrieve a DICOM instance using its Orthanc identifier. | |
2255 * | |
2256 * Retrieve a DICOM instance using its Orthanc identifier. The DICOM | |
2257 * file is stored into a newly allocated memory buffer. | |
2258 * | |
2259 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2260 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
2261 * @param instanceId The Orthanc identifier of the DICOM instance of interest. | |
2262 * @return 0 if success, or the error code if failure. | |
2263 * @ingroup Orthanc | |
2264 **/ | |
2265 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetDicomForInstance( | |
2266 OrthancPluginContext* context, | |
2267 OrthancPluginMemoryBuffer* target, | |
2268 const char* instanceId) | |
2269 { | |
2270 _OrthancPluginGetDicomForInstance params; | |
2271 params.target = target; | |
2272 params.instanceId = instanceId; | |
2273 return context->InvokeService(context, _OrthancPluginService_GetDicomForInstance, ¶ms); | |
2274 } | |
2275 | |
2276 | |
2277 | |
2278 typedef struct | |
2279 { | |
2280 OrthancPluginMemoryBuffer* target; | |
2281 const char* uri; | |
2282 } _OrthancPluginRestApiGet; | |
2283 | |
2284 /** | |
2285 * @brief Make a GET call to the built-in Orthanc REST API. | |
2286 * | |
2287 * Make a GET call to the built-in Orthanc REST API. The result to | |
2288 * the query is stored into a newly allocated memory buffer. | |
2289 * | |
2290 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2291 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
2292 * @param uri The URI in the built-in Orthanc API. | |
2293 * @return 0 if success, or the error code if failure. | |
2294 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. | |
2295 * @see OrthancPluginRestApiGetAfterPlugins | |
2296 * @ingroup Orthanc | |
2297 **/ | |
2298 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGet( | |
2299 OrthancPluginContext* context, | |
2300 OrthancPluginMemoryBuffer* target, | |
2301 const char* uri) | |
2302 { | |
2303 _OrthancPluginRestApiGet params; | |
2304 params.target = target; | |
2305 params.uri = uri; | |
2306 return context->InvokeService(context, _OrthancPluginService_RestApiGet, ¶ms); | |
2307 } | |
2308 | |
2309 | |
2310 | |
2311 /** | |
2312 * @brief Make a GET call to the REST API, as tainted by the plugins. | |
2313 * | |
2314 * Make a GET call to the Orthanc REST API, after all the plugins | |
2315 * are applied. In other words, if some plugin overrides or adds the | |
2316 * called URI to the built-in Orthanc REST API, this call will | |
2317 * return the result provided by this plugin. The result to the | |
2318 * query is stored into a newly allocated memory buffer. | |
2319 * | |
2320 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2321 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
2322 * @param uri The URI in the built-in Orthanc API. | |
2323 * @return 0 if success, or the error code if failure. | |
2324 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. | |
2325 * @see OrthancPluginRestApiGet | |
2326 * @ingroup Orthanc | |
2327 **/ | |
2328 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGetAfterPlugins( | |
2329 OrthancPluginContext* context, | |
2330 OrthancPluginMemoryBuffer* target, | |
2331 const char* uri) | |
2332 { | |
2333 _OrthancPluginRestApiGet params; | |
2334 params.target = target; | |
2335 params.uri = uri; | |
2336 return context->InvokeService(context, _OrthancPluginService_RestApiGetAfterPlugins, ¶ms); | |
2337 } | |
2338 | |
2339 | |
2340 | |
2341 typedef struct | |
2342 { | |
2343 OrthancPluginMemoryBuffer* target; | |
2344 const char* uri; | |
2345 const void* body; | |
2346 uint32_t bodySize; | |
2347 } _OrthancPluginRestApiPostPut; | |
2348 | |
2349 /** | |
2350 * @brief Make a POST call to the built-in Orthanc REST API. | |
2351 * | |
2352 * Make a POST call to the built-in Orthanc REST API. The result to | |
2353 * the query is stored into a newly allocated memory buffer. | |
2354 * | |
2355 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2356 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
2357 * @param uri The URI in the built-in Orthanc API. | |
2358 * @param body The body of the POST request. | |
2359 * @param bodySize The size of the body. | |
2360 * @return 0 if success, or the error code if failure. | |
2361 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. | |
2362 * @see OrthancPluginRestApiPostAfterPlugins | |
2363 * @ingroup Orthanc | |
2364 **/ | |
2365 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPost( | |
2366 OrthancPluginContext* context, | |
2367 OrthancPluginMemoryBuffer* target, | |
2368 const char* uri, | |
2369 const void* body, | |
2370 uint32_t bodySize) | |
2371 { | |
2372 _OrthancPluginRestApiPostPut params; | |
2373 params.target = target; | |
2374 params.uri = uri; | |
2375 params.body = body; | |
2376 params.bodySize = bodySize; | |
2377 return context->InvokeService(context, _OrthancPluginService_RestApiPost, ¶ms); | |
2378 } | |
2379 | |
2380 | |
2381 /** | |
2382 * @brief Make a POST call to the REST API, as tainted by the plugins. | |
2383 * | |
2384 * Make a POST call to the Orthanc REST API, after all the plugins | |
2385 * are applied. In other words, if some plugin overrides or adds the | |
2386 * called URI to the built-in Orthanc REST API, this call will | |
2387 * return the result provided by this plugin. The result to the | |
2388 * query is stored into a newly allocated memory buffer. | |
2389 * | |
2390 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2391 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
2392 * @param uri The URI in the built-in Orthanc API. | |
2393 * @param body The body of the POST request. | |
2394 * @param bodySize The size of the body. | |
2395 * @return 0 if success, or the error code if failure. | |
2396 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. | |
2397 * @see OrthancPluginRestApiPost | |
2398 * @ingroup Orthanc | |
2399 **/ | |
2400 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPostAfterPlugins( | |
2401 OrthancPluginContext* context, | |
2402 OrthancPluginMemoryBuffer* target, | |
2403 const char* uri, | |
2404 const void* body, | |
2405 uint32_t bodySize) | |
2406 { | |
2407 _OrthancPluginRestApiPostPut params; | |
2408 params.target = target; | |
2409 params.uri = uri; | |
2410 params.body = body; | |
2411 params.bodySize = bodySize; | |
2412 return context->InvokeService(context, _OrthancPluginService_RestApiPostAfterPlugins, ¶ms); | |
2413 } | |
2414 | |
2415 | |
2416 | |
2417 /** | |
2418 * @brief Make a DELETE call to the built-in Orthanc REST API. | |
2419 * | |
2420 * Make a DELETE call to the built-in Orthanc REST API. | |
2421 * | |
2422 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2423 * @param uri The URI to delete in the built-in Orthanc API. | |
2424 * @return 0 if success, or the error code if failure. | |
2425 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. | |
2426 * @see OrthancPluginRestApiDeleteAfterPlugins | |
2427 * @ingroup Orthanc | |
2428 **/ | |
2429 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiDelete( | |
2430 OrthancPluginContext* context, | |
2431 const char* uri) | |
2432 { | |
2433 return context->InvokeService(context, _OrthancPluginService_RestApiDelete, uri); | |
2434 } | |
2435 | |
2436 | |
2437 /** | |
2438 * @brief Make a DELETE call to the REST API, as tainted by the plugins. | |
2439 * | |
2440 * Make a DELETE call to the Orthanc REST API, after all the plugins | |
2441 * are applied. In other words, if some plugin overrides or adds the | |
2442 * called URI to the built-in Orthanc REST API, this call will | |
2443 * return the result provided by this plugin. | |
2444 * | |
2445 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2446 * @param uri The URI to delete in the built-in Orthanc API. | |
2447 * @return 0 if success, or the error code if failure. | |
2448 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. | |
2449 * @see OrthancPluginRestApiDelete | |
2450 * @ingroup Orthanc | |
2451 **/ | |
2452 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiDeleteAfterPlugins( | |
2453 OrthancPluginContext* context, | |
2454 const char* uri) | |
2455 { | |
2456 return context->InvokeService(context, _OrthancPluginService_RestApiDeleteAfterPlugins, uri); | |
2457 } | |
2458 | |
2459 | |
2460 | |
2461 /** | |
2462 * @brief Make a PUT call to the built-in Orthanc REST API. | |
2463 * | |
2464 * Make a PUT call to the built-in Orthanc REST API. The result to | |
2465 * the query is stored into a newly allocated memory buffer. | |
2466 * | |
2467 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2468 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
2469 * @param uri The URI in the built-in Orthanc API. | |
2470 * @param body The body of the PUT request. | |
2471 * @param bodySize The size of the body. | |
2472 * @return 0 if success, or the error code if failure. | |
2473 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. | |
2474 * @see OrthancPluginRestApiPutAfterPlugins | |
2475 * @ingroup Orthanc | |
2476 **/ | |
2477 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPut( | |
2478 OrthancPluginContext* context, | |
2479 OrthancPluginMemoryBuffer* target, | |
2480 const char* uri, | |
2481 const void* body, | |
2482 uint32_t bodySize) | |
2483 { | |
2484 _OrthancPluginRestApiPostPut params; | |
2485 params.target = target; | |
2486 params.uri = uri; | |
2487 params.body = body; | |
2488 params.bodySize = bodySize; | |
2489 return context->InvokeService(context, _OrthancPluginService_RestApiPut, ¶ms); | |
2490 } | |
2491 | |
2492 | |
2493 | |
2494 /** | |
2495 * @brief Make a PUT call to the REST API, as tainted by the plugins. | |
2496 * | |
2497 * Make a PUT call to the Orthanc REST API, after all the plugins | |
2498 * are applied. In other words, if some plugin overrides or adds the | |
2499 * called URI to the built-in Orthanc REST API, this call will | |
2500 * return the result provided by this plugin. The result to the | |
2501 * query is stored into a newly allocated memory buffer. | |
2502 * | |
2503 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2504 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
2505 * @param uri The URI in the built-in Orthanc API. | |
2506 * @param body The body of the PUT request. | |
2507 * @param bodySize The size of the body. | |
2508 * @return 0 if success, or the error code if failure. | |
2509 * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. | |
2510 * @see OrthancPluginRestApiPut | |
2511 * @ingroup Orthanc | |
2512 **/ | |
2513 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPutAfterPlugins( | |
2514 OrthancPluginContext* context, | |
2515 OrthancPluginMemoryBuffer* target, | |
2516 const char* uri, | |
2517 const void* body, | |
2518 uint32_t bodySize) | |
2519 { | |
2520 _OrthancPluginRestApiPostPut params; | |
2521 params.target = target; | |
2522 params.uri = uri; | |
2523 params.body = body; | |
2524 params.bodySize = bodySize; | |
2525 return context->InvokeService(context, _OrthancPluginService_RestApiPutAfterPlugins, ¶ms); | |
2526 } | |
2527 | |
2528 | |
2529 | |
2530 typedef struct | |
2531 { | |
2532 OrthancPluginRestOutput* output; | |
2533 const char* argument; | |
2534 } _OrthancPluginOutputPlusArgument; | |
2535 | |
2536 /** | |
2537 * @brief Redirect a REST request. | |
2538 * | |
2539 * This function answers to a REST request by redirecting the user | |
2540 * to another URI using HTTP status 301. | |
2541 * | |
2542 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2543 * @param output The HTTP connection to the client application. | |
2544 * @param redirection Where to redirect. | |
2545 * @ingroup REST | |
2546 **/ | |
2547 ORTHANC_PLUGIN_INLINE void OrthancPluginRedirect( | |
2548 OrthancPluginContext* context, | |
2549 OrthancPluginRestOutput* output, | |
2550 const char* redirection) | |
2551 { | |
2552 _OrthancPluginOutputPlusArgument params; | |
2553 params.output = output; | |
2554 params.argument = redirection; | |
2555 context->InvokeService(context, _OrthancPluginService_Redirect, ¶ms); | |
2556 } | |
2557 | |
2558 | |
2559 | |
2560 typedef struct | |
2561 { | |
2562 char** result; | |
2563 const char* argument; | |
2564 } _OrthancPluginRetrieveDynamicString; | |
2565 | |
2566 /** | |
2567 * @brief Look for a patient. | |
2568 * | |
2569 * Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020). | |
2570 * This function uses the database index to run as fast as possible (it does not loop | |
2571 * over all the stored patients). | |
2572 * | |
2573 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2574 * @param patientID The Patient ID of interest. | |
2575 * @return The NULL value if the patient is non-existent, or a string containing the | |
2576 * Orthanc ID of the patient. This string must be freed by OrthancPluginFreeString(). | |
2577 * @ingroup Orthanc | |
2578 **/ | |
2579 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupPatient( | |
2580 OrthancPluginContext* context, | |
2581 const char* patientID) | |
2582 { | |
2583 char* result; | |
2584 | |
2585 _OrthancPluginRetrieveDynamicString params; | |
2586 params.result = &result; | |
2587 params.argument = patientID; | |
2588 | |
2589 if (context->InvokeService(context, _OrthancPluginService_LookupPatient, ¶ms) != OrthancPluginErrorCode_Success) | |
2590 { | |
2591 /* Error */ | |
2592 return NULL; | |
2593 } | |
2594 else | |
2595 { | |
2596 return result; | |
2597 } | |
2598 } | |
2599 | |
2600 | |
2601 /** | |
2602 * @brief Look for a study. | |
2603 * | |
2604 * Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d). | |
2605 * This function uses the database index to run as fast as possible (it does not loop | |
2606 * over all the stored studies). | |
2607 * | |
2608 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2609 * @param studyUID The Study Instance UID of interest. | |
2610 * @return The NULL value if the study is non-existent, or a string containing the | |
2611 * Orthanc ID of the study. This string must be freed by OrthancPluginFreeString(). | |
2612 * @ingroup Orthanc | |
2613 **/ | |
2614 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudy( | |
2615 OrthancPluginContext* context, | |
2616 const char* studyUID) | |
2617 { | |
2618 char* result; | |
2619 | |
2620 _OrthancPluginRetrieveDynamicString params; | |
2621 params.result = &result; | |
2622 params.argument = studyUID; | |
2623 | |
2624 if (context->InvokeService(context, _OrthancPluginService_LookupStudy, ¶ms) != OrthancPluginErrorCode_Success) | |
2625 { | |
2626 /* Error */ | |
2627 return NULL; | |
2628 } | |
2629 else | |
2630 { | |
2631 return result; | |
2632 } | |
2633 } | |
2634 | |
2635 | |
2636 /** | |
2637 * @brief Look for a study, using the accession number. | |
2638 * | |
2639 * Look for a study stored in Orthanc, using its Accession Number tag (0x0008, 0x0050). | |
2640 * This function uses the database index to run as fast as possible (it does not loop | |
2641 * over all the stored studies). | |
2642 * | |
2643 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2644 * @param accessionNumber The Accession Number of interest. | |
2645 * @return The NULL value if the study is non-existent, or a string containing the | |
2646 * Orthanc ID of the study. This string must be freed by OrthancPluginFreeString(). | |
2647 * @ingroup Orthanc | |
2648 **/ | |
2649 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudyWithAccessionNumber( | |
2650 OrthancPluginContext* context, | |
2651 const char* accessionNumber) | |
2652 { | |
2653 char* result; | |
2654 | |
2655 _OrthancPluginRetrieveDynamicString params; | |
2656 params.result = &result; | |
2657 params.argument = accessionNumber; | |
2658 | |
2659 if (context->InvokeService(context, _OrthancPluginService_LookupStudyWithAccessionNumber, ¶ms) != OrthancPluginErrorCode_Success) | |
2660 { | |
2661 /* Error */ | |
2662 return NULL; | |
2663 } | |
2664 else | |
2665 { | |
2666 return result; | |
2667 } | |
2668 } | |
2669 | |
2670 | |
2671 /** | |
2672 * @brief Look for a series. | |
2673 * | |
2674 * Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e). | |
2675 * This function uses the database index to run as fast as possible (it does not loop | |
2676 * over all the stored series). | |
2677 * | |
2678 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2679 * @param seriesUID The Series Instance UID of interest. | |
2680 * @return The NULL value if the series is non-existent, or a string containing the | |
2681 * Orthanc ID of the series. This string must be freed by OrthancPluginFreeString(). | |
2682 * @ingroup Orthanc | |
2683 **/ | |
2684 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupSeries( | |
2685 OrthancPluginContext* context, | |
2686 const char* seriesUID) | |
2687 { | |
2688 char* result; | |
2689 | |
2690 _OrthancPluginRetrieveDynamicString params; | |
2691 params.result = &result; | |
2692 params.argument = seriesUID; | |
2693 | |
2694 if (context->InvokeService(context, _OrthancPluginService_LookupSeries, ¶ms) != OrthancPluginErrorCode_Success) | |
2695 { | |
2696 /* Error */ | |
2697 return NULL; | |
2698 } | |
2699 else | |
2700 { | |
2701 return result; | |
2702 } | |
2703 } | |
2704 | |
2705 | |
2706 /** | |
2707 * @brief Look for an instance. | |
2708 * | |
2709 * Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018). | |
2710 * This function uses the database index to run as fast as possible (it does not loop | |
2711 * over all the stored instances). | |
2712 * | |
2713 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2714 * @param sopInstanceUID The SOP Instance UID of interest. | |
2715 * @return The NULL value if the instance is non-existent, or a string containing the | |
2716 * Orthanc ID of the instance. This string must be freed by OrthancPluginFreeString(). | |
2717 * @ingroup Orthanc | |
2718 **/ | |
2719 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupInstance( | |
2720 OrthancPluginContext* context, | |
2721 const char* sopInstanceUID) | |
2722 { | |
2723 char* result; | |
2724 | |
2725 _OrthancPluginRetrieveDynamicString params; | |
2726 params.result = &result; | |
2727 params.argument = sopInstanceUID; | |
2728 | |
2729 if (context->InvokeService(context, _OrthancPluginService_LookupInstance, ¶ms) != OrthancPluginErrorCode_Success) | |
2730 { | |
2731 /* Error */ | |
2732 return NULL; | |
2733 } | |
2734 else | |
2735 { | |
2736 return result; | |
2737 } | |
2738 } | |
2739 | |
2740 | |
2741 | |
2742 typedef struct | |
2743 { | |
2744 OrthancPluginRestOutput* output; | |
2745 uint16_t status; | |
2746 } _OrthancPluginSendHttpStatusCode; | |
2747 | |
2748 /** | |
2749 * @brief Send a HTTP status code. | |
2750 * | |
2751 * This function answers to a REST request by sending a HTTP status | |
2752 * code (such as "400 - Bad Request"). Note that: | |
2753 * - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). | |
2754 * - Redirections (status 301) must use ::OrthancPluginRedirect(). | |
2755 * - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). | |
2756 * - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed(). | |
2757 * | |
2758 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2759 * @param output The HTTP connection to the client application. | |
2760 * @param status The HTTP status code to be sent. | |
2761 * @ingroup REST | |
2762 * @see OrthancPluginSendHttpStatus() | |
2763 **/ | |
2764 ORTHANC_PLUGIN_INLINE void OrthancPluginSendHttpStatusCode( | |
2765 OrthancPluginContext* context, | |
2766 OrthancPluginRestOutput* output, | |
2767 uint16_t status) | |
2768 { | |
2769 _OrthancPluginSendHttpStatusCode params; | |
2770 params.output = output; | |
2771 params.status = status; | |
2772 context->InvokeService(context, _OrthancPluginService_SendHttpStatusCode, ¶ms); | |
2773 } | |
2774 | |
2775 | |
2776 /** | |
2777 * @brief Signal that a REST request is not authorized. | |
2778 * | |
2779 * This function answers to a REST request by signaling that it is | |
2780 * not authorized. | |
2781 * | |
2782 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2783 * @param output The HTTP connection to the client application. | |
2784 * @param realm The realm for the authorization process. | |
2785 * @ingroup REST | |
2786 **/ | |
2787 ORTHANC_PLUGIN_INLINE void OrthancPluginSendUnauthorized( | |
2788 OrthancPluginContext* context, | |
2789 OrthancPluginRestOutput* output, | |
2790 const char* realm) | |
2791 { | |
2792 _OrthancPluginOutputPlusArgument params; | |
2793 params.output = output; | |
2794 params.argument = realm; | |
2795 context->InvokeService(context, _OrthancPluginService_SendUnauthorized, ¶ms); | |
2796 } | |
2797 | |
2798 | |
2799 /** | |
2800 * @brief Signal that this URI does not support this HTTP method. | |
2801 * | |
2802 * This function answers to a REST request by signaling that the | |
2803 * queried URI does not support this method. | |
2804 * | |
2805 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2806 * @param output The HTTP connection to the client application. | |
2807 * @param allowedMethods The allowed methods for this URI (e.g. "GET,POST" after a PUT or a POST request). | |
2808 * @ingroup REST | |
2809 **/ | |
2810 ORTHANC_PLUGIN_INLINE void OrthancPluginSendMethodNotAllowed( | |
2811 OrthancPluginContext* context, | |
2812 OrthancPluginRestOutput* output, | |
2813 const char* allowedMethods) | |
2814 { | |
2815 _OrthancPluginOutputPlusArgument params; | |
2816 params.output = output; | |
2817 params.argument = allowedMethods; | |
2818 context->InvokeService(context, _OrthancPluginService_SendMethodNotAllowed, ¶ms); | |
2819 } | |
2820 | |
2821 | |
2822 typedef struct | |
2823 { | |
2824 OrthancPluginRestOutput* output; | |
2825 const char* key; | |
2826 const char* value; | |
2827 } _OrthancPluginSetHttpHeader; | |
2828 | |
2829 /** | |
2830 * @brief Set a cookie. | |
2831 * | |
2832 * This function sets a cookie in the HTTP client. | |
2833 * | |
2834 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2835 * @param output The HTTP connection to the client application. | |
2836 * @param cookie The cookie to be set. | |
2837 * @param value The value of the cookie. | |
2838 * @ingroup REST | |
2839 **/ | |
2840 ORTHANC_PLUGIN_INLINE void OrthancPluginSetCookie( | |
2841 OrthancPluginContext* context, | |
2842 OrthancPluginRestOutput* output, | |
2843 const char* cookie, | |
2844 const char* value) | |
2845 { | |
2846 _OrthancPluginSetHttpHeader params; | |
2847 params.output = output; | |
2848 params.key = cookie; | |
2849 params.value = value; | |
2850 context->InvokeService(context, _OrthancPluginService_SetCookie, ¶ms); | |
2851 } | |
2852 | |
2853 | |
2854 /** | |
2855 * @brief Set some HTTP header. | |
2856 * | |
2857 * This function sets a HTTP header in the HTTP answer. | |
2858 * | |
2859 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2860 * @param output The HTTP connection to the client application. | |
2861 * @param key The HTTP header to be set. | |
2862 * @param value The value of the HTTP header. | |
2863 * @ingroup REST | |
2864 **/ | |
2865 ORTHANC_PLUGIN_INLINE void OrthancPluginSetHttpHeader( | |
2866 OrthancPluginContext* context, | |
2867 OrthancPluginRestOutput* output, | |
2868 const char* key, | |
2869 const char* value) | |
2870 { | |
2871 _OrthancPluginSetHttpHeader params; | |
2872 params.output = output; | |
2873 params.key = key; | |
2874 params.value = value; | |
2875 context->InvokeService(context, _OrthancPluginService_SetHttpHeader, ¶ms); | |
2876 } | |
2877 | |
2878 | |
2879 typedef struct | |
2880 { | |
2881 char** resultStringToFree; | |
2882 const char** resultString; | |
2883 int64_t* resultInt64; | |
2884 const char* key; | |
2885 const OrthancPluginDicomInstance* instance; | |
2886 OrthancPluginInstanceOrigin* resultOrigin; /* New in Orthanc 0.9.5 SDK */ | |
2887 } _OrthancPluginAccessDicomInstance; | |
2888 | |
2889 | |
2890 /** | |
2891 * @brief Get the AET of a DICOM instance. | |
2892 * | |
2893 * This function returns the Application Entity Title (AET) of the | |
2894 * DICOM modality from which a DICOM instance originates. | |
2895 * | |
2896 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2897 * @param instance The instance of interest. | |
2898 * @return The AET if success, NULL if error. | |
2899 * @ingroup DicomInstance | |
2900 **/ | |
2901 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceRemoteAet( | |
2902 OrthancPluginContext* context, | |
2903 const OrthancPluginDicomInstance* instance) | |
2904 { | |
2905 const char* result; | |
2906 | |
2907 _OrthancPluginAccessDicomInstance params; | |
2908 memset(¶ms, 0, sizeof(params)); | |
2909 params.resultString = &result; | |
2910 params.instance = instance; | |
2911 | |
2912 if (context->InvokeService(context, _OrthancPluginService_GetInstanceRemoteAet, ¶ms) != OrthancPluginErrorCode_Success) | |
2913 { | |
2914 /* Error */ | |
2915 return NULL; | |
2916 } | |
2917 else | |
2918 { | |
2919 return result; | |
2920 } | |
2921 } | |
2922 | |
2923 | |
2924 /** | |
2925 * @brief Get the size of a DICOM file. | |
2926 * | |
2927 * This function returns the number of bytes of the given DICOM instance. | |
2928 * | |
2929 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2930 * @param instance The instance of interest. | |
2931 * @return The size of the file, -1 in case of error. | |
2932 * @ingroup DicomInstance | |
2933 **/ | |
2934 ORTHANC_PLUGIN_INLINE int64_t OrthancPluginGetInstanceSize( | |
2935 OrthancPluginContext* context, | |
2936 const OrthancPluginDicomInstance* instance) | |
2937 { | |
2938 int64_t size; | |
2939 | |
2940 _OrthancPluginAccessDicomInstance params; | |
2941 memset(¶ms, 0, sizeof(params)); | |
2942 params.resultInt64 = &size; | |
2943 params.instance = instance; | |
2944 | |
2945 if (context->InvokeService(context, _OrthancPluginService_GetInstanceSize, ¶ms) != OrthancPluginErrorCode_Success) | |
2946 { | |
2947 /* Error */ | |
2948 return -1; | |
2949 } | |
2950 else | |
2951 { | |
2952 return size; | |
2953 } | |
2954 } | |
2955 | |
2956 | |
2957 /** | |
2958 * @brief Get the data of a DICOM file. | |
2959 * | |
2960 * This function returns a pointer to the content of the given DICOM instance. | |
2961 * | |
2962 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2963 * @param instance The instance of interest. | |
2964 * @return The pointer to the DICOM data, NULL in case of error. | |
2965 * @ingroup DicomInstance | |
2966 **/ | |
2967 ORTHANC_PLUGIN_INLINE const void* OrthancPluginGetInstanceData( | |
2968 OrthancPluginContext* context, | |
2969 const OrthancPluginDicomInstance* instance) | |
2970 { | |
2971 const char* result; | |
2972 | |
2973 _OrthancPluginAccessDicomInstance params; | |
2974 memset(¶ms, 0, sizeof(params)); | |
2975 params.resultString = &result; | |
2976 params.instance = instance; | |
2977 | |
2978 if (context->InvokeService(context, _OrthancPluginService_GetInstanceData, ¶ms) != OrthancPluginErrorCode_Success) | |
2979 { | |
2980 /* Error */ | |
2981 return NULL; | |
2982 } | |
2983 else | |
2984 { | |
2985 return result; | |
2986 } | |
2987 } | |
2988 | |
2989 | |
2990 /** | |
2991 * @brief Get the DICOM tag hierarchy as a JSON file. | |
2992 * | |
2993 * This function returns a pointer to a newly created string | |
2994 * containing a JSON file. This JSON file encodes the tag hierarchy | |
2995 * of the given DICOM instance. | |
2996 * | |
2997 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
2998 * @param instance The instance of interest. | |
2999 * @return The NULL value in case of error, or a string containing the JSON file. | |
3000 * This string must be freed by OrthancPluginFreeString(). | |
3001 * @ingroup DicomInstance | |
3002 **/ | |
3003 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceJson( | |
3004 OrthancPluginContext* context, | |
3005 const OrthancPluginDicomInstance* instance) | |
3006 { | |
3007 char* result; | |
3008 | |
3009 _OrthancPluginAccessDicomInstance params; | |
3010 memset(¶ms, 0, sizeof(params)); | |
3011 params.resultStringToFree = &result; | |
3012 params.instance = instance; | |
3013 | |
3014 if (context->InvokeService(context, _OrthancPluginService_GetInstanceJson, ¶ms) != OrthancPluginErrorCode_Success) | |
3015 { | |
3016 /* Error */ | |
3017 return NULL; | |
3018 } | |
3019 else | |
3020 { | |
3021 return result; | |
3022 } | |
3023 } | |
3024 | |
3025 | |
3026 /** | |
3027 * @brief Get the DICOM tag hierarchy as a JSON file (with simplification). | |
3028 * | |
3029 * This function returns a pointer to a newly created string | |
3030 * containing a JSON file. This JSON file encodes the tag hierarchy | |
3031 * of the given DICOM instance. In contrast with | |
3032 * ::OrthancPluginGetInstanceJson(), the returned JSON file is in | |
3033 * its simplified version. | |
3034 * | |
3035 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3036 * @param instance The instance of interest. | |
3037 * @return The NULL value in case of error, or a string containing the JSON file. | |
3038 * This string must be freed by OrthancPluginFreeString(). | |
3039 * @ingroup DicomInstance | |
3040 **/ | |
3041 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceSimplifiedJson( | |
3042 OrthancPluginContext* context, | |
3043 const OrthancPluginDicomInstance* instance) | |
3044 { | |
3045 char* result; | |
3046 | |
3047 _OrthancPluginAccessDicomInstance params; | |
3048 memset(¶ms, 0, sizeof(params)); | |
3049 params.resultStringToFree = &result; | |
3050 params.instance = instance; | |
3051 | |
3052 if (context->InvokeService(context, _OrthancPluginService_GetInstanceSimplifiedJson, ¶ms) != OrthancPluginErrorCode_Success) | |
3053 { | |
3054 /* Error */ | |
3055 return NULL; | |
3056 } | |
3057 else | |
3058 { | |
3059 return result; | |
3060 } | |
3061 } | |
3062 | |
3063 | |
3064 /** | |
3065 * @brief Check whether a DICOM instance is associated with some metadata. | |
3066 * | |
3067 * This function checks whether the DICOM instance of interest is | |
3068 * associated with some metadata. As of Orthanc 0.8.1, in the | |
3069 * callbacks registered by | |
3070 * ::OrthancPluginRegisterOnStoredInstanceCallback(), the only | |
3071 * possibly available metadata are "ReceptionDate", "RemoteAET" and | |
3072 * "IndexInSeries". | |
3073 * | |
3074 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3075 * @param instance The instance of interest. | |
3076 * @param metadata The metadata of interest. | |
3077 * @return 1 if the metadata is present, 0 if it is absent, -1 in case of error. | |
3078 * @ingroup DicomInstance | |
3079 **/ | |
3080 ORTHANC_PLUGIN_INLINE int OrthancPluginHasInstanceMetadata( | |
3081 OrthancPluginContext* context, | |
3082 const OrthancPluginDicomInstance* instance, | |
3083 const char* metadata) | |
3084 { | |
3085 int64_t result; | |
3086 | |
3087 _OrthancPluginAccessDicomInstance params; | |
3088 memset(¶ms, 0, sizeof(params)); | |
3089 params.resultInt64 = &result; | |
3090 params.instance = instance; | |
3091 params.key = metadata; | |
3092 | |
3093 if (context->InvokeService(context, _OrthancPluginService_HasInstanceMetadata, ¶ms) != OrthancPluginErrorCode_Success) | |
3094 { | |
3095 /* Error */ | |
3096 return -1; | |
3097 } | |
3098 else | |
3099 { | |
3100 return (result != 0); | |
3101 } | |
3102 } | |
3103 | |
3104 | |
3105 /** | |
3106 * @brief Get the value of some metadata associated with a given DICOM instance. | |
3107 * | |
3108 * This functions returns the value of some metadata that is associated with the DICOM instance of interest. | |
3109 * Before calling this function, the existence of the metadata must have been checked with | |
3110 * ::OrthancPluginHasInstanceMetadata(). | |
3111 * | |
3112 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3113 * @param instance The instance of interest. | |
3114 * @param metadata The metadata of interest. | |
3115 * @return The metadata value if success, NULL if error. Please note that the | |
3116 * returned string belongs to the instance object and must NOT be | |
3117 * deallocated. Please make a copy of the string if you wish to access | |
3118 * it later. | |
3119 * @ingroup DicomInstance | |
3120 **/ | |
3121 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceMetadata( | |
3122 OrthancPluginContext* context, | |
3123 const OrthancPluginDicomInstance* instance, | |
3124 const char* metadata) | |
3125 { | |
3126 const char* result; | |
3127 | |
3128 _OrthancPluginAccessDicomInstance params; | |
3129 memset(¶ms, 0, sizeof(params)); | |
3130 params.resultString = &result; | |
3131 params.instance = instance; | |
3132 params.key = metadata; | |
3133 | |
3134 if (context->InvokeService(context, _OrthancPluginService_GetInstanceMetadata, ¶ms) != OrthancPluginErrorCode_Success) | |
3135 { | |
3136 /* Error */ | |
3137 return NULL; | |
3138 } | |
3139 else | |
3140 { | |
3141 return result; | |
3142 } | |
3143 } | |
3144 | |
3145 | |
3146 | |
3147 typedef struct | |
3148 { | |
3149 OrthancPluginStorageCreate create; | |
3150 OrthancPluginStorageRead read; | |
3151 OrthancPluginStorageRemove remove; | |
3152 OrthancPluginFree free; | |
3153 } _OrthancPluginRegisterStorageArea; | |
3154 | |
3155 /** | |
3156 * @brief Register a custom storage area. | |
3157 * | |
3158 * This function registers a custom storage area, to replace the | |
3159 * built-in way Orthanc stores its files on the filesystem. This | |
3160 * function must be called during the initialization of the plugin, | |
3161 * i.e. inside the OrthancPluginInitialize() public function. | |
3162 * | |
3163 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3164 * @param create The callback function to store a file on the custom storage area. | |
3165 * @param read The callback function to read a file from the custom storage area. | |
3166 * @param remove The callback function to remove a file from the custom storage area. | |
3167 * @ingroup Callbacks | |
3168 * @deprecated Please use OrthancPluginRegisterStorageArea2() | |
3169 **/ | |
3170 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterStorageArea( | |
3171 OrthancPluginContext* context, | |
3172 OrthancPluginStorageCreate create, | |
3173 OrthancPluginStorageRead read, | |
3174 OrthancPluginStorageRemove remove) | |
3175 { | |
3176 _OrthancPluginRegisterStorageArea params; | |
3177 params.create = create; | |
3178 params.read = read; | |
3179 params.remove = remove; | |
3180 | |
3181 #ifdef __cplusplus | |
3182 params.free = ::free; | |
3183 #else | |
3184 params.free = free; | |
3185 #endif | |
3186 | |
3187 context->InvokeService(context, _OrthancPluginService_RegisterStorageArea, ¶ms); | |
3188 } | |
3189 | |
3190 | |
3191 | |
3192 /** | |
3193 * @brief Return the path to the Orthanc executable. | |
3194 * | |
3195 * This function returns the path to the Orthanc executable. | |
3196 * | |
3197 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3198 * @return NULL in the case of an error, or a newly allocated string | |
3199 * containing the path. This string must be freed by | |
3200 * OrthancPluginFreeString(). | |
3201 **/ | |
3202 ORTHANC_PLUGIN_INLINE char *OrthancPluginGetOrthancPath(OrthancPluginContext* context) | |
3203 { | |
3204 char* result; | |
3205 | |
3206 _OrthancPluginRetrieveDynamicString params; | |
3207 params.result = &result; | |
3208 params.argument = NULL; | |
3209 | |
3210 if (context->InvokeService(context, _OrthancPluginService_GetOrthancPath, ¶ms) != OrthancPluginErrorCode_Success) | |
3211 { | |
3212 /* Error */ | |
3213 return NULL; | |
3214 } | |
3215 else | |
3216 { | |
3217 return result; | |
3218 } | |
3219 } | |
3220 | |
3221 | |
3222 /** | |
3223 * @brief Return the directory containing the Orthanc. | |
3224 * | |
3225 * This function returns the path to the directory containing the Orthanc executable. | |
3226 * | |
3227 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3228 * @return NULL in the case of an error, or a newly allocated string | |
3229 * containing the path. This string must be freed by | |
3230 * OrthancPluginFreeString(). | |
3231 **/ | |
3232 ORTHANC_PLUGIN_INLINE char *OrthancPluginGetOrthancDirectory(OrthancPluginContext* context) | |
3233 { | |
3234 char* result; | |
3235 | |
3236 _OrthancPluginRetrieveDynamicString params; | |
3237 params.result = &result; | |
3238 params.argument = NULL; | |
3239 | |
3240 if (context->InvokeService(context, _OrthancPluginService_GetOrthancDirectory, ¶ms) != OrthancPluginErrorCode_Success) | |
3241 { | |
3242 /* Error */ | |
3243 return NULL; | |
3244 } | |
3245 else | |
3246 { | |
3247 return result; | |
3248 } | |
3249 } | |
3250 | |
3251 | |
3252 /** | |
3253 * @brief Return the path to the configuration file(s). | |
3254 * | |
3255 * This function returns the path to the configuration file(s) that | |
3256 * was specified when starting Orthanc. Since version 0.9.1, this | |
3257 * path can refer to a folder that stores a set of configuration | |
3258 * files. This function is deprecated in favor of | |
3259 * OrthancPluginGetConfiguration(). | |
3260 * | |
3261 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3262 * @return NULL in the case of an error, or a newly allocated string | |
3263 * containing the path. This string must be freed by | |
3264 * OrthancPluginFreeString(). | |
3265 * @see OrthancPluginGetConfiguration() | |
3266 **/ | |
3267 ORTHANC_PLUGIN_INLINE char *OrthancPluginGetConfigurationPath(OrthancPluginContext* context) | |
3268 { | |
3269 char* result; | |
3270 | |
3271 _OrthancPluginRetrieveDynamicString params; | |
3272 params.result = &result; | |
3273 params.argument = NULL; | |
3274 | |
3275 if (context->InvokeService(context, _OrthancPluginService_GetConfigurationPath, ¶ms) != OrthancPluginErrorCode_Success) | |
3276 { | |
3277 /* Error */ | |
3278 return NULL; | |
3279 } | |
3280 else | |
3281 { | |
3282 return result; | |
3283 } | |
3284 } | |
3285 | |
3286 | |
3287 | |
3288 typedef struct | |
3289 { | |
3290 OrthancPluginOnChangeCallback callback; | |
3291 } _OrthancPluginOnChangeCallback; | |
3292 | |
3293 /** | |
3294 * @brief Register a callback to monitor changes. | |
3295 * | |
3296 * This function registers a callback function that is called | |
3297 * whenever a change happens to some DICOM resource. | |
3298 * | |
3299 * @warning Your callback function will be called synchronously with | |
3300 * the core of Orthanc. This implies that deadlocks might emerge if | |
3301 * you call other core primitives of Orthanc in your callback (such | |
3302 * deadlocks are particularly visible in the presence of other plugins | |
3303 * or Lua scripts). It is thus strongly advised to avoid any call to | |
3304 * the REST API of Orthanc in the callback. If you have to call | |
3305 * other primitives of Orthanc, you should make these calls in a | |
3306 * separate thread, passing the pending events to be processed | |
3307 * through a message queue. | |
3308 * | |
3309 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3310 * @param callback The callback function. | |
3311 * @ingroup Callbacks | |
3312 **/ | |
3313 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterOnChangeCallback( | |
3314 OrthancPluginContext* context, | |
3315 OrthancPluginOnChangeCallback callback) | |
3316 { | |
3317 _OrthancPluginOnChangeCallback params; | |
3318 params.callback = callback; | |
3319 | |
3320 context->InvokeService(context, _OrthancPluginService_RegisterOnChangeCallback, ¶ms); | |
3321 } | |
3322 | |
3323 | |
3324 | |
3325 typedef struct | |
3326 { | |
3327 const char* plugin; | |
3328 _OrthancPluginProperty property; | |
3329 const char* value; | |
3330 } _OrthancPluginSetPluginProperty; | |
3331 | |
3332 | |
3333 /** | |
3334 * @brief Set the URI where the plugin provides its Web interface. | |
3335 * | |
3336 * For plugins that come with a Web interface, this function | |
3337 * declares the entry path where to find this interface. This | |
3338 * information is notably used in the "Plugins" page of Orthanc | |
3339 * Explorer. | |
3340 * | |
3341 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3342 * @param uri The root URI for this plugin. | |
3343 **/ | |
3344 ORTHANC_PLUGIN_INLINE void OrthancPluginSetRootUri( | |
3345 OrthancPluginContext* context, | |
3346 const char* uri) | |
3347 { | |
3348 _OrthancPluginSetPluginProperty params; | |
3349 params.plugin = OrthancPluginGetName(); | |
3350 params.property = _OrthancPluginProperty_RootUri; | |
3351 params.value = uri; | |
3352 | |
3353 context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); | |
3354 } | |
3355 | |
3356 | |
3357 /** | |
3358 * @brief Set a description for this plugin. | |
3359 * | |
3360 * Set a description for this plugin. It is displayed in the | |
3361 * "Plugins" page of Orthanc Explorer. | |
3362 * | |
3363 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3364 * @param description The description. | |
3365 **/ | |
3366 ORTHANC_PLUGIN_INLINE void OrthancPluginSetDescription( | |
3367 OrthancPluginContext* context, | |
3368 const char* description) | |
3369 { | |
3370 _OrthancPluginSetPluginProperty params; | |
3371 params.plugin = OrthancPluginGetName(); | |
3372 params.property = _OrthancPluginProperty_Description; | |
3373 params.value = description; | |
3374 | |
3375 context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); | |
3376 } | |
3377 | |
3378 | |
3379 /** | |
3380 * @brief Extend the JavaScript code of Orthanc Explorer. | |
3381 * | |
3382 * Add JavaScript code to customize the default behavior of Orthanc | |
3383 * Explorer. This can for instance be used to add new buttons. | |
3384 * | |
3385 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3386 * @param javascript The custom JavaScript code. | |
3387 **/ | |
3388 ORTHANC_PLUGIN_INLINE void OrthancPluginExtendOrthancExplorer( | |
3389 OrthancPluginContext* context, | |
3390 const char* javascript) | |
3391 { | |
3392 _OrthancPluginSetPluginProperty params; | |
3393 params.plugin = OrthancPluginGetName(); | |
3394 params.property = _OrthancPluginProperty_OrthancExplorer; | |
3395 params.value = javascript; | |
3396 | |
3397 context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); | |
3398 } | |
3399 | |
3400 | |
3401 typedef struct | |
3402 { | |
3403 char** result; | |
3404 int32_t property; | |
3405 const char* value; | |
3406 } _OrthancPluginGlobalProperty; | |
3407 | |
3408 | |
3409 /** | |
3410 * @brief Get the value of a global property. | |
3411 * | |
3412 * Get the value of a global property that is stored in the Orthanc database. Global | |
3413 * properties whose index is below 1024 are reserved by Orthanc. | |
3414 * | |
3415 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3416 * @param property The global property of interest. | |
3417 * @param defaultValue The value to return, if the global property is unset. | |
3418 * @return The value of the global property, or NULL in the case of an error. This | |
3419 * string must be freed by OrthancPluginFreeString(). | |
3420 * @ingroup Orthanc | |
3421 **/ | |
3422 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetGlobalProperty( | |
3423 OrthancPluginContext* context, | |
3424 int32_t property, | |
3425 const char* defaultValue) | |
3426 { | |
3427 char* result; | |
3428 | |
3429 _OrthancPluginGlobalProperty params; | |
3430 params.result = &result; | |
3431 params.property = property; | |
3432 params.value = defaultValue; | |
3433 | |
3434 if (context->InvokeService(context, _OrthancPluginService_GetGlobalProperty, ¶ms) != OrthancPluginErrorCode_Success) | |
3435 { | |
3436 /* Error */ | |
3437 return NULL; | |
3438 } | |
3439 else | |
3440 { | |
3441 return result; | |
3442 } | |
3443 } | |
3444 | |
3445 | |
3446 /** | |
3447 * @brief Set the value of a global property. | |
3448 * | |
3449 * Set the value of a global property into the Orthanc | |
3450 * database. Setting a global property can be used by plugins to | |
3451 * save their internal parameters. Plugins are only allowed to set | |
3452 * properties whose index are above or equal to 1024 (properties | |
3453 * below 1024 are read-only and reserved by Orthanc). | |
3454 * | |
3455 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3456 * @param property The global property of interest. | |
3457 * @param value The value to be set in the global property. | |
3458 * @return 0 if success, or the error code if failure. | |
3459 * @ingroup Orthanc | |
3460 **/ | |
3461 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSetGlobalProperty( | |
3462 OrthancPluginContext* context, | |
3463 int32_t property, | |
3464 const char* value) | |
3465 { | |
3466 _OrthancPluginGlobalProperty params; | |
3467 params.result = NULL; | |
3468 params.property = property; | |
3469 params.value = value; | |
3470 | |
3471 return context->InvokeService(context, _OrthancPluginService_SetGlobalProperty, ¶ms); | |
3472 } | |
3473 | |
3474 | |
3475 | |
3476 typedef struct | |
3477 { | |
3478 int32_t *resultInt32; | |
3479 uint32_t *resultUint32; | |
3480 int64_t *resultInt64; | |
3481 uint64_t *resultUint64; | |
3482 } _OrthancPluginReturnSingleValue; | |
3483 | |
3484 /** | |
3485 * @brief Get the number of command-line arguments. | |
3486 * | |
3487 * Retrieve the number of command-line arguments that were used to launch Orthanc. | |
3488 * | |
3489 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3490 * @return The number of arguments. | |
3491 **/ | |
3492 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetCommandLineArgumentsCount( | |
3493 OrthancPluginContext* context) | |
3494 { | |
3495 uint32_t count = 0; | |
3496 | |
3497 _OrthancPluginReturnSingleValue params; | |
3498 memset(¶ms, 0, sizeof(params)); | |
3499 params.resultUint32 = &count; | |
3500 | |
3501 if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgumentsCount, ¶ms) != OrthancPluginErrorCode_Success) | |
3502 { | |
3503 /* Error */ | |
3504 return 0; | |
3505 } | |
3506 else | |
3507 { | |
3508 return count; | |
3509 } | |
3510 } | |
3511 | |
3512 | |
3513 | |
3514 /** | |
3515 * @brief Get the value of a command-line argument. | |
3516 * | |
3517 * Get the value of one of the command-line arguments that were used | |
3518 * to launch Orthanc. The number of available arguments can be | |
3519 * retrieved by OrthancPluginGetCommandLineArgumentsCount(). | |
3520 * | |
3521 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3522 * @param argument The index of the argument. | |
3523 * @return The value of the argument, or NULL in the case of an error. This | |
3524 * string must be freed by OrthancPluginFreeString(). | |
3525 **/ | |
3526 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetCommandLineArgument( | |
3527 OrthancPluginContext* context, | |
3528 uint32_t argument) | |
3529 { | |
3530 char* result; | |
3531 | |
3532 _OrthancPluginGlobalProperty params; | |
3533 params.result = &result; | |
3534 params.property = (int32_t) argument; | |
3535 params.value = NULL; | |
3536 | |
3537 if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgument, ¶ms) != OrthancPluginErrorCode_Success) | |
3538 { | |
3539 /* Error */ | |
3540 return NULL; | |
3541 } | |
3542 else | |
3543 { | |
3544 return result; | |
3545 } | |
3546 } | |
3547 | |
3548 | |
3549 /** | |
3550 * @brief Get the expected version of the database schema. | |
3551 * | |
3552 * Retrieve the expected version of the database schema. | |
3553 * | |
3554 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3555 * @return The version. | |
3556 * @ingroup Callbacks | |
3557 **/ | |
3558 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetExpectedDatabaseVersion( | |
3559 OrthancPluginContext* context) | |
3560 { | |
3561 uint32_t count = 0; | |
3562 | |
3563 _OrthancPluginReturnSingleValue params; | |
3564 memset(¶ms, 0, sizeof(params)); | |
3565 params.resultUint32 = &count; | |
3566 | |
3567 if (context->InvokeService(context, _OrthancPluginService_GetExpectedDatabaseVersion, ¶ms) != OrthancPluginErrorCode_Success) | |
3568 { | |
3569 /* Error */ | |
3570 return 0; | |
3571 } | |
3572 else | |
3573 { | |
3574 return count; | |
3575 } | |
3576 } | |
3577 | |
3578 | |
3579 | |
3580 /** | |
3581 * @brief Return the content of the configuration file(s). | |
3582 * | |
3583 * This function returns the content of the configuration that is | |
3584 * used by Orthanc, formatted as a JSON string. | |
3585 * | |
3586 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3587 * @return NULL in the case of an error, or a newly allocated string | |
3588 * containing the configuration. This string must be freed by | |
3589 * OrthancPluginFreeString(). | |
3590 **/ | |
3591 ORTHANC_PLUGIN_INLINE char *OrthancPluginGetConfiguration(OrthancPluginContext* context) | |
3592 { | |
3593 char* result; | |
3594 | |
3595 _OrthancPluginRetrieveDynamicString params; | |
3596 params.result = &result; | |
3597 params.argument = NULL; | |
3598 | |
3599 if (context->InvokeService(context, _OrthancPluginService_GetConfiguration, ¶ms) != OrthancPluginErrorCode_Success) | |
3600 { | |
3601 /* Error */ | |
3602 return NULL; | |
3603 } | |
3604 else | |
3605 { | |
3606 return result; | |
3607 } | |
3608 } | |
3609 | |
3610 | |
3611 | |
3612 typedef struct | |
3613 { | |
3614 OrthancPluginRestOutput* output; | |
3615 const char* subType; | |
3616 const char* contentType; | |
3617 } _OrthancPluginStartMultipartAnswer; | |
3618 | |
3619 /** | |
3620 * @brief Start an HTTP multipart answer. | |
3621 * | |
3622 * Initiates a HTTP multipart answer, as the result of a REST request. | |
3623 * | |
3624 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3625 * @param output The HTTP connection to the client application. | |
3626 * @param subType The sub-type of the multipart answer ("mixed" or "related"). | |
3627 * @param contentType The MIME type of the items in the multipart answer. | |
3628 * @return 0 if success, or the error code if failure. | |
3629 * @see OrthancPluginSendMultipartItem(), OrthancPluginSendMultipartItem2() | |
3630 * @ingroup REST | |
3631 **/ | |
3632 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStartMultipartAnswer( | |
3633 OrthancPluginContext* context, | |
3634 OrthancPluginRestOutput* output, | |
3635 const char* subType, | |
3636 const char* contentType) | |
3637 { | |
3638 _OrthancPluginStartMultipartAnswer params; | |
3639 params.output = output; | |
3640 params.subType = subType; | |
3641 params.contentType = contentType; | |
3642 return context->InvokeService(context, _OrthancPluginService_StartMultipartAnswer, ¶ms); | |
3643 } | |
3644 | |
3645 | |
3646 /** | |
3647 * @brief Send an item as a part of some HTTP multipart answer. | |
3648 * | |
3649 * This function sends an item as a part of some HTTP multipart | |
3650 * answer that was initiated by OrthancPluginStartMultipartAnswer(). | |
3651 * | |
3652 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3653 * @param output The HTTP connection to the client application. | |
3654 * @param answer Pointer to the memory buffer containing the item. | |
3655 * @param answerSize Number of bytes of the item. | |
3656 * @return 0 if success, or the error code if failure (this notably happens | |
3657 * if the connection is closed by the client). | |
3658 * @see OrthancPluginSendMultipartItem2() | |
3659 * @ingroup REST | |
3660 **/ | |
3661 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSendMultipartItem( | |
3662 OrthancPluginContext* context, | |
3663 OrthancPluginRestOutput* output, | |
3664 const void* answer, | |
3665 uint32_t answerSize) | |
3666 { | |
3667 _OrthancPluginAnswerBuffer params; | |
3668 params.output = output; | |
3669 params.answer = answer; | |
3670 params.answerSize = answerSize; | |
3671 params.mimeType = NULL; | |
3672 return context->InvokeService(context, _OrthancPluginService_SendMultipartItem, ¶ms); | |
3673 } | |
3674 | |
3675 | |
3676 | |
3677 typedef struct | |
3678 { | |
3679 OrthancPluginMemoryBuffer* target; | |
3680 const void* source; | |
3681 uint32_t size; | |
3682 OrthancPluginCompressionType compression; | |
3683 uint8_t uncompress; | |
3684 } _OrthancPluginBufferCompression; | |
3685 | |
3686 | |
3687 /** | |
3688 * @brief Compress or decompress a buffer. | |
3689 * | |
3690 * This function compresses or decompresses a buffer, using the | |
3691 * version of the zlib library that is used by the Orthanc core. | |
3692 * | |
3693 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3694 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
3695 * @param source The source buffer. | |
3696 * @param size The size in bytes of the source buffer. | |
3697 * @param compression The compression algorithm. | |
3698 * @param uncompress If set to "0", the buffer must be compressed. | |
3699 * If set to "1", the buffer must be uncompressed. | |
3700 * @return 0 if success, or the error code if failure. | |
3701 * @ingroup Images | |
3702 **/ | |
3703 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginBufferCompression( | |
3704 OrthancPluginContext* context, | |
3705 OrthancPluginMemoryBuffer* target, | |
3706 const void* source, | |
3707 uint32_t size, | |
3708 OrthancPluginCompressionType compression, | |
3709 uint8_t uncompress) | |
3710 { | |
3711 _OrthancPluginBufferCompression params; | |
3712 params.target = target; | |
3713 params.source = source; | |
3714 params.size = size; | |
3715 params.compression = compression; | |
3716 params.uncompress = uncompress; | |
3717 | |
3718 return context->InvokeService(context, _OrthancPluginService_BufferCompression, ¶ms); | |
3719 } | |
3720 | |
3721 | |
3722 | |
3723 typedef struct | |
3724 { | |
3725 OrthancPluginMemoryBuffer* target; | |
3726 const char* path; | |
3727 } _OrthancPluginReadFile; | |
3728 | |
3729 /** | |
3730 * @brief Read a file. | |
3731 * | |
3732 * Read the content of a file on the filesystem, and returns it into | |
3733 * a newly allocated memory buffer. | |
3734 * | |
3735 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3736 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
3737 * @param path The path of the file to be read. | |
3738 * @return 0 if success, or the error code if failure. | |
3739 **/ | |
3740 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginReadFile( | |
3741 OrthancPluginContext* context, | |
3742 OrthancPluginMemoryBuffer* target, | |
3743 const char* path) | |
3744 { | |
3745 _OrthancPluginReadFile params; | |
3746 params.target = target; | |
3747 params.path = path; | |
3748 return context->InvokeService(context, _OrthancPluginService_ReadFile, ¶ms); | |
3749 } | |
3750 | |
3751 | |
3752 | |
3753 typedef struct | |
3754 { | |
3755 const char* path; | |
3756 const void* data; | |
3757 uint32_t size; | |
3758 } _OrthancPluginWriteFile; | |
3759 | |
3760 /** | |
3761 * @brief Write a file. | |
3762 * | |
3763 * Write the content of a memory buffer to the filesystem. | |
3764 * | |
3765 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3766 * @param path The path of the file to be written. | |
3767 * @param data The content of the memory buffer. | |
3768 * @param size The size of the memory buffer. | |
3769 * @return 0 if success, or the error code if failure. | |
3770 **/ | |
3771 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWriteFile( | |
3772 OrthancPluginContext* context, | |
3773 const char* path, | |
3774 const void* data, | |
3775 uint32_t size) | |
3776 { | |
3777 _OrthancPluginWriteFile params; | |
3778 params.path = path; | |
3779 params.data = data; | |
3780 params.size = size; | |
3781 return context->InvokeService(context, _OrthancPluginService_WriteFile, ¶ms); | |
3782 } | |
3783 | |
3784 | |
3785 | |
3786 typedef struct | |
3787 { | |
3788 const char** target; | |
3789 OrthancPluginErrorCode error; | |
3790 } _OrthancPluginGetErrorDescription; | |
3791 | |
3792 /** | |
3793 * @brief Get the description of a given error code. | |
3794 * | |
3795 * This function returns the description of a given error code. | |
3796 * | |
3797 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3798 * @param error The error code of interest. | |
3799 * @return The error description. This is a statically-allocated | |
3800 * string, do not free it. | |
3801 **/ | |
3802 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetErrorDescription( | |
3803 OrthancPluginContext* context, | |
3804 OrthancPluginErrorCode error) | |
3805 { | |
3806 const char* result = NULL; | |
3807 | |
3808 _OrthancPluginGetErrorDescription params; | |
3809 params.target = &result; | |
3810 params.error = error; | |
3811 | |
3812 if (context->InvokeService(context, _OrthancPluginService_GetErrorDescription, ¶ms) != OrthancPluginErrorCode_Success || | |
3813 result == NULL) | |
3814 { | |
3815 return "Unknown error code"; | |
3816 } | |
3817 else | |
3818 { | |
3819 return result; | |
3820 } | |
3821 } | |
3822 | |
3823 | |
3824 | |
3825 typedef struct | |
3826 { | |
3827 OrthancPluginRestOutput* output; | |
3828 uint16_t status; | |
3829 const char* body; | |
3830 uint32_t bodySize; | |
3831 } _OrthancPluginSendHttpStatus; | |
3832 | |
3833 /** | |
3834 * @brief Send a HTTP status, with a custom body. | |
3835 * | |
3836 * This function answers to a HTTP request by sending a HTTP status | |
3837 * code (such as "400 - Bad Request"), together with a body | |
3838 * describing the error. The body will only be returned if the | |
3839 * configuration option "HttpDescribeErrors" of Orthanc is set to "true". | |
3840 * | |
3841 * Note that: | |
3842 * - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). | |
3843 * - Redirections (status 301) must use ::OrthancPluginRedirect(). | |
3844 * - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). | |
3845 * - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed(). | |
3846 * | |
3847 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3848 * @param output The HTTP connection to the client application. | |
3849 * @param status The HTTP status code to be sent. | |
3850 * @param body The body of the answer. | |
3851 * @param bodySize The size of the body. | |
3852 * @see OrthancPluginSendHttpStatusCode() | |
3853 * @ingroup REST | |
3854 **/ | |
3855 ORTHANC_PLUGIN_INLINE void OrthancPluginSendHttpStatus( | |
3856 OrthancPluginContext* context, | |
3857 OrthancPluginRestOutput* output, | |
3858 uint16_t status, | |
3859 const char* body, | |
3860 uint32_t bodySize) | |
3861 { | |
3862 _OrthancPluginSendHttpStatus params; | |
3863 params.output = output; | |
3864 params.status = status; | |
3865 params.body = body; | |
3866 params.bodySize = bodySize; | |
3867 context->InvokeService(context, _OrthancPluginService_SendHttpStatus, ¶ms); | |
3868 } | |
3869 | |
3870 | |
3871 | |
3872 typedef struct | |
3873 { | |
3874 const OrthancPluginImage* image; | |
3875 uint32_t* resultUint32; | |
3876 OrthancPluginPixelFormat* resultPixelFormat; | |
3877 void** resultBuffer; | |
3878 } _OrthancPluginGetImageInfo; | |
3879 | |
3880 | |
3881 /** | |
3882 * @brief Return the pixel format of an image. | |
3883 * | |
3884 * This function returns the type of memory layout for the pixels of the given image. | |
3885 * | |
3886 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3887 * @param image The image of interest. | |
3888 * @return The pixel format. | |
3889 * @ingroup Images | |
3890 **/ | |
3891 ORTHANC_PLUGIN_INLINE OrthancPluginPixelFormat OrthancPluginGetImagePixelFormat( | |
3892 OrthancPluginContext* context, | |
3893 const OrthancPluginImage* image) | |
3894 { | |
3895 OrthancPluginPixelFormat target; | |
3896 | |
3897 _OrthancPluginGetImageInfo params; | |
3898 memset(¶ms, 0, sizeof(params)); | |
3899 params.image = image; | |
3900 params.resultPixelFormat = ⌖ | |
3901 | |
3902 if (context->InvokeService(context, _OrthancPluginService_GetImagePixelFormat, ¶ms) != OrthancPluginErrorCode_Success) | |
3903 { | |
3904 return OrthancPluginPixelFormat_Unknown; | |
3905 } | |
3906 else | |
3907 { | |
3908 return (OrthancPluginPixelFormat) target; | |
3909 } | |
3910 } | |
3911 | |
3912 | |
3913 | |
3914 /** | |
3915 * @brief Return the width of an image. | |
3916 * | |
3917 * This function returns the width of the given image. | |
3918 * | |
3919 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3920 * @param image The image of interest. | |
3921 * @return The width. | |
3922 * @ingroup Images | |
3923 **/ | |
3924 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImageWidth( | |
3925 OrthancPluginContext* context, | |
3926 const OrthancPluginImage* image) | |
3927 { | |
3928 uint32_t width; | |
3929 | |
3930 _OrthancPluginGetImageInfo params; | |
3931 memset(¶ms, 0, sizeof(params)); | |
3932 params.image = image; | |
3933 params.resultUint32 = &width; | |
3934 | |
3935 if (context->InvokeService(context, _OrthancPluginService_GetImageWidth, ¶ms) != OrthancPluginErrorCode_Success) | |
3936 { | |
3937 return 0; | |
3938 } | |
3939 else | |
3940 { | |
3941 return width; | |
3942 } | |
3943 } | |
3944 | |
3945 | |
3946 | |
3947 /** | |
3948 * @brief Return the height of an image. | |
3949 * | |
3950 * This function returns the height of the given image. | |
3951 * | |
3952 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3953 * @param image The image of interest. | |
3954 * @return The height. | |
3955 * @ingroup Images | |
3956 **/ | |
3957 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImageHeight( | |
3958 OrthancPluginContext* context, | |
3959 const OrthancPluginImage* image) | |
3960 { | |
3961 uint32_t height; | |
3962 | |
3963 _OrthancPluginGetImageInfo params; | |
3964 memset(¶ms, 0, sizeof(params)); | |
3965 params.image = image; | |
3966 params.resultUint32 = &height; | |
3967 | |
3968 if (context->InvokeService(context, _OrthancPluginService_GetImageHeight, ¶ms) != OrthancPluginErrorCode_Success) | |
3969 { | |
3970 return 0; | |
3971 } | |
3972 else | |
3973 { | |
3974 return height; | |
3975 } | |
3976 } | |
3977 | |
3978 | |
3979 | |
3980 /** | |
3981 * @brief Return the pitch of an image. | |
3982 * | |
3983 * This function returns the pitch of the given image. The pitch is | |
3984 * defined as the number of bytes between 2 successive lines of the | |
3985 * image in the memory buffer. | |
3986 * | |
3987 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3988 * @param image The image of interest. | |
3989 * @return The pitch. | |
3990 * @ingroup Images | |
3991 **/ | |
3992 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImagePitch( | |
3993 OrthancPluginContext* context, | |
3994 const OrthancPluginImage* image) | |
3995 { | |
3996 uint32_t pitch; | |
3997 | |
3998 _OrthancPluginGetImageInfo params; | |
3999 memset(¶ms, 0, sizeof(params)); | |
4000 params.image = image; | |
4001 params.resultUint32 = &pitch; | |
4002 | |
4003 if (context->InvokeService(context, _OrthancPluginService_GetImagePitch, ¶ms) != OrthancPluginErrorCode_Success) | |
4004 { | |
4005 return 0; | |
4006 } | |
4007 else | |
4008 { | |
4009 return pitch; | |
4010 } | |
4011 } | |
4012 | |
4013 | |
4014 | |
4015 /** | |
4016 * @brief Return a pointer to the content of an image. | |
4017 * | |
4018 * This function returns a pointer to the memory buffer that | |
4019 * contains the pixels of the image. | |
4020 * | |
4021 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4022 * @param image The image of interest. | |
4023 * @return The pointer. | |
4024 * @ingroup Images | |
4025 **/ | |
4026 ORTHANC_PLUGIN_INLINE void* OrthancPluginGetImageBuffer( | |
4027 OrthancPluginContext* context, | |
4028 const OrthancPluginImage* image) | |
4029 { | |
4030 void* target = NULL; | |
4031 | |
4032 _OrthancPluginGetImageInfo params; | |
4033 memset(¶ms, 0, sizeof(params)); | |
4034 params.resultBuffer = ⌖ | |
4035 params.image = image; | |
4036 | |
4037 if (context->InvokeService(context, _OrthancPluginService_GetImageBuffer, ¶ms) != OrthancPluginErrorCode_Success) | |
4038 { | |
4039 return NULL; | |
4040 } | |
4041 else | |
4042 { | |
4043 return target; | |
4044 } | |
4045 } | |
4046 | |
4047 | |
4048 typedef struct | |
4049 { | |
4050 OrthancPluginImage** target; | |
4051 const void* data; | |
4052 uint32_t size; | |
4053 OrthancPluginImageFormat format; | |
4054 } _OrthancPluginUncompressImage; | |
4055 | |
4056 | |
4057 /** | |
4058 * @brief Decode a compressed image. | |
4059 * | |
4060 * This function decodes a compressed image from a memory buffer. | |
4061 * | |
4062 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4063 * @param data Pointer to a memory buffer containing the compressed image. | |
4064 * @param size Size of the memory buffer containing the compressed image. | |
4065 * @param format The file format of the compressed image. | |
4066 * @return The uncompressed image. It must be freed with OrthancPluginFreeImage(). | |
4067 * @ingroup Images | |
4068 **/ | |
4069 ORTHANC_PLUGIN_INLINE OrthancPluginImage *OrthancPluginUncompressImage( | |
4070 OrthancPluginContext* context, | |
4071 const void* data, | |
4072 uint32_t size, | |
4073 OrthancPluginImageFormat format) | |
4074 { | |
4075 OrthancPluginImage* target = NULL; | |
4076 | |
4077 _OrthancPluginUncompressImage params; | |
4078 memset(¶ms, 0, sizeof(params)); | |
4079 params.target = ⌖ | |
4080 params.data = data; | |
4081 params.size = size; | |
4082 params.format = format; | |
4083 | |
4084 if (context->InvokeService(context, _OrthancPluginService_UncompressImage, ¶ms) != OrthancPluginErrorCode_Success) | |
4085 { | |
4086 return NULL; | |
4087 } | |
4088 else | |
4089 { | |
4090 return target; | |
4091 } | |
4092 } | |
4093 | |
4094 | |
4095 | |
4096 | |
4097 typedef struct | |
4098 { | |
4099 OrthancPluginImage* image; | |
4100 } _OrthancPluginFreeImage; | |
4101 | |
4102 /** | |
4103 * @brief Free an image. | |
4104 * | |
4105 * This function frees an image that was decoded with OrthancPluginUncompressImage(). | |
4106 * | |
4107 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4108 * @param image The image. | |
4109 * @ingroup Images | |
4110 **/ | |
4111 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeImage( | |
4112 OrthancPluginContext* context, | |
4113 OrthancPluginImage* image) | |
4114 { | |
4115 _OrthancPluginFreeImage params; | |
4116 params.image = image; | |
4117 | |
4118 context->InvokeService(context, _OrthancPluginService_FreeImage, ¶ms); | |
4119 } | |
4120 | |
4121 | |
4122 | |
4123 | |
4124 typedef struct | |
4125 { | |
4126 OrthancPluginMemoryBuffer* target; | |
4127 OrthancPluginImageFormat imageFormat; | |
4128 OrthancPluginPixelFormat pixelFormat; | |
4129 uint32_t width; | |
4130 uint32_t height; | |
4131 uint32_t pitch; | |
4132 const void* buffer; | |
4133 uint8_t quality; | |
4134 } _OrthancPluginCompressImage; | |
4135 | |
4136 | |
4137 /** | |
4138 * @brief Encode a PNG image. | |
4139 * | |
4140 * This function compresses the given memory buffer containing an | |
4141 * image using the PNG specification, and stores the result of the | |
4142 * compression into a newly allocated memory buffer. | |
4143 * | |
4144 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4145 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
4146 * @param format The memory layout of the uncompressed image. | |
4147 * @param width The width of the image. | |
4148 * @param height The height of the image. | |
4149 * @param pitch The pitch of the image (i.e. the number of bytes | |
4150 * between 2 successive lines of the image in the memory buffer). | |
4151 * @param buffer The memory buffer containing the uncompressed image. | |
4152 * @return 0 if success, or the error code if failure. | |
4153 * @see OrthancPluginCompressAndAnswerPngImage() | |
4154 * @ingroup Images | |
4155 **/ | |
4156 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCompressPngImage( | |
4157 OrthancPluginContext* context, | |
4158 OrthancPluginMemoryBuffer* target, | |
4159 OrthancPluginPixelFormat format, | |
4160 uint32_t width, | |
4161 uint32_t height, | |
4162 uint32_t pitch, | |
4163 const void* buffer) | |
4164 { | |
4165 _OrthancPluginCompressImage params; | |
4166 memset(¶ms, 0, sizeof(params)); | |
4167 params.target = target; | |
4168 params.imageFormat = OrthancPluginImageFormat_Png; | |
4169 params.pixelFormat = format; | |
4170 params.width = width; | |
4171 params.height = height; | |
4172 params.pitch = pitch; | |
4173 params.buffer = buffer; | |
4174 params.quality = 0; /* Unused for PNG */ | |
4175 | |
4176 return context->InvokeService(context, _OrthancPluginService_CompressImage, ¶ms); | |
4177 } | |
4178 | |
4179 | |
4180 /** | |
4181 * @brief Encode a JPEG image. | |
4182 * | |
4183 * This function compresses the given memory buffer containing an | |
4184 * image using the JPEG specification, and stores the result of the | |
4185 * compression into a newly allocated memory buffer. | |
4186 * | |
4187 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4188 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
4189 * @param format The memory layout of the uncompressed image. | |
4190 * @param width The width of the image. | |
4191 * @param height The height of the image. | |
4192 * @param pitch The pitch of the image (i.e. the number of bytes | |
4193 * between 2 successive lines of the image in the memory buffer). | |
4194 * @param buffer The memory buffer containing the uncompressed image. | |
4195 * @param quality The quality of the JPEG encoding, between 1 (worst | |
4196 * quality, best compression) and 100 (best quality, worst | |
4197 * compression). | |
4198 * @return 0 if success, or the error code if failure. | |
4199 * @ingroup Images | |
4200 **/ | |
4201 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCompressJpegImage( | |
4202 OrthancPluginContext* context, | |
4203 OrthancPluginMemoryBuffer* target, | |
4204 OrthancPluginPixelFormat format, | |
4205 uint32_t width, | |
4206 uint32_t height, | |
4207 uint32_t pitch, | |
4208 const void* buffer, | |
4209 uint8_t quality) | |
4210 { | |
4211 _OrthancPluginCompressImage params; | |
4212 memset(¶ms, 0, sizeof(params)); | |
4213 params.target = target; | |
4214 params.imageFormat = OrthancPluginImageFormat_Jpeg; | |
4215 params.pixelFormat = format; | |
4216 params.width = width; | |
4217 params.height = height; | |
4218 params.pitch = pitch; | |
4219 params.buffer = buffer; | |
4220 params.quality = quality; | |
4221 | |
4222 return context->InvokeService(context, _OrthancPluginService_CompressImage, ¶ms); | |
4223 } | |
4224 | |
4225 | |
4226 | |
4227 /** | |
4228 * @brief Answer to a REST request with a JPEG image. | |
4229 * | |
4230 * This function answers to a REST request with a JPEG image. The | |
4231 * parameters of this function describe a memory buffer that | |
4232 * contains an uncompressed image. The image will be automatically compressed | |
4233 * as a JPEG image by the core system of Orthanc. | |
4234 * | |
4235 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4236 * @param output The HTTP connection to the client application. | |
4237 * @param format The memory layout of the uncompressed image. | |
4238 * @param width The width of the image. | |
4239 * @param height The height of the image. | |
4240 * @param pitch The pitch of the image (i.e. the number of bytes | |
4241 * between 2 successive lines of the image in the memory buffer). | |
4242 * @param buffer The memory buffer containing the uncompressed image. | |
4243 * @param quality The quality of the JPEG encoding, between 1 (worst | |
4244 * quality, best compression) and 100 (best quality, worst | |
4245 * compression). | |
4246 * @ingroup REST | |
4247 **/ | |
4248 ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerJpegImage( | |
4249 OrthancPluginContext* context, | |
4250 OrthancPluginRestOutput* output, | |
4251 OrthancPluginPixelFormat format, | |
4252 uint32_t width, | |
4253 uint32_t height, | |
4254 uint32_t pitch, | |
4255 const void* buffer, | |
4256 uint8_t quality) | |
4257 { | |
4258 _OrthancPluginCompressAndAnswerImage params; | |
4259 params.output = output; | |
4260 params.imageFormat = OrthancPluginImageFormat_Jpeg; | |
4261 params.pixelFormat = format; | |
4262 params.width = width; | |
4263 params.height = height; | |
4264 params.pitch = pitch; | |
4265 params.buffer = buffer; | |
4266 params.quality = quality; | |
4267 context->InvokeService(context, _OrthancPluginService_CompressAndAnswerImage, ¶ms); | |
4268 } | |
4269 | |
4270 | |
4271 | |
4272 | |
4273 typedef struct | |
4274 { | |
4275 OrthancPluginMemoryBuffer* target; | |
4276 OrthancPluginHttpMethod method; | |
4277 const char* url; | |
4278 const char* username; | |
4279 const char* password; | |
4280 const void* body; | |
4281 uint32_t bodySize; | |
4282 } _OrthancPluginCallHttpClient; | |
4283 | |
4284 | |
4285 /** | |
4286 * @brief Issue a HTTP GET call. | |
4287 * | |
4288 * Make a HTTP GET call to the given URL. The result to the query is | |
4289 * stored into a newly allocated memory buffer. Favor | |
4290 * OrthancPluginRestApiGet() if calling the built-in REST API of the | |
4291 * Orthanc instance that hosts this plugin. | |
4292 * | |
4293 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4294 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
4295 * @param url The URL of interest. | |
4296 * @param username The username (can be <tt>NULL</tt> if no password protection). | |
4297 * @param password The password (can be <tt>NULL</tt> if no password protection). | |
4298 * @return 0 if success, or the error code if failure. | |
4299 * @ingroup Toolbox | |
4300 **/ | |
4301 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpGet( | |
4302 OrthancPluginContext* context, | |
4303 OrthancPluginMemoryBuffer* target, | |
4304 const char* url, | |
4305 const char* username, | |
4306 const char* password) | |
4307 { | |
4308 _OrthancPluginCallHttpClient params; | |
4309 memset(¶ms, 0, sizeof(params)); | |
4310 | |
4311 params.target = target; | |
4312 params.method = OrthancPluginHttpMethod_Get; | |
4313 params.url = url; | |
4314 params.username = username; | |
4315 params.password = password; | |
4316 | |
4317 return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); | |
4318 } | |
4319 | |
4320 | |
4321 /** | |
4322 * @brief Issue a HTTP POST call. | |
4323 * | |
4324 * Make a HTTP POST call to the given URL. The result to the query | |
4325 * is stored into a newly allocated memory buffer. Favor | |
4326 * OrthancPluginRestApiPost() if calling the built-in REST API of | |
4327 * the Orthanc instance that hosts this plugin. | |
4328 * | |
4329 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4330 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
4331 * @param url The URL of interest. | |
4332 * @param body The content of the body of the request. | |
4333 * @param bodySize The size of the body of the request. | |
4334 * @param username The username (can be <tt>NULL</tt> if no password protection). | |
4335 * @param password The password (can be <tt>NULL</tt> if no password protection). | |
4336 * @return 0 if success, or the error code if failure. | |
4337 * @ingroup Toolbox | |
4338 **/ | |
4339 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpPost( | |
4340 OrthancPluginContext* context, | |
4341 OrthancPluginMemoryBuffer* target, | |
4342 const char* url, | |
4343 const void* body, | |
4344 uint32_t bodySize, | |
4345 const char* username, | |
4346 const char* password) | |
4347 { | |
4348 _OrthancPluginCallHttpClient params; | |
4349 memset(¶ms, 0, sizeof(params)); | |
4350 | |
4351 params.target = target; | |
4352 params.method = OrthancPluginHttpMethod_Post; | |
4353 params.url = url; | |
4354 params.body = body; | |
4355 params.bodySize = bodySize; | |
4356 params.username = username; | |
4357 params.password = password; | |
4358 | |
4359 return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); | |
4360 } | |
4361 | |
4362 | |
4363 /** | |
4364 * @brief Issue a HTTP PUT call. | |
4365 * | |
4366 * Make a HTTP PUT call to the given URL. The result to the query is | |
4367 * stored into a newly allocated memory buffer. Favor | |
4368 * OrthancPluginRestApiPut() if calling the built-in REST API of the | |
4369 * Orthanc instance that hosts this plugin. | |
4370 * | |
4371 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4372 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
4373 * @param url The URL of interest. | |
4374 * @param body The content of the body of the request. | |
4375 * @param bodySize The size of the body of the request. | |
4376 * @param username The username (can be <tt>NULL</tt> if no password protection). | |
4377 * @param password The password (can be <tt>NULL</tt> if no password protection). | |
4378 * @return 0 if success, or the error code if failure. | |
4379 * @ingroup Toolbox | |
4380 **/ | |
4381 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpPut( | |
4382 OrthancPluginContext* context, | |
4383 OrthancPluginMemoryBuffer* target, | |
4384 const char* url, | |
4385 const void* body, | |
4386 uint32_t bodySize, | |
4387 const char* username, | |
4388 const char* password) | |
4389 { | |
4390 _OrthancPluginCallHttpClient params; | |
4391 memset(¶ms, 0, sizeof(params)); | |
4392 | |
4393 params.target = target; | |
4394 params.method = OrthancPluginHttpMethod_Put; | |
4395 params.url = url; | |
4396 params.body = body; | |
4397 params.bodySize = bodySize; | |
4398 params.username = username; | |
4399 params.password = password; | |
4400 | |
4401 return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); | |
4402 } | |
4403 | |
4404 | |
4405 /** | |
4406 * @brief Issue a HTTP DELETE call. | |
4407 * | |
4408 * Make a HTTP DELETE call to the given URL. Favor | |
4409 * OrthancPluginRestApiDelete() if calling the built-in REST API of | |
4410 * the Orthanc instance that hosts this plugin. | |
4411 * | |
4412 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4413 * @param url The URL of interest. | |
4414 * @param username The username (can be <tt>NULL</tt> if no password protection). | |
4415 * @param password The password (can be <tt>NULL</tt> if no password protection). | |
4416 * @return 0 if success, or the error code if failure. | |
4417 * @ingroup Toolbox | |
4418 **/ | |
4419 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpDelete( | |
4420 OrthancPluginContext* context, | |
4421 const char* url, | |
4422 const char* username, | |
4423 const char* password) | |
4424 { | |
4425 _OrthancPluginCallHttpClient params; | |
4426 memset(¶ms, 0, sizeof(params)); | |
4427 | |
4428 params.method = OrthancPluginHttpMethod_Delete; | |
4429 params.url = url; | |
4430 params.username = username; | |
4431 params.password = password; | |
4432 | |
4433 return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); | |
4434 } | |
4435 | |
4436 | |
4437 | |
4438 typedef struct | |
4439 { | |
4440 OrthancPluginImage** target; | |
4441 const OrthancPluginImage* source; | |
4442 OrthancPluginPixelFormat targetFormat; | |
4443 } _OrthancPluginConvertPixelFormat; | |
4444 | |
4445 | |
4446 /** | |
4447 * @brief Change the pixel format of an image. | |
4448 * | |
4449 * This function creates a new image, changing the memory layout of the pixels. | |
4450 * | |
4451 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4452 * @param source The source image. | |
4453 * @param targetFormat The target pixel format. | |
4454 * @return The resulting image. It must be freed with OrthancPluginFreeImage(). | |
4455 * @ingroup Images | |
4456 **/ | |
4457 ORTHANC_PLUGIN_INLINE OrthancPluginImage *OrthancPluginConvertPixelFormat( | |
4458 OrthancPluginContext* context, | |
4459 const OrthancPluginImage* source, | |
4460 OrthancPluginPixelFormat targetFormat) | |
4461 { | |
4462 OrthancPluginImage* target = NULL; | |
4463 | |
4464 _OrthancPluginConvertPixelFormat params; | |
4465 params.target = ⌖ | |
4466 params.source = source; | |
4467 params.targetFormat = targetFormat; | |
4468 | |
4469 if (context->InvokeService(context, _OrthancPluginService_ConvertPixelFormat, ¶ms) != OrthancPluginErrorCode_Success) | |
4470 { | |
4471 return NULL; | |
4472 } | |
4473 else | |
4474 { | |
4475 return target; | |
4476 } | |
4477 } | |
4478 | |
4479 | |
4480 | |
4481 /** | |
4482 * @brief Return the number of available fonts. | |
4483 * | |
4484 * This function returns the number of fonts that are built in the | |
4485 * Orthanc core. These fonts can be used to draw texts on images | |
4486 * through OrthancPluginDrawText(). | |
4487 * | |
4488 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4489 * @return The number of fonts. | |
4490 * @ingroup Images | |
4491 **/ | |
4492 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFontsCount( | |
4493 OrthancPluginContext* context) | |
4494 { | |
4495 uint32_t count = 0; | |
4496 | |
4497 _OrthancPluginReturnSingleValue params; | |
4498 memset(¶ms, 0, sizeof(params)); | |
4499 params.resultUint32 = &count; | |
4500 | |
4501 if (context->InvokeService(context, _OrthancPluginService_GetFontsCount, ¶ms) != OrthancPluginErrorCode_Success) | |
4502 { | |
4503 /* Error */ | |
4504 return 0; | |
4505 } | |
4506 else | |
4507 { | |
4508 return count; | |
4509 } | |
4510 } | |
4511 | |
4512 | |
4513 | |
4514 | |
4515 typedef struct | |
4516 { | |
4517 uint32_t fontIndex; /* in */ | |
4518 const char** name; /* out */ | |
4519 uint32_t* size; /* out */ | |
4520 } _OrthancPluginGetFontInfo; | |
4521 | |
4522 /** | |
4523 * @brief Return the name of a font. | |
4524 * | |
4525 * This function returns the name of a font that is built in the Orthanc core. | |
4526 * | |
4527 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4528 * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount(). | |
4529 * @return The font name. This is a statically-allocated string, do not free it. | |
4530 * @ingroup Images | |
4531 **/ | |
4532 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetFontName( | |
4533 OrthancPluginContext* context, | |
4534 uint32_t fontIndex) | |
4535 { | |
4536 const char* result = NULL; | |
4537 | |
4538 _OrthancPluginGetFontInfo params; | |
4539 memset(¶ms, 0, sizeof(params)); | |
4540 params.name = &result; | |
4541 params.fontIndex = fontIndex; | |
4542 | |
4543 if (context->InvokeService(context, _OrthancPluginService_GetFontInfo, ¶ms) != OrthancPluginErrorCode_Success) | |
4544 { | |
4545 return NULL; | |
4546 } | |
4547 else | |
4548 { | |
4549 return result; | |
4550 } | |
4551 } | |
4552 | |
4553 | |
4554 /** | |
4555 * @brief Return the size of a font. | |
4556 * | |
4557 * This function returns the size of a font that is built in the Orthanc core. | |
4558 * | |
4559 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4560 * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount(). | |
4561 * @return The font size. | |
4562 * @ingroup Images | |
4563 **/ | |
4564 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFontSize( | |
4565 OrthancPluginContext* context, | |
4566 uint32_t fontIndex) | |
4567 { | |
4568 uint32_t result; | |
4569 | |
4570 _OrthancPluginGetFontInfo params; | |
4571 memset(¶ms, 0, sizeof(params)); | |
4572 params.size = &result; | |
4573 params.fontIndex = fontIndex; | |
4574 | |
4575 if (context->InvokeService(context, _OrthancPluginService_GetFontInfo, ¶ms) != OrthancPluginErrorCode_Success) | |
4576 { | |
4577 return 0; | |
4578 } | |
4579 else | |
4580 { | |
4581 return result; | |
4582 } | |
4583 } | |
4584 | |
4585 | |
4586 | |
4587 typedef struct | |
4588 { | |
4589 OrthancPluginImage* image; | |
4590 uint32_t fontIndex; | |
4591 const char* utf8Text; | |
4592 int32_t x; | |
4593 int32_t y; | |
4594 uint8_t r; | |
4595 uint8_t g; | |
4596 uint8_t b; | |
4597 } _OrthancPluginDrawText; | |
4598 | |
4599 | |
4600 /** | |
4601 * @brief Draw text on an image. | |
4602 * | |
4603 * This function draws some text on some image. | |
4604 * | |
4605 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4606 * @param image The image upon which to draw the text. | |
4607 * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount(). | |
4608 * @param utf8Text The text to be drawn, encoded as an UTF-8 zero-terminated string. | |
4609 * @param x The X position of the text over the image. | |
4610 * @param y The Y position of the text over the image. | |
4611 * @param r The value of the red color channel of the text. | |
4612 * @param g The value of the green color channel of the text. | |
4613 * @param b The value of the blue color channel of the text. | |
4614 * @return 0 if success, other value if error. | |
4615 * @ingroup Images | |
4616 **/ | |
4617 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginDrawText( | |
4618 OrthancPluginContext* context, | |
4619 OrthancPluginImage* image, | |
4620 uint32_t fontIndex, | |
4621 const char* utf8Text, | |
4622 int32_t x, | |
4623 int32_t y, | |
4624 uint8_t r, | |
4625 uint8_t g, | |
4626 uint8_t b) | |
4627 { | |
4628 _OrthancPluginDrawText params; | |
4629 memset(¶ms, 0, sizeof(params)); | |
4630 params.image = image; | |
4631 params.fontIndex = fontIndex; | |
4632 params.utf8Text = utf8Text; | |
4633 params.x = x; | |
4634 params.y = y; | |
4635 params.r = r; | |
4636 params.g = g; | |
4637 params.b = b; | |
4638 | |
4639 return context->InvokeService(context, _OrthancPluginService_DrawText, ¶ms); | |
4640 } | |
4641 | |
4642 | |
4643 | |
4644 typedef struct | |
4645 { | |
4646 OrthancPluginStorageArea* storageArea; | |
4647 const char* uuid; | |
4648 const void* content; | |
4649 uint64_t size; | |
4650 OrthancPluginContentType type; | |
4651 } _OrthancPluginStorageAreaCreate; | |
4652 | |
4653 | |
4654 /** | |
4655 * @brief Create a file inside the storage area. | |
4656 * | |
4657 * This function creates a new file inside the storage area that is | |
4658 * currently used by Orthanc. | |
4659 * | |
4660 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4661 * @param storageArea The storage area. | |
4662 * @param uuid The identifier of the file to be created. | |
4663 * @param content The content to store in the newly created file. | |
4664 * @param size The size of the content. | |
4665 * @param type The type of the file content. | |
4666 * @return 0 if success, other value if error. | |
4667 * @ingroup Callbacks | |
4668 * @deprecated This function should not be used anymore. Use "OrthancPluginRestApiPut()" on | |
4669 * "/{patients|studies|series|instances}/{id}/attachments/{name}" instead. | |
4670 **/ | |
4671 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaCreate( | |
4672 OrthancPluginContext* context, | |
4673 OrthancPluginStorageArea* storageArea, | |
4674 const char* uuid, | |
4675 const void* content, | |
4676 uint64_t size, | |
4677 OrthancPluginContentType type) | |
4678 { | |
4679 _OrthancPluginStorageAreaCreate params; | |
4680 params.storageArea = storageArea; | |
4681 params.uuid = uuid; | |
4682 params.content = content; | |
4683 params.size = size; | |
4684 params.type = type; | |
4685 | |
4686 return context->InvokeService(context, _OrthancPluginService_StorageAreaCreate, ¶ms); | |
4687 } | |
4688 | |
4689 | |
4690 typedef struct | |
4691 { | |
4692 OrthancPluginMemoryBuffer* target; | |
4693 OrthancPluginStorageArea* storageArea; | |
4694 const char* uuid; | |
4695 OrthancPluginContentType type; | |
4696 } _OrthancPluginStorageAreaRead; | |
4697 | |
4698 | |
4699 /** | |
4700 * @brief Read a file from the storage area. | |
4701 * | |
4702 * This function reads the content of a given file from the storage | |
4703 * area that is currently used by Orthanc. | |
4704 * | |
4705 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4706 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
4707 * @param storageArea The storage area. | |
4708 * @param uuid The identifier of the file to be read. | |
4709 * @param type The type of the file content. | |
4710 * @return 0 if success, other value if error. | |
4711 * @ingroup Callbacks | |
4712 * @deprecated This function should not be used anymore. Use "OrthancPluginRestApiGet()" on | |
4713 * "/{patients|studies|series|instances}/{id}/attachments/{name}" instead. | |
4714 **/ | |
4715 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaRead( | |
4716 OrthancPluginContext* context, | |
4717 OrthancPluginMemoryBuffer* target, | |
4718 OrthancPluginStorageArea* storageArea, | |
4719 const char* uuid, | |
4720 OrthancPluginContentType type) | |
4721 { | |
4722 _OrthancPluginStorageAreaRead params; | |
4723 params.target = target; | |
4724 params.storageArea = storageArea; | |
4725 params.uuid = uuid; | |
4726 params.type = type; | |
4727 | |
4728 return context->InvokeService(context, _OrthancPluginService_StorageAreaRead, ¶ms); | |
4729 } | |
4730 | |
4731 | |
4732 typedef struct | |
4733 { | |
4734 OrthancPluginStorageArea* storageArea; | |
4735 const char* uuid; | |
4736 OrthancPluginContentType type; | |
4737 } _OrthancPluginStorageAreaRemove; | |
4738 | |
4739 /** | |
4740 * @brief Remove a file from the storage area. | |
4741 * | |
4742 * This function removes a given file from the storage area that is | |
4743 * currently used by Orthanc. | |
4744 * | |
4745 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4746 * @param storageArea The storage area. | |
4747 * @param uuid The identifier of the file to be removed. | |
4748 * @param type The type of the file content. | |
4749 * @return 0 if success, other value if error. | |
4750 * @ingroup Callbacks | |
4751 * @deprecated This function should not be used anymore. Use "OrthancPluginRestApiDelete()" on | |
4752 * "/{patients|studies|series|instances}/{id}/attachments/{name}" instead. | |
4753 **/ | |
4754 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaRemove( | |
4755 OrthancPluginContext* context, | |
4756 OrthancPluginStorageArea* storageArea, | |
4757 const char* uuid, | |
4758 OrthancPluginContentType type) | |
4759 { | |
4760 _OrthancPluginStorageAreaRemove params; | |
4761 params.storageArea = storageArea; | |
4762 params.uuid = uuid; | |
4763 params.type = type; | |
4764 | |
4765 return context->InvokeService(context, _OrthancPluginService_StorageAreaRemove, ¶ms); | |
4766 } | |
4767 | |
4768 | |
4769 | |
4770 typedef struct | |
4771 { | |
4772 OrthancPluginErrorCode* target; | |
4773 int32_t code; | |
4774 uint16_t httpStatus; | |
4775 const char* message; | |
4776 } _OrthancPluginRegisterErrorCode; | |
4777 | |
4778 /** | |
4779 * @brief Declare a custom error code for this plugin. | |
4780 * | |
4781 * This function declares a custom error code that can be generated | |
4782 * by this plugin. This declaration is used to enrich the body of | |
4783 * the HTTP answer in the case of an error, and to set the proper | |
4784 * HTTP status code. | |
4785 * | |
4786 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4787 * @param code The error code that is internal to this plugin. | |
4788 * @param httpStatus The HTTP status corresponding to this error. | |
4789 * @param message The description of the error. | |
4790 * @return The error code that has been assigned inside the Orthanc core. | |
4791 * @ingroup Toolbox | |
4792 **/ | |
4793 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterErrorCode( | |
4794 OrthancPluginContext* context, | |
4795 int32_t code, | |
4796 uint16_t httpStatus, | |
4797 const char* message) | |
4798 { | |
4799 OrthancPluginErrorCode target; | |
4800 | |
4801 _OrthancPluginRegisterErrorCode params; | |
4802 params.target = ⌖ | |
4803 params.code = code; | |
4804 params.httpStatus = httpStatus; | |
4805 params.message = message; | |
4806 | |
4807 if (context->InvokeService(context, _OrthancPluginService_RegisterErrorCode, ¶ms) == OrthancPluginErrorCode_Success) | |
4808 { | |
4809 return target; | |
4810 } | |
4811 else | |
4812 { | |
4813 /* There was an error while assigned the error. Use a generic code. */ | |
4814 return OrthancPluginErrorCode_Plugin; | |
4815 } | |
4816 } | |
4817 | |
4818 | |
4819 | |
4820 typedef struct | |
4821 { | |
4822 uint16_t group; | |
4823 uint16_t element; | |
4824 OrthancPluginValueRepresentation vr; | |
4825 const char* name; | |
4826 uint32_t minMultiplicity; | |
4827 uint32_t maxMultiplicity; | |
4828 } _OrthancPluginRegisterDictionaryTag; | |
4829 | |
4830 /** | |
4831 * @brief Register a new tag into the DICOM dictionary. | |
4832 * | |
4833 * This function declares a new public tag in the dictionary of | |
4834 * DICOM tags that are known to Orthanc. This function should be | |
4835 * used in the OrthancPluginInitialize() callback. | |
4836 * | |
4837 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4838 * @param group The group of the tag. | |
4839 * @param element The element of the tag. | |
4840 * @param vr The value representation of the tag. | |
4841 * @param name The nickname of the tag. | |
4842 * @param minMultiplicity The minimum multiplicity of the tag (must be above 0). | |
4843 * @param maxMultiplicity The maximum multiplicity of the tag. A value of 0 means | |
4844 * an arbitrary multiplicity ("<tt>n</tt>"). | |
4845 * @return 0 if success, other value if error. | |
4846 * @see OrthancPluginRegisterPrivateDictionaryTag() | |
4847 * @ingroup Toolbox | |
4848 **/ | |
4849 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDictionaryTag( | |
4850 OrthancPluginContext* context, | |
4851 uint16_t group, | |
4852 uint16_t element, | |
4853 OrthancPluginValueRepresentation vr, | |
4854 const char* name, | |
4855 uint32_t minMultiplicity, | |
4856 uint32_t maxMultiplicity) | |
4857 { | |
4858 _OrthancPluginRegisterDictionaryTag params; | |
4859 params.group = group; | |
4860 params.element = element; | |
4861 params.vr = vr; | |
4862 params.name = name; | |
4863 params.minMultiplicity = minMultiplicity; | |
4864 params.maxMultiplicity = maxMultiplicity; | |
4865 | |
4866 return context->InvokeService(context, _OrthancPluginService_RegisterDictionaryTag, ¶ms); | |
4867 } | |
4868 | |
4869 | |
4870 | |
4871 typedef struct | |
4872 { | |
4873 uint16_t group; | |
4874 uint16_t element; | |
4875 OrthancPluginValueRepresentation vr; | |
4876 const char* name; | |
4877 uint32_t minMultiplicity; | |
4878 uint32_t maxMultiplicity; | |
4879 const char* privateCreator; | |
4880 } _OrthancPluginRegisterPrivateDictionaryTag; | |
4881 | |
4882 /** | |
4883 * @brief Register a new private tag into the DICOM dictionary. | |
4884 * | |
4885 * This function declares a new private tag in the dictionary of | |
4886 * DICOM tags that are known to Orthanc. This function should be | |
4887 * used in the OrthancPluginInitialize() callback. | |
4888 * | |
4889 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4890 * @param group The group of the tag. | |
4891 * @param element The element of the tag. | |
4892 * @param vr The value representation of the tag. | |
4893 * @param name The nickname of the tag. | |
4894 * @param minMultiplicity The minimum multiplicity of the tag (must be above 0). | |
4895 * @param maxMultiplicity The maximum multiplicity of the tag. A value of 0 means | |
4896 * an arbitrary multiplicity ("<tt>n</tt>"). | |
4897 * @param privateCreator The private creator of this private tag. | |
4898 * @return 0 if success, other value if error. | |
4899 * @see OrthancPluginRegisterDictionaryTag() | |
4900 * @ingroup Toolbox | |
4901 **/ | |
4902 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterPrivateDictionaryTag( | |
4903 OrthancPluginContext* context, | |
4904 uint16_t group, | |
4905 uint16_t element, | |
4906 OrthancPluginValueRepresentation vr, | |
4907 const char* name, | |
4908 uint32_t minMultiplicity, | |
4909 uint32_t maxMultiplicity, | |
4910 const char* privateCreator) | |
4911 { | |
4912 _OrthancPluginRegisterPrivateDictionaryTag params; | |
4913 params.group = group; | |
4914 params.element = element; | |
4915 params.vr = vr; | |
4916 params.name = name; | |
4917 params.minMultiplicity = minMultiplicity; | |
4918 params.maxMultiplicity = maxMultiplicity; | |
4919 params.privateCreator = privateCreator; | |
4920 | |
4921 return context->InvokeService(context, _OrthancPluginService_RegisterPrivateDictionaryTag, ¶ms); | |
4922 } | |
4923 | |
4924 | |
4925 | |
4926 typedef struct | |
4927 { | |
4928 OrthancPluginStorageArea* storageArea; | |
4929 OrthancPluginResourceType level; | |
4930 } _OrthancPluginReconstructMainDicomTags; | |
4931 | |
4932 /** | |
4933 * @brief Reconstruct the main DICOM tags. | |
4934 * | |
4935 * This function requests the Orthanc core to reconstruct the main | |
4936 * DICOM tags of all the resources of the given type. This function | |
4937 * can only be used as a part of the upgrade of a custom database | |
4938 * back-end. A database transaction will be automatically setup. | |
4939 * | |
4940 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4941 * @param storageArea The storage area. | |
4942 * @param level The type of the resources of interest. | |
4943 * @return 0 if success, other value if error. | |
4944 * @ingroup Callbacks | |
4945 **/ | |
4946 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginReconstructMainDicomTags( | |
4947 OrthancPluginContext* context, | |
4948 OrthancPluginStorageArea* storageArea, | |
4949 OrthancPluginResourceType level) | |
4950 { | |
4951 _OrthancPluginReconstructMainDicomTags params; | |
4952 params.level = level; | |
4953 params.storageArea = storageArea; | |
4954 | |
4955 return context->InvokeService(context, _OrthancPluginService_ReconstructMainDicomTags, ¶ms); | |
4956 } | |
4957 | |
4958 | |
4959 typedef struct | |
4960 { | |
4961 char** result; | |
4962 const char* instanceId; | |
4963 const void* buffer; | |
4964 uint32_t size; | |
4965 OrthancPluginDicomToJsonFormat format; | |
4966 OrthancPluginDicomToJsonFlags flags; | |
4967 uint32_t maxStringLength; | |
4968 } _OrthancPluginDicomToJson; | |
4969 | |
4970 | |
4971 /** | |
4972 * @brief Format a DICOM memory buffer as a JSON string. | |
4973 * | |
4974 * This function takes as input a memory buffer containing a DICOM | |
4975 * file, and outputs a JSON string representing the tags of this | |
4976 * DICOM file. | |
4977 * | |
4978 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4979 * @param buffer The memory buffer containing the DICOM file. | |
4980 * @param size The size of the memory buffer. | |
4981 * @param format The output format. | |
4982 * @param flags Flags governing the output. | |
4983 * @param maxStringLength The maximum length of a field. Too long fields will | |
4984 * be output as "null". The 0 value means no maximum length. | |
4985 * @return The NULL value if the case of an error, or the JSON | |
4986 * string. This string must be freed by OrthancPluginFreeString(). | |
4987 * @ingroup Toolbox | |
4988 * @see OrthancPluginDicomInstanceToJson | |
4989 **/ | |
4990 ORTHANC_PLUGIN_INLINE char* OrthancPluginDicomBufferToJson( | |
4991 OrthancPluginContext* context, | |
4992 const void* buffer, | |
4993 uint32_t size, | |
4994 OrthancPluginDicomToJsonFormat format, | |
4995 OrthancPluginDicomToJsonFlags flags, | |
4996 uint32_t maxStringLength) | |
4997 { | |
4998 char* result; | |
4999 | |
5000 _OrthancPluginDicomToJson params; | |
5001 memset(¶ms, 0, sizeof(params)); | |
5002 params.result = &result; | |
5003 params.buffer = buffer; | |
5004 params.size = size; | |
5005 params.format = format; | |
5006 params.flags = flags; | |
5007 params.maxStringLength = maxStringLength; | |
5008 | |
5009 if (context->InvokeService(context, _OrthancPluginService_DicomBufferToJson, ¶ms) != OrthancPluginErrorCode_Success) | |
5010 { | |
5011 /* Error */ | |
5012 return NULL; | |
5013 } | |
5014 else | |
5015 { | |
5016 return result; | |
5017 } | |
5018 } | |
5019 | |
5020 | |
5021 /** | |
5022 * @brief Format a DICOM instance as a JSON string. | |
5023 * | |
5024 * This function formats a DICOM instance that is stored in Orthanc, | |
5025 * and outputs a JSON string representing the tags of this DICOM | |
5026 * instance. | |
5027 * | |
5028 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5029 * @param instanceId The Orthanc identifier of the instance. | |
5030 * @param format The output format. | |
5031 * @param flags Flags governing the output. | |
5032 * @param maxStringLength The maximum length of a field. Too long fields will | |
5033 * be output as "null". The 0 value means no maximum length. | |
5034 * @return The NULL value if the case of an error, or the JSON | |
5035 * string. This string must be freed by OrthancPluginFreeString(). | |
5036 * @ingroup Toolbox | |
5037 * @see OrthancPluginDicomInstanceToJson | |
5038 **/ | |
5039 ORTHANC_PLUGIN_INLINE char* OrthancPluginDicomInstanceToJson( | |
5040 OrthancPluginContext* context, | |
5041 const char* instanceId, | |
5042 OrthancPluginDicomToJsonFormat format, | |
5043 OrthancPluginDicomToJsonFlags flags, | |
5044 uint32_t maxStringLength) | |
5045 { | |
5046 char* result; | |
5047 | |
5048 _OrthancPluginDicomToJson params; | |
5049 memset(¶ms, 0, sizeof(params)); | |
5050 params.result = &result; | |
5051 params.instanceId = instanceId; | |
5052 params.format = format; | |
5053 params.flags = flags; | |
5054 params.maxStringLength = maxStringLength; | |
5055 | |
5056 if (context->InvokeService(context, _OrthancPluginService_DicomInstanceToJson, ¶ms) != OrthancPluginErrorCode_Success) | |
5057 { | |
5058 /* Error */ | |
5059 return NULL; | |
5060 } | |
5061 else | |
5062 { | |
5063 return result; | |
5064 } | |
5065 } | |
5066 | |
5067 | |
5068 typedef struct | |
5069 { | |
5070 OrthancPluginMemoryBuffer* target; | |
5071 const char* uri; | |
5072 uint32_t headersCount; | |
5073 const char* const* headersKeys; | |
5074 const char* const* headersValues; | |
5075 int32_t afterPlugins; | |
5076 } _OrthancPluginRestApiGet2; | |
5077 | |
5078 /** | |
5079 * @brief Make a GET call to the Orthanc REST API, with custom HTTP headers. | |
5080 * | |
5081 * Make a GET call to the Orthanc REST API with extended | |
5082 * parameters. The result to the query is stored into a newly | |
5083 * allocated memory buffer. | |
5084 * | |
5085 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5086 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
5087 * @param uri The URI in the built-in Orthanc API. | |
5088 * @param headersCount The number of HTTP headers. | |
5089 * @param headersKeys Array containing the keys of the HTTP headers (can be <tt>NULL</tt> if no header). | |
5090 * @param headersValues Array containing the values of the HTTP headers (can be <tt>NULL</tt> if no header). | |
5091 * @param afterPlugins If 0, the built-in API of Orthanc is used. | |
5092 * If 1, the API is tainted by the plugins. | |
5093 * @return 0 if success, or the error code if failure. | |
5094 * @see OrthancPluginRestApiGet, OrthancPluginRestApiGetAfterPlugins | |
5095 * @ingroup Orthanc | |
5096 **/ | |
5097 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGet2( | |
5098 OrthancPluginContext* context, | |
5099 OrthancPluginMemoryBuffer* target, | |
5100 const char* uri, | |
5101 uint32_t headersCount, | |
5102 const char* const* headersKeys, | |
5103 const char* const* headersValues, | |
5104 int32_t afterPlugins) | |
5105 { | |
5106 _OrthancPluginRestApiGet2 params; | |
5107 params.target = target; | |
5108 params.uri = uri; | |
5109 params.headersCount = headersCount; | |
5110 params.headersKeys = headersKeys; | |
5111 params.headersValues = headersValues; | |
5112 params.afterPlugins = afterPlugins; | |
5113 | |
5114 return context->InvokeService(context, _OrthancPluginService_RestApiGet2, ¶ms); | |
5115 } | |
5116 | |
5117 | |
5118 | |
5119 typedef struct | |
5120 { | |
5121 OrthancPluginWorklistCallback callback; | |
5122 } _OrthancPluginWorklistCallback; | |
5123 | |
5124 /** | |
5125 * @brief Register a callback to handle modality worklists requests. | |
5126 * | |
5127 * This function registers a callback to handle C-Find SCP requests | |
5128 * on modality worklists. | |
5129 * | |
5130 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5131 * @param callback The callback. | |
5132 * @return 0 if success, other value if error. | |
5133 * @ingroup DicomCallbacks | |
5134 **/ | |
5135 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterWorklistCallback( | |
5136 OrthancPluginContext* context, | |
5137 OrthancPluginWorklistCallback callback) | |
5138 { | |
5139 _OrthancPluginWorklistCallback params; | |
5140 params.callback = callback; | |
5141 | |
5142 return context->InvokeService(context, _OrthancPluginService_RegisterWorklistCallback, ¶ms); | |
5143 } | |
5144 | |
5145 | |
5146 | |
5147 typedef struct | |
5148 { | |
5149 OrthancPluginWorklistAnswers* answers; | |
5150 const OrthancPluginWorklistQuery* query; | |
5151 const void* dicom; | |
5152 uint32_t size; | |
5153 } _OrthancPluginWorklistAnswersOperation; | |
5154 | |
5155 /** | |
5156 * @brief Add one answer to some modality worklist request. | |
5157 * | |
5158 * This function adds one worklist (encoded as a DICOM file) to the | |
5159 * set of answers corresponding to some C-Find SCP request against | |
5160 * modality worklists. | |
5161 * | |
5162 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5163 * @param answers The set of answers. | |
5164 * @param query The worklist query, as received by the callback. | |
5165 * @param dicom The worklist to answer, encoded as a DICOM file. | |
5166 * @param size The size of the DICOM file. | |
5167 * @return 0 if success, other value if error. | |
5168 * @ingroup DicomCallbacks | |
5169 * @see OrthancPluginCreateDicom() | |
5170 **/ | |
5171 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistAddAnswer( | |
5172 OrthancPluginContext* context, | |
5173 OrthancPluginWorklistAnswers* answers, | |
5174 const OrthancPluginWorklistQuery* query, | |
5175 const void* dicom, | |
5176 uint32_t size) | |
5177 { | |
5178 _OrthancPluginWorklistAnswersOperation params; | |
5179 params.answers = answers; | |
5180 params.query = query; | |
5181 params.dicom = dicom; | |
5182 params.size = size; | |
5183 | |
5184 return context->InvokeService(context, _OrthancPluginService_WorklistAddAnswer, ¶ms); | |
5185 } | |
5186 | |
5187 | |
5188 /** | |
5189 * @brief Mark the set of worklist answers as incomplete. | |
5190 * | |
5191 * This function marks as incomplete the set of answers | |
5192 * corresponding to some C-Find SCP request against modality | |
5193 * worklists. This must be used if canceling the handling of a | |
5194 * request when too many answers are to be returned. | |
5195 * | |
5196 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5197 * @param answers The set of answers. | |
5198 * @return 0 if success, other value if error. | |
5199 * @ingroup DicomCallbacks | |
5200 **/ | |
5201 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistMarkIncomplete( | |
5202 OrthancPluginContext* context, | |
5203 OrthancPluginWorklistAnswers* answers) | |
5204 { | |
5205 _OrthancPluginWorklistAnswersOperation params; | |
5206 params.answers = answers; | |
5207 params.query = NULL; | |
5208 params.dicom = NULL; | |
5209 params.size = 0; | |
5210 | |
5211 return context->InvokeService(context, _OrthancPluginService_WorklistMarkIncomplete, ¶ms); | |
5212 } | |
5213 | |
5214 | |
5215 typedef struct | |
5216 { | |
5217 const OrthancPluginWorklistQuery* query; | |
5218 const void* dicom; | |
5219 uint32_t size; | |
5220 int32_t* isMatch; | |
5221 OrthancPluginMemoryBuffer* target; | |
5222 } _OrthancPluginWorklistQueryOperation; | |
5223 | |
5224 /** | |
5225 * @brief Test whether a worklist matches the query. | |
5226 * | |
5227 * This function checks whether one worklist (encoded as a DICOM | |
5228 * file) matches the C-Find SCP query against modality | |
5229 * worklists. This function must be called before adding the | |
5230 * worklist as an answer through OrthancPluginWorklistAddAnswer(). | |
5231 * | |
5232 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5233 * @param query The worklist query, as received by the callback. | |
5234 * @param dicom The worklist to answer, encoded as a DICOM file. | |
5235 * @param size The size of the DICOM file. | |
5236 * @return 1 if the worklist matches the query, 0 otherwise. | |
5237 * @ingroup DicomCallbacks | |
5238 **/ | |
5239 ORTHANC_PLUGIN_INLINE int32_t OrthancPluginWorklistIsMatch( | |
5240 OrthancPluginContext* context, | |
5241 const OrthancPluginWorklistQuery* query, | |
5242 const void* dicom, | |
5243 uint32_t size) | |
5244 { | |
5245 int32_t isMatch = 0; | |
5246 | |
5247 _OrthancPluginWorklistQueryOperation params; | |
5248 params.query = query; | |
5249 params.dicom = dicom; | |
5250 params.size = size; | |
5251 params.isMatch = &isMatch; | |
5252 params.target = NULL; | |
5253 | |
5254 if (context->InvokeService(context, _OrthancPluginService_WorklistIsMatch, ¶ms) == OrthancPluginErrorCode_Success) | |
5255 { | |
5256 return isMatch; | |
5257 } | |
5258 else | |
5259 { | |
5260 /* Error: Assume non-match */ | |
5261 return 0; | |
5262 } | |
5263 } | |
5264 | |
5265 | |
5266 /** | |
5267 * @brief Retrieve the worklist query as a DICOM file. | |
5268 * | |
5269 * This function retrieves the DICOM file that underlies a C-Find | |
5270 * SCP query against modality worklists. | |
5271 * | |
5272 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5273 * @param target Memory buffer where to store the DICOM file. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
5274 * @param query The worklist query, as received by the callback. | |
5275 * @return 0 if success, other value if error. | |
5276 * @ingroup DicomCallbacks | |
5277 **/ | |
5278 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistGetDicomQuery( | |
5279 OrthancPluginContext* context, | |
5280 OrthancPluginMemoryBuffer* target, | |
5281 const OrthancPluginWorklistQuery* query) | |
5282 { | |
5283 _OrthancPluginWorklistQueryOperation params; | |
5284 params.query = query; | |
5285 params.dicom = NULL; | |
5286 params.size = 0; | |
5287 params.isMatch = NULL; | |
5288 params.target = target; | |
5289 | |
5290 return context->InvokeService(context, _OrthancPluginService_WorklistGetDicomQuery, ¶ms); | |
5291 } | |
5292 | |
5293 | |
5294 /** | |
5295 * @brief Get the origin of a DICOM file. | |
5296 * | |
5297 * This function returns the origin of a DICOM instance that has been received by Orthanc. | |
5298 * | |
5299 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5300 * @param instance The instance of interest. | |
5301 * @return The origin of the instance. | |
5302 * @ingroup DicomInstance | |
5303 **/ | |
5304 ORTHANC_PLUGIN_INLINE OrthancPluginInstanceOrigin OrthancPluginGetInstanceOrigin( | |
5305 OrthancPluginContext* context, | |
5306 const OrthancPluginDicomInstance* instance) | |
5307 { | |
5308 OrthancPluginInstanceOrigin origin; | |
5309 | |
5310 _OrthancPluginAccessDicomInstance params; | |
5311 memset(¶ms, 0, sizeof(params)); | |
5312 params.resultOrigin = &origin; | |
5313 params.instance = instance; | |
5314 | |
5315 if (context->InvokeService(context, _OrthancPluginService_GetInstanceOrigin, ¶ms) != OrthancPluginErrorCode_Success) | |
5316 { | |
5317 /* Error */ | |
5318 return OrthancPluginInstanceOrigin_Unknown; | |
5319 } | |
5320 else | |
5321 { | |
5322 return origin; | |
5323 } | |
5324 } | |
5325 | |
5326 | |
5327 typedef struct | |
5328 { | |
5329 OrthancPluginMemoryBuffer* target; | |
5330 const char* json; | |
5331 const OrthancPluginImage* pixelData; | |
5332 OrthancPluginCreateDicomFlags flags; | |
5333 } _OrthancPluginCreateDicom; | |
5334 | |
5335 /** | |
5336 * @brief Create a DICOM instance from a JSON string and an image. | |
5337 * | |
5338 * This function takes as input a string containing a JSON file | |
5339 * describing the content of a DICOM instance. As an output, it | |
5340 * writes the corresponding DICOM instance to a newly allocated | |
5341 * memory buffer. Additionally, an image to be encoded within the | |
5342 * DICOM instance can also be provided. | |
5343 * | |
5344 * Private tags will be associated with the private creator whose | |
5345 * value is specified in the "DefaultPrivateCreator" configuration | |
5346 * option of Orthanc. The function OrthancPluginCreateDicom2() can | |
5347 * be used if another private creator must be used to create this | |
5348 * instance. | |
5349 * | |
5350 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5351 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
5352 * @param json The input JSON file. | |
5353 * @param pixelData The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme. | |
5354 * @param flags Flags governing the output. | |
5355 * @return 0 if success, other value if error. | |
5356 * @ingroup Toolbox | |
5357 * @see OrthancPluginCreateDicom2 | |
5358 * @see OrthancPluginDicomBufferToJson | |
5359 **/ | |
5360 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateDicom( | |
5361 OrthancPluginContext* context, | |
5362 OrthancPluginMemoryBuffer* target, | |
5363 const char* json, | |
5364 const OrthancPluginImage* pixelData, | |
5365 OrthancPluginCreateDicomFlags flags) | |
5366 { | |
5367 _OrthancPluginCreateDicom params; | |
5368 params.target = target; | |
5369 params.json = json; | |
5370 params.pixelData = pixelData; | |
5371 params.flags = flags; | |
5372 | |
5373 return context->InvokeService(context, _OrthancPluginService_CreateDicom, ¶ms); | |
5374 } | |
5375 | |
5376 | |
5377 typedef struct | |
5378 { | |
5379 OrthancPluginDecodeImageCallback callback; | |
5380 } _OrthancPluginDecodeImageCallback; | |
5381 | |
5382 /** | |
5383 * @brief Register a callback to handle the decoding of DICOM images. | |
5384 * | |
5385 * This function registers a custom callback to decode DICOM images, | |
5386 * extending the built-in decoder of Orthanc that uses | |
5387 * DCMTK. Starting with Orthanc 1.7.0, the exact behavior is | |
5388 * affected by the configuration option | |
5389 * "BuiltinDecoderTranscoderOrder" of Orthanc. | |
5390 * | |
5391 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5392 * @param callback The callback. | |
5393 * @return 0 if success, other value if error. | |
5394 * @ingroup Callbacks | |
5395 **/ | |
5396 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDecodeImageCallback( | |
5397 OrthancPluginContext* context, | |
5398 OrthancPluginDecodeImageCallback callback) | |
5399 { | |
5400 _OrthancPluginDecodeImageCallback params; | |
5401 params.callback = callback; | |
5402 | |
5403 return context->InvokeService(context, _OrthancPluginService_RegisterDecodeImageCallback, ¶ms); | |
5404 } | |
5405 | |
5406 | |
5407 | |
5408 typedef struct | |
5409 { | |
5410 OrthancPluginImage** target; | |
5411 OrthancPluginPixelFormat format; | |
5412 uint32_t width; | |
5413 uint32_t height; | |
5414 uint32_t pitch; | |
5415 void* buffer; | |
5416 const void* constBuffer; | |
5417 uint32_t bufferSize; | |
5418 uint32_t frameIndex; | |
5419 } _OrthancPluginCreateImage; | |
5420 | |
5421 | |
5422 /** | |
5423 * @brief Create an image. | |
5424 * | |
5425 * This function creates an image of given size and format. | |
5426 * | |
5427 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5428 * @param format The format of the pixels. | |
5429 * @param width The width of the image. | |
5430 * @param height The height of the image. | |
5431 * @return The newly allocated image. It must be freed with OrthancPluginFreeImage(). | |
5432 * @ingroup Images | |
5433 **/ | |
5434 ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginCreateImage( | |
5435 OrthancPluginContext* context, | |
5436 OrthancPluginPixelFormat format, | |
5437 uint32_t width, | |
5438 uint32_t height) | |
5439 { | |
5440 OrthancPluginImage* target = NULL; | |
5441 | |
5442 _OrthancPluginCreateImage params; | |
5443 memset(¶ms, 0, sizeof(params)); | |
5444 params.target = ⌖ | |
5445 params.format = format; | |
5446 params.width = width; | |
5447 params.height = height; | |
5448 | |
5449 if (context->InvokeService(context, _OrthancPluginService_CreateImage, ¶ms) != OrthancPluginErrorCode_Success) | |
5450 { | |
5451 return NULL; | |
5452 } | |
5453 else | |
5454 { | |
5455 return target; | |
5456 } | |
5457 } | |
5458 | |
5459 | |
5460 /** | |
5461 * @brief Create an image pointing to a memory buffer. | |
5462 * | |
5463 * This function creates an image whose content points to a memory | |
5464 * buffer managed by the plugin. Note that the buffer is directly | |
5465 * accessed, no memory is allocated and no data is copied. | |
5466 * | |
5467 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5468 * @param format The format of the pixels. | |
5469 * @param width The width of the image. | |
5470 * @param height The height of the image. | |
5471 * @param pitch The pitch of the image (i.e. the number of bytes | |
5472 * between 2 successive lines of the image in the memory buffer). | |
5473 * @param buffer The memory buffer. | |
5474 * @return The newly allocated image. It must be freed with OrthancPluginFreeImage(). | |
5475 * @ingroup Images | |
5476 **/ | |
5477 ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginCreateImageAccessor( | |
5478 OrthancPluginContext* context, | |
5479 OrthancPluginPixelFormat format, | |
5480 uint32_t width, | |
5481 uint32_t height, | |
5482 uint32_t pitch, | |
5483 void* buffer) | |
5484 { | |
5485 OrthancPluginImage* target = NULL; | |
5486 | |
5487 _OrthancPluginCreateImage params; | |
5488 memset(¶ms, 0, sizeof(params)); | |
5489 params.target = ⌖ | |
5490 params.format = format; | |
5491 params.width = width; | |
5492 params.height = height; | |
5493 params.pitch = pitch; | |
5494 params.buffer = buffer; | |
5495 | |
5496 if (context->InvokeService(context, _OrthancPluginService_CreateImageAccessor, ¶ms) != OrthancPluginErrorCode_Success) | |
5497 { | |
5498 return NULL; | |
5499 } | |
5500 else | |
5501 { | |
5502 return target; | |
5503 } | |
5504 } | |
5505 | |
5506 | |
5507 | |
5508 /** | |
5509 * @brief Decode one frame from a DICOM instance. | |
5510 * | |
5511 * This function decodes one frame of a DICOM image that is stored | |
5512 * in a memory buffer. This function will give the same result as | |
5513 * OrthancPluginUncompressImage() for single-frame DICOM images. | |
5514 * | |
5515 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5516 * @param buffer Pointer to a memory buffer containing the DICOM image. | |
5517 * @param bufferSize Size of the memory buffer containing the DICOM image. | |
5518 * @param frameIndex The index of the frame of interest in a multi-frame image. | |
5519 * @return The uncompressed image. It must be freed with OrthancPluginFreeImage(). | |
5520 * @ingroup Images | |
5521 * @see OrthancPluginGetInstanceDecodedFrame() | |
5522 **/ | |
5523 ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginDecodeDicomImage( | |
5524 OrthancPluginContext* context, | |
5525 const void* buffer, | |
5526 uint32_t bufferSize, | |
5527 uint32_t frameIndex) | |
5528 { | |
5529 OrthancPluginImage* target = NULL; | |
5530 | |
5531 _OrthancPluginCreateImage params; | |
5532 memset(¶ms, 0, sizeof(params)); | |
5533 params.target = ⌖ | |
5534 params.constBuffer = buffer; | |
5535 params.bufferSize = bufferSize; | |
5536 params.frameIndex = frameIndex; | |
5537 | |
5538 if (context->InvokeService(context, _OrthancPluginService_DecodeDicomImage, ¶ms) != OrthancPluginErrorCode_Success) | |
5539 { | |
5540 return NULL; | |
5541 } | |
5542 else | |
5543 { | |
5544 return target; | |
5545 } | |
5546 } | |
5547 | |
5548 | |
5549 | |
5550 typedef struct | |
5551 { | |
5552 char** result; | |
5553 const void* buffer; | |
5554 uint32_t size; | |
5555 } _OrthancPluginComputeHash; | |
5556 | |
5557 /** | |
5558 * @brief Compute an MD5 hash. | |
5559 * | |
5560 * This functions computes the MD5 cryptographic hash of the given memory buffer. | |
5561 * | |
5562 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5563 * @param buffer The source memory buffer. | |
5564 * @param size The size in bytes of the source buffer. | |
5565 * @return The NULL value in case of error, or a string containing the cryptographic hash. | |
5566 * This string must be freed by OrthancPluginFreeString(). | |
5567 * @ingroup Toolbox | |
5568 **/ | |
5569 ORTHANC_PLUGIN_INLINE char* OrthancPluginComputeMd5( | |
5570 OrthancPluginContext* context, | |
5571 const void* buffer, | |
5572 uint32_t size) | |
5573 { | |
5574 char* result; | |
5575 | |
5576 _OrthancPluginComputeHash params; | |
5577 params.result = &result; | |
5578 params.buffer = buffer; | |
5579 params.size = size; | |
5580 | |
5581 if (context->InvokeService(context, _OrthancPluginService_ComputeMd5, ¶ms) != OrthancPluginErrorCode_Success) | |
5582 { | |
5583 /* Error */ | |
5584 return NULL; | |
5585 } | |
5586 else | |
5587 { | |
5588 return result; | |
5589 } | |
5590 } | |
5591 | |
5592 | |
5593 /** | |
5594 * @brief Compute a SHA-1 hash. | |
5595 * | |
5596 * This functions computes the SHA-1 cryptographic hash of the given memory buffer. | |
5597 * | |
5598 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5599 * @param buffer The source memory buffer. | |
5600 * @param size The size in bytes of the source buffer. | |
5601 * @return The NULL value in case of error, or a string containing the cryptographic hash. | |
5602 * This string must be freed by OrthancPluginFreeString(). | |
5603 * @ingroup Toolbox | |
5604 **/ | |
5605 ORTHANC_PLUGIN_INLINE char* OrthancPluginComputeSha1( | |
5606 OrthancPluginContext* context, | |
5607 const void* buffer, | |
5608 uint32_t size) | |
5609 { | |
5610 char* result; | |
5611 | |
5612 _OrthancPluginComputeHash params; | |
5613 params.result = &result; | |
5614 params.buffer = buffer; | |
5615 params.size = size; | |
5616 | |
5617 if (context->InvokeService(context, _OrthancPluginService_ComputeSha1, ¶ms) != OrthancPluginErrorCode_Success) | |
5618 { | |
5619 /* Error */ | |
5620 return NULL; | |
5621 } | |
5622 else | |
5623 { | |
5624 return result; | |
5625 } | |
5626 } | |
5627 | |
5628 | |
5629 | |
5630 typedef struct | |
5631 { | |
5632 OrthancPluginDictionaryEntry* target; | |
5633 const char* name; | |
5634 } _OrthancPluginLookupDictionary; | |
5635 | |
5636 /** | |
5637 * @brief Get information about the given DICOM tag. | |
5638 * | |
5639 * This functions makes a lookup in the dictionary of DICOM tags | |
5640 * that are known to Orthanc, and returns information about this | |
5641 * tag. The tag can be specified using its human-readable name | |
5642 * (e.g. "PatientName") or a set of two hexadecimal numbers | |
5643 * (e.g. "0010-0020"). | |
5644 * | |
5645 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5646 * @param target Where to store the information about the tag. | |
5647 * @param name The name of the DICOM tag. | |
5648 * @return 0 if success, other value if error. | |
5649 * @ingroup Toolbox | |
5650 **/ | |
5651 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginLookupDictionary( | |
5652 OrthancPluginContext* context, | |
5653 OrthancPluginDictionaryEntry* target, | |
5654 const char* name) | |
5655 { | |
5656 _OrthancPluginLookupDictionary params; | |
5657 params.target = target; | |
5658 params.name = name; | |
5659 return context->InvokeService(context, _OrthancPluginService_LookupDictionary, ¶ms); | |
5660 } | |
5661 | |
5662 | |
5663 | |
5664 typedef struct | |
5665 { | |
5666 OrthancPluginRestOutput* output; | |
5667 const void* answer; | |
5668 uint32_t answerSize; | |
5669 uint32_t headersCount; | |
5670 const char* const* headersKeys; | |
5671 const char* const* headersValues; | |
5672 } _OrthancPluginSendMultipartItem2; | |
5673 | |
5674 /** | |
5675 * @brief Send an item as a part of some HTTP multipart answer, with custom headers. | |
5676 * | |
5677 * This function sends an item as a part of some HTTP multipart | |
5678 * answer that was initiated by OrthancPluginStartMultipartAnswer(). In addition to | |
5679 * OrthancPluginSendMultipartItem(), this function will set HTTP header associated | |
5680 * with the item. | |
5681 * | |
5682 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5683 * @param output The HTTP connection to the client application. | |
5684 * @param answer Pointer to the memory buffer containing the item. | |
5685 * @param answerSize Number of bytes of the item. | |
5686 * @param headersCount The number of HTTP headers. | |
5687 * @param headersKeys Array containing the keys of the HTTP headers. | |
5688 * @param headersValues Array containing the values of the HTTP headers. | |
5689 * @return 0 if success, or the error code if failure (this notably happens | |
5690 * if the connection is closed by the client). | |
5691 * @see OrthancPluginSendMultipartItem() | |
5692 * @ingroup REST | |
5693 **/ | |
5694 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSendMultipartItem2( | |
5695 OrthancPluginContext* context, | |
5696 OrthancPluginRestOutput* output, | |
5697 const void* answer, | |
5698 uint32_t answerSize, | |
5699 uint32_t headersCount, | |
5700 const char* const* headersKeys, | |
5701 const char* const* headersValues) | |
5702 { | |
5703 _OrthancPluginSendMultipartItem2 params; | |
5704 params.output = output; | |
5705 params.answer = answer; | |
5706 params.answerSize = answerSize; | |
5707 params.headersCount = headersCount; | |
5708 params.headersKeys = headersKeys; | |
5709 params.headersValues = headersValues; | |
5710 | |
5711 return context->InvokeService(context, _OrthancPluginService_SendMultipartItem2, ¶ms); | |
5712 } | |
5713 | |
5714 | |
5715 typedef struct | |
5716 { | |
5717 OrthancPluginIncomingHttpRequestFilter callback; | |
5718 } _OrthancPluginIncomingHttpRequestFilter; | |
5719 | |
5720 /** | |
5721 * @brief Register a callback to filter incoming HTTP requests. | |
5722 * | |
5723 * This function registers a custom callback to filter incoming HTTP/REST | |
5724 * requests received by the HTTP server of Orthanc. | |
5725 * | |
5726 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5727 * @param callback The callback. | |
5728 * @return 0 if success, other value if error. | |
5729 * @ingroup Callbacks | |
5730 * @deprecated Please instead use OrthancPluginRegisterIncomingHttpRequestFilter2() | |
5731 **/ | |
5732 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingHttpRequestFilter( | |
5733 OrthancPluginContext* context, | |
5734 OrthancPluginIncomingHttpRequestFilter callback) | |
5735 { | |
5736 _OrthancPluginIncomingHttpRequestFilter params; | |
5737 params.callback = callback; | |
5738 | |
5739 return context->InvokeService(context, _OrthancPluginService_RegisterIncomingHttpRequestFilter, ¶ms); | |
5740 } | |
5741 | |
5742 | |
5743 | |
5744 typedef struct | |
5745 { | |
5746 OrthancPluginMemoryBuffer* answerBody; | |
5747 OrthancPluginMemoryBuffer* answerHeaders; | |
5748 uint16_t* httpStatus; | |
5749 OrthancPluginHttpMethod method; | |
5750 const char* url; | |
5751 uint32_t headersCount; | |
5752 const char* const* headersKeys; | |
5753 const char* const* headersValues; | |
5754 const void* body; | |
5755 uint32_t bodySize; | |
5756 const char* username; | |
5757 const char* password; | |
5758 uint32_t timeout; | |
5759 const char* certificateFile; | |
5760 const char* certificateKeyFile; | |
5761 const char* certificateKeyPassword; | |
5762 uint8_t pkcs11; | |
5763 } _OrthancPluginCallHttpClient2; | |
5764 | |
5765 | |
5766 | |
5767 /** | |
5768 * @brief Issue a HTTP call with full flexibility. | |
5769 * | |
5770 * Make a HTTP call to the given URL. The result to the query is | |
5771 * stored into a newly allocated memory buffer. The HTTP request | |
5772 * will be done accordingly to the global configuration of Orthanc | |
5773 * (in particular, the options "HttpProxy", "HttpTimeout", | |
5774 * "HttpsVerifyPeers", "HttpsCACertificates", and "Pkcs11" will be | |
5775 * taken into account). | |
5776 * | |
5777 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5778 * @param answerBody The target memory buffer (out argument). | |
5779 * It must be freed with OrthancPluginFreeMemoryBuffer(). | |
5780 * The value of this argument is ignored if the HTTP method is DELETE. | |
5781 * @param answerHeaders The target memory buffer for the HTTP headers in the answers (out argument). | |
5782 * The answer headers are formatted as a JSON object (associative array). | |
5783 * The buffer must be freed with OrthancPluginFreeMemoryBuffer(). | |
5784 * This argument can be set to NULL if the plugin has no interest in the HTTP headers. | |
5785 * @param httpStatus The HTTP status after the execution of the request (out argument). | |
5786 * @param method HTTP method to be used. | |
5787 * @param url The URL of interest. | |
5788 * @param headersCount The number of HTTP headers. | |
5789 * @param headersKeys Array containing the keys of the HTTP headers (can be <tt>NULL</tt> if no header). | |
5790 * @param headersValues Array containing the values of the HTTP headers (can be <tt>NULL</tt> if no header). | |
5791 * @param username The username (can be <tt>NULL</tt> if no password protection). | |
5792 * @param password The password (can be <tt>NULL</tt> if no password protection). | |
5793 * @param body The HTTP body for a POST or PUT request. | |
5794 * @param bodySize The size of the body. | |
5795 * @param timeout Timeout in seconds (0 for default timeout). | |
5796 * @param certificateFile Path to the client certificate for HTTPS, in PEM format | |
5797 * (can be <tt>NULL</tt> if no client certificate or if not using HTTPS). | |
5798 * @param certificateKeyFile Path to the key of the client certificate for HTTPS, in PEM format | |
5799 * (can be <tt>NULL</tt> if no client certificate or if not using HTTPS). | |
5800 * @param certificateKeyPassword Password to unlock the key of the client certificate | |
5801 * (can be <tt>NULL</tt> if no client certificate or if not using HTTPS). | |
5802 * @param pkcs11 Enable PKCS#11 client authentication for hardware security modules and smart cards. | |
5803 * @return 0 if success, or the error code if failure. | |
5804 * @see OrthancPluginCallPeerApi() | |
5805 * @ingroup Toolbox | |
5806 **/ | |
5807 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpClient( | |
5808 OrthancPluginContext* context, | |
5809 OrthancPluginMemoryBuffer* answerBody, | |
5810 OrthancPluginMemoryBuffer* answerHeaders, | |
5811 uint16_t* httpStatus, | |
5812 OrthancPluginHttpMethod method, | |
5813 const char* url, | |
5814 uint32_t headersCount, | |
5815 const char* const* headersKeys, | |
5816 const char* const* headersValues, | |
5817 const void* body, | |
5818 uint32_t bodySize, | |
5819 const char* username, | |
5820 const char* password, | |
5821 uint32_t timeout, | |
5822 const char* certificateFile, | |
5823 const char* certificateKeyFile, | |
5824 const char* certificateKeyPassword, | |
5825 uint8_t pkcs11) | |
5826 { | |
5827 _OrthancPluginCallHttpClient2 params; | |
5828 memset(¶ms, 0, sizeof(params)); | |
5829 | |
5830 params.answerBody = answerBody; | |
5831 params.answerHeaders = answerHeaders; | |
5832 params.httpStatus = httpStatus; | |
5833 params.method = method; | |
5834 params.url = url; | |
5835 params.headersCount = headersCount; | |
5836 params.headersKeys = headersKeys; | |
5837 params.headersValues = headersValues; | |
5838 params.body = body; | |
5839 params.bodySize = bodySize; | |
5840 params.username = username; | |
5841 params.password = password; | |
5842 params.timeout = timeout; | |
5843 params.certificateFile = certificateFile; | |
5844 params.certificateKeyFile = certificateKeyFile; | |
5845 params.certificateKeyPassword = certificateKeyPassword; | |
5846 params.pkcs11 = pkcs11; | |
5847 | |
5848 return context->InvokeService(context, _OrthancPluginService_CallHttpClient2, ¶ms); | |
5849 } | |
5850 | |
5851 | |
5852 /** | |
5853 * @brief Generate an UUID. | |
5854 * | |
5855 * Generate a random GUID/UUID (globally unique identifier). | |
5856 * | |
5857 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5858 * @return NULL in the case of an error, or a newly allocated string | |
5859 * containing the UUID. This string must be freed by OrthancPluginFreeString(). | |
5860 * @ingroup Toolbox | |
5861 **/ | |
5862 ORTHANC_PLUGIN_INLINE char* OrthancPluginGenerateUuid( | |
5863 OrthancPluginContext* context) | |
5864 { | |
5865 char* result; | |
5866 | |
5867 _OrthancPluginRetrieveDynamicString params; | |
5868 params.result = &result; | |
5869 params.argument = NULL; | |
5870 | |
5871 if (context->InvokeService(context, _OrthancPluginService_GenerateUuid, ¶ms) != OrthancPluginErrorCode_Success) | |
5872 { | |
5873 /* Error */ | |
5874 return NULL; | |
5875 } | |
5876 else | |
5877 { | |
5878 return result; | |
5879 } | |
5880 } | |
5881 | |
5882 | |
5883 | |
5884 | |
5885 typedef struct | |
5886 { | |
5887 OrthancPluginFindCallback callback; | |
5888 } _OrthancPluginFindCallback; | |
5889 | |
5890 /** | |
5891 * @brief Register a callback to handle C-Find requests. | |
5892 * | |
5893 * This function registers a callback to handle C-Find SCP requests | |
5894 * that are not related to modality worklists. | |
5895 * | |
5896 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5897 * @param callback The callback. | |
5898 * @return 0 if success, other value if error. | |
5899 * @ingroup DicomCallbacks | |
5900 **/ | |
5901 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterFindCallback( | |
5902 OrthancPluginContext* context, | |
5903 OrthancPluginFindCallback callback) | |
5904 { | |
5905 _OrthancPluginFindCallback params; | |
5906 params.callback = callback; | |
5907 | |
5908 return context->InvokeService(context, _OrthancPluginService_RegisterFindCallback, ¶ms); | |
5909 } | |
5910 | |
5911 | |
5912 typedef struct | |
5913 { | |
5914 OrthancPluginFindAnswers *answers; | |
5915 const OrthancPluginFindQuery *query; | |
5916 const void *dicom; | |
5917 uint32_t size; | |
5918 uint32_t index; | |
5919 uint32_t *resultUint32; | |
5920 uint16_t *resultGroup; | |
5921 uint16_t *resultElement; | |
5922 char **resultString; | |
5923 } _OrthancPluginFindOperation; | |
5924 | |
5925 /** | |
5926 * @brief Add one answer to some C-Find request. | |
5927 * | |
5928 * This function adds one answer (encoded as a DICOM file) to the | |
5929 * set of answers corresponding to some C-Find SCP request that is | |
5930 * not related to modality worklists. | |
5931 * | |
5932 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5933 * @param answers The set of answers. | |
5934 * @param dicom The answer to be added, encoded as a DICOM file. | |
5935 * @param size The size of the DICOM file. | |
5936 * @return 0 if success, other value if error. | |
5937 * @ingroup DicomCallbacks | |
5938 * @see OrthancPluginCreateDicom() | |
5939 **/ | |
5940 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginFindAddAnswer( | |
5941 OrthancPluginContext* context, | |
5942 OrthancPluginFindAnswers* answers, | |
5943 const void* dicom, | |
5944 uint32_t size) | |
5945 { | |
5946 _OrthancPluginFindOperation params; | |
5947 memset(¶ms, 0, sizeof(params)); | |
5948 params.answers = answers; | |
5949 params.dicom = dicom; | |
5950 params.size = size; | |
5951 | |
5952 return context->InvokeService(context, _OrthancPluginService_FindAddAnswer, ¶ms); | |
5953 } | |
5954 | |
5955 | |
5956 /** | |
5957 * @brief Mark the set of C-Find answers as incomplete. | |
5958 * | |
5959 * This function marks as incomplete the set of answers | |
5960 * corresponding to some C-Find SCP request that is not related to | |
5961 * modality worklists. This must be used if canceling the handling | |
5962 * of a request when too many answers are to be returned. | |
5963 * | |
5964 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5965 * @param answers The set of answers. | |
5966 * @return 0 if success, other value if error. | |
5967 * @ingroup DicomCallbacks | |
5968 **/ | |
5969 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginFindMarkIncomplete( | |
5970 OrthancPluginContext* context, | |
5971 OrthancPluginFindAnswers* answers) | |
5972 { | |
5973 _OrthancPluginFindOperation params; | |
5974 memset(¶ms, 0, sizeof(params)); | |
5975 params.answers = answers; | |
5976 | |
5977 return context->InvokeService(context, _OrthancPluginService_FindMarkIncomplete, ¶ms); | |
5978 } | |
5979 | |
5980 | |
5981 | |
5982 /** | |
5983 * @brief Get the number of tags in a C-Find query. | |
5984 * | |
5985 * This function returns the number of tags that are contained in | |
5986 * the given C-Find query. | |
5987 * | |
5988 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
5989 * @param query The C-Find query. | |
5990 * @return The number of tags. | |
5991 * @ingroup DicomCallbacks | |
5992 **/ | |
5993 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFindQuerySize( | |
5994 OrthancPluginContext* context, | |
5995 const OrthancPluginFindQuery* query) | |
5996 { | |
5997 uint32_t count = 0; | |
5998 | |
5999 _OrthancPluginFindOperation params; | |
6000 memset(¶ms, 0, sizeof(params)); | |
6001 params.query = query; | |
6002 params.resultUint32 = &count; | |
6003 | |
6004 if (context->InvokeService(context, _OrthancPluginService_GetFindQuerySize, ¶ms) != OrthancPluginErrorCode_Success) | |
6005 { | |
6006 /* Error */ | |
6007 return 0; | |
6008 } | |
6009 else | |
6010 { | |
6011 return count; | |
6012 } | |
6013 } | |
6014 | |
6015 | |
6016 /** | |
6017 * @brief Get one tag in a C-Find query. | |
6018 * | |
6019 * This function returns the group and the element of one DICOM tag | |
6020 * in the given C-Find query. | |
6021 * | |
6022 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6023 * @param group The group of the tag (output). | |
6024 * @param element The element of the tag (output). | |
6025 * @param query The C-Find query. | |
6026 * @param index The index of the tag of interest. | |
6027 * @return 0 if success, other value if error. | |
6028 * @ingroup DicomCallbacks | |
6029 **/ | |
6030 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetFindQueryTag( | |
6031 OrthancPluginContext* context, | |
6032 uint16_t* group, | |
6033 uint16_t* element, | |
6034 const OrthancPluginFindQuery* query, | |
6035 uint32_t index) | |
6036 { | |
6037 _OrthancPluginFindOperation params; | |
6038 memset(¶ms, 0, sizeof(params)); | |
6039 params.query = query; | |
6040 params.index = index; | |
6041 params.resultGroup = group; | |
6042 params.resultElement = element; | |
6043 | |
6044 return context->InvokeService(context, _OrthancPluginService_GetFindQueryTag, ¶ms); | |
6045 } | |
6046 | |
6047 | |
6048 /** | |
6049 * @brief Get the symbolic name of one tag in a C-Find query. | |
6050 * | |
6051 * This function returns the symbolic name of one DICOM tag in the | |
6052 * given C-Find query. | |
6053 * | |
6054 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6055 * @param query The C-Find query. | |
6056 * @param index The index of the tag of interest. | |
6057 * @return The NULL value in case of error, or a string containing the name of the tag. | |
6058 * @return 0 if success, other value if error. | |
6059 * @ingroup DicomCallbacks | |
6060 **/ | |
6061 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetFindQueryTagName( | |
6062 OrthancPluginContext* context, | |
6063 const OrthancPluginFindQuery* query, | |
6064 uint32_t index) | |
6065 { | |
6066 char* result; | |
6067 | |
6068 _OrthancPluginFindOperation params; | |
6069 memset(¶ms, 0, sizeof(params)); | |
6070 params.query = query; | |
6071 params.index = index; | |
6072 params.resultString = &result; | |
6073 | |
6074 if (context->InvokeService(context, _OrthancPluginService_GetFindQueryTagName, ¶ms) != OrthancPluginErrorCode_Success) | |
6075 { | |
6076 /* Error */ | |
6077 return NULL; | |
6078 } | |
6079 else | |
6080 { | |
6081 return result; | |
6082 } | |
6083 } | |
6084 | |
6085 | |
6086 /** | |
6087 * @brief Get the value associated with one tag in a C-Find query. | |
6088 * | |
6089 * This function returns the value associated with one tag in the | |
6090 * given C-Find query. | |
6091 * | |
6092 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6093 * @param query The C-Find query. | |
6094 * @param index The index of the tag of interest. | |
6095 * @return The NULL value in case of error, or a string containing the value of the tag. | |
6096 * @return 0 if success, other value if error. | |
6097 * @ingroup DicomCallbacks | |
6098 **/ | |
6099 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetFindQueryValue( | |
6100 OrthancPluginContext* context, | |
6101 const OrthancPluginFindQuery* query, | |
6102 uint32_t index) | |
6103 { | |
6104 char* result; | |
6105 | |
6106 _OrthancPluginFindOperation params; | |
6107 memset(¶ms, 0, sizeof(params)); | |
6108 params.query = query; | |
6109 params.index = index; | |
6110 params.resultString = &result; | |
6111 | |
6112 if (context->InvokeService(context, _OrthancPluginService_GetFindQueryValue, ¶ms) != OrthancPluginErrorCode_Success) | |
6113 { | |
6114 /* Error */ | |
6115 return NULL; | |
6116 } | |
6117 else | |
6118 { | |
6119 return result; | |
6120 } | |
6121 } | |
6122 | |
6123 | |
6124 | |
6125 | |
6126 typedef struct | |
6127 { | |
6128 OrthancPluginMoveCallback callback; | |
6129 OrthancPluginGetMoveSize getMoveSize; | |
6130 OrthancPluginApplyMove applyMove; | |
6131 OrthancPluginFreeMove freeMove; | |
6132 } _OrthancPluginMoveCallback; | |
6133 | |
6134 /** | |
6135 * @brief Register a callback to handle C-Move requests. | |
6136 * | |
6137 * This function registers a callback to handle C-Move SCP requests. | |
6138 * | |
6139 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6140 * @param callback The main callback. | |
6141 * @param getMoveSize Callback to read the number of C-Move suboperations. | |
6142 * @param applyMove Callback to apply one C-Move suboperation. | |
6143 * @param freeMove Callback to free the C-Move driver. | |
6144 * @return 0 if success, other value if error. | |
6145 * @ingroup DicomCallbacks | |
6146 **/ | |
6147 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterMoveCallback( | |
6148 OrthancPluginContext* context, | |
6149 OrthancPluginMoveCallback callback, | |
6150 OrthancPluginGetMoveSize getMoveSize, | |
6151 OrthancPluginApplyMove applyMove, | |
6152 OrthancPluginFreeMove freeMove) | |
6153 { | |
6154 _OrthancPluginMoveCallback params; | |
6155 params.callback = callback; | |
6156 params.getMoveSize = getMoveSize; | |
6157 params.applyMove = applyMove; | |
6158 params.freeMove = freeMove; | |
6159 | |
6160 return context->InvokeService(context, _OrthancPluginService_RegisterMoveCallback, ¶ms); | |
6161 } | |
6162 | |
6163 | |
6164 | |
6165 typedef struct | |
6166 { | |
6167 OrthancPluginFindMatcher** target; | |
6168 const void* query; | |
6169 uint32_t size; | |
6170 } _OrthancPluginCreateFindMatcher; | |
6171 | |
6172 | |
6173 /** | |
6174 * @brief Create a C-Find matcher. | |
6175 * | |
6176 * This function creates a "matcher" object that can be used to | |
6177 * check whether a DICOM instance matches a C-Find query. The C-Find | |
6178 * query must be expressed as a DICOM buffer. | |
6179 * | |
6180 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6181 * @param query The C-Find DICOM query. | |
6182 * @param size The size of the DICOM query. | |
6183 * @return The newly allocated matcher. It must be freed with OrthancPluginFreeFindMatcher(). | |
6184 * @ingroup Toolbox | |
6185 **/ | |
6186 ORTHANC_PLUGIN_INLINE OrthancPluginFindMatcher* OrthancPluginCreateFindMatcher( | |
6187 OrthancPluginContext* context, | |
6188 const void* query, | |
6189 uint32_t size) | |
6190 { | |
6191 OrthancPluginFindMatcher* target = NULL; | |
6192 | |
6193 _OrthancPluginCreateFindMatcher params; | |
6194 memset(¶ms, 0, sizeof(params)); | |
6195 params.target = ⌖ | |
6196 params.query = query; | |
6197 params.size = size; | |
6198 | |
6199 if (context->InvokeService(context, _OrthancPluginService_CreateFindMatcher, ¶ms) != OrthancPluginErrorCode_Success) | |
6200 { | |
6201 return NULL; | |
6202 } | |
6203 else | |
6204 { | |
6205 return target; | |
6206 } | |
6207 } | |
6208 | |
6209 | |
6210 typedef struct | |
6211 { | |
6212 OrthancPluginFindMatcher* matcher; | |
6213 } _OrthancPluginFreeFindMatcher; | |
6214 | |
6215 /** | |
6216 * @brief Free a C-Find matcher. | |
6217 * | |
6218 * This function frees a matcher that was created using OrthancPluginCreateFindMatcher(). | |
6219 * | |
6220 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6221 * @param matcher The matcher of interest. | |
6222 * @ingroup Toolbox | |
6223 **/ | |
6224 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeFindMatcher( | |
6225 OrthancPluginContext* context, | |
6226 OrthancPluginFindMatcher* matcher) | |
6227 { | |
6228 _OrthancPluginFreeFindMatcher params; | |
6229 params.matcher = matcher; | |
6230 | |
6231 context->InvokeService(context, _OrthancPluginService_FreeFindMatcher, ¶ms); | |
6232 } | |
6233 | |
6234 | |
6235 typedef struct | |
6236 { | |
6237 const OrthancPluginFindMatcher* matcher; | |
6238 const void* dicom; | |
6239 uint32_t size; | |
6240 int32_t* isMatch; | |
6241 } _OrthancPluginFindMatcherIsMatch; | |
6242 | |
6243 /** | |
6244 * @brief Test whether a DICOM instance matches a C-Find query. | |
6245 * | |
6246 * This function checks whether one DICOM instance matches C-Find | |
6247 * matcher that was previously allocated using | |
6248 * OrthancPluginCreateFindMatcher(). | |
6249 * | |
6250 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6251 * @param matcher The matcher of interest. | |
6252 * @param dicom The DICOM instance to be matched. | |
6253 * @param size The size of the DICOM instance. | |
6254 * @return 1 if the DICOM instance matches the query, 0 otherwise. | |
6255 * @ingroup Toolbox | |
6256 **/ | |
6257 ORTHANC_PLUGIN_INLINE int32_t OrthancPluginFindMatcherIsMatch( | |
6258 OrthancPluginContext* context, | |
6259 const OrthancPluginFindMatcher* matcher, | |
6260 const void* dicom, | |
6261 uint32_t size) | |
6262 { | |
6263 int32_t isMatch = 0; | |
6264 | |
6265 _OrthancPluginFindMatcherIsMatch params; | |
6266 params.matcher = matcher; | |
6267 params.dicom = dicom; | |
6268 params.size = size; | |
6269 params.isMatch = &isMatch; | |
6270 | |
6271 if (context->InvokeService(context, _OrthancPluginService_FindMatcherIsMatch, ¶ms) == OrthancPluginErrorCode_Success) | |
6272 { | |
6273 return isMatch; | |
6274 } | |
6275 else | |
6276 { | |
6277 /* Error: Assume non-match */ | |
6278 return 0; | |
6279 } | |
6280 } | |
6281 | |
6282 | |
6283 typedef struct | |
6284 { | |
6285 OrthancPluginIncomingHttpRequestFilter2 callback; | |
6286 } _OrthancPluginIncomingHttpRequestFilter2; | |
6287 | |
6288 /** | |
6289 * @brief Register a callback to filter incoming HTTP requests. | |
6290 * | |
6291 * This function registers a custom callback to filter incoming HTTP/REST | |
6292 * requests received by the HTTP server of Orthanc. | |
6293 * | |
6294 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6295 * @param callback The callback. | |
6296 * @return 0 if success, other value if error. | |
6297 * @ingroup Callbacks | |
6298 **/ | |
6299 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingHttpRequestFilter2( | |
6300 OrthancPluginContext* context, | |
6301 OrthancPluginIncomingHttpRequestFilter2 callback) | |
6302 { | |
6303 _OrthancPluginIncomingHttpRequestFilter2 params; | |
6304 params.callback = callback; | |
6305 | |
6306 return context->InvokeService(context, _OrthancPluginService_RegisterIncomingHttpRequestFilter2, ¶ms); | |
6307 } | |
6308 | |
6309 | |
6310 | |
6311 typedef struct | |
6312 { | |
6313 OrthancPluginPeers** peers; | |
6314 } _OrthancPluginGetPeers; | |
6315 | |
6316 /** | |
6317 * @brief Return the list of available Orthanc peers. | |
6318 * | |
6319 * This function returns the parameters of the Orthanc peers that are known to | |
6320 * the Orthanc server hosting the plugin. | |
6321 * | |
6322 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6323 * @return NULL if error, or a newly allocated opaque data structure containing the peers. | |
6324 * This structure must be freed with OrthancPluginFreePeers(). | |
6325 * @ingroup Toolbox | |
6326 **/ | |
6327 ORTHANC_PLUGIN_INLINE OrthancPluginPeers* OrthancPluginGetPeers( | |
6328 OrthancPluginContext* context) | |
6329 { | |
6330 OrthancPluginPeers* peers = NULL; | |
6331 | |
6332 _OrthancPluginGetPeers params; | |
6333 memset(¶ms, 0, sizeof(params)); | |
6334 params.peers = &peers; | |
6335 | |
6336 if (context->InvokeService(context, _OrthancPluginService_GetPeers, ¶ms) != OrthancPluginErrorCode_Success) | |
6337 { | |
6338 return NULL; | |
6339 } | |
6340 else | |
6341 { | |
6342 return peers; | |
6343 } | |
6344 } | |
6345 | |
6346 | |
6347 typedef struct | |
6348 { | |
6349 OrthancPluginPeers* peers; | |
6350 } _OrthancPluginFreePeers; | |
6351 | |
6352 /** | |
6353 * @brief Free the list of available Orthanc peers. | |
6354 * | |
6355 * This function frees the data structure returned by OrthancPluginGetPeers(). | |
6356 * | |
6357 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6358 * @param peers The data structure describing the Orthanc peers. | |
6359 * @ingroup Toolbox | |
6360 **/ | |
6361 ORTHANC_PLUGIN_INLINE void OrthancPluginFreePeers( | |
6362 OrthancPluginContext* context, | |
6363 OrthancPluginPeers* peers) | |
6364 { | |
6365 _OrthancPluginFreePeers params; | |
6366 params.peers = peers; | |
6367 | |
6368 context->InvokeService(context, _OrthancPluginService_FreePeers, ¶ms); | |
6369 } | |
6370 | |
6371 | |
6372 typedef struct | |
6373 { | |
6374 uint32_t* target; | |
6375 const OrthancPluginPeers* peers; | |
6376 } _OrthancPluginGetPeersCount; | |
6377 | |
6378 /** | |
6379 * @brief Get the number of Orthanc peers. | |
6380 * | |
6381 * This function returns the number of Orthanc peers. | |
6382 * | |
6383 * This function is thread-safe: Several threads sharing the same | |
6384 * OrthancPluginPeers object can simultaneously call this function. | |
6385 * | |
6386 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6387 * @param peers The data structure describing the Orthanc peers. | |
6388 * @result The number of peers. | |
6389 * @ingroup Toolbox | |
6390 **/ | |
6391 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetPeersCount( | |
6392 OrthancPluginContext* context, | |
6393 const OrthancPluginPeers* peers) | |
6394 { | |
6395 uint32_t target = 0; | |
6396 | |
6397 _OrthancPluginGetPeersCount params; | |
6398 memset(¶ms, 0, sizeof(params)); | |
6399 params.target = ⌖ | |
6400 params.peers = peers; | |
6401 | |
6402 if (context->InvokeService(context, _OrthancPluginService_GetPeersCount, ¶ms) != OrthancPluginErrorCode_Success) | |
6403 { | |
6404 /* Error */ | |
6405 return 0; | |
6406 } | |
6407 else | |
6408 { | |
6409 return target; | |
6410 } | |
6411 } | |
6412 | |
6413 | |
6414 typedef struct | |
6415 { | |
6416 const char** target; | |
6417 const OrthancPluginPeers* peers; | |
6418 uint32_t peerIndex; | |
6419 const char* userProperty; | |
6420 } _OrthancPluginGetPeerProperty; | |
6421 | |
6422 /** | |
6423 * @brief Get the symbolic name of an Orthanc peer. | |
6424 * | |
6425 * This function returns the symbolic name of the Orthanc peer, | |
6426 * which corresponds to the key of the "OrthancPeers" configuration | |
6427 * option of Orthanc. | |
6428 * | |
6429 * This function is thread-safe: Several threads sharing the same | |
6430 * OrthancPluginPeers object can simultaneously call this function. | |
6431 * | |
6432 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6433 * @param peers The data structure describing the Orthanc peers. | |
6434 * @param peerIndex The index of the peer of interest. | |
6435 * This value must be lower than OrthancPluginGetPeersCount(). | |
6436 * @result The symbolic name, or NULL in the case of an error. | |
6437 * @ingroup Toolbox | |
6438 **/ | |
6439 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetPeerName( | |
6440 OrthancPluginContext* context, | |
6441 const OrthancPluginPeers* peers, | |
6442 uint32_t peerIndex) | |
6443 { | |
6444 const char* target = NULL; | |
6445 | |
6446 _OrthancPluginGetPeerProperty params; | |
6447 memset(¶ms, 0, sizeof(params)); | |
6448 params.target = ⌖ | |
6449 params.peers = peers; | |
6450 params.peerIndex = peerIndex; | |
6451 params.userProperty = NULL; | |
6452 | |
6453 if (context->InvokeService(context, _OrthancPluginService_GetPeerName, ¶ms) != OrthancPluginErrorCode_Success) | |
6454 { | |
6455 /* Error */ | |
6456 return NULL; | |
6457 } | |
6458 else | |
6459 { | |
6460 return target; | |
6461 } | |
6462 } | |
6463 | |
6464 | |
6465 /** | |
6466 * @brief Get the base URL of an Orthanc peer. | |
6467 * | |
6468 * This function returns the base URL to the REST API of some Orthanc peer. | |
6469 * | |
6470 * This function is thread-safe: Several threads sharing the same | |
6471 * OrthancPluginPeers object can simultaneously call this function. | |
6472 * | |
6473 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6474 * @param peers The data structure describing the Orthanc peers. | |
6475 * @param peerIndex The index of the peer of interest. | |
6476 * This value must be lower than OrthancPluginGetPeersCount(). | |
6477 * @result The URL, or NULL in the case of an error. | |
6478 * @ingroup Toolbox | |
6479 **/ | |
6480 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetPeerUrl( | |
6481 OrthancPluginContext* context, | |
6482 const OrthancPluginPeers* peers, | |
6483 uint32_t peerIndex) | |
6484 { | |
6485 const char* target = NULL; | |
6486 | |
6487 _OrthancPluginGetPeerProperty params; | |
6488 memset(¶ms, 0, sizeof(params)); | |
6489 params.target = ⌖ | |
6490 params.peers = peers; | |
6491 params.peerIndex = peerIndex; | |
6492 params.userProperty = NULL; | |
6493 | |
6494 if (context->InvokeService(context, _OrthancPluginService_GetPeerUrl, ¶ms) != OrthancPluginErrorCode_Success) | |
6495 { | |
6496 /* Error */ | |
6497 return NULL; | |
6498 } | |
6499 else | |
6500 { | |
6501 return target; | |
6502 } | |
6503 } | |
6504 | |
6505 | |
6506 | |
6507 /** | |
6508 * @brief Get some user-defined property of an Orthanc peer. | |
6509 * | |
6510 * This function returns some user-defined property of some Orthanc | |
6511 * peer. An user-defined property is a property that is associated | |
6512 * with the peer in the Orthanc configuration file, but that is not | |
6513 * recognized by the Orthanc core. | |
6514 * | |
6515 * This function is thread-safe: Several threads sharing the same | |
6516 * OrthancPluginPeers object can simultaneously call this function. | |
6517 * | |
6518 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6519 * @param peers The data structure describing the Orthanc peers. | |
6520 * @param peerIndex The index of the peer of interest. | |
6521 * This value must be lower than OrthancPluginGetPeersCount(). | |
6522 * @param userProperty The user property of interest. | |
6523 * @result The value of the user property, or NULL if it is not defined. | |
6524 * @ingroup Toolbox | |
6525 **/ | |
6526 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetPeerUserProperty( | |
6527 OrthancPluginContext* context, | |
6528 const OrthancPluginPeers* peers, | |
6529 uint32_t peerIndex, | |
6530 const char* userProperty) | |
6531 { | |
6532 const char* target = NULL; | |
6533 | |
6534 _OrthancPluginGetPeerProperty params; | |
6535 memset(¶ms, 0, sizeof(params)); | |
6536 params.target = ⌖ | |
6537 params.peers = peers; | |
6538 params.peerIndex = peerIndex; | |
6539 params.userProperty = userProperty; | |
6540 | |
6541 if (context->InvokeService(context, _OrthancPluginService_GetPeerUserProperty, ¶ms) != OrthancPluginErrorCode_Success) | |
6542 { | |
6543 /* No such user property */ | |
6544 return NULL; | |
6545 } | |
6546 else | |
6547 { | |
6548 return target; | |
6549 } | |
6550 } | |
6551 | |
6552 | |
6553 | |
6554 typedef struct | |
6555 { | |
6556 OrthancPluginMemoryBuffer* answerBody; | |
6557 OrthancPluginMemoryBuffer* answerHeaders; | |
6558 uint16_t* httpStatus; | |
6559 const OrthancPluginPeers* peers; | |
6560 uint32_t peerIndex; | |
6561 OrthancPluginHttpMethod method; | |
6562 const char* uri; | |
6563 uint32_t additionalHeadersCount; | |
6564 const char* const* additionalHeadersKeys; | |
6565 const char* const* additionalHeadersValues; | |
6566 const void* body; | |
6567 uint32_t bodySize; | |
6568 uint32_t timeout; | |
6569 } _OrthancPluginCallPeerApi; | |
6570 | |
6571 /** | |
6572 * @brief Call the REST API of an Orthanc peer. | |
6573 * | |
6574 * Make a REST call to the given URI in the REST API of a remote | |
6575 * Orthanc peer. The result to the query is stored into a newly | |
6576 * allocated memory buffer. The HTTP request will be done according | |
6577 * to the "OrthancPeers" configuration option of Orthanc. | |
6578 * | |
6579 * This function is thread-safe: Several threads sharing the same | |
6580 * OrthancPluginPeers object can simultaneously call this function. | |
6581 * | |
6582 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6583 * @param answerBody The target memory buffer (out argument). | |
6584 * It must be freed with OrthancPluginFreeMemoryBuffer(). | |
6585 * The value of this argument is ignored if the HTTP method is DELETE. | |
6586 * @param answerHeaders The target memory buffer for the HTTP headers in the answers (out argument). | |
6587 * The answer headers are formatted as a JSON object (associative array). | |
6588 * The buffer must be freed with OrthancPluginFreeMemoryBuffer(). | |
6589 * This argument can be set to NULL if the plugin has no interest in the HTTP headers. | |
6590 * @param httpStatus The HTTP status after the execution of the request (out argument). | |
6591 * @param peers The data structure describing the Orthanc peers. | |
6592 * @param peerIndex The index of the peer of interest. | |
6593 * This value must be lower than OrthancPluginGetPeersCount(). | |
6594 * @param method HTTP method to be used. | |
6595 * @param uri The URI of interest in the REST API. | |
6596 * @param additionalHeadersCount The number of HTTP headers to be added to the | |
6597 * HTTP headers provided in the global configuration of Orthanc. | |
6598 * @param additionalHeadersKeys Array containing the keys of the HTTP headers (can be <tt>NULL</tt> if no header). | |
6599 * @param additionalHeadersValues Array containing the values of the HTTP headers (can be <tt>NULL</tt> if no header). | |
6600 * @param body The HTTP body for a POST or PUT request. | |
6601 * @param bodySize The size of the body. | |
6602 * @param timeout Timeout in seconds (0 for default timeout). | |
6603 * @return 0 if success, or the error code if failure. | |
6604 * @see OrthancPluginHttpClient() | |
6605 * @ingroup Toolbox | |
6606 **/ | |
6607 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCallPeerApi( | |
6608 OrthancPluginContext* context, | |
6609 OrthancPluginMemoryBuffer* answerBody, | |
6610 OrthancPluginMemoryBuffer* answerHeaders, | |
6611 uint16_t* httpStatus, | |
6612 const OrthancPluginPeers* peers, | |
6613 uint32_t peerIndex, | |
6614 OrthancPluginHttpMethod method, | |
6615 const char* uri, | |
6616 uint32_t additionalHeadersCount, | |
6617 const char* const* additionalHeadersKeys, | |
6618 const char* const* additionalHeadersValues, | |
6619 const void* body, | |
6620 uint32_t bodySize, | |
6621 uint32_t timeout) | |
6622 { | |
6623 _OrthancPluginCallPeerApi params; | |
6624 memset(¶ms, 0, sizeof(params)); | |
6625 | |
6626 params.answerBody = answerBody; | |
6627 params.answerHeaders = answerHeaders; | |
6628 params.httpStatus = httpStatus; | |
6629 params.peers = peers; | |
6630 params.peerIndex = peerIndex; | |
6631 params.method = method; | |
6632 params.uri = uri; | |
6633 params.additionalHeadersCount = additionalHeadersCount; | |
6634 params.additionalHeadersKeys = additionalHeadersKeys; | |
6635 params.additionalHeadersValues = additionalHeadersValues; | |
6636 params.body = body; | |
6637 params.bodySize = bodySize; | |
6638 params.timeout = timeout; | |
6639 | |
6640 return context->InvokeService(context, _OrthancPluginService_CallPeerApi, ¶ms); | |
6641 } | |
6642 | |
6643 | |
6644 | |
6645 | |
6646 | |
6647 typedef struct | |
6648 { | |
6649 OrthancPluginJob** target; | |
6650 void *job; | |
6651 OrthancPluginJobFinalize finalize; | |
6652 const char *type; | |
6653 OrthancPluginJobGetProgress getProgress; | |
6654 OrthancPluginJobGetContent getContent; | |
6655 OrthancPluginJobGetSerialized getSerialized; | |
6656 OrthancPluginJobStep step; | |
6657 OrthancPluginJobStop stop; | |
6658 OrthancPluginJobReset reset; | |
6659 } _OrthancPluginCreateJob; | |
6660 | |
6661 /** | |
6662 * @brief Create a custom job. | |
6663 * | |
6664 * This function creates a custom job to be run by the jobs engine | |
6665 * of Orthanc. | |
6666 * | |
6667 * Orthanc starts one dedicated thread per custom job that is | |
6668 * running. It is guaranteed that all the callbacks will only be | |
6669 * called from this single dedicated thread, in mutual exclusion: As | |
6670 * a consequence, it is *not* mandatory to protect the various | |
6671 * callbacks by mutexes. | |
6672 * | |
6673 * The custom job can nonetheless launch its own processing threads | |
6674 * on the first call to the "step()" callback, and stop them once | |
6675 * the "stop()" callback is called. | |
6676 * | |
6677 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6678 * @param job The job to be executed. | |
6679 * @param finalize The finalization callback. | |
6680 * @param type The type of the job, provided to the job unserializer. | |
6681 * See OrthancPluginRegisterJobsUnserializer(). | |
6682 * @param getProgress The progress callback. | |
6683 * @param getContent The content callback. | |
6684 * @param getSerialized The serialization callback. | |
6685 * @param step The callback to execute the individual steps of the job. | |
6686 * @param stop The callback that is invoked once the job leaves the "running" state. | |
6687 * @param reset The callback that is invoked if a stopped job is started again. | |
6688 * @return The newly allocated job. It must be freed with OrthancPluginFreeJob(), | |
6689 * as long as it is not submitted with OrthancPluginSubmitJob(). | |
6690 * @ingroup Toolbox | |
6691 **/ | |
6692 ORTHANC_PLUGIN_INLINE OrthancPluginJob *OrthancPluginCreateJob( | |
6693 OrthancPluginContext *context, | |
6694 void *job, | |
6695 OrthancPluginJobFinalize finalize, | |
6696 const char *type, | |
6697 OrthancPluginJobGetProgress getProgress, | |
6698 OrthancPluginJobGetContent getContent, | |
6699 OrthancPluginJobGetSerialized getSerialized, | |
6700 OrthancPluginJobStep step, | |
6701 OrthancPluginJobStop stop, | |
6702 OrthancPluginJobReset reset) | |
6703 { | |
6704 OrthancPluginJob* target = NULL; | |
6705 | |
6706 _OrthancPluginCreateJob params; | |
6707 memset(¶ms, 0, sizeof(params)); | |
6708 | |
6709 params.target = ⌖ | |
6710 params.job = job; | |
6711 params.finalize = finalize; | |
6712 params.type = type; | |
6713 params.getProgress = getProgress; | |
6714 params.getContent = getContent; | |
6715 params.getSerialized = getSerialized; | |
6716 params.step = step; | |
6717 params.stop = stop; | |
6718 params.reset = reset; | |
6719 | |
6720 if (context->InvokeService(context, _OrthancPluginService_CreateJob, ¶ms) != OrthancPluginErrorCode_Success || | |
6721 target == NULL) | |
6722 { | |
6723 /* Error */ | |
6724 return NULL; | |
6725 } | |
6726 else | |
6727 { | |
6728 return target; | |
6729 } | |
6730 } | |
6731 | |
6732 | |
6733 typedef struct | |
6734 { | |
6735 OrthancPluginJob* job; | |
6736 } _OrthancPluginFreeJob; | |
6737 | |
6738 /** | |
6739 * @brief Free a custom job. | |
6740 * | |
6741 * This function frees an image that was created with OrthancPluginCreateJob(). | |
6742 * | |
6743 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6744 * @param job The job. | |
6745 * @ingroup Toolbox | |
6746 **/ | |
6747 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeJob( | |
6748 OrthancPluginContext* context, | |
6749 OrthancPluginJob* job) | |
6750 { | |
6751 _OrthancPluginFreeJob params; | |
6752 params.job = job; | |
6753 | |
6754 context->InvokeService(context, _OrthancPluginService_FreeJob, ¶ms); | |
6755 } | |
6756 | |
6757 | |
6758 | |
6759 typedef struct | |
6760 { | |
6761 char** resultId; | |
6762 OrthancPluginJob *job; | |
6763 int priority; | |
6764 } _OrthancPluginSubmitJob; | |
6765 | |
6766 /** | |
6767 * @brief Submit a new job to the jobs engine of Orthanc. | |
6768 * | |
6769 * This function adds the given job to the pending jobs of | |
6770 * Orthanc. Orthanc will take take of freeing it by invoking the | |
6771 * finalization callback provided to OrthancPluginCreateJob(). | |
6772 * | |
6773 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6774 * @param job The job, as received by OrthancPluginCreateJob(). | |
6775 * @param priority The priority of the job. | |
6776 * @return ID of the newly-submitted job. This string must be freed by OrthancPluginFreeString(). | |
6777 * @ingroup Toolbox | |
6778 **/ | |
6779 ORTHANC_PLUGIN_INLINE char *OrthancPluginSubmitJob( | |
6780 OrthancPluginContext *context, | |
6781 OrthancPluginJob *job, | |
6782 int priority) | |
6783 { | |
6784 char* resultId = NULL; | |
6785 | |
6786 _OrthancPluginSubmitJob params; | |
6787 memset(¶ms, 0, sizeof(params)); | |
6788 | |
6789 params.resultId = &resultId; | |
6790 params.job = job; | |
6791 params.priority = priority; | |
6792 | |
6793 if (context->InvokeService(context, _OrthancPluginService_SubmitJob, ¶ms) != OrthancPluginErrorCode_Success || | |
6794 resultId == NULL) | |
6795 { | |
6796 /* Error */ | |
6797 return NULL; | |
6798 } | |
6799 else | |
6800 { | |
6801 return resultId; | |
6802 } | |
6803 } | |
6804 | |
6805 | |
6806 | |
6807 typedef struct | |
6808 { | |
6809 OrthancPluginJobsUnserializer unserializer; | |
6810 } _OrthancPluginJobsUnserializer; | |
6811 | |
6812 /** | |
6813 * @brief Register an unserializer for custom jobs. | |
6814 * | |
6815 * This function registers an unserializer that decodes custom jobs | |
6816 * from a JSON string. This callback is invoked when the jobs engine | |
6817 * of Orthanc is started (on Orthanc initialization), for each job | |
6818 * that is stored in the Orthanc database. | |
6819 * | |
6820 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6821 * @param unserializer The job unserializer. | |
6822 * @ingroup Callbacks | |
6823 **/ | |
6824 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterJobsUnserializer( | |
6825 OrthancPluginContext* context, | |
6826 OrthancPluginJobsUnserializer unserializer) | |
6827 { | |
6828 _OrthancPluginJobsUnserializer params; | |
6829 params.unserializer = unserializer; | |
6830 | |
6831 context->InvokeService(context, _OrthancPluginService_RegisterJobsUnserializer, ¶ms); | |
6832 } | |
6833 | |
6834 | |
6835 | |
6836 typedef struct | |
6837 { | |
6838 OrthancPluginRestOutput* output; | |
6839 const char* details; | |
6840 uint8_t log; | |
6841 } _OrthancPluginSetHttpErrorDetails; | |
6842 | |
6843 /** | |
6844 * @brief Provide a detailed description for an HTTP error. | |
6845 * | |
6846 * This function sets the detailed description associated with an | |
6847 * HTTP error. This description will be displayed in the "Details" | |
6848 * field of the JSON body of the HTTP answer. It is only taken into | |
6849 * consideration if the REST callback returns an error code that is | |
6850 * different from "OrthancPluginErrorCode_Success", and if the | |
6851 * "HttpDescribeErrors" configuration option of Orthanc is set to | |
6852 * "true". | |
6853 * | |
6854 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6855 * @param output The HTTP connection to the client application. | |
6856 * @param details The details of the error message. | |
6857 * @param log Whether to also write the detailed error to the Orthanc logs. | |
6858 * @ingroup REST | |
6859 **/ | |
6860 ORTHANC_PLUGIN_INLINE void OrthancPluginSetHttpErrorDetails( | |
6861 OrthancPluginContext* context, | |
6862 OrthancPluginRestOutput* output, | |
6863 const char* details, | |
6864 uint8_t log) | |
6865 { | |
6866 _OrthancPluginSetHttpErrorDetails params; | |
6867 params.output = output; | |
6868 params.details = details; | |
6869 params.log = log; | |
6870 context->InvokeService(context, _OrthancPluginService_SetHttpErrorDetails, ¶ms); | |
6871 } | |
6872 | |
6873 | |
6874 | |
6875 typedef struct | |
6876 { | |
6877 const char** result; | |
6878 const char* argument; | |
6879 } _OrthancPluginRetrieveStaticString; | |
6880 | |
6881 /** | |
6882 * @brief Detect the MIME type of a file. | |
6883 * | |
6884 * This function returns the MIME type of a file by inspecting its extension. | |
6885 * | |
6886 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6887 * @param path Path to the file. | |
6888 * @return The MIME type. This is a statically-allocated | |
6889 * string, do not free it. | |
6890 * @ingroup Toolbox | |
6891 **/ | |
6892 ORTHANC_PLUGIN_INLINE const char* OrthancPluginAutodetectMimeType( | |
6893 OrthancPluginContext* context, | |
6894 const char* path) | |
6895 { | |
6896 const char* result = NULL; | |
6897 | |
6898 _OrthancPluginRetrieveStaticString params; | |
6899 params.result = &result; | |
6900 params.argument = path; | |
6901 | |
6902 if (context->InvokeService(context, _OrthancPluginService_AutodetectMimeType, ¶ms) != OrthancPluginErrorCode_Success) | |
6903 { | |
6904 /* Error */ | |
6905 return NULL; | |
6906 } | |
6907 else | |
6908 { | |
6909 return result; | |
6910 } | |
6911 } | |
6912 | |
6913 | |
6914 | |
6915 typedef struct | |
6916 { | |
6917 const char* name; | |
6918 float value; | |
6919 OrthancPluginMetricsType type; | |
6920 } _OrthancPluginSetMetricsValue; | |
6921 | |
6922 /** | |
6923 * @brief Set the value of a metrics. | |
6924 * | |
6925 * This function sets the value of a metrics to monitor the behavior | |
6926 * of the plugin through tools such as Prometheus. The values of all | |
6927 * the metrics are stored within the Orthanc context. | |
6928 * | |
6929 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6930 * @param name The name of the metrics to be set. | |
6931 * @param value The value of the metrics. | |
6932 * @param type The type of the metrics. This parameter is only taken into consideration | |
6933 * the first time this metrics is set. | |
6934 * @ingroup Toolbox | |
6935 **/ | |
6936 ORTHANC_PLUGIN_INLINE void OrthancPluginSetMetricsValue( | |
6937 OrthancPluginContext* context, | |
6938 const char* name, | |
6939 float value, | |
6940 OrthancPluginMetricsType type) | |
6941 { | |
6942 _OrthancPluginSetMetricsValue params; | |
6943 params.name = name; | |
6944 params.value = value; | |
6945 params.type = type; | |
6946 context->InvokeService(context, _OrthancPluginService_SetMetricsValue, ¶ms); | |
6947 } | |
6948 | |
6949 | |
6950 | |
6951 typedef struct | |
6952 { | |
6953 OrthancPluginRefreshMetricsCallback callback; | |
6954 } _OrthancPluginRegisterRefreshMetricsCallback; | |
6955 | |
6956 /** | |
6957 * @brief Register a callback to refresh the metrics. | |
6958 * | |
6959 * This function registers a callback to refresh the metrics. The | |
6960 * callback must make calls to OrthancPluginSetMetricsValue(). | |
6961 * | |
6962 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6963 * @param callback The callback function to handle the refresh. | |
6964 * @ingroup Callbacks | |
6965 **/ | |
6966 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRefreshMetricsCallback( | |
6967 OrthancPluginContext* context, | |
6968 OrthancPluginRefreshMetricsCallback callback) | |
6969 { | |
6970 _OrthancPluginRegisterRefreshMetricsCallback params; | |
6971 params.callback = callback; | |
6972 context->InvokeService(context, _OrthancPluginService_RegisterRefreshMetricsCallback, ¶ms); | |
6973 } | |
6974 | |
6975 | |
6976 | |
6977 | |
6978 typedef struct | |
6979 { | |
6980 char** target; | |
6981 const void* dicom; | |
6982 uint32_t dicomSize; | |
6983 OrthancPluginDicomWebBinaryCallback callback; | |
6984 } _OrthancPluginEncodeDicomWeb; | |
6985 | |
6986 /** | |
6987 * @brief Convert a DICOM instance to DICOMweb JSON. | |
6988 * | |
6989 * This function converts a memory buffer containing a DICOM instance, | |
6990 * into its DICOMweb JSON representation. | |
6991 * | |
6992 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
6993 * @param dicom Pointer to the DICOM instance. | |
6994 * @param dicomSize Size of the DICOM instance. | |
6995 * @param callback Callback to set the value of the binary tags. | |
6996 * @see OrthancPluginCreateDicom() | |
6997 * @return The NULL value in case of error, or the JSON document. This string must | |
6998 * be freed by OrthancPluginFreeString(). | |
6999 * @deprecated OrthancPluginEncodeDicomWebJson2() | |
7000 * @ingroup Toolbox | |
7001 **/ | |
7002 ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebJson( | |
7003 OrthancPluginContext* context, | |
7004 const void* dicom, | |
7005 uint32_t dicomSize, | |
7006 OrthancPluginDicomWebBinaryCallback callback) | |
7007 { | |
7008 char* target = NULL; | |
7009 | |
7010 _OrthancPluginEncodeDicomWeb params; | |
7011 params.target = ⌖ | |
7012 params.dicom = dicom; | |
7013 params.dicomSize = dicomSize; | |
7014 params.callback = callback; | |
7015 | |
7016 if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebJson, ¶ms) != OrthancPluginErrorCode_Success) | |
7017 { | |
7018 /* Error */ | |
7019 return NULL; | |
7020 } | |
7021 else | |
7022 { | |
7023 return target; | |
7024 } | |
7025 } | |
7026 | |
7027 | |
7028 /** | |
7029 * @brief Convert a DICOM instance to DICOMweb XML. | |
7030 * | |
7031 * This function converts a memory buffer containing a DICOM instance, | |
7032 * into its DICOMweb XML representation. | |
7033 * | |
7034 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
7035 * @param dicom Pointer to the DICOM instance. | |
7036 * @param dicomSize Size of the DICOM instance. | |
7037 * @param callback Callback to set the value of the binary tags. | |
7038 * @return The NULL value in case of error, or the XML document. This string must | |
7039 * be freed by OrthancPluginFreeString(). | |
7040 * @see OrthancPluginCreateDicom() | |
7041 * @deprecated OrthancPluginEncodeDicomWebXml2() | |
7042 * @ingroup Toolbox | |
7043 **/ | |
7044 ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebXml( | |
7045 OrthancPluginContext* context, | |
7046 const void* dicom, | |
7047 uint32_t dicomSize, | |
7048 OrthancPluginDicomWebBinaryCallback callback) | |
7049 { | |
7050 char* target = NULL; | |
7051 | |
7052 _OrthancPluginEncodeDicomWeb params; | |
7053 params.target = ⌖ | |
7054 params.dicom = dicom; | |
7055 params.dicomSize = dicomSize; | |
7056 params.callback = callback; | |
7057 | |
7058 if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebXml, ¶ms) != OrthancPluginErrorCode_Success) | |
7059 { | |
7060 /* Error */ | |
7061 return NULL; | |
7062 } | |
7063 else | |
7064 { | |
7065 return target; | |
7066 } | |
7067 } | |
7068 | |
7069 | |
7070 | |
7071 typedef struct | |
7072 { | |
7073 char** target; | |
7074 const void* dicom; | |
7075 uint32_t dicomSize; | |
7076 OrthancPluginDicomWebBinaryCallback2 callback; | |
7077 void* payload; | |
7078 } _OrthancPluginEncodeDicomWeb2; | |
7079 | |
7080 /** | |
7081 * @brief Convert a DICOM instance to DICOMweb JSON. | |
7082 * | |
7083 * This function converts a memory buffer containing a DICOM instance, | |
7084 * into its DICOMweb JSON representation. | |
7085 * | |
7086 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
7087 * @param dicom Pointer to the DICOM instance. | |
7088 * @param dicomSize Size of the DICOM instance. | |
7089 * @param callback Callback to set the value of the binary tags. | |
7090 * @param payload User payload. | |
7091 * @return The NULL value in case of error, or the JSON document. This string must | |
7092 * be freed by OrthancPluginFreeString(). | |
7093 * @see OrthancPluginCreateDicom() | |
7094 * @ingroup Toolbox | |
7095 **/ | |
7096 ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebJson2( | |
7097 OrthancPluginContext* context, | |
7098 const void* dicom, | |
7099 uint32_t dicomSize, | |
7100 OrthancPluginDicomWebBinaryCallback2 callback, | |
7101 void* payload) | |
7102 { | |
7103 char* target = NULL; | |
7104 | |
7105 _OrthancPluginEncodeDicomWeb2 params; | |
7106 params.target = ⌖ | |
7107 params.dicom = dicom; | |
7108 params.dicomSize = dicomSize; | |
7109 params.callback = callback; | |
7110 params.payload = payload; | |
7111 | |
7112 if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebJson2, ¶ms) != OrthancPluginErrorCode_Success) | |
7113 { | |
7114 /* Error */ | |
7115 return NULL; | |
7116 } | |
7117 else | |
7118 { | |
7119 return target; | |
7120 } | |
7121 } | |
7122 | |
7123 | |
7124 /** | |
7125 * @brief Convert a DICOM instance to DICOMweb XML. | |
7126 * | |
7127 * This function converts a memory buffer containing a DICOM instance, | |
7128 * into its DICOMweb XML representation. | |
7129 * | |
7130 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
7131 * @param dicom Pointer to the DICOM instance. | |
7132 * @param dicomSize Size of the DICOM instance. | |
7133 * @param callback Callback to set the value of the binary tags. | |
7134 * @param payload User payload. | |
7135 * @return The NULL value in case of error, or the XML document. This string must | |
7136 * be freed by OrthancPluginFreeString(). | |
7137 * @see OrthancPluginCreateDicom() | |
7138 * @ingroup Toolbox | |
7139 **/ | |
7140 ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebXml2( | |
7141 OrthancPluginContext* context, | |
7142 const void* dicom, | |
7143 uint32_t dicomSize, | |
7144 OrthancPluginDicomWebBinaryCallback2 callback, | |
7145 void* payload) | |
7146 { | |
7147 char* target = NULL; | |
7148 | |
7149 _OrthancPluginEncodeDicomWeb2 params; | |
7150 params.target = ⌖ | |
7151 params.dicom = dicom; | |
7152 params.dicomSize = dicomSize; | |
7153 params.callback = callback; | |
7154 params.payload = payload; | |
7155 | |
7156 if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebXml2, ¶ms) != OrthancPluginErrorCode_Success) | |
7157 { | |
7158 /* Error */ | |
7159 return NULL; | |
7160 } | |
7161 else | |
7162 { | |
7163 return target; | |
7164 } | |
7165 } | |
7166 | |
7167 | |
7168 | |
7169 /** | |
7170 * @brief Callback executed when a HTTP header is received during a chunked transfer. | |
7171 * | |
7172 * Signature of a callback function that is called by Orthanc acting | |
7173 * as a HTTP client during a chunked HTTP transfer, as soon as it | |
7174 * receives one HTTP header from the answer of the remote HTTP | |
7175 * server. | |
7176 * | |
7177 * @see OrthancPluginChunkedHttpClient() | |
7178 * @param answer The user payload, as provided by the calling plugin. | |
7179 * @param key The key of the HTTP header. | |
7180 * @param value The value of the HTTP header. | |
7181 * @return 0 if success, or the error code if failure. | |
7182 * @ingroup Toolbox | |
7183 **/ | |
7184 typedef OrthancPluginErrorCode (*OrthancPluginChunkedClientAnswerAddHeader) ( | |
7185 void* answer, | |
7186 const char* key, | |
7187 const char* value); | |
7188 | |
7189 | |
7190 /** | |
7191 * @brief Callback executed when an answer chunk is received during a chunked transfer. | |
7192 * | |
7193 * Signature of a callback function that is called by Orthanc acting | |
7194 * as a HTTP client during a chunked HTTP transfer, as soon as it | |
7195 * receives one data chunk from the answer of the remote HTTP | |
7196 * server. | |
7197 * | |
7198 * @see OrthancPluginChunkedHttpClient() | |
7199 * @param answer The user payload, as provided by the calling plugin. | |
7200 * @param data The content of the data chunk. | |
7201 * @param size The size of the data chunk. | |
7202 * @return 0 if success, or the error code if failure. | |
7203 * @ingroup Toolbox | |
7204 **/ | |
7205 typedef OrthancPluginErrorCode (*OrthancPluginChunkedClientAnswerAddChunk) ( | |
7206 void* answer, | |
7207 const void* data, | |
7208 uint32_t size); | |
7209 | |
7210 | |
7211 /** | |
7212 * @brief Callback to know whether the request body is entirely read during a chunked transfer | |
7213 * | |
7214 * Signature of a callback function that is called by Orthanc acting | |
7215 * as a HTTP client during a chunked HTTP transfer, while reading | |
7216 * the body of a POST or PUT request. The plugin must answer "1" as | |
7217 * soon as the body is entirely read: The "request" data structure | |
7218 * must act as an iterator. | |
7219 * | |
7220 * @see OrthancPluginChunkedHttpClient() | |
7221 * @param request The user payload, as provided by the calling plugin. | |
7222 * @return "1" if the body is over, or "0" if there is still data to be read. | |
7223 * @ingroup Toolbox | |
7224 **/ | |
7225 typedef uint8_t (*OrthancPluginChunkedClientRequestIsDone) (void* request); | |
7226 | |
7227 | |
7228 /** | |
7229 * @brief Callback to advance in the request body during a chunked transfer | |
7230 * | |
7231 * Signature of a callback function that is called by Orthanc acting | |
7232 * as a HTTP client during a chunked HTTP transfer, while reading | |
7233 * the body of a POST or PUT request. This function asks the plugin | |
7234 * to advance to the next chunk of data of the request body: The | |
7235 * "request" data structure must act as an iterator. | |
7236 * | |
7237 * @see OrthancPluginChunkedHttpClient() | |
7238 * @param request The user payload, as provided by the calling plugin. | |
7239 * @return 0 if success, or the error code if failure. | |
7240 * @ingroup Toolbox | |
7241 **/ | |
7242 typedef OrthancPluginErrorCode (*OrthancPluginChunkedClientRequestNext) (void* request); | |
7243 | |
7244 | |
7245 /** | |
7246 * @brief Callback to read the current chunk of the request body during a chunked transfer | |
7247 * | |
7248 * Signature of a callback function that is called by Orthanc acting | |
7249 * as a HTTP client during a chunked HTTP transfer, while reading | |
7250 * the body of a POST or PUT request. The plugin must provide the | |
7251 * content of the current chunk of data of the request body. | |
7252 * | |
7253 * @see OrthancPluginChunkedHttpClient() | |
7254 * @param request The user payload, as provided by the calling plugin. | |
7255 * @return The content of the current request chunk. | |
7256 * @ingroup Toolbox | |
7257 **/ | |
7258 typedef const void* (*OrthancPluginChunkedClientRequestGetChunkData) (void* request); | |
7259 | |
7260 | |
7261 /** | |
7262 * @brief Callback to read the size of the current request chunk during a chunked transfer | |
7263 * | |
7264 * Signature of a callback function that is called by Orthanc acting | |
7265 * as a HTTP client during a chunked HTTP transfer, while reading | |
7266 * the body of a POST or PUT request. The plugin must provide the | |
7267 * size of the current chunk of data of the request body. | |
7268 * | |
7269 * @see OrthancPluginChunkedHttpClient() | |
7270 * @param request The user payload, as provided by the calling plugin. | |
7271 * @return The size of the current request chunk. | |
7272 * @ingroup Toolbox | |
7273 **/ | |
7274 typedef uint32_t (*OrthancPluginChunkedClientRequestGetChunkSize) (void* request); | |
7275 | |
7276 | |
7277 typedef struct | |
7278 { | |
7279 void* answer; | |
7280 OrthancPluginChunkedClientAnswerAddChunk answerAddChunk; | |
7281 OrthancPluginChunkedClientAnswerAddHeader answerAddHeader; | |
7282 uint16_t* httpStatus; | |
7283 OrthancPluginHttpMethod method; | |
7284 const char* url; | |
7285 uint32_t headersCount; | |
7286 const char* const* headersKeys; | |
7287 const char* const* headersValues; | |
7288 void* request; | |
7289 OrthancPluginChunkedClientRequestIsDone requestIsDone; | |
7290 OrthancPluginChunkedClientRequestGetChunkData requestChunkData; | |
7291 OrthancPluginChunkedClientRequestGetChunkSize requestChunkSize; | |
7292 OrthancPluginChunkedClientRequestNext requestNext; | |
7293 const char* username; | |
7294 const char* password; | |
7295 uint32_t timeout; | |
7296 const char* certificateFile; | |
7297 const char* certificateKeyFile; | |
7298 const char* certificateKeyPassword; | |
7299 uint8_t pkcs11; | |
7300 } _OrthancPluginChunkedHttpClient; | |
7301 | |
7302 | |
7303 /** | |
7304 * @brief Issue a HTTP call, using chunked HTTP transfers. | |
7305 * | |
7306 * Make a HTTP call to the given URL using chunked HTTP | |
7307 * transfers. The request body is provided as an iterator over data | |
7308 * chunks. The answer is provided as a sequence of function calls | |
7309 * with the individual HTTP headers and answer chunks. | |
7310 * | |
7311 * Contrarily to OrthancPluginHttpClient() that entirely stores the | |
7312 * request body and the answer body in memory buffers, this function | |
7313 * uses chunked HTTP transfers. This results in a lower memory | |
7314 * consumption. Pay attention to the fact that Orthanc servers with | |
7315 * version <= 1.5.6 do not support chunked transfers: You must use | |
7316 * OrthancPluginHttpClient() if contacting such older servers. | |
7317 * | |
7318 * The HTTP request will be done accordingly to the global | |
7319 * configuration of Orthanc (in particular, the options "HttpProxy", | |
7320 * "HttpTimeout", "HttpsVerifyPeers", "HttpsCACertificates", and | |
7321 * "Pkcs11" will be taken into account). | |
7322 * | |
7323 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
7324 * @param answer The user payload for the answer body. It will be provided to the callbacks for the answer. | |
7325 * @param answerAddChunk Callback function to report a data chunk from the answer body. | |
7326 * @param answerAddHeader Callback function to report an HTTP header sent by the remote server. | |
7327 * @param httpStatus The HTTP status after the execution of the request (out argument). | |
7328 * @param method HTTP method to be used. | |
7329 * @param url The URL of interest. | |
7330 * @param headersCount The number of HTTP headers. | |
7331 * @param headersKeys Array containing the keys of the HTTP headers (can be <tt>NULL</tt> if no header). | |
7332 * @param headersValues Array containing the values of the HTTP headers (can be <tt>NULL</tt> if no header). | |
7333 * @param request The user payload containing the request body, and acting as an iterator. | |
7334 * It will be provided to the callbacks for the request. | |
7335 * @param requestIsDone Callback function to tell whether the request body is entirely read. | |
7336 * @param requestChunkData Callback function to get the content of the current data chunk of the request body. | |
7337 * @param requestChunkSize Callback function to get the size of the current data chunk of the request body. | |
7338 * @param requestNext Callback function to advance to the next data chunk of the request body. | |
7339 * @param username The username (can be <tt>NULL</tt> if no password protection). | |
7340 * @param password The password (can be <tt>NULL</tt> if no password protection). | |
7341 * @param timeout Timeout in seconds (0 for default timeout). | |
7342 * @param certificateFile Path to the client certificate for HTTPS, in PEM format | |
7343 * (can be <tt>NULL</tt> if no client certificate or if not using HTTPS). | |
7344 * @param certificateKeyFile Path to the key of the client certificate for HTTPS, in PEM format | |
7345 * (can be <tt>NULL</tt> if no client certificate or if not using HTTPS). | |
7346 * @param certificateKeyPassword Password to unlock the key of the client certificate | |
7347 * (can be <tt>NULL</tt> if no client certificate or if not using HTTPS). | |
7348 * @param pkcs11 Enable PKCS#11 client authentication for hardware security modules and smart cards. | |
7349 * @return 0 if success, or the error code if failure. | |
7350 * @see OrthancPluginHttpClient() | |
7351 * @ingroup Toolbox | |
7352 **/ | |
7353 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginChunkedHttpClient( | |
7354 OrthancPluginContext* context, | |
7355 void* answer, | |
7356 OrthancPluginChunkedClientAnswerAddChunk answerAddChunk, | |
7357 OrthancPluginChunkedClientAnswerAddHeader answerAddHeader, | |
7358 uint16_t* httpStatus, | |
7359 OrthancPluginHttpMethod method, | |
7360 const char* url, | |
7361 uint32_t headersCount, | |
7362 const char* const* headersKeys, | |
7363 const char* const* headersValues, | |
7364 void* request, | |
7365 OrthancPluginChunkedClientRequestIsDone requestIsDone, | |
7366 OrthancPluginChunkedClientRequestGetChunkData requestChunkData, | |
7367 OrthancPluginChunkedClientRequestGetChunkSize requestChunkSize, | |
7368 OrthancPluginChunkedClientRequestNext requestNext, | |
7369 const char* username, | |
7370 const char* password, | |
7371 uint32_t timeout, | |
7372 const char* certificateFile, | |
7373 const char* certificateKeyFile, | |
7374 const char* certificateKeyPassword, | |
7375 uint8_t pkcs11) | |
7376 { | |
7377 _OrthancPluginChunkedHttpClient params; | |
7378 memset(¶ms, 0, sizeof(params)); | |
7379 | |
7380 /* In common with OrthancPluginHttpClient() */ | |
7381 params.httpStatus = httpStatus; | |
7382 params.method = method; | |
7383 params.url = url; | |
7384 params.headersCount = headersCount; | |
7385 params.headersKeys = headersKeys; | |
7386 params.headersValues = headersValues; | |
7387 params.username = username; | |
7388 params.password = password; | |
7389 params.timeout = timeout; | |
7390 params.certificateFile = certificateFile; | |
7391 params.certificateKeyFile = certificateKeyFile; | |
7392 params.certificateKeyPassword = certificateKeyPassword; | |
7393 params.pkcs11 = pkcs11; | |
7394 | |
7395 /* For chunked body/answer */ | |
7396 params.answer = answer; | |
7397 params.answerAddChunk = answerAddChunk; | |
7398 params.answerAddHeader = answerAddHeader; | |
7399 params.request = request; | |
7400 params.requestIsDone = requestIsDone; | |
7401 params.requestChunkData = requestChunkData; | |
7402 params.requestChunkSize = requestChunkSize; | |
7403 params.requestNext = requestNext; | |
7404 | |
7405 return context->InvokeService(context, _OrthancPluginService_ChunkedHttpClient, ¶ms); | |
7406 } | |
7407 | |
7408 | |
7409 | |
7410 /** | |
7411 * @brief Opaque structure that reads the content of a HTTP request body during a chunked HTTP transfer. | |
7412 * @ingroup Callback | |
7413 **/ | |
7414 typedef struct _OrthancPluginServerChunkedRequestReader_t OrthancPluginServerChunkedRequestReader; | |
7415 | |
7416 | |
7417 | |
7418 /** | |
7419 * @brief Callback to create a reader to handle incoming chunked HTTP transfers. | |
7420 * | |
7421 * Signature of a callback function that is called by Orthanc acting | |
7422 * as a HTTP server that supports chunked HTTP transfers. This | |
7423 * callback is only invoked if the HTTP method is POST or PUT. The | |
7424 * callback must create an user-specific "reader" object that will | |
7425 * be fed with the body of the incoming body. | |
7426 * | |
7427 * @see OrthancPluginRegisterChunkedRestCallback() | |
7428 * @param reader Memory location that must be filled with the newly-created reader. | |
7429 * @param url The URI that is accessed. | |
7430 * @param request The body of the HTTP request. Note that "body" and "bodySize" are not used. | |
7431 * @return 0 if success, or the error code if failure. | |
7432 **/ | |
7433 typedef OrthancPluginErrorCode (*OrthancPluginServerChunkedRequestReaderFactory) ( | |
7434 OrthancPluginServerChunkedRequestReader** reader, | |
7435 const char* url, | |
7436 const OrthancPluginHttpRequest* request); | |
7437 | |
7438 | |
7439 /** | |
7440 * @brief Callback invoked whenever a new data chunk is available during a chunked transfer. | |
7441 * | |
7442 * Signature of a callback function that is called by Orthanc acting | |
7443 * as a HTTP server that supports chunked HTTP transfers. This callback | |
7444 * is invoked as soon as a new data chunk is available for the request body. | |
7445 * | |
7446 * @see OrthancPluginRegisterChunkedRestCallback() | |
7447 * @param reader The user payload, as created by the OrthancPluginServerChunkedRequestReaderFactory() callback. | |
7448 * @param data The content of the data chunk. | |
7449 * @param size The size of the data chunk. | |
7450 * @return 0 if success, or the error code if failure. | |
7451 **/ | |
7452 typedef OrthancPluginErrorCode (*OrthancPluginServerChunkedRequestReaderAddChunk) ( | |
7453 OrthancPluginServerChunkedRequestReader* reader, | |
7454 const void* data, | |
7455 uint32_t size); | |
7456 | |
7457 | |
7458 /** | |
7459 * @brief Callback invoked whenever the request body is entirely received. | |
7460 * | |
7461 * Signature of a callback function that is called by Orthanc acting | |
7462 * as a HTTP server that supports chunked HTTP transfers. This | |
7463 * callback is invoked as soon as the full body of the HTTP request | |
7464 * is available. The plugin can then send its answer thanks to the | |
7465 * provided "output" object. | |
7466 * | |
7467 * @see OrthancPluginRegisterChunkedRestCallback() | |
7468 * @param reader The user payload, as created by the OrthancPluginServerChunkedRequestReaderFactory() callback. | |
7469 * @param output The HTTP connection to the client application. | |
7470 * @return 0 if success, or the error code if failure. | |
7471 **/ | |
7472 typedef OrthancPluginErrorCode (*OrthancPluginServerChunkedRequestReaderExecute) ( | |
7473 OrthancPluginServerChunkedRequestReader* reader, | |
7474 OrthancPluginRestOutput* output); | |
7475 | |
7476 | |
7477 /** | |
7478 * @brief Callback invoked to release the resources associated with an incoming HTTP chunked transfer. | |
7479 * | |
7480 * Signature of a callback function that is called by Orthanc acting | |
7481 * as a HTTP server that supports chunked HTTP transfers. This | |
7482 * callback is invoked to release all the resources allocated by the | |
7483 * given reader. Note that this function might be invoked even if | |
7484 * the entire body was not read, to deal with client error or | |
7485 * disconnection. | |
7486 * | |
7487 * @see OrthancPluginRegisterChunkedRestCallback() | |
7488 * @param reader The user payload, as created by the OrthancPluginServerChunkedRequestReaderFactory() callback. | |
7489 **/ | |
7490 typedef void (*OrthancPluginServerChunkedRequestReaderFinalize) ( | |
7491 OrthancPluginServerChunkedRequestReader* reader); | |
7492 | |
7493 typedef struct | |
7494 { | |
7495 const char* pathRegularExpression; | |
7496 OrthancPluginRestCallback getHandler; | |
7497 OrthancPluginServerChunkedRequestReaderFactory postHandler; | |
7498 OrthancPluginRestCallback deleteHandler; | |
7499 OrthancPluginServerChunkedRequestReaderFactory putHandler; | |
7500 OrthancPluginServerChunkedRequestReaderAddChunk addChunk; | |
7501 OrthancPluginServerChunkedRequestReaderExecute execute; | |
7502 OrthancPluginServerChunkedRequestReaderFinalize finalize; | |
7503 } _OrthancPluginChunkedRestCallback; | |
7504 | |
7505 | |
7506 /** | |
7507 * @brief Register a REST callback to handle chunked HTTP transfers. | |
7508 * | |
7509 * This function registers a REST callback against a regular | |
7510 * expression for a URI. This function must be called during the | |
7511 * initialization of the plugin, i.e. inside the | |
7512 * OrthancPluginInitialize() public function. | |
7513 * | |
7514 * Contrarily to OrthancPluginRegisterRestCallback(), the callbacks | |
7515 * will NOT be invoked in mutual exclusion, so it is up to the | |
7516 * plugin to implement the required locking mechanisms. | |
7517 * | |
7518 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
7519 * @param pathRegularExpression Regular expression for the URI. May contain groups. | |
7520 * @param getHandler The callback function to handle REST calls using the GET HTTP method. | |
7521 * @param postHandler The callback function to handle REST calls using the POST HTTP method. | |
7522 * @param deleteHandler The callback function to handle REST calls using the DELETE HTTP method. | |
7523 * @param putHandler The callback function to handle REST calls using the PUT HTTP method. | |
7524 * @param addChunk The callback invoked when a new chunk is available for the request body of a POST or PUT call. | |
7525 * @param execute The callback invoked once the entire body of a POST or PUT call is read. | |
7526 * @param finalize The callback invoked to release the resources associated with a POST or PUT call. | |
7527 * @see OrthancPluginRegisterRestCallbackNoLock() | |
7528 * | |
7529 * @note | |
7530 * The regular expression is case sensitive and must follow the | |
7531 * [Perl syntax](https://www.boost.org/doc/libs/1_67_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html). | |
7532 * | |
7533 * @ingroup Callbacks | |
7534 **/ | |
7535 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterChunkedRestCallback( | |
7536 OrthancPluginContext* context, | |
7537 const char* pathRegularExpression, | |
7538 OrthancPluginRestCallback getHandler, | |
7539 OrthancPluginServerChunkedRequestReaderFactory postHandler, | |
7540 OrthancPluginRestCallback deleteHandler, | |
7541 OrthancPluginServerChunkedRequestReaderFactory putHandler, | |
7542 OrthancPluginServerChunkedRequestReaderAddChunk addChunk, | |
7543 OrthancPluginServerChunkedRequestReaderExecute execute, | |
7544 OrthancPluginServerChunkedRequestReaderFinalize finalize) | |
7545 { | |
7546 _OrthancPluginChunkedRestCallback params; | |
7547 params.pathRegularExpression = pathRegularExpression; | |
7548 params.getHandler = getHandler; | |
7549 params.postHandler = postHandler; | |
7550 params.deleteHandler = deleteHandler; | |
7551 params.putHandler = putHandler; | |
7552 params.addChunk = addChunk; | |
7553 params.execute = execute; | |
7554 params.finalize = finalize; | |
7555 | |
7556 context->InvokeService(context, _OrthancPluginService_RegisterChunkedRestCallback, ¶ms); | |
7557 } | |
7558 | |
7559 | |
7560 | |
7561 | |
7562 | |
7563 typedef struct | |
7564 { | |
7565 char** result; | |
7566 uint16_t group; | |
7567 uint16_t element; | |
7568 const char* privateCreator; | |
7569 } _OrthancPluginGetTagName; | |
7570 | |
7571 /** | |
7572 * @brief Returns the symbolic name of a DICOM tag. | |
7573 * | |
7574 * This function makes a lookup to the dictionary of DICOM tags that | |
7575 * are known to Orthanc, and returns the symbolic name of a DICOM tag. | |
7576 * | |
7577 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
7578 * @param group The group of the tag. | |
7579 * @param element The element of the tag. | |
7580 * @param privateCreator For private tags, the name of the private creator (can be NULL). | |
7581 * @return NULL in the case of an error, or a newly allocated string | |
7582 * containing the path. This string must be freed by | |
7583 * OrthancPluginFreeString(). | |
7584 * @ingroup Toolbox | |
7585 **/ | |
7586 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetTagName( | |
7587 OrthancPluginContext* context, | |
7588 uint16_t group, | |
7589 uint16_t element, | |
7590 const char* privateCreator) | |
7591 { | |
7592 char* result; | |
7593 | |
7594 _OrthancPluginGetTagName params; | |
7595 params.result = &result; | |
7596 params.group = group; | |
7597 params.element = element; | |
7598 params.privateCreator = privateCreator; | |
7599 | |
7600 if (context->InvokeService(context, _OrthancPluginService_GetTagName, ¶ms) != OrthancPluginErrorCode_Success) | |
7601 { | |
7602 /* Error */ | |
7603 return NULL; | |
7604 } | |
7605 else | |
7606 { | |
7607 return result; | |
7608 } | |
7609 } | |
7610 | |
7611 | |
7612 | |
7613 /** | |
7614 * @brief Callback executed by the storage commitment SCP. | |
7615 * | |
7616 * Signature of a factory function that creates an object to handle | |
7617 * one incoming storage commitment request. | |
7618 * | |
7619 * @remark The factory receives the list of the SOP class/instance | |
7620 * UIDs of interest to the remote storage commitment SCU. This gives | |
7621 * the factory the possibility to start some prefetch process | |
7622 * upfront in the background, before the handler object is actually | |
7623 * queried about the status of these DICOM instances. | |
7624 * | |
7625 * @param handler Output variable where the factory puts the handler object it created. | |
7626 * @param jobId ID of the Orthanc job that is responsible for handling | |
7627 * the storage commitment request. This job will successively look for the | |
7628 * status of all the individual queried DICOM instances. | |
7629 * @param transactionUid UID of the storage commitment transaction | |
7630 * provided by the storage commitment SCU. It contains the value of the | |
7631 * (0008,1195) DICOM tag. | |
7632 * @param sopClassUids Array of the SOP class UIDs (0008,0016) that are queried by the SCU. | |
7633 * @param sopInstanceUids Array of the SOP instance UIDs (0008,0018) that are queried by the SCU. | |
7634 * @param countInstances Number of DICOM instances that are queried. This is the size | |
7635 * of the `sopClassUids` and `sopInstanceUids` arrays. | |
7636 * @param remoteAet The AET of the storage commitment SCU. | |
7637 * @param calledAet The AET used by the SCU to contact the storage commitment SCP (i.e. Orthanc). | |
7638 * @return 0 if success, other value if error. | |
7639 * @ingroup DicomCallbacks | |
7640 **/ | |
7641 typedef OrthancPluginErrorCode (*OrthancPluginStorageCommitmentFactory) ( | |
7642 void** handler /* out */, | |
7643 const char* jobId, | |
7644 const char* transactionUid, | |
7645 const char* const* sopClassUids, | |
7646 const char* const* sopInstanceUids, | |
7647 uint32_t countInstances, | |
7648 const char* remoteAet, | |
7649 const char* calledAet); | |
7650 | |
7651 | |
7652 /** | |
7653 * @brief Callback to free one storage commitment SCP handler. | |
7654 * | |
7655 * Signature of a callback function that releases the resources | |
7656 * allocated by the factory of the storage commitment SCP. The | |
7657 * handler is the return value of a previous call to the | |
7658 * OrthancPluginStorageCommitmentFactory() callback. | |
7659 * | |
7660 * @param handler The handler object to be destructed. | |
7661 * @ingroup DicomCallbacks | |
7662 **/ | |
7663 typedef void (*OrthancPluginStorageCommitmentDestructor) (void* handler); | |
7664 | |
7665 | |
7666 /** | |
7667 * @brief Callback to get the status of one DICOM instance in the | |
7668 * storage commitment SCP. | |
7669 * | |
7670 * Signature of a callback function that is successively invoked for | |
7671 * each DICOM instance that is queried by the remote storage | |
7672 * commitment SCU. The function must be tought of as a method of | |
7673 * the handler object that was created by a previous call to the | |
7674 * OrthancPluginStorageCommitmentFactory() callback. After each call | |
7675 * to this method, the progress of the associated Orthanc job is | |
7676 * updated. | |
7677 * | |
7678 * @param target Output variable where to put the status for the queried instance. | |
7679 * @param handler The handler object associated with this storage commitment request. | |
7680 * @param sopClassUid The SOP class UID (0008,0016) of interest. | |
7681 * @param sopInstanceUid The SOP instance UID (0008,0018) of interest. | |
7682 * @ingroup DicomCallbacks | |
7683 **/ | |
7684 typedef OrthancPluginErrorCode (*OrthancPluginStorageCommitmentLookup) ( | |
7685 OrthancPluginStorageCommitmentFailureReason* target, | |
7686 void* handler, | |
7687 const char* sopClassUid, | |
7688 const char* sopInstanceUid); | |
7689 | |
7690 | |
7691 typedef struct | |
7692 { | |
7693 OrthancPluginStorageCommitmentFactory factory; | |
7694 OrthancPluginStorageCommitmentDestructor destructor; | |
7695 OrthancPluginStorageCommitmentLookup lookup; | |
7696 } _OrthancPluginRegisterStorageCommitmentScpCallback; | |
7697 | |
7698 /** | |
7699 * @brief Register a callback to handle incoming requests to the storage commitment SCP. | |
7700 * | |
7701 * This function registers a callback to handle storage commitment SCP requests. | |
7702 * | |
7703 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
7704 * @param factory Factory function that creates the handler object | |
7705 * for incoming storage commitment requests. | |
7706 * @param destructor Destructor function to destroy the handler object. | |
7707 * @param lookup Callback method to get the status of one DICOM instance. | |
7708 * @return 0 if success, other value if error. | |
7709 * @ingroup DicomCallbacks | |
7710 **/ | |
7711 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterStorageCommitmentScpCallback( | |
7712 OrthancPluginContext* context, | |
7713 OrthancPluginStorageCommitmentFactory factory, | |
7714 OrthancPluginStorageCommitmentDestructor destructor, | |
7715 OrthancPluginStorageCommitmentLookup lookup) | |
7716 { | |
7717 _OrthancPluginRegisterStorageCommitmentScpCallback params; | |
7718 params.factory = factory; | |
7719 params.destructor = destructor; | |
7720 params.lookup = lookup; | |
7721 return context->InvokeService(context, _OrthancPluginService_RegisterStorageCommitmentScpCallback, ¶ms); | |
7722 } | |
7723 | |
7724 | |
7725 | |
7726 /** | |
7727 * @brief Callback to filter incoming DICOM instances received by Orthanc. | |
7728 * | |
7729 * Signature of a callback function that is triggered whenever | |
7730 * Orthanc receives a new DICOM instance (e.g. through REST API or | |
7731 * DICOM protocol), and that answers whether this DICOM instance | |
7732 * should be accepted or discarded by Orthanc. | |
7733 * | |
7734 * Note that the metadata information is not available | |
7735 * (i.e. GetInstanceMetadata() should not be used on "instance"). | |
7736 * | |
7737 * @warning Your callback function will be called synchronously with | |
7738 * the core of Orthanc. This implies that deadlocks might emerge if | |
7739 * you call other core primitives of Orthanc in your callback (such | |
7740 * deadlocks are particularly visible in the presence of other plugins | |
7741 * or Lua scripts). It is thus strongly advised to avoid any call to | |
7742 * the REST API of Orthanc in the callback. If you have to call | |
7743 * other primitives of Orthanc, you should make these calls in a | |
7744 * separate thread, passing the pending events to be processed | |
7745 * through a message queue. | |
7746 * | |
7747 * @param instance The received DICOM instance. | |
7748 * @return 0 to discard the instance, 1 to store the instance, -1 if error. | |
7749 * @ingroup Callback | |
7750 **/ | |
7751 typedef int32_t (*OrthancPluginIncomingDicomInstanceFilter) ( | |
7752 const OrthancPluginDicomInstance* instance); | |
7753 | |
7754 | |
7755 typedef struct | |
7756 { | |
7757 OrthancPluginIncomingDicomInstanceFilter callback; | |
7758 } _OrthancPluginIncomingDicomInstanceFilter; | |
7759 | |
7760 /** | |
7761 * @brief Register a callback to filter incoming DICOM instances. | |
7762 * | |
7763 * This function registers a custom callback to filter incoming | |
7764 * DICOM instances received by Orthanc (either through the REST API | |
7765 * or through the DICOM protocol). | |
7766 * | |
7767 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
7768 * @param callback The callback. | |
7769 * @return 0 if success, other value if error. | |
7770 * @ingroup Callbacks | |
7771 **/ | |
7772 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingDicomInstanceFilter( | |
7773 OrthancPluginContext* context, | |
7774 OrthancPluginIncomingDicomInstanceFilter callback) | |
7775 { | |
7776 _OrthancPluginIncomingDicomInstanceFilter params; | |
7777 params.callback = callback; | |
7778 | |
7779 return context->InvokeService(context, _OrthancPluginService_RegisterIncomingDicomInstanceFilter, ¶ms); | |
7780 } | |
7781 | |
7782 | |
7783 /** | |
7784 * @brief Callback to filter incoming DICOM instances received by | |
7785 * Orthanc through C-STORE. | |
7786 * | |
7787 * Signature of a callback function that is triggered whenever | |
7788 * Orthanc receives a new DICOM instance using DICOM C-STORE, and | |
7789 * that answers whether this DICOM instance should be accepted or | |
7790 * discarded by Orthanc. If the instance is discarded, the callback | |
7791 * can specify the DIMSE error code answered by the Orthanc C-STORE | |
7792 * SCP. | |
7793 * | |
7794 * Note that the metadata information is not available | |
7795 * (i.e. GetInstanceMetadata() should not be used on "instance"). | |
7796 * | |
7797 * @warning Your callback function will be called synchronously with | |
7798 * the core of Orthanc. This implies that deadlocks might emerge if | |
7799 * you call other core primitives of Orthanc in your callback (such | |
7800 * deadlocks are particularly visible in the presence of other plugins | |
7801 * or Lua scripts). It is thus strongly advised to avoid any call to | |
7802 * the REST API of Orthanc in the callback. If you have to call | |
7803 * other primitives of Orthanc, you should make these calls in a | |
7804 * separate thread, passing the pending events to be processed | |
7805 * through a message queue. | |
7806 * | |
7807 * @param dimseStatus If the DICOM instance is discarded, | |
7808 * DIMSE status to be sent by the C-STORE SCP of Orthanc | |
7809 * @param instance The received DICOM instance. | |
7810 * @return 0 to discard the instance, 1 to store the instance, -1 if error. | |
7811 * @ingroup Callback | |
7812 **/ | |
7813 typedef int32_t (*OrthancPluginIncomingCStoreInstanceFilter) ( | |
7814 uint16_t* dimseStatus /* out */, | |
7815 const OrthancPluginDicomInstance* instance); | |
7816 | |
7817 | |
7818 typedef struct | |
7819 { | |
7820 OrthancPluginIncomingCStoreInstanceFilter callback; | |
7821 } _OrthancPluginIncomingCStoreInstanceFilter; | |
7822 | |
7823 /** | |
7824 * @brief Register a callback to filter incoming DICOM instances | |
7825 * received by Orthanc through C-STORE. | |
7826 * | |
7827 * This function registers a custom callback to filter incoming | |
7828 * DICOM instances received by Orthanc through the DICOM protocol. | |
7829 * | |
7830 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
7831 * @param callback The callback. | |
7832 * @return 0 if success, other value if error. | |
7833 * @ingroup Callbacks | |
7834 **/ | |
7835 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingCStoreInstanceFilter( | |
7836 OrthancPluginContext* context, | |
7837 OrthancPluginIncomingCStoreInstanceFilter callback) | |
7838 { | |
7839 _OrthancPluginIncomingCStoreInstanceFilter params; | |
7840 params.callback = callback; | |
7841 | |
7842 return context->InvokeService(context, _OrthancPluginService_RegisterIncomingCStoreInstanceFilter, ¶ms); | |
7843 } | |
7844 | |
7845 /** | |
7846 * @brief Callback to keep/discard/modify a DICOM instance received | |
7847 * by Orthanc from any source (C-STORE or REST API) | |
7848 * | |
7849 * Signature of a callback function that is triggered whenever | |
7850 * Orthanc receives a new DICOM instance (through DICOM protocol or | |
7851 * REST API), and that specifies an action to be applied to this | |
7852 * newly received instance. The instance can be kept as it is, can | |
7853 * be modified by the plugin, or can be discarded. | |
7854 * | |
7855 * This callback is invoked immediately after reception, i.e. before | |
7856 * transcoding and before filtering | |
7857 * (cf. OrthancPluginRegisterIncomingDicomInstanceFilter()). | |
7858 * | |
7859 * @warning Your callback function will be called synchronously with | |
7860 * the core of Orthanc. This implies that deadlocks might emerge if | |
7861 * you call other core primitives of Orthanc in your callback (such | |
7862 * deadlocks are particularly visible in the presence of other plugins | |
7863 * or Lua scripts). It is thus strongly advised to avoid any call to | |
7864 * the REST API of Orthanc in the callback. If you have to call | |
7865 * other primitives of Orthanc, you should make these calls in a | |
7866 * separate thread, passing the pending events to be processed | |
7867 * through a message queue. | |
7868 * | |
7869 * @param modifiedDicomBuffer A buffer containing the modified DICOM (output). | |
7870 * This buffer must be allocated using OrthancPluginCreateMemoryBuffer64() | |
7871 * and will be freed by the Orthanc core. | |
7872 * @param receivedDicomBuffer A buffer containing the received DICOM (input). | |
7873 * @param receivedDicomBufferSize The size of the received DICOM (input). | |
7874 * @param origin The origin of the DICOM instance (input). | |
7875 * @return `OrthancPluginReceivedInstanceAction_KeepAsIs` to accept the instance as is,<br/> | |
7876 * `OrthancPluginReceivedInstanceAction_Modify` to store the modified DICOM contained in `modifiedDicomBuffer`,<br/> | |
7877 * `OrthancPluginReceivedInstanceAction_Discard` to tell Orthanc to discard the instance. | |
7878 * @ingroup Callback | |
7879 **/ | |
7880 typedef OrthancPluginReceivedInstanceAction (*OrthancPluginReceivedInstanceCallback) ( | |
7881 OrthancPluginMemoryBuffer64* modifiedDicomBuffer, | |
7882 const void* receivedDicomBuffer, | |
7883 uint64_t receivedDicomBufferSize, | |
7884 OrthancPluginInstanceOrigin origin); | |
7885 | |
7886 | |
7887 typedef struct | |
7888 { | |
7889 OrthancPluginReceivedInstanceCallback callback; | |
7890 } _OrthancPluginReceivedInstanceCallback; | |
7891 | |
7892 /** | |
7893 * @brief Register a callback to keep/discard/modify a DICOM instance received | |
7894 * by Orthanc from any source (C-STORE or REST API) | |
7895 * | |
7896 * This function registers a custom callback to keep/discard/modify | |
7897 * incoming DICOM instances received by Orthanc from any source | |
7898 * (C-STORE or REST API). | |
7899 * | |
7900 * @warning Contrarily to | |
7901 * OrthancPluginRegisterIncomingCStoreInstanceFilter() and | |
7902 * OrthancPluginRegisterIncomingDicomInstanceFilter() that can be | |
7903 * called by multiple plugins, | |
7904 * OrthancPluginRegisterReceivedInstanceCallback() can only be used | |
7905 * by one single plugin. | |
7906 * | |
7907 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
7908 * @param callback The callback. | |
7909 * @return 0 if success, other value if error. | |
7910 * @ingroup Callbacks | |
7911 **/ | |
7912 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterReceivedInstanceCallback( | |
7913 OrthancPluginContext* context, | |
7914 OrthancPluginReceivedInstanceCallback callback) | |
7915 { | |
7916 _OrthancPluginReceivedInstanceCallback params; | |
7917 params.callback = callback; | |
7918 | |
7919 return context->InvokeService(context, _OrthancPluginService_RegisterReceivedInstanceCallback, ¶ms); | |
7920 } | |
7921 | |
7922 /** | |
7923 * @brief Get the transfer syntax of a DICOM file. | |
7924 * | |
7925 * This function returns a pointer to a newly created string that | |
7926 * contains the transfer syntax UID of the DICOM instance. The empty | |
7927 * string might be returned if this information is unknown. | |
7928 * | |
7929 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
7930 * @param instance The instance of interest. | |
7931 * @return The NULL value in case of error, or a string containing the | |
7932 * transfer syntax UID. This string must be freed by OrthancPluginFreeString(). | |
7933 * @ingroup DicomInstance | |
7934 **/ | |
7935 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceTransferSyntaxUid( | |
7936 OrthancPluginContext* context, | |
7937 const OrthancPluginDicomInstance* instance) | |
7938 { | |
7939 char* result; | |
7940 | |
7941 _OrthancPluginAccessDicomInstance params; | |
7942 memset(¶ms, 0, sizeof(params)); | |
7943 params.resultStringToFree = &result; | |
7944 params.instance = instance; | |
7945 | |
7946 if (context->InvokeService(context, _OrthancPluginService_GetInstanceTransferSyntaxUid, ¶ms) != OrthancPluginErrorCode_Success) | |
7947 { | |
7948 /* Error */ | |
7949 return NULL; | |
7950 } | |
7951 else | |
7952 { | |
7953 return result; | |
7954 } | |
7955 } | |
7956 | |
7957 | |
7958 /** | |
7959 * @brief Check whether the DICOM file has pixel data. | |
7960 * | |
7961 * This function returns a Boolean value indicating whether the | |
7962 * DICOM instance contains the pixel data (7FE0,0010) tag. | |
7963 * | |
7964 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
7965 * @param instance The instance of interest. | |
7966 * @return "1" if the DICOM instance contains pixel data, or "0" if | |
7967 * the tag is missing, or "-1" in the case of an error. | |
7968 * @ingroup DicomInstance | |
7969 **/ | |
7970 ORTHANC_PLUGIN_INLINE int32_t OrthancPluginHasInstancePixelData( | |
7971 OrthancPluginContext* context, | |
7972 const OrthancPluginDicomInstance* instance) | |
7973 { | |
7974 int64_t hasPixelData; | |
7975 | |
7976 _OrthancPluginAccessDicomInstance params; | |
7977 memset(¶ms, 0, sizeof(params)); | |
7978 params.resultInt64 = &hasPixelData; | |
7979 params.instance = instance; | |
7980 | |
7981 if (context->InvokeService(context, _OrthancPluginService_HasInstancePixelData, ¶ms) != OrthancPluginErrorCode_Success || | |
7982 hasPixelData < 0 || | |
7983 hasPixelData > 1) | |
7984 { | |
7985 /* Error */ | |
7986 return -1; | |
7987 } | |
7988 else | |
7989 { | |
7990 return (hasPixelData != 0); | |
7991 } | |
7992 } | |
7993 | |
7994 | |
7995 | |
7996 | |
7997 | |
7998 | |
7999 typedef struct | |
8000 { | |
8001 OrthancPluginDicomInstance** target; | |
8002 const void* buffer; | |
8003 uint32_t size; | |
8004 const char* transferSyntax; | |
8005 } _OrthancPluginCreateDicomInstance; | |
8006 | |
8007 /** | |
8008 * @brief Parse a DICOM instance. | |
8009 * | |
8010 * This function parses a memory buffer that contains a DICOM | |
8011 * file. The function returns a new pointer to a data structure that | |
8012 * is managed by the Orthanc core. | |
8013 * | |
8014 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8015 * @param buffer The memory buffer containing the DICOM instance. | |
8016 * @param size The size of the memory buffer. | |
8017 * @return The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance(). | |
8018 * @ingroup DicomInstance | |
8019 **/ | |
8020 ORTHANC_PLUGIN_INLINE OrthancPluginDicomInstance* OrthancPluginCreateDicomInstance( | |
8021 OrthancPluginContext* context, | |
8022 const void* buffer, | |
8023 uint32_t size) | |
8024 { | |
8025 OrthancPluginDicomInstance* target = NULL; | |
8026 | |
8027 _OrthancPluginCreateDicomInstance params; | |
8028 params.target = ⌖ | |
8029 params.buffer = buffer; | |
8030 params.size = size; | |
8031 | |
8032 if (context->InvokeService(context, _OrthancPluginService_CreateDicomInstance, ¶ms) != OrthancPluginErrorCode_Success) | |
8033 { | |
8034 /* Error */ | |
8035 return NULL; | |
8036 } | |
8037 else | |
8038 { | |
8039 return target; | |
8040 } | |
8041 } | |
8042 | |
8043 typedef struct | |
8044 { | |
8045 OrthancPluginDicomInstance* dicom; | |
8046 } _OrthancPluginFreeDicomInstance; | |
8047 | |
8048 /** | |
8049 * @brief Free a DICOM instance. | |
8050 * | |
8051 * This function frees a DICOM instance that was parsed using | |
8052 * OrthancPluginCreateDicomInstance(). | |
8053 * | |
8054 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8055 * @param dicom The DICOM instance. | |
8056 * @ingroup DicomInstance | |
8057 **/ | |
8058 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeDicomInstance( | |
8059 OrthancPluginContext* context, | |
8060 OrthancPluginDicomInstance* dicom) | |
8061 { | |
8062 _OrthancPluginFreeDicomInstance params; | |
8063 params.dicom = dicom; | |
8064 | |
8065 context->InvokeService(context, _OrthancPluginService_FreeDicomInstance, ¶ms); | |
8066 } | |
8067 | |
8068 | |
8069 typedef struct | |
8070 { | |
8071 uint32_t* targetUint32; | |
8072 OrthancPluginMemoryBuffer* targetBuffer; | |
8073 OrthancPluginImage** targetImage; | |
8074 char** targetStringToFree; | |
8075 const OrthancPluginDicomInstance* instance; | |
8076 uint32_t frameIndex; | |
8077 OrthancPluginDicomToJsonFormat format; | |
8078 OrthancPluginDicomToJsonFlags flags; | |
8079 uint32_t maxStringLength; | |
8080 OrthancPluginDicomWebBinaryCallback2 dicomWebCallback; | |
8081 void* dicomWebPayload; | |
8082 } _OrthancPluginAccessDicomInstance2; | |
8083 | |
8084 /** | |
8085 * @brief Get the number of frames in a DICOM instance. | |
8086 * | |
8087 * This function returns the number of frames that are part of a | |
8088 * DICOM image managed by the Orthanc core. | |
8089 * | |
8090 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8091 * @param instance The instance of interest. | |
8092 * @return The number of frames (will be zero in the case of an error). | |
8093 * @ingroup DicomInstance | |
8094 **/ | |
8095 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetInstanceFramesCount( | |
8096 OrthancPluginContext* context, | |
8097 const OrthancPluginDicomInstance* instance) | |
8098 { | |
8099 uint32_t count; | |
8100 | |
8101 _OrthancPluginAccessDicomInstance2 params; | |
8102 memset(¶ms, 0, sizeof(params)); | |
8103 params.targetUint32 = &count; | |
8104 params.instance = instance; | |
8105 | |
8106 if (context->InvokeService(context, _OrthancPluginService_GetInstanceFramesCount, ¶ms) != OrthancPluginErrorCode_Success) | |
8107 { | |
8108 /* Error */ | |
8109 return 0; | |
8110 } | |
8111 else | |
8112 { | |
8113 return count; | |
8114 } | |
8115 } | |
8116 | |
8117 | |
8118 /** | |
8119 * @brief Get the raw content of a frame in a DICOM instance. | |
8120 * | |
8121 * This function returns a memory buffer containing the raw content | |
8122 * of a frame in a DICOM instance that is managed by the Orthanc | |
8123 * core. This is notably useful for compressed transfer syntaxes, as | |
8124 * it gives access to the embedded files (such as JPEG, JPEG-LS or | |
8125 * JPEG2k). The Orthanc core transparently reassembles the fragments | |
8126 * to extract the raw frame. | |
8127 * | |
8128 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8129 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
8130 * @param instance The instance of interest. | |
8131 * @param frameIndex The index of the frame of interest. | |
8132 * @return 0 if success, or the error code if failure. | |
8133 * @ingroup DicomInstance | |
8134 **/ | |
8135 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetInstanceRawFrame( | |
8136 OrthancPluginContext* context, | |
8137 OrthancPluginMemoryBuffer* target, | |
8138 const OrthancPluginDicomInstance* instance, | |
8139 uint32_t frameIndex) | |
8140 { | |
8141 _OrthancPluginAccessDicomInstance2 params; | |
8142 memset(¶ms, 0, sizeof(params)); | |
8143 params.targetBuffer = target; | |
8144 params.instance = instance; | |
8145 params.frameIndex = frameIndex; | |
8146 | |
8147 return context->InvokeService(context, _OrthancPluginService_GetInstanceRawFrame, ¶ms); | |
8148 } | |
8149 | |
8150 | |
8151 /** | |
8152 * @brief Decode one frame from a DICOM instance. | |
8153 * | |
8154 * This function decodes one frame of a DICOM image that is managed | |
8155 * by the Orthanc core. | |
8156 * | |
8157 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8158 * @param instance The instance of interest. | |
8159 * @param frameIndex The index of the frame of interest. | |
8160 * @return The uncompressed image. It must be freed with OrthancPluginFreeImage(). | |
8161 * @ingroup DicomInstance | |
8162 **/ | |
8163 ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginGetInstanceDecodedFrame( | |
8164 OrthancPluginContext* context, | |
8165 const OrthancPluginDicomInstance* instance, | |
8166 uint32_t frameIndex) | |
8167 { | |
8168 OrthancPluginImage* target = NULL; | |
8169 | |
8170 _OrthancPluginAccessDicomInstance2 params; | |
8171 memset(¶ms, 0, sizeof(params)); | |
8172 params.targetImage = ⌖ | |
8173 params.instance = instance; | |
8174 params.frameIndex = frameIndex; | |
8175 | |
8176 if (context->InvokeService(context, _OrthancPluginService_GetInstanceDecodedFrame, ¶ms) != OrthancPluginErrorCode_Success) | |
8177 { | |
8178 return NULL; | |
8179 } | |
8180 else | |
8181 { | |
8182 return target; | |
8183 } | |
8184 } | |
8185 | |
8186 | |
8187 /** | |
8188 * @brief Parse and transcode a DICOM instance. | |
8189 * | |
8190 * This function parses a memory buffer that contains a DICOM file, | |
8191 * then transcodes it to the given transfer syntax. The function | |
8192 * returns a new pointer to a data structure that is managed by the | |
8193 * Orthanc core. | |
8194 * | |
8195 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8196 * @param buffer The memory buffer containing the DICOM instance. | |
8197 * @param size The size of the memory buffer. | |
8198 * @param transferSyntax The transfer syntax UID for the transcoding. | |
8199 * @return The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance(). | |
8200 * @ingroup DicomInstance | |
8201 **/ | |
8202 ORTHANC_PLUGIN_INLINE OrthancPluginDicomInstance* OrthancPluginTranscodeDicomInstance( | |
8203 OrthancPluginContext* context, | |
8204 const void* buffer, | |
8205 uint32_t size, | |
8206 const char* transferSyntax) | |
8207 { | |
8208 OrthancPluginDicomInstance* target = NULL; | |
8209 | |
8210 _OrthancPluginCreateDicomInstance params; | |
8211 params.target = ⌖ | |
8212 params.buffer = buffer; | |
8213 params.size = size; | |
8214 params.transferSyntax = transferSyntax; | |
8215 | |
8216 if (context->InvokeService(context, _OrthancPluginService_TranscodeDicomInstance, ¶ms) != OrthancPluginErrorCode_Success) | |
8217 { | |
8218 /* Error */ | |
8219 return NULL; | |
8220 } | |
8221 else | |
8222 { | |
8223 return target; | |
8224 } | |
8225 } | |
8226 | |
8227 /** | |
8228 * @brief Writes a DICOM instance to a memory buffer. | |
8229 * | |
8230 * This function returns a memory buffer containing the | |
8231 * serialization of a DICOM instance that is managed by the Orthanc | |
8232 * core. | |
8233 * | |
8234 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8235 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
8236 * @param instance The instance of interest. | |
8237 * @return 0 if success, or the error code if failure. | |
8238 * @ingroup DicomInstance | |
8239 **/ | |
8240 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSerializeDicomInstance( | |
8241 OrthancPluginContext* context, | |
8242 OrthancPluginMemoryBuffer* target, | |
8243 const OrthancPluginDicomInstance* instance) | |
8244 { | |
8245 _OrthancPluginAccessDicomInstance2 params; | |
8246 memset(¶ms, 0, sizeof(params)); | |
8247 params.targetBuffer = target; | |
8248 params.instance = instance; | |
8249 | |
8250 return context->InvokeService(context, _OrthancPluginService_SerializeDicomInstance, ¶ms); | |
8251 } | |
8252 | |
8253 | |
8254 /** | |
8255 * @brief Format a DICOM memory buffer as a JSON string. | |
8256 * | |
8257 * This function takes as DICOM instance managed by the Orthanc | |
8258 * core, and outputs a JSON string representing the tags of this | |
8259 * DICOM file. | |
8260 * | |
8261 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8262 * @param instance The DICOM instance of interest. | |
8263 * @param format The output format. | |
8264 * @param flags Flags governing the output. | |
8265 * @param maxStringLength The maximum length of a field. Too long fields will | |
8266 * be output as "null". The 0 value means no maximum length. | |
8267 * @return The NULL value if the case of an error, or the JSON | |
8268 * string. This string must be freed by OrthancPluginFreeString(). | |
8269 * @ingroup DicomInstance | |
8270 * @see OrthancPluginDicomBufferToJson | |
8271 **/ | |
8272 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceAdvancedJson( | |
8273 OrthancPluginContext* context, | |
8274 const OrthancPluginDicomInstance* instance, | |
8275 OrthancPluginDicomToJsonFormat format, | |
8276 OrthancPluginDicomToJsonFlags flags, | |
8277 uint32_t maxStringLength) | |
8278 { | |
8279 char* result = NULL; | |
8280 | |
8281 _OrthancPluginAccessDicomInstance2 params; | |
8282 memset(¶ms, 0, sizeof(params)); | |
8283 params.targetStringToFree = &result; | |
8284 params.instance = instance; | |
8285 params.format = format; | |
8286 params.flags = flags; | |
8287 params.maxStringLength = maxStringLength; | |
8288 | |
8289 if (context->InvokeService(context, _OrthancPluginService_GetInstanceAdvancedJson, ¶ms) != OrthancPluginErrorCode_Success) | |
8290 { | |
8291 /* Error */ | |
8292 return NULL; | |
8293 } | |
8294 else | |
8295 { | |
8296 return result; | |
8297 } | |
8298 } | |
8299 | |
8300 | |
8301 /** | |
8302 * @brief Convert a DICOM instance to DICOMweb JSON. | |
8303 * | |
8304 * This function converts a DICOM instance that is managed by the | |
8305 * Orthanc core, into its DICOMweb JSON representation. | |
8306 * | |
8307 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8308 * @param instance The DICOM instance of interest. | |
8309 * @param callback Callback to set the value of the binary tags. | |
8310 * @param payload User payload. | |
8311 * @return The NULL value in case of error, or the JSON document. This string must | |
8312 * be freed by OrthancPluginFreeString(). | |
8313 * @ingroup DicomInstance | |
8314 **/ | |
8315 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceDicomWebJson( | |
8316 OrthancPluginContext* context, | |
8317 const OrthancPluginDicomInstance* instance, | |
8318 OrthancPluginDicomWebBinaryCallback2 callback, | |
8319 void* payload) | |
8320 { | |
8321 char* target = NULL; | |
8322 | |
8323 _OrthancPluginAccessDicomInstance2 params; | |
8324 params.targetStringToFree = ⌖ | |
8325 params.instance = instance; | |
8326 params.dicomWebCallback = callback; | |
8327 params.dicomWebPayload = payload; | |
8328 | |
8329 if (context->InvokeService(context, _OrthancPluginService_GetInstanceDicomWebJson, ¶ms) != OrthancPluginErrorCode_Success) | |
8330 { | |
8331 /* Error */ | |
8332 return NULL; | |
8333 } | |
8334 else | |
8335 { | |
8336 return target; | |
8337 } | |
8338 } | |
8339 | |
8340 | |
8341 /** | |
8342 * @brief Convert a DICOM instance to DICOMweb XML. | |
8343 * | |
8344 * This function converts a DICOM instance that is managed by the | |
8345 * Orthanc core, into its DICOMweb XML representation. | |
8346 * | |
8347 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8348 * @param instance The DICOM instance of interest. | |
8349 * @param callback Callback to set the value of the binary tags. | |
8350 * @param payload User payload. | |
8351 * @return The NULL value in case of error, or the XML document. This string must | |
8352 * be freed by OrthancPluginFreeString(). | |
8353 * @ingroup DicomInstance | |
8354 **/ | |
8355 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceDicomWebXml( | |
8356 OrthancPluginContext* context, | |
8357 const OrthancPluginDicomInstance* instance, | |
8358 OrthancPluginDicomWebBinaryCallback2 callback, | |
8359 void* payload) | |
8360 { | |
8361 char* target = NULL; | |
8362 | |
8363 _OrthancPluginAccessDicomInstance2 params; | |
8364 params.targetStringToFree = ⌖ | |
8365 params.instance = instance; | |
8366 params.dicomWebCallback = callback; | |
8367 params.dicomWebPayload = payload; | |
8368 | |
8369 if (context->InvokeService(context, _OrthancPluginService_GetInstanceDicomWebXml, ¶ms) != OrthancPluginErrorCode_Success) | |
8370 { | |
8371 /* Error */ | |
8372 return NULL; | |
8373 } | |
8374 else | |
8375 { | |
8376 return target; | |
8377 } | |
8378 } | |
8379 | |
8380 | |
8381 | |
8382 /** | |
8383 * @brief Signature of a callback function to transcode a DICOM instance. | |
8384 * @param transcoded Target memory buffer. It must be allocated by the | |
8385 * plugin using OrthancPluginCreateMemoryBuffer(). | |
8386 * @param buffer Memory buffer containing the source DICOM instance. | |
8387 * @param size Size of the source memory buffer. | |
8388 * @param allowedSyntaxes A C array of possible transfer syntaxes UIDs for the | |
8389 * result of the transcoding. The plugin must choose by itself the | |
8390 * transfer syntax that will be used for the resulting DICOM image. | |
8391 * @param countSyntaxes The number of transfer syntaxes that are contained | |
8392 * in the "allowedSyntaxes" array. | |
8393 * @param allowNewSopInstanceUid Whether the transcoding plugin can select | |
8394 * a transfer syntax that will change the SOP instance UID (or, in other | |
8395 * terms, whether the plugin can transcode using lossy compression). | |
8396 * @return 0 if success (i.e. image successfully transcoded and stored into | |
8397 * "transcoded"), or the error code if failure. | |
8398 * @ingroup Callbacks | |
8399 **/ | |
8400 typedef OrthancPluginErrorCode (*OrthancPluginTranscoderCallback) ( | |
8401 OrthancPluginMemoryBuffer* transcoded /* out */, | |
8402 const void* buffer, | |
8403 uint64_t size, | |
8404 const char* const* allowedSyntaxes, | |
8405 uint32_t countSyntaxes, | |
8406 uint8_t allowNewSopInstanceUid); | |
8407 | |
8408 | |
8409 typedef struct | |
8410 { | |
8411 OrthancPluginTranscoderCallback callback; | |
8412 } _OrthancPluginTranscoderCallback; | |
8413 | |
8414 /** | |
8415 * @brief Register a callback to handle the transcoding of DICOM images. | |
8416 * | |
8417 * This function registers a custom callback to transcode DICOM | |
8418 * images, extending the built-in transcoder of Orthanc that uses | |
8419 * DCMTK. The exact behavior is affected by the configuration option | |
8420 * "BuiltinDecoderTranscoderOrder" of Orthanc. | |
8421 * | |
8422 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8423 * @param callback The callback. | |
8424 * @return 0 if success, other value if error. | |
8425 * @ingroup Callbacks | |
8426 **/ | |
8427 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterTranscoderCallback( | |
8428 OrthancPluginContext* context, | |
8429 OrthancPluginTranscoderCallback callback) | |
8430 { | |
8431 _OrthancPluginTranscoderCallback params; | |
8432 params.callback = callback; | |
8433 | |
8434 return context->InvokeService(context, _OrthancPluginService_RegisterTranscoderCallback, ¶ms); | |
8435 } | |
8436 | |
8437 | |
8438 | |
8439 typedef struct | |
8440 { | |
8441 OrthancPluginMemoryBuffer* target; | |
8442 uint32_t size; | |
8443 } _OrthancPluginCreateMemoryBuffer; | |
8444 | |
8445 /** | |
8446 * @brief Create a 32-bit memory buffer. | |
8447 * | |
8448 * This function creates a memory buffer that is managed by the | |
8449 * Orthanc core. The main use case of this function is for plugins | |
8450 * that act as DICOM transcoders. | |
8451 * | |
8452 * Your plugin should never call "free()" on the resulting memory | |
8453 * buffer, as the C library that is used by the plugin is in general | |
8454 * not the same as the one used by the Orthanc core. | |
8455 * | |
8456 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8457 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
8458 * @param size Size of the memory buffer to be created. | |
8459 * @return 0 if success, or the error code if failure. | |
8460 * @ingroup Toolbox | |
8461 **/ | |
8462 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateMemoryBuffer( | |
8463 OrthancPluginContext* context, | |
8464 OrthancPluginMemoryBuffer* target, | |
8465 uint32_t size) | |
8466 { | |
8467 _OrthancPluginCreateMemoryBuffer params; | |
8468 params.target = target; | |
8469 params.size = size; | |
8470 | |
8471 return context->InvokeService(context, _OrthancPluginService_CreateMemoryBuffer, ¶ms); | |
8472 } | |
8473 | |
8474 | |
8475 /** | |
8476 * @brief Generate a token to grant full access to the REST API of Orthanc | |
8477 * | |
8478 * This function generates a token that can be set in the HTTP | |
8479 * header "Authorization" so as to grant full access to the REST API | |
8480 * of Orthanc using an external HTTP client. Using this function | |
8481 * avoids the need of adding a separate user in the | |
8482 * "RegisteredUsers" configuration of Orthanc, which eases | |
8483 * deployments. | |
8484 * | |
8485 * This feature is notably useful in multiprocess scenarios, where a | |
8486 * subprocess created by a plugin has no access to the | |
8487 * "OrthancPluginContext", and thus cannot call | |
8488 * "OrthancPluginRestApi[Get|Post|Put|Delete]()". | |
8489 * | |
8490 * This situation is frequently encountered in Python plugins, where | |
8491 * the "multiprocessing" package can be used to bypass the Global | |
8492 * Interpreter Lock (GIL) and thus to improve performance and | |
8493 * concurrency. | |
8494 * | |
8495 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8496 * @return The authorization token, or NULL value in the case of an error. | |
8497 * This string must be freed by OrthancPluginFreeString(). | |
8498 * @ingroup Orthanc | |
8499 **/ | |
8500 ORTHANC_PLUGIN_INLINE char* OrthancPluginGenerateRestApiAuthorizationToken( | |
8501 OrthancPluginContext* context) | |
8502 { | |
8503 char* result; | |
8504 | |
8505 _OrthancPluginRetrieveDynamicString params; | |
8506 params.result = &result; | |
8507 params.argument = NULL; | |
8508 | |
8509 if (context->InvokeService(context, _OrthancPluginService_GenerateRestApiAuthorizationToken, | |
8510 ¶ms) != OrthancPluginErrorCode_Success) | |
8511 { | |
8512 /* Error */ | |
8513 return NULL; | |
8514 } | |
8515 else | |
8516 { | |
8517 return result; | |
8518 } | |
8519 } | |
8520 | |
8521 | |
8522 | |
8523 typedef struct | |
8524 { | |
8525 OrthancPluginMemoryBuffer64* target; | |
8526 uint64_t size; | |
8527 } _OrthancPluginCreateMemoryBuffer64; | |
8528 | |
8529 /** | |
8530 * @brief Create a 64-bit memory buffer. | |
8531 * | |
8532 * This function creates a 64-bit memory buffer that is managed by | |
8533 * the Orthanc core. The main use case of this function is for | |
8534 * plugins that read files from the storage area. | |
8535 * | |
8536 * Your plugin should never call "free()" on the resulting memory | |
8537 * buffer, as the C library that is used by the plugin is in general | |
8538 * not the same as the one used by the Orthanc core. | |
8539 * | |
8540 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8541 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
8542 * @param size Size of the memory buffer to be created. | |
8543 * @return 0 if success, or the error code if failure. | |
8544 * @ingroup Toolbox | |
8545 **/ | |
8546 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateMemoryBuffer64( | |
8547 OrthancPluginContext* context, | |
8548 OrthancPluginMemoryBuffer64* target, | |
8549 uint64_t size) | |
8550 { | |
8551 _OrthancPluginCreateMemoryBuffer64 params; | |
8552 params.target = target; | |
8553 params.size = size; | |
8554 | |
8555 return context->InvokeService(context, _OrthancPluginService_CreateMemoryBuffer64, ¶ms); | |
8556 } | |
8557 | |
8558 | |
8559 typedef struct | |
8560 { | |
8561 OrthancPluginStorageCreate create; | |
8562 OrthancPluginStorageReadWhole readWhole; | |
8563 OrthancPluginStorageReadRange readRange; | |
8564 OrthancPluginStorageRemove remove; | |
8565 } _OrthancPluginRegisterStorageArea2; | |
8566 | |
8567 /** | |
8568 * @brief Register a custom storage area, with support for range request. | |
8569 * | |
8570 * This function registers a custom storage area, to replace the | |
8571 * built-in way Orthanc stores its files on the filesystem. This | |
8572 * function must be called during the initialization of the plugin, | |
8573 * i.e. inside the OrthancPluginInitialize() public function. | |
8574 * | |
8575 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8576 * @param create The callback function to store a file on the custom storage area. | |
8577 * @param readWhole The callback function to read a whole file from the custom storage area. | |
8578 * @param readRange The callback function to read some range of a file from the custom storage area. | |
8579 * If this feature is not supported by the plugin, this value can be set to NULL. | |
8580 * @param remove The callback function to remove a file from the custom storage area. | |
8581 * @ingroup Callbacks | |
8582 **/ | |
8583 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterStorageArea2( | |
8584 OrthancPluginContext* context, | |
8585 OrthancPluginStorageCreate create, | |
8586 OrthancPluginStorageReadWhole readWhole, | |
8587 OrthancPluginStorageReadRange readRange, | |
8588 OrthancPluginStorageRemove remove) | |
8589 { | |
8590 _OrthancPluginRegisterStorageArea2 params; | |
8591 params.create = create; | |
8592 params.readWhole = readWhole; | |
8593 params.readRange = readRange; | |
8594 params.remove = remove; | |
8595 context->InvokeService(context, _OrthancPluginService_RegisterStorageArea2, ¶ms); | |
8596 } | |
8597 | |
8598 | |
8599 | |
8600 typedef struct | |
8601 { | |
8602 _OrthancPluginCreateDicom createDicom; | |
8603 const char* privateCreator; | |
8604 } _OrthancPluginCreateDicom2; | |
8605 | |
8606 /** | |
8607 * @brief Create a DICOM instance from a JSON string and an image, with a private creator. | |
8608 * | |
8609 * This function takes as input a string containing a JSON file | |
8610 * describing the content of a DICOM instance. As an output, it | |
8611 * writes the corresponding DICOM instance to a newly allocated | |
8612 * memory buffer. Additionally, an image to be encoded within the | |
8613 * DICOM instance can also be provided. | |
8614 * | |
8615 * Contrarily to the function OrthancPluginCreateDicom(), this | |
8616 * function can be explicitly provided with a private creator. | |
8617 * | |
8618 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8619 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
8620 * @param json The input JSON file. | |
8621 * @param pixelData The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme. | |
8622 * @param flags Flags governing the output. | |
8623 * @param privateCreator The private creator to be used for the private DICOM tags. | |
8624 * Check out the global configuration option "Dictionary" of Orthanc. | |
8625 * @return 0 if success, other value if error. | |
8626 * @ingroup Toolbox | |
8627 * @see OrthancPluginCreateDicom | |
8628 * @see OrthancPluginDicomBufferToJson | |
8629 **/ | |
8630 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateDicom2( | |
8631 OrthancPluginContext* context, | |
8632 OrthancPluginMemoryBuffer* target, | |
8633 const char* json, | |
8634 const OrthancPluginImage* pixelData, | |
8635 OrthancPluginCreateDicomFlags flags, | |
8636 const char* privateCreator) | |
8637 { | |
8638 _OrthancPluginCreateDicom2 params; | |
8639 params.createDicom.target = target; | |
8640 params.createDicom.json = json; | |
8641 params.createDicom.pixelData = pixelData; | |
8642 params.createDicom.flags = flags; | |
8643 params.privateCreator = privateCreator; | |
8644 | |
8645 return context->InvokeService(context, _OrthancPluginService_CreateDicom2, ¶ms); | |
8646 } | |
8647 | |
8648 | |
8649 | |
8650 | |
8651 | |
8652 | |
8653 typedef struct | |
8654 { | |
8655 OrthancPluginMemoryBuffer* answerBody; | |
8656 OrthancPluginMemoryBuffer* answerHeaders; | |
8657 uint16_t* httpStatus; | |
8658 OrthancPluginHttpMethod method; | |
8659 const char* uri; | |
8660 uint32_t headersCount; | |
8661 const char* const* headersKeys; | |
8662 const char* const* headersValues; | |
8663 const void* body; | |
8664 uint32_t bodySize; | |
8665 uint8_t afterPlugins; | |
8666 } _OrthancPluginCallRestApi; | |
8667 | |
8668 /** | |
8669 * @brief Call the REST API of Orthanc with full flexibility. | |
8670 * | |
8671 * Make a call to the given URI in the REST API of Orthanc. The | |
8672 * result to the query is stored into a newly allocated memory | |
8673 * buffer. This function is always granted full access to the REST | |
8674 * API (no credentials, nor security token is needed). | |
8675 * | |
8676 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
8677 * @param answerBody The target memory buffer (out argument). | |
8678 * It must be freed with OrthancPluginFreeMemoryBuffer(). | |
8679 * The value of this argument is ignored if the HTTP method is DELETE. | |
8680 * @param answerHeaders The target memory buffer for the HTTP headers in the answer (out argument). | |
8681 * The answer headers are formatted as a JSON object (associative array). | |
8682 * The buffer must be freed with OrthancPluginFreeMemoryBuffer(). | |
8683 * This argument can be set to NULL if the plugin has no interest in the answer HTTP headers. | |
8684 * @param httpStatus The HTTP status after the execution of the request (out argument). | |
8685 * @param method HTTP method to be used. | |
8686 * @param uri The URI of interest. | |
8687 * @param headersCount The number of HTTP headers. | |
8688 * @param headersKeys Array containing the keys of the HTTP headers (can be <tt>NULL</tt> if no header). | |
8689 * @param headersValues Array containing the values of the HTTP headers (can be <tt>NULL</tt> if no header). | |
8690 * @param body The HTTP body for a POST or PUT request. | |
8691 * @param bodySize The size of the body. | |
8692 * @param afterPlugins If 0, the built-in API of Orthanc is used. | |
8693 * If 1, the API is tainted by the plugins. | |
8694 * @return 0 if success, or the error code if failure. | |
8695 * @see OrthancPluginRestApiGet2, OrthancPluginRestApiPost, OrthancPluginRestApiPut, OrthancPluginRestApiDelete | |
8696 * @ingroup Orthanc | |
8697 **/ | |
8698 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCallRestApi( | |
8699 OrthancPluginContext* context, | |
8700 OrthancPluginMemoryBuffer* answerBody, | |
8701 OrthancPluginMemoryBuffer* answerHeaders, | |
8702 uint16_t* httpStatus, | |
8703 OrthancPluginHttpMethod method, | |
8704 const char* uri, | |
8705 uint32_t headersCount, | |
8706 const char* const* headersKeys, | |
8707 const char* const* headersValues, | |
8708 const void* body, | |
8709 uint32_t bodySize, | |
8710 uint8_t afterPlugins) | |
8711 { | |
8712 _OrthancPluginCallRestApi params; | |
8713 memset(¶ms, 0, sizeof(params)); | |
8714 | |
8715 params.answerBody = answerBody; | |
8716 params.answerHeaders = answerHeaders; | |
8717 params.httpStatus = httpStatus; | |
8718 params.method = method; | |
8719 params.uri = uri; | |
8720 params.headersCount = headersCount; | |
8721 params.headersKeys = headersKeys; | |
8722 params.headersValues = headersValues; | |
8723 params.body = body; | |
8724 params.bodySize = bodySize; | |
8725 params.afterPlugins = afterPlugins; | |
8726 | |
8727 return context->InvokeService(context, _OrthancPluginService_CallRestApi, ¶ms); | |
8728 } | |
8729 | |
8730 | |
8731 #ifdef __cplusplus | |
8732 } | |
8733 #endif | |
8734 | |
8735 | |
8736 /** @} */ | |
8737 |