0
|
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 ::OrthancPluginRegisterStorageArea().
|
|
20 * - Possibly register a custom database back-end area using OrthancPluginRegisterDatabaseBackendV2().
|
|
21 * - Possibly register a handler for C-Find SCP against DICOM worklists using OrthancPluginRegisterWorklistCallback().
|
|
22 * - Possibly register a custom decoder for DICOM images using OrthancPluginRegisterDecodeImageCallback().
|
|
23 * -# <tt>void OrthancPluginFinalize()</tt>:
|
|
24 * This function is invoked by Orthanc during its shutdown. The plugin
|
|
25 * must free all its memory.
|
|
26 * -# <tt>const char* OrthancPluginGetName()</tt>:
|
|
27 * The plugin must return a short string to identify itself.
|
|
28 * -# <tt>const char* OrthancPluginGetVersion()</tt>:
|
|
29 * The plugin must return a string containing its version number.
|
|
30 *
|
|
31 * The name and the version of a plugin is only used to prevent it
|
|
32 * from being loaded twice. Note that, in C++, it is mandatory to
|
|
33 * declare these functions within an <tt>extern "C"</tt> section.
|
|
34 *
|
|
35 * To ensure multi-threading safety, the various REST callbacks are
|
|
36 * guaranteed to be executed in mutual exclusion since Orthanc
|
|
37 * 0.8.5. If this feature is undesired (notably when developing
|
|
38 * high-performance plugins handling simultaneous requests), use
|
|
39 * ::OrthancPluginRegisterRestCallbackNoLock().
|
|
40 **/
|
|
41
|
|
42
|
|
43
|
|
44 /**
|
|
45 * @defgroup Images Images and compression
|
|
46 * @brief Functions to deal with images and compressed buffers.
|
|
47 *
|
|
48 * @defgroup REST REST
|
|
49 * @brief Functions to answer REST requests in a callback.
|
|
50 *
|
|
51 * @defgroup Callbacks Callbacks
|
|
52 * @brief Functions to register and manage callbacks by the plugins.
|
|
53 *
|
|
54 * @defgroup Worklists Worklists
|
|
55 * @brief Functions to register and manage worklists.
|
|
56 *
|
|
57 * @defgroup Orthanc Orthanc
|
|
58 * @brief Functions to access the content of the Orthanc server.
|
|
59 **/
|
|
60
|
|
61
|
|
62
|
|
63 /**
|
|
64 * @defgroup Toolbox Toolbox
|
|
65 * @brief Generic functions to help with the creation of plugins.
|
|
66 **/
|
|
67
|
|
68
|
|
69
|
|
70 /**
|
|
71 * Orthanc - A Lightweight, RESTful DICOM Store
|
|
72 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
|
|
73 * Department, University Hospital of Liege, Belgium
|
|
74 *
|
|
75 * This program is free software: you can redistribute it and/or
|
|
76 * modify it under the terms of the GNU General Public License as
|
|
77 * published by the Free Software Foundation, either version 3 of the
|
|
78 * License, or (at your option) any later version.
|
|
79 *
|
|
80 * In addition, as a special exception, the copyright holders of this
|
|
81 * program give permission to link the code of its release with the
|
|
82 * OpenSSL project's "OpenSSL" library (or with modified versions of it
|
|
83 * that use the same license as the "OpenSSL" library), and distribute
|
|
84 * the linked executables. You must obey the GNU General Public License
|
|
85 * in all respects for all of the code used other than "OpenSSL". If you
|
|
86 * modify file(s) with this exception, you may extend this exception to
|
|
87 * your version of the file(s), but you are not obligated to do so. If
|
|
88 * you do not wish to do so, delete this exception statement from your
|
|
89 * version. If you delete this exception statement from all source files
|
|
90 * in the program, then also delete it here.
|
|
91 *
|
|
92 * This program is distributed in the hope that it will be useful, but
|
|
93 * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
94 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
95 * General Public License for more details.
|
|
96 *
|
|
97 * You should have received a copy of the GNU General Public License
|
|
98 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
99 **/
|
|
100
|
|
101
|
|
102
|
|
103 #pragma once
|
|
104
|
|
105
|
|
106 #include <stdio.h>
|
|
107 #include <string.h>
|
|
108
|
|
109 #ifdef WIN32
|
|
110 #define ORTHANC_PLUGINS_API __declspec(dllexport)
|
|
111 #else
|
|
112 #define ORTHANC_PLUGINS_API
|
|
113 #endif
|
|
114
|
|
115 #define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 1
|
|
116 #define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 0
|
|
117 #define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 0
|
|
118
|
|
119
|
|
120
|
|
121 /********************************************************************
|
|
122 ** Check that function inlining is properly supported. The use of
|
|
123 ** inlining is required, to avoid the duplication of object code
|
|
124 ** between two compilation modules that would use the Orthanc Plugin
|
|
125 ** API.
|
|
126 ********************************************************************/
|
|
127
|
|
128 /* If the auto-detection of the "inline" keyword below does not work
|
|
129 automatically and that your compiler is known to properly support
|
|
130 inlining, uncomment the following #define and adapt the definition
|
|
131 of "static inline". */
|
|
132
|
|
133 /* #define ORTHANC_PLUGIN_INLINE static inline */
|
|
134
|
|
135 #ifndef ORTHANC_PLUGIN_INLINE
|
|
136 # if __STDC_VERSION__ >= 199901L
|
|
137 /* This is C99 or above: http://predef.sourceforge.net/prestd.html */
|
|
138 # define ORTHANC_PLUGIN_INLINE static inline
|
|
139 # elif defined(__cplusplus)
|
|
140 /* This is C++ */
|
|
141 # define ORTHANC_PLUGIN_INLINE static inline
|
|
142 # elif defined(__GNUC__)
|
|
143 /* This is GCC running in C89 mode */
|
|
144 # define ORTHANC_PLUGIN_INLINE static __inline
|
|
145 # elif defined(_MSC_VER)
|
|
146 /* This is Visual Studio running in C89 mode */
|
|
147 # define ORTHANC_PLUGIN_INLINE static __inline
|
|
148 # else
|
|
149 # error Your compiler is not known to support the "inline" keyword
|
|
150 # endif
|
|
151 #endif
|
|
152
|
|
153
|
|
154
|
|
155 /********************************************************************
|
|
156 ** Inclusion of standard libraries.
|
|
157 ********************************************************************/
|
|
158
|
|
159 /**
|
|
160 * For Microsoft Visual Studio, a compatibility "stdint.h" can be
|
|
161 * downloaded at the following URL:
|
|
162 * https://orthanc.googlecode.com/hg/Resources/ThirdParty/VisualStudio/stdint.h
|
|
163 **/
|
|
164 #include <stdint.h>
|
|
165
|
|
166 #include <stdlib.h>
|
|
167
|
|
168
|
|
169
|
|
170 /********************************************************************
|
|
171 ** Definition of the Orthanc Plugin API.
|
|
172 ********************************************************************/
|
|
173
|
|
174 /** @{ */
|
|
175
|
|
176 #ifdef __cplusplus
|
|
177 extern "C"
|
|
178 {
|
|
179 #endif
|
|
180
|
|
181 /**
|
|
182 * The various error codes that can be returned by the Orthanc core.
|
|
183 **/
|
|
184 typedef enum
|
|
185 {
|
|
186 OrthancPluginErrorCode_InternalError = -1 /*!< Internal error */,
|
|
187 OrthancPluginErrorCode_Success = 0 /*!< Success */,
|
|
188 OrthancPluginErrorCode_Plugin = 1 /*!< Error encountered within the plugin engine */,
|
|
189 OrthancPluginErrorCode_NotImplemented = 2 /*!< Not implemented yet */,
|
|
190 OrthancPluginErrorCode_ParameterOutOfRange = 3 /*!< Parameter out of range */,
|
|
191 OrthancPluginErrorCode_NotEnoughMemory = 4 /*!< Not enough memory */,
|
|
192 OrthancPluginErrorCode_BadParameterType = 5 /*!< Bad type for a parameter */,
|
|
193 OrthancPluginErrorCode_BadSequenceOfCalls = 6 /*!< Bad sequence of calls */,
|
|
194 OrthancPluginErrorCode_InexistentItem = 7 /*!< Accessing an inexistent item */,
|
|
195 OrthancPluginErrorCode_BadRequest = 8 /*!< Bad request */,
|
|
196 OrthancPluginErrorCode_NetworkProtocol = 9 /*!< Error in the network protocol */,
|
|
197 OrthancPluginErrorCode_SystemCommand = 10 /*!< Error while calling a system command */,
|
|
198 OrthancPluginErrorCode_Database = 11 /*!< Error with the database engine */,
|
|
199 OrthancPluginErrorCode_UriSyntax = 12 /*!< Badly formatted URI */,
|
|
200 OrthancPluginErrorCode_InexistentFile = 13 /*!< Inexistent file */,
|
|
201 OrthancPluginErrorCode_CannotWriteFile = 14 /*!< Cannot write to file */,
|
|
202 OrthancPluginErrorCode_BadFileFormat = 15 /*!< Bad file format */,
|
|
203 OrthancPluginErrorCode_Timeout = 16 /*!< Timeout */,
|
|
204 OrthancPluginErrorCode_UnknownResource = 17 /*!< Unknown resource */,
|
|
205 OrthancPluginErrorCode_IncompatibleDatabaseVersion = 18 /*!< Incompatible version of the database */,
|
|
206 OrthancPluginErrorCode_FullStorage = 19 /*!< The file storage is full */,
|
|
207 OrthancPluginErrorCode_CorruptedFile = 20 /*!< Corrupted file (e.g. inconsistent MD5 hash) */,
|
|
208 OrthancPluginErrorCode_InexistentTag = 21 /*!< Inexistent tag */,
|
|
209 OrthancPluginErrorCode_ReadOnly = 22 /*!< Cannot modify a read-only data structure */,
|
|
210 OrthancPluginErrorCode_IncompatibleImageFormat = 23 /*!< Incompatible format of the images */,
|
|
211 OrthancPluginErrorCode_IncompatibleImageSize = 24 /*!< Incompatible size of the images */,
|
|
212 OrthancPluginErrorCode_SharedLibrary = 25 /*!< Error while using a shared library (plugin) */,
|
|
213 OrthancPluginErrorCode_UnknownPluginService = 26 /*!< Plugin invoking an unknown service */,
|
|
214 OrthancPluginErrorCode_UnknownDicomTag = 27 /*!< Unknown DICOM tag */,
|
|
215 OrthancPluginErrorCode_BadJson = 28 /*!< Cannot parse a JSON document */,
|
|
216 OrthancPluginErrorCode_Unauthorized = 29 /*!< Bad credentials were provided to an HTTP request */,
|
|
217 OrthancPluginErrorCode_BadFont = 30 /*!< Badly formatted font file */,
|
|
218 OrthancPluginErrorCode_DatabasePlugin = 31 /*!< The plugin implementing a custom database back-end does not fulfill the proper interface */,
|
|
219 OrthancPluginErrorCode_StorageAreaPlugin = 32 /*!< Error in the plugin implementing a custom storage area */,
|
|
220 OrthancPluginErrorCode_EmptyRequest = 33 /*!< The request is empty */,
|
|
221 OrthancPluginErrorCode_NotAcceptable = 34 /*!< Cannot send a response which is acceptable according to the Accept HTTP header */,
|
|
222 OrthancPluginErrorCode_SQLiteNotOpened = 1000 /*!< SQLite: The database is not opened */,
|
|
223 OrthancPluginErrorCode_SQLiteAlreadyOpened = 1001 /*!< SQLite: Connection is already open */,
|
|
224 OrthancPluginErrorCode_SQLiteCannotOpen = 1002 /*!< SQLite: Unable to open the database */,
|
|
225 OrthancPluginErrorCode_SQLiteStatementAlreadyUsed = 1003 /*!< SQLite: This cached statement is already being referred to */,
|
|
226 OrthancPluginErrorCode_SQLiteExecute = 1004 /*!< SQLite: Cannot execute a command */,
|
|
227 OrthancPluginErrorCode_SQLiteRollbackWithoutTransaction = 1005 /*!< SQLite: Rolling back a nonexistent transaction (have you called Begin()?) */,
|
|
228 OrthancPluginErrorCode_SQLiteCommitWithoutTransaction = 1006 /*!< SQLite: Committing a nonexistent transaction */,
|
|
229 OrthancPluginErrorCode_SQLiteRegisterFunction = 1007 /*!< SQLite: Unable to register a function */,
|
|
230 OrthancPluginErrorCode_SQLiteFlush = 1008 /*!< SQLite: Unable to flush the database */,
|
|
231 OrthancPluginErrorCode_SQLiteCannotRun = 1009 /*!< SQLite: Cannot run a cached statement */,
|
|
232 OrthancPluginErrorCode_SQLiteCannotStep = 1010 /*!< SQLite: Cannot step over a cached statement */,
|
|
233 OrthancPluginErrorCode_SQLiteBindOutOfRange = 1011 /*!< SQLite: Bing a value while out of range (serious error) */,
|
|
234 OrthancPluginErrorCode_SQLitePrepareStatement = 1012 /*!< SQLite: Cannot prepare a cached statement */,
|
|
235 OrthancPluginErrorCode_SQLiteTransactionAlreadyStarted = 1013 /*!< SQLite: Beginning the same transaction twice */,
|
|
236 OrthancPluginErrorCode_SQLiteTransactionCommit = 1014 /*!< SQLite: Failure when committing the transaction */,
|
|
237 OrthancPluginErrorCode_SQLiteTransactionBegin = 1015 /*!< SQLite: Cannot start a transaction */,
|
|
238 OrthancPluginErrorCode_DirectoryOverFile = 2000 /*!< The directory to be created is already occupied by a regular file */,
|
|
239 OrthancPluginErrorCode_FileStorageCannotWrite = 2001 /*!< Unable to create a subdirectory or a file in the file storage */,
|
|
240 OrthancPluginErrorCode_DirectoryExpected = 2002 /*!< The specified path does not point to a directory */,
|
|
241 OrthancPluginErrorCode_HttpPortInUse = 2003 /*!< The TCP port of the HTTP server is already in use */,
|
|
242 OrthancPluginErrorCode_DicomPortInUse = 2004 /*!< The TCP port of the DICOM server is already in use */,
|
|
243 OrthancPluginErrorCode_BadHttpStatusInRest = 2005 /*!< This HTTP status is not allowed in a REST API */,
|
|
244 OrthancPluginErrorCode_RegularFileExpected = 2006 /*!< The specified path does not point to a regular file */,
|
|
245 OrthancPluginErrorCode_PathToExecutable = 2007 /*!< Unable to get the path to the executable */,
|
|
246 OrthancPluginErrorCode_MakeDirectory = 2008 /*!< Cannot create a directory */,
|
|
247 OrthancPluginErrorCode_BadApplicationEntityTitle = 2009 /*!< An application entity title (AET) cannot be empty or be longer than 16 characters */,
|
|
248 OrthancPluginErrorCode_NoCFindHandler = 2010 /*!< No request handler factory for DICOM C-FIND SCP */,
|
|
249 OrthancPluginErrorCode_NoCMoveHandler = 2011 /*!< No request handler factory for DICOM C-MOVE SCP */,
|
|
250 OrthancPluginErrorCode_NoCStoreHandler = 2012 /*!< No request handler factory for DICOM C-STORE SCP */,
|
|
251 OrthancPluginErrorCode_NoApplicationEntityFilter = 2013 /*!< No application entity filter */,
|
|
252 OrthancPluginErrorCode_NoSopClassOrInstance = 2014 /*!< DicomUserConnection: Unable to find the SOP class and instance */,
|
|
253 OrthancPluginErrorCode_NoPresentationContext = 2015 /*!< DicomUserConnection: No acceptable presentation context for modality */,
|
|
254 OrthancPluginErrorCode_DicomFindUnavailable = 2016 /*!< DicomUserConnection: The C-FIND command is not supported by the remote SCP */,
|
|
255 OrthancPluginErrorCode_DicomMoveUnavailable = 2017 /*!< DicomUserConnection: The C-MOVE command is not supported by the remote SCP */,
|
|
256 OrthancPluginErrorCode_CannotStoreInstance = 2018 /*!< Cannot store an instance */,
|
|
257 OrthancPluginErrorCode_CreateDicomNotString = 2019 /*!< Only string values are supported when creating DICOM instances */,
|
|
258 OrthancPluginErrorCode_CreateDicomOverrideTag = 2020 /*!< Trying to override a value inherited from a parent module */,
|
|
259 OrthancPluginErrorCode_CreateDicomUseContent = 2021 /*!< Use \"Content\" to inject an image into a new DICOM instance */,
|
|
260 OrthancPluginErrorCode_CreateDicomNoPayload = 2022 /*!< No payload is present for one instance in the series */,
|
|
261 OrthancPluginErrorCode_CreateDicomUseDataUriScheme = 2023 /*!< The payload of the DICOM instance must be specified according to Data URI scheme */,
|
|
262 OrthancPluginErrorCode_CreateDicomBadParent = 2024 /*!< Trying to attach a new DICOM instance to an inexistent resource */,
|
|
263 OrthancPluginErrorCode_CreateDicomParentIsInstance = 2025 /*!< Trying to attach a new DICOM instance to an instance (must be a series, study or patient) */,
|
|
264 OrthancPluginErrorCode_CreateDicomParentEncoding = 2026 /*!< Unable to get the encoding of the parent resource */,
|
|
265 OrthancPluginErrorCode_UnknownModality = 2027 /*!< Unknown modality */,
|
|
266 OrthancPluginErrorCode_BadJobOrdering = 2028 /*!< Bad ordering of filters in a job */,
|
|
267 OrthancPluginErrorCode_JsonToLuaTable = 2029 /*!< Cannot convert the given JSON object to a Lua table */,
|
|
268 OrthancPluginErrorCode_CannotCreateLua = 2030 /*!< Cannot create the Lua context */,
|
|
269 OrthancPluginErrorCode_CannotExecuteLua = 2031 /*!< Cannot execute a Lua command */,
|
|
270 OrthancPluginErrorCode_LuaAlreadyExecuted = 2032 /*!< Arguments cannot be pushed after the Lua function is executed */,
|
|
271 OrthancPluginErrorCode_LuaBadOutput = 2033 /*!< The Lua function does not give the expected number of outputs */,
|
|
272 OrthancPluginErrorCode_NotLuaPredicate = 2034 /*!< The Lua function is not a predicate (only true/false outputs allowed) */,
|
|
273 OrthancPluginErrorCode_LuaReturnsNoString = 2035 /*!< The Lua function does not return a string */,
|
|
274 OrthancPluginErrorCode_StorageAreaAlreadyRegistered = 2036 /*!< Another plugin has already registered a custom storage area */,
|
|
275 OrthancPluginErrorCode_DatabaseBackendAlreadyRegistered = 2037 /*!< Another plugin has already registered a custom database back-end */,
|
|
276 OrthancPluginErrorCode_DatabaseNotInitialized = 2038 /*!< Plugin trying to call the database during its initialization */,
|
|
277 OrthancPluginErrorCode_SslDisabled = 2039 /*!< Orthanc has been built without SSL support */,
|
|
278 OrthancPluginErrorCode_CannotOrderSlices = 2040 /*!< Unable to order the slices of the series */,
|
|
279 OrthancPluginErrorCode_NoWorklistHandler = 2041 /*!< No request handler factory for DICOM C-Find Modality SCP */,
|
|
280
|
|
281 _OrthancPluginErrorCode_INTERNAL = 0x7fffffff
|
|
282 } OrthancPluginErrorCode;
|
|
283
|
|
284
|
|
285 /**
|
|
286 * Forward declaration of one of the mandatory functions for Orthanc
|
|
287 * plugins.
|
|
288 **/
|
|
289 ORTHANC_PLUGINS_API const char* OrthancPluginGetName();
|
|
290
|
|
291
|
|
292 /**
|
|
293 * The various HTTP methods for a REST call.
|
|
294 **/
|
|
295 typedef enum
|
|
296 {
|
|
297 OrthancPluginHttpMethod_Get = 1, /*!< GET request */
|
|
298 OrthancPluginHttpMethod_Post = 2, /*!< POST request */
|
|
299 OrthancPluginHttpMethod_Put = 3, /*!< PUT request */
|
|
300 OrthancPluginHttpMethod_Delete = 4, /*!< DELETE request */
|
|
301
|
|
302 _OrthancPluginHttpMethod_INTERNAL = 0x7fffffff
|
|
303 } OrthancPluginHttpMethod;
|
|
304
|
|
305
|
|
306 /**
|
|
307 * @brief The parameters of a REST request.
|
|
308 * @ingroup Callbacks
|
|
309 **/
|
|
310 typedef struct
|
|
311 {
|
|
312 /**
|
|
313 * @brief The HTTP method.
|
|
314 **/
|
|
315 OrthancPluginHttpMethod method;
|
|
316
|
|
317 /**
|
|
318 * @brief The number of groups of the regular expression.
|
|
319 **/
|
|
320 uint32_t groupsCount;
|
|
321
|
|
322 /**
|
|
323 * @brief The matched values for the groups of the regular expression.
|
|
324 **/
|
|
325 const char* const* groups;
|
|
326
|
|
327 /**
|
|
328 * @brief For a GET request, the number of GET parameters.
|
|
329 **/
|
|
330 uint32_t getCount;
|
|
331
|
|
332 /**
|
|
333 * @brief For a GET request, the keys of the GET parameters.
|
|
334 **/
|
|
335 const char* const* getKeys;
|
|
336
|
|
337 /**
|
|
338 * @brief For a GET request, the values of the GET parameters.
|
|
339 **/
|
|
340 const char* const* getValues;
|
|
341
|
|
342 /**
|
|
343 * @brief For a PUT or POST request, the content of the body.
|
|
344 **/
|
|
345 const char* body;
|
|
346
|
|
347 /**
|
|
348 * @brief For a PUT or POST request, the number of bytes of the body.
|
|
349 **/
|
|
350 uint32_t bodySize;
|
|
351
|
|
352
|
|
353 /* --------------------------------------------------
|
|
354 New in version 0.8.1
|
|
355 -------------------------------------------------- */
|
|
356
|
|
357 /**
|
|
358 * @brief The number of HTTP headers.
|
|
359 **/
|
|
360 uint32_t headersCount;
|
|
361
|
|
362 /**
|
|
363 * @brief The keys of the HTTP headers (always converted to low-case).
|
|
364 **/
|
|
365 const char* const* headersKeys;
|
|
366
|
|
367 /**
|
|
368 * @brief The values of the HTTP headers.
|
|
369 **/
|
|
370 const char* const* headersValues;
|
|
371
|
|
372 } OrthancPluginHttpRequest;
|
|
373
|
|
374
|
|
375 typedef enum
|
|
376 {
|
|
377 /* Generic services */
|
|
378 _OrthancPluginService_LogInfo = 1,
|
|
379 _OrthancPluginService_LogWarning = 2,
|
|
380 _OrthancPluginService_LogError = 3,
|
|
381 _OrthancPluginService_GetOrthancPath = 4,
|
|
382 _OrthancPluginService_GetOrthancDirectory = 5,
|
|
383 _OrthancPluginService_GetConfigurationPath = 6,
|
|
384 _OrthancPluginService_SetPluginProperty = 7,
|
|
385 _OrthancPluginService_GetGlobalProperty = 8,
|
|
386 _OrthancPluginService_SetGlobalProperty = 9,
|
|
387 _OrthancPluginService_GetCommandLineArgumentsCount = 10,
|
|
388 _OrthancPluginService_GetCommandLineArgument = 11,
|
|
389 _OrthancPluginService_GetExpectedDatabaseVersion = 12,
|
|
390 _OrthancPluginService_GetConfiguration = 13,
|
|
391 _OrthancPluginService_BufferCompression = 14,
|
|
392 _OrthancPluginService_ReadFile = 15,
|
|
393 _OrthancPluginService_WriteFile = 16,
|
|
394 _OrthancPluginService_GetErrorDescription = 17,
|
|
395 _OrthancPluginService_CallHttpClient = 18,
|
|
396 _OrthancPluginService_RegisterErrorCode = 19,
|
|
397 _OrthancPluginService_RegisterDictionaryTag = 20,
|
|
398 _OrthancPluginService_DicomBufferToJson = 21,
|
|
399 _OrthancPluginService_DicomInstanceToJson = 22,
|
|
400 _OrthancPluginService_CreateDicom = 23,
|
|
401 _OrthancPluginService_ComputeMd5 = 24,
|
|
402 _OrthancPluginService_ComputeSha1 = 25,
|
|
403 _OrthancPluginService_LookupDictionary = 26,
|
|
404
|
|
405 /* Registration of callbacks */
|
|
406 _OrthancPluginService_RegisterRestCallback = 1000,
|
|
407 _OrthancPluginService_RegisterOnStoredInstanceCallback = 1001,
|
|
408 _OrthancPluginService_RegisterStorageArea = 1002,
|
|
409 _OrthancPluginService_RegisterOnChangeCallback = 1003,
|
|
410 _OrthancPluginService_RegisterRestCallbackNoLock = 1004,
|
|
411 _OrthancPluginService_RegisterWorklistCallback = 1005,
|
|
412 _OrthancPluginService_RegisterDecodeImageCallback = 1006,
|
|
413
|
|
414 /* Sending answers to REST calls */
|
|
415 _OrthancPluginService_AnswerBuffer = 2000,
|
|
416 _OrthancPluginService_CompressAndAnswerPngImage = 2001, /* Unused as of Orthanc 0.9.4 */
|
|
417 _OrthancPluginService_Redirect = 2002,
|
|
418 _OrthancPluginService_SendHttpStatusCode = 2003,
|
|
419 _OrthancPluginService_SendUnauthorized = 2004,
|
|
420 _OrthancPluginService_SendMethodNotAllowed = 2005,
|
|
421 _OrthancPluginService_SetCookie = 2006,
|
|
422 _OrthancPluginService_SetHttpHeader = 2007,
|
|
423 _OrthancPluginService_StartMultipartAnswer = 2008,
|
|
424 _OrthancPluginService_SendMultipartItem = 2009,
|
|
425 _OrthancPluginService_SendHttpStatus = 2010,
|
|
426 _OrthancPluginService_CompressAndAnswerImage = 2011,
|
|
427 _OrthancPluginService_SendMultipartItem2 = 2012,
|
|
428
|
|
429 /* Access to the Orthanc database and API */
|
|
430 _OrthancPluginService_GetDicomForInstance = 3000,
|
|
431 _OrthancPluginService_RestApiGet = 3001,
|
|
432 _OrthancPluginService_RestApiPost = 3002,
|
|
433 _OrthancPluginService_RestApiDelete = 3003,
|
|
434 _OrthancPluginService_RestApiPut = 3004,
|
|
435 _OrthancPluginService_LookupPatient = 3005,
|
|
436 _OrthancPluginService_LookupStudy = 3006,
|
|
437 _OrthancPluginService_LookupSeries = 3007,
|
|
438 _OrthancPluginService_LookupInstance = 3008,
|
|
439 _OrthancPluginService_LookupStudyWithAccessionNumber = 3009,
|
|
440 _OrthancPluginService_RestApiGetAfterPlugins = 3010,
|
|
441 _OrthancPluginService_RestApiPostAfterPlugins = 3011,
|
|
442 _OrthancPluginService_RestApiDeleteAfterPlugins = 3012,
|
|
443 _OrthancPluginService_RestApiPutAfterPlugins = 3013,
|
|
444 _OrthancPluginService_ReconstructMainDicomTags = 3014,
|
|
445 _OrthancPluginService_RestApiGet2 = 3015,
|
|
446
|
|
447 /* Access to DICOM instances */
|
|
448 _OrthancPluginService_GetInstanceRemoteAet = 4000,
|
|
449 _OrthancPluginService_GetInstanceSize = 4001,
|
|
450 _OrthancPluginService_GetInstanceData = 4002,
|
|
451 _OrthancPluginService_GetInstanceJson = 4003,
|
|
452 _OrthancPluginService_GetInstanceSimplifiedJson = 4004,
|
|
453 _OrthancPluginService_HasInstanceMetadata = 4005,
|
|
454 _OrthancPluginService_GetInstanceMetadata = 4006,
|
|
455 _OrthancPluginService_GetInstanceOrigin = 4007,
|
|
456
|
|
457 /* Services for plugins implementing a database back-end */
|
|
458 _OrthancPluginService_RegisterDatabaseBackend = 5000,
|
|
459 _OrthancPluginService_DatabaseAnswer = 5001,
|
|
460 _OrthancPluginService_RegisterDatabaseBackendV2 = 5002,
|
|
461 _OrthancPluginService_StorageAreaCreate = 5003,
|
|
462 _OrthancPluginService_StorageAreaRead = 5004,
|
|
463 _OrthancPluginService_StorageAreaRemove = 5005,
|
|
464
|
|
465 /* Primitives for handling images */
|
|
466 _OrthancPluginService_GetImagePixelFormat = 6000,
|
|
467 _OrthancPluginService_GetImageWidth = 6001,
|
|
468 _OrthancPluginService_GetImageHeight = 6002,
|
|
469 _OrthancPluginService_GetImagePitch = 6003,
|
|
470 _OrthancPluginService_GetImageBuffer = 6004,
|
|
471 _OrthancPluginService_UncompressImage = 6005,
|
|
472 _OrthancPluginService_FreeImage = 6006,
|
|
473 _OrthancPluginService_CompressImage = 6007,
|
|
474 _OrthancPluginService_ConvertPixelFormat = 6008,
|
|
475 _OrthancPluginService_GetFontsCount = 6009,
|
|
476 _OrthancPluginService_GetFontInfo = 6010,
|
|
477 _OrthancPluginService_DrawText = 6011,
|
|
478 _OrthancPluginService_CreateImage = 6012,
|
|
479 _OrthancPluginService_CreateImageAccessor = 6013,
|
|
480 _OrthancPluginService_DecodeDicomImage = 6014,
|
|
481
|
|
482 /* Primitives for handling worklists */
|
|
483 _OrthancPluginService_WorklistAddAnswer = 7000,
|
|
484 _OrthancPluginService_WorklistMarkIncomplete = 7001,
|
|
485 _OrthancPluginService_WorklistIsMatch = 7002,
|
|
486 _OrthancPluginService_WorklistGetDicomQuery = 7003,
|
|
487
|
|
488 _OrthancPluginService_INTERNAL = 0x7fffffff
|
|
489 } _OrthancPluginService;
|
|
490
|
|
491
|
|
492 typedef enum
|
|
493 {
|
|
494 _OrthancPluginProperty_Description = 1,
|
|
495 _OrthancPluginProperty_RootUri = 2,
|
|
496 _OrthancPluginProperty_OrthancExplorer = 3,
|
|
497
|
|
498 _OrthancPluginProperty_INTERNAL = 0x7fffffff
|
|
499 } _OrthancPluginProperty;
|
|
500
|
|
501
|
|
502
|
|
503 /**
|
|
504 * The memory layout of the pixels of an image.
|
|
505 * @ingroup Images
|
|
506 **/
|
|
507 typedef enum
|
|
508 {
|
|
509 /**
|
|
510 * @brief Graylevel 8bpp image.
|
|
511 *
|
|
512 * The image is graylevel. Each pixel is unsigned and stored in
|
|
513 * one byte.
|
|
514 **/
|
|
515 OrthancPluginPixelFormat_Grayscale8 = 1,
|
|
516
|
|
517 /**
|
|
518 * @brief Graylevel, unsigned 16bpp image.
|
|
519 *
|
|
520 * The image is graylevel. Each pixel is unsigned and stored in
|
|
521 * two bytes.
|
|
522 **/
|
|
523 OrthancPluginPixelFormat_Grayscale16 = 2,
|
|
524
|
|
525 /**
|
|
526 * @brief Graylevel, signed 16bpp image.
|
|
527 *
|
|
528 * The image is graylevel. Each pixel is signed and stored in two
|
|
529 * bytes.
|
|
530 **/
|
|
531 OrthancPluginPixelFormat_SignedGrayscale16 = 3,
|
|
532
|
|
533 /**
|
|
534 * @brief Color image in RGB24 format.
|
|
535 *
|
|
536 * This format describes a color image. The pixels are stored in 3
|
|
537 * consecutive bytes. The memory layout is RGB.
|
|
538 **/
|
|
539 OrthancPluginPixelFormat_RGB24 = 4,
|
|
540
|
|
541 /**
|
|
542 * @brief Color image in RGBA32 format.
|
|
543 *
|
|
544 * This format describes a color image. The pixels are stored in 4
|
|
545 * consecutive bytes. The memory layout is RGBA.
|
|
546 **/
|
|
547 OrthancPluginPixelFormat_RGBA32 = 5,
|
|
548
|
|
549 OrthancPluginPixelFormat_Unknown = 6, /*!< Unknown pixel format */
|
|
550
|
|
551 _OrthancPluginPixelFormat_INTERNAL = 0x7fffffff
|
|
552 } OrthancPluginPixelFormat;
|
|
553
|
|
554
|
|
555
|
|
556 /**
|
|
557 * The content types that are supported by Orthanc plugins.
|
|
558 **/
|
|
559 typedef enum
|
|
560 {
|
|
561 OrthancPluginContentType_Unknown = 0, /*!< Unknown content type */
|
|
562 OrthancPluginContentType_Dicom = 1, /*!< DICOM */
|
|
563 OrthancPluginContentType_DicomAsJson = 2, /*!< JSON summary of a DICOM file */
|
|
564
|
|
565 _OrthancPluginContentType_INTERNAL = 0x7fffffff
|
|
566 } OrthancPluginContentType;
|
|
567
|
|
568
|
|
569
|
|
570 /**
|
|
571 * The supported types of DICOM resources.
|
|
572 **/
|
|
573 typedef enum
|
|
574 {
|
|
575 OrthancPluginResourceType_Patient = 0, /*!< Patient */
|
|
576 OrthancPluginResourceType_Study = 1, /*!< Study */
|
|
577 OrthancPluginResourceType_Series = 2, /*!< Series */
|
|
578 OrthancPluginResourceType_Instance = 3, /*!< Instance */
|
|
579 OrthancPluginResourceType_None = 4, /*!< Unavailable resource type */
|
|
580
|
|
581 _OrthancPluginResourceType_INTERNAL = 0x7fffffff
|
|
582 } OrthancPluginResourceType;
|
|
583
|
|
584
|
|
585
|
|
586 /**
|
|
587 * The supported types of changes that can happen to DICOM resources.
|
|
588 * @ingroup Callbacks
|
|
589 **/
|
|
590 typedef enum
|
|
591 {
|
|
592 OrthancPluginChangeType_CompletedSeries = 0, /*!< Series is now complete */
|
|
593 OrthancPluginChangeType_Deleted = 1, /*!< Deleted resource */
|
|
594 OrthancPluginChangeType_NewChildInstance = 2, /*!< A new instance was added to this resource */
|
|
595 OrthancPluginChangeType_NewInstance = 3, /*!< New instance received */
|
|
596 OrthancPluginChangeType_NewPatient = 4, /*!< New patient created */
|
|
597 OrthancPluginChangeType_NewSeries = 5, /*!< New series created */
|
|
598 OrthancPluginChangeType_NewStudy = 6, /*!< New study created */
|
|
599 OrthancPluginChangeType_StablePatient = 7, /*!< Timeout: No new instance in this patient */
|
|
600 OrthancPluginChangeType_StableSeries = 8, /*!< Timeout: No new instance in this series */
|
|
601 OrthancPluginChangeType_StableStudy = 9, /*!< Timeout: No new instance in this study */
|
|
602 OrthancPluginChangeType_OrthancStarted = 10, /*!< Orthanc has started */
|
|
603 OrthancPluginChangeType_OrthancStopped = 11, /*!< Orthanc is stopping */
|
|
604 OrthancPluginChangeType_UpdatedAttachment = 12, /*!< Some user-defined attachment has changed for this resource */
|
|
605 OrthancPluginChangeType_UpdatedMetadata = 13, /*!< Some user-defined metadata has changed for this resource */
|
|
606
|
|
607 _OrthancPluginChangeType_INTERNAL = 0x7fffffff
|
|
608 } OrthancPluginChangeType;
|
|
609
|
|
610
|
|
611 /**
|
|
612 * The compression algorithms that are supported by the Orthanc core.
|
|
613 * @ingroup Images
|
|
614 **/
|
|
615 typedef enum
|
|
616 {
|
|
617 OrthancPluginCompressionType_Zlib = 0, /*!< Standard zlib compression */
|
|
618 OrthancPluginCompressionType_ZlibWithSize = 1, /*!< zlib, prefixed with uncompressed size (uint64_t) */
|
|
619 OrthancPluginCompressionType_Gzip = 2, /*!< Standard gzip compression */
|
|
620 OrthancPluginCompressionType_GzipWithSize = 3, /*!< gzip, prefixed with uncompressed size (uint64_t) */
|
|
621
|
|
622 _OrthancPluginCompressionType_INTERNAL = 0x7fffffff
|
|
623 } OrthancPluginCompressionType;
|
|
624
|
|
625
|
|
626 /**
|
|
627 * The image formats that are supported by the Orthanc core.
|
|
628 * @ingroup Images
|
|
629 **/
|
|
630 typedef enum
|
|
631 {
|
|
632 OrthancPluginImageFormat_Png = 0, /*!< Image compressed using PNG */
|
|
633 OrthancPluginImageFormat_Jpeg = 1, /*!< Image compressed using JPEG */
|
|
634 OrthancPluginImageFormat_Dicom = 2, /*!< Image compressed using DICOM */
|
|
635
|
|
636 _OrthancPluginImageFormat_INTERNAL = 0x7fffffff
|
|
637 } OrthancPluginImageFormat;
|
|
638
|
|
639
|
|
640 /**
|
|
641 * The value representations present in the DICOM standard (version 2013).
|
|
642 * @ingroup Toolbox
|
|
643 **/
|
|
644 typedef enum
|
|
645 {
|
|
646 OrthancPluginValueRepresentation_AE = 1, /*!< Application Entity */
|
|
647 OrthancPluginValueRepresentation_AS = 2, /*!< Age String */
|
|
648 OrthancPluginValueRepresentation_AT = 3, /*!< Attribute Tag */
|
|
649 OrthancPluginValueRepresentation_CS = 4, /*!< Code String */
|
|
650 OrthancPluginValueRepresentation_DA = 5, /*!< Date */
|
|
651 OrthancPluginValueRepresentation_DS = 6, /*!< Decimal String */
|
|
652 OrthancPluginValueRepresentation_DT = 7, /*!< Date Time */
|
|
653 OrthancPluginValueRepresentation_FD = 8, /*!< Floating Point Double */
|
|
654 OrthancPluginValueRepresentation_FL = 9, /*!< Floating Point Single */
|
|
655 OrthancPluginValueRepresentation_IS = 10, /*!< Integer String */
|
|
656 OrthancPluginValueRepresentation_LO = 11, /*!< Long String */
|
|
657 OrthancPluginValueRepresentation_LT = 12, /*!< Long Text */
|
|
658 OrthancPluginValueRepresentation_OB = 13, /*!< Other Byte String */
|
|
659 OrthancPluginValueRepresentation_OF = 14, /*!< Other Float String */
|
|
660 OrthancPluginValueRepresentation_OW = 15, /*!< Other Word String */
|
|
661 OrthancPluginValueRepresentation_PN = 16, /*!< Person Name */
|
|
662 OrthancPluginValueRepresentation_SH = 17, /*!< Short String */
|
|
663 OrthancPluginValueRepresentation_SL = 18, /*!< Signed Long */
|
|
664 OrthancPluginValueRepresentation_SQ = 19, /*!< Sequence of Items */
|
|
665 OrthancPluginValueRepresentation_SS = 20, /*!< Signed Short */
|
|
666 OrthancPluginValueRepresentation_ST = 21, /*!< Short Text */
|
|
667 OrthancPluginValueRepresentation_TM = 22, /*!< Time */
|
|
668 OrthancPluginValueRepresentation_UI = 23, /*!< Unique Identifier (UID) */
|
|
669 OrthancPluginValueRepresentation_UL = 24, /*!< Unsigned Long */
|
|
670 OrthancPluginValueRepresentation_UN = 25, /*!< Unknown */
|
|
671 OrthancPluginValueRepresentation_US = 26, /*!< Unsigned Short */
|
|
672 OrthancPluginValueRepresentation_UT = 27, /*!< Unlimited Text */
|
|
673
|
|
674 _OrthancPluginValueRepresentation_INTERNAL = 0x7fffffff
|
|
675 } OrthancPluginValueRepresentation;
|
|
676
|
|
677
|
|
678 /**
|
|
679 * The possible output formats for a DICOM-to-JSON conversion.
|
|
680 * @ingroup Toolbox
|
|
681 * @see OrthancPluginDicomToJson()
|
|
682 **/
|
|
683 typedef enum
|
|
684 {
|
|
685 OrthancPluginDicomToJsonFormat_Full = 1, /*!< Full output, with most details */
|
|
686 OrthancPluginDicomToJsonFormat_Short = 2, /*!< Tags output as hexadecimal numbers */
|
|
687 OrthancPluginDicomToJsonFormat_Human = 3, /*!< Human-readable JSON */
|
|
688
|
|
689 _OrthancPluginDicomToJsonFormat_INTERNAL = 0x7fffffff
|
|
690 } OrthancPluginDicomToJsonFormat;
|
|
691
|
|
692
|
|
693 /**
|
|
694 * Flags to customize a DICOM-to-JSON conversion. By default, binary
|
|
695 * tags are formatted using Data URI scheme.
|
|
696 * @ingroup Toolbox
|
|
697 **/
|
|
698 typedef enum
|
|
699 {
|
|
700 OrthancPluginDicomToJsonFlags_IncludeBinary = (1 << 0), /*!< Include the binary tags */
|
|
701 OrthancPluginDicomToJsonFlags_IncludePrivateTags = (1 << 1), /*!< Include the private tags */
|
|
702 OrthancPluginDicomToJsonFlags_IncludeUnknownTags = (1 << 2), /*!< Include the tags unknown by the dictionary */
|
|
703 OrthancPluginDicomToJsonFlags_IncludePixelData = (1 << 3), /*!< Include the pixel data */
|
|
704 OrthancPluginDicomToJsonFlags_ConvertBinaryToAscii = (1 << 4), /*!< Output binary tags as-is, dropping non-ASCII */
|
|
705 OrthancPluginDicomToJsonFlags_ConvertBinaryToNull = (1 << 5), /*!< Signal binary tags as null values */
|
|
706
|
|
707 _OrthancPluginDicomToJsonFlags_INTERNAL = 0x7fffffff
|
|
708 } OrthancPluginDicomToJsonFlags;
|
|
709
|
|
710
|
|
711 /**
|
|
712 * Flags to the creation of a DICOM file.
|
|
713 * @ingroup Toolbox
|
|
714 * @see OrthancPluginCreateDicom()
|
|
715 **/
|
|
716 typedef enum
|
|
717 {
|
|
718 OrthancPluginCreateDicomFlags_DecodeDataUriScheme = (1 << 0), /*!< Decode fields encoded using data URI scheme */
|
|
719 OrthancPluginCreateDicomFlags_GenerateIdentifiers = (1 << 1), /*!< Automatically generate DICOM identifiers */
|
|
720
|
|
721 _OrthancPluginCreateDicomFlags_INTERNAL = 0x7fffffff
|
|
722 } OrthancPluginCreateDicomFlags;
|
|
723
|
|
724
|
|
725 /**
|
|
726 * The constraints on the DICOM identifiers that must be supported
|
|
727 * by the database plugins.
|
|
728 **/
|
|
729 typedef enum
|
|
730 {
|
|
731 OrthancPluginIdentifierConstraint_Equal = 1, /*!< Equal */
|
|
732 OrthancPluginIdentifierConstraint_SmallerOrEqual = 2, /*!< Less or equal */
|
|
733 OrthancPluginIdentifierConstraint_GreaterOrEqual = 3, /*!< More or equal */
|
|
734 OrthancPluginIdentifierConstraint_Wildcard = 4, /*!< Case-sensitive wildcard matching (with * and ?) */
|
|
735
|
|
736 _OrthancPluginIdentifierConstraint_INTERNAL = 0x7fffffff
|
|
737 } OrthancPluginIdentifierConstraint;
|
|
738
|
|
739
|
|
740 /**
|
|
741 * The origin of a DICOM instance that has been received by Orthanc.
|
|
742 **/
|
|
743 typedef enum
|
|
744 {
|
|
745 OrthancPluginInstanceOrigin_Unknown = 1, /*!< Unknown origin */
|
|
746 OrthancPluginInstanceOrigin_DicomProtocol = 2, /*!< Instance received through DICOM protocol */
|
|
747 OrthancPluginInstanceOrigin_RestApi = 3, /*!< Instance received through REST API of Orthanc */
|
|
748 OrthancPluginInstanceOrigin_Plugin = 4, /*!< Instance added to Orthanc by a plugin */
|
|
749 OrthancPluginInstanceOrigin_Lua = 5, /*!< Instance added to Orthanc by a Lua script */
|
|
750
|
|
751 _OrthancPluginInstanceOrigin_INTERNAL = 0x7fffffff
|
|
752 } OrthancPluginInstanceOrigin;
|
|
753
|
|
754
|
|
755 /**
|
|
756 * @brief A memory buffer allocated by the core system of Orthanc.
|
|
757 *
|
|
758 * A memory buffer allocated by the core system of Orthanc. When the
|
|
759 * content of the buffer is not useful anymore, it must be free by a
|
|
760 * call to ::OrthancPluginFreeMemoryBuffer().
|
|
761 **/
|
|
762 typedef struct
|
|
763 {
|
|
764 /**
|
|
765 * @brief The content of the buffer.
|
|
766 **/
|
|
767 void* data;
|
|
768
|
|
769 /**
|
|
770 * @brief The number of bytes in the buffer.
|
|
771 **/
|
|
772 uint32_t size;
|
|
773 } OrthancPluginMemoryBuffer;
|
|
774
|
|
775
|
|
776
|
|
777
|
|
778 /**
|
|
779 * @brief Opaque structure that represents the HTTP connection to the client application.
|
|
780 * @ingroup Callback
|
|
781 **/
|
|
782 typedef struct _OrthancPluginRestOutput_t OrthancPluginRestOutput;
|
|
783
|
|
784
|
|
785
|
|
786 /**
|
|
787 * @brief Opaque structure that represents a DICOM instance received by Orthanc.
|
|
788 **/
|
|
789 typedef struct _OrthancPluginDicomInstance_t OrthancPluginDicomInstance;
|
|
790
|
|
791
|
|
792
|
|
793 /**
|
|
794 * @brief Opaque structure that represents an image that is uncompressed in memory.
|
|
795 * @ingroup Images
|
|
796 **/
|
|
797 typedef struct _OrthancPluginImage_t OrthancPluginImage;
|
|
798
|
|
799
|
|
800
|
|
801 /**
|
|
802 * @brief Opaque structure that represents the storage area that is actually used by Orthanc.
|
|
803 * @ingroup Images
|
|
804 **/
|
|
805 typedef struct _OrthancPluginStorageArea_t OrthancPluginStorageArea;
|
|
806
|
|
807
|
|
808
|
|
809 /**
|
|
810 * @brief Opaque structure to an object that represents a C-Find query.
|
|
811 * @ingroup Worklists
|
|
812 **/
|
|
813 typedef struct _OrthancPluginWorklistQuery_t OrthancPluginWorklistQuery;
|
|
814
|
|
815
|
|
816
|
|
817 /**
|
|
818 * @brief Opaque structure to an object that represents the answers to a C-Find query.
|
|
819 * @ingroup Worklists
|
|
820 **/
|
|
821 typedef struct _OrthancPluginWorklistAnswers_t OrthancPluginWorklistAnswers;
|
|
822
|
|
823
|
|
824
|
|
825 /**
|
|
826 * @brief Signature of a callback function that answers to a REST request.
|
|
827 * @ingroup Callbacks
|
|
828 **/
|
|
829 typedef OrthancPluginErrorCode (*OrthancPluginRestCallback) (
|
|
830 OrthancPluginRestOutput* output,
|
|
831 const char* url,
|
|
832 const OrthancPluginHttpRequest* request);
|
|
833
|
|
834
|
|
835
|
|
836 /**
|
|
837 * @brief Signature of a callback function that is triggered when Orthanc receives a DICOM instance.
|
|
838 * @ingroup Callbacks
|
|
839 **/
|
|
840 typedef OrthancPluginErrorCode (*OrthancPluginOnStoredInstanceCallback) (
|
|
841 OrthancPluginDicomInstance* instance,
|
|
842 const char* instanceId);
|
|
843
|
|
844
|
|
845
|
|
846 /**
|
|
847 * @brief Signature of a callback function that is triggered when a change happens to some DICOM resource.
|
|
848 * @ingroup Callbacks
|
|
849 **/
|
|
850 typedef OrthancPluginErrorCode (*OrthancPluginOnChangeCallback) (
|
|
851 OrthancPluginChangeType changeType,
|
|
852 OrthancPluginResourceType resourceType,
|
|
853 const char* resourceId);
|
|
854
|
|
855
|
|
856
|
|
857 /**
|
|
858 * @brief Signature of a callback function to decode a DICOM instance as an image.
|
|
859 * @ingroup Callbacks
|
|
860 **/
|
|
861 typedef OrthancPluginErrorCode (*OrthancPluginDecodeImageCallback) (
|
|
862 OrthancPluginImage** target,
|
|
863 const void* dicom,
|
|
864 const uint32_t size,
|
|
865 uint32_t frameIndex);
|
|
866
|
|
867
|
|
868
|
|
869 /**
|
|
870 * @brief Signature of a function to free dynamic memory.
|
|
871 **/
|
|
872 typedef void (*OrthancPluginFree) (void* buffer);
|
|
873
|
|
874
|
|
875
|
|
876 /**
|
|
877 * @brief Callback for writing to the storage area.
|
|
878 *
|
|
879 * Signature of a callback function that is triggered when Orthanc writes a file to the storage area.
|
|
880 *
|
|
881 * @param uuid The UUID of the file.
|
|
882 * @param content The content of the file.
|
|
883 * @param size The size of the file.
|
|
884 * @param type The content type corresponding to this file.
|
|
885 * @return 0 if success, other value if error.
|
|
886 * @ingroup Callbacks
|
|
887 **/
|
|
888 typedef OrthancPluginErrorCode (*OrthancPluginStorageCreate) (
|
|
889 const char* uuid,
|
|
890 const void* content,
|
|
891 int64_t size,
|
|
892 OrthancPluginContentType type);
|
|
893
|
|
894
|
|
895
|
|
896 /**
|
|
897 * @brief Callback for reading from the storage area.
|
|
898 *
|
|
899 * Signature of a callback function that is triggered when Orthanc reads a file from the storage area.
|
|
900 *
|
|
901 * @param content The content of the file (output).
|
|
902 * @param size The size of the file (output).
|
|
903 * @param uuid The UUID of the file of interest.
|
|
904 * @param type The content type corresponding to this file.
|
|
905 * @return 0 if success, other value if error.
|
|
906 * @ingroup Callbacks
|
|
907 **/
|
|
908 typedef OrthancPluginErrorCode (*OrthancPluginStorageRead) (
|
|
909 void** content,
|
|
910 int64_t* size,
|
|
911 const char* uuid,
|
|
912 OrthancPluginContentType type);
|
|
913
|
|
914
|
|
915
|
|
916 /**
|
|
917 * @brief Callback for removing a file from the storage area.
|
|
918 *
|
|
919 * Signature of a callback function that is triggered when Orthanc deletes a file from the storage area.
|
|
920 *
|
|
921 * @param uuid The UUID of the file to be removed.
|
|
922 * @param type The content type corresponding to this file.
|
|
923 * @return 0 if success, other value if error.
|
|
924 * @ingroup Callbacks
|
|
925 **/
|
|
926 typedef OrthancPluginErrorCode (*OrthancPluginStorageRemove) (
|
|
927 const char* uuid,
|
|
928 OrthancPluginContentType type);
|
|
929
|
|
930
|
|
931
|
|
932 /**
|
|
933 * @brief Callback to handle the C-Find SCP requests received by Orthanc.
|
|
934 *
|
|
935 * Signature of a callback function that is triggered when Orthanc
|
|
936 * receives a C-Find SCP request against modality worklists.
|
|
937 *
|
|
938 * @param answers The target structure where answers must be stored.
|
|
939 * @param query The worklist query.
|
|
940 * @param remoteAet The Application Entity Title (AET) of the modality from which the request originates.
|
|
941 * @param calledAet The Application Entity Title (AET) of the modality that is called by the request.
|
|
942 * @return 0 if success, other value if error.
|
|
943 * @ingroup Worklists
|
|
944 **/
|
|
945 typedef OrthancPluginErrorCode (*OrthancPluginWorklistCallback) (
|
|
946 OrthancPluginWorklistAnswers* answers,
|
|
947 const OrthancPluginWorklistQuery* query,
|
|
948 const char* remoteAet,
|
|
949 const char* calledAet);
|
|
950
|
|
951
|
|
952
|
|
953 /**
|
|
954 * @brief Data structure that contains information about the Orthanc core.
|
|
955 **/
|
|
956 typedef struct _OrthancPluginContext_t
|
|
957 {
|
|
958 void* pluginsManager;
|
|
959 const char* orthancVersion;
|
|
960 OrthancPluginFree Free;
|
|
961 OrthancPluginErrorCode (*InvokeService) (struct _OrthancPluginContext_t* context,
|
|
962 _OrthancPluginService service,
|
|
963 const void* params);
|
|
964 } OrthancPluginContext;
|
|
965
|
|
966
|
|
967
|
|
968 /**
|
|
969 * @brief An entry in the dictionary of DICOM tags.
|
|
970 **/
|
|
971 typedef struct
|
|
972 {
|
|
973 uint16_t group; /*!< The group of the tag */
|
|
974 uint16_t element; /*!< The element of the tag */
|
|
975 OrthancPluginValueRepresentation vr; /*!< The value representation of the tag */
|
|
976 uint32_t minMultiplicity; /*!< The minimum multiplicity of the tag */
|
|
977 uint32_t maxMultiplicity; /*!< The maximum multiplicity of the tag (0 means arbitrary) */
|
|
978 } OrthancPluginDictionaryEntry;
|
|
979
|
|
980
|
|
981
|
|
982 /**
|
|
983 * @brief Free a string.
|
|
984 *
|
|
985 * Free a string that was allocated by the core system of Orthanc.
|
|
986 *
|
|
987 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
988 * @param str The string to be freed.
|
|
989 **/
|
|
990 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeString(
|
|
991 OrthancPluginContext* context,
|
|
992 char* str)
|
|
993 {
|
|
994 if (str != NULL)
|
|
995 {
|
|
996 context->Free(str);
|
|
997 }
|
|
998 }
|
|
999
|
|
1000
|
|
1001 /**
|
|
1002 * @brief Check the compatibility of the plugin wrt. the version of its hosting Orthanc.
|
|
1003 *
|
|
1004 * This function checks whether the version of this C header is
|
|
1005 * compatible with the current version of Orthanc. The result of
|
|
1006 * this function should always be checked in the
|
|
1007 * OrthancPluginInitialize() entry point of the plugin.
|
|
1008 *
|
|
1009 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1010 * @return 1 if and only if the versions are compatible. If the
|
|
1011 * result is 0, the initialization of the plugin should fail.
|
|
1012 * @ingroup Callbacks
|
|
1013 **/
|
|
1014 ORTHANC_PLUGIN_INLINE int OrthancPluginCheckVersion(
|
|
1015 OrthancPluginContext* context)
|
|
1016 {
|
|
1017 int major, minor, revision;
|
|
1018
|
|
1019 if (sizeof(int32_t) != sizeof(OrthancPluginErrorCode) ||
|
|
1020 sizeof(int32_t) != sizeof(OrthancPluginHttpMethod) ||
|
|
1021 sizeof(int32_t) != sizeof(_OrthancPluginService) ||
|
|
1022 sizeof(int32_t) != sizeof(_OrthancPluginProperty) ||
|
|
1023 sizeof(int32_t) != sizeof(OrthancPluginPixelFormat) ||
|
|
1024 sizeof(int32_t) != sizeof(OrthancPluginContentType) ||
|
|
1025 sizeof(int32_t) != sizeof(OrthancPluginResourceType) ||
|
|
1026 sizeof(int32_t) != sizeof(OrthancPluginChangeType) ||
|
|
1027 sizeof(int32_t) != sizeof(OrthancPluginCompressionType) ||
|
|
1028 sizeof(int32_t) != sizeof(OrthancPluginImageFormat) ||
|
|
1029 sizeof(int32_t) != sizeof(OrthancPluginValueRepresentation) ||
|
|
1030 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFormat) ||
|
|
1031 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFlags) ||
|
|
1032 sizeof(int32_t) != sizeof(OrthancPluginCreateDicomFlags) ||
|
|
1033 sizeof(int32_t) != sizeof(OrthancPluginIdentifierConstraint) ||
|
|
1034 sizeof(int32_t) != sizeof(OrthancPluginInstanceOrigin))
|
|
1035 {
|
|
1036 /* Mismatch in the size of the enumerations */
|
|
1037 return 0;
|
|
1038 }
|
|
1039
|
|
1040 /* Assume compatibility with the mainline */
|
|
1041 if (!strcmp(context->orthancVersion, "mainline"))
|
|
1042 {
|
|
1043 return 1;
|
|
1044 }
|
|
1045
|
|
1046 /* Parse the version of the Orthanc core */
|
|
1047 if (
|
|
1048 #ifdef _MSC_VER
|
|
1049 sscanf_s
|
|
1050 #else
|
|
1051 sscanf
|
|
1052 #endif
|
|
1053 (context->orthancVersion, "%4d.%4d.%4d", &major, &minor, &revision) != 3)
|
|
1054 {
|
|
1055 return 0;
|
|
1056 }
|
|
1057
|
|
1058 /* Check the major number of the version */
|
|
1059
|
|
1060 if (major > ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER)
|
|
1061 {
|
|
1062 return 1;
|
|
1063 }
|
|
1064
|
|
1065 if (major < ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER)
|
|
1066 {
|
|
1067 return 0;
|
|
1068 }
|
|
1069
|
|
1070 /* Check the minor number of the version */
|
|
1071
|
|
1072 if (minor > ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER)
|
|
1073 {
|
|
1074 return 1;
|
|
1075 }
|
|
1076
|
|
1077 if (minor < ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER)
|
|
1078 {
|
|
1079 return 0;
|
|
1080 }
|
|
1081
|
|
1082 /* Check the revision number of the version */
|
|
1083
|
|
1084 if (revision >= ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER)
|
|
1085 {
|
|
1086 return 1;
|
|
1087 }
|
|
1088 else
|
|
1089 {
|
|
1090 return 0;
|
|
1091 }
|
|
1092 }
|
|
1093
|
|
1094
|
|
1095 /**
|
|
1096 * @brief Free a memory buffer.
|
|
1097 *
|
|
1098 * Free a memory buffer that was allocated by the core system of Orthanc.
|
|
1099 *
|
|
1100 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1101 * @param buffer The memory buffer to release.
|
|
1102 **/
|
|
1103 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeMemoryBuffer(
|
|
1104 OrthancPluginContext* context,
|
|
1105 OrthancPluginMemoryBuffer* buffer)
|
|
1106 {
|
|
1107 context->Free(buffer->data);
|
|
1108 }
|
|
1109
|
|
1110
|
|
1111 /**
|
|
1112 * @brief Log an error.
|
|
1113 *
|
|
1114 * Log an error message using the Orthanc logging system.
|
|
1115 *
|
|
1116 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1117 * @param message The message to be logged.
|
|
1118 **/
|
|
1119 ORTHANC_PLUGIN_INLINE void OrthancPluginLogError(
|
|
1120 OrthancPluginContext* context,
|
|
1121 const char* message)
|
|
1122 {
|
|
1123 context->InvokeService(context, _OrthancPluginService_LogError, message);
|
|
1124 }
|
|
1125
|
|
1126
|
|
1127 /**
|
|
1128 * @brief Log a warning.
|
|
1129 *
|
|
1130 * Log a warning message using the Orthanc logging system.
|
|
1131 *
|
|
1132 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1133 * @param message The message to be logged.
|
|
1134 **/
|
|
1135 ORTHANC_PLUGIN_INLINE void OrthancPluginLogWarning(
|
|
1136 OrthancPluginContext* context,
|
|
1137 const char* message)
|
|
1138 {
|
|
1139 context->InvokeService(context, _OrthancPluginService_LogWarning, message);
|
|
1140 }
|
|
1141
|
|
1142
|
|
1143 /**
|
|
1144 * @brief Log an information.
|
|
1145 *
|
|
1146 * Log an information message using the Orthanc logging system.
|
|
1147 *
|
|
1148 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1149 * @param message The message to be logged.
|
|
1150 **/
|
|
1151 ORTHANC_PLUGIN_INLINE void OrthancPluginLogInfo(
|
|
1152 OrthancPluginContext* context,
|
|
1153 const char* message)
|
|
1154 {
|
|
1155 context->InvokeService(context, _OrthancPluginService_LogInfo, message);
|
|
1156 }
|
|
1157
|
|
1158
|
|
1159
|
|
1160 typedef struct
|
|
1161 {
|
|
1162 const char* pathRegularExpression;
|
|
1163 OrthancPluginRestCallback callback;
|
|
1164 } _OrthancPluginRestCallback;
|
|
1165
|
|
1166 /**
|
|
1167 * @brief Register a REST callback.
|
|
1168 *
|
|
1169 * This function registers a REST callback against a regular
|
|
1170 * expression for a URI. This function must be called during the
|
|
1171 * initialization of the plugin, i.e. inside the
|
|
1172 * OrthancPluginInitialize() public function.
|
|
1173 *
|
|
1174 * Each REST callback is guaranteed to run in mutual exclusion.
|
|
1175 *
|
|
1176 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1177 * @param pathRegularExpression Regular expression for the URI. May contain groups.
|
|
1178 * @param callback The callback function to handle the REST call.
|
|
1179 * @see OrthancPluginRegisterRestCallbackNoLock()
|
|
1180 * @ingroup Callbacks
|
|
1181 **/
|
|
1182 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallback(
|
|
1183 OrthancPluginContext* context,
|
|
1184 const char* pathRegularExpression,
|
|
1185 OrthancPluginRestCallback callback)
|
|
1186 {
|
|
1187 _OrthancPluginRestCallback params;
|
|
1188 params.pathRegularExpression = pathRegularExpression;
|
|
1189 params.callback = callback;
|
|
1190 context->InvokeService(context, _OrthancPluginService_RegisterRestCallback, ¶ms);
|
|
1191 }
|
|
1192
|
|
1193
|
|
1194
|
|
1195 /**
|
|
1196 * @brief Register a REST callback, without locking.
|
|
1197 *
|
|
1198 * This function registers a REST callback against a regular
|
|
1199 * expression for a URI. This function must be called during the
|
|
1200 * initialization of the plugin, i.e. inside the
|
|
1201 * OrthancPluginInitialize() public function.
|
|
1202 *
|
|
1203 * Contrarily to OrthancPluginRegisterRestCallback(), the callback
|
|
1204 * will NOT be invoked in mutual exclusion. This can be useful for
|
|
1205 * high-performance plugins that must handle concurrent requests
|
|
1206 * (Orthanc uses a pool of threads, one thread being assigned to
|
|
1207 * each incoming HTTP request). Of course, it is up to the plugin to
|
|
1208 * implement the required locking mechanisms.
|
|
1209 *
|
|
1210 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1211 * @param pathRegularExpression Regular expression for the URI. May contain groups.
|
|
1212 * @param callback The callback function to handle the REST call.
|
|
1213 * @see OrthancPluginRegisterRestCallback()
|
|
1214 * @ingroup Callbacks
|
|
1215 **/
|
|
1216 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallbackNoLock(
|
|
1217 OrthancPluginContext* context,
|
|
1218 const char* pathRegularExpression,
|
|
1219 OrthancPluginRestCallback callback)
|
|
1220 {
|
|
1221 _OrthancPluginRestCallback params;
|
|
1222 params.pathRegularExpression = pathRegularExpression;
|
|
1223 params.callback = callback;
|
|
1224 context->InvokeService(context, _OrthancPluginService_RegisterRestCallbackNoLock, ¶ms);
|
|
1225 }
|
|
1226
|
|
1227
|
|
1228
|
|
1229 typedef struct
|
|
1230 {
|
|
1231 OrthancPluginOnStoredInstanceCallback callback;
|
|
1232 } _OrthancPluginOnStoredInstanceCallback;
|
|
1233
|
|
1234 /**
|
|
1235 * @brief Register a callback for received instances.
|
|
1236 *
|
|
1237 * This function registers a callback function that is called
|
|
1238 * whenever a new DICOM instance is stored into the Orthanc core.
|
|
1239 *
|
|
1240 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1241 * @param callback The callback function.
|
|
1242 * @ingroup Callbacks
|
|
1243 **/
|
|
1244 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterOnStoredInstanceCallback(
|
|
1245 OrthancPluginContext* context,
|
|
1246 OrthancPluginOnStoredInstanceCallback callback)
|
|
1247 {
|
|
1248 _OrthancPluginOnStoredInstanceCallback params;
|
|
1249 params.callback = callback;
|
|
1250
|
|
1251 context->InvokeService(context, _OrthancPluginService_RegisterOnStoredInstanceCallback, ¶ms);
|
|
1252 }
|
|
1253
|
|
1254
|
|
1255
|
|
1256 typedef struct
|
|
1257 {
|
|
1258 OrthancPluginRestOutput* output;
|
|
1259 const char* answer;
|
|
1260 uint32_t answerSize;
|
|
1261 const char* mimeType;
|
|
1262 } _OrthancPluginAnswerBuffer;
|
|
1263
|
|
1264 /**
|
|
1265 * @brief Answer to a REST request.
|
|
1266 *
|
|
1267 * This function answers to a REST request with the content of a memory buffer.
|
|
1268 *
|
|
1269 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1270 * @param output The HTTP connection to the client application.
|
|
1271 * @param answer Pointer to the memory buffer containing the answer.
|
|
1272 * @param answerSize Number of bytes of the answer.
|
|
1273 * @param mimeType The MIME type of the answer.
|
|
1274 * @ingroup REST
|
|
1275 **/
|
|
1276 ORTHANC_PLUGIN_INLINE void OrthancPluginAnswerBuffer(
|
|
1277 OrthancPluginContext* context,
|
|
1278 OrthancPluginRestOutput* output,
|
|
1279 const char* answer,
|
|
1280 uint32_t answerSize,
|
|
1281 const char* mimeType)
|
|
1282 {
|
|
1283 _OrthancPluginAnswerBuffer params;
|
|
1284 params.output = output;
|
|
1285 params.answer = answer;
|
|
1286 params.answerSize = answerSize;
|
|
1287 params.mimeType = mimeType;
|
|
1288 context->InvokeService(context, _OrthancPluginService_AnswerBuffer, ¶ms);
|
|
1289 }
|
|
1290
|
|
1291
|
|
1292 typedef struct
|
|
1293 {
|
|
1294 OrthancPluginRestOutput* output;
|
|
1295 OrthancPluginPixelFormat format;
|
|
1296 uint32_t width;
|
|
1297 uint32_t height;
|
|
1298 uint32_t pitch;
|
|
1299 const void* buffer;
|
|
1300 } _OrthancPluginCompressAndAnswerPngImage;
|
|
1301
|
|
1302 typedef struct
|
|
1303 {
|
|
1304 OrthancPluginRestOutput* output;
|
|
1305 OrthancPluginImageFormat imageFormat;
|
|
1306 OrthancPluginPixelFormat pixelFormat;
|
|
1307 uint32_t width;
|
|
1308 uint32_t height;
|
|
1309 uint32_t pitch;
|
|
1310 const void* buffer;
|
|
1311 uint8_t quality;
|
|
1312 } _OrthancPluginCompressAndAnswerImage;
|
|
1313
|
|
1314
|
|
1315 /**
|
|
1316 * @brief Answer to a REST request with a PNG image.
|
|
1317 *
|
|
1318 * This function answers to a REST request with a PNG image. The
|
|
1319 * parameters of this function describe a memory buffer that
|
|
1320 * contains an uncompressed image. The image will be automatically compressed
|
|
1321 * as a PNG image by the core system of Orthanc.
|
|
1322 *
|
|
1323 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1324 * @param output The HTTP connection to the client application.
|
|
1325 * @param format The memory layout of the uncompressed image.
|
|
1326 * @param width The width of the image.
|
|
1327 * @param height The height of the image.
|
|
1328 * @param pitch The pitch of the image (i.e. the number of bytes
|
|
1329 * between 2 successive lines of the image in the memory buffer).
|
|
1330 * @param buffer The memory buffer containing the uncompressed image.
|
|
1331 * @ingroup REST
|
|
1332 **/
|
|
1333 ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerPngImage(
|
|
1334 OrthancPluginContext* context,
|
|
1335 OrthancPluginRestOutput* output,
|
|
1336 OrthancPluginPixelFormat format,
|
|
1337 uint32_t width,
|
|
1338 uint32_t height,
|
|
1339 uint32_t pitch,
|
|
1340 const void* buffer)
|
|
1341 {
|
|
1342 _OrthancPluginCompressAndAnswerImage params;
|
|
1343 params.output = output;
|
|
1344 params.imageFormat = OrthancPluginImageFormat_Png;
|
|
1345 params.pixelFormat = format;
|
|
1346 params.width = width;
|
|
1347 params.height = height;
|
|
1348 params.pitch = pitch;
|
|
1349 params.buffer = buffer;
|
|
1350 params.quality = 0; /* No quality for PNG */
|
|
1351 context->InvokeService(context, _OrthancPluginService_CompressAndAnswerImage, ¶ms);
|
|
1352 }
|
|
1353
|
|
1354
|
|
1355
|
|
1356 typedef struct
|
|
1357 {
|
|
1358 OrthancPluginMemoryBuffer* target;
|
|
1359 const char* instanceId;
|
|
1360 } _OrthancPluginGetDicomForInstance;
|
|
1361
|
|
1362 /**
|
|
1363 * @brief Retrieve a DICOM instance using its Orthanc identifier.
|
|
1364 *
|
|
1365 * Retrieve a DICOM instance using its Orthanc identifier. The DICOM
|
|
1366 * file is stored into a newly allocated memory buffer.
|
|
1367 *
|
|
1368 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1369 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
1370 * @param instanceId The Orthanc identifier of the DICOM instance of interest.
|
|
1371 * @return 0 if success, or the error code if failure.
|
|
1372 * @ingroup Orthanc
|
|
1373 **/
|
|
1374 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetDicomForInstance(
|
|
1375 OrthancPluginContext* context,
|
|
1376 OrthancPluginMemoryBuffer* target,
|
|
1377 const char* instanceId)
|
|
1378 {
|
|
1379 _OrthancPluginGetDicomForInstance params;
|
|
1380 params.target = target;
|
|
1381 params.instanceId = instanceId;
|
|
1382 return context->InvokeService(context, _OrthancPluginService_GetDicomForInstance, ¶ms);
|
|
1383 }
|
|
1384
|
|
1385
|
|
1386
|
|
1387 typedef struct
|
|
1388 {
|
|
1389 OrthancPluginMemoryBuffer* target;
|
|
1390 const char* uri;
|
|
1391 } _OrthancPluginRestApiGet;
|
|
1392
|
|
1393 /**
|
|
1394 * @brief Make a GET call to the built-in Orthanc REST API.
|
|
1395 *
|
|
1396 * Make a GET call to the built-in Orthanc REST API. The result to
|
|
1397 * the query is stored into a newly allocated memory buffer.
|
|
1398 *
|
|
1399 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1400 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
1401 * @param uri The URI in the built-in Orthanc API.
|
|
1402 * @return 0 if success, or the error code if failure.
|
|
1403 * @see OrthancPluginRestApiGetAfterPlugins
|
|
1404 * @ingroup Orthanc
|
|
1405 **/
|
|
1406 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGet(
|
|
1407 OrthancPluginContext* context,
|
|
1408 OrthancPluginMemoryBuffer* target,
|
|
1409 const char* uri)
|
|
1410 {
|
|
1411 _OrthancPluginRestApiGet params;
|
|
1412 params.target = target;
|
|
1413 params.uri = uri;
|
|
1414 return context->InvokeService(context, _OrthancPluginService_RestApiGet, ¶ms);
|
|
1415 }
|
|
1416
|
|
1417
|
|
1418
|
|
1419 /**
|
|
1420 * @brief Make a GET call to the REST API, as tainted by the plugins.
|
|
1421 *
|
|
1422 * Make a GET call to the Orthanc REST API, after all the plugins
|
|
1423 * are applied. In other words, if some plugin overrides or adds the
|
|
1424 * called URI to the built-in Orthanc REST API, this call will
|
|
1425 * return the result provided by this plugin. The result to the
|
|
1426 * query is stored into a newly allocated memory buffer.
|
|
1427 *
|
|
1428 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1429 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
1430 * @param uri The URI in the built-in Orthanc API.
|
|
1431 * @return 0 if success, or the error code if failure.
|
|
1432 * @see OrthancPluginRestApiGet
|
|
1433 * @ingroup Orthanc
|
|
1434 **/
|
|
1435 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGetAfterPlugins(
|
|
1436 OrthancPluginContext* context,
|
|
1437 OrthancPluginMemoryBuffer* target,
|
|
1438 const char* uri)
|
|
1439 {
|
|
1440 _OrthancPluginRestApiGet params;
|
|
1441 params.target = target;
|
|
1442 params.uri = uri;
|
|
1443 return context->InvokeService(context, _OrthancPluginService_RestApiGetAfterPlugins, ¶ms);
|
|
1444 }
|
|
1445
|
|
1446
|
|
1447
|
|
1448 typedef struct
|
|
1449 {
|
|
1450 OrthancPluginMemoryBuffer* target;
|
|
1451 const char* uri;
|
|
1452 const char* body;
|
|
1453 uint32_t bodySize;
|
|
1454 } _OrthancPluginRestApiPostPut;
|
|
1455
|
|
1456 /**
|
|
1457 * @brief Make a POST call to the built-in Orthanc REST API.
|
|
1458 *
|
|
1459 * Make a POST call to the built-in Orthanc REST API. The result to
|
|
1460 * the query is stored into a newly allocated memory buffer.
|
|
1461 *
|
|
1462 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1463 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
1464 * @param uri The URI in the built-in Orthanc API.
|
|
1465 * @param body The body of the POST request.
|
|
1466 * @param bodySize The size of the body.
|
|
1467 * @return 0 if success, or the error code if failure.
|
|
1468 * @see OrthancPluginRestApiPostAfterPlugins
|
|
1469 * @ingroup Orthanc
|
|
1470 **/
|
|
1471 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPost(
|
|
1472 OrthancPluginContext* context,
|
|
1473 OrthancPluginMemoryBuffer* target,
|
|
1474 const char* uri,
|
|
1475 const char* body,
|
|
1476 uint32_t bodySize)
|
|
1477 {
|
|
1478 _OrthancPluginRestApiPostPut params;
|
|
1479 params.target = target;
|
|
1480 params.uri = uri;
|
|
1481 params.body = body;
|
|
1482 params.bodySize = bodySize;
|
|
1483 return context->InvokeService(context, _OrthancPluginService_RestApiPost, ¶ms);
|
|
1484 }
|
|
1485
|
|
1486
|
|
1487 /**
|
|
1488 * @brief Make a POST call to the REST API, as tainted by the plugins.
|
|
1489 *
|
|
1490 * Make a POST call to the Orthanc REST API, after all the plugins
|
|
1491 * are applied. In other words, if some plugin overrides or adds the
|
|
1492 * called URI to the built-in Orthanc REST API, this call will
|
|
1493 * return the result provided by this plugin. The result to the
|
|
1494 * query is stored into a newly allocated memory buffer.
|
|
1495 *
|
|
1496 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1497 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
1498 * @param uri The URI in the built-in Orthanc API.
|
|
1499 * @param body The body of the POST request.
|
|
1500 * @param bodySize The size of the body.
|
|
1501 * @return 0 if success, or the error code if failure.
|
|
1502 * @see OrthancPluginRestApiPost
|
|
1503 * @ingroup Orthanc
|
|
1504 **/
|
|
1505 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPostAfterPlugins(
|
|
1506 OrthancPluginContext* context,
|
|
1507 OrthancPluginMemoryBuffer* target,
|
|
1508 const char* uri,
|
|
1509 const char* body,
|
|
1510 uint32_t bodySize)
|
|
1511 {
|
|
1512 _OrthancPluginRestApiPostPut params;
|
|
1513 params.target = target;
|
|
1514 params.uri = uri;
|
|
1515 params.body = body;
|
|
1516 params.bodySize = bodySize;
|
|
1517 return context->InvokeService(context, _OrthancPluginService_RestApiPostAfterPlugins, ¶ms);
|
|
1518 }
|
|
1519
|
|
1520
|
|
1521
|
|
1522 /**
|
|
1523 * @brief Make a DELETE call to the built-in Orthanc REST API.
|
|
1524 *
|
|
1525 * Make a DELETE call to the built-in Orthanc REST API.
|
|
1526 *
|
|
1527 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1528 * @param uri The URI to delete in the built-in Orthanc API.
|
|
1529 * @return 0 if success, or the error code if failure.
|
|
1530 * @see OrthancPluginRestApiDeleteAfterPlugins
|
|
1531 * @ingroup Orthanc
|
|
1532 **/
|
|
1533 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiDelete(
|
|
1534 OrthancPluginContext* context,
|
|
1535 const char* uri)
|
|
1536 {
|
|
1537 return context->InvokeService(context, _OrthancPluginService_RestApiDelete, uri);
|
|
1538 }
|
|
1539
|
|
1540
|
|
1541 /**
|
|
1542 * @brief Make a DELETE call to the REST API, as tainted by the plugins.
|
|
1543 *
|
|
1544 * Make a DELETE call to the Orthanc REST API, after all the plugins
|
|
1545 * are applied. In other words, if some plugin overrides or adds the
|
|
1546 * called URI to the built-in Orthanc REST API, this call will
|
|
1547 * return the result provided by this plugin.
|
|
1548 *
|
|
1549 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1550 * @param uri The URI to delete in the built-in Orthanc API.
|
|
1551 * @return 0 if success, or the error code if failure.
|
|
1552 * @see OrthancPluginRestApiDelete
|
|
1553 * @ingroup Orthanc
|
|
1554 **/
|
|
1555 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiDeleteAfterPlugins(
|
|
1556 OrthancPluginContext* context,
|
|
1557 const char* uri)
|
|
1558 {
|
|
1559 return context->InvokeService(context, _OrthancPluginService_RestApiDeleteAfterPlugins, uri);
|
|
1560 }
|
|
1561
|
|
1562
|
|
1563
|
|
1564 /**
|
|
1565 * @brief Make a PUT call to the built-in Orthanc REST API.
|
|
1566 *
|
|
1567 * Make a PUT call to the built-in Orthanc REST API. The result to
|
|
1568 * the query is stored into a newly allocated memory buffer.
|
|
1569 *
|
|
1570 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1571 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
1572 * @param uri The URI in the built-in Orthanc API.
|
|
1573 * @param body The body of the PUT request.
|
|
1574 * @param bodySize The size of the body.
|
|
1575 * @return 0 if success, or the error code if failure.
|
|
1576 * @see OrthancPluginRestApiPutAfterPlugins
|
|
1577 * @ingroup Orthanc
|
|
1578 **/
|
|
1579 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPut(
|
|
1580 OrthancPluginContext* context,
|
|
1581 OrthancPluginMemoryBuffer* target,
|
|
1582 const char* uri,
|
|
1583 const char* body,
|
|
1584 uint32_t bodySize)
|
|
1585 {
|
|
1586 _OrthancPluginRestApiPostPut params;
|
|
1587 params.target = target;
|
|
1588 params.uri = uri;
|
|
1589 params.body = body;
|
|
1590 params.bodySize = bodySize;
|
|
1591 return context->InvokeService(context, _OrthancPluginService_RestApiPut, ¶ms);
|
|
1592 }
|
|
1593
|
|
1594
|
|
1595
|
|
1596 /**
|
|
1597 * @brief Make a PUT call to the REST API, as tainted by the plugins.
|
|
1598 *
|
|
1599 * Make a PUT call to the Orthanc REST API, after all the plugins
|
|
1600 * are applied. In other words, if some plugin overrides or adds the
|
|
1601 * called URI to the built-in Orthanc REST API, this call will
|
|
1602 * return the result provided by this plugin. The result to the
|
|
1603 * query is stored into a newly allocated memory buffer.
|
|
1604 *
|
|
1605 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1606 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
1607 * @param uri The URI in the built-in Orthanc API.
|
|
1608 * @param body The body of the PUT request.
|
|
1609 * @param bodySize The size of the body.
|
|
1610 * @return 0 if success, or the error code if failure.
|
|
1611 * @see OrthancPluginRestApiPut
|
|
1612 * @ingroup Orthanc
|
|
1613 **/
|
|
1614 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPutAfterPlugins(
|
|
1615 OrthancPluginContext* context,
|
|
1616 OrthancPluginMemoryBuffer* target,
|
|
1617 const char* uri,
|
|
1618 const char* body,
|
|
1619 uint32_t bodySize)
|
|
1620 {
|
|
1621 _OrthancPluginRestApiPostPut params;
|
|
1622 params.target = target;
|
|
1623 params.uri = uri;
|
|
1624 params.body = body;
|
|
1625 params.bodySize = bodySize;
|
|
1626 return context->InvokeService(context, _OrthancPluginService_RestApiPutAfterPlugins, ¶ms);
|
|
1627 }
|
|
1628
|
|
1629
|
|
1630
|
|
1631 typedef struct
|
|
1632 {
|
|
1633 OrthancPluginRestOutput* output;
|
|
1634 const char* argument;
|
|
1635 } _OrthancPluginOutputPlusArgument;
|
|
1636
|
|
1637 /**
|
|
1638 * @brief Redirect a REST request.
|
|
1639 *
|
|
1640 * This function answers to a REST request by redirecting the user
|
|
1641 * to another URI using HTTP status 301.
|
|
1642 *
|
|
1643 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1644 * @param output The HTTP connection to the client application.
|
|
1645 * @param redirection Where to redirect.
|
|
1646 * @ingroup REST
|
|
1647 **/
|
|
1648 ORTHANC_PLUGIN_INLINE void OrthancPluginRedirect(
|
|
1649 OrthancPluginContext* context,
|
|
1650 OrthancPluginRestOutput* output,
|
|
1651 const char* redirection)
|
|
1652 {
|
|
1653 _OrthancPluginOutputPlusArgument params;
|
|
1654 params.output = output;
|
|
1655 params.argument = redirection;
|
|
1656 context->InvokeService(context, _OrthancPluginService_Redirect, ¶ms);
|
|
1657 }
|
|
1658
|
|
1659
|
|
1660
|
|
1661 typedef struct
|
|
1662 {
|
|
1663 char** result;
|
|
1664 const char* argument;
|
|
1665 } _OrthancPluginRetrieveDynamicString;
|
|
1666
|
|
1667 /**
|
|
1668 * @brief Look for a patient.
|
|
1669 *
|
|
1670 * Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020).
|
|
1671 * This function uses the database index to run as fast as possible (it does not loop
|
|
1672 * over all the stored patients).
|
|
1673 *
|
|
1674 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1675 * @param patientID The Patient ID of interest.
|
|
1676 * @return The NULL value if the patient is non-existent, or a string containing the
|
|
1677 * Orthanc ID of the patient. This string must be freed by OrthancPluginFreeString().
|
|
1678 * @ingroup Orthanc
|
|
1679 **/
|
|
1680 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupPatient(
|
|
1681 OrthancPluginContext* context,
|
|
1682 const char* patientID)
|
|
1683 {
|
|
1684 char* result;
|
|
1685
|
|
1686 _OrthancPluginRetrieveDynamicString params;
|
|
1687 params.result = &result;
|
|
1688 params.argument = patientID;
|
|
1689
|
|
1690 if (context->InvokeService(context, _OrthancPluginService_LookupPatient, ¶ms) != OrthancPluginErrorCode_Success)
|
|
1691 {
|
|
1692 /* Error */
|
|
1693 return NULL;
|
|
1694 }
|
|
1695 else
|
|
1696 {
|
|
1697 return result;
|
|
1698 }
|
|
1699 }
|
|
1700
|
|
1701
|
|
1702 /**
|
|
1703 * @brief Look for a study.
|
|
1704 *
|
|
1705 * Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d).
|
|
1706 * This function uses the database index to run as fast as possible (it does not loop
|
|
1707 * over all the stored studies).
|
|
1708 *
|
|
1709 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1710 * @param studyUID The Study Instance UID of interest.
|
|
1711 * @return The NULL value if the study is non-existent, or a string containing the
|
|
1712 * Orthanc ID of the study. This string must be freed by OrthancPluginFreeString().
|
|
1713 * @ingroup Orthanc
|
|
1714 **/
|
|
1715 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudy(
|
|
1716 OrthancPluginContext* context,
|
|
1717 const char* studyUID)
|
|
1718 {
|
|
1719 char* result;
|
|
1720
|
|
1721 _OrthancPluginRetrieveDynamicString params;
|
|
1722 params.result = &result;
|
|
1723 params.argument = studyUID;
|
|
1724
|
|
1725 if (context->InvokeService(context, _OrthancPluginService_LookupStudy, ¶ms) != OrthancPluginErrorCode_Success)
|
|
1726 {
|
|
1727 /* Error */
|
|
1728 return NULL;
|
|
1729 }
|
|
1730 else
|
|
1731 {
|
|
1732 return result;
|
|
1733 }
|
|
1734 }
|
|
1735
|
|
1736
|
|
1737 /**
|
|
1738 * @brief Look for a study, using the accession number.
|
|
1739 *
|
|
1740 * Look for a study stored in Orthanc, using its Accession Number tag (0x0008, 0x0050).
|
|
1741 * This function uses the database index to run as fast as possible (it does not loop
|
|
1742 * over all the stored studies).
|
|
1743 *
|
|
1744 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1745 * @param accessionNumber The Accession Number of interest.
|
|
1746 * @return The NULL value if the study is non-existent, or a string containing the
|
|
1747 * Orthanc ID of the study. This string must be freed by OrthancPluginFreeString().
|
|
1748 * @ingroup Orthanc
|
|
1749 **/
|
|
1750 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudyWithAccessionNumber(
|
|
1751 OrthancPluginContext* context,
|
|
1752 const char* accessionNumber)
|
|
1753 {
|
|
1754 char* result;
|
|
1755
|
|
1756 _OrthancPluginRetrieveDynamicString params;
|
|
1757 params.result = &result;
|
|
1758 params.argument = accessionNumber;
|
|
1759
|
|
1760 if (context->InvokeService(context, _OrthancPluginService_LookupStudyWithAccessionNumber, ¶ms) != OrthancPluginErrorCode_Success)
|
|
1761 {
|
|
1762 /* Error */
|
|
1763 return NULL;
|
|
1764 }
|
|
1765 else
|
|
1766 {
|
|
1767 return result;
|
|
1768 }
|
|
1769 }
|
|
1770
|
|
1771
|
|
1772 /**
|
|
1773 * @brief Look for a series.
|
|
1774 *
|
|
1775 * Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e).
|
|
1776 * This function uses the database index to run as fast as possible (it does not loop
|
|
1777 * over all the stored series).
|
|
1778 *
|
|
1779 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1780 * @param seriesUID The Series Instance UID of interest.
|
|
1781 * @return The NULL value if the series is non-existent, or a string containing the
|
|
1782 * Orthanc ID of the series. This string must be freed by OrthancPluginFreeString().
|
|
1783 * @ingroup Orthanc
|
|
1784 **/
|
|
1785 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupSeries(
|
|
1786 OrthancPluginContext* context,
|
|
1787 const char* seriesUID)
|
|
1788 {
|
|
1789 char* result;
|
|
1790
|
|
1791 _OrthancPluginRetrieveDynamicString params;
|
|
1792 params.result = &result;
|
|
1793 params.argument = seriesUID;
|
|
1794
|
|
1795 if (context->InvokeService(context, _OrthancPluginService_LookupSeries, ¶ms) != OrthancPluginErrorCode_Success)
|
|
1796 {
|
|
1797 /* Error */
|
|
1798 return NULL;
|
|
1799 }
|
|
1800 else
|
|
1801 {
|
|
1802 return result;
|
|
1803 }
|
|
1804 }
|
|
1805
|
|
1806
|
|
1807 /**
|
|
1808 * @brief Look for an instance.
|
|
1809 *
|
|
1810 * Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018).
|
|
1811 * This function uses the database index to run as fast as possible (it does not loop
|
|
1812 * over all the stored instances).
|
|
1813 *
|
|
1814 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1815 * @param sopInstanceUID The SOP Instance UID of interest.
|
|
1816 * @return The NULL value if the instance is non-existent, or a string containing the
|
|
1817 * Orthanc ID of the instance. This string must be freed by OrthancPluginFreeString().
|
|
1818 * @ingroup Orthanc
|
|
1819 **/
|
|
1820 ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupInstance(
|
|
1821 OrthancPluginContext* context,
|
|
1822 const char* sopInstanceUID)
|
|
1823 {
|
|
1824 char* result;
|
|
1825
|
|
1826 _OrthancPluginRetrieveDynamicString params;
|
|
1827 params.result = &result;
|
|
1828 params.argument = sopInstanceUID;
|
|
1829
|
|
1830 if (context->InvokeService(context, _OrthancPluginService_LookupInstance, ¶ms) != OrthancPluginErrorCode_Success)
|
|
1831 {
|
|
1832 /* Error */
|
|
1833 return NULL;
|
|
1834 }
|
|
1835 else
|
|
1836 {
|
|
1837 return result;
|
|
1838 }
|
|
1839 }
|
|
1840
|
|
1841
|
|
1842
|
|
1843 typedef struct
|
|
1844 {
|
|
1845 OrthancPluginRestOutput* output;
|
|
1846 uint16_t status;
|
|
1847 } _OrthancPluginSendHttpStatusCode;
|
|
1848
|
|
1849 /**
|
|
1850 * @brief Send a HTTP status code.
|
|
1851 *
|
|
1852 * This function answers to a REST request by sending a HTTP status
|
|
1853 * code (such as "400 - Bad Request"). Note that:
|
|
1854 * - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer().
|
|
1855 * - Redirections (status 301) must use ::OrthancPluginRedirect().
|
|
1856 * - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized().
|
|
1857 * - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed().
|
|
1858 *
|
|
1859 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1860 * @param output The HTTP connection to the client application.
|
|
1861 * @param status The HTTP status code to be sent.
|
|
1862 * @ingroup REST
|
|
1863 * @see OrthancPluginSendHttpStatus()
|
|
1864 **/
|
|
1865 ORTHANC_PLUGIN_INLINE void OrthancPluginSendHttpStatusCode(
|
|
1866 OrthancPluginContext* context,
|
|
1867 OrthancPluginRestOutput* output,
|
|
1868 uint16_t status)
|
|
1869 {
|
|
1870 _OrthancPluginSendHttpStatusCode params;
|
|
1871 params.output = output;
|
|
1872 params.status = status;
|
|
1873 context->InvokeService(context, _OrthancPluginService_SendHttpStatusCode, ¶ms);
|
|
1874 }
|
|
1875
|
|
1876
|
|
1877 /**
|
|
1878 * @brief Signal that a REST request is not authorized.
|
|
1879 *
|
|
1880 * This function answers to a REST request by signaling that it is
|
|
1881 * not authorized.
|
|
1882 *
|
|
1883 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1884 * @param output The HTTP connection to the client application.
|
|
1885 * @param realm The realm for the authorization process.
|
|
1886 * @ingroup REST
|
|
1887 **/
|
|
1888 ORTHANC_PLUGIN_INLINE void OrthancPluginSendUnauthorized(
|
|
1889 OrthancPluginContext* context,
|
|
1890 OrthancPluginRestOutput* output,
|
|
1891 const char* realm)
|
|
1892 {
|
|
1893 _OrthancPluginOutputPlusArgument params;
|
|
1894 params.output = output;
|
|
1895 params.argument = realm;
|
|
1896 context->InvokeService(context, _OrthancPluginService_SendUnauthorized, ¶ms);
|
|
1897 }
|
|
1898
|
|
1899
|
|
1900 /**
|
|
1901 * @brief Signal that this URI does not support this HTTP method.
|
|
1902 *
|
|
1903 * This function answers to a REST request by signaling that the
|
|
1904 * queried URI does not support this method.
|
|
1905 *
|
|
1906 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1907 * @param output The HTTP connection to the client application.
|
|
1908 * @param allowedMethods The allowed methods for this URI (e.g. "GET,POST" after a PUT or a POST request).
|
|
1909 * @ingroup REST
|
|
1910 **/
|
|
1911 ORTHANC_PLUGIN_INLINE void OrthancPluginSendMethodNotAllowed(
|
|
1912 OrthancPluginContext* context,
|
|
1913 OrthancPluginRestOutput* output,
|
|
1914 const char* allowedMethods)
|
|
1915 {
|
|
1916 _OrthancPluginOutputPlusArgument params;
|
|
1917 params.output = output;
|
|
1918 params.argument = allowedMethods;
|
|
1919 context->InvokeService(context, _OrthancPluginService_SendMethodNotAllowed, ¶ms);
|
|
1920 }
|
|
1921
|
|
1922
|
|
1923 typedef struct
|
|
1924 {
|
|
1925 OrthancPluginRestOutput* output;
|
|
1926 const char* key;
|
|
1927 const char* value;
|
|
1928 } _OrthancPluginSetHttpHeader;
|
|
1929
|
|
1930 /**
|
|
1931 * @brief Set a cookie.
|
|
1932 *
|
|
1933 * This function sets a cookie in the HTTP client.
|
|
1934 *
|
|
1935 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1936 * @param output The HTTP connection to the client application.
|
|
1937 * @param cookie The cookie to be set.
|
|
1938 * @param value The value of the cookie.
|
|
1939 * @ingroup REST
|
|
1940 **/
|
|
1941 ORTHANC_PLUGIN_INLINE void OrthancPluginSetCookie(
|
|
1942 OrthancPluginContext* context,
|
|
1943 OrthancPluginRestOutput* output,
|
|
1944 const char* cookie,
|
|
1945 const char* value)
|
|
1946 {
|
|
1947 _OrthancPluginSetHttpHeader params;
|
|
1948 params.output = output;
|
|
1949 params.key = cookie;
|
|
1950 params.value = value;
|
|
1951 context->InvokeService(context, _OrthancPluginService_SetCookie, ¶ms);
|
|
1952 }
|
|
1953
|
|
1954
|
|
1955 /**
|
|
1956 * @brief Set some HTTP header.
|
|
1957 *
|
|
1958 * This function sets a HTTP header in the HTTP answer.
|
|
1959 *
|
|
1960 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1961 * @param output The HTTP connection to the client application.
|
|
1962 * @param key The HTTP header to be set.
|
|
1963 * @param value The value of the HTTP header.
|
|
1964 * @ingroup REST
|
|
1965 **/
|
|
1966 ORTHANC_PLUGIN_INLINE void OrthancPluginSetHttpHeader(
|
|
1967 OrthancPluginContext* context,
|
|
1968 OrthancPluginRestOutput* output,
|
|
1969 const char* key,
|
|
1970 const char* value)
|
|
1971 {
|
|
1972 _OrthancPluginSetHttpHeader params;
|
|
1973 params.output = output;
|
|
1974 params.key = key;
|
|
1975 params.value = value;
|
|
1976 context->InvokeService(context, _OrthancPluginService_SetHttpHeader, ¶ms);
|
|
1977 }
|
|
1978
|
|
1979
|
|
1980 typedef struct
|
|
1981 {
|
|
1982 char** resultStringToFree;
|
|
1983 const char** resultString;
|
|
1984 int64_t* resultInt64;
|
|
1985 const char* key;
|
|
1986 OrthancPluginDicomInstance* instance;
|
|
1987 OrthancPluginInstanceOrigin* resultOrigin; /* New in Orthanc 0.9.5 SDK */
|
|
1988 } _OrthancPluginAccessDicomInstance;
|
|
1989
|
|
1990
|
|
1991 /**
|
|
1992 * @brief Get the AET of a DICOM instance.
|
|
1993 *
|
|
1994 * This function returns the Application Entity Title (AET) of the
|
|
1995 * DICOM modality from which a DICOM instance originates.
|
|
1996 *
|
|
1997 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1998 * @param instance The instance of interest.
|
|
1999 * @return The AET if success, NULL if error.
|
|
2000 * @ingroup Callbacks
|
|
2001 **/
|
|
2002 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceRemoteAet(
|
|
2003 OrthancPluginContext* context,
|
|
2004 OrthancPluginDicomInstance* instance)
|
|
2005 {
|
|
2006 const char* result;
|
|
2007
|
|
2008 _OrthancPluginAccessDicomInstance params;
|
|
2009 memset(¶ms, 0, sizeof(params));
|
|
2010 params.resultString = &result;
|
|
2011 params.instance = instance;
|
|
2012
|
|
2013 if (context->InvokeService(context, _OrthancPluginService_GetInstanceRemoteAet, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2014 {
|
|
2015 /* Error */
|
|
2016 return NULL;
|
|
2017 }
|
|
2018 else
|
|
2019 {
|
|
2020 return result;
|
|
2021 }
|
|
2022 }
|
|
2023
|
|
2024
|
|
2025 /**
|
|
2026 * @brief Get the size of a DICOM file.
|
|
2027 *
|
|
2028 * This function returns the number of bytes of the given DICOM instance.
|
|
2029 *
|
|
2030 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2031 * @param instance The instance of interest.
|
|
2032 * @return The size of the file, -1 in case of error.
|
|
2033 * @ingroup Callbacks
|
|
2034 **/
|
|
2035 ORTHANC_PLUGIN_INLINE int64_t OrthancPluginGetInstanceSize(
|
|
2036 OrthancPluginContext* context,
|
|
2037 OrthancPluginDicomInstance* instance)
|
|
2038 {
|
|
2039 int64_t size;
|
|
2040
|
|
2041 _OrthancPluginAccessDicomInstance params;
|
|
2042 memset(¶ms, 0, sizeof(params));
|
|
2043 params.resultInt64 = &size;
|
|
2044 params.instance = instance;
|
|
2045
|
|
2046 if (context->InvokeService(context, _OrthancPluginService_GetInstanceSize, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2047 {
|
|
2048 /* Error */
|
|
2049 return -1;
|
|
2050 }
|
|
2051 else
|
|
2052 {
|
|
2053 return size;
|
|
2054 }
|
|
2055 }
|
|
2056
|
|
2057
|
|
2058 /**
|
|
2059 * @brief Get the data of a DICOM file.
|
|
2060 *
|
|
2061 * This function returns a pointer to the content of the given DICOM instance.
|
|
2062 *
|
|
2063 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2064 * @param instance The instance of interest.
|
|
2065 * @return The pointer to the DICOM data, NULL in case of error.
|
|
2066 * @ingroup Callbacks
|
|
2067 **/
|
|
2068 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceData(
|
|
2069 OrthancPluginContext* context,
|
|
2070 OrthancPluginDicomInstance* instance)
|
|
2071 {
|
|
2072 const char* result;
|
|
2073
|
|
2074 _OrthancPluginAccessDicomInstance params;
|
|
2075 memset(¶ms, 0, sizeof(params));
|
|
2076 params.resultString = &result;
|
|
2077 params.instance = instance;
|
|
2078
|
|
2079 if (context->InvokeService(context, _OrthancPluginService_GetInstanceData, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2080 {
|
|
2081 /* Error */
|
|
2082 return NULL;
|
|
2083 }
|
|
2084 else
|
|
2085 {
|
|
2086 return result;
|
|
2087 }
|
|
2088 }
|
|
2089
|
|
2090
|
|
2091 /**
|
|
2092 * @brief Get the DICOM tag hierarchy as a JSON file.
|
|
2093 *
|
|
2094 * This function returns a pointer to a newly created string
|
|
2095 * containing a JSON file. This JSON file encodes the tag hierarchy
|
|
2096 * of the given DICOM instance.
|
|
2097 *
|
|
2098 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2099 * @param instance The instance of interest.
|
|
2100 * @return The NULL value in case of error, or a string containing the JSON file.
|
|
2101 * This string must be freed by OrthancPluginFreeString().
|
|
2102 * @ingroup Callbacks
|
|
2103 **/
|
|
2104 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceJson(
|
|
2105 OrthancPluginContext* context,
|
|
2106 OrthancPluginDicomInstance* instance)
|
|
2107 {
|
|
2108 char* result;
|
|
2109
|
|
2110 _OrthancPluginAccessDicomInstance params;
|
|
2111 memset(¶ms, 0, sizeof(params));
|
|
2112 params.resultStringToFree = &result;
|
|
2113 params.instance = instance;
|
|
2114
|
|
2115 if (context->InvokeService(context, _OrthancPluginService_GetInstanceJson, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2116 {
|
|
2117 /* Error */
|
|
2118 return NULL;
|
|
2119 }
|
|
2120 else
|
|
2121 {
|
|
2122 return result;
|
|
2123 }
|
|
2124 }
|
|
2125
|
|
2126
|
|
2127 /**
|
|
2128 * @brief Get the DICOM tag hierarchy as a JSON file (with simplification).
|
|
2129 *
|
|
2130 * This function returns a pointer to a newly created string
|
|
2131 * containing a JSON file. This JSON file encodes the tag hierarchy
|
|
2132 * of the given DICOM instance. In contrast with
|
|
2133 * ::OrthancPluginGetInstanceJson(), the returned JSON file is in
|
|
2134 * its simplified version.
|
|
2135 *
|
|
2136 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2137 * @param instance The instance of interest.
|
|
2138 * @return The NULL value in case of error, or a string containing the JSON file.
|
|
2139 * This string must be freed by OrthancPluginFreeString().
|
|
2140 * @ingroup Callbacks
|
|
2141 **/
|
|
2142 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceSimplifiedJson(
|
|
2143 OrthancPluginContext* context,
|
|
2144 OrthancPluginDicomInstance* instance)
|
|
2145 {
|
|
2146 char* result;
|
|
2147
|
|
2148 _OrthancPluginAccessDicomInstance params;
|
|
2149 memset(¶ms, 0, sizeof(params));
|
|
2150 params.resultStringToFree = &result;
|
|
2151 params.instance = instance;
|
|
2152
|
|
2153 if (context->InvokeService(context, _OrthancPluginService_GetInstanceSimplifiedJson, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2154 {
|
|
2155 /* Error */
|
|
2156 return NULL;
|
|
2157 }
|
|
2158 else
|
|
2159 {
|
|
2160 return result;
|
|
2161 }
|
|
2162 }
|
|
2163
|
|
2164
|
|
2165 /**
|
|
2166 * @brief Check whether a DICOM instance is associated with some metadata.
|
|
2167 *
|
|
2168 * This function checks whether the DICOM instance of interest is
|
|
2169 * associated with some metadata. As of Orthanc 0.8.1, in the
|
|
2170 * callbacks registered by
|
|
2171 * ::OrthancPluginRegisterOnStoredInstanceCallback(), the only
|
|
2172 * possibly available metadata are "ReceptionDate", "RemoteAET" and
|
|
2173 * "IndexInSeries".
|
|
2174 *
|
|
2175 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2176 * @param instance The instance of interest.
|
|
2177 * @param metadata The metadata of interest.
|
|
2178 * @return 1 if the metadata is present, 0 if it is absent, -1 in case of error.
|
|
2179 * @ingroup Callbacks
|
|
2180 **/
|
|
2181 ORTHANC_PLUGIN_INLINE int OrthancPluginHasInstanceMetadata(
|
|
2182 OrthancPluginContext* context,
|
|
2183 OrthancPluginDicomInstance* instance,
|
|
2184 const char* metadata)
|
|
2185 {
|
|
2186 int64_t result;
|
|
2187
|
|
2188 _OrthancPluginAccessDicomInstance params;
|
|
2189 memset(¶ms, 0, sizeof(params));
|
|
2190 params.resultInt64 = &result;
|
|
2191 params.instance = instance;
|
|
2192 params.key = metadata;
|
|
2193
|
|
2194 if (context->InvokeService(context, _OrthancPluginService_HasInstanceMetadata, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2195 {
|
|
2196 /* Error */
|
|
2197 return -1;
|
|
2198 }
|
|
2199 else
|
|
2200 {
|
|
2201 return (result != 0);
|
|
2202 }
|
|
2203 }
|
|
2204
|
|
2205
|
|
2206 /**
|
|
2207 * @brief Get the value of some metadata associated with a given DICOM instance.
|
|
2208 *
|
|
2209 * This functions returns the value of some metadata that is associated with the DICOM instance of interest.
|
|
2210 * Before calling this function, the existence of the metadata must have been checked with
|
|
2211 * ::OrthancPluginHasInstanceMetadata().
|
|
2212 *
|
|
2213 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2214 * @param instance The instance of interest.
|
|
2215 * @param metadata The metadata of interest.
|
|
2216 * @return The metadata value if success, NULL if error.
|
|
2217 * @ingroup Callbacks
|
|
2218 **/
|
|
2219 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceMetadata(
|
|
2220 OrthancPluginContext* context,
|
|
2221 OrthancPluginDicomInstance* instance,
|
|
2222 const char* metadata)
|
|
2223 {
|
|
2224 const char* result;
|
|
2225
|
|
2226 _OrthancPluginAccessDicomInstance params;
|
|
2227 memset(¶ms, 0, sizeof(params));
|
|
2228 params.resultString = &result;
|
|
2229 params.instance = instance;
|
|
2230 params.key = metadata;
|
|
2231
|
|
2232 if (context->InvokeService(context, _OrthancPluginService_GetInstanceMetadata, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2233 {
|
|
2234 /* Error */
|
|
2235 return NULL;
|
|
2236 }
|
|
2237 else
|
|
2238 {
|
|
2239 return result;
|
|
2240 }
|
|
2241 }
|
|
2242
|
|
2243
|
|
2244
|
|
2245 typedef struct
|
|
2246 {
|
|
2247 OrthancPluginStorageCreate create;
|
|
2248 OrthancPluginStorageRead read;
|
|
2249 OrthancPluginStorageRemove remove;
|
|
2250 OrthancPluginFree free;
|
|
2251 } _OrthancPluginRegisterStorageArea;
|
|
2252
|
|
2253 /**
|
|
2254 * @brief Register a custom storage area.
|
|
2255 *
|
|
2256 * This function registers a custom storage area, to replace the
|
|
2257 * built-in way Orthanc stores its files on the filesystem. This
|
|
2258 * function must be called during the initialization of the plugin,
|
|
2259 * i.e. inside the OrthancPluginInitialize() public function.
|
|
2260 *
|
|
2261 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2262 * @param create The callback function to store a file on the custom storage area.
|
|
2263 * @param read The callback function to read a file from the custom storage area.
|
|
2264 * @param remove The callback function to remove a file from the custom storage area.
|
|
2265 * @ingroup Callbacks
|
|
2266 **/
|
|
2267 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterStorageArea(
|
|
2268 OrthancPluginContext* context,
|
|
2269 OrthancPluginStorageCreate create,
|
|
2270 OrthancPluginStorageRead read,
|
|
2271 OrthancPluginStorageRemove remove)
|
|
2272 {
|
|
2273 _OrthancPluginRegisterStorageArea params;
|
|
2274 params.create = create;
|
|
2275 params.read = read;
|
|
2276 params.remove = remove;
|
|
2277
|
|
2278 #ifdef __cplusplus
|
|
2279 params.free = ::free;
|
|
2280 #else
|
|
2281 params.free = free;
|
|
2282 #endif
|
|
2283
|
|
2284 context->InvokeService(context, _OrthancPluginService_RegisterStorageArea, ¶ms);
|
|
2285 }
|
|
2286
|
|
2287
|
|
2288
|
|
2289 /**
|
|
2290 * @brief Return the path to the Orthanc executable.
|
|
2291 *
|
|
2292 * This function returns the path to the Orthanc executable.
|
|
2293 *
|
|
2294 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2295 * @return NULL in the case of an error, or a newly allocated string
|
|
2296 * containing the path. This string must be freed by
|
|
2297 * OrthancPluginFreeString().
|
|
2298 **/
|
|
2299 ORTHANC_PLUGIN_INLINE char *OrthancPluginGetOrthancPath(OrthancPluginContext* context)
|
|
2300 {
|
|
2301 char* result;
|
|
2302
|
|
2303 _OrthancPluginRetrieveDynamicString params;
|
|
2304 params.result = &result;
|
|
2305 params.argument = NULL;
|
|
2306
|
|
2307 if (context->InvokeService(context, _OrthancPluginService_GetOrthancPath, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2308 {
|
|
2309 /* Error */
|
|
2310 return NULL;
|
|
2311 }
|
|
2312 else
|
|
2313 {
|
|
2314 return result;
|
|
2315 }
|
|
2316 }
|
|
2317
|
|
2318
|
|
2319 /**
|
|
2320 * @brief Return the directory containing the Orthanc.
|
|
2321 *
|
|
2322 * This function returns the path to the directory containing the Orthanc executable.
|
|
2323 *
|
|
2324 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2325 * @return NULL in the case of an error, or a newly allocated string
|
|
2326 * containing the path. This string must be freed by
|
|
2327 * OrthancPluginFreeString().
|
|
2328 **/
|
|
2329 ORTHANC_PLUGIN_INLINE char *OrthancPluginGetOrthancDirectory(OrthancPluginContext* context)
|
|
2330 {
|
|
2331 char* result;
|
|
2332
|
|
2333 _OrthancPluginRetrieveDynamicString params;
|
|
2334 params.result = &result;
|
|
2335 params.argument = NULL;
|
|
2336
|
|
2337 if (context->InvokeService(context, _OrthancPluginService_GetOrthancDirectory, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2338 {
|
|
2339 /* Error */
|
|
2340 return NULL;
|
|
2341 }
|
|
2342 else
|
|
2343 {
|
|
2344 return result;
|
|
2345 }
|
|
2346 }
|
|
2347
|
|
2348
|
|
2349 /**
|
|
2350 * @brief Return the path to the configuration file(s).
|
|
2351 *
|
|
2352 * This function returns the path to the configuration file(s) that
|
|
2353 * was specified when starting Orthanc. Since version 0.9.1, this
|
|
2354 * path can refer to a folder that stores a set of configuration
|
|
2355 * files. This function is deprecated in favor of
|
|
2356 * OrthancPluginGetConfiguration().
|
|
2357 *
|
|
2358 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2359 * @return NULL in the case of an error, or a newly allocated string
|
|
2360 * containing the path. This string must be freed by
|
|
2361 * OrthancPluginFreeString().
|
|
2362 * @see OrthancPluginGetConfiguration()
|
|
2363 **/
|
|
2364 ORTHANC_PLUGIN_INLINE char *OrthancPluginGetConfigurationPath(OrthancPluginContext* context)
|
|
2365 {
|
|
2366 char* result;
|
|
2367
|
|
2368 _OrthancPluginRetrieveDynamicString params;
|
|
2369 params.result = &result;
|
|
2370 params.argument = NULL;
|
|
2371
|
|
2372 if (context->InvokeService(context, _OrthancPluginService_GetConfigurationPath, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2373 {
|
|
2374 /* Error */
|
|
2375 return NULL;
|
|
2376 }
|
|
2377 else
|
|
2378 {
|
|
2379 return result;
|
|
2380 }
|
|
2381 }
|
|
2382
|
|
2383
|
|
2384
|
|
2385 typedef struct
|
|
2386 {
|
|
2387 OrthancPluginOnChangeCallback callback;
|
|
2388 } _OrthancPluginOnChangeCallback;
|
|
2389
|
|
2390 /**
|
|
2391 * @brief Register a callback to monitor changes.
|
|
2392 *
|
|
2393 * This function registers a callback function that is called
|
|
2394 * whenever a change happens to some DICOM resource.
|
|
2395 *
|
|
2396 * @warning If your change callback has to call the REST API of
|
|
2397 * Orthanc, you should make these calls in a separate thread (with
|
|
2398 * the events passing through a message queue). Otherwise, this
|
|
2399 * could result in deadlocks in the presence of other plugins or Lua
|
|
2400 * script.
|
|
2401 *
|
|
2402 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2403 * @param callback The callback function.
|
|
2404 * @ingroup Callbacks
|
|
2405 **/
|
|
2406 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterOnChangeCallback(
|
|
2407 OrthancPluginContext* context,
|
|
2408 OrthancPluginOnChangeCallback callback)
|
|
2409 {
|
|
2410 _OrthancPluginOnChangeCallback params;
|
|
2411 params.callback = callback;
|
|
2412
|
|
2413 context->InvokeService(context, _OrthancPluginService_RegisterOnChangeCallback, ¶ms);
|
|
2414 }
|
|
2415
|
|
2416
|
|
2417
|
|
2418 typedef struct
|
|
2419 {
|
|
2420 const char* plugin;
|
|
2421 _OrthancPluginProperty property;
|
|
2422 const char* value;
|
|
2423 } _OrthancPluginSetPluginProperty;
|
|
2424
|
|
2425
|
|
2426 /**
|
|
2427 * @brief Set the URI where the plugin provides its Web interface.
|
|
2428 *
|
|
2429 * For plugins that come with a Web interface, this function
|
|
2430 * declares the entry path where to find this interface. This
|
|
2431 * information is notably used in the "Plugins" page of Orthanc
|
|
2432 * Explorer.
|
|
2433 *
|
|
2434 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2435 * @param uri The root URI for this plugin.
|
|
2436 **/
|
|
2437 ORTHANC_PLUGIN_INLINE void OrthancPluginSetRootUri(
|
|
2438 OrthancPluginContext* context,
|
|
2439 const char* uri)
|
|
2440 {
|
|
2441 _OrthancPluginSetPluginProperty params;
|
|
2442 params.plugin = OrthancPluginGetName();
|
|
2443 params.property = _OrthancPluginProperty_RootUri;
|
|
2444 params.value = uri;
|
|
2445
|
|
2446 context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms);
|
|
2447 }
|
|
2448
|
|
2449
|
|
2450 /**
|
|
2451 * @brief Set a description for this plugin.
|
|
2452 *
|
|
2453 * Set a description for this plugin. It is displayed in the
|
|
2454 * "Plugins" page of Orthanc Explorer.
|
|
2455 *
|
|
2456 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2457 * @param description The description.
|
|
2458 **/
|
|
2459 ORTHANC_PLUGIN_INLINE void OrthancPluginSetDescription(
|
|
2460 OrthancPluginContext* context,
|
|
2461 const char* description)
|
|
2462 {
|
|
2463 _OrthancPluginSetPluginProperty params;
|
|
2464 params.plugin = OrthancPluginGetName();
|
|
2465 params.property = _OrthancPluginProperty_Description;
|
|
2466 params.value = description;
|
|
2467
|
|
2468 context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms);
|
|
2469 }
|
|
2470
|
|
2471
|
|
2472 /**
|
|
2473 * @brief Extend the JavaScript code of Orthanc Explorer.
|
|
2474 *
|
|
2475 * Add JavaScript code to customize the default behavior of Orthanc
|
|
2476 * Explorer. This can for instance be used to add new buttons.
|
|
2477 *
|
|
2478 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2479 * @param javascript The custom JavaScript code.
|
|
2480 **/
|
|
2481 ORTHANC_PLUGIN_INLINE void OrthancPluginExtendOrthancExplorer(
|
|
2482 OrthancPluginContext* context,
|
|
2483 const char* javascript)
|
|
2484 {
|
|
2485 _OrthancPluginSetPluginProperty params;
|
|
2486 params.plugin = OrthancPluginGetName();
|
|
2487 params.property = _OrthancPluginProperty_OrthancExplorer;
|
|
2488 params.value = javascript;
|
|
2489
|
|
2490 context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms);
|
|
2491 }
|
|
2492
|
|
2493
|
|
2494 typedef struct
|
|
2495 {
|
|
2496 char** result;
|
|
2497 int32_t property;
|
|
2498 const char* value;
|
|
2499 } _OrthancPluginGlobalProperty;
|
|
2500
|
|
2501
|
|
2502 /**
|
|
2503 * @brief Get the value of a global property.
|
|
2504 *
|
|
2505 * Get the value of a global property that is stored in the Orthanc database. Global
|
|
2506 * properties whose index is below 1024 are reserved by Orthanc.
|
|
2507 *
|
|
2508 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2509 * @param property The global property of interest.
|
|
2510 * @param defaultValue The value to return, if the global property is unset.
|
|
2511 * @return The value of the global property, or NULL in the case of an error. This
|
|
2512 * string must be freed by OrthancPluginFreeString().
|
|
2513 * @ingroup Orthanc
|
|
2514 **/
|
|
2515 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetGlobalProperty(
|
|
2516 OrthancPluginContext* context,
|
|
2517 int32_t property,
|
|
2518 const char* defaultValue)
|
|
2519 {
|
|
2520 char* result;
|
|
2521
|
|
2522 _OrthancPluginGlobalProperty params;
|
|
2523 params.result = &result;
|
|
2524 params.property = property;
|
|
2525 params.value = defaultValue;
|
|
2526
|
|
2527 if (context->InvokeService(context, _OrthancPluginService_GetGlobalProperty, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2528 {
|
|
2529 /* Error */
|
|
2530 return NULL;
|
|
2531 }
|
|
2532 else
|
|
2533 {
|
|
2534 return result;
|
|
2535 }
|
|
2536 }
|
|
2537
|
|
2538
|
|
2539 /**
|
|
2540 * @brief Set the value of a global property.
|
|
2541 *
|
|
2542 * Set the value of a global property into the Orthanc
|
|
2543 * database. Setting a global property can be used by plugins to
|
|
2544 * save their internal parameters. Plugins are only allowed to set
|
|
2545 * properties whose index are above or equal to 1024 (properties
|
|
2546 * below 1024 are read-only and reserved by Orthanc).
|
|
2547 *
|
|
2548 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2549 * @param property The global property of interest.
|
|
2550 * @param value The value to be set in the global property.
|
|
2551 * @return 0 if success, or the error code if failure.
|
|
2552 * @ingroup Orthanc
|
|
2553 **/
|
|
2554 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSetGlobalProperty(
|
|
2555 OrthancPluginContext* context,
|
|
2556 int32_t property,
|
|
2557 const char* value)
|
|
2558 {
|
|
2559 _OrthancPluginGlobalProperty params;
|
|
2560 params.result = NULL;
|
|
2561 params.property = property;
|
|
2562 params.value = value;
|
|
2563
|
|
2564 return context->InvokeService(context, _OrthancPluginService_SetGlobalProperty, ¶ms);
|
|
2565 }
|
|
2566
|
|
2567
|
|
2568
|
|
2569 typedef struct
|
|
2570 {
|
|
2571 int32_t *resultInt32;
|
|
2572 uint32_t *resultUint32;
|
|
2573 int64_t *resultInt64;
|
|
2574 uint64_t *resultUint64;
|
|
2575 } _OrthancPluginReturnSingleValue;
|
|
2576
|
|
2577 /**
|
|
2578 * @brief Get the number of command-line arguments.
|
|
2579 *
|
|
2580 * Retrieve the number of command-line arguments that were used to launch Orthanc.
|
|
2581 *
|
|
2582 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2583 * @return The number of arguments.
|
|
2584 **/
|
|
2585 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetCommandLineArgumentsCount(
|
|
2586 OrthancPluginContext* context)
|
|
2587 {
|
|
2588 uint32_t count = 0;
|
|
2589
|
|
2590 _OrthancPluginReturnSingleValue params;
|
|
2591 memset(¶ms, 0, sizeof(params));
|
|
2592 params.resultUint32 = &count;
|
|
2593
|
|
2594 if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgumentsCount, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2595 {
|
|
2596 /* Error */
|
|
2597 return 0;
|
|
2598 }
|
|
2599 else
|
|
2600 {
|
|
2601 return count;
|
|
2602 }
|
|
2603 }
|
|
2604
|
|
2605
|
|
2606
|
|
2607 /**
|
|
2608 * @brief Get the value of a command-line argument.
|
|
2609 *
|
|
2610 * Get the value of one of the command-line arguments that were used
|
|
2611 * to launch Orthanc. The number of available arguments can be
|
|
2612 * retrieved by OrthancPluginGetCommandLineArgumentsCount().
|
|
2613 *
|
|
2614 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2615 * @param argument The index of the argument.
|
|
2616 * @return The value of the argument, or NULL in the case of an error. This
|
|
2617 * string must be freed by OrthancPluginFreeString().
|
|
2618 **/
|
|
2619 ORTHANC_PLUGIN_INLINE char* OrthancPluginGetCommandLineArgument(
|
|
2620 OrthancPluginContext* context,
|
|
2621 uint32_t argument)
|
|
2622 {
|
|
2623 char* result;
|
|
2624
|
|
2625 _OrthancPluginGlobalProperty params;
|
|
2626 params.result = &result;
|
|
2627 params.property = (int32_t) argument;
|
|
2628 params.value = NULL;
|
|
2629
|
|
2630 if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgument, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2631 {
|
|
2632 /* Error */
|
|
2633 return NULL;
|
|
2634 }
|
|
2635 else
|
|
2636 {
|
|
2637 return result;
|
|
2638 }
|
|
2639 }
|
|
2640
|
|
2641
|
|
2642 /**
|
|
2643 * @brief Get the expected version of the database schema.
|
|
2644 *
|
|
2645 * Retrieve the expected version of the database schema.
|
|
2646 *
|
|
2647 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2648 * @return The version.
|
|
2649 * @ingroup Callbacks
|
|
2650 * @deprecated Please instead use IDatabaseBackend::UpgradeDatabase()
|
|
2651 **/
|
|
2652 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetExpectedDatabaseVersion(
|
|
2653 OrthancPluginContext* context)
|
|
2654 {
|
|
2655 uint32_t count = 0;
|
|
2656
|
|
2657 _OrthancPluginReturnSingleValue params;
|
|
2658 memset(¶ms, 0, sizeof(params));
|
|
2659 params.resultUint32 = &count;
|
|
2660
|
|
2661 if (context->InvokeService(context, _OrthancPluginService_GetExpectedDatabaseVersion, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2662 {
|
|
2663 /* Error */
|
|
2664 return 0;
|
|
2665 }
|
|
2666 else
|
|
2667 {
|
|
2668 return count;
|
|
2669 }
|
|
2670 }
|
|
2671
|
|
2672
|
|
2673
|
|
2674 /**
|
|
2675 * @brief Return the content of the configuration file(s).
|
|
2676 *
|
|
2677 * This function returns the content of the configuration that is
|
|
2678 * used by Orthanc, formatted as a JSON string.
|
|
2679 *
|
|
2680 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2681 * @return NULL in the case of an error, or a newly allocated string
|
|
2682 * containing the configuration. This string must be freed by
|
|
2683 * OrthancPluginFreeString().
|
|
2684 **/
|
|
2685 ORTHANC_PLUGIN_INLINE char *OrthancPluginGetConfiguration(OrthancPluginContext* context)
|
|
2686 {
|
|
2687 char* result;
|
|
2688
|
|
2689 _OrthancPluginRetrieveDynamicString params;
|
|
2690 params.result = &result;
|
|
2691 params.argument = NULL;
|
|
2692
|
|
2693 if (context->InvokeService(context, _OrthancPluginService_GetConfiguration, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2694 {
|
|
2695 /* Error */
|
|
2696 return NULL;
|
|
2697 }
|
|
2698 else
|
|
2699 {
|
|
2700 return result;
|
|
2701 }
|
|
2702 }
|
|
2703
|
|
2704
|
|
2705
|
|
2706 typedef struct
|
|
2707 {
|
|
2708 OrthancPluginRestOutput* output;
|
|
2709 const char* subType;
|
|
2710 const char* contentType;
|
|
2711 } _OrthancPluginStartMultipartAnswer;
|
|
2712
|
|
2713 /**
|
|
2714 * @brief Start an HTTP multipart answer.
|
|
2715 *
|
|
2716 * Initiates a HTTP multipart answer, as the result of a REST request.
|
|
2717 *
|
|
2718 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2719 * @param output The HTTP connection to the client application.
|
|
2720 * @param subType The sub-type of the multipart answer ("mixed" or "related").
|
|
2721 * @param contentType The MIME type of the items in the multipart answer.
|
|
2722 * @return 0 if success, or the error code if failure.
|
|
2723 * @see OrthancPluginSendMultipartItem(), OrthancPluginSendMultipartItem2()
|
|
2724 * @ingroup REST
|
|
2725 **/
|
|
2726 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStartMultipartAnswer(
|
|
2727 OrthancPluginContext* context,
|
|
2728 OrthancPluginRestOutput* output,
|
|
2729 const char* subType,
|
|
2730 const char* contentType)
|
|
2731 {
|
|
2732 _OrthancPluginStartMultipartAnswer params;
|
|
2733 params.output = output;
|
|
2734 params.subType = subType;
|
|
2735 params.contentType = contentType;
|
|
2736 return context->InvokeService(context, _OrthancPluginService_StartMultipartAnswer, ¶ms);
|
|
2737 }
|
|
2738
|
|
2739
|
|
2740 /**
|
|
2741 * @brief Send an item as a part of some HTTP multipart answer.
|
|
2742 *
|
|
2743 * This function sends an item as a part of some HTTP multipart
|
|
2744 * answer that was initiated by OrthancPluginStartMultipartAnswer().
|
|
2745 *
|
|
2746 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2747 * @param output The HTTP connection to the client application.
|
|
2748 * @param answer Pointer to the memory buffer containing the item.
|
|
2749 * @param answerSize Number of bytes of the item.
|
|
2750 * @return 0 if success, or the error code if failure (this notably happens
|
|
2751 * if the connection is closed by the client).
|
|
2752 * @see OrthancPluginSendMultipartItem2()
|
|
2753 * @ingroup REST
|
|
2754 **/
|
|
2755 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSendMultipartItem(
|
|
2756 OrthancPluginContext* context,
|
|
2757 OrthancPluginRestOutput* output,
|
|
2758 const char* answer,
|
|
2759 uint32_t answerSize)
|
|
2760 {
|
|
2761 _OrthancPluginAnswerBuffer params;
|
|
2762 params.output = output;
|
|
2763 params.answer = answer;
|
|
2764 params.answerSize = answerSize;
|
|
2765 params.mimeType = NULL;
|
|
2766 return context->InvokeService(context, _OrthancPluginService_SendMultipartItem, ¶ms);
|
|
2767 }
|
|
2768
|
|
2769
|
|
2770
|
|
2771 typedef struct
|
|
2772 {
|
|
2773 OrthancPluginMemoryBuffer* target;
|
|
2774 const void* source;
|
|
2775 uint32_t size;
|
|
2776 OrthancPluginCompressionType compression;
|
|
2777 uint8_t uncompress;
|
|
2778 } _OrthancPluginBufferCompression;
|
|
2779
|
|
2780
|
|
2781 /**
|
|
2782 * @brief Compress or decompress a buffer.
|
|
2783 *
|
|
2784 * This function compresses or decompresses a buffer, using the
|
|
2785 * version of the zlib library that is used by the Orthanc core.
|
|
2786 *
|
|
2787 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2788 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
2789 * @param source The source buffer.
|
|
2790 * @param size The size in bytes of the source buffer.
|
|
2791 * @param compression The compression algorithm.
|
|
2792 * @param uncompress If set to "0", the buffer must be compressed.
|
|
2793 * If set to "1", the buffer must be uncompressed.
|
|
2794 * @return 0 if success, or the error code if failure.
|
|
2795 * @ingroup Images
|
|
2796 **/
|
|
2797 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginBufferCompression(
|
|
2798 OrthancPluginContext* context,
|
|
2799 OrthancPluginMemoryBuffer* target,
|
|
2800 const void* source,
|
|
2801 uint32_t size,
|
|
2802 OrthancPluginCompressionType compression,
|
|
2803 uint8_t uncompress)
|
|
2804 {
|
|
2805 _OrthancPluginBufferCompression params;
|
|
2806 params.target = target;
|
|
2807 params.source = source;
|
|
2808 params.size = size;
|
|
2809 params.compression = compression;
|
|
2810 params.uncompress = uncompress;
|
|
2811
|
|
2812 return context->InvokeService(context, _OrthancPluginService_BufferCompression, ¶ms);
|
|
2813 }
|
|
2814
|
|
2815
|
|
2816
|
|
2817 typedef struct
|
|
2818 {
|
|
2819 OrthancPluginMemoryBuffer* target;
|
|
2820 const char* path;
|
|
2821 } _OrthancPluginReadFile;
|
|
2822
|
|
2823 /**
|
|
2824 * @brief Read a file.
|
|
2825 *
|
|
2826 * Read the content of a file on the filesystem, and returns it into
|
|
2827 * a newly allocated memory buffer.
|
|
2828 *
|
|
2829 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2830 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
2831 * @param path The path of the file to be read.
|
|
2832 * @return 0 if success, or the error code if failure.
|
|
2833 **/
|
|
2834 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginReadFile(
|
|
2835 OrthancPluginContext* context,
|
|
2836 OrthancPluginMemoryBuffer* target,
|
|
2837 const char* path)
|
|
2838 {
|
|
2839 _OrthancPluginReadFile params;
|
|
2840 params.target = target;
|
|
2841 params.path = path;
|
|
2842 return context->InvokeService(context, _OrthancPluginService_ReadFile, ¶ms);
|
|
2843 }
|
|
2844
|
|
2845
|
|
2846
|
|
2847 typedef struct
|
|
2848 {
|
|
2849 const char* path;
|
|
2850 const void* data;
|
|
2851 uint32_t size;
|
|
2852 } _OrthancPluginWriteFile;
|
|
2853
|
|
2854 /**
|
|
2855 * @brief Write a file.
|
|
2856 *
|
|
2857 * Write the content of a memory buffer to the filesystem.
|
|
2858 *
|
|
2859 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2860 * @param path The path of the file to be written.
|
|
2861 * @param data The content of the memory buffer.
|
|
2862 * @param size The size of the memory buffer.
|
|
2863 * @return 0 if success, or the error code if failure.
|
|
2864 **/
|
|
2865 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWriteFile(
|
|
2866 OrthancPluginContext* context,
|
|
2867 const char* path,
|
|
2868 const void* data,
|
|
2869 uint32_t size)
|
|
2870 {
|
|
2871 _OrthancPluginWriteFile params;
|
|
2872 params.path = path;
|
|
2873 params.data = data;
|
|
2874 params.size = size;
|
|
2875 return context->InvokeService(context, _OrthancPluginService_WriteFile, ¶ms);
|
|
2876 }
|
|
2877
|
|
2878
|
|
2879
|
|
2880 typedef struct
|
|
2881 {
|
|
2882 const char** target;
|
|
2883 OrthancPluginErrorCode error;
|
|
2884 } _OrthancPluginGetErrorDescription;
|
|
2885
|
|
2886 /**
|
|
2887 * @brief Get the description of a given error code.
|
|
2888 *
|
|
2889 * This function returns the description of a given error code.
|
|
2890 *
|
|
2891 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2892 * @param error The error code of interest.
|
|
2893 * @return The error description. This is a statically-allocated
|
|
2894 * string, do not free it.
|
|
2895 **/
|
|
2896 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetErrorDescription(
|
|
2897 OrthancPluginContext* context,
|
|
2898 OrthancPluginErrorCode error)
|
|
2899 {
|
|
2900 const char* result = NULL;
|
|
2901
|
|
2902 _OrthancPluginGetErrorDescription params;
|
|
2903 params.target = &result;
|
|
2904 params.error = error;
|
|
2905
|
|
2906 if (context->InvokeService(context, _OrthancPluginService_GetErrorDescription, ¶ms) != OrthancPluginErrorCode_Success ||
|
|
2907 result == NULL)
|
|
2908 {
|
|
2909 return "Unknown error code";
|
|
2910 }
|
|
2911 else
|
|
2912 {
|
|
2913 return result;
|
|
2914 }
|
|
2915 }
|
|
2916
|
|
2917
|
|
2918
|
|
2919 typedef struct
|
|
2920 {
|
|
2921 OrthancPluginRestOutput* output;
|
|
2922 uint16_t status;
|
|
2923 const char* body;
|
|
2924 uint32_t bodySize;
|
|
2925 } _OrthancPluginSendHttpStatus;
|
|
2926
|
|
2927 /**
|
|
2928 * @brief Send a HTTP status, with a custom body.
|
|
2929 *
|
|
2930 * This function answers to a HTTP request by sending a HTTP status
|
|
2931 * code (such as "400 - Bad Request"), together with a body
|
|
2932 * describing the error. The body will only be returned if the
|
|
2933 * configuration option "HttpDescribeErrors" of Orthanc is set to "true".
|
|
2934 *
|
|
2935 * Note that:
|
|
2936 * - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer().
|
|
2937 * - Redirections (status 301) must use ::OrthancPluginRedirect().
|
|
2938 * - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized().
|
|
2939 * - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed().
|
|
2940 *
|
|
2941 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2942 * @param output The HTTP connection to the client application.
|
|
2943 * @param status The HTTP status code to be sent.
|
|
2944 * @param body The body of the answer.
|
|
2945 * @param bodySize The size of the body.
|
|
2946 * @see OrthancPluginSendHttpStatusCode()
|
|
2947 * @ingroup REST
|
|
2948 **/
|
|
2949 ORTHANC_PLUGIN_INLINE void OrthancPluginSendHttpStatus(
|
|
2950 OrthancPluginContext* context,
|
|
2951 OrthancPluginRestOutput* output,
|
|
2952 uint16_t status,
|
|
2953 const char* body,
|
|
2954 uint32_t bodySize)
|
|
2955 {
|
|
2956 _OrthancPluginSendHttpStatus params;
|
|
2957 params.output = output;
|
|
2958 params.status = status;
|
|
2959 params.body = body;
|
|
2960 params.bodySize = bodySize;
|
|
2961 context->InvokeService(context, _OrthancPluginService_SendHttpStatus, ¶ms);
|
|
2962 }
|
|
2963
|
|
2964
|
|
2965
|
|
2966 typedef struct
|
|
2967 {
|
|
2968 const OrthancPluginImage* image;
|
|
2969 uint32_t* resultUint32;
|
|
2970 OrthancPluginPixelFormat* resultPixelFormat;
|
|
2971 void** resultBuffer;
|
|
2972 } _OrthancPluginGetImageInfo;
|
|
2973
|
|
2974
|
|
2975 /**
|
|
2976 * @brief Return the pixel format of an image.
|
|
2977 *
|
|
2978 * This function returns the type of memory layout for the pixels of the given image.
|
|
2979 *
|
|
2980 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
2981 * @param image The image of interest.
|
|
2982 * @return The pixel format.
|
|
2983 * @ingroup Images
|
|
2984 **/
|
|
2985 ORTHANC_PLUGIN_INLINE OrthancPluginPixelFormat OrthancPluginGetImagePixelFormat(
|
|
2986 OrthancPluginContext* context,
|
|
2987 const OrthancPluginImage* image)
|
|
2988 {
|
|
2989 OrthancPluginPixelFormat target;
|
|
2990
|
|
2991 _OrthancPluginGetImageInfo params;
|
|
2992 memset(¶ms, 0, sizeof(params));
|
|
2993 params.image = image;
|
|
2994 params.resultPixelFormat = ⌖
|
|
2995
|
|
2996 if (context->InvokeService(context, _OrthancPluginService_GetImagePixelFormat, ¶ms) != OrthancPluginErrorCode_Success)
|
|
2997 {
|
|
2998 return OrthancPluginPixelFormat_Unknown;
|
|
2999 }
|
|
3000 else
|
|
3001 {
|
|
3002 return (OrthancPluginPixelFormat) target;
|
|
3003 }
|
|
3004 }
|
|
3005
|
|
3006
|
|
3007
|
|
3008 /**
|
|
3009 * @brief Return the width of an image.
|
|
3010 *
|
|
3011 * This function returns the width of the given image.
|
|
3012 *
|
|
3013 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3014 * @param image The image of interest.
|
|
3015 * @return The width.
|
|
3016 * @ingroup Images
|
|
3017 **/
|
|
3018 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImageWidth(
|
|
3019 OrthancPluginContext* context,
|
|
3020 const OrthancPluginImage* image)
|
|
3021 {
|
|
3022 uint32_t width;
|
|
3023
|
|
3024 _OrthancPluginGetImageInfo params;
|
|
3025 memset(¶ms, 0, sizeof(params));
|
|
3026 params.image = image;
|
|
3027 params.resultUint32 = &width;
|
|
3028
|
|
3029 if (context->InvokeService(context, _OrthancPluginService_GetImageWidth, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3030 {
|
|
3031 return 0;
|
|
3032 }
|
|
3033 else
|
|
3034 {
|
|
3035 return width;
|
|
3036 }
|
|
3037 }
|
|
3038
|
|
3039
|
|
3040
|
|
3041 /**
|
|
3042 * @brief Return the height of an image.
|
|
3043 *
|
|
3044 * This function returns the height of the given image.
|
|
3045 *
|
|
3046 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3047 * @param image The image of interest.
|
|
3048 * @return The height.
|
|
3049 * @ingroup Images
|
|
3050 **/
|
|
3051 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImageHeight(
|
|
3052 OrthancPluginContext* context,
|
|
3053 const OrthancPluginImage* image)
|
|
3054 {
|
|
3055 uint32_t height;
|
|
3056
|
|
3057 _OrthancPluginGetImageInfo params;
|
|
3058 memset(¶ms, 0, sizeof(params));
|
|
3059 params.image = image;
|
|
3060 params.resultUint32 = &height;
|
|
3061
|
|
3062 if (context->InvokeService(context, _OrthancPluginService_GetImageHeight, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3063 {
|
|
3064 return 0;
|
|
3065 }
|
|
3066 else
|
|
3067 {
|
|
3068 return height;
|
|
3069 }
|
|
3070 }
|
|
3071
|
|
3072
|
|
3073
|
|
3074 /**
|
|
3075 * @brief Return the pitch of an image.
|
|
3076 *
|
|
3077 * This function returns the pitch of the given image. The pitch is
|
|
3078 * defined as the number of bytes between 2 successive lines of the
|
|
3079 * image in the memory buffer.
|
|
3080 *
|
|
3081 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3082 * @param image The image of interest.
|
|
3083 * @return The pitch.
|
|
3084 * @ingroup Images
|
|
3085 **/
|
|
3086 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImagePitch(
|
|
3087 OrthancPluginContext* context,
|
|
3088 const OrthancPluginImage* image)
|
|
3089 {
|
|
3090 uint32_t pitch;
|
|
3091
|
|
3092 _OrthancPluginGetImageInfo params;
|
|
3093 memset(¶ms, 0, sizeof(params));
|
|
3094 params.image = image;
|
|
3095 params.resultUint32 = &pitch;
|
|
3096
|
|
3097 if (context->InvokeService(context, _OrthancPluginService_GetImagePitch, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3098 {
|
|
3099 return 0;
|
|
3100 }
|
|
3101 else
|
|
3102 {
|
|
3103 return pitch;
|
|
3104 }
|
|
3105 }
|
|
3106
|
|
3107
|
|
3108
|
|
3109 /**
|
|
3110 * @brief Return a pointer to the content of an image.
|
|
3111 *
|
|
3112 * This function returns a pointer to the memory buffer that
|
|
3113 * contains the pixels of the image.
|
|
3114 *
|
|
3115 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3116 * @param image The image of interest.
|
|
3117 * @return The pointer.
|
|
3118 * @ingroup Images
|
|
3119 **/
|
|
3120 ORTHANC_PLUGIN_INLINE void* OrthancPluginGetImageBuffer(
|
|
3121 OrthancPluginContext* context,
|
|
3122 const OrthancPluginImage* image)
|
|
3123 {
|
|
3124 void* target = NULL;
|
|
3125
|
|
3126 _OrthancPluginGetImageInfo params;
|
|
3127 memset(¶ms, 0, sizeof(params));
|
|
3128 params.resultBuffer = ⌖
|
|
3129 params.image = image;
|
|
3130
|
|
3131 if (context->InvokeService(context, _OrthancPluginService_GetImageBuffer, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3132 {
|
|
3133 return NULL;
|
|
3134 }
|
|
3135 else
|
|
3136 {
|
|
3137 return target;
|
|
3138 }
|
|
3139 }
|
|
3140
|
|
3141
|
|
3142 typedef struct
|
|
3143 {
|
|
3144 OrthancPluginImage** target;
|
|
3145 const void* data;
|
|
3146 uint32_t size;
|
|
3147 OrthancPluginImageFormat format;
|
|
3148 } _OrthancPluginUncompressImage;
|
|
3149
|
|
3150
|
|
3151 /**
|
|
3152 * @brief Decode a compressed image.
|
|
3153 *
|
|
3154 * This function decodes a compressed image from a memory buffer.
|
|
3155 *
|
|
3156 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3157 * @param data Pointer to a memory buffer containing the compressed image.
|
|
3158 * @param size Size of the memory buffer containing the compressed image.
|
|
3159 * @param format The file format of the compressed image.
|
|
3160 * @return The uncompressed image. It must be freed with OrthancPluginFreeImage().
|
|
3161 * @ingroup Images
|
|
3162 **/
|
|
3163 ORTHANC_PLUGIN_INLINE OrthancPluginImage *OrthancPluginUncompressImage(
|
|
3164 OrthancPluginContext* context,
|
|
3165 const void* data,
|
|
3166 uint32_t size,
|
|
3167 OrthancPluginImageFormat format)
|
|
3168 {
|
|
3169 OrthancPluginImage* target = NULL;
|
|
3170
|
|
3171 _OrthancPluginUncompressImage params;
|
|
3172 memset(¶ms, 0, sizeof(params));
|
|
3173 params.target = ⌖
|
|
3174 params.data = data;
|
|
3175 params.size = size;
|
|
3176 params.format = format;
|
|
3177
|
|
3178 if (context->InvokeService(context, _OrthancPluginService_UncompressImage, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3179 {
|
|
3180 return NULL;
|
|
3181 }
|
|
3182 else
|
|
3183 {
|
|
3184 return target;
|
|
3185 }
|
|
3186 }
|
|
3187
|
|
3188
|
|
3189
|
|
3190
|
|
3191 typedef struct
|
|
3192 {
|
|
3193 OrthancPluginImage* image;
|
|
3194 } _OrthancPluginFreeImage;
|
|
3195
|
|
3196 /**
|
|
3197 * @brief Free an image.
|
|
3198 *
|
|
3199 * This function frees an image that was decoded with OrthancPluginUncompressImage().
|
|
3200 *
|
|
3201 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3202 * @param image The image.
|
|
3203 * @ingroup Images
|
|
3204 **/
|
|
3205 ORTHANC_PLUGIN_INLINE void OrthancPluginFreeImage(
|
|
3206 OrthancPluginContext* context,
|
|
3207 OrthancPluginImage* image)
|
|
3208 {
|
|
3209 _OrthancPluginFreeImage params;
|
|
3210 params.image = image;
|
|
3211
|
|
3212 context->InvokeService(context, _OrthancPluginService_FreeImage, ¶ms);
|
|
3213 }
|
|
3214
|
|
3215
|
|
3216
|
|
3217
|
|
3218 typedef struct
|
|
3219 {
|
|
3220 OrthancPluginMemoryBuffer* target;
|
|
3221 OrthancPluginImageFormat imageFormat;
|
|
3222 OrthancPluginPixelFormat pixelFormat;
|
|
3223 uint32_t width;
|
|
3224 uint32_t height;
|
|
3225 uint32_t pitch;
|
|
3226 const void* buffer;
|
|
3227 uint8_t quality;
|
|
3228 } _OrthancPluginCompressImage;
|
|
3229
|
|
3230
|
|
3231 /**
|
|
3232 * @brief Encode a PNG image.
|
|
3233 *
|
|
3234 * This function compresses the given memory buffer containing an
|
|
3235 * image using the PNG specification, and stores the result of the
|
|
3236 * compression into a newly allocated memory buffer.
|
|
3237 *
|
|
3238 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3239 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
3240 * @param format The memory layout of the uncompressed image.
|
|
3241 * @param width The width of the image.
|
|
3242 * @param height The height of the image.
|
|
3243 * @param pitch The pitch of the image (i.e. the number of bytes
|
|
3244 * between 2 successive lines of the image in the memory buffer).
|
|
3245 * @param buffer The memory buffer containing the uncompressed image.
|
|
3246 * @return 0 if success, or the error code if failure.
|
|
3247 * @see OrthancPluginCompressAndAnswerPngImage()
|
|
3248 * @ingroup Images
|
|
3249 **/
|
|
3250 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCompressPngImage(
|
|
3251 OrthancPluginContext* context,
|
|
3252 OrthancPluginMemoryBuffer* target,
|
|
3253 OrthancPluginPixelFormat format,
|
|
3254 uint32_t width,
|
|
3255 uint32_t height,
|
|
3256 uint32_t pitch,
|
|
3257 const void* buffer)
|
|
3258 {
|
|
3259 _OrthancPluginCompressImage params;
|
|
3260 memset(¶ms, 0, sizeof(params));
|
|
3261 params.target = target;
|
|
3262 params.imageFormat = OrthancPluginImageFormat_Png;
|
|
3263 params.pixelFormat = format;
|
|
3264 params.width = width;
|
|
3265 params.height = height;
|
|
3266 params.pitch = pitch;
|
|
3267 params.buffer = buffer;
|
|
3268 params.quality = 0; /* Unused for PNG */
|
|
3269
|
|
3270 return context->InvokeService(context, _OrthancPluginService_CompressImage, ¶ms);
|
|
3271 }
|
|
3272
|
|
3273
|
|
3274 /**
|
|
3275 * @brief Encode a JPEG image.
|
|
3276 *
|
|
3277 * This function compresses the given memory buffer containing an
|
|
3278 * image using the JPEG specification, and stores the result of the
|
|
3279 * compression into a newly allocated memory buffer.
|
|
3280 *
|
|
3281 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3282 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
3283 * @param format The memory layout of the uncompressed image.
|
|
3284 * @param width The width of the image.
|
|
3285 * @param height The height of the image.
|
|
3286 * @param pitch The pitch of the image (i.e. the number of bytes
|
|
3287 * between 2 successive lines of the image in the memory buffer).
|
|
3288 * @param buffer The memory buffer containing the uncompressed image.
|
|
3289 * @param quality The quality of the JPEG encoding, between 1 (worst
|
|
3290 * quality, best compression) and 100 (best quality, worst
|
|
3291 * compression).
|
|
3292 * @return 0 if success, or the error code if failure.
|
|
3293 * @ingroup Images
|
|
3294 **/
|
|
3295 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCompressJpegImage(
|
|
3296 OrthancPluginContext* context,
|
|
3297 OrthancPluginMemoryBuffer* target,
|
|
3298 OrthancPluginPixelFormat format,
|
|
3299 uint32_t width,
|
|
3300 uint32_t height,
|
|
3301 uint32_t pitch,
|
|
3302 const void* buffer,
|
|
3303 uint8_t quality)
|
|
3304 {
|
|
3305 _OrthancPluginCompressImage params;
|
|
3306 memset(¶ms, 0, sizeof(params));
|
|
3307 params.target = target;
|
|
3308 params.imageFormat = OrthancPluginImageFormat_Jpeg;
|
|
3309 params.pixelFormat = format;
|
|
3310 params.width = width;
|
|
3311 params.height = height;
|
|
3312 params.pitch = pitch;
|
|
3313 params.buffer = buffer;
|
|
3314 params.quality = quality;
|
|
3315
|
|
3316 return context->InvokeService(context, _OrthancPluginService_CompressImage, ¶ms);
|
|
3317 }
|
|
3318
|
|
3319
|
|
3320
|
|
3321 /**
|
|
3322 * @brief Answer to a REST request with a JPEG image.
|
|
3323 *
|
|
3324 * This function answers to a REST request with a JPEG image. The
|
|
3325 * parameters of this function describe a memory buffer that
|
|
3326 * contains an uncompressed image. The image will be automatically compressed
|
|
3327 * as a JPEG image by the core system of Orthanc.
|
|
3328 *
|
|
3329 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3330 * @param output The HTTP connection to the client application.
|
|
3331 * @param format The memory layout of the uncompressed image.
|
|
3332 * @param width The width of the image.
|
|
3333 * @param height The height of the image.
|
|
3334 * @param pitch The pitch of the image (i.e. the number of bytes
|
|
3335 * between 2 successive lines of the image in the memory buffer).
|
|
3336 * @param buffer The memory buffer containing the uncompressed image.
|
|
3337 * @param quality The quality of the JPEG encoding, between 1 (worst
|
|
3338 * quality, best compression) and 100 (best quality, worst
|
|
3339 * compression).
|
|
3340 * @ingroup REST
|
|
3341 **/
|
|
3342 ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerJpegImage(
|
|
3343 OrthancPluginContext* context,
|
|
3344 OrthancPluginRestOutput* output,
|
|
3345 OrthancPluginPixelFormat format,
|
|
3346 uint32_t width,
|
|
3347 uint32_t height,
|
|
3348 uint32_t pitch,
|
|
3349 const void* buffer,
|
|
3350 uint8_t quality)
|
|
3351 {
|
|
3352 _OrthancPluginCompressAndAnswerImage params;
|
|
3353 params.output = output;
|
|
3354 params.imageFormat = OrthancPluginImageFormat_Jpeg;
|
|
3355 params.pixelFormat = format;
|
|
3356 params.width = width;
|
|
3357 params.height = height;
|
|
3358 params.pitch = pitch;
|
|
3359 params.buffer = buffer;
|
|
3360 params.quality = quality;
|
|
3361 context->InvokeService(context, _OrthancPluginService_CompressAndAnswerImage, ¶ms);
|
|
3362 }
|
|
3363
|
|
3364
|
|
3365
|
|
3366
|
|
3367 typedef struct
|
|
3368 {
|
|
3369 OrthancPluginMemoryBuffer* target;
|
|
3370 OrthancPluginHttpMethod method;
|
|
3371 const char* url;
|
|
3372 const char* username;
|
|
3373 const char* password;
|
|
3374 const char* body;
|
|
3375 uint32_t bodySize;
|
|
3376 } _OrthancPluginCallHttpClient;
|
|
3377
|
|
3378
|
|
3379 /**
|
|
3380 * @brief Issue a HTTP GET call.
|
|
3381 *
|
|
3382 * Make a HTTP GET call to the given URL. The result to the query is
|
|
3383 * stored into a newly allocated memory buffer. Favor
|
|
3384 * OrthancPluginRestApiGet() if calling the built-in REST API of the
|
|
3385 * Orthanc instance that hosts this plugin.
|
|
3386 *
|
|
3387 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3388 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
3389 * @param url The URL of interest.
|
|
3390 * @param username The username (can be <tt>NULL</tt> if no password protection).
|
|
3391 * @param password The password (can be <tt>NULL</tt> if no password protection).
|
|
3392 * @return 0 if success, or the error code if failure.
|
|
3393 **/
|
|
3394 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpGet(
|
|
3395 OrthancPluginContext* context,
|
|
3396 OrthancPluginMemoryBuffer* target,
|
|
3397 const char* url,
|
|
3398 const char* username,
|
|
3399 const char* password)
|
|
3400 {
|
|
3401 _OrthancPluginCallHttpClient params;
|
|
3402 memset(¶ms, 0, sizeof(params));
|
|
3403
|
|
3404 params.target = target;
|
|
3405 params.method = OrthancPluginHttpMethod_Get;
|
|
3406 params.url = url;
|
|
3407 params.username = username;
|
|
3408 params.password = password;
|
|
3409
|
|
3410 return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms);
|
|
3411 }
|
|
3412
|
|
3413
|
|
3414 /**
|
|
3415 * @brief Issue a HTTP POST call.
|
|
3416 *
|
|
3417 * Make a HTTP POST call to the given URL. The result to the query
|
|
3418 * is stored into a newly allocated memory buffer. Favor
|
|
3419 * OrthancPluginRestApiPost() if calling the built-in REST API of
|
|
3420 * the Orthanc instance that hosts this plugin.
|
|
3421 *
|
|
3422 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3423 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
3424 * @param url The URL of interest.
|
|
3425 * @param body The content of the body of the request.
|
|
3426 * @param bodySize The size of the body of the request.
|
|
3427 * @param username The username (can be <tt>NULL</tt> if no password protection).
|
|
3428 * @param password The password (can be <tt>NULL</tt> if no password protection).
|
|
3429 * @return 0 if success, or the error code if failure.
|
|
3430 **/
|
|
3431 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpPost(
|
|
3432 OrthancPluginContext* context,
|
|
3433 OrthancPluginMemoryBuffer* target,
|
|
3434 const char* url,
|
|
3435 const char* body,
|
|
3436 uint32_t bodySize,
|
|
3437 const char* username,
|
|
3438 const char* password)
|
|
3439 {
|
|
3440 _OrthancPluginCallHttpClient params;
|
|
3441 memset(¶ms, 0, sizeof(params));
|
|
3442
|
|
3443 params.target = target;
|
|
3444 params.method = OrthancPluginHttpMethod_Post;
|
|
3445 params.url = url;
|
|
3446 params.body = body;
|
|
3447 params.bodySize = bodySize;
|
|
3448 params.username = username;
|
|
3449 params.password = password;
|
|
3450
|
|
3451 return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms);
|
|
3452 }
|
|
3453
|
|
3454
|
|
3455 /**
|
|
3456 * @brief Issue a HTTP PUT call.
|
|
3457 *
|
|
3458 * Make a HTTP PUT call to the given URL. The result to the query is
|
|
3459 * stored into a newly allocated memory buffer. Favor
|
|
3460 * OrthancPluginRestApiPut() if calling the built-in REST API of the
|
|
3461 * Orthanc instance that hosts this plugin.
|
|
3462 *
|
|
3463 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3464 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
3465 * @param url The URL of interest.
|
|
3466 * @param body The content of the body of the request.
|
|
3467 * @param bodySize The size of the body of the request.
|
|
3468 * @param username The username (can be <tt>NULL</tt> if no password protection).
|
|
3469 * @param password The password (can be <tt>NULL</tt> if no password protection).
|
|
3470 * @return 0 if success, or the error code if failure.
|
|
3471 **/
|
|
3472 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpPut(
|
|
3473 OrthancPluginContext* context,
|
|
3474 OrthancPluginMemoryBuffer* target,
|
|
3475 const char* url,
|
|
3476 const char* body,
|
|
3477 uint32_t bodySize,
|
|
3478 const char* username,
|
|
3479 const char* password)
|
|
3480 {
|
|
3481 _OrthancPluginCallHttpClient params;
|
|
3482 memset(¶ms, 0, sizeof(params));
|
|
3483
|
|
3484 params.target = target;
|
|
3485 params.method = OrthancPluginHttpMethod_Put;
|
|
3486 params.url = url;
|
|
3487 params.body = body;
|
|
3488 params.bodySize = bodySize;
|
|
3489 params.username = username;
|
|
3490 params.password = password;
|
|
3491
|
|
3492 return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms);
|
|
3493 }
|
|
3494
|
|
3495
|
|
3496 /**
|
|
3497 * @brief Issue a HTTP DELETE call.
|
|
3498 *
|
|
3499 * Make a HTTP DELETE call to the given URL. Favor
|
|
3500 * OrthancPluginRestApiDelete() if calling the built-in REST API of
|
|
3501 * the Orthanc instance that hosts this plugin.
|
|
3502 *
|
|
3503 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3504 * @param url The URL of interest.
|
|
3505 * @param username The username (can be <tt>NULL</tt> if no password protection).
|
|
3506 * @param password The password (can be <tt>NULL</tt> if no password protection).
|
|
3507 * @return 0 if success, or the error code if failure.
|
|
3508 **/
|
|
3509 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpDelete(
|
|
3510 OrthancPluginContext* context,
|
|
3511 const char* url,
|
|
3512 const char* username,
|
|
3513 const char* password)
|
|
3514 {
|
|
3515 _OrthancPluginCallHttpClient params;
|
|
3516 memset(¶ms, 0, sizeof(params));
|
|
3517
|
|
3518 params.method = OrthancPluginHttpMethod_Delete;
|
|
3519 params.url = url;
|
|
3520 params.username = username;
|
|
3521 params.password = password;
|
|
3522
|
|
3523 return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms);
|
|
3524 }
|
|
3525
|
|
3526
|
|
3527
|
|
3528 typedef struct
|
|
3529 {
|
|
3530 OrthancPluginImage** target;
|
|
3531 const OrthancPluginImage* source;
|
|
3532 OrthancPluginPixelFormat targetFormat;
|
|
3533 } _OrthancPluginConvertPixelFormat;
|
|
3534
|
|
3535
|
|
3536 /**
|
|
3537 * @brief Change the pixel format of an image.
|
|
3538 *
|
|
3539 * This function creates a new image, changing the memory layout of the pixels.
|
|
3540 *
|
|
3541 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3542 * @param source The source image.
|
|
3543 * @param targetFormat The target pixel format.
|
|
3544 * @return The resulting image. It must be freed with OrthancPluginFreeImage().
|
|
3545 * @ingroup Images
|
|
3546 **/
|
|
3547 ORTHANC_PLUGIN_INLINE OrthancPluginImage *OrthancPluginConvertPixelFormat(
|
|
3548 OrthancPluginContext* context,
|
|
3549 const OrthancPluginImage* source,
|
|
3550 OrthancPluginPixelFormat targetFormat)
|
|
3551 {
|
|
3552 OrthancPluginImage* target = NULL;
|
|
3553
|
|
3554 _OrthancPluginConvertPixelFormat params;
|
|
3555 params.target = ⌖
|
|
3556 params.source = source;
|
|
3557 params.targetFormat = targetFormat;
|
|
3558
|
|
3559 if (context->InvokeService(context, _OrthancPluginService_ConvertPixelFormat, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3560 {
|
|
3561 return NULL;
|
|
3562 }
|
|
3563 else
|
|
3564 {
|
|
3565 return target;
|
|
3566 }
|
|
3567 }
|
|
3568
|
|
3569
|
|
3570
|
|
3571 /**
|
|
3572 * @brief Return the number of available fonts.
|
|
3573 *
|
|
3574 * This function returns the number of fonts that are built in the
|
|
3575 * Orthanc core. These fonts can be used to draw texts on images
|
|
3576 * through OrthancPluginDrawText().
|
|
3577 *
|
|
3578 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3579 * @return The number of fonts.
|
|
3580 * @ingroup Images
|
|
3581 **/
|
|
3582 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFontsCount(
|
|
3583 OrthancPluginContext* context)
|
|
3584 {
|
|
3585 uint32_t count = 0;
|
|
3586
|
|
3587 _OrthancPluginReturnSingleValue params;
|
|
3588 memset(¶ms, 0, sizeof(params));
|
|
3589 params.resultUint32 = &count;
|
|
3590
|
|
3591 if (context->InvokeService(context, _OrthancPluginService_GetFontsCount, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3592 {
|
|
3593 /* Error */
|
|
3594 return 0;
|
|
3595 }
|
|
3596 else
|
|
3597 {
|
|
3598 return count;
|
|
3599 }
|
|
3600 }
|
|
3601
|
|
3602
|
|
3603
|
|
3604
|
|
3605 typedef struct
|
|
3606 {
|
|
3607 uint32_t fontIndex; /* in */
|
|
3608 const char** name; /* out */
|
|
3609 uint32_t* size; /* out */
|
|
3610 } _OrthancPluginGetFontInfo;
|
|
3611
|
|
3612 /**
|
|
3613 * @brief Return the name of a font.
|
|
3614 *
|
|
3615 * This function returns the name of a font that is built in the Orthanc core.
|
|
3616 *
|
|
3617 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3618 * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount().
|
|
3619 * @return The font name. This is a statically-allocated string, do not free it.
|
|
3620 * @ingroup Images
|
|
3621 **/
|
|
3622 ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetFontName(
|
|
3623 OrthancPluginContext* context,
|
|
3624 uint32_t fontIndex)
|
|
3625 {
|
|
3626 const char* result = NULL;
|
|
3627
|
|
3628 _OrthancPluginGetFontInfo params;
|
|
3629 memset(¶ms, 0, sizeof(params));
|
|
3630 params.name = &result;
|
|
3631 params.fontIndex = fontIndex;
|
|
3632
|
|
3633 if (context->InvokeService(context, _OrthancPluginService_GetFontInfo, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3634 {
|
|
3635 return NULL;
|
|
3636 }
|
|
3637 else
|
|
3638 {
|
|
3639 return result;
|
|
3640 }
|
|
3641 }
|
|
3642
|
|
3643
|
|
3644 /**
|
|
3645 * @brief Return the size of a font.
|
|
3646 *
|
|
3647 * This function returns the size of a font that is built in the Orthanc core.
|
|
3648 *
|
|
3649 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3650 * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount().
|
|
3651 * @return The font size.
|
|
3652 * @ingroup Images
|
|
3653 **/
|
|
3654 ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFontSize(
|
|
3655 OrthancPluginContext* context,
|
|
3656 uint32_t fontIndex)
|
|
3657 {
|
|
3658 uint32_t result;
|
|
3659
|
|
3660 _OrthancPluginGetFontInfo params;
|
|
3661 memset(¶ms, 0, sizeof(params));
|
|
3662 params.size = &result;
|
|
3663 params.fontIndex = fontIndex;
|
|
3664
|
|
3665 if (context->InvokeService(context, _OrthancPluginService_GetFontInfo, ¶ms) != OrthancPluginErrorCode_Success)
|
|
3666 {
|
|
3667 return 0;
|
|
3668 }
|
|
3669 else
|
|
3670 {
|
|
3671 return result;
|
|
3672 }
|
|
3673 }
|
|
3674
|
|
3675
|
|
3676
|
|
3677 typedef struct
|
|
3678 {
|
|
3679 OrthancPluginImage* image;
|
|
3680 uint32_t fontIndex;
|
|
3681 const char* utf8Text;
|
|
3682 int32_t x;
|
|
3683 int32_t y;
|
|
3684 uint8_t r;
|
|
3685 uint8_t g;
|
|
3686 uint8_t b;
|
|
3687 } _OrthancPluginDrawText;
|
|
3688
|
|
3689
|
|
3690 /**
|
|
3691 * @brief Draw text on an image.
|
|
3692 *
|
|
3693 * This function draws some text on some image.
|
|
3694 *
|
|
3695 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3696 * @param image The image upon which to draw the text.
|
|
3697 * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount().
|
|
3698 * @param utf8Text The text to be drawn, encoded as an UTF-8 zero-terminated string.
|
|
3699 * @param x The X position of the text over the image.
|
|
3700 * @param y The Y position of the text over the image.
|
|
3701 * @param r The value of the red color channel of the text.
|
|
3702 * @param g The value of the green color channel of the text.
|
|
3703 * @param b The value of the blue color channel of the text.
|
|
3704 * @return 0 if success, other value if error.
|
|
3705 * @ingroup Images
|
|
3706 **/
|
|
3707 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginDrawText(
|
|
3708 OrthancPluginContext* context,
|
|
3709 OrthancPluginImage* image,
|
|
3710 uint32_t fontIndex,
|
|
3711 const char* utf8Text,
|
|
3712 int32_t x,
|
|
3713 int32_t y,
|
|
3714 uint8_t r,
|
|
3715 uint8_t g,
|
|
3716 uint8_t b)
|
|
3717 {
|
|
3718 _OrthancPluginDrawText params;
|
|
3719 memset(¶ms, 0, sizeof(params));
|
|
3720 params.image = image;
|
|
3721 params.fontIndex = fontIndex;
|
|
3722 params.utf8Text = utf8Text;
|
|
3723 params.x = x;
|
|
3724 params.y = y;
|
|
3725 params.r = r;
|
|
3726 params.g = g;
|
|
3727 params.b = b;
|
|
3728
|
|
3729 return context->InvokeService(context, _OrthancPluginService_DrawText, ¶ms);
|
|
3730 }
|
|
3731
|
|
3732
|
|
3733
|
|
3734 typedef struct
|
|
3735 {
|
|
3736 OrthancPluginStorageArea* storageArea;
|
|
3737 const char* uuid;
|
|
3738 const void* content;
|
|
3739 uint64_t size;
|
|
3740 OrthancPluginContentType type;
|
|
3741 } _OrthancPluginStorageAreaCreate;
|
|
3742
|
|
3743
|
|
3744 /**
|
|
3745 * @brief Create a file inside the storage area.
|
|
3746 *
|
|
3747 * This function creates a new file inside the storage area that is
|
|
3748 * currently used by Orthanc.
|
|
3749 *
|
|
3750 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3751 * @param storageArea The storage area.
|
|
3752 * @param uuid The identifier of the file to be created.
|
|
3753 * @param content The content to store in the newly created file.
|
|
3754 * @param size The size of the content.
|
|
3755 * @param type The type of the file content.
|
|
3756 * @return 0 if success, other value if error.
|
|
3757 * @ingroup Callbacks
|
|
3758 **/
|
|
3759 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaCreate(
|
|
3760 OrthancPluginContext* context,
|
|
3761 OrthancPluginStorageArea* storageArea,
|
|
3762 const char* uuid,
|
|
3763 const void* content,
|
|
3764 uint64_t size,
|
|
3765 OrthancPluginContentType type)
|
|
3766 {
|
|
3767 _OrthancPluginStorageAreaCreate params;
|
|
3768 params.storageArea = storageArea;
|
|
3769 params.uuid = uuid;
|
|
3770 params.content = content;
|
|
3771 params.size = size;
|
|
3772 params.type = type;
|
|
3773
|
|
3774 return context->InvokeService(context, _OrthancPluginService_StorageAreaCreate, ¶ms);
|
|
3775 }
|
|
3776
|
|
3777
|
|
3778 typedef struct
|
|
3779 {
|
|
3780 OrthancPluginMemoryBuffer* target;
|
|
3781 OrthancPluginStorageArea* storageArea;
|
|
3782 const char* uuid;
|
|
3783 OrthancPluginContentType type;
|
|
3784 } _OrthancPluginStorageAreaRead;
|
|
3785
|
|
3786
|
|
3787 /**
|
|
3788 * @brief Read a file from the storage area.
|
|
3789 *
|
|
3790 * This function reads the content of a given file from the storage
|
|
3791 * area that is currently used by Orthanc.
|
|
3792 *
|
|
3793 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3794 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
3795 * @param storageArea The storage area.
|
|
3796 * @param uuid The identifier of the file to be read.
|
|
3797 * @param type The type of the file content.
|
|
3798 * @return 0 if success, other value if error.
|
|
3799 * @ingroup Callbacks
|
|
3800 **/
|
|
3801 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaRead(
|
|
3802 OrthancPluginContext* context,
|
|
3803 OrthancPluginMemoryBuffer* target,
|
|
3804 OrthancPluginStorageArea* storageArea,
|
|
3805 const char* uuid,
|
|
3806 OrthancPluginContentType type)
|
|
3807 {
|
|
3808 _OrthancPluginStorageAreaRead params;
|
|
3809 params.target = target;
|
|
3810 params.storageArea = storageArea;
|
|
3811 params.uuid = uuid;
|
|
3812 params.type = type;
|
|
3813
|
|
3814 return context->InvokeService(context, _OrthancPluginService_StorageAreaRead, ¶ms);
|
|
3815 }
|
|
3816
|
|
3817
|
|
3818 typedef struct
|
|
3819 {
|
|
3820 OrthancPluginStorageArea* storageArea;
|
|
3821 const char* uuid;
|
|
3822 OrthancPluginContentType type;
|
|
3823 } _OrthancPluginStorageAreaRemove;
|
|
3824
|
|
3825 /**
|
|
3826 * @brief Remove a file from the storage area.
|
|
3827 *
|
|
3828 * This function removes a given file from the storage area that is
|
|
3829 * currently used by Orthanc.
|
|
3830 *
|
|
3831 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3832 * @param storageArea The storage area.
|
|
3833 * @param uuid The identifier of the file to be removed.
|
|
3834 * @param type The type of the file content.
|
|
3835 * @return 0 if success, other value if error.
|
|
3836 * @ingroup Callbacks
|
|
3837 **/
|
|
3838 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaRemove(
|
|
3839 OrthancPluginContext* context,
|
|
3840 OrthancPluginStorageArea* storageArea,
|
|
3841 const char* uuid,
|
|
3842 OrthancPluginContentType type)
|
|
3843 {
|
|
3844 _OrthancPluginStorageAreaRemove params;
|
|
3845 params.storageArea = storageArea;
|
|
3846 params.uuid = uuid;
|
|
3847 params.type = type;
|
|
3848
|
|
3849 return context->InvokeService(context, _OrthancPluginService_StorageAreaRemove, ¶ms);
|
|
3850 }
|
|
3851
|
|
3852
|
|
3853
|
|
3854 typedef struct
|
|
3855 {
|
|
3856 OrthancPluginErrorCode* target;
|
|
3857 int32_t code;
|
|
3858 uint16_t httpStatus;
|
|
3859 const char* message;
|
|
3860 } _OrthancPluginRegisterErrorCode;
|
|
3861
|
|
3862 /**
|
|
3863 * @brief Declare a custom error code for this plugin.
|
|
3864 *
|
|
3865 * This function declares a custom error code that can be generated
|
|
3866 * by this plugin. This declaration is used to enrich the body of
|
|
3867 * the HTTP answer in the case of an error, and to set the proper
|
|
3868 * HTTP status code.
|
|
3869 *
|
|
3870 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3871 * @param code The error code that is internal to this plugin.
|
|
3872 * @param httpStatus The HTTP status corresponding to this error.
|
|
3873 * @param message The description of the error.
|
|
3874 * @return The error code that has been assigned inside the Orthanc core.
|
|
3875 * @ingroup Toolbox
|
|
3876 **/
|
|
3877 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterErrorCode(
|
|
3878 OrthancPluginContext* context,
|
|
3879 int32_t code,
|
|
3880 uint16_t httpStatus,
|
|
3881 const char* message)
|
|
3882 {
|
|
3883 OrthancPluginErrorCode target;
|
|
3884
|
|
3885 _OrthancPluginRegisterErrorCode params;
|
|
3886 params.target = ⌖
|
|
3887 params.code = code;
|
|
3888 params.httpStatus = httpStatus;
|
|
3889 params.message = message;
|
|
3890
|
|
3891 if (context->InvokeService(context, _OrthancPluginService_RegisterErrorCode, ¶ms) == OrthancPluginErrorCode_Success)
|
|
3892 {
|
|
3893 return target;
|
|
3894 }
|
|
3895 else
|
|
3896 {
|
|
3897 /* There was an error while assigned the error. Use a generic code. */
|
|
3898 return OrthancPluginErrorCode_Plugin;
|
|
3899 }
|
|
3900 }
|
|
3901
|
|
3902
|
|
3903
|
|
3904 typedef struct
|
|
3905 {
|
|
3906 uint16_t group;
|
|
3907 uint16_t element;
|
|
3908 OrthancPluginValueRepresentation vr;
|
|
3909 const char* name;
|
|
3910 uint32_t minMultiplicity;
|
|
3911 uint32_t maxMultiplicity;
|
|
3912 } _OrthancPluginRegisterDictionaryTag;
|
|
3913
|
|
3914 /**
|
|
3915 * @brief Register a new tag into the DICOM dictionary.
|
|
3916 *
|
|
3917 * This function declares a new tag in the dictionary of DICOM tags
|
|
3918 * that are known to Orthanc. This function should be used in the
|
|
3919 * OrthancPluginInitialize() callback.
|
|
3920 *
|
|
3921 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3922 * @param group The group of the tag.
|
|
3923 * @param element The element of the tag.
|
|
3924 * @param vr The value representation of the tag.
|
|
3925 * @param name The nickname of the tag.
|
|
3926 * @param minMultiplicity The minimum multiplicity of the tag (must be above 0).
|
|
3927 * @param maxMultiplicity The maximum multiplicity of the tag. A value of 0 means
|
|
3928 * an arbitrary multiplicity ("<tt>n</tt>").
|
|
3929 * @return 0 if success, other value if error.
|
|
3930 * @ingroup Toolbox
|
|
3931 **/
|
|
3932 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDictionaryTag(
|
|
3933 OrthancPluginContext* context,
|
|
3934 uint16_t group,
|
|
3935 uint16_t element,
|
|
3936 OrthancPluginValueRepresentation vr,
|
|
3937 const char* name,
|
|
3938 uint32_t minMultiplicity,
|
|
3939 uint32_t maxMultiplicity)
|
|
3940 {
|
|
3941 _OrthancPluginRegisterDictionaryTag params;
|
|
3942 params.group = group;
|
|
3943 params.element = element;
|
|
3944 params.vr = vr;
|
|
3945 params.name = name;
|
|
3946 params.minMultiplicity = minMultiplicity;
|
|
3947 params.maxMultiplicity = maxMultiplicity;
|
|
3948
|
|
3949 return context->InvokeService(context, _OrthancPluginService_RegisterDictionaryTag, ¶ms);
|
|
3950 }
|
|
3951
|
|
3952
|
|
3953
|
|
3954
|
|
3955 typedef struct
|
|
3956 {
|
|
3957 OrthancPluginStorageArea* storageArea;
|
|
3958 OrthancPluginResourceType level;
|
|
3959 } _OrthancPluginReconstructMainDicomTags;
|
|
3960
|
|
3961 /**
|
|
3962 * @brief Reconstruct the main DICOM tags.
|
|
3963 *
|
|
3964 * This function requests the Orthanc core to reconstruct the main
|
|
3965 * DICOM tags of all the resources of the given type. This function
|
|
3966 * can only be used as a part of the upgrade of a custom database
|
|
3967 * back-end
|
|
3968 * (cf. OrthancPlugins::IDatabaseBackend::UpgradeDatabase). A
|
|
3969 * database transaction will be automatically setup.
|
|
3970 *
|
|
3971 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
3972 * @param storageArea The storage area.
|
|
3973 * @param level The type of the resources of interest.
|
|
3974 * @return 0 if success, other value if error.
|
|
3975 * @ingroup Callbacks
|
|
3976 **/
|
|
3977 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginReconstructMainDicomTags(
|
|
3978 OrthancPluginContext* context,
|
|
3979 OrthancPluginStorageArea* storageArea,
|
|
3980 OrthancPluginResourceType level)
|
|
3981 {
|
|
3982 _OrthancPluginReconstructMainDicomTags params;
|
|
3983 params.level = level;
|
|
3984 params.storageArea = storageArea;
|
|
3985
|
|
3986 return context->InvokeService(context, _OrthancPluginService_ReconstructMainDicomTags, ¶ms);
|
|
3987 }
|
|
3988
|
|
3989
|
|
3990 typedef struct
|
|
3991 {
|
|
3992 char** result;
|
|
3993 const char* instanceId;
|
|
3994 const char* buffer;
|
|
3995 uint32_t size;
|
|
3996 OrthancPluginDicomToJsonFormat format;
|
|
3997 OrthancPluginDicomToJsonFlags flags;
|
|
3998 uint32_t maxStringLength;
|
|
3999 } _OrthancPluginDicomToJson;
|
|
4000
|
|
4001
|
|
4002 /**
|
|
4003 * @brief Format a DICOM memory buffer as a JSON string.
|
|
4004 *
|
|
4005 * This function takes as input a memory buffer containing a DICOM
|
|
4006 * file, and outputs a JSON string representing the tags of this
|
|
4007 * DICOM file.
|
|
4008 *
|
|
4009 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4010 * @param buffer The memory buffer containing the DICOM file.
|
|
4011 * @param size The size of the memory buffer.
|
|
4012 * @param format The output format.
|
|
4013 * @param flags Flags governing the output.
|
|
4014 * @param maxStringLength The maximum length of a field. Too long fields will
|
|
4015 * be output as "null". The 0 value means no maximum length.
|
|
4016 * @return The NULL value if the case of an error, or the JSON
|
|
4017 * string. This string must be freed by OrthancPluginFreeString().
|
|
4018 * @ingroup Toolbox
|
|
4019 * @see OrthancPluginDicomInstanceToJson
|
|
4020 **/
|
|
4021 ORTHANC_PLUGIN_INLINE char* OrthancPluginDicomBufferToJson(
|
|
4022 OrthancPluginContext* context,
|
|
4023 const char* buffer,
|
|
4024 uint32_t size,
|
|
4025 OrthancPluginDicomToJsonFormat format,
|
|
4026 OrthancPluginDicomToJsonFlags flags,
|
|
4027 uint32_t maxStringLength)
|
|
4028 {
|
|
4029 char* result;
|
|
4030
|
|
4031 _OrthancPluginDicomToJson params;
|
|
4032 memset(¶ms, 0, sizeof(params));
|
|
4033 params.result = &result;
|
|
4034 params.buffer = buffer;
|
|
4035 params.size = size;
|
|
4036 params.format = format;
|
|
4037 params.flags = flags;
|
|
4038 params.maxStringLength = maxStringLength;
|
|
4039
|
|
4040 if (context->InvokeService(context, _OrthancPluginService_DicomBufferToJson, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4041 {
|
|
4042 /* Error */
|
|
4043 return NULL;
|
|
4044 }
|
|
4045 else
|
|
4046 {
|
|
4047 return result;
|
|
4048 }
|
|
4049 }
|
|
4050
|
|
4051
|
|
4052 /**
|
|
4053 * @brief Format a DICOM instance as a JSON string.
|
|
4054 *
|
|
4055 * This function formats a DICOM instance that is stored in Orthanc,
|
|
4056 * and outputs a JSON string representing the tags of this DICOM
|
|
4057 * instance.
|
|
4058 *
|
|
4059 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4060 * @param instanceId The Orthanc identifier of the instance.
|
|
4061 * @param format The output format.
|
|
4062 * @param flags Flags governing the output.
|
|
4063 * @param maxStringLength The maximum length of a field. Too long fields will
|
|
4064 * be output as "null". The 0 value means no maximum length.
|
|
4065 * @return The NULL value if the case of an error, or the JSON
|
|
4066 * string. This string must be freed by OrthancPluginFreeString().
|
|
4067 * @ingroup Toolbox
|
|
4068 * @see OrthancPluginDicomInstanceToJson
|
|
4069 **/
|
|
4070 ORTHANC_PLUGIN_INLINE char* OrthancPluginDicomInstanceToJson(
|
|
4071 OrthancPluginContext* context,
|
|
4072 const char* instanceId,
|
|
4073 OrthancPluginDicomToJsonFormat format,
|
|
4074 OrthancPluginDicomToJsonFlags flags,
|
|
4075 uint32_t maxStringLength)
|
|
4076 {
|
|
4077 char* result;
|
|
4078
|
|
4079 _OrthancPluginDicomToJson params;
|
|
4080 memset(¶ms, 0, sizeof(params));
|
|
4081 params.result = &result;
|
|
4082 params.instanceId = instanceId;
|
|
4083 params.format = format;
|
|
4084 params.flags = flags;
|
|
4085 params.maxStringLength = maxStringLength;
|
|
4086
|
|
4087 if (context->InvokeService(context, _OrthancPluginService_DicomInstanceToJson, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4088 {
|
|
4089 /* Error */
|
|
4090 return NULL;
|
|
4091 }
|
|
4092 else
|
|
4093 {
|
|
4094 return result;
|
|
4095 }
|
|
4096 }
|
|
4097
|
|
4098
|
|
4099 typedef struct
|
|
4100 {
|
|
4101 OrthancPluginMemoryBuffer* target;
|
|
4102 const char* uri;
|
|
4103 uint32_t headersCount;
|
|
4104 const char* const* headersKeys;
|
|
4105 const char* const* headersValues;
|
|
4106 int32_t afterPlugins;
|
|
4107 } _OrthancPluginRestApiGet2;
|
|
4108
|
|
4109 /**
|
|
4110 * @brief Make a GET call to the Orthanc REST API, with custom HTTP headers.
|
|
4111 *
|
|
4112 * Make a GET call to the Orthanc REST API with extended
|
|
4113 * parameters. The result to the query is stored into a newly
|
|
4114 * allocated memory buffer.
|
|
4115 *
|
|
4116 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4117 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
4118 * @param uri The URI in the built-in Orthanc API.
|
|
4119 * @param headersCount The number of HTTP headers.
|
|
4120 * @param headersKeys Array containing the keys of the HTTP headers.
|
|
4121 * @param headersValues Array containing the values of the HTTP headers.
|
|
4122 * @param afterPlugins If 0, the built-in API of Orthanc is used.
|
|
4123 * If 1, the API is tainted by the plugins.
|
|
4124 * @return 0 if success, or the error code if failure.
|
|
4125 * @see OrthancPluginRestApiGet, OrthancPluginRestApiGetAfterPlugins
|
|
4126 * @ingroup Orthanc
|
|
4127 **/
|
|
4128 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGet2(
|
|
4129 OrthancPluginContext* context,
|
|
4130 OrthancPluginMemoryBuffer* target,
|
|
4131 const char* uri,
|
|
4132 uint32_t headersCount,
|
|
4133 const char* const* headersKeys,
|
|
4134 const char* const* headersValues,
|
|
4135 int32_t afterPlugins)
|
|
4136 {
|
|
4137 _OrthancPluginRestApiGet2 params;
|
|
4138 params.target = target;
|
|
4139 params.uri = uri;
|
|
4140 params.headersCount = headersCount;
|
|
4141 params.headersKeys = headersKeys;
|
|
4142 params.headersValues = headersValues;
|
|
4143 params.afterPlugins = afterPlugins;
|
|
4144
|
|
4145 return context->InvokeService(context, _OrthancPluginService_RestApiGet2, ¶ms);
|
|
4146 }
|
|
4147
|
|
4148
|
|
4149
|
|
4150 typedef struct
|
|
4151 {
|
|
4152 OrthancPluginWorklistCallback callback;
|
|
4153 } _OrthancPluginWorklistCallback;
|
|
4154
|
|
4155 /**
|
|
4156 * @brief Register a callback to handle modality worklists requests.
|
|
4157 *
|
|
4158 * This function registers a callback to handle C-Find SCP requests
|
|
4159 * on modality worklists.
|
|
4160 *
|
|
4161 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4162 * @param callback The callback.
|
|
4163 * @return 0 if success, other value if error.
|
|
4164 * @ingroup Worklists
|
|
4165 **/
|
|
4166 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterWorklistCallback(
|
|
4167 OrthancPluginContext* context,
|
|
4168 OrthancPluginWorklistCallback callback)
|
|
4169 {
|
|
4170 _OrthancPluginWorklistCallback params;
|
|
4171 params.callback = callback;
|
|
4172
|
|
4173 return context->InvokeService(context, _OrthancPluginService_RegisterWorklistCallback, ¶ms);
|
|
4174 }
|
|
4175
|
|
4176
|
|
4177
|
|
4178 typedef struct
|
|
4179 {
|
|
4180 OrthancPluginWorklistAnswers* answers;
|
|
4181 const OrthancPluginWorklistQuery* query;
|
|
4182 const void* dicom;
|
|
4183 uint32_t size;
|
|
4184 } _OrthancPluginWorklistAnswersOperation;
|
|
4185
|
|
4186 /**
|
|
4187 * @brief Add one answer to some modality worklist request.
|
|
4188 *
|
|
4189 * This function adds one worklist (encoded as a DICOM file) to the
|
|
4190 * set of answers corresponding to some C-Find SCP request against
|
|
4191 * modality worklists.
|
|
4192 *
|
|
4193 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4194 * @param answers The set of answers.
|
|
4195 * @param query The worklist query, as received by the callback.
|
|
4196 * @param dicom The worklist to answer, encoded as a DICOM file.
|
|
4197 * @param size The size of the DICOM file.
|
|
4198 * @return 0 if success, other value if error.
|
|
4199 * @ingroup Worklists
|
|
4200 **/
|
|
4201 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistAddAnswer(
|
|
4202 OrthancPluginContext* context,
|
|
4203 OrthancPluginWorklistAnswers* answers,
|
|
4204 const OrthancPluginWorklistQuery* query,
|
|
4205 const void* dicom,
|
|
4206 uint32_t size)
|
|
4207 {
|
|
4208 _OrthancPluginWorklistAnswersOperation params;
|
|
4209 params.answers = answers;
|
|
4210 params.query = query;
|
|
4211 params.dicom = dicom;
|
|
4212 params.size = size;
|
|
4213
|
|
4214 return context->InvokeService(context, _OrthancPluginService_WorklistAddAnswer, ¶ms);
|
|
4215 }
|
|
4216
|
|
4217
|
|
4218 /**
|
|
4219 * @brief Mark the set of worklist answers as incomplete.
|
|
4220 *
|
|
4221 * This function marks as incomplete the set of answers
|
|
4222 * corresponding to some C-Find SCP request against modality
|
|
4223 * worklists. This must be used if canceling the handling of a
|
|
4224 * request when too many answers are to be returned.
|
|
4225 *
|
|
4226 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4227 * @param answers The set of answers.
|
|
4228 * @return 0 if success, other value if error.
|
|
4229 * @ingroup Worklists
|
|
4230 **/
|
|
4231 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistMarkIncomplete(
|
|
4232 OrthancPluginContext* context,
|
|
4233 OrthancPluginWorklistAnswers* answers)
|
|
4234 {
|
|
4235 _OrthancPluginWorklistAnswersOperation params;
|
|
4236 params.answers = answers;
|
|
4237 params.query = NULL;
|
|
4238 params.dicom = NULL;
|
|
4239 params.size = 0;
|
|
4240
|
|
4241 return context->InvokeService(context, _OrthancPluginService_WorklistMarkIncomplete, ¶ms);
|
|
4242 }
|
|
4243
|
|
4244
|
|
4245 typedef struct
|
|
4246 {
|
|
4247 const OrthancPluginWorklistQuery* query;
|
|
4248 const void* dicom;
|
|
4249 uint32_t size;
|
|
4250 int32_t* isMatch;
|
|
4251 OrthancPluginMemoryBuffer* target;
|
|
4252 } _OrthancPluginWorklistQueryOperation;
|
|
4253
|
|
4254 /**
|
|
4255 * @brief Test whether a worklist matches the query.
|
|
4256 *
|
|
4257 * This function checks whether one worklist (encoded as a DICOM
|
|
4258 * file) matches the C-Find SCP query against modality
|
|
4259 * worklists. This function must be called before adding the
|
|
4260 * worklist as an answer through OrthancPluginWorklistAddAnswer().
|
|
4261 *
|
|
4262 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4263 * @param query The worklist query, as received by the callback.
|
|
4264 * @param dicom The worklist to answer, encoded as a DICOM file.
|
|
4265 * @param size The size of the DICOM file.
|
|
4266 * @return 1 if the worklist matches the query, 0 otherwise.
|
|
4267 * @ingroup Worklists
|
|
4268 **/
|
|
4269 ORTHANC_PLUGIN_INLINE int32_t OrthancPluginWorklistIsMatch(
|
|
4270 OrthancPluginContext* context,
|
|
4271 const OrthancPluginWorklistQuery* query,
|
|
4272 const void* dicom,
|
|
4273 uint32_t size)
|
|
4274 {
|
|
4275 int32_t isMatch = 0;
|
|
4276
|
|
4277 _OrthancPluginWorklistQueryOperation params;
|
|
4278 params.query = query;
|
|
4279 params.dicom = dicom;
|
|
4280 params.size = size;
|
|
4281 params.isMatch = &isMatch;
|
|
4282 params.target = NULL;
|
|
4283
|
|
4284 if (context->InvokeService(context, _OrthancPluginService_WorklistIsMatch, ¶ms) == OrthancPluginErrorCode_Success)
|
|
4285 {
|
|
4286 return isMatch;
|
|
4287 }
|
|
4288 else
|
|
4289 {
|
|
4290 /* Error: Assume non-match */
|
|
4291 return 0;
|
|
4292 }
|
|
4293 }
|
|
4294
|
|
4295
|
|
4296 /**
|
|
4297 * @brief Retrieve the worklist query as a DICOM file.
|
|
4298 *
|
|
4299 * This function retrieves the DICOM file that underlies a C-Find
|
|
4300 * SCP query against modality worklists.
|
|
4301 *
|
|
4302 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4303 * @param target Memory buffer where to store the DICOM file. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
4304 * @param query The worklist query, as received by the callback.
|
|
4305 * @return 0 if success, other value if error.
|
|
4306 * @ingroup Worklists
|
|
4307 **/
|
|
4308 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistGetDicomQuery(
|
|
4309 OrthancPluginContext* context,
|
|
4310 OrthancPluginMemoryBuffer* target,
|
|
4311 const OrthancPluginWorklistQuery* query)
|
|
4312 {
|
|
4313 _OrthancPluginWorklistQueryOperation params;
|
|
4314 params.query = query;
|
|
4315 params.dicom = NULL;
|
|
4316 params.size = 0;
|
|
4317 params.isMatch = NULL;
|
|
4318 params.target = target;
|
|
4319
|
|
4320 return context->InvokeService(context, _OrthancPluginService_WorklistGetDicomQuery, ¶ms);
|
|
4321 }
|
|
4322
|
|
4323
|
|
4324 /**
|
|
4325 * @brief Get the origin of a DICOM file.
|
|
4326 *
|
|
4327 * This function returns the origin of a DICOM instance that has been received by Orthanc.
|
|
4328 *
|
|
4329 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4330 * @param instance The instance of interest.
|
|
4331 * @return The origin of the instance.
|
|
4332 * @ingroup Callbacks
|
|
4333 **/
|
|
4334 ORTHANC_PLUGIN_INLINE OrthancPluginInstanceOrigin OrthancPluginGetInstanceOrigin(
|
|
4335 OrthancPluginContext* context,
|
|
4336 OrthancPluginDicomInstance* instance)
|
|
4337 {
|
|
4338 OrthancPluginInstanceOrigin origin;
|
|
4339
|
|
4340 _OrthancPluginAccessDicomInstance params;
|
|
4341 memset(¶ms, 0, sizeof(params));
|
|
4342 params.resultOrigin = &origin;
|
|
4343 params.instance = instance;
|
|
4344
|
|
4345 if (context->InvokeService(context, _OrthancPluginService_GetInstanceOrigin, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4346 {
|
|
4347 /* Error */
|
|
4348 return OrthancPluginInstanceOrigin_Unknown;
|
|
4349 }
|
|
4350 else
|
|
4351 {
|
|
4352 return origin;
|
|
4353 }
|
|
4354 }
|
|
4355
|
|
4356
|
|
4357 typedef struct
|
|
4358 {
|
|
4359 OrthancPluginMemoryBuffer* target;
|
|
4360 const char* json;
|
|
4361 const OrthancPluginImage* pixelData;
|
|
4362 OrthancPluginCreateDicomFlags flags;
|
|
4363 } _OrthancPluginCreateDicom;
|
|
4364
|
|
4365 /**
|
|
4366 * @brief Create a DICOM instance from a JSON string and an image.
|
|
4367 *
|
|
4368 * This function takes as input a string containing a JSON file
|
|
4369 * describing the content of a DICOM instance. As an output, it
|
|
4370 * writes the corresponding DICOM instance to a newly allocated
|
|
4371 * memory buffer. Additionally, an image to be encoded within the
|
|
4372 * DICOM instance can also be provided.
|
|
4373 *
|
|
4374 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4375 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().
|
|
4376 * @param json The input JSON file.
|
|
4377 * @param pixelData The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme.
|
|
4378 * @param flags Flags governing the output.
|
|
4379 * @return 0 if success, other value if error.
|
|
4380 * @ingroup Toolbox
|
|
4381 * @see OrthancPluginDicomBufferToJson
|
|
4382 **/
|
|
4383 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateDicom(
|
|
4384 OrthancPluginContext* context,
|
|
4385 OrthancPluginMemoryBuffer* target,
|
|
4386 const char* json,
|
|
4387 const OrthancPluginImage* pixelData,
|
|
4388 OrthancPluginCreateDicomFlags flags)
|
|
4389 {
|
|
4390 _OrthancPluginCreateDicom params;
|
|
4391 params.target = target;
|
|
4392 params.json = json;
|
|
4393 params.pixelData = pixelData;
|
|
4394 params.flags = flags;
|
|
4395
|
|
4396 return context->InvokeService(context, _OrthancPluginService_CreateDicom, ¶ms);
|
|
4397 }
|
|
4398
|
|
4399
|
|
4400 typedef struct
|
|
4401 {
|
|
4402 OrthancPluginDecodeImageCallback callback;
|
|
4403 } _OrthancPluginDecodeImageCallback;
|
|
4404
|
|
4405 /**
|
|
4406 * @brief Register a callback to handle the decoding of DICOM images.
|
|
4407 *
|
|
4408 * This function registers a custom callback to the decoding of
|
|
4409 * DICOM images, replacing the built-in decoder of Orthanc.
|
|
4410 *
|
|
4411 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4412 * @param callback The callback.
|
|
4413 * @return 0 if success, other value if error.
|
|
4414 * @ingroup Callbacks
|
|
4415 **/
|
|
4416 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDecodeImageCallback(
|
|
4417 OrthancPluginContext* context,
|
|
4418 OrthancPluginDecodeImageCallback callback)
|
|
4419 {
|
|
4420 _OrthancPluginDecodeImageCallback params;
|
|
4421 params.callback = callback;
|
|
4422
|
|
4423 return context->InvokeService(context, _OrthancPluginService_RegisterDecodeImageCallback, ¶ms);
|
|
4424 }
|
|
4425
|
|
4426
|
|
4427
|
|
4428 typedef struct
|
|
4429 {
|
|
4430 OrthancPluginImage** target;
|
|
4431 OrthancPluginPixelFormat format;
|
|
4432 uint32_t width;
|
|
4433 uint32_t height;
|
|
4434 uint32_t pitch;
|
|
4435 void* buffer;
|
|
4436 const void* constBuffer;
|
|
4437 uint32_t bufferSize;
|
|
4438 uint32_t frameIndex;
|
|
4439 } _OrthancPluginCreateImage;
|
|
4440
|
|
4441
|
|
4442 /**
|
|
4443 * @brief Create an image.
|
|
4444 *
|
|
4445 * This function creates an image of given size and format.
|
|
4446 *
|
|
4447 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4448 * @param format The format of the pixels.
|
|
4449 * @param width The width of the image.
|
|
4450 * @param height The height of the image.
|
|
4451 * @return The newly allocated image. It must be freed with OrthancPluginFreeImage().
|
|
4452 * @ingroup Images
|
|
4453 **/
|
|
4454 ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginCreateImage(
|
|
4455 OrthancPluginContext* context,
|
|
4456 OrthancPluginPixelFormat format,
|
|
4457 uint32_t width,
|
|
4458 uint32_t height)
|
|
4459 {
|
|
4460 OrthancPluginImage* target = NULL;
|
|
4461
|
|
4462 _OrthancPluginCreateImage params;
|
|
4463 memset(¶ms, 0, sizeof(params));
|
|
4464 params.target = ⌖
|
|
4465 params.format = format;
|
|
4466 params.width = width;
|
|
4467 params.height = height;
|
|
4468
|
|
4469 if (context->InvokeService(context, _OrthancPluginService_CreateImage, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4470 {
|
|
4471 return NULL;
|
|
4472 }
|
|
4473 else
|
|
4474 {
|
|
4475 return target;
|
|
4476 }
|
|
4477 }
|
|
4478
|
|
4479
|
|
4480 /**
|
|
4481 * @brief Create an image pointing to a memory buffer.
|
|
4482 *
|
|
4483 * This function creates an image whose content points to a memory
|
|
4484 * buffer managed by the plugin. Note that the buffer is directly
|
|
4485 * accessed, no memory is allocated and no data is copied.
|
|
4486 *
|
|
4487 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4488 * @param format The format of the pixels.
|
|
4489 * @param width The width of the image.
|
|
4490 * @param height The height of the image.
|
|
4491 * @param pitch The pitch of the image (i.e. the number of bytes
|
|
4492 * between 2 successive lines of the image in the memory buffer).
|
|
4493 * @param buffer The memory buffer.
|
|
4494 * @return The newly allocated image. It must be freed with OrthancPluginFreeImage().
|
|
4495 * @ingroup Images
|
|
4496 **/
|
|
4497 ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginCreateImageAccessor(
|
|
4498 OrthancPluginContext* context,
|
|
4499 OrthancPluginPixelFormat format,
|
|
4500 uint32_t width,
|
|
4501 uint32_t height,
|
|
4502 uint32_t pitch,
|
|
4503 void* buffer)
|
|
4504 {
|
|
4505 OrthancPluginImage* target = NULL;
|
|
4506
|
|
4507 _OrthancPluginCreateImage params;
|
|
4508 memset(¶ms, 0, sizeof(params));
|
|
4509 params.target = ⌖
|
|
4510 params.format = format;
|
|
4511 params.width = width;
|
|
4512 params.height = height;
|
|
4513 params.pitch = pitch;
|
|
4514 params.buffer = buffer;
|
|
4515
|
|
4516 if (context->InvokeService(context, _OrthancPluginService_CreateImageAccessor, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4517 {
|
|
4518 return NULL;
|
|
4519 }
|
|
4520 else
|
|
4521 {
|
|
4522 return target;
|
|
4523 }
|
|
4524 }
|
|
4525
|
|
4526
|
|
4527
|
|
4528 /**
|
|
4529 * @brief Decode one frame from a DICOM instance.
|
|
4530 *
|
|
4531 * This function decodes one frame of a DICOM image that is stored
|
|
4532 * in a memory buffer. This function will give the same result as
|
|
4533 * OrthancPluginUncompressImage() for single-frame DICOM images.
|
|
4534 *
|
|
4535 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4536 * @param buffer Pointer to a memory buffer containing the DICOM image.
|
|
4537 * @param bufferSize Size of the memory buffer containing the DICOM image.
|
|
4538 * @param frameIndex The index of the frame of interest in a multi-frame image.
|
|
4539 * @return The uncompressed image. It must be freed with OrthancPluginFreeImage().
|
|
4540 * @ingroup Images
|
|
4541 **/
|
|
4542 ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginDecodeDicomImage(
|
|
4543 OrthancPluginContext* context,
|
|
4544 const void* buffer,
|
|
4545 uint32_t bufferSize,
|
|
4546 uint32_t frameIndex)
|
|
4547 {
|
|
4548 OrthancPluginImage* target = NULL;
|
|
4549
|
|
4550 _OrthancPluginCreateImage params;
|
|
4551 memset(¶ms, 0, sizeof(params));
|
|
4552 params.target = ⌖
|
|
4553 params.constBuffer = buffer;
|
|
4554 params.bufferSize = bufferSize;
|
|
4555 params.frameIndex = frameIndex;
|
|
4556
|
|
4557 if (context->InvokeService(context, _OrthancPluginService_DecodeDicomImage, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4558 {
|
|
4559 return NULL;
|
|
4560 }
|
|
4561 else
|
|
4562 {
|
|
4563 return target;
|
|
4564 }
|
|
4565 }
|
|
4566
|
|
4567
|
|
4568
|
|
4569 typedef struct
|
|
4570 {
|
|
4571 char** result;
|
|
4572 const void* buffer;
|
|
4573 uint32_t size;
|
|
4574 } _OrthancPluginComputeHash;
|
|
4575
|
|
4576 /**
|
|
4577 * @brief Compute an MD5 hash.
|
|
4578 *
|
|
4579 * This functions computes the MD5 cryptographic hash of the given memory buffer.
|
|
4580 *
|
|
4581 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4582 * @param buffer The source memory buffer.
|
|
4583 * @param size The size in bytes of the source buffer.
|
|
4584 * @return The NULL value in case of error, or a string containing the cryptographic hash.
|
|
4585 * This string must be freed by OrthancPluginFreeString().
|
|
4586 * @ingroup Toolbox
|
|
4587 **/
|
|
4588 ORTHANC_PLUGIN_INLINE char* OrthancPluginComputeMd5(
|
|
4589 OrthancPluginContext* context,
|
|
4590 const void* buffer,
|
|
4591 uint32_t size)
|
|
4592 {
|
|
4593 char* result;
|
|
4594
|
|
4595 _OrthancPluginComputeHash params;
|
|
4596 params.result = &result;
|
|
4597 params.buffer = buffer;
|
|
4598 params.size = size;
|
|
4599
|
|
4600 if (context->InvokeService(context, _OrthancPluginService_ComputeMd5, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4601 {
|
|
4602 /* Error */
|
|
4603 return NULL;
|
|
4604 }
|
|
4605 else
|
|
4606 {
|
|
4607 return result;
|
|
4608 }
|
|
4609 }
|
|
4610
|
|
4611
|
|
4612 /**
|
|
4613 * @brief Compute a SHA-1 hash.
|
|
4614 *
|
|
4615 * This functions computes the SHA-1 cryptographic hash of the given memory buffer.
|
|
4616 *
|
|
4617 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4618 * @param buffer The source memory buffer.
|
|
4619 * @param size The size in bytes of the source buffer.
|
|
4620 * @return The NULL value in case of error, or a string containing the cryptographic hash.
|
|
4621 * This string must be freed by OrthancPluginFreeString().
|
|
4622 * @ingroup Toolbox
|
|
4623 **/
|
|
4624 ORTHANC_PLUGIN_INLINE char* OrthancPluginComputeSha1(
|
|
4625 OrthancPluginContext* context,
|
|
4626 const void* buffer,
|
|
4627 uint32_t size)
|
|
4628 {
|
|
4629 char* result;
|
|
4630
|
|
4631 _OrthancPluginComputeHash params;
|
|
4632 params.result = &result;
|
|
4633 params.buffer = buffer;
|
|
4634 params.size = size;
|
|
4635
|
|
4636 if (context->InvokeService(context, _OrthancPluginService_ComputeSha1, ¶ms) != OrthancPluginErrorCode_Success)
|
|
4637 {
|
|
4638 /* Error */
|
|
4639 return NULL;
|
|
4640 }
|
|
4641 else
|
|
4642 {
|
|
4643 return result;
|
|
4644 }
|
|
4645 }
|
|
4646
|
|
4647
|
|
4648
|
|
4649 typedef struct
|
|
4650 {
|
|
4651 OrthancPluginDictionaryEntry* target;
|
|
4652 const char* name;
|
|
4653 } _OrthancPluginLookupDictionary;
|
|
4654
|
|
4655 /**
|
|
4656 * @brief Get information about the given DICOM tag.
|
|
4657 *
|
|
4658 * This functions makes a lookup in the dictionary of DICOM tags
|
|
4659 * that are known to Orthanc, and returns information about this
|
|
4660 * tag. The tag can be specified using its human-readable name
|
|
4661 * (e.g. "PatientName") or a set of two hexadecimal numbers
|
|
4662 * (e.g. "0010-0020").
|
|
4663 *
|
|
4664 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4665 * @param target Where to store the information about the tag.
|
|
4666 * @param name The name of the DICOM tag.
|
|
4667 * @return 0 if success, other value if error.
|
|
4668 * @ingroup Toolbox
|
|
4669 **/
|
|
4670 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginLookupDictionary(
|
|
4671 OrthancPluginContext* context,
|
|
4672 OrthancPluginDictionaryEntry* target,
|
|
4673 const char* name)
|
|
4674 {
|
|
4675 _OrthancPluginLookupDictionary params;
|
|
4676 params.target = target;
|
|
4677 params.name = name;
|
|
4678 return context->InvokeService(context, _OrthancPluginService_LookupDictionary, ¶ms);
|
|
4679 }
|
|
4680
|
|
4681
|
|
4682
|
|
4683 typedef struct
|
|
4684 {
|
|
4685 OrthancPluginRestOutput* output;
|
|
4686 const char* answer;
|
|
4687 uint32_t answerSize;
|
|
4688 uint32_t headersCount;
|
|
4689 const char* const* headersKeys;
|
|
4690 const char* const* headersValues;
|
|
4691 } _OrthancPluginSendMultipartItem2;
|
|
4692
|
|
4693 /**
|
|
4694 * @brief Send an item as a part of some HTTP multipart answer, with custom headers.
|
|
4695 *
|
|
4696 * This function sends an item as a part of some HTTP multipart
|
|
4697 * answer that was initiated by OrthancPluginStartMultipartAnswer(). In addition to
|
|
4698 * OrthancPluginSendMultipartItem(), this function will set HTTP header associated
|
|
4699 * with the item.
|
|
4700 *
|
|
4701 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
4702 * @param output The HTTP connection to the client application.
|
|
4703 * @param answer Pointer to the memory buffer containing the item.
|
|
4704 * @param answerSize Number of bytes of the item.
|
|
4705 * @param headersCount The number of HTTP headers.
|
|
4706 * @param headersKeys Array containing the keys of the HTTP headers.
|
|
4707 * @param headersValues Array containing the values of the HTTP headers.
|
|
4708 * @return 0 if success, or the error code if failure (this notably happens
|
|
4709 * if the connection is closed by the client).
|
|
4710 * @see OrthancPluginSendMultipartItem()
|
|
4711 * @ingroup REST
|
|
4712 **/
|
|
4713 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSendMultipartItem2(
|
|
4714 OrthancPluginContext* context,
|
|
4715 OrthancPluginRestOutput* output,
|
|
4716 const char* answer,
|
|
4717 uint32_t answerSize,
|
|
4718 uint32_t headersCount,
|
|
4719 const char* const* headersKeys,
|
|
4720 const char* const* headersValues)
|
|
4721 {
|
|
4722 _OrthancPluginSendMultipartItem2 params;
|
|
4723 params.output = output;
|
|
4724 params.answer = answer;
|
|
4725 params.answerSize = answerSize;
|
|
4726 params.headersCount = headersCount;
|
|
4727 params.headersKeys = headersKeys;
|
|
4728 params.headersValues = headersValues;
|
|
4729
|
|
4730 return context->InvokeService(context, _OrthancPluginService_SendMultipartItem2, ¶ms);
|
|
4731 }
|
|
4732
|
|
4733
|
|
4734 #ifdef __cplusplus
|
|
4735 }
|
|
4736 #endif
|
|
4737
|
|
4738
|
|
4739 /** @} */
|
|
4740
|