Mercurial > hg > orthanc
comparison Plugins/Samples/Basic/Plugin.c @ 1249:40725595aaf0
Plugins can get/set global properties to save their configuration
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 15 Dec 2014 10:20:33 +0100 |
parents | f1c01451a8ee |
children | d6a65dc6d0ac |
comparison
equal
deleted
inserted
replaced
1248:db753e57934f | 1249:40725595aaf0 |
---|---|
278 | 278 |
279 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c) | 279 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c) |
280 { | 280 { |
281 OrthancPluginMemoryBuffer tmp; | 281 OrthancPluginMemoryBuffer tmp; |
282 char info[1024], *s; | 282 char info[1024], *s; |
283 int counter; | |
283 | 284 |
284 context = c; | 285 context = c; |
285 OrthancPluginLogWarning(context, "Sample plugin is initializing"); | 286 OrthancPluginLogWarning(context, "Sample plugin is initializing"); |
286 | 287 |
287 /* Check the version of the Orthanc core */ | 288 /* Check the version of the Orthanc core */ |
338 OrthancPluginFreeMemoryBuffer(context, &tmp); | 339 OrthancPluginFreeMemoryBuffer(context, &tmp); |
339 | 340 |
340 /* Play with PUT by defining a new target modality. */ | 341 /* Play with PUT by defining a new target modality. */ |
341 sprintf(info, "[ \"STORESCP\", \"localhost\", 2000 ]"); | 342 sprintf(info, "[ \"STORESCP\", \"localhost\", 2000 ]"); |
342 OrthancPluginRestApiPut(context, &tmp, "/modalities/demo", info, strlen(info)); | 343 OrthancPluginRestApiPut(context, &tmp, "/modalities/demo", info, strlen(info)); |
343 | 344 |
345 /* Play with global properties: A global counter is incremented | |
346 each time the plugin starts. */ | |
347 s = OrthancPluginGetGlobalProperty(context, 1024, "0"); | |
348 sscanf(s, "%d", &counter); | |
349 sprintf(info, "Number of times this plugin was started: %d", counter); | |
350 OrthancPluginLogWarning(context, info); | |
351 counter++; | |
352 sprintf(info, "%d", counter); | |
353 OrthancPluginSetGlobalProperty(context, 1024, info); | |
354 OrthancPluginFreeString(context, s); | |
355 | |
344 return 0; | 356 return 0; |
345 } | 357 } |
346 | 358 |
347 | 359 |
348 ORTHANC_PLUGINS_API void OrthancPluginFinalize() | 360 ORTHANC_PLUGINS_API void OrthancPluginFinalize() |