Orthanc Plugin SDK
Documentation of the plugin interface of Orthanc
OrthancCPlugin.h
1 
78 #pragma once
79 
80 
81 #include <stdio.h>
82 #include <string.h>
83 
84 #ifdef WIN32
85 #define ORTHANC_PLUGINS_API __declspec(dllexport)
86 #else
87 #define ORTHANC_PLUGINS_API
88 #endif
89 
90 #define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 0
91 #define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 8
92 #define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 5
93 
94 
95 
96 /********************************************************************
97  ** Check that function inlining is properly supported. The use of
98  ** inlining is required, to avoid the duplication of object code
99  ** between two compilation modules that would use the Orthanc Plugin
100  ** API.
101  ********************************************************************/
102 
103 /* If the auto-detection of the "inline" keyword below does not work
104  automatically and that your compiler is known to properly support
105  inlining, uncomment the following #define and adapt the definition
106  of "static inline". */
107 
108 /* #define ORTHANC_PLUGIN_INLINE static inline */
109 
110 #ifndef ORTHANC_PLUGIN_INLINE
111 # if __STDC_VERSION__ >= 199901L
112 /* This is C99 or above: http://predef.sourceforge.net/prestd.html */
113 # define ORTHANC_PLUGIN_INLINE static inline
114 # elif defined(__cplusplus)
115 /* This is C++ */
116 # define ORTHANC_PLUGIN_INLINE static inline
117 # elif defined(__GNUC__)
118 /* This is GCC running in C89 mode */
119 # define ORTHANC_PLUGIN_INLINE static __inline
120 # elif defined(_MSC_VER)
121 /* This is Visual Studio running in C89 mode */
122 # define ORTHANC_PLUGIN_INLINE static __inline
123 # else
124 # error Your compiler is not known to support the "inline" keyword
125 # endif
126 #endif
127 
128 
129 
130 /********************************************************************
131  ** Inclusion of standard libraries.
132  ********************************************************************/
133 
134 #ifdef _MSC_VER
135 #include "../../Resources/ThirdParty/VisualStudio/stdint.h"
136 #else
137 #include <stdint.h>
138 #endif
139 
140 #include <stdlib.h>
141 
142 
143 
144 /********************************************************************
145  ** Definition of the Orthanc Plugin API.
146  ********************************************************************/
147 
150 #ifdef __cplusplus
151 extern "C"
152 {
153 #endif
154 
158  typedef enum
159  {
165 
166 
170  typedef struct
171  {
176 
180  uint32_t groupsCount;
181 
185  const char* const* groups;
186 
190  uint32_t getCount;
191 
195  const char* const* getKeys;
196 
200  const char* const* getValues;
201 
205  const char* body;
206 
210  uint32_t bodySize;
211 
212 
213  /* --------------------------------------------------
214  New in version 0.8.1
215  -------------------------------------------------- */
216 
220  uint32_t headersCount;
221 
225  const char* const* headersKeys;
226 
230  const char* const* headersValues;
231 
233 
234 
235  typedef enum
236  {
237  /* Generic services */
238  _OrthancPluginService_LogInfo = 1,
239  _OrthancPluginService_LogWarning = 2,
240  _OrthancPluginService_LogError = 3,
241  _OrthancPluginService_GetOrthancPath = 4,
242  _OrthancPluginService_GetOrthancDirectory = 5,
243  _OrthancPluginService_GetConfigurationPath = 6,
244 
245  /* Registration of callbacks */
246  _OrthancPluginService_RegisterRestCallback = 1000,
247  _OrthancPluginService_RegisterOnStoredInstanceCallback = 1001,
248  _OrthancPluginService_RegisterStorageArea = 1002,
249  _OrthancPluginService_RegisterOnChangeCallback = 1003,
250 
251  /* Sending answers to REST calls */
252  _OrthancPluginService_AnswerBuffer = 2000,
253  _OrthancPluginService_CompressAndAnswerPngImage = 2001,
254  _OrthancPluginService_Redirect = 2002,
255  _OrthancPluginService_SendHttpStatusCode = 2003,
256  _OrthancPluginService_SendUnauthorized = 2004,
257  _OrthancPluginService_SendMethodNotAllowed = 2005,
258  _OrthancPluginService_SetCookie = 2006,
259  _OrthancPluginService_SetHttpHeader = 2007,
260 
261  /* Access to the Orthanc database and API */
262  _OrthancPluginService_GetDicomForInstance = 3000,
263  _OrthancPluginService_RestApiGet = 3001,
264  _OrthancPluginService_RestApiPost = 3002,
265  _OrthancPluginService_RestApiDelete = 3003,
266  _OrthancPluginService_RestApiPut = 3004,
267  _OrthancPluginService_LookupPatient = 3005,
268  _OrthancPluginService_LookupStudy = 3006,
269  _OrthancPluginService_LookupSeries = 3007,
270  _OrthancPluginService_LookupInstance = 3008,
271  _OrthancPluginService_LookupStudyWithAccessionNumber = 3009,
272 
273  /* Access to DICOM instances */
274  _OrthancPluginService_GetInstanceRemoteAet = 4000,
275  _OrthancPluginService_GetInstanceSize = 4001,
276  _OrthancPluginService_GetInstanceData = 4002,
277  _OrthancPluginService_GetInstanceJson = 4003,
278  _OrthancPluginService_GetInstanceSimplifiedJson = 4004,
279  _OrthancPluginService_HasInstanceMetadata = 4005,
280  _OrthancPluginService_GetInstanceMetadata = 4006
281  } _OrthancPluginService;
282 
283 
284 
288  typedef enum
289  {
297 
305 
313 
321 
330 
331 
332 
336  typedef enum
337  {
342 
343 
344 
348  typedef enum
349  {
355 
356 
357 
361  typedef enum
362  {
374 
375 
376 
384  typedef struct
385  {
389  void* data;
390 
394  uint32_t size;
396 
397 
398 
399 
403  typedef struct _OrthancPluginRestOutput_t OrthancPluginRestOutput;
404 
405 
406 
410  typedef struct _OrthancPluginDicomInstance_t OrthancPluginDicomInstance;
411 
412 
413 
417  typedef int32_t (*OrthancPluginRestCallback) (
418  OrthancPluginRestOutput* output,
419  const char* url,
420  const OrthancPluginHttpRequest* request);
421 
422 
423 
428  OrthancPluginDicomInstance* instance,
429  const char* instanceId);
430 
431 
432 
436  typedef int32_t (*OrthancPluginOnChangeCallback) (
437  OrthancPluginChangeType changeType,
438  OrthancPluginResourceType resourceType,
439  const char* resourceId);
440 
441 
442 
446  typedef void (*OrthancPluginFree) (void* buffer);
447 
448 
449 
461  typedef int32_t (*OrthancPluginStorageCreate) (
462  const char* uuid,
463  const void* content,
464  int64_t size,
466 
467 
468 
480  typedef int32_t (*OrthancPluginStorageRead) (
481  void** content,
482  int64_t* size,
483  const char* uuid,
485 
486 
487 
497  typedef int32_t (*OrthancPluginStorageRemove) (
498  const char* uuid,
500 
501 
502 
506  typedef struct _OrthancPluginContext_t
507  {
508  void* pluginsManager;
509  const char* orthancVersion;
510  OrthancPluginFree Free;
511  int32_t (*InvokeService) (struct _OrthancPluginContext_t* context,
512  _OrthancPluginService service,
513  const void* params);
515 
516 
517 
526  ORTHANC_PLUGIN_INLINE void OrthancPluginFreeString(
527  OrthancPluginContext* context,
528  char* str)
529  {
530  if (str != NULL)
531  {
532  context->Free(str);
533  }
534  }
535 
536 
549  ORTHANC_PLUGIN_INLINE int OrthancPluginCheckVersion(
550  OrthancPluginContext* context)
551  {
552  int major, minor, revision;
553 
554  /* Assume compatibility with the mainline */
555  if (!strcmp(context->orthancVersion, "mainline"))
556  {
557  return 1;
558  }
559 
560  /* Parse the version of the Orthanc core */
561  if (
562 #ifdef _MSC_VER
563  sscanf_s
564 #else
565  sscanf
566 #endif
567  (context->orthancVersion, "%d.%d.%d", &major, &minor, &revision) != 3)
568  {
569  return 0;
570  }
571 
572  /* Check the major number of the version */
573 
574  if (major > ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER)
575  {
576  return 1;
577  }
578 
579  if (major < ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER)
580  {
581  return 0;
582  }
583 
584  /* Check the minor number of the version */
585 
586  if (minor > ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER)
587  {
588  return 1;
589  }
590 
591  if (minor < ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER)
592  {
593  return 0;
594  }
595 
596  /* Check the revision number of the version */
597 
598  if (revision >= ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER)
599  {
600  return 1;
601  }
602  else
603  {
604  return 0;
605  }
606  }
607 
608 
617  ORTHANC_PLUGIN_INLINE void OrthancPluginFreeMemoryBuffer(
618  OrthancPluginContext* context,
620  {
621  context->Free(buffer->data);
622  }
623 
624 
633  ORTHANC_PLUGIN_INLINE void OrthancPluginLogError(
634  OrthancPluginContext* context,
635  const char* message)
636  {
637  context->InvokeService(context, _OrthancPluginService_LogError, message);
638  }
639 
640 
649  ORTHANC_PLUGIN_INLINE void OrthancPluginLogWarning(
650  OrthancPluginContext* context,
651  const char* message)
652  {
653  context->InvokeService(context, _OrthancPluginService_LogWarning, message);
654  }
655 
656 
665  ORTHANC_PLUGIN_INLINE void OrthancPluginLogInfo(
666  OrthancPluginContext* context,
667  const char* message)
668  {
669  context->InvokeService(context, _OrthancPluginService_LogInfo, message);
670  }
671 
672 
673 
674  typedef struct
675  {
676  const char* pathRegularExpression;
677  OrthancPluginRestCallback callback;
678  } _OrthancPluginRestCallback;
679 
692  ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallback(
693  OrthancPluginContext* context,
694  const char* pathRegularExpression,
695  OrthancPluginRestCallback callback)
696  {
697  _OrthancPluginRestCallback params;
698  params.pathRegularExpression = pathRegularExpression;
699  params.callback = callback;
700  context->InvokeService(context, _OrthancPluginService_RegisterRestCallback, &params);
701  }
702 
703 
704 
705  typedef struct
706  {
708  } _OrthancPluginOnStoredInstanceCallback;
709 
720  OrthancPluginContext* context,
722  {
723  _OrthancPluginOnStoredInstanceCallback params;
724  params.callback = callback;
725 
726  context->InvokeService(context, _OrthancPluginService_RegisterOnStoredInstanceCallback, &params);
727  }
728 
729 
730 
731  typedef struct
732  {
733  OrthancPluginRestOutput* output;
734  const char* answer;
735  uint32_t answerSize;
736  const char* mimeType;
737  } _OrthancPluginAnswerBuffer;
738 
750  ORTHANC_PLUGIN_INLINE void OrthancPluginAnswerBuffer(
751  OrthancPluginContext* context,
752  OrthancPluginRestOutput* output,
753  const char* answer,
754  uint32_t answerSize,
755  const char* mimeType)
756  {
757  _OrthancPluginAnswerBuffer params;
758  params.output = output;
759  params.answer = answer;
760  params.answerSize = answerSize;
761  params.mimeType = mimeType;
762  context->InvokeService(context, _OrthancPluginService_AnswerBuffer, &params);
763  }
764 
765 
766  typedef struct
767  {
768  OrthancPluginRestOutput* output;
770  uint32_t width;
771  uint32_t height;
772  uint32_t pitch;
773  const void* buffer;
774  } _OrthancPluginCompressAndAnswerPngImage;
775 
793  ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerPngImage(
794  OrthancPluginContext* context,
795  OrthancPluginRestOutput* output,
797  uint32_t width,
798  uint32_t height,
799  uint32_t pitch,
800  const void* buffer)
801  {
802  _OrthancPluginCompressAndAnswerPngImage params;
803  params.output = output;
804  params.format = format;
805  params.width = width;
806  params.height = height;
807  params.pitch = pitch;
808  params.buffer = buffer;
809  context->InvokeService(context, _OrthancPluginService_CompressAndAnswerPngImage, &params);
810  }
811 
812 
813 
814  typedef struct
815  {
817  const char* instanceId;
818  } _OrthancPluginGetDicomForInstance;
819 
831  ORTHANC_PLUGIN_INLINE int OrthancPluginGetDicomForInstance(
832  OrthancPluginContext* context,
834  const char* instanceId)
835  {
836  _OrthancPluginGetDicomForInstance params;
837  params.target = target;
838  params.instanceId = instanceId;
839  return context->InvokeService(context, _OrthancPluginService_GetDicomForInstance, &params);
840  }
841 
842 
843 
844  typedef struct
845  {
847  const char* uri;
848  } _OrthancPluginRestApiGet;
849 
861  ORTHANC_PLUGIN_INLINE int OrthancPluginRestApiGet(
862  OrthancPluginContext* context,
864  const char* uri)
865  {
866  _OrthancPluginRestApiGet params;
867  params.target = target;
868  params.uri = uri;
869  return context->InvokeService(context, _OrthancPluginService_RestApiGet, &params);
870  }
871 
872 
873 
874  typedef struct
875  {
877  const char* uri;
878  const char* body;
879  uint32_t bodySize;
880  } _OrthancPluginRestApiPostPut;
881 
895  ORTHANC_PLUGIN_INLINE int OrthancPluginRestApiPost(
896  OrthancPluginContext* context,
898  const char* uri,
899  const char* body,
900  uint32_t bodySize)
901  {
902  _OrthancPluginRestApiPostPut params;
903  params.target = target;
904  params.uri = uri;
905  params.body = body;
906  params.bodySize = bodySize;
907  return context->InvokeService(context, _OrthancPluginService_RestApiPost, &params);
908  }
909 
910 
911 
921  ORTHANC_PLUGIN_INLINE int OrthancPluginRestApiDelete(
922  OrthancPluginContext* context,
923  const char* uri)
924  {
925  return context->InvokeService(context, _OrthancPluginService_RestApiDelete, uri);
926  }
927 
928 
929 
943  ORTHANC_PLUGIN_INLINE int OrthancPluginRestApiPut(
944  OrthancPluginContext* context,
946  const char* uri,
947  const char* body,
948  uint32_t bodySize)
949  {
950  _OrthancPluginRestApiPostPut params;
951  params.target = target;
952  params.uri = uri;
953  params.body = body;
954  params.bodySize = bodySize;
955  return context->InvokeService(context, _OrthancPluginService_RestApiPut, &params);
956  }
957 
958 
959 
960  typedef struct
961  {
962  OrthancPluginRestOutput* output;
963  const char* argument;
964  } _OrthancPluginOutputPlusArgument;
965 
976  ORTHANC_PLUGIN_INLINE void OrthancPluginRedirect(
977  OrthancPluginContext* context,
978  OrthancPluginRestOutput* output,
979  const char* redirection)
980  {
981  _OrthancPluginOutputPlusArgument params;
982  params.output = output;
983  params.argument = redirection;
984  context->InvokeService(context, _OrthancPluginService_Redirect, &params);
985  }
986 
987 
988 
989  typedef struct
990  {
991  char** result;
992  const char* argument;
993  } _OrthancPluginRetrieveDynamicString;
994 
1007  ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupPatient(
1008  OrthancPluginContext* context,
1009  const char* patientID)
1010  {
1011  char* result;
1012 
1013  _OrthancPluginRetrieveDynamicString params;
1014  params.result = &result;
1015  params.argument = patientID;
1016 
1017  if (context->InvokeService(context, _OrthancPluginService_LookupPatient, &params))
1018  {
1019  /* Error */
1020  return NULL;
1021  }
1022  else
1023  {
1024  return result;
1025  }
1026  }
1027 
1028 
1041  ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudy(
1042  OrthancPluginContext* context,
1043  const char* studyUID)
1044  {
1045  char* result;
1046 
1047  _OrthancPluginRetrieveDynamicString params;
1048  params.result = &result;
1049  params.argument = studyUID;
1050 
1051  if (context->InvokeService(context, _OrthancPluginService_LookupStudy, &params))
1052  {
1053  /* Error */
1054  return NULL;
1055  }
1056  else
1057  {
1058  return result;
1059  }
1060  }
1061 
1062 
1075  ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudyWithAccessionNumber(
1076  OrthancPluginContext* context,
1077  const char* accessionNumber)
1078  {
1079  char* result;
1080 
1081  _OrthancPluginRetrieveDynamicString params;
1082  params.result = &result;
1083  params.argument = accessionNumber;
1084 
1085  if (context->InvokeService(context, _OrthancPluginService_LookupStudyWithAccessionNumber, &params))
1086  {
1087  /* Error */
1088  return NULL;
1089  }
1090  else
1091  {
1092  return result;
1093  }
1094  }
1095 
1096 
1109  ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupSeries(
1110  OrthancPluginContext* context,
1111  const char* seriesUID)
1112  {
1113  char* result;
1114 
1115  _OrthancPluginRetrieveDynamicString params;
1116  params.result = &result;
1117  params.argument = seriesUID;
1118 
1119  if (context->InvokeService(context, _OrthancPluginService_LookupSeries, &params))
1120  {
1121  /* Error */
1122  return NULL;
1123  }
1124  else
1125  {
1126  return result;
1127  }
1128  }
1129 
1130 
1143  ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupInstance(
1144  OrthancPluginContext* context,
1145  const char* sopInstanceUID)
1146  {
1147  char* result;
1148 
1149  _OrthancPluginRetrieveDynamicString params;
1150  params.result = &result;
1151  params.argument = sopInstanceUID;
1152 
1153  if (context->InvokeService(context, _OrthancPluginService_LookupInstance, &params))
1154  {
1155  /* Error */
1156  return NULL;
1157  }
1158  else
1159  {
1160  return result;
1161  }
1162  }
1163 
1164 
1165 
1166  typedef struct
1167  {
1168  OrthancPluginRestOutput* output;
1169  uint16_t status;
1170  } _OrthancPluginSendHttpStatusCode;
1171 
1186  ORTHANC_PLUGIN_INLINE void OrthancPluginSendHttpStatusCode(
1187  OrthancPluginContext* context,
1188  OrthancPluginRestOutput* output,
1189  uint16_t status)
1190  {
1191  _OrthancPluginSendHttpStatusCode params;
1192  params.output = output;
1193  params.status = status;
1194  context->InvokeService(context, _OrthancPluginService_SendHttpStatusCode, &params);
1195  }
1196 
1197 
1208  ORTHANC_PLUGIN_INLINE void OrthancPluginSendUnauthorized(
1209  OrthancPluginContext* context,
1210  OrthancPluginRestOutput* output,
1211  const char* realm)
1212  {
1213  _OrthancPluginOutputPlusArgument params;
1214  params.output = output;
1215  params.argument = realm;
1216  context->InvokeService(context, _OrthancPluginService_SendUnauthorized, &params);
1217  }
1218 
1219 
1230  ORTHANC_PLUGIN_INLINE void OrthancPluginSendMethodNotAllowed(
1231  OrthancPluginContext* context,
1232  OrthancPluginRestOutput* output,
1233  const char* allowedMethods)
1234  {
1235  _OrthancPluginOutputPlusArgument params;
1236  params.output = output;
1237  params.argument = allowedMethods;
1238  context->InvokeService(context, _OrthancPluginService_SendMethodNotAllowed, &params);
1239  }
1240 
1241 
1242  typedef struct
1243  {
1244  OrthancPluginRestOutput* output;
1245  const char* key;
1246  const char* value;
1247  } _OrthancPluginSetHttpHeader;
1248 
1259  ORTHANC_PLUGIN_INLINE void OrthancPluginSetCookie(
1260  OrthancPluginContext* context,
1261  OrthancPluginRestOutput* output,
1262  const char* cookie,
1263  const char* value)
1264  {
1265  _OrthancPluginSetHttpHeader params;
1266  params.output = output;
1267  params.key = cookie;
1268  params.value = value;
1269  context->InvokeService(context, _OrthancPluginService_SetCookie, &params);
1270  }
1271 
1272 
1283  ORTHANC_PLUGIN_INLINE void OrthancPluginSetHttpHeader(
1284  OrthancPluginContext* context,
1285  OrthancPluginRestOutput* output,
1286  const char* key,
1287  const char* value)
1288  {
1289  _OrthancPluginSetHttpHeader params;
1290  params.output = output;
1291  params.key = key;
1292  params.value = value;
1293  context->InvokeService(context, _OrthancPluginService_SetHttpHeader, &params);
1294  }
1295 
1296 
1297  typedef struct
1298  {
1299  char** resultStringToFree;
1300  const char** resultString;
1301  int64_t* resultInt64;
1302  const char* key;
1303  OrthancPluginDicomInstance* instance;
1304  } _OrthancPluginAccessDicomInstance;
1305 
1306 
1317  ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceRemoteAet(
1318  OrthancPluginContext* context,
1319  OrthancPluginDicomInstance* instance)
1320  {
1321  const char* result;
1322 
1323  _OrthancPluginAccessDicomInstance params;
1324  memset(&params, 0, sizeof(params));
1325  params.resultString = &result;
1326  params.instance = instance;
1327 
1328  if (context->InvokeService(context, _OrthancPluginService_GetInstanceRemoteAet, &params))
1329  {
1330  /* Error */
1331  return NULL;
1332  }
1333  else
1334  {
1335  return result;
1336  }
1337  }
1338 
1339 
1349  ORTHANC_PLUGIN_INLINE int64_t OrthancPluginGetInstanceSize(
1350  OrthancPluginContext* context,
1351  OrthancPluginDicomInstance* instance)
1352  {
1353  int64_t size;
1354 
1355  _OrthancPluginAccessDicomInstance params;
1356  memset(&params, 0, sizeof(params));
1357  params.resultInt64 = &size;
1358  params.instance = instance;
1359 
1360  if (context->InvokeService(context, _OrthancPluginService_GetInstanceSize, &params))
1361  {
1362  /* Error */
1363  return -1;
1364  }
1365  else
1366  {
1367  return size;
1368  }
1369  }
1370 
1371 
1381  ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceData(
1382  OrthancPluginContext* context,
1383  OrthancPluginDicomInstance* instance)
1384  {
1385  const char* result;
1386 
1387  _OrthancPluginAccessDicomInstance params;
1388  memset(&params, 0, sizeof(params));
1389  params.resultString = &result;
1390  params.instance = instance;
1391 
1392  if (context->InvokeService(context, _OrthancPluginService_GetInstanceData, &params))
1393  {
1394  /* Error */
1395  return NULL;
1396  }
1397  else
1398  {
1399  return result;
1400  }
1401  }
1402 
1403 
1416  ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceJson(
1417  OrthancPluginContext* context,
1418  OrthancPluginDicomInstance* instance)
1419  {
1420  char* result;
1421 
1422  _OrthancPluginAccessDicomInstance params;
1423  memset(&params, 0, sizeof(params));
1424  params.resultStringToFree = &result;
1425  params.instance = instance;
1426 
1427  if (context->InvokeService(context, _OrthancPluginService_GetInstanceJson, &params))
1428  {
1429  /* Error */
1430  return NULL;
1431  }
1432  else
1433  {
1434  return result;
1435  }
1436  }
1437 
1438 
1453  ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceSimplifiedJson(
1454  OrthancPluginContext* context,
1455  OrthancPluginDicomInstance* instance)
1456  {
1457  char* result;
1458 
1459  _OrthancPluginAccessDicomInstance params;
1460  memset(&params, 0, sizeof(params));
1461  params.resultStringToFree = &result;
1462  params.instance = instance;
1463 
1464  if (context->InvokeService(context, _OrthancPluginService_GetInstanceSimplifiedJson, &params))
1465  {
1466  /* Error */
1467  return NULL;
1468  }
1469  else
1470  {
1471  return result;
1472  }
1473  }
1474 
1475 
1491  ORTHANC_PLUGIN_INLINE int OrthancPluginHasInstanceMetadata(
1492  OrthancPluginContext* context,
1493  OrthancPluginDicomInstance* instance,
1494  const char* metadata)
1495  {
1496  int64_t result;
1497 
1498  _OrthancPluginAccessDicomInstance params;
1499  memset(&params, 0, sizeof(params));
1500  params.resultInt64 = &result;
1501  params.instance = instance;
1502  params.key = metadata;
1503 
1504  if (context->InvokeService(context, _OrthancPluginService_HasInstanceMetadata, &params))
1505  {
1506  /* Error */
1507  return -1;
1508  }
1509  else
1510  {
1511  return (result != 0);
1512  }
1513  }
1514 
1515 
1528  ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceMetadata(
1529  OrthancPluginContext* context,
1530  OrthancPluginDicomInstance* instance,
1531  const char* metadata)
1532  {
1533  const char* result;
1534 
1535  _OrthancPluginAccessDicomInstance params;
1536  memset(&params, 0, sizeof(params));
1537  params.resultString = &result;
1538  params.instance = instance;
1539  params.key = metadata;
1540 
1541  if (context->InvokeService(context, _OrthancPluginService_GetInstanceMetadata, &params))
1542  {
1543  /* Error */
1544  return NULL;
1545  }
1546  else
1547  {
1548  return result;
1549  }
1550  }
1551 
1552 
1553 
1554  typedef struct
1555  {
1559  OrthancPluginFree free_;
1560  } _OrthancPluginRegisterStorageArea;
1561 
1575  ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterStorageArea(
1576  OrthancPluginContext* context,
1580  {
1581  _OrthancPluginRegisterStorageArea params;
1582  params.create_ = create;
1583  params.read_ = read;
1584  params.remove_ = remove;
1585 
1586 #ifdef __cplusplus
1587  params.free_ = ::free;
1588 #else
1589  params.free_ = free;
1590 #endif
1591 
1592  context->InvokeService(context, _OrthancPluginService_RegisterStorageArea, &params);
1593  }
1594 
1595 
1596 
1607  ORTHANC_PLUGIN_INLINE char *OrthancPluginGetOrthancPath(OrthancPluginContext* context)
1608  {
1609  char* result;
1610 
1611  _OrthancPluginRetrieveDynamicString params;
1612  params.result = &result;
1613  params.argument = NULL;
1614 
1615  if (context->InvokeService(context, _OrthancPluginService_GetOrthancPath, &params))
1616  {
1617  /* Error */
1618  return NULL;
1619  }
1620  else
1621  {
1622  return result;
1623  }
1624  }
1625 
1626 
1637  ORTHANC_PLUGIN_INLINE char *OrthancPluginGetOrthancDirectory(OrthancPluginContext* context)
1638  {
1639  char* result;
1640 
1641  _OrthancPluginRetrieveDynamicString params;
1642  params.result = &result;
1643  params.argument = NULL;
1644 
1645  if (context->InvokeService(context, _OrthancPluginService_GetOrthancDirectory, &params))
1646  {
1647  /* Error */
1648  return NULL;
1649  }
1650  else
1651  {
1652  return result;
1653  }
1654  }
1655 
1656 
1668  ORTHANC_PLUGIN_INLINE char *OrthancPluginGetConfigurationPath(OrthancPluginContext* context)
1669  {
1670  char* result;
1671 
1672  _OrthancPluginRetrieveDynamicString params;
1673  params.result = &result;
1674  params.argument = NULL;
1675 
1676  if (context->InvokeService(context, _OrthancPluginService_GetConfigurationPath, &params))
1677  {
1678  /* Error */
1679  return NULL;
1680  }
1681  else
1682  {
1683  return result;
1684  }
1685  }
1686 
1687 
1688 
1689  typedef struct
1690  {
1692  } _OrthancPluginOnChangeCallback;
1693 
1703  ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterOnChangeCallback(
1704  OrthancPluginContext* context,
1706  {
1707  _OrthancPluginOnChangeCallback params;
1708  params.callback = callback;
1709 
1710  context->InvokeService(context, _OrthancPluginService_RegisterOnChangeCallback, &params);
1711  }
1712 
1713 
1714 
1715 
1716 #ifdef __cplusplus
1717 }
1718 #endif
1719 
1720