comparison 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
comparison
equal deleted inserted replaced
899:bb0a51561016 900:1b92ce45cc8d
1 /**
2 * @defgroup CInterface C Interface
3 * @brief The C interface to create Orthanc plugins.
4 *
5 * These functions must be used to create C plugins for Orthanc.
6 **/
7
8
1 /** 9 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store 10 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, 11 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege,
4 * Belgium 12 * Belgium
5 * 13 *
31 39
32 40
33 #pragma once 41 #pragma once
34 42
35 43
44 #include <stdio.h>
45 #include <string.h>
46
36 #ifdef WIN32 47 #ifdef WIN32
37 #define ORTHANC_PLUGINS_API __declspec(dllexport) 48 #define ORTHANC_PLUGINS_API __declspec(dllexport)
38 #else 49 #else
39 #define ORTHANC_PLUGINS_API 50 #define ORTHANC_PLUGINS_API
40 #endif 51 #endif
91 102
92 /******************************************************************** 103 /********************************************************************
93 ** Definition of the Orthanc Plugin API. 104 ** Definition of the Orthanc Plugin API.
94 ********************************************************************/ 105 ********************************************************************/
95 106
107 /** @{ */
108
96 #ifdef __cplusplus 109 #ifdef __cplusplus
97 extern "C" 110 extern "C"
98 { 111 {
99 #endif 112 #endif
100
101 typedef struct OrthancPluginRestOutput_t OrthancPluginRestOutput;
102 113
103 typedef enum 114 typedef enum
104 { 115 {
105 OrthancPluginHttpMethod_Get = 1, 116 OrthancPluginHttpMethod_Get = 1,
106 OrthancPluginHttpMethod_Post = 2, 117 OrthancPluginHttpMethod_Post = 2,
107 OrthancPluginHttpMethod_Put = 3, 118 OrthancPluginHttpMethod_Put = 3,
108 OrthancPluginHttpMethod_Delete = 4 119 OrthancPluginHttpMethod_Delete = 4
109 } OrthancPluginHttpMethod; 120 } OrthancPluginHttpMethod;
110 121
122 typedef struct
123 {
124 OrthancPluginHttpMethod method;
125
126 /* For GET requests */
127 const char* const* getKeys;
128 const char* const* getValues;
129 uint32_t getCount;
130
131 /* For POST and PUT requests */
132 const char* body;
133 uint32_t bodySize;
134 } OrthancPluginHttpRequest;
135
111 typedef enum 136 typedef enum
112 { 137 {
113 /* Generic services */ 138 /* Generic services */
114 OrthancPluginService_LogInfo = 1, 139 OrthancPluginService_LogInfo = 1,
115 OrthancPluginService_LogWarning = 2, 140 OrthancPluginService_LogWarning = 2,
120 145
121 /* Sending answers to REST calls */ 146 /* Sending answers to REST calls */
122 OrthancPluginService_AnswerBuffer = 2000 147 OrthancPluginService_AnswerBuffer = 2000
123 } OrthancPluginService; 148 } OrthancPluginService;
124 149
125 typedef struct 150
126 { 151
127 OrthancPluginHttpMethod method; 152
128 153 typedef struct _OrthancPluginRestOutput_t OrthancPluginRestOutput;
129 /* For GET requests */ 154
130 const char* const* getKeys; 155 typedef int32_t (*OrthancPluginRestCallback) (
131 const char* const* getValues; 156 OrthancPluginRestOutput* output,
132 uint32_t getCount; 157 const char* url,
133 158 const OrthancPluginHttpRequest* request);
134 /* For POST and PUT requests */ 159
135 const char* body; 160 typedef struct _OrthancPluginContext_t
136 uint32_t bodySize; 161 {
137 } OrthancPluginHttpRequest; 162 void* pluginsManager;
138 163 const char* orthancVersion;
139 typedef int32_t (*OrthancPluginRestCallback) (OrthancPluginRestOutput* output, 164 void (*FreeBuffer) (void* buffer);
140 const char* url, 165 int32_t (*InvokeService) (struct _OrthancPluginContext_t* context,
141 const OrthancPluginHttpRequest* request); 166 OrthancPluginService service,
142 167 const void* params);
143 typedef struct OrthancPluginContext_t
144 {
145 void* pluginsManager;
146
147 const char* orthancVersion;
148 void (*FreeBuffer) (void* buffer);
149 int32_t (*InvokeService) (struct OrthancPluginContext_t* context,
150 OrthancPluginService service,
151 const void* params);
152 } OrthancPluginContext; 168 } OrthancPluginContext;
153 169
154 170
155 typedef struct 171 typedef struct
156 { 172 {
157 const char* pathRegularExpression; 173 const char* pathRegularExpression;
158 OrthancPluginRestCallback callback; 174 OrthancPluginRestCallback callback;
159 } OrthancPluginRestCallbackParams; 175 } _OrthancPluginRestCallbackParams;
160 176
161 177
162 typedef struct 178 typedef struct
163 { 179 {
164 OrthancPluginRestOutput* output; 180 OrthancPluginRestOutput* output;
165 const char* answer; 181 const char* answer;
166 uint32_t answerSize; 182 uint32_t answerSize;
167 const char* mimeType; 183 const char* mimeType;
168 } OrthancPluginAnswerBufferParams; 184 } _OrthancPluginAnswerBufferParams;
169 185
170 186
171 ORTHANC_PLUGIN_INLINE void OrthancPluginLogError(OrthancPluginContext* context, 187 ORTHANC_PLUGIN_INLINE void OrthancPluginLogError(
172 const char* str) 188 OrthancPluginContext* context,
189 const char* str)
173 { 190 {
174 context->InvokeService(context, OrthancPluginService_LogError, str); 191 context->InvokeService(context, OrthancPluginService_LogError, str);
175 } 192 }
176 193
177 194
178 ORTHANC_PLUGIN_INLINE void OrthancPluginLogWarning(OrthancPluginContext* context, 195 ORTHANC_PLUGIN_INLINE void OrthancPluginLogWarning(
179 const char* str) 196 OrthancPluginContext* context,
197 const char* str)
180 { 198 {
181 context->InvokeService(context, OrthancPluginService_LogWarning, str); 199 context->InvokeService(context, OrthancPluginService_LogWarning, str);
182 } 200 }
183 201
184 202
185 ORTHANC_PLUGIN_INLINE void OrthancPluginLogInfo(OrthancPluginContext* context, 203 ORTHANC_PLUGIN_INLINE void OrthancPluginLogInfo(
186 const char* str) 204 OrthancPluginContext* context,
205 const char* str)
187 { 206 {
188 context->InvokeService(context, OrthancPluginService_LogInfo, str); 207 context->InvokeService(context, OrthancPluginService_LogInfo, str);
189 } 208 }
190 209
191 210
192 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallback(OrthancPluginContext* context, 211 ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallback(
193 const char* pathRegularExpression, 212 OrthancPluginContext* context,
194 OrthancPluginRestCallback callback) 213 const char* pathRegularExpression,
195 { 214 OrthancPluginRestCallback callback)
196 OrthancPluginRestCallbackParams params; 215 {
216 _OrthancPluginRestCallbackParams params;
197 params.pathRegularExpression = pathRegularExpression; 217 params.pathRegularExpression = pathRegularExpression;
198 params.callback = callback; 218 params.callback = callback;
199 context->InvokeService(context, OrthancPluginService_RegisterRestCallback, &params); 219 context->InvokeService(context, OrthancPluginService_RegisterRestCallback, &params);
200 } 220 }
201 221
202 222
203 ORTHANC_PLUGIN_INLINE void OrthancPluginAnswerBuffer(OrthancPluginContext* context, 223 ORTHANC_PLUGIN_INLINE void OrthancPluginAnswerBuffer(
204 OrthancPluginRestOutput* output, 224 OrthancPluginContext* context,
205 const char* answer, 225 OrthancPluginRestOutput* output,
206 uint32_t answerSize, 226 const char* answer,
207 const char* mimeType) 227 uint32_t answerSize,
208 { 228 const char* mimeType)
209 OrthancPluginAnswerBufferParams params; 229 {
230 _OrthancPluginAnswerBufferParams params;
210 params.output = output; 231 params.output = output;
211 params.answer = answer; 232 params.answer = answer;
212 params.answerSize = answerSize; 233 params.answerSize = answerSize;
213 params.mimeType = mimeType; 234 params.mimeType = mimeType;
214 context->InvokeService(context, OrthancPluginService_AnswerBuffer, &params); 235 context->InvokeService(context, OrthancPluginService_AnswerBuffer, &params);
227 **/ 248 **/
228 249
229 #ifdef __cplusplus 250 #ifdef __cplusplus
230 } 251 }
231 #endif 252 #endif
253
254
255 /** @} */
256