annotate Plugins/OrthancCPlugin/OrthancCPlugin.h @ 900:1b92ce45cc8d plugins

plugin doc
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 18 Jun 2014 14:02:02 +0200
parents bb0a51561016
children 7d88f3f4a3b3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
1 /**
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
2 * @defgroup CInterface C Interface
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
3 * @brief The C interface to create Orthanc plugins.
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
4 *
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
5 * These functions must be used to create C plugins for Orthanc.
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
6 **/
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
7
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
8
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 /**
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * Orthanc - A Lightweight, RESTful DICOM Store
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege,
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * Belgium
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 *
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * This program is free software: you can redistribute it and/or
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * modify it under the terms of the GNU General Public License as
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * published by the Free Software Foundation, either version 3 of the
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * License, or (at your option) any later version.
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * In addition, as a special exception, the copyright holders of this
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * program give permission to link the code of its release with the
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * OpenSSL project's "OpenSSL" library (or with modified versions of it
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * that use the same license as the "OpenSSL" library), and distribute
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * the linked executables. You must obey the GNU General Public License
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * in all respects for all of the code used other than "OpenSSL". If you
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * modify file(s) with this exception, you may extend this exception to
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * your version of the file(s), but you are not obligated to do so. If
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * you do not wish to do so, delete this exception statement from your
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * version. If you delete this exception statement from all source files
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * in the program, then also delete it here.
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 *
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 * This program is distributed in the hope that it will be useful, but
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 * WITHOUT ANY WARRANTY; without even the implied warranty of
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 * General Public License for more details.
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 *
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 * You should have received a copy of the GNU General Public License
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 **/
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 #pragma once
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
44 #include <stdio.h>
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
45 #include <string.h>
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
46
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 #ifdef WIN32
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 #define ORTHANC_PLUGINS_API __declspec(dllexport)
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 #else
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 #define ORTHANC_PLUGINS_API
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 #endif
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
898
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
54
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
55 /********************************************************************
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
56 ** Check that function inlining is properly supported. The use of
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
57 ** inlining is required, to avoid the duplication of object code
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
58 ** between two compilation modules that would use the Orthanc Plugin
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
59 ** API.
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
60 ********************************************************************/
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
61
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
62 /* If the auto-detection of the "inline" keyword below does not work
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
63 automatically and that your compiler is known to properly support
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
64 inlining, uncomment the following #define and adapt the definition
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
65 of "static inline". */
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
66
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
67 /* #define ORTHANC_PLUGIN_INLINE static inline */
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
68
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
69 #ifndef ORTHANC_PLUGIN_INLINE
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
70 # if __STDC_VERSION__ >= 199901L
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
71 /* This is C99 or above: http://predef.sourceforge.net/prestd.html */
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
72 # define ORTHANC_PLUGIN_INLINE static inline
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
73 # elif defined(__cplusplus)
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
74 /* This is C++ */
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
75 # define ORTHANC_PLUGIN_INLINE static inline
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
76 # elif defined(__GNUC__)
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
77 /* This is GCC running in C89 mode */
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
78 # define ORTHANC_PLUGIN_INLINE static __inline
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
79 # elif defined(_MSC_VER)
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
80 /* This is Visual Studio running in C89 mode */
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
81 # define ORTHANC_PLUGIN_INLINE static __inline
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
82 # else
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
83 # error Your compiler is not known to support the "inline" keyword
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
84 # endif
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
85 #endif
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
86
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
87
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
88
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
89 /********************************************************************
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
90 ** Inclusion of standard libaries.
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
91 ********************************************************************/
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
92
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
93 #ifdef _MSC_VER
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
94 #include "../../Resources/VisualStudio/stdint.h"
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
95 #else
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
96 #include <stdint.h>
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
97 #endif
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
98
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 #include <stdlib.h>
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
898
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
102
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
103 /********************************************************************
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
104 ** Definition of the Orthanc Plugin API.
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
105 ********************************************************************/
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
106
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
107 /** @{ */
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
108
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 #ifdef __cplusplus
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 extern "C"
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 {
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 #endif
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
894
690aeb4cb899 REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
114 typedef enum
690aeb4cb899 REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
115 {
896
c4053ac5db04 better plugni api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 894
diff changeset
116 OrthancPluginHttpMethod_Get = 1,
c4053ac5db04 better plugni api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 894
diff changeset
117 OrthancPluginHttpMethod_Post = 2,
c4053ac5db04 better plugni api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 894
diff changeset
118 OrthancPluginHttpMethod_Put = 3,
c4053ac5db04 better plugni api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 894
diff changeset
119 OrthancPluginHttpMethod_Delete = 4
c4053ac5db04 better plugni api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 894
diff changeset
120 } OrthancPluginHttpMethod;
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
122 typedef struct
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
123 {
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
124 OrthancPluginHttpMethod method;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
125
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
126 /* For GET requests */
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
127 const char* const* getKeys;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
128 const char* const* getValues;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
129 uint32_t getCount;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
130
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
131 /* For POST and PUT requests */
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
132 const char* body;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
133 uint32_t bodySize;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
134 } OrthancPluginHttpRequest;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
135
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
136 typedef enum
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 {
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
138 /* Generic services */
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
139 OrthancPluginService_LogInfo = 1,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
140 OrthancPluginService_LogWarning = 2,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
141 OrthancPluginService_LogError = 3,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
142
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
143 /* Registration of callbacks */
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
144 OrthancPluginService_RegisterRestCallback = 1000,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
145
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
146 /* Sending answers to REST calls */
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
147 OrthancPluginService_AnswerBuffer = 2000
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
148 } OrthancPluginService;
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
149
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
150
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
151
894
690aeb4cb899 REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
152
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
153 typedef struct _OrthancPluginRestOutput_t OrthancPluginRestOutput;
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
154
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
155 typedef int32_t (*OrthancPluginRestCallback) (
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
156 OrthancPluginRestOutput* output,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
157 const char* url,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
158 const OrthancPluginHttpRequest* request);
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
159
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
160 typedef struct _OrthancPluginContext_t
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
161 {
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
162 void* pluginsManager;
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
163 const char* orthancVersion;
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
164 void (*FreeBuffer) (void* buffer);
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
165 int32_t (*InvokeService) (struct _OrthancPluginContext_t* context,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
166 OrthancPluginService service,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
167 const void* params);
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
168 } OrthancPluginContext;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
169
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
171 typedef struct
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
172 {
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
173 const char* pathRegularExpression;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
174 OrthancPluginRestCallback callback;
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
175 } _OrthancPluginRestCallbackParams;
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
176
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
178 typedef struct
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
179 {
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
180 OrthancPluginRestOutput* output;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
181 const char* answer;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
182 uint32_t answerSize;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
183 const char* mimeType;
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
184 } _OrthancPluginAnswerBufferParams;
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
187 ORTHANC_PLUGIN_INLINE void OrthancPluginLogError(
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
188 OrthancPluginContext* context,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
189 const char* str)
898
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
190 {
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
191 context->InvokeService(context, OrthancPluginService_LogError, str);
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
192 }
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
193
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
194
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
195 ORTHANC_PLUGIN_INLINE void OrthancPluginLogWarning(
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
196 OrthancPluginContext* context,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
197 const char* str)
898
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
198 {
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
199 context->InvokeService(context, OrthancPluginService_LogWarning, str);
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
200 }
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
201
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
202
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
203 ORTHANC_PLUGIN_INLINE void OrthancPluginLogInfo(
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
204 OrthancPluginContext* context,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
205 const char* str)
898
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
206 {
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
207 context->InvokeService(context, OrthancPluginService_LogInfo, str);
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
208 }
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
209
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
210
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
211 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallback(
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
212 OrthancPluginContext* context,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
213 const char* pathRegularExpression,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
214 OrthancPluginRestCallback callback)
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
215 {
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
216 _OrthancPluginRestCallbackParams params;
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
217 params.pathRegularExpression = pathRegularExpression;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
218 params.callback = callback;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
219 context->InvokeService(context, OrthancPluginService_RegisterRestCallback, &params);
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
220 }
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
221
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
222
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
223 ORTHANC_PLUGIN_INLINE void OrthancPluginAnswerBuffer(
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
224 OrthancPluginContext* context,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
225 OrthancPluginRestOutput* output,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
226 const char* answer,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
227 uint32_t answerSize,
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
228 const char* mimeType)
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
229 {
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
230 _OrthancPluginAnswerBufferParams params;
899
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
231 params.output = output;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
232 params.answer = answer;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
233 params.answerSize = answerSize;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
234 params.mimeType = mimeType;
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
235 context->InvokeService(context, OrthancPluginService_AnswerBuffer, &params);
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
236 }
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
237
bb0a51561016 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 898
diff changeset
238
898
7000fc86fe62 improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 897
diff changeset
239
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 /**
894
690aeb4cb899 REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 888
diff changeset
241 Each plugin must define 4 functions, whose signature are:
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 - int32_t OrthancPluginInitialize(const OrthancPluginContext*);
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 - void OrthancPluginFinalize();
888
d44b845c1c89 recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 886
diff changeset
244 - const char* OrthancPluginGetName();
d44b845c1c89 recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 886
diff changeset
245 - const char* OrthancPluginGetVersion();
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 nm -C -D --defined-only libPluginTest.so
896
c4053ac5db04 better plugni api
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 894
diff changeset
248 **/
886
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 #ifdef __cplusplus
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 }
29087d728e0a plugin sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 #endif
900
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
253
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
254
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
255 /** @} */
1b92ce45cc8d plugin doc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 899
diff changeset
256