comparison Plugins/OrthancCPlugin/OrthancCPlugin.h @ 1039:5a5a4890ffca

check version in plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 17 Jul 2014 12:46:00 +0200
parents 6208ab500ffd
children d06186cdc502
comparison
equal deleted inserted replaced
1038:a53dc58edc5a 1039:5a5a4890ffca
79 #define ORTHANC_PLUGINS_API __declspec(dllexport) 79 #define ORTHANC_PLUGINS_API __declspec(dllexport)
80 #else 80 #else
81 #define ORTHANC_PLUGINS_API 81 #define ORTHANC_PLUGINS_API
82 #endif 82 #endif
83 83
84 #define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 0
85 #define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 8
86 #define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 1
87
84 88
85 89
86 /******************************************************************** 90 /********************************************************************
87 ** Check that function inlining is properly supported. The use of 91 ** Check that function inlining is properly supported. The use of
88 ** inlining is required, to avoid the duplication of object code 92 ** inlining is required, to avoid the duplication of object code
347 } 351 }
348 } 352 }
349 353
350 354
351 /** 355 /**
356 * @brief Check the version of Orthanc.
357 *
358 * This function checks whether the version of this C header is
359 * compatible with the current version of Orthanc. The result of
360 * this function should always be checked in the
361 * OrthancPluginInitialize() entry point of the plugin.
362 *
363 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
364 * @return 1 if and only if the versions are compatible. If the
365 * result is 0, the initialization of the plugin should fail.
366 **/
367 ORTHANC_PLUGIN_INLINE int OrthancPluginCheckVersion(
368 OrthancPluginContext* context)
369 {
370 int major, minor, revision;
371
372 /* Assume compatibility with the mainline */
373 if (!strcmp(context->orthancVersion, "mainline"))
374 {
375 printf("mainline\n");
376 return 1;
377 }
378
379 /* Parse the version of the Orthanc core */
380 if (
381 #ifdef _MSC_VER
382 sscanf_s
383 #else
384 sscanf
385 #endif
386 (context->orthancVersion, "%d.%d.%d", &major, &minor, &revision) != 3)
387 {
388 return 0;
389 }
390
391 /* Check the major number of the version */
392
393 if (major > ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER)
394 {
395 return 1;
396 }
397
398 if (major < ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER)
399 {
400 return 0;
401 }
402
403 /* Check the minor number of the version */
404
405 if (minor > ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER)
406 {
407 return 1;
408 }
409
410 if (minor < ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER)
411 {
412 return 0;
413 }
414
415 /* Check the revision number of the version */
416
417 if (revision >= ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER)
418 {
419 return 1;
420 }
421 else
422 {
423 return 0;
424 }
425 }
426
427
428 /**
352 * @brief Free a memory buffer. 429 * @brief Free a memory buffer.
353 * 430 *
354 * Free a memory buffer that was allocated by the core system of Orthanc. 431 * Free a memory buffer that was allocated by the core system of Orthanc.
355 * 432 *
356 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). 433 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().