# HG changeset patch # User Sebastien Jodogne # Date 1755079324 -7200 # Node ID 67c833e5dee640e0343cd8c0a9b145907c857758 # Parent 98219e09a9bafd9488d74c96a87f3a9c57cbaf37# Parent 6a7e91d753ae62d3df731422a661e2a8172ef6fa integration OrthancPython-4.4->mainline diff -r 6a7e91d753ae -r 67c833e5dee6 .reuse/dep5 --- a/.reuse/dep5 Wed Jan 22 16:18:14 2025 +0100 +++ b/.reuse/dep5 Wed Aug 13 12:02:04 2025 +0200 @@ -16,22 +16,21 @@ License: CC0-1.0 Files: - CodeAnalysis/CustomFunctions.json - CodeAnalysis/CustomMethods.json - CodeAnalysis/FunctionBody.mustache - CodeAnalysis/FunctionDocumentation.mustache + CodeAnalysis/*.json + CodeAnalysis/*.mustache Resources/valgrind-python.supp Copyright: 2020-2023 Osimis S.A. (Belgium), 2024-2025 Orthanc Team SRL (Belgium), 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain (Belgium) License: AGPL-3.0-or-later -Files: Resources/Orthanc/CMake/* Resources/Orthanc/Toolchains/* +Files: + Resources/Orthanc/CMake/* + Resources/Orthanc/Toolchains/* Copyright: 2012-2016 Sebastien Jodogne, University Hospital of Liege (Belgium), 2017-2023 Osimis S.A. (Belgium), 2024-2025 Orthanc Team SRL (Belgium), and 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain (Belgium) License: LGPL-3.0-or-later -Files: Resources/Orthanc/Plugins/* +Files: + Resources/Orthanc/OrthancPluginCodeModel.json + Resources/Orthanc/Plugins/* + Resources/Orthanc/Sdk-*/orthanc/OrthancCPlugin.h Copyright: 2012-2016 Sebastien Jodogne, University Hospital of Liege (Belgium), 2017-2023 Osimis S.A. (Belgium), 2024-2025 Orthanc Team SRL (Belgium), and 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain (Belgium) License: GPL-3.0-or-later - -Files: Resources/Orthanc/Sdk-1.10.0/orthanc/OrthancCPlugin.h -Copyright: 2012-2016 Sebastien Jodogne, University Hospital of Liege (Belgium), 2017-2022 Osimis S.A. (Belgium), and 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain (Belgium) -License: GPL-3.0-or-later diff -r 6a7e91d753ae -r 67c833e5dee6 CITATION.cff --- a/CITATION.cff Wed Jan 22 16:18:14 2025 +0100 +++ b/CITATION.cff Wed Aug 13 12:02:04 2025 +0200 @@ -10,5 +10,5 @@ doi: "10.1007/s10278-018-0082-y" license: "GPL-3.0-or-later" repository-code: "https://orthanc.uclouvain.be/hg/orthanc/" -version: 1.12.4 -date-released: 2024-06-05 +version: 1.12.9 +date-released: 2025-08-11 diff -r 6a7e91d753ae -r 67c833e5dee6 CMakeLists.txt --- a/CMakeLists.txt Wed Jan 22 16:18:14 2025 +0100 +++ b/CMakeLists.txt Wed Aug 13 12:02:04 2025 +0200 @@ -31,16 +31,23 @@ set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "mainline") set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg") else() - set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "1.12.4") + set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "1.12.9") set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web") endif() -include(${CMAKE_SOURCE_DIR}/OrthancSDKVersion.cmake) +set(ORTHANC_SDK_DEFAULT_VERSION "1.12.9") + +# This list must correspond to the content of "./Resources/SyncOrthancFolder.py" +set(ORTHANC_SDK_AVAILABLE_VERSIONS "1.7.2" "1.10.0" "1.12.6" "1.12.9") +##################################################################### +## Parameters of the build +##################################################################### + if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") # The Python version cannot be controlled on OS X (yet) - set(PYTHON_VERSION "3.6" CACHE STRING "Version of Python to be used") + set(PYTHON_VERSION "3.13" CACHE STRING "Version of Python to be used") endif() if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") @@ -50,23 +57,32 @@ set(PYTHON_WINDOWS_USE_RELEASE_LIBS ON CACHE BOOL "Use the release Python libraries when building with Microsoft Visual Studio, even when compiling in _DEBUG mode (set it to OFF if you require linking to a Python debug build)") endif() - - -# Parameters of the build +# Generic parameters set(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)") set(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages") set(ORTHANC_FRAMEWORK_SOURCE "${ORTHANC_FRAMEWORK_DEFAULT_SOURCE}" CACHE STRING "Source of the Orthanc framework (can be \"system\", \"hg\", \"archive\", \"web\" or \"path\")") set(ORTHANC_FRAMEWORK_VERSION "${ORTHANC_FRAMEWORK_DEFAULT_VERSION}" CACHE STRING "Version of the Orthanc framework") set(ORTHANC_FRAMEWORK_ARCHIVE "" CACHE STRING "Path to the Orthanc archive, if ORTHANC_FRAMEWORK_SOURCE is \"archive\"") set(ORTHANC_FRAMEWORK_ROOT "" CACHE STRING "Path to the Orthanc source directory, if ORTHANC_FRAMEWORK_SOURCE is \"path\"") -set(USE_FRAMEWORK_ORTHANC_SDK OFF CACHE BOOL "Whether to use the SDK from the Orthanc sources (for developers only, to support new features of the SDK that are still pending in the mainline)") # Advanced parameters to fine-tune linking against system libraries -set(ORTHANC_FRAMEWORK_STATIC OFF CACHE BOOL "If linking against the Orthanc framework system library, indicates whether this library was statically linked") -mark_as_advanced(ORTHANC_FRAMEWORK_STATIC) +set(USE_SYSTEM_ORTHANC_SDK ON CACHE BOOL "Use the system-wide version of the Orthanc plugin SDK") + +# Generate the documentation about the "ORTHANC_SDK_VERSION" option +set(tmp "Version of the Orthanc plugin SDK to use, if not using the system version (can be") +foreach(version IN LISTS ORTHANC_SDK_AVAILABLE_VERSIONS) + set(tmp "${tmp} ${version},") +endforeach() +set(tmp "${tmp} \"framework\", or \"path\")") + +set(ORTHANC_SDK_VERSION "${ORTHANC_SDK_DEFAULT_VERSION}" CACHE STRING "${tmp}") +set(ORTHANC_SDK_PATH "" CACHE STRING "Path to the orthanc/OrthancCPlugin.h file, if ORTHANC_SDK_VERSION is set to \"path\"") -# Download and setup the Orthanc framework +##################################################################### +## Download and setup the Orthanc framework +##################################################################### + include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake) if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system") @@ -81,11 +97,11 @@ else() include(${ORTHANC_FRAMEWORK_ROOT}/../Resources/CMake/OrthancFrameworkParameters.cmake) - - #set(ENABLE_MODULE_IMAGES OFF CACHE INTERNAL "") - #set(ENABLE_MODULE_JOBS OFF CACHE INTERNAL "") - #set(ENABLE_MODULE_DICOM OFF CACHE INTERNAL "") - + + set(ENABLE_MODULE_IMAGES OFF CACHE INTERNAL "") + set(ENABLE_MODULE_JOBS OFF CACHE INTERNAL "") + set(ENABLE_MODULE_DICOM OFF CACHE INTERNAL "") + include(${ORTHANC_FRAMEWORK_ROOT}/../Resources/CMake/OrthancFrameworkConfiguration.cmake) include_directories(${ORTHANC_FRAMEWORK_ROOT}) endif() @@ -94,11 +110,22 @@ include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/Plugins/OrthancPluginsExports.cmake) +##################################################################### +## Configure the Python library +##################################################################### + include(CheckIncludeFile) include(CheckIncludeFileCXX) include(CheckIncludeFiles) include(CheckLibraryExists) -include(FindPythonInterp) + +if(CMAKE_VERSION VERSION_GREATER "3.11") + find_package(Python REQUIRED COMPONENTS Interpreter) + set(PYTHON_EXECUTABLE ${Python_EXECUTABLE}) +else() + include(FindPythonInterp) + find_package(PythonInterp REQUIRED) +endif() if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") @@ -159,7 +186,9 @@ message(FATAL_ERROR "Error while computing the version information: ${Failure}") endif() - set(WINDOWS_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/Version.rc) + list(APPEND AUTOGENERATED_SOURCES + ${CMAKE_CURRENT_BINARY_DIR}/Version.rc + ) else() find_package(PkgConfig REQUIRED) @@ -177,26 +206,103 @@ endif() -if (USE_FRAMEWORK_ORTHANC_SDK) - include_directories( - ${ORTHANC_FRAMEWORK_ROOT}/../../OrthancServer/Plugins/Include - ) +##################################################################### +## Find the Orthanc SDK +##################################################################### + +if (STATIC_BUILD OR NOT USE_SYSTEM_ORTHANC_SDK) + if (ORTHANC_SDK_VERSION STREQUAL "framework") + include_directories(${ORTHANC_FRAMEWORK_ROOT}/../../OrthancServer/Plugins/Include) + set(ORTHANC_SDK ${ORTHANC_FRAMEWORK_ROOT}/../../OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h) + + elseif (ORTHANC_SDK_VERSION STREQUAL "path") + include_directories(${ORTHANC_SDK_PATH}) + set(ORTHANC_SDK ${ORTHANC_SDK_PATH}/orthanc/OrthancCPlugin.h) + + else() + list(FIND ORTHANC_SDK_AVAILABLE_VERSIONS ${ORTHANC_SDK_VERSION} tmp) + if (tmp EQUAL -1) + message(FATAL_ERROR "The source distribution of this plugin does not contain Orthanc SDK ${ORTHANC_SDK_VERSION}") + endif() + + include_directories(${CMAKE_SOURCE_DIR}/Resources/Orthanc/Sdk-${ORTHANC_SDK_VERSION}) + set(ORTHANC_SDK ${CMAKE_SOURCE_DIR}/Resources/Orthanc/Sdk-${ORTHANC_SDK_VERSION}/orthanc/OrthancCPlugin.h) + endif() + else() - include_directories( - ${CMAKE_SOURCE_DIR}/Resources/Orthanc/Sdk-${ORTHANC_SDK_VERSION} + find_path(ORTHANC_SDK_SYSTEM_DIR OrthancCPlugin.h + /usr/ + /usr/local/ + PATH_SUFFIXES include/orthanc ) + + if (${ORTHANC_SDK_SYSTEM_DIR} STREQUAL "ORTHANC_SDK_SYSTEM_DIR-NOTFOUND") + message(FATAL_ERROR "Cannot locate the orthanc/OrthancCPlugin.h header") + endif() + + set(ORTHANC_SDK ${ORTHANC_SDK_SYSTEM_DIR}/OrthancCPlugin.h) endif() + +##################################################################### +## Auto-generate the wrapper +##################################################################### + +set(ORTHANC_CODE_MODEL ${CMAKE_SOURCE_DIR}/Resources/Orthanc/OrthancPluginCodeModel.json) + +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/orthanc.pyi + ${AUTOGENERATED_DIR}/sdk/sdk.cpp + ${AUTOGENERATED_DIR}/sdk/sdk.h + + COMMAND + ${PYTHON_EXECUTABLE} + ${CMAKE_SOURCE_DIR}/CodeAnalysis/GenerateOrthancSDK.py + --sdk ${ORTHANC_SDK} + --model ${ORTHANC_CODE_MODEL} + --target ${AUTOGENERATED_DIR}/sdk/ + + COMMAND + ${CMAKE_COMMAND} -E copy + ${AUTOGENERATED_DIR}/sdk/orthanc.pyi + ${CMAKE_CURRENT_BINARY_DIR}/orthanc.pyi + + DEPENDS + ${CMAKE_SOURCE_DIR}/CodeAnalysis/ + ${ORTHANC_SDK} + ${ORTHANC_CODE_MODEL} + ) + +list(APPEND AUTOGENERATED_SOURCES + ${AUTOGENERATED_DIR}/sdk/sdk.cpp + ) + +add_custom_target( + AutogeneratedTarget + DEPENDS + ${AUTOGENERATED_SOURCES} + ) + + + +##################################################################### +## Build the plugin +##################################################################### + add_definitions( -DHAS_ORTHANC_EXCEPTION=0 ) include_directories( + ${AUTOGENERATED_DIR}/sdk/ + ${CMAKE_SOURCE_DIR}/Resources/Orthanc/Plugins/ + ${CMAKE_SOURCE_DIR}/Sources/ ${PYTHON_INCLUDE_DIRS} ) add_library(OrthancPython SHARED - Sources/Autogenerated/sdk.cpp + ${AUTOGENERATED_SOURCES} Sources/DicomScpCallbacks.cpp Sources/ICallbackRegistration.cpp Sources/IncomingHttpRequestFilter.cpp @@ -220,16 +326,22 @@ ${CMAKE_SOURCE_DIR}/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp ${BOOST_SOURCES} ${JSONCPP_SOURCES} - ${WINDOWS_RESOURCES} ) -if (CMAKE_COMPILER_IS_GNUCXX) +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR + CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # Don't report warnings about deprecated functions in the Orthanc SDK set_source_files_properties( - Sources/Autogenerated/sdk.cpp - PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations) + ${AUTOGENERATED_DIR}/sdk/sdk.cpp + COMPILE_FLAGS -Wno-deprecated-declarations) endif() +if (COMMAND DefineSourceBasenameForTarget) + DefineSourceBasenameForTarget(OrthancPython) +endif() + +add_dependencies(OrthancPython AutogeneratedTarget) + target_link_libraries(OrthancPython ${PYTHON_LIBRARIES}) add_definitions( @@ -242,17 +354,13 @@ SOVERSION ${PLUGIN_VERSION} ) -configure_file( - Sources/Autogenerated/orthanc.pyi - ${CMAKE_CURRENT_BINARY_DIR}/orthanc.pyi - COPYONLY) - install( TARGETS OrthancPython RUNTIME DESTINATION lib # Destination for Windows LIBRARY DESTINATION share/orthanc/plugins # Destination for Linux ) -if (COMMAND DefineSourceBasenameForTarget) - DefineSourceBasenameForTarget(OrthancPython) -endif() +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/orthanc.pyi + DESTINATION . + ) diff -r 6a7e91d753ae -r 67c833e5dee6 CodeAnalysis/ClassDocumentation.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CodeAnalysis/ClassDocumentation.json Wed Aug 13 12:02:04 2025 +0200 @@ -0,0 +1,17 @@ +{ + "OrthancPluginDicomInstance" : "DICOM instance managed by the Orthanc core", + "OrthancPluginDicomWebNode" : "Node visited by DICOMweb conversion", + "OrthancPluginFindAnswers" : "Answers to a DICOM C-FIND query", + "OrthancPluginFindMatcher" : "Matcher for DICOM C-FIND query", + "OrthancPluginFindQuery" : "DICOM C-FIND query", + "OrthancPluginImage" : "2D image managed by the Orthanc core", + "OrthancPluginJob" : "Orthanc job", + "OrthancPluginKeysValuesIterator" : "Iterator over the keys and values of a key-value store", + "OrthancPluginPeers" : "Orthanc peer", + "OrthancPluginRestOutput" : "Output for a call to the REST API of Orthanc", + "OrthancPluginServerChunkedRequestReader" : "Read for a chunked HTTP request", + "OrthancPluginStorageArea" : "Storage area plugin", + "OrthancPluginWebDavCollection" : "WebDAV collection", + "OrthancPluginWorklistAnswers" : "Answers to a DICOM C-FIND worklist query", + "OrthancPluginWorklistQuery" : "DICOM C-FIND worklist query" +} diff -r 6a7e91d753ae -r 67c833e5dee6 CodeAnalysis/CustomFunctions.json --- a/CodeAnalysis/CustomFunctions.json Wed Jan 22 16:18:14 2025 +0100 +++ b/CodeAnalysis/CustomFunctions.json Wed Aug 13 12:02:04 2025 +0200 @@ -373,5 +373,107 @@ } ], "return_sdk_type" : "void" + }, + + { + "comment" : "New in release 6.0", + "short_name" : "GetKeyValue", + "implementation" : "GetKeyValue", + "documentation" : { + "description" : [ "Get the value associated with a key in the Orthanc key-value store." ], + "args" : { + "storeId" : "The identifier of the key-value store.", + "key" : "The key." + }, + "return" : "The value, or None." + }, + "args" : [ + { + "sdk_name" : "storeId", + "sdk_type" : "const char *" + }, + { + "sdk_name" : "key", + "sdk_type" : "const char *" + } + ], + "return_sdk_type" : "OrthancPluginMemoryBuffer *", + "since_sdk" : [ 1, 12, 8 ] + }, + + { + "comment" : "New in release 6.0", + "short_name" : "DequeueValue", + "implementation" : "DequeueValue", + "documentation" : { + "description" : [ "Dequeue a value from a queue." ], + "args" : { + "queueId" : "The identifier of the queue.", + "origin" : "The position from where the value is dequeued (back for LIFO, front for FIFO)." + }, + "return" : "The value, or None if no more value is available." + }, + "args" : [ + { + "sdk_name" : "queueId", + "sdk_type" : "const char *" + }, + { + "sdk_name" : "origin", + "sdk_type" : "enumeration", + "sdk_enumeration" : "OrthancPluginQueueOrigin" + } + ], + "return_sdk_type" : "OrthancPluginMemoryBuffer *", + "since_sdk" : [ 1, 12, 8 ] + }, + + { + "comment" : "New in release 6.0", + "short_name" : "GetQueueSize", + "implementation" : "GetQueueSize", + "documentation" : { + "description" : [ "Get the number of elements in a queue." ], + "args" : { + "queueId" : "The identifier of the queue." + }, + "return" : "The value, or None." + }, + "args" : [ + { + "sdk_name" : "queueId", + "sdk_type" : "const char *" + } + ], + "return_sdk_type" : "uint64_t", + "since_sdk" : [ 1, 12, 8 ] + }, + + { + "comment" : "New in release 6.0", + "short_name" : "SetStableStatus", + "implementation" : "SetStableStatus", + "documentation" : { + "description" : [ "Change the Stable status of a resource" ], + "args" : { + "resourceId" : "The identifier of the resource.", + "stableStatus" : "The new stable status: 0 for Stable, 1 for Unstable." + }, + "return" : "A tuple with (The error code, An integer indicating wheter the status has changed (1) or not (0) during the execution of this command)." + }, + "args" : [ + { + "sdk_name" : "resourceId", + "sdk_type" : "const char *" + }, + { + "sdk_name" : "stableStatus", + "sdk_type" : "enumeration", + "sdk_enumeration" : "OrthancPluginStableStatus" + } + ], + "return_sdk_type" : "Tuple", + "since_sdk" : [ 1, 12, 9 ] } + ] diff -r 6a7e91d753ae -r 67c833e5dee6 CodeAnalysis/CustomMethods.json --- a/CodeAnalysis/CustomMethods.json Wed Jan 22 16:18:14 2025 +0100 +++ b/CodeAnalysis/CustomMethods.json Wed Aug 13 12:02:04 2025 +0200 @@ -65,5 +65,19 @@ ], "return_sdk_type" : "OrthancPluginMemoryBuffer *" } + ], + + "OrthancPluginKeysValuesIterator" : [ + { + "short_name" : "Next", + "implementation" : "KeysValuesIteratorNext", + "documentation" : { + "description" : [ "Advance to the next element in the iterator." ], + "return" : "Whether the iterator is done." + }, + "args" : [ + ], + "return_sdk_type" : "bool" + } ] } diff -r 6a7e91d753ae -r 67c833e5dee6 CodeAnalysis/FunctionBody.mustache --- a/CodeAnalysis/FunctionBody.mustache Wed Jan 22 16:18:14 2025 +0100 +++ b/CodeAnalysis/FunctionBody.mustache Wed Aug 13 12:02:04 2025 +0200 @@ -99,7 +99,7 @@ if (obj == NULL) { PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; + return NULL; } else { @@ -119,7 +119,7 @@ {{#args}}{{release}}{{/args}} if (code == OrthancPluginErrorCode_Success) { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); + return PyBytes_FromStringAndSize(reinterpret_cast(buffer.GetData()), buffer.GetSize()); } else { diff -r 6a7e91d753ae -r 67c833e5dee6 CodeAnalysis/GenerateOrthancSDK.py --- a/CodeAnalysis/GenerateOrthancSDK.py Wed Jan 22 16:18:14 2025 +0100 +++ b/CodeAnalysis/GenerateOrthancSDK.py Wed Aug 13 12:02:04 2025 +0200 @@ -31,17 +31,17 @@ import re import sys -ROOT = os.path.dirname(os.path.realpath(sys.argv[0])) +ROOT = os.path.dirname(os.path.realpath(__file__)) ## ## Extract the default SDK version ## -with open(os.path.join(os.path.dirname(__file__), '..', 'OrthancSDKVersion.cmake'), 'r') as f: - m = re.match('^set\(ORTHANC_SDK_VERSION "([^"]+)"\)$', f.read(), re.MULTILINE) - assert(m != None) - PLUGIN_SDK_VERSION = m.group(1) +with open(os.path.join(ROOT, '..', 'CMakeLists.txt'), 'r') as f: + m = re.findall(r'^set\(ORTHANC_SDK_DEFAULT_VERSION "([^"]+)"\)$', f.read(), re.MULTILINE) + assert(len(m) == 1) + ORTHANC_SDK_DEFAULT_VERSION = m[0] ## @@ -49,21 +49,81 @@ ## parser = argparse.ArgumentParser(description = 'Generate Python code to wrap the Orthanc SDK.') +parser.add_argument('--sdk', + default = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), + '../Resources/Orthanc/Sdk-%s/orthanc/OrthancCPlugin.h' % ORTHANC_SDK_DEFAULT_VERSION), + help = 'Path to the Orthanc SDK') parser.add_argument('--model', - default = os.path.join(os.path.dirname(__file__), - '../Resources/Orthanc/Sdk-%s/CodeModel.json' % PLUGIN_SDK_VERSION), - help = 'Input code model, as generated by the orthanc-java project') -parser.add_argument('--classes', - default = os.path.join(os.path.dirname(__file__), - '../Resources/Orthanc/Sdk-%s/ClassDocumentation.json' % PLUGIN_SDK_VERSION), - help = 'Input description of classes, as defined in the orthanc-java project') + default = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), + '../Resources/Orthanc/OrthancPluginCodeModel.json'), + help = 'Input code model, as generated by the orthanc project') parser.add_argument('--target', - default = os.path.join(os.path.dirname(__file__), - '../Sources/Autogenerated'), + default = os.path.join('/tmp/PythonAutogenerated/'), help = 'Target folder') args = parser.parse_args() +TARGET = os.path.realpath(args.target) + +try: + # "exist_ok = True" is not available on Python 2.7, which is still in use on our CIS for Ubuntu 16.04 + os.makedirs(TARGET) +except: + pass + + +## +## Detect the actual version of the Orthanc SDK +## + +with open(args.sdk, 'r') as f: + content = f.read() + + major = re.findall(r'#\s*define\s+ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER\s+([0-9.]+)$', content, re.MULTILINE) + minor = re.findall(r'#\s*define\s+ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER\s+([0-9.]+)$', content, re.MULTILINE) + revision = re.findall(r'#\s*define\s+ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER\s+([0-9.]+)$', content, re.MULTILINE) + assert(len(major) == 1) + assert(len(minor) == 1) + assert(len(revision) == 1) + + SDK_VERSION = [ int(major[0]), int(minor[0]), int(revision[0]) ] + + +def IsPrimitiveAvailable(item, key_prefix = ''): + since_sdk = item.get('since_sdk') + if since_sdk != None: + assert(len(since_sdk) == 3) + assert(len(SDK_VERSION) == 3) + if since_sdk[0] < SDK_VERSION[0]: + available = True + elif since_sdk[0] > SDK_VERSION[0]: + available = False + elif since_sdk[1] < SDK_VERSION[1]: + available = True + elif since_sdk[1] > SDK_VERSION[1]: + available = False + else: + available = since_sdk[2] <= SDK_VERSION[2] + + if not available: + name = item.get('name') + if name == None: + name = item.get('c_function') + if name == None: + name = item.get('short_name') + if name == None: + # For enumerations + key = item.get('key') + if key != None: + name = '%s_%s' % (key_prefix, key) + print('Primitive unavailable in SDK: %s (only available since %s)' % (name, '.'.join(map(str, since_sdk)))) + + return available + else: + return True + + +print('\n** Generating the Python wrapper for Orthanc SDK %d.%d.%d **' % (SDK_VERSION[0], SDK_VERSION[1], SDK_VERSION[2])) ## @@ -71,9 +131,6 @@ ## implemented (not autogenerated) ## -TARGET = os.path.realpath(args.target) - - with open(os.path.join(ROOT, 'CustomMethods.json'), 'r') as f: CUSTOM_METHODS = json.loads(f.read()) @@ -99,8 +156,8 @@ with open(args.model, 'r') as f: model = json.loads(f.read()) -with open(args.classes, 'r') as f: - classes_description = json.loads(f.read()) +with open(os.path.join(ROOT, 'ClassDocumentation.json'), 'r') as f: + classes_documentation = json.loads(f.read()) def ToUpperCase(name): @@ -132,9 +189,11 @@ return s -def GetShortName(name): +def GetShortName(name, parent_class = None): if not name.startswith('OrthancPlugin'): raise Exception() + elif parent_class != None and name.startswith(parent_class): + return name[len(parent_class):] else: return name[len('OrthancPlugin'):] @@ -151,6 +210,10 @@ 'type' : 'long int', 'format' : 'l', }, + 'int64_t' : { + 'type' : 'long long', + 'format' : 'L', + }, 'uint16_t' : { 'type' : 'unsigned short', 'format' : 'H', @@ -191,7 +254,7 @@ arg_type = GetShortName(a['sdk_enumeration']) elif a['sdk_type'] == 'const_object': arg_type = GetShortName(a['sdk_class']) - elif a['sdk_type'] in [ 'int32_t', 'uint32_t', 'uint8_t', 'uint16_t', 'uint64_t' ]: + elif a['sdk_type'] in [ 'int32_t', 'int64_t', 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t' ]: arg_type = 'int' elif a['sdk_type'] == 'Callable': # This is only used to generate the documentation file "orthanc.pyi" @@ -225,11 +288,17 @@ documentation['return_type'] = 'bytes' elif f['return_sdk_type'] in [ 'char *', 'const char *' ]: documentation['return_type'] = 'str' - elif f['return_sdk_type'] in [ 'int32_t', 'uint32_t', 'uint16_t', 'int64_t' ]: + elif f['return_sdk_type'] in [ 'int32_t', 'int64_t', 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t' ]: documentation['return_type'] = 'int' elif f['return_sdk_type'] == 'Dictionary': # This is only used to generate the documentation file "orthanc.pyi" documentation['return_type'] = 'dict' + elif f['return_sdk_type'] == 'Tuple': + # This is only used to generate the documentation file "orthanc.pyi" + documentation['return_type'] = 'tuple' + elif f['return_sdk_type'] == 'bool': + # This is only used to generate the documentation file "orthanc.pyi" + documentation['return_type'] = 'bool' else: raise Exception('Return type not implemented: %s' % f['return_sdk_type']) @@ -239,10 +308,10 @@ return documentation -def FormatFunction(f): +def FormatFunction(f, parent_class = None): answer = { 'c_function' : f['c_function'], - 'short_name' : GetShortName(f['c_function']), + 'short_name' : GetShortName(f['c_function'], parent_class), 'has_args' : len(f['args']) > 0, 'count_args' : len(f['args']), } @@ -260,7 +329,7 @@ 'python_type' : 'Py_buffer', 'release' : 'PyBuffer_Release(&%s);' % arg['name'], }) - tuple_format += 's*' + tuple_format += 'z*' elif arg['sdk_type'] == 'const char *': args.append({ 'name' : arg['name'], @@ -300,8 +369,11 @@ if arg['sdk_type'] == 'const void *': call_args.append(arg['name'] + '.buf') elif arg['sdk_type'] == 'const_void_pointer_with_size': - call_args.append(arg['name'] + '.buf') - call_args.append(arg['name'] + '.len') + # NB: The cast to "const char*" allows compatibility with functions whose + # signatures were incorrect at the time they were introduced, notably: + # - argument "body" of "OrthancPluginSendHttpStatus()" in 1.11.1 + call_args.append('reinterpret_cast(' + arg['name'] + '.len > 0 ? ' + arg['name'] + '.buf' + ' : NULL)') + call_args.append('(' + arg['name'] + '.len > 0 ? ' + arg['name'] + '.len' + ' : 0)') elif arg['sdk_type'] == 'enumeration': call_args.append('static_cast<%s>(%s)' % (arg['sdk_enumeration'], arg['name'])) elif arg['sdk_type'] == 'const_object': @@ -314,7 +386,7 @@ if f['return_sdk_type'] == 'void': answer['return_void'] = True - elif f['return_sdk_type'] in [ 'int32_t', 'uint32_t', 'int64_t' ]: + elif f['return_sdk_type'] in [ 'int32_t', 'int64_t', 'uint32_t', 'uint64_t' ]: answer['return_long'] = True elif f['return_sdk_type'] == 'OrthancPluginMemoryBuffer *': answer['return_bytes'] = True @@ -349,13 +421,15 @@ customFunctions = [] for f in model['global_functions']: - g = FormatFunction(f) - if g != None: - globalFunctions.append(g) + if IsPrimitiveAvailable(f): + g = FormatFunction(f) + if g != None: + globalFunctions.append(g) for f in CUSTOM_FUNCTIONS: - f['documentation'] = DocumentFunction(f) - customFunctions.append(f) + if IsPrimitiveAvailable(f): + f['documentation'] = DocumentFunction(f) + customFunctions.append(f) enumerations = [] @@ -364,13 +438,17 @@ ENUMERATION_TEMPLATE = f.read() for e in model['enumerations']: + if not IsPrimitiveAvailable(e): + continue + values = [] for value in e['values']: - values.append({ - 'key' : ToUpperCase(value['key']), - 'value' : value['value'], - 'documentation' : value['documentation'], - }) + if IsPrimitiveAvailable(value, key_prefix = e['name']): + values.append({ + 'key' : ToUpperCase(value['key']), + 'value' : value['value'], + 'documentation' : value['documentation'], + }) enumerations.append({ 'name' : e['name'], @@ -395,24 +473,29 @@ countDestructors = 0 for c in model['classes']: + if not IsPrimitiveAvailable(c): + continue + methods = [] for m in c['methods']: - g = FormatFunction(m) - if g != None: - g['self'] = ', self->object_' - methods.append(g) + if IsPrimitiveAvailable(m): + g = FormatFunction(m, parent_class = c['name']) + if g != None: + g['self'] = ', self->object_' + methods.append(g) custom_methods = [] if c['name'] in CUSTOM_METHODS: for custom_method in CUSTOM_METHODS[c['name']]: - custom_method['self'] = True # Indicates that this is a method - custom_method['documentation'] = DocumentFunction(custom_method) - custom_methods.append(custom_method) + if IsPrimitiveAvailable(custom_method): + custom_method['self'] = True # Indicates that this is a method + custom_method['documentation'] = DocumentFunction(custom_method) + custom_methods.append(custom_method) classes.append({ - 'description' : classes_description[c['name']], + 'description' : classes_documentation[c['name']], 'class_name' : c['name'], 'short_name' : GetShortName(c['name']), 'methods' : methods, @@ -489,12 +572,12 @@ print('\nNumber of automatically wrapped global functions: %d' % len(sortedGlobalFunctions)) print('Number of automatically wrapped methods: %d' % countWrappedMethods) print('Number of automatically wrapped destructors: %d' % countDestructors) + +totalWrapped = (len(sortedGlobalFunctions) + countWrappedMethods + countDestructors) +print('=> Total number of automatically wrapped functions (including destructors): %d\n' % totalWrapped) + print('Number of manually implemented (custom) global functions: %d' % len(sortedCustomFunctions)) print('Number of manually implemented (custom) methods: %d' % countCustomMethods) -totalWrapped = (len(sortedGlobalFunctions) + countWrappedMethods + countDestructors) -print('\nTotal number of automatically wrapped functions (including destructors): %d' % totalWrapped) -print('NB: This number must correspond to "ParseOrthancSDK.py" in "orthanc-java"') - total = totalWrapped + len(sortedCustomFunctions) + countCustomMethods -print('\n=> Total number of functions or methods in the Python SDK: %d\n' % total) +print('=> Total number of functions or methods in the Python wrapper: %d\n' % total) diff -r 6a7e91d753ae -r 67c833e5dee6 CodeAnalysis/README.txt --- a/CodeAnalysis/README.txt Wed Jan 22 16:18:14 2025 +0100 +++ b/CodeAnalysis/README.txt Wed Aug 13 12:02:04 2025 +0200 @@ -3,13 +3,14 @@ ============ This folder contains the Python script that reads the code model of -the Orthanc SDK that is generated by the "orthanc-java" project [1], -then automatically wraps this SDK as a Python extension module. - -The output of the script is written to "../Sources/Autogenerated". +the Orthanc SDK, and that automatically wraps this SDK as a Python +extension module. This script is automatically invoked during the +build by CMake. It necessitates the Pystache module [1] to be +installed in the Python environment used by CMake. Usage: $ ./GenerateOrthancSDK.py -[1] https://orthanc.uclouvain.be/book/plugins/java.html + +[1] https://pypi.org/project/pystache/ diff -r 6a7e91d753ae -r 67c833e5dee6 CodeAnalysis/sdk.cpp.mustache --- a/CodeAnalysis/sdk.cpp.mustache Wed Jan 22 16:18:14 2025 +0100 +++ b/CodeAnalysis/sdk.cpp.mustache Wed Aug 13 12:02:04 2025 +0200 @@ -27,12 +27,13 @@ // WARNING: Auto-generated file. Do not modify it by hand. -#include "sdk.h" +#include // Must be before "sdk.h" +#include "./sdk.h" -#include "../PythonLock.h" -#include "../PythonThreadsAllower.h" +#include +#include -#include "../../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" +#include {{#enumerations}} #include "./sdk_{{name}}.impl.h" diff -r 6a7e91d753ae -r 67c833e5dee6 CodeAnalysis/sdk.h.mustache --- a/CodeAnalysis/sdk.h.mustache Wed Jan 22 16:18:14 2025 +0100 +++ b/CodeAnalysis/sdk.h.mustache Wed Aug 13 12:02:04 2025 +0200 @@ -29,8 +29,6 @@ #pragma once -#include "../PythonHeaderWrapper.h" - void RegisterOrthancSdk(PyObject* module); PyMethodDef* GetOrthancSdkFunctions(); diff -r 6a7e91d753ae -r 67c833e5dee6 NEWS --- a/NEWS Wed Jan 22 16:18:14 2025 +0100 +++ b/NEWS Wed Aug 13 12:02:04 2025 +0200 @@ -1,6 +1,27 @@ Pending changes in the mainline =============================== + +Version 6.0 (2025-08-12) +======================== + +=> Maximum SDK version: 1.12.9 (default) <= +=> Minimum SDK version: 1.7.2 <= + +* The auto-generation of the Python wrapper is now part of the build, + to exploit the ORTHANC_PLUGIN_SINCE_SDK macro. This provides backward + compatibility with the SDK that is actually installed on the system +* The plugin now uses the code model that is part of the core "orthanc" project +* Added Windows builder for Python 3.13 +* Added Docker-based builder scripts for Debian 13 (trixie) + + +Version 5.0 (2025-01-22) +======================== + +=> Minimum SDK version: 1.12.6 <= + +* Added "orthanc.RestOutput.StartStreamAnswer()" and "orthanc.RestOutput.SendStreamChunk()" * In "orthanc.pyi", enumerations are not tagged as deriving from "enum.Enum" anymore: https://github.com/orthanc-server/orthanc-builder/issues/21 * Docker-based builder scripts for Debian 12 (bookworm) diff -r 6a7e91d753ae -r 67c833e5dee6 OrthancSDKVersion.cmake --- a/OrthancSDKVersion.cmake Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -set(ORTHANC_SDK_VERSION "1.10.0") diff -r 6a7e91d753ae -r 67c833e5dee6 README --- a/README Wed Jan 22 16:18:14 2025 +0100 +++ b/README Wed Aug 13 12:02:04 2025 +0200 @@ -17,6 +17,14 @@ Orthanc Book: https://orthanc.uclouvain.be/book/plugins/python.html +Note that since version 6.0 of this plugin, the build process requires +the Pystache module to be installed in the Python environment used by +CMake: +https://pypi.org/project/pystache/ + +On Debian/Ubuntu environments, it is sufficient to install the +"python3-pystache" package. This dependency is not needed at runtime. + Contributing ------------ diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/BuildAllWindows.sh --- a/Resources/Builders/BuildAllWindows.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/BuildAllWindows.sh Wed Aug 13 12:02:04 2025 +0200 @@ -68,6 +68,9 @@ bash ${DIR}/MinGW32-Python3.12/docker-compile.sh Release cp ${DIR}/../../docker-build/lib/libOrthancPython.dll ${TARGET}/OrthancPython-Win32-Python3.12-${VERSION}.dll +bash ${DIR}/MinGW32-Python3.13/docker-compile.sh Release +cp ${DIR}/../../docker-build/lib/libOrthancPython.dll ${TARGET}/OrthancPython-Win32-Python3.13-${VERSION}.dll + ## Windows 64 @@ -91,3 +94,6 @@ bash ${DIR}/MinGW64-Python3.12/docker-compile.sh Release cp ${DIR}/../../docker-build/lib/libOrthancPython.dll ${TARGET}/OrthancPython-Win64-Python3.12-${VERSION}.dll + +bash ${DIR}/MinGW64-Python3.13/docker-compile.sh Release +cp ${DIR}/../../docker-build/lib/libOrthancPython.dll ${TARGET}/OrthancPython-Win64-Python3.13-${VERSION}.dll diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/Debian/docker-internal.sh --- a/Resources/Builders/Debian/docker-internal.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/Debian/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -37,6 +37,11 @@ groupadd -g ${GROUP_ID} -r orthanc useradd -u ${USER_ID} -r -g orthanc orthanc +# This line is needed since the release of Debian 13 (trixie) +if [ "${DEBIAN_VERSION}" = "buster" ]; then + sed -i s/deb.debian.org/archive.debian.org/g /etc/apt/sources.list +fi + if [ "${DEBIAN_VERSION}" = "bullseye" ]; then MERCURIAL_PACKAGES=python else @@ -44,7 +49,7 @@ fi apt-get update -DEBIAN_FRONTEND=noninteractive apt-get -y install nano build-essential unzip cmake pkg-config libpython3-dev curl ${MERCURIAL_PACKAGES} +DEBIAN_FRONTEND=noninteractive apt-get -y install nano build-essential unzip cmake pkg-config libpython3-dev curl python3-pystache ${MERCURIAL_PACKAGES} apt-get -y clean rm -rf /var/lib/apt/lists/* @@ -64,10 +69,11 @@ mkdir /tmp/source-writeable -cp -r /source/CMakeLists.txt /tmp/source-writeable/ +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ cp -r /source/Sources /tmp/source-writeable/ -cp -r /source/Resources /tmp/source-writeable/ -cp -r /source/OrthancSDKVersion.cmake /tmp/source-writeable/ mkdir /tmp/build cd /tmp/build @@ -89,3 +95,4 @@ # running "./debian-{distro}-compile.sh" script. This allows to avoid # files owned by the "root" user on the host filesystem. su -c "cp /tmp/build/libOrthancPython.so /target" orthanc +su -c "cp /tmp/build/orthanc.pyi /target" orthanc diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/Debian/docker-trixie-compile.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Builders/Debian/docker-trixie-compile.sh Wed Aug 13 12:02:04 2025 +0200 @@ -0,0 +1,51 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain +# SPDX-License-Identifier: AGPL-3.0-or-later + +## +## Python plugin for Orthanc +## Copyright (C) 2020-2023 Osimis S.A., Belgium +## Copyright (C) 2024-2025 Orthanc Team SRL, Belgium +## Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium +## +## This program is free software: you can redistribute it and/or +## modify it under the terms of the GNU Affero General Public License +## as published by the Free Software Foundation, either version 3 of +## the License, or (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Affero General Public License for more details. +## +## You should have received a copy of the GNU Affero General Public License +## along with this program. If not, see . +## + + +set -ex + +if [ "$1" != "Debug" -a "$1" != "Release" ]; then + echo "Please provide build type: Debug or Release" + exit -1 +fi + +if [ -t 1 ]; then + # TTY is available => use interactive mode + DOCKER_FLAGS='-i' +fi + +ROOT_DIR=`dirname $(readlink -f $0)`/../../.. + +mkdir -p ${ROOT_DIR}/docker-build-trixie/ + +docker pull debian:trixie-slim + +docker run -t ${DOCKER_FLAGS} --rm \ + -v ${ROOT_DIR}:/source:ro \ + -v ${ROOT_DIR}/docker-build-trixie:/target:rw \ + debian:trixie-slim \ + bash /source/Resources/Builders/Debian/docker-internal.sh $1 trixie 3.13 $(id -u) $(id -g) + +ls -lR ${ROOT_DIR}/docker-build-trixie/ diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/Dockerfile-MinGW-BuildEnvironment --- a/Resources/Builders/Dockerfile-MinGW-BuildEnvironment Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/Dockerfile-MinGW-BuildEnvironment Wed Aug 13 12:02:04 2025 +0200 @@ -24,12 +24,12 @@ # 2021-09-15: We don't use "debian:bullseye-slim", as the "mercurial" package # fails to install on CBlue -FROM debian:buster-slim +FROM debian:bookworm-slim MAINTAINER Sebastien Jodogne LABEL Description="Orthanc, free DICOM server" Vendor="The Orthanc project" RUN apt-get -y clean && apt-get -y update && \ DEBIAN_FRONTEND=noninteractive apt-get -y install \ - nano unzip cmake mingw-w64 patch wget bzip2 python mercurial && \ + nano unzip cmake mingw-w64 patch wget bzip2 python3 mercurial python3-pystache && \ apt-get clean && rm -rf /var/lib/apt/lists/* diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW32-Python2.7/docker-internal.sh --- a/Resources/Builders/MinGW32-Python2.7/docker-internal.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/MinGW32-Python2.7/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -28,10 +28,11 @@ mkdir /tmp/source-writeable -cp -r /source/CMakeLists.txt /tmp/source-writeable/ +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ cp -r /source/Sources /tmp/source-writeable/ -cp -r /source/Resources /tmp/source-writeable/ -cp -r /source/OrthancSDKVersion.cmake /tmp/source-writeable/ mkdir /tmp/build cd /tmp/build diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW32-Python3.10/docker-internal.sh --- a/Resources/Builders/MinGW32-Python3.10/docker-internal.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/MinGW32-Python3.10/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -28,10 +28,11 @@ mkdir /tmp/source-writeable -cp -r /source/CMakeLists.txt /tmp/source-writeable/ +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ cp -r /source/Sources /tmp/source-writeable/ -cp -r /source/Resources /tmp/source-writeable/ -cp -r /source/OrthancSDKVersion.cmake /tmp/source-writeable/ mkdir /tmp/build cd /tmp/build diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW32-Python3.11/docker-internal.sh --- a/Resources/Builders/MinGW32-Python3.11/docker-internal.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/MinGW32-Python3.11/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -28,10 +28,11 @@ mkdir /tmp/source-writeable -cp -r /source/CMakeLists.txt /tmp/source-writeable/ +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ cp -r /source/Sources /tmp/source-writeable/ -cp -r /source/Resources /tmp/source-writeable/ -cp -r /source/OrthancSDKVersion.cmake /tmp/source-writeable/ mkdir /tmp/build cd /tmp/build diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW32-Python3.12/docker-internal.sh --- a/Resources/Builders/MinGW32-Python3.12/docker-internal.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/MinGW32-Python3.12/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -28,10 +28,11 @@ mkdir /tmp/source-writeable -cp -r /source/CMakeLists.txt /tmp/source-writeable/ +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ cp -r /source/Sources /tmp/source-writeable/ -cp -r /source/Resources /tmp/source-writeable/ -cp -r /source/OrthancSDKVersion.cmake /tmp/source-writeable/ mkdir /tmp/build cd /tmp/build diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW32-Python3.13/docker-compile.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Builders/MinGW32-Python3.13/docker-compile.sh Wed Aug 13 12:02:04 2025 +0200 @@ -0,0 +1,55 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain +# SPDX-License-Identifier: AGPL-3.0-or-later + +## +## Python plugin for Orthanc +## Copyright (C) 2020-2023 Osimis S.A., Belgium +## Copyright (C) 2024-2025 Orthanc Team SRL, Belgium +## Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium +## +## This program is free software: you can redistribute it and/or +## modify it under the terms of the GNU Affero General Public License +## as published by the Free Software Foundation, either version 3 of +## the License, or (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Affero General Public License for more details. +## +## You should have received a copy of the GNU Affero General Public License +## along with this program. If not, see . +## + + +set -ex + +if [ "$1" != "Debug" -a "$1" != "Release" ]; then + echo "Please provide build type: Debug or Release" + exit -1 +fi + +if [ -t 1 ]; then + # TTY is available => use interactive mode + DOCKER_FLAGS='-i' +fi + +ROOT_DIR=`dirname $(readlink -f $0)`/../../.. + +mkdir -p ${ROOT_DIR}/docker-build/ + +( cd ${ROOT_DIR}/Resources/Builders/ && \ + docker build \ + -f ./Dockerfile-MinGW-BuildEnvironment \ + -t mingw-python-build . ) + +docker run -t ${DOCKER_FLAGS} --rm \ + --user $(id -u):$(id -g) \ + -v ${ROOT_DIR}:/source:ro \ + -v ${ROOT_DIR}/docker-build:/target:rw \ + mingw-python-build \ + bash /source/Resources/Builders/MinGW32-Python3.13/docker-internal.sh $1 + +ls -lR ${ROOT_DIR}/docker-build/ diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW32-Python3.13/docker-internal.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Builders/MinGW32-Python3.13/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -0,0 +1,65 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain +# SPDX-License-Identifier: AGPL-3.0-or-later + +## +## Python plugin for Orthanc +## Copyright (C) 2020-2023 Osimis S.A., Belgium +## Copyright (C) 2024-2025 Orthanc Team SRL, Belgium +## Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium +## +## This program is free software: you can redistribute it and/or +## modify it under the terms of the GNU Affero General Public License +## as published by the Free Software Foundation, either version 3 of +## the License, or (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Affero General Public License for more details. +## +## You should have received a copy of the GNU Affero General Public License +## along with this program. If not, see . +## + + +set -ex + +mkdir /tmp/source-writeable + +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ +cp -r /source/Sources /tmp/source-writeable/ + +mkdir /tmp/build +cd /tmp/build + +wget https://orthanc.uclouvain.be/downloads/third-party-downloads/Python/python-3.13.2-win32.zip +unzip python-3.13.2-win32.zip + +if [ "$1" == "Release" ]; then + LIBRARY_NAME=python313.lib +else + LIBRARY_NAME=python313_d.lib +fi + +cmake /tmp/source-writeable/ \ + -DCMAKE_BUILD_TYPE=$1 \ + -DSTATIC_BUILD=ON \ + -DUSE_LEGACY_BOOST=ON \ + -DPYTHON_VERSION=3.12 \ + -DPYTHON_LIBRARY_NAME=${LIBRARY_NAME} \ + -DPYTHON_WINDOWS_ROOT=/tmp/build/python-3.13.2-win32/ \ + -DCMAKE_TOOLCHAIN_FILE=/source/Resources/Orthanc/Toolchains/MinGW-W64-Toolchain32.cmake \ + -DCMAKE_INSTALL_PREFIX=/target + +make -j`nproc` + +if [ "$1" == "Release" ]; then + i686-w64-mingw32-strip ./libOrthancPython.dll +fi + +make install diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW32-Python3.7/docker-internal.sh --- a/Resources/Builders/MinGW32-Python3.7/docker-internal.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/MinGW32-Python3.7/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -28,10 +28,11 @@ mkdir /tmp/source-writeable -cp -r /source/CMakeLists.txt /tmp/source-writeable/ +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ cp -r /source/Sources /tmp/source-writeable/ -cp -r /source/Resources /tmp/source-writeable/ -cp -r /source/OrthancSDKVersion.cmake /tmp/source-writeable/ mkdir /tmp/build cd /tmp/build diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW32-Python3.8/docker-internal.sh --- a/Resources/Builders/MinGW32-Python3.8/docker-internal.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/MinGW32-Python3.8/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -28,10 +28,11 @@ mkdir /tmp/source-writeable -cp -r /source/CMakeLists.txt /tmp/source-writeable/ +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ cp -r /source/Sources /tmp/source-writeable/ -cp -r /source/Resources /tmp/source-writeable/ -cp -r /source/OrthancSDKVersion.cmake /tmp/source-writeable/ mkdir /tmp/build cd /tmp/build diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW32-Python3.9/docker-internal.sh --- a/Resources/Builders/MinGW32-Python3.9/docker-internal.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/MinGW32-Python3.9/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -28,10 +28,11 @@ mkdir /tmp/source-writeable -cp -r /source/CMakeLists.txt /tmp/source-writeable/ +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ cp -r /source/Sources /tmp/source-writeable/ -cp -r /source/Resources /tmp/source-writeable/ -cp -r /source/OrthancSDKVersion.cmake /tmp/source-writeable/ mkdir /tmp/build cd /tmp/build diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW64-Python2.7/docker-internal.sh --- a/Resources/Builders/MinGW64-Python2.7/docker-internal.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/MinGW64-Python2.7/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -28,10 +28,11 @@ mkdir /tmp/source-writeable -cp -r /source/CMakeLists.txt /tmp/source-writeable/ +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ cp -r /source/Sources /tmp/source-writeable/ -cp -r /source/Resources /tmp/source-writeable/ -cp -r /source/OrthancSDKVersion.cmake /tmp/source-writeable/ mkdir /tmp/build cd /tmp/build diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW64-Python3.10/docker-internal.sh --- a/Resources/Builders/MinGW64-Python3.10/docker-internal.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/MinGW64-Python3.10/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -28,10 +28,11 @@ mkdir /tmp/source-writeable -cp -r /source/CMakeLists.txt /tmp/source-writeable/ +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ cp -r /source/Sources /tmp/source-writeable/ -cp -r /source/Resources /tmp/source-writeable/ -cp -r /source/OrthancSDKVersion.cmake /tmp/source-writeable/ mkdir /tmp/build cd /tmp/build diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW64-Python3.11/docker-internal.sh --- a/Resources/Builders/MinGW64-Python3.11/docker-internal.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/MinGW64-Python3.11/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -28,10 +28,11 @@ mkdir /tmp/source-writeable -cp -r /source/CMakeLists.txt /tmp/source-writeable/ +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ cp -r /source/Sources /tmp/source-writeable/ -cp -r /source/Resources /tmp/source-writeable/ -cp -r /source/OrthancSDKVersion.cmake /tmp/source-writeable/ mkdir /tmp/build cd /tmp/build diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW64-Python3.12/docker-internal.sh --- a/Resources/Builders/MinGW64-Python3.12/docker-internal.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/MinGW64-Python3.12/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -28,10 +28,11 @@ mkdir /tmp/source-writeable -cp -r /source/CMakeLists.txt /tmp/source-writeable/ +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ cp -r /source/Sources /tmp/source-writeable/ -cp -r /source/Resources /tmp/source-writeable/ -cp -r /source/OrthancSDKVersion.cmake /tmp/source-writeable/ mkdir /tmp/build cd /tmp/build diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW64-Python3.13/docker-compile.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Builders/MinGW64-Python3.13/docker-compile.sh Wed Aug 13 12:02:04 2025 +0200 @@ -0,0 +1,55 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain +# SPDX-License-Identifier: AGPL-3.0-or-later + +## +## Python plugin for Orthanc +## Copyright (C) 2020-2023 Osimis S.A., Belgium +## Copyright (C) 2024-2025 Orthanc Team SRL, Belgium +## Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium +## +## This program is free software: you can redistribute it and/or +## modify it under the terms of the GNU Affero General Public License +## as published by the Free Software Foundation, either version 3 of +## the License, or (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Affero General Public License for more details. +## +## You should have received a copy of the GNU Affero General Public License +## along with this program. If not, see . +## + + +set -ex + +if [ "$1" != "Debug" -a "$1" != "Release" ]; then + echo "Please provide build type: Debug or Release" + exit -1 +fi + +if [ -t 1 ]; then + # TTY is available => use interactive mode + DOCKER_FLAGS='-i' +fi + +ROOT_DIR=`dirname $(readlink -f $0)`/../../.. + +mkdir -p ${ROOT_DIR}/docker-build/ + +( cd ${ROOT_DIR}/Resources/Builders/ && \ + docker build \ + -f ./Dockerfile-MinGW-BuildEnvironment \ + -t mingw-python-build . ) + +docker run -t ${DOCKER_FLAGS} --rm \ + --user $(id -u):$(id -g) \ + -v ${ROOT_DIR}:/source:ro \ + -v ${ROOT_DIR}/docker-build:/target:rw \ + mingw-python-build \ + bash /source/Resources/Builders/MinGW64-Python3.13/docker-internal.sh $1 + +ls -lR ${ROOT_DIR}/docker-build/ diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW64-Python3.13/docker-internal.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Builders/MinGW64-Python3.13/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -0,0 +1,65 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain +# SPDX-License-Identifier: AGPL-3.0-or-later + +## +## Python plugin for Orthanc +## Copyright (C) 2020-2023 Osimis S.A., Belgium +## Copyright (C) 2024-2025 Orthanc Team SRL, Belgium +## Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium +## +## This program is free software: you can redistribute it and/or +## modify it under the terms of the GNU Affero General Public License +## as published by the Free Software Foundation, either version 3 of +## the License, or (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Affero General Public License for more details. +## +## You should have received a copy of the GNU Affero General Public License +## along with this program. If not, see . +## + + +set -ex + +mkdir /tmp/source-writeable + +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ +cp -r /source/Sources /tmp/source-writeable/ + +mkdir /tmp/build +cd /tmp/build + +wget https://orthanc.uclouvain.be/downloads/third-party-downloads/Python/python-3.13.2-win64.zip +unzip python-3.13.2-win64.zip + +if [ "$1" == "Release" ]; then + LIBRARY_NAME=python313.lib +else + LIBRARY_NAME=python313_d.lib +fi + +cmake /tmp/source-writeable/ \ + -DCMAKE_BUILD_TYPE=$1 \ + -DSTATIC_BUILD=ON \ + -DUSE_LEGACY_BOOST=ON \ + -DPYTHON_VERSION=3.12 \ + -DPYTHON_LIBRARY_NAME=${LIBRARY_NAME} \ + -DPYTHON_WINDOWS_ROOT=/tmp/build/python-3.13.2-win64 \ + -DCMAKE_TOOLCHAIN_FILE=/source/Resources/Orthanc/Toolchains/MinGW-W64-Toolchain64.cmake \ + -DCMAKE_INSTALL_PREFIX=/target + +make -j`nproc` + +if [ "$1" == "Release" ]; then + x86_64-w64-mingw32-strip ./libOrthancPython.dll +fi + +make install diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW64-Python3.7/docker-internal.sh --- a/Resources/Builders/MinGW64-Python3.7/docker-internal.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/MinGW64-Python3.7/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -28,10 +28,11 @@ mkdir /tmp/source-writeable -cp -r /source/CMakeLists.txt /tmp/source-writeable/ +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ cp -r /source/Sources /tmp/source-writeable/ -cp -r /source/Resources /tmp/source-writeable/ -cp -r /source/OrthancSDKVersion.cmake /tmp/source-writeable/ mkdir /tmp/build cd /tmp/build diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW64-Python3.8/docker-internal.sh --- a/Resources/Builders/MinGW64-Python3.8/docker-internal.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/MinGW64-Python3.8/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -28,10 +28,11 @@ mkdir /tmp/source-writeable -cp -r /source/CMakeLists.txt /tmp/source-writeable/ +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ cp -r /source/Sources /tmp/source-writeable/ -cp -r /source/Resources /tmp/source-writeable/ -cp -r /source/OrthancSDKVersion.cmake /tmp/source-writeable/ mkdir /tmp/build cd /tmp/build diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Builders/MinGW64-Python3.9/docker-internal.sh --- a/Resources/Builders/MinGW64-Python3.9/docker-internal.sh Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Builders/MinGW64-Python3.9/docker-internal.sh Wed Aug 13 12:02:04 2025 +0200 @@ -28,10 +28,11 @@ mkdir /tmp/source-writeable -cp -r /source/CMakeLists.txt /tmp/source-writeable/ +cp /source/CMakeLists.txt /tmp/source-writeable/ + +cp -r /source/CodeAnalysis /tmp/source-writeable/ +cp -r /source/Resources /tmp/source-writeable/ cp -r /source/Sources /tmp/source-writeable/ -cp -r /source/Resources /tmp/source-writeable/ -cp -r /source/OrthancSDKVersion.cmake /tmp/source-writeable/ mkdir /tmp/build cd /tmp/build diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Orthanc/CMake/Compiler.cmake --- a/Resources/Orthanc/CMake/Compiler.cmake Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Orthanc/CMake/Compiler.cmake Wed Aug 13 12:02:04 2025 +0200 @@ -22,6 +22,16 @@ # This file sets all the compiler-related flags +if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + # Since Orthanc 1.12.7 that allows CMake 4.0, builds for macOS + # require the C++ standard to be explicitly set to C++11. Do *not* + # do this on GNU/Linux, as third-party system libraries could have + # been compiled with higher versions of the C++ standard. + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) +endif() + # Save the current compiler flags to the cache every time cmake configures the project set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "compiler flags" FORCE) diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Orthanc/CMake/DownloadOrthancFramework.cmake --- a/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake Wed Aug 13 12:02:04 2025 +0200 @@ -169,6 +169,12 @@ set(ORTHANC_FRAMEWORK_MD5 "5bb69f092981fdcfc11dec0a0f9a7db3") elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.12.6") set(ORTHANC_FRAMEWORK_MD5 "0e971f32f4f3e4951e0f3b5de49a3da6") + elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.12.7") + set(ORTHANC_FRAMEWORK_MD5 "f27c27d7a7a694dab1fd7f0a99d9715a") + elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.12.8") + set(ORTHANC_FRAMEWORK_MD5 "eb1c719234338e8277b80d3453563e9f") + elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.12.9") + set(ORTHANC_FRAMEWORK_MD5 "66b5a2ee60706c4a502896083b9e1a01") # Below this point are development snapshots that were used to # release some plugin, before an official release of the Orthanc @@ -501,11 +507,18 @@ include(CheckIncludeFile) include(CheckIncludeFileCXX) - include(FindPythonInterp) + + if(CMAKE_VERSION VERSION_GREATER "3.11") + find_package(Python REQUIRED COMPONENTS Interpreter) + set(PYTHON_EXECUTABLE ${Python_EXECUTABLE}) + else() + include(FindPythonInterp) + find_package(PythonInterp REQUIRED) + endif() + include(${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake) include(${CMAKE_CURRENT_LIST_DIR}/DownloadPackage.cmake) include(${CMAKE_CURRENT_LIST_DIR}/AutoGeneratedCode.cmake) - set(EMBED_RESOURCES_PYTHON ${CMAKE_CURRENT_LIST_DIR}/EmbedResources.py) if (ORTHANC_FRAMEWORK_USE_SHARED) list(GET CMAKE_FIND_LIBRARY_PREFIXES 0 Prefix) diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Orthanc/OrthancPluginCodeModel.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Orthanc/OrthancPluginCodeModel.json Wed Aug 13 12:02:04 2025 +0200 @@ -0,0 +1,5491 @@ +{ + "classes": [ + { + "destructor": "OrthancPluginFreeDicomInstance", + "methods": [ + { + "args": [], + "c_function": "OrthancPluginGetInstanceRemoteAet", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns the Application Entity Title (AET) of the DICOM modality from which a DICOM instance originates." + ], + "return": "The AET if success, NULL if error.", + "summary": "Get the AET of a DICOM instance." + }, + "return_sdk_type": "const char *" + }, + { + "args": [], + "c_function": "OrthancPluginGetInstanceSize", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns the number of bytes of the given DICOM instance." + ], + "return": "The size of the file, -1 in case of error.", + "summary": "Get the size of a DICOM file." + }, + "return_sdk_type": "int64_t" + }, + { + "args": [], + "c_function": "OrthancPluginGetInstanceJson", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns a pointer to a newly created string containing a JSON file. This JSON file encodes the tag hierarchy of the given DICOM instance." + ], + "return": "The NULL value in case of error, or a string containing the JSON file. This string must be freed by OrthancPluginFreeString().", + "summary": "Get the DICOM tag hierarchy as a JSON file." + }, + "return_sdk_type": "char *" + }, + { + "args": [], + "c_function": "OrthancPluginGetInstanceSimplifiedJson", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns a pointer to a newly created string containing a JSON file. This JSON file encodes the tag hierarchy of the given DICOM instance. In contrast with ::OrthancPluginGetInstanceJson(), the returned JSON file is in its simplified version." + ], + "return": "The NULL value in case of error, or a string containing the JSON file. This string must be freed by OrthancPluginFreeString().", + "summary": "Get the DICOM tag hierarchy as a JSON file (with simplification)." + }, + "return_sdk_type": "char *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "metadata", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginHasInstanceMetadata", + "const": true, + "documentation": { + "args": { + "metadata": "The metadata of interest." + }, + "description": [ + "This function checks whether the DICOM instance of interest is associated with some metadata. As of Orthanc 0.8.1, in the callbacks registered by ::OrthancPluginRegisterOnStoredInstanceCallback(), the only possibly available metadata are \"ReceptionDate\", \"RemoteAET\" and \"IndexInSeries\"." + ], + "return": "1 if the metadata is present, 0 if it is absent, -1 in case of error.", + "summary": "Check whether a DICOM instance is associated with some metadata." + }, + "return_sdk_type": "int32_t" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "metadata", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginGetInstanceMetadata", + "const": true, + "documentation": { + "args": { + "metadata": "The metadata of interest." + }, + "description": [ + "This functions returns the value of some metadata that is associated with the DICOM instance of interest. Before calling this function, the existence of the metadata must have been checked with ::OrthancPluginHasInstanceMetadata()." + ], + "return": "The metadata value if success, NULL if error. Please note that the returned string belongs to the instance object and must NOT be deallocated. Please make a copy of the string if you wish to access it later.", + "summary": "Get the value of some metadata associated with a given DICOM instance." + }, + "return_sdk_type": "const char *" + }, + { + "args": [], + "c_function": "OrthancPluginGetInstanceOrigin", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns the origin of a DICOM instance that has been received by Orthanc." + ], + "return": "The origin of the instance.", + "summary": "Get the origin of a DICOM file." + }, + "return_sdk_enumeration": "OrthancPluginInstanceOrigin", + "return_sdk_type": "enumeration" + }, + { + "args": [], + "c_function": "OrthancPluginGetInstanceTransferSyntaxUid", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns a pointer to a newly created string that contains the transfer syntax UID of the DICOM instance. The empty string might be returned if this information is unknown." + ], + "return": "The NULL value in case of error, or a string containing the transfer syntax UID. This string must be freed by OrthancPluginFreeString().", + "summary": "Get the transfer syntax of a DICOM file." + }, + "return_sdk_type": "char *", + "since_sdk": [ + 1, + 6, + 1 + ] + }, + { + "args": [], + "c_function": "OrthancPluginHasInstancePixelData", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns a Boolean value indicating whether the DICOM instance contains the pixel data (7FE0,0010) tag." + ], + "return": "\"1\" if the DICOM instance contains pixel data, or \"0\" if the tag is missing, or \"-1\" in the case of an error.", + "summary": "Check whether the DICOM file has pixel data." + }, + "return_sdk_type": "int32_t", + "since_sdk": [ + 1, + 6, + 1 + ] + }, + { + "args": [], + "c_function": "OrthancPluginGetInstanceFramesCount", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns the number of frames that are part of a DICOM image managed by the Orthanc core." + ], + "return": "The number of frames (will be zero in the case of an error).", + "summary": "Get the number of frames in a DICOM instance." + }, + "return_sdk_type": "uint32_t", + "since_sdk": [ + 1, + 7, + 0 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "frameIndex", + "sdk_type": "uint32_t" + } + ], + "c_function": "OrthancPluginGetInstanceRawFrame", + "const": true, + "documentation": { + "args": { + "frameIndex": "The index of the frame of interest.", + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer()." + }, + "description": [ + "This function returns a memory buffer containing the raw content of a frame in a DICOM instance that is managed by the Orthanc core. This is notably useful for compressed transfer syntaxes, as it gives access to the embedded files (such as JPEG, JPEG-LS or JPEG2k). The Orthanc core transparently reassembles the fragments to extract the raw frame." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Get the raw content of a frame in a DICOM instance." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *", + "since_sdk": [ + 1, + 7, + 0 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "frameIndex", + "sdk_type": "uint32_t" + } + ], + "c_function": "OrthancPluginGetInstanceDecodedFrame", + "const": true, + "documentation": { + "args": { + "frameIndex": "The index of the frame of interest." + }, + "description": [ + "This function decodes one frame of a DICOM image that is managed by the Orthanc core." + ], + "return": "The uncompressed image. It must be freed with OrthancPluginFreeImage().", + "summary": "Decode one frame from a DICOM instance." + }, + "return_sdk_class": "OrthancPluginImage", + "return_sdk_type": "object", + "since_sdk": [ + 1, + 7, + 0 + ] + }, + { + "args": [], + "c_function": "OrthancPluginSerializeDicomInstance", + "const": true, + "documentation": { + "args": { + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer()." + }, + "description": [ + "This function returns a memory buffer containing the serialization of a DICOM instance that is managed by the Orthanc core." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Writes a DICOM instance to a memory buffer." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *", + "since_sdk": [ + 1, + 7, + 0 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_enumeration": "OrthancPluginDicomToJsonFormat", + "sdk_name": "format", + "sdk_type": "enumeration" + }, + { + "name": "arg1", + "sdk_enumeration": "OrthancPluginDicomToJsonFlags", + "sdk_name": "flags", + "sdk_type": "enumeration" + }, + { + "name": "arg2", + "sdk_name": "maxStringLength", + "sdk_type": "uint32_t" + } + ], + "c_function": "OrthancPluginGetInstanceAdvancedJson", + "const": true, + "documentation": { + "args": { + "flags": "Flags governing the output.", + "format": "The output format.", + "maxStringLength": "The maximum length of a field. Too long fields will be output as \"null\". The 0 value means no maximum length." + }, + "description": [ + "This function takes as DICOM instance managed by the Orthanc core, and outputs a JSON string representing the tags of this DICOM file." + ], + "return": "The NULL value if the case of an error, or the JSON string. This string must be freed by OrthancPluginFreeString().", + "summary": "Format a DICOM memory buffer as a JSON string." + }, + "return_sdk_type": "char *", + "since_sdk": [ + 1, + 7, + 0 + ] + } + ], + "name": "OrthancPluginDicomInstance" + }, + { + "methods": [], + "name": "OrthancPluginDicomWebNode", + "since_sdk": [ + 1, + 5, + 4 + ] + }, + { + "methods": [ + { + "args": [ + { + "name": "arg0", + "sdk_name": "dicom", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginFindAddAnswer", + "const": false, + "documentation": { + "args": { + "dicom": "The answer to be added, encoded as a DICOM file.", + "size": "The size of the DICOM file." + }, + "description": [ + "This function adds one answer (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request that is not related to modality worklists." + ], + "return": "0 if success, other value if error.", + "summary": "Add one answer to some C-Find request." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration", + "since_sdk": [ + 1, + 1, + 0 + ] + }, + { + "args": [], + "c_function": "OrthancPluginFindMarkIncomplete", + "const": false, + "documentation": { + "args": {}, + "description": [ + "This function marks as incomplete the set of answers corresponding to some C-Find SCP request that is not related to modality worklists. This must be used if canceling the handling of a request when too many answers are to be returned." + ], + "return": "0 if success, other value if error.", + "summary": "Mark the set of C-Find answers as incomplete." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration", + "since_sdk": [ + 1, + 1, + 0 + ] + } + ], + "name": "OrthancPluginFindAnswers", + "since_sdk": [ + 1, + 1, + 0 + ] + }, + { + "destructor": "OrthancPluginFreeFindMatcher", + "methods": [ + { + "args": [ + { + "name": "arg0", + "sdk_name": "dicom", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginFindMatcherIsMatch", + "const": true, + "documentation": { + "args": { + "dicom": "The DICOM instance to be matched.", + "size": "The size of the DICOM instance." + }, + "description": [ + "This function checks whether one DICOM instance matches C-Find matcher that was previously allocated using OrthancPluginCreateFindMatcher()." + ], + "return": "1 if the DICOM instance matches the query, 0 otherwise.", + "summary": "Test whether a DICOM instance matches a C-Find query." + }, + "return_sdk_type": "int32_t", + "since_sdk": [ + 1, + 2, + 0 + ] + } + ], + "name": "OrthancPluginFindMatcher", + "since_sdk": [ + 1, + 2, + 0 + ] + }, + { + "methods": [ + { + "args": [], + "c_function": "OrthancPluginGetFindQuerySize", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns the number of tags that are contained in the given C-Find query." + ], + "return": "The number of tags.", + "summary": "Get the number of tags in a C-Find query." + }, + "return_sdk_type": "uint32_t", + "since_sdk": [ + 1, + 1, + 0 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "index", + "sdk_type": "uint32_t" + } + ], + "c_function": "OrthancPluginGetFindQueryTagName", + "const": true, + "documentation": { + "args": { + "index": "The index of the tag of interest." + }, + "description": [ + "This function returns the symbolic name of one DICOM tag in the given C-Find query." + ], + "return": "0 if success, other value if error.", + "summary": "Get the symbolic name of one tag in a C-Find query." + }, + "return_sdk_type": "char *", + "since_sdk": [ + 1, + 1, + 0 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "index", + "sdk_type": "uint32_t" + } + ], + "c_function": "OrthancPluginGetFindQueryValue", + "const": true, + "documentation": { + "args": { + "index": "The index of the tag of interest." + }, + "description": [ + "This function returns the value associated with one tag in the given C-Find query." + ], + "return": "0 if success, other value if error.", + "summary": "Get the value associated with one tag in a C-Find query." + }, + "return_sdk_type": "char *", + "since_sdk": [ + 1, + 1, + 0 + ] + } + ], + "name": "OrthancPluginFindQuery", + "since_sdk": [ + 1, + 1, + 0 + ] + }, + { + "destructor": "OrthancPluginFreeImage", + "methods": [ + { + "args": [], + "c_function": "OrthancPluginGetImagePixelFormat", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns the type of memory layout for the pixels of the given image." + ], + "return": "The pixel format.", + "summary": "Return the pixel format of an image." + }, + "return_sdk_enumeration": "OrthancPluginPixelFormat", + "return_sdk_type": "enumeration" + }, + { + "args": [], + "c_function": "OrthancPluginGetImageWidth", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns the width of the given image." + ], + "return": "The width.", + "summary": "Return the width of an image." + }, + "return_sdk_type": "uint32_t" + }, + { + "args": [], + "c_function": "OrthancPluginGetImageHeight", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns the height of the given image." + ], + "return": "The height.", + "summary": "Return the height of an image." + }, + "return_sdk_type": "uint32_t" + }, + { + "args": [], + "c_function": "OrthancPluginGetImagePitch", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns the pitch of the given image. The pitch is defined as the number of bytes between 2 successive lines of the image in the memory buffer." + ], + "return": "The pitch.", + "summary": "Return the pitch of an image." + }, + "return_sdk_type": "uint32_t" + }, + { + "args": [ + { + "name": "arg0", + "sdk_enumeration": "OrthancPluginPixelFormat", + "sdk_name": "targetFormat", + "sdk_type": "enumeration" + } + ], + "c_function": "OrthancPluginConvertPixelFormat", + "const": true, + "documentation": { + "args": { + "targetFormat": "The target pixel format." + }, + "description": [ + "This function creates a new image, changing the memory layout of the pixels." + ], + "return": "The resulting image. It must be freed with OrthancPluginFreeImage().", + "summary": "Change the pixel format of an image." + }, + "return_sdk_class": "OrthancPluginImage", + "return_sdk_type": "object" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "fontIndex", + "sdk_type": "uint32_t" + }, + { + "name": "arg1", + "sdk_name": "utf8Text", + "sdk_type": "const char *" + }, + { + "name": "arg2", + "sdk_name": "x", + "sdk_type": "int32_t" + }, + { + "name": "arg3", + "sdk_name": "y", + "sdk_type": "int32_t" + }, + { + "name": "arg4", + "sdk_name": "r", + "sdk_type": "uint8_t" + }, + { + "name": "arg5", + "sdk_name": "g", + "sdk_type": "uint8_t" + }, + { + "name": "arg6", + "sdk_name": "b", + "sdk_type": "uint8_t" + } + ], + "c_function": "OrthancPluginDrawText", + "const": false, + "documentation": { + "args": { + "b": "The value of the blue color channel of the text.", + "fontIndex": "The index of the font. This value must be less than OrthancPluginGetFontsCount().", + "g": "The value of the green color channel of the text.", + "r": "The value of the red color channel of the text.", + "utf8Text": "The text to be drawn, encoded as an UTF-8 zero-terminated string.", + "x": "The X position of the text over the image.", + "y": "The Y position of the text over the image." + }, + "description": [ + "This function draws some text on some image." + ], + "return": "0 if success, other value if error.", + "summary": "Draw text on an image." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration" + } + ], + "name": "OrthancPluginImage" + }, + { + "destructor": "OrthancPluginFreeJob", + "methods": [ + { + "args": [ + { + "name": "arg0", + "sdk_name": "priority", + "sdk_type": "int32_t" + } + ], + "c_function": "OrthancPluginSubmitJob", + "const": false, + "documentation": { + "args": { + "priority": "The priority of the job." + }, + "description": [ + "This function adds the given job to the pending jobs of Orthanc. Orthanc will take take of freeing it by invoking the finalization callback provided to OrthancPluginCreateJob()." + ], + "return": "ID of the newly-submitted job. This string must be freed by OrthancPluginFreeString().", + "summary": "Submit a new job to the jobs engine of Orthanc." + }, + "return_sdk_type": "char *", + "since_sdk": [ + 1, + 4, + 2 + ] + } + ], + "name": "OrthancPluginJob", + "since_sdk": [ + 1, + 4, + 2 + ] + }, + { + "destructor": "OrthancPluginFreeKeysValuesIterator", + "methods": [ + { + "args": [], + "c_function": "OrthancPluginKeysValuesIteratorGetKey", + "const": false, + "documentation": { + "args": {}, + "description": [ + "Before using this function, the function OrthancPluginKeysValuesIteratorNext() must have been called at least once." + ], + "return": "The current key, or NULL in the case of an error.", + "summary": "Get the current key of an iterator over a key-value store." + }, + "return_sdk_type": "const char *", + "since_sdk": [ + 1, + 12, + 8 + ] + }, + { + "args": [], + "c_function": "OrthancPluginKeysValuesIteratorGetValue", + "const": false, + "documentation": { + "args": { + "target": "Memory buffer where to store the value that has been retrieved from the key-value store. It must be freed with OrthancPluginFreeMemoryBuffer()." + }, + "description": [ + "Before using this function, the function OrthancPluginKeysValuesIteratorNext() must have been called at least once." + ], + "return": "The current value, or NULL in the case of an error.", + "summary": "Get the current value of an iterator over a key-value store." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *", + "since_sdk": [ + 1, + 12, + 8 + ] + } + ], + "name": "OrthancPluginKeysValuesIterator", + "since_sdk": [ + 1, + 12, + 8 + ] + }, + { + "destructor": "OrthancPluginFreePeers", + "methods": [ + { + "args": [], + "c_function": "OrthancPluginGetPeersCount", + "const": true, + "documentation": { + "args": {}, + "description": [ + "This function returns the number of Orthanc peers.", + "This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function." + ], + "return": "The number of peers.", + "summary": "Get the number of Orthanc peers." + }, + "return_sdk_type": "uint32_t", + "since_sdk": [ + 1, + 4, + 2 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "peerIndex", + "sdk_type": "uint32_t" + } + ], + "c_function": "OrthancPluginGetPeerName", + "const": true, + "documentation": { + "args": { + "peerIndex": "The index of the peer of interest. This value must be lower than OrthancPluginGetPeersCount()." + }, + "description": [ + "This function returns the symbolic name of the Orthanc peer, which corresponds to the key of the \"OrthancPeers\" configuration option of Orthanc.", + "This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function." + ], + "return": "The symbolic name, or NULL in the case of an error.", + "summary": "Get the symbolic name of an Orthanc peer." + }, + "return_sdk_type": "const char *", + "since_sdk": [ + 1, + 4, + 2 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "peerIndex", + "sdk_type": "uint32_t" + } + ], + "c_function": "OrthancPluginGetPeerUrl", + "const": true, + "documentation": { + "args": { + "peerIndex": "The index of the peer of interest. This value must be lower than OrthancPluginGetPeersCount()." + }, + "description": [ + "This function returns the base URL to the REST API of some Orthanc peer.", + "This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function." + ], + "return": "The URL, or NULL in the case of an error.", + "summary": "Get the base URL of an Orthanc peer." + }, + "return_sdk_type": "const char *", + "since_sdk": [ + 1, + 4, + 2 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "peerIndex", + "sdk_type": "uint32_t" + }, + { + "name": "arg1", + "sdk_name": "userProperty", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginGetPeerUserProperty", + "const": true, + "documentation": { + "args": { + "peerIndex": "The index of the peer of interest. This value must be lower than OrthancPluginGetPeersCount().", + "userProperty": "The user property of interest." + }, + "description": [ + "This function returns some user-defined property of some Orthanc peer. An user-defined property is a property that is associated with the peer in the Orthanc configuration file, but that is not recognized by the Orthanc core.", + "This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function." + ], + "return": "The value of the user property, or NULL if it is not defined.", + "summary": "Get some user-defined property of an Orthanc peer." + }, + "return_sdk_type": "const char *", + "since_sdk": [ + 1, + 4, + 2 + ] + } + ], + "name": "OrthancPluginPeers", + "since_sdk": [ + 1, + 4, + 2 + ] + }, + { + "methods": [ + { + "args": [ + { + "name": "arg0", + "sdk_name": "answer", + "sdk_type": "const_void_pointer_with_size" + }, + { + "name": "arg2", + "sdk_name": "mimeType", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginAnswerBuffer", + "const": false, + "documentation": { + "args": { + "answer": "Pointer to the memory buffer containing the answer.", + "answerSize": "Number of bytes of the answer.", + "mimeType": "The MIME type of the answer." + }, + "description": [ + "This function answers to a REST request with the content of a memory buffer." + ], + "summary": "Answer to a REST request." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_enumeration": "OrthancPluginPixelFormat", + "sdk_name": "format", + "sdk_type": "enumeration" + }, + { + "name": "arg1", + "sdk_name": "width", + "sdk_type": "uint32_t" + }, + { + "name": "arg2", + "sdk_name": "height", + "sdk_type": "uint32_t" + }, + { + "name": "arg3", + "sdk_name": "pitch", + "sdk_type": "uint32_t" + }, + { + "name": "arg4", + "sdk_name": "buffer", + "sdk_type": "const void *" + } + ], + "c_function": "OrthancPluginCompressAndAnswerPngImage", + "const": false, + "documentation": { + "args": { + "buffer": "The memory buffer containing the uncompressed image.", + "format": "The memory layout of the uncompressed image.", + "height": "The height of the image.", + "pitch": "The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer).", + "width": "The width of the image." + }, + "description": [ + "This function answers to a REST request with a PNG image. The parameters of this function describe a memory buffer that contains an uncompressed image. The image will be automatically compressed as a PNG image by the core system of Orthanc." + ], + "summary": "Answer to a REST request with a PNG image." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "redirection", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginRedirect", + "const": false, + "documentation": { + "args": { + "redirection": "Where to redirect." + }, + "description": [ + "This function answers to a REST request by redirecting the user to another URI using HTTP status 301." + ], + "summary": "Redirect a REST request." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "status", + "sdk_type": "uint16_t" + } + ], + "c_function": "OrthancPluginSendHttpStatusCode", + "const": false, + "documentation": { + "args": { + "status": "The HTTP status code to be sent." + }, + "description": [ + "This function answers to a REST request by sending a HTTP status code (such as \"400 - Bad Request\"). Note that: - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). - Redirections (status 301) must use ::OrthancPluginRedirect(). - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed()." + ], + "summary": "Send a HTTP status code." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "realm", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginSendUnauthorized", + "const": false, + "documentation": { + "args": { + "realm": "The realm for the authorization process." + }, + "description": [ + "This function answers to a REST request by signaling that it is not authorized." + ], + "summary": "Signal that a REST request is not authorized." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "allowedMethods", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginSendMethodNotAllowed", + "const": false, + "documentation": { + "args": { + "allowedMethods": "The allowed methods for this URI (e.g. \"GET,POST\" after a PUT or a POST request)." + }, + "description": [ + "This function answers to a REST request by signaling that the queried URI does not support this method." + ], + "summary": "Signal that this URI does not support this HTTP method." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "cookie", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "value", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginSetCookie", + "const": false, + "documentation": { + "args": { + "cookie": "The cookie to be set.", + "value": "The value of the cookie." + }, + "description": [ + "This function sets a cookie in the HTTP client." + ], + "summary": "Set a cookie." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "key", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "value", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginSetHttpHeader", + "const": false, + "documentation": { + "args": { + "key": "The HTTP header to be set.", + "value": "The value of the HTTP header." + }, + "description": [ + "This function sets a HTTP header in the HTTP answer." + ], + "summary": "Set some HTTP header." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "subType", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "contentType", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginStartMultipartAnswer", + "const": false, + "documentation": { + "args": { + "contentType": "The MIME type of the items in the multipart answer.", + "subType": "The sub-type of the multipart answer (\"mixed\" or \"related\")." + }, + "description": [ + "Initiates a HTTP multipart answer, as the result of a REST request." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Start an HTTP multipart answer." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "answer", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginSendMultipartItem", + "const": false, + "documentation": { + "args": { + "answer": "Pointer to the memory buffer containing the item.", + "answerSize": "Number of bytes of the item." + }, + "description": [ + "This function sends an item as a part of some HTTP multipart answer that was initiated by OrthancPluginStartMultipartAnswer()." + ], + "return": "0 if success, or the error code if failure (this notably happens if the connection is closed by the client).", + "summary": "Send an item as a part of some HTTP multipart answer." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "status", + "sdk_type": "uint16_t" + }, + { + "name": "arg1", + "sdk_name": "body", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginSendHttpStatus", + "const": false, + "documentation": { + "args": { + "body": "The body of the answer.", + "bodySize": "The size of the body.", + "status": "The HTTP status code to be sent." + }, + "description": [ + "This function answers to a HTTP request by sending a HTTP status code (such as \"400 - Bad Request\"), together with a body describing the error. The body will only be returned if the configuration option \"HttpDescribeErrors\" of Orthanc is set to \"true\".", + "Note that: - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). - Redirections (status 301) must use ::OrthancPluginRedirect(). - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed()." + ], + "summary": "Send a HTTP status, with a custom body." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_enumeration": "OrthancPluginPixelFormat", + "sdk_name": "format", + "sdk_type": "enumeration" + }, + { + "name": "arg1", + "sdk_name": "width", + "sdk_type": "uint32_t" + }, + { + "name": "arg2", + "sdk_name": "height", + "sdk_type": "uint32_t" + }, + { + "name": "arg3", + "sdk_name": "pitch", + "sdk_type": "uint32_t" + }, + { + "name": "arg4", + "sdk_name": "buffer", + "sdk_type": "const void *" + }, + { + "name": "arg5", + "sdk_name": "quality", + "sdk_type": "uint8_t" + } + ], + "c_function": "OrthancPluginCompressAndAnswerJpegImage", + "const": false, + "documentation": { + "args": { + "buffer": "The memory buffer containing the uncompressed image.", + "format": "The memory layout of the uncompressed image.", + "height": "The height of the image.", + "pitch": "The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer).", + "quality": "The quality of the JPEG encoding, between 1 (worst quality, best compression) and 100 (best quality, worst compression).", + "width": "The width of the image." + }, + "description": [ + "This function answers to a REST request with a JPEG image. The parameters of this function describe a memory buffer that contains an uncompressed image. The image will be automatically compressed as a JPEG image by the core system of Orthanc." + ], + "summary": "Answer to a REST request with a JPEG image." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "details", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "log", + "sdk_type": "uint8_t" + } + ], + "c_function": "OrthancPluginSetHttpErrorDetails", + "const": false, + "documentation": { + "args": { + "details": "The details of the error message.", + "log": "Whether to also write the detailed error to the Orthanc logs." + }, + "description": [ + "This function sets the detailed description associated with an HTTP error. This description will be displayed in the \"Details\" field of the JSON body of the HTTP answer. It is only taken into consideration if the REST callback returns an error code that is different from \"OrthancPluginErrorCode_Success\", and if the \"HttpDescribeErrors\" configuration option of Orthanc is set to \"true\"." + ], + "summary": "Provide a detailed description for an HTTP error." + }, + "return_sdk_type": "void", + "since_sdk": [ + 1, + 5, + 0 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "contentType", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginStartStreamAnswer", + "const": false, + "documentation": { + "args": { + "contentType": "The MIME type of the items in the stream answer." + }, + "description": [ + "Initiates an HTTP stream answer, as the result of a REST request." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Start an HTTP stream answer." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration", + "since_sdk": [ + 1, + 12, + 6 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "answer", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginSendStreamChunk", + "const": false, + "documentation": { + "args": { + "answer": "Pointer to the memory buffer containing the item.", + "answerSize": "Number of bytes of the item." + }, + "description": [ + "This function sends a chunk as part of an HTTP stream answer that was initiated by OrthancPluginStartStreamAnswer()." + ], + "return": "0 if success, or the error code if failure (this notably happens if the connection is closed by the client).", + "summary": "Send a chunk as a part of an HTTP stream answer." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration", + "since_sdk": [ + 1, + 12, + 6 + ] + } + ], + "name": "OrthancPluginRestOutput" + }, + { + "methods": [], + "name": "OrthancPluginServerChunkedRequestReader", + "since_sdk": [ + 1, + 5, + 7 + ] + }, + { + "methods": [ + { + "args": [ + { + "name": "arg0", + "sdk_name": "uuid", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "content", + "sdk_type": "const void *" + }, + { + "name": "arg2", + "sdk_name": "size", + "sdk_type": "uint64_t" + }, + { + "name": "arg3", + "sdk_enumeration": "OrthancPluginContentType", + "sdk_name": "type", + "sdk_type": "enumeration" + } + ], + "c_function": "OrthancPluginStorageAreaCreate", + "const": false, + "documentation": { + "args": { + "content": "The content to store in the newly created file.", + "size": "The size of the content.", + "type": "The type of the file content.", + "uuid": "The identifier of the file to be created." + }, + "description": [ + "This function creates a new file inside the storage area that is currently used by Orthanc.", + "Warning: This function will result in a \"not implemented\" error on versions of the Orthanc core above 1.12.6." + ], + "return": "0 if success, other value if error.", + "summary": "Create a file inside the storage area." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "uuid", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_enumeration": "OrthancPluginContentType", + "sdk_name": "type", + "sdk_type": "enumeration" + } + ], + "c_function": "OrthancPluginStorageAreaRead", + "const": false, + "documentation": { + "args": { + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", + "type": "The type of the file content.", + "uuid": "The identifier of the file to be read." + }, + "description": [ + "This function reads the content of a given file from the storage area that is currently used by Orthanc.", + "Warning: This function will result in a \"not implemented\" error on versions of the Orthanc core above 1.12.6." + ], + "return": "0 if success, other value if error.", + "summary": "Read a file from the storage area." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "uuid", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_enumeration": "OrthancPluginContentType", + "sdk_name": "type", + "sdk_type": "enumeration" + } + ], + "c_function": "OrthancPluginStorageAreaRemove", + "const": false, + "documentation": { + "args": { + "type": "The type of the file content.", + "uuid": "The identifier of the file to be removed." + }, + "description": [ + "This function removes a given file from the storage area that is currently used by Orthanc.", + "Warning: This function will result in a \"not implemented\" error on versions of the Orthanc core above 1.12.6." + ], + "return": "0 if success, other value if error.", + "summary": "Remove a file from the storage area." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration" + }, + { + "args": [ + { + "name": "arg0", + "sdk_enumeration": "OrthancPluginResourceType", + "sdk_name": "level", + "sdk_type": "enumeration" + } + ], + "c_function": "OrthancPluginReconstructMainDicomTags", + "const": false, + "documentation": { + "args": { + "level": "The type of the resources of interest." + }, + "description": [ + "This function requests the Orthanc core to reconstruct the main DICOM tags of all the resources of the given type. This function can only be used as a part of the upgrade of a custom database back-end. A database transaction will be automatically setup." + ], + "return": "0 if success, other value if error.", + "summary": "Reconstruct the main DICOM tags." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration" + } + ], + "name": "OrthancPluginStorageArea" + }, + { + "methods": [], + "name": "OrthancPluginWebDavCollection", + "since_sdk": [ + 1, + 10, + 1 + ] + }, + { + "methods": [ + { + "args": [ + { + "name": "arg0", + "sdk_class": "OrthancPluginWorklistQuery", + "sdk_name": "query", + "sdk_type": "const_object" + }, + { + "name": "arg1", + "sdk_name": "dicom", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginWorklistAddAnswer", + "const": false, + "documentation": { + "args": { + "dicom": "The worklist to answer, encoded as a DICOM file.", + "query": "The worklist query, as received by the callback.", + "size": "The size of the DICOM file." + }, + "description": [ + "This function adds one worklist (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request against modality worklists." + ], + "return": "0 if success, other value if error.", + "summary": "Add one answer to some modality worklist request." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration" + }, + { + "args": [], + "c_function": "OrthancPluginWorklistMarkIncomplete", + "const": false, + "documentation": { + "args": {}, + "description": [ + "This function marks as incomplete the set of answers corresponding to some C-Find SCP request against modality worklists. This must be used if canceling the handling of a request when too many answers are to be returned." + ], + "return": "0 if success, other value if error.", + "summary": "Mark the set of worklist answers as incomplete." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration" + } + ], + "name": "OrthancPluginWorklistAnswers" + }, + { + "methods": [ + { + "args": [ + { + "name": "arg0", + "sdk_name": "dicom", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginWorklistIsMatch", + "const": true, + "documentation": { + "args": { + "dicom": "The worklist to answer, encoded as a DICOM file.", + "size": "The size of the DICOM file." + }, + "description": [ + "This function checks whether one worklist (encoded as a DICOM file) matches the C-Find SCP query against modality worklists. This function must be called before adding the worklist as an answer through OrthancPluginWorklistAddAnswer()." + ], + "return": "1 if the worklist matches the query, 0 otherwise.", + "summary": "Test whether a worklist matches the query." + }, + "return_sdk_type": "int32_t" + }, + { + "args": [], + "c_function": "OrthancPluginWorklistGetDicomQuery", + "const": true, + "documentation": { + "args": { + "target": "Memory buffer where to store the DICOM file. It must be freed with OrthancPluginFreeMemoryBuffer()." + }, + "description": [ + "This function retrieves the DICOM file that underlies a C-Find SCP query against modality worklists." + ], + "return": "0 if success, other value if error.", + "summary": "Retrieve the worklist query as a DICOM file." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + } + ], + "name": "OrthancPluginWorklistQuery" + } + ], + "enumerations": [ + { + "documentation": "The supported types of changes that can be signaled to the change callback. Note: This enumeration is not used to store changes in the database!", + "name": "OrthancPluginChangeType", + "values": [ + { + "documentation": "Series is now complete", + "key": "CompletedSeries", + "value": 0 + }, + { + "documentation": "Deleted resource", + "key": "Deleted", + "value": 1 + }, + { + "documentation": "A new instance was added to this resource", + "key": "NewChildInstance", + "value": 2 + }, + { + "documentation": "New instance received", + "key": "NewInstance", + "value": 3 + }, + { + "documentation": "New patient created", + "key": "NewPatient", + "value": 4 + }, + { + "documentation": "New series created", + "key": "NewSeries", + "value": 5 + }, + { + "documentation": "New study created", + "key": "NewStudy", + "value": 6 + }, + { + "documentation": "Timeout: No new instance in this patient", + "key": "StablePatient", + "value": 7 + }, + { + "documentation": "Timeout: No new instance in this series", + "key": "StableSeries", + "value": 8 + }, + { + "documentation": "Timeout: No new instance in this study", + "key": "StableStudy", + "value": 9 + }, + { + "documentation": "Orthanc has started", + "key": "OrthancStarted", + "value": 10 + }, + { + "documentation": "Orthanc is stopping", + "key": "OrthancStopped", + "value": 11 + }, + { + "documentation": "Some user-defined attachment has changed for this resource", + "key": "UpdatedAttachment", + "value": 12 + }, + { + "documentation": "Some user-defined metadata has changed for this resource", + "key": "UpdatedMetadata", + "value": 13 + }, + { + "documentation": "The list of Orthanc peers has changed", + "key": "UpdatedPeers", + "since_sdk": [ + 1, + 4, + 2 + ], + "value": 14 + }, + { + "documentation": "The list of DICOM modalities has changed", + "key": "UpdatedModalities", + "since_sdk": [ + 1, + 4, + 2 + ], + "value": 15 + }, + { + "documentation": "New Job submitted", + "key": "JobSubmitted", + "since_sdk": [ + 1, + 7, + 2 + ], + "value": 16 + }, + { + "documentation": "A Job has completed successfully", + "key": "JobSuccess", + "since_sdk": [ + 1, + 7, + 2 + ], + "value": 17 + }, + { + "documentation": "A Job has failed", + "key": "JobFailure", + "since_sdk": [ + 1, + 7, + 2 + ], + "value": 18 + } + ] + }, + { + "documentation": "The compression algorithms that are supported by the Orthanc core.", + "name": "OrthancPluginCompressionType", + "values": [ + { + "documentation": "Standard zlib compression", + "key": "Zlib", + "value": 0 + }, + { + "documentation": "zlib, prefixed with uncompressed size (uint64_t)", + "key": "ZlibWithSize", + "value": 1 + }, + { + "documentation": "Standard gzip compression", + "key": "Gzip", + "value": 2 + }, + { + "documentation": "gzip, prefixed with uncompressed size (uint64_t)", + "key": "GzipWithSize", + "value": 3 + }, + { + "documentation": "No compression (new in Orthanc 1.12.8)", + "key": "None", + "since_sdk": [ + 1, + 12, + 8 + ], + "value": 4 + } + ] + }, + { + "documentation": "The constraints on the tags (main DICOM tags and identifier tags) that must be supported by the database plugins.", + "name": "OrthancPluginConstraintType", + "values": [ + { + "documentation": "Equal", + "key": "Equal", + "value": 1 + }, + { + "documentation": "Less or equal", + "key": "SmallerOrEqual", + "value": 2 + }, + { + "documentation": "More or equal", + "key": "GreaterOrEqual", + "value": 3 + }, + { + "documentation": "Wildcard matching", + "key": "Wildcard", + "value": 4 + }, + { + "documentation": "List of values", + "key": "List", + "value": 5 + } + ] + }, + { + "documentation": "The content types that are supported by Orthanc plugins.", + "name": "OrthancPluginContentType", + "values": [ + { + "documentation": "Unknown content type", + "key": "Unknown", + "value": 0 + }, + { + "documentation": "DICOM", + "key": "Dicom", + "value": 1 + }, + { + "documentation": "JSON summary of a DICOM file", + "key": "DicomAsJson", + "value": 2 + }, + { + "documentation": "DICOM Header till pixel data", + "key": "DicomUntilPixelData", + "since_sdk": [ + 1, + 9, + 2 + ], + "value": 3 + } + ] + }, + { + "documentation": "Flags for the creation of a DICOM file.", + "name": "OrthancPluginCreateDicomFlags", + "values": [ + { + "documentation": "Default mode", + "key": "None", + "since_sdk": [ + 1, + 2, + 0 + ], + "value": 0 + }, + { + "documentation": "Decode fields encoded using data URI scheme", + "key": "DecodeDataUriScheme", + "value": 1 + }, + { + "documentation": "Automatically generate DICOM identifiers", + "key": "GenerateIdentifiers", + "value": 2 + } + ] + }, + { + "documentation": "Flags to customize a DICOM-to-JSON conversion. By default, binary tags are formatted using Data URI scheme.", + "name": "OrthancPluginDicomToJsonFlags", + "values": [ + { + "documentation": "Default formatting", + "key": "None", + "value": 0 + }, + { + "documentation": "Include the binary tags", + "key": "IncludeBinary", + "value": 1 + }, + { + "documentation": "Include the private tags", + "key": "IncludePrivateTags", + "value": 2 + }, + { + "documentation": "Include the tags unknown by the dictionary", + "key": "IncludeUnknownTags", + "value": 4 + }, + { + "documentation": "Include the pixel data", + "key": "IncludePixelData", + "value": 8 + }, + { + "documentation": "Output binary tags as-is, dropping non-ASCII", + "key": "ConvertBinaryToAscii", + "value": 16 + }, + { + "documentation": "Signal binary tags as null values", + "key": "ConvertBinaryToNull", + "value": 32 + }, + { + "documentation": "Stop processing after pixel data (new in 1.9.1)", + "key": "StopAfterPixelData", + "since_sdk": [ + 1, + 9, + 1 + ], + "value": 64 + }, + { + "documentation": "Skip tags whose element is zero (new in 1.9.1)", + "key": "SkipGroupLengths", + "since_sdk": [ + 1, + 9, + 1 + ], + "value": 128 + } + ] + }, + { + "documentation": "The possible output formats for a DICOM-to-JSON conversion.", + "name": "OrthancPluginDicomToJsonFormat", + "values": [ + { + "documentation": "Full output, with most details", + "key": "Full", + "value": 1 + }, + { + "documentation": "Tags output as hexadecimal numbers", + "key": "Short", + "value": 2 + }, + { + "documentation": "Human-readable JSON", + "key": "Human", + "value": 3 + } + ] + }, + { + "documentation": "The available modes to export a binary DICOM tag into a DICOMweb JSON or XML document.", + "name": "OrthancPluginDicomWebBinaryMode", + "since_sdk": [ + 1, + 5, + 4 + ], + "values": [ + { + "documentation": "Don't include binary tags", + "key": "Ignore", + "value": 0 + }, + { + "documentation": "Inline encoding using Base64", + "key": "InlineBinary", + "value": 1 + }, + { + "documentation": "Use a bulk data URI field", + "key": "BulkDataUri", + "value": 2 + } + ] + }, + { + "documentation": "The various error codes that can be returned by the Orthanc core.", + "name": "OrthancPluginErrorCode", + "values": [ + { + "documentation": "Internal error", + "key": "InternalError", + "value": -1 + }, + { + "documentation": "Success", + "key": "Success", + "value": 0 + }, + { + "documentation": "Error encountered within the plugin engine", + "key": "Plugin", + "value": 1 + }, + { + "documentation": "Not implemented yet", + "key": "NotImplemented", + "value": 2 + }, + { + "documentation": "Parameter out of range", + "key": "ParameterOutOfRange", + "value": 3 + }, + { + "documentation": "The server hosting Orthanc is running out of memory", + "key": "NotEnoughMemory", + "value": 4 + }, + { + "documentation": "Bad type for a parameter", + "key": "BadParameterType", + "value": 5 + }, + { + "documentation": "Bad sequence of calls", + "key": "BadSequenceOfCalls", + "value": 6 + }, + { + "documentation": "Accessing an inexistent item", + "key": "InexistentItem", + "value": 7 + }, + { + "documentation": "Bad request", + "key": "BadRequest", + "value": 8 + }, + { + "documentation": "Error in the network protocol", + "key": "NetworkProtocol", + "value": 9 + }, + { + "documentation": "Error while calling a system command", + "key": "SystemCommand", + "value": 10 + }, + { + "documentation": "Error with the database engine", + "key": "Database", + "value": 11 + }, + { + "documentation": "Badly formatted URI", + "key": "UriSyntax", + "value": 12 + }, + { + "documentation": "Inexistent file", + "key": "InexistentFile", + "value": 13 + }, + { + "documentation": "Cannot write to file", + "key": "CannotWriteFile", + "value": 14 + }, + { + "documentation": "Bad file format", + "key": "BadFileFormat", + "value": 15 + }, + { + "documentation": "Timeout", + "key": "Timeout", + "value": 16 + }, + { + "documentation": "Unknown resource", + "key": "UnknownResource", + "value": 17 + }, + { + "documentation": "Incompatible version of the database", + "key": "IncompatibleDatabaseVersion", + "value": 18 + }, + { + "documentation": "The file storage is full", + "key": "FullStorage", + "value": 19 + }, + { + "documentation": "Corrupted file (e.g. inconsistent MD5 hash)", + "key": "CorruptedFile", + "value": 20 + }, + { + "documentation": "Inexistent tag", + "key": "InexistentTag", + "value": 21 + }, + { + "documentation": "Cannot modify a read-only data structure", + "key": "ReadOnly", + "value": 22 + }, + { + "documentation": "Incompatible format of the images", + "key": "IncompatibleImageFormat", + "value": 23 + }, + { + "documentation": "Incompatible size of the images", + "key": "IncompatibleImageSize", + "value": 24 + }, + { + "documentation": "Error while using a shared library (plugin)", + "key": "SharedLibrary", + "value": 25 + }, + { + "documentation": "Plugin invoking an unknown service", + "key": "UnknownPluginService", + "value": 26 + }, + { + "documentation": "Unknown DICOM tag", + "key": "UnknownDicomTag", + "value": 27 + }, + { + "documentation": "Cannot parse a JSON document", + "key": "BadJson", + "value": 28 + }, + { + "documentation": "Bad credentials were provided to an HTTP request", + "key": "Unauthorized", + "value": 29 + }, + { + "documentation": "Badly formatted font file", + "key": "BadFont", + "value": 30 + }, + { + "documentation": "The plugin implementing a custom database back-end does not fulfill the proper interface", + "key": "DatabasePlugin", + "value": 31 + }, + { + "documentation": "Error in the plugin implementing a custom storage area", + "key": "StorageAreaPlugin", + "value": 32 + }, + { + "documentation": "The request is empty", + "key": "EmptyRequest", + "value": 33 + }, + { + "documentation": "Cannot send a response which is acceptable according to the Accept HTTP header", + "key": "NotAcceptable", + "value": 34 + }, + { + "documentation": "Cannot handle a NULL pointer", + "key": "NullPointer", + "value": 35 + }, + { + "documentation": "The database is currently not available (probably a transient situation)", + "key": "DatabaseUnavailable", + "value": 36 + }, + { + "documentation": "This job was canceled", + "key": "CanceledJob", + "value": 37 + }, + { + "documentation": "Geometry error encountered in Stone", + "key": "BadGeometry", + "value": 38 + }, + { + "documentation": "Cannot initialize SSL encryption, check out your certificates", + "key": "SslInitialization", + "value": 39 + }, + { + "documentation": "Calling a function that has been removed from the Orthanc Framework", + "key": "DiscontinuedAbi", + "value": 40 + }, + { + "documentation": "Incorrect range request", + "key": "BadRange", + "value": 41 + }, + { + "documentation": "Database could not serialize access due to concurrent update, the transaction should be retried", + "key": "DatabaseCannotSerialize", + "value": 42 + }, + { + "documentation": "A bad revision number was provided, which might indicate conflict between multiple writers", + "key": "Revision", + "value": 43 + }, + { + "documentation": "A main DICOM Tag has been defined multiple times for the same resource level", + "key": "MainDicomTagsMultiplyDefined", + "value": 44 + }, + { + "documentation": "Access to a resource is forbidden", + "key": "ForbiddenAccess", + "value": 45 + }, + { + "documentation": "Duplicate resource", + "key": "DuplicateResource", + "value": 46 + }, + { + "documentation": "Your configuration file contains configuration that are mutually incompatible", + "key": "IncompatibleConfigurations", + "value": 47 + }, + { + "documentation": "SQLite: The database is not opened", + "key": "SQLiteNotOpened", + "value": 1000 + }, + { + "documentation": "SQLite: Connection is already open", + "key": "SQLiteAlreadyOpened", + "value": 1001 + }, + { + "documentation": "SQLite: Unable to open the database", + "key": "SQLiteCannotOpen", + "value": 1002 + }, + { + "documentation": "SQLite: This cached statement is already being referred to", + "key": "SQLiteStatementAlreadyUsed", + "value": 1003 + }, + { + "documentation": "SQLite: Cannot execute a command", + "key": "SQLiteExecute", + "value": 1004 + }, + { + "documentation": "SQLite: Rolling back a nonexistent transaction (have you called Begin()?)", + "key": "SQLiteRollbackWithoutTransaction", + "value": 1005 + }, + { + "documentation": "SQLite: Committing a nonexistent transaction", + "key": "SQLiteCommitWithoutTransaction", + "value": 1006 + }, + { + "documentation": "SQLite: Unable to register a function", + "key": "SQLiteRegisterFunction", + "value": 1007 + }, + { + "documentation": "SQLite: Unable to flush the database", + "key": "SQLiteFlush", + "value": 1008 + }, + { + "documentation": "SQLite: Cannot run a cached statement", + "key": "SQLiteCannotRun", + "value": 1009 + }, + { + "documentation": "SQLite: Cannot step over a cached statement", + "key": "SQLiteCannotStep", + "value": 1010 + }, + { + "documentation": "SQLite: Bind a value while out of range (serious error)", + "key": "SQLiteBindOutOfRange", + "value": 1011 + }, + { + "documentation": "SQLite: Cannot prepare a cached statement", + "key": "SQLitePrepareStatement", + "value": 1012 + }, + { + "documentation": "SQLite: Beginning the same transaction twice", + "key": "SQLiteTransactionAlreadyStarted", + "value": 1013 + }, + { + "documentation": "SQLite: Failure when committing the transaction", + "key": "SQLiteTransactionCommit", + "value": 1014 + }, + { + "documentation": "SQLite: Cannot start a transaction", + "key": "SQLiteTransactionBegin", + "value": 1015 + }, + { + "documentation": "The directory to be created is already occupied by a regular file", + "key": "DirectoryOverFile", + "value": 2000 + }, + { + "documentation": "Unable to create a subdirectory or a file in the file storage", + "key": "FileStorageCannotWrite", + "value": 2001 + }, + { + "documentation": "The specified path does not point to a directory", + "key": "DirectoryExpected", + "value": 2002 + }, + { + "documentation": "The TCP port of the HTTP server is privileged or already in use", + "key": "HttpPortInUse", + "value": 2003 + }, + { + "documentation": "The TCP port of the DICOM server is privileged or already in use", + "key": "DicomPortInUse", + "value": 2004 + }, + { + "documentation": "This HTTP status is not allowed in a REST API", + "key": "BadHttpStatusInRest", + "value": 2005 + }, + { + "documentation": "The specified path does not point to a regular file", + "key": "RegularFileExpected", + "value": 2006 + }, + { + "documentation": "Unable to get the path to the executable", + "key": "PathToExecutable", + "value": 2007 + }, + { + "documentation": "Cannot create a directory", + "key": "MakeDirectory", + "value": 2008 + }, + { + "documentation": "An application entity title (AET) cannot be empty or be longer than 16 characters", + "key": "BadApplicationEntityTitle", + "value": 2009 + }, + { + "documentation": "No request handler factory for DICOM C-FIND SCP", + "key": "NoCFindHandler", + "value": 2010 + }, + { + "documentation": "No request handler factory for DICOM C-MOVE SCP", + "key": "NoCMoveHandler", + "value": 2011 + }, + { + "documentation": "No request handler factory for DICOM C-STORE SCP", + "key": "NoCStoreHandler", + "value": 2012 + }, + { + "documentation": "No application entity filter", + "key": "NoApplicationEntityFilter", + "value": 2013 + }, + { + "documentation": "DicomUserConnection: Unable to find the SOP class and instance", + "key": "NoSopClassOrInstance", + "value": 2014 + }, + { + "documentation": "DicomUserConnection: No acceptable presentation context for modality", + "key": "NoPresentationContext", + "value": 2015 + }, + { + "documentation": "DicomUserConnection: The C-FIND command is not supported by the remote SCP", + "key": "DicomFindUnavailable", + "value": 2016 + }, + { + "documentation": "DicomUserConnection: The C-MOVE command is not supported by the remote SCP", + "key": "DicomMoveUnavailable", + "value": 2017 + }, + { + "documentation": "Cannot store an instance", + "key": "CannotStoreInstance", + "value": 2018 + }, + { + "documentation": "Only string values are supported when creating DICOM instances", + "key": "CreateDicomNotString", + "value": 2019 + }, + { + "documentation": "Trying to override a value inherited from a parent module", + "key": "CreateDicomOverrideTag", + "value": 2020 + }, + { + "documentation": "Use \\\"Content\\\" to inject an image into a new DICOM instance", + "key": "CreateDicomUseContent", + "value": 2021 + }, + { + "documentation": "No payload is present for one instance in the series", + "key": "CreateDicomNoPayload", + "value": 2022 + }, + { + "documentation": "The payload of the DICOM instance must be specified according to Data URI scheme", + "key": "CreateDicomUseDataUriScheme", + "value": 2023 + }, + { + "documentation": "Trying to attach a new DICOM instance to an inexistent resource", + "key": "CreateDicomBadParent", + "value": 2024 + }, + { + "documentation": "Trying to attach a new DICOM instance to an instance (must be a series, study or patient)", + "key": "CreateDicomParentIsInstance", + "value": 2025 + }, + { + "documentation": "Unable to get the encoding of the parent resource", + "key": "CreateDicomParentEncoding", + "value": 2026 + }, + { + "documentation": "Unknown modality", + "key": "UnknownModality", + "value": 2027 + }, + { + "documentation": "Bad ordering of filters in a job", + "key": "BadJobOrdering", + "value": 2028 + }, + { + "documentation": "Cannot convert the given JSON object to a Lua table", + "key": "JsonToLuaTable", + "value": 2029 + }, + { + "documentation": "Cannot create the Lua context", + "key": "CannotCreateLua", + "value": 2030 + }, + { + "documentation": "Cannot execute a Lua command", + "key": "CannotExecuteLua", + "value": 2031 + }, + { + "documentation": "Arguments cannot be pushed after the Lua function is executed", + "key": "LuaAlreadyExecuted", + "value": 2032 + }, + { + "documentation": "The Lua function does not give the expected number of outputs", + "key": "LuaBadOutput", + "value": 2033 + }, + { + "documentation": "The Lua function is not a predicate (only true/false outputs allowed)", + "key": "NotLuaPredicate", + "value": 2034 + }, + { + "documentation": "The Lua function does not return a string", + "key": "LuaReturnsNoString", + "value": 2035 + }, + { + "documentation": "Another plugin has already registered a custom storage area", + "key": "StorageAreaAlreadyRegistered", + "value": 2036 + }, + { + "documentation": "Another plugin has already registered a custom database back-end", + "key": "DatabaseBackendAlreadyRegistered", + "value": 2037 + }, + { + "documentation": "Plugin trying to call the database during its initialization", + "key": "DatabaseNotInitialized", + "value": 2038 + }, + { + "documentation": "Orthanc has been built without SSL support", + "key": "SslDisabled", + "value": 2039 + }, + { + "documentation": "Unable to order the slices of the series", + "key": "CannotOrderSlices", + "value": 2040 + }, + { + "documentation": "No request handler factory for DICOM C-Find Modality SCP", + "key": "NoWorklistHandler", + "value": 2041 + }, + { + "documentation": "Cannot override the value of a tag that already exists", + "key": "AlreadyExistingTag", + "value": 2042 + }, + { + "documentation": "No request handler factory for DICOM N-ACTION SCP (storage commitment)", + "key": "NoStorageCommitmentHandler", + "value": 2043 + }, + { + "documentation": "No request handler factory for DICOM C-GET SCP", + "key": "NoCGetHandler", + "value": 2044 + }, + { + "documentation": "DicomUserConnection: The C-GET command is not supported by the remote SCP", + "key": "DicomGetUnavailable", + "value": 2045 + }, + { + "documentation": "Unsupported media type", + "key": "UnsupportedMediaType", + "value": 3000 + } + ] + }, + { + "documentation": "Status associated with the authentication of a HTTP request.", + "name": "OrthancPluginHttpAuthenticationStatus", + "since_sdk": [ + 1, + 12, + 9 + ], + "values": [ + { + "documentation": "The authentication has been granted", + "key": "Granted", + "value": 0 + }, + { + "documentation": "The authentication has failed (401 HTTP status)", + "key": "Unauthorized", + "value": 1 + }, + { + "documentation": "The authorization has failed (403 HTTP status)", + "key": "Forbidden", + "value": 2 + }, + { + "documentation": "Redirect to another path (307 HTTP status, e.g., for login)", + "key": "Redirect", + "value": 3 + } + ] + }, + { + "documentation": "The various HTTP methods for a REST call.", + "name": "OrthancPluginHttpMethod", + "values": [ + { + "documentation": "GET request", + "key": "Get", + "value": 1 + }, + { + "documentation": "POST request", + "key": "Post", + "value": 2 + }, + { + "documentation": "PUT request", + "key": "Put", + "value": 3 + }, + { + "documentation": "DELETE request", + "key": "Delete", + "value": 4 + } + ] + }, + { + "documentation": "The constraints on the DICOM identifiers that must be supported by the database plugins.", + "name": "OrthancPluginIdentifierConstraint", + "values": [ + { + "documentation": "Equal", + "key": "Equal", + "value": 1 + }, + { + "documentation": "Less or equal", + "key": "SmallerOrEqual", + "value": 2 + }, + { + "documentation": "More or equal", + "key": "GreaterOrEqual", + "value": 3 + }, + { + "documentation": "Case-sensitive wildcard matching (with * and ?)", + "key": "Wildcard", + "value": 4 + } + ] + }, + { + "documentation": "The image formats that are supported by the Orthanc core.", + "name": "OrthancPluginImageFormat", + "values": [ + { + "documentation": "Image compressed using PNG", + "key": "Png", + "value": 0 + }, + { + "documentation": "Image compressed using JPEG", + "key": "Jpeg", + "value": 1 + }, + { + "documentation": "Image compressed using DICOM", + "key": "Dicom", + "value": 2 + } + ] + }, + { + "documentation": "The origin of a DICOM instance that has been received by Orthanc.", + "name": "OrthancPluginInstanceOrigin", + "values": [ + { + "documentation": "Unknown origin", + "key": "Unknown", + "value": 1 + }, + { + "documentation": "Instance received through DICOM protocol", + "key": "DicomProtocol", + "value": 2 + }, + { + "documentation": "Instance received through REST API of Orthanc", + "key": "RestApi", + "value": 3 + }, + { + "documentation": "Instance added to Orthanc by a plugin", + "key": "Plugin", + "value": 4 + }, + { + "documentation": "Instance added to Orthanc by a Lua script", + "key": "Lua", + "value": 5 + }, + { + "documentation": "Instance received through WebDAV (new in 1.8.0)", + "key": "WebDav", + "since_sdk": [ + 1, + 8, + 0 + ], + "value": 6 + } + ] + }, + { + "documentation": "The possible status for one single step of a job.", + "name": "OrthancPluginJobStepStatus", + "since_sdk": [ + 1, + 4, + 2 + ], + "values": [ + { + "documentation": "The job has successfully executed all its steps", + "key": "Success", + "value": 1 + }, + { + "documentation": "The job has failed while executing this step", + "key": "Failure", + "value": 2 + }, + { + "documentation": "The job has still data to process after this step", + "key": "Continue", + "value": 3 + } + ] + }, + { + "documentation": "Explains why the job should stop and release the resources it has allocated. This is especially important to disambiguate between the \"paused\" condition and the \"final\" conditions (success, failure, or canceled).", + "name": "OrthancPluginJobStopReason", + "since_sdk": [ + 1, + 4, + 2 + ], + "values": [ + { + "documentation": "The job has succeeded", + "key": "Success", + "value": 1 + }, + { + "documentation": "The job was paused, and will be resumed later", + "key": "Paused", + "value": 2 + }, + { + "documentation": "The job has failed, and might be resubmitted later", + "key": "Failure", + "value": 3 + }, + { + "documentation": "The job was canceled, and might be resubmitted later", + "key": "Canceled", + "value": 4 + } + ] + }, + { + "documentation": "Mode specifying how to load a DICOM instance.", + "name": "OrthancPluginLoadDicomInstanceMode", + "since_sdk": [ + 1, + 12, + 1 + ], + "values": [ + { + "documentation": "Load the whole DICOM file, including pixel data", + "key": "WholeDicom", + "value": 1 + }, + { + "documentation": "Load the whole DICOM file until pixel data, which speeds up the loading", + "key": "UntilPixelData", + "value": 2 + }, + { + "documentation": "Load the whole DICOM file until pixel data, and replace pixel data by an empty tag whose VR (value representation) is the same as those of the original DICOM file", + "key": "EmptyPixelData", + "value": 3 + } + ] + }, + { + "documentation": "The log categories supported by Orthanc. These values must match those of enumeration \"LogCategory\" in the Orthanc Core.", + "name": "OrthancPluginLogCategory", + "since_sdk": [ + 1, + 12, + 4 + ], + "values": [ + { + "documentation": "Generic (default) category", + "key": "Generic", + "value": 1 + }, + { + "documentation": "Plugin engine related logs (shall not be used by plugins)", + "key": "Plugins", + "value": 2 + }, + { + "documentation": "HTTP related logs", + "key": "Http", + "value": 4 + }, + { + "documentation": "SQLite related logs (shall not be used by plugins)", + "key": "Sqlite", + "value": 8 + }, + { + "documentation": "DICOM related logs", + "key": "Dicom", + "value": 16 + }, + { + "documentation": "jobs related logs", + "key": "Jobs", + "value": 32 + }, + { + "documentation": "Lua related logs (shall not be used by plugins)", + "key": "Lua", + "value": 64 + } + ] + }, + { + "documentation": "The log levels supported by Orthanc. These values must match those of enumeration \"LogLevel\" in the Orthanc Core.", + "name": "OrthancPluginLogLevel", + "since_sdk": [ + 1, + 12, + 4 + ], + "values": [ + { + "documentation": "Error log level", + "key": "Error", + "value": 0 + }, + { + "documentation": "Warning log level", + "key": "Warning", + "value": 1 + }, + { + "documentation": "Info log level", + "key": "Info", + "value": 2 + }, + { + "documentation": "Trace log level", + "key": "Trace", + "value": 3 + } + ] + }, + { + "documentation": "The available types of metrics.", + "name": "OrthancPluginMetricsType", + "since_sdk": [ + 1, + 5, + 4 + ], + "values": [ + { + "documentation": "Default metrics", + "key": "Default", + "value": 0 + }, + { + "documentation": "This metrics represents a time duration. Orthanc will keep the maximum value of the metrics over a sliding window of ten seconds, which is useful if the metrics is sampled frequently.", + "key": "Timer", + "value": 1 + } + ] + }, + { + "documentation": "The memory layout of the pixels of an image.", + "name": "OrthancPluginPixelFormat", + "values": [ + { + "documentation": "Graylevel 8bpp image. The image is graylevel. Each pixel is unsigned and stored in one byte.", + "key": "Grayscale8", + "value": 1 + }, + { + "documentation": "Graylevel, unsigned 16bpp image. The image is graylevel. Each pixel is unsigned and stored in two bytes.", + "key": "Grayscale16", + "value": 2 + }, + { + "documentation": "Graylevel, signed 16bpp image. The image is graylevel. Each pixel is signed and stored in two bytes.", + "key": "SignedGrayscale16", + "value": 3 + }, + { + "documentation": "Color image in RGB24 format. This format describes a color image. The pixels are stored in 3 consecutive bytes. The memory layout is RGB.", + "key": "RGB24", + "value": 4 + }, + { + "documentation": "Color image in RGBA32 format. This format describes a color image. The pixels are stored in 4 consecutive bytes. The memory layout is RGBA.", + "key": "RGBA32", + "value": 5 + }, + { + "documentation": "Unknown pixel format", + "key": "Unknown", + "value": 6 + }, + { + "documentation": "Color image in RGB48 format. This format describes a color image. The pixels are stored in 6 consecutive bytes. The memory layout is RRGGBB.", + "key": "RGB48", + "since_sdk": [ + 1, + 3, + 1 + ], + "value": 7 + }, + { + "documentation": "Graylevel, unsigned 32bpp image. The image is graylevel. Each pixel is unsigned and stored in four bytes.", + "key": "Grayscale32", + "since_sdk": [ + 1, + 3, + 1 + ], + "value": 8 + }, + { + "documentation": "Graylevel, floating-point 32bpp image. The image is graylevel. Each pixel is floating-point and stored in four bytes.", + "key": "Float32", + "since_sdk": [ + 1, + 3, + 1 + ], + "value": 9 + }, + { + "documentation": "Color image in BGRA32 format. This format describes a color image. The pixels are stored in 4 consecutive bytes. The memory layout is BGRA.", + "key": "BGRA32", + "since_sdk": [ + 1, + 3, + 1 + ], + "value": 10 + }, + { + "documentation": "Graylevel, unsigned 64bpp image. The image is graylevel. Each pixel is unsigned and stored in eight bytes.", + "key": "Grayscale64", + "since_sdk": [ + 1, + 4, + 0 + ], + "value": 11 + } + ] + }, + { + "documentation": "The supported modes to remove an element from a queue.", + "name": "OrthancPluginQueueOrigin", + "since_sdk": [ + 1, + 12, + 8 + ], + "values": [ + { + "documentation": "Dequeue from the front of the queue", + "key": "Front", + "value": 0 + }, + { + "documentation": "Dequeue from the back of the queue", + "key": "Back", + "value": 1 + } + ] + }, + { + "documentation": "The action to be taken after ReceivedInstanceCallback is triggered", + "name": "OrthancPluginReceivedInstanceAction", + "since_sdk": [ + 1, + 10, + 0 + ], + "values": [ + { + "documentation": "Keep the instance as is", + "key": "KeepAsIs", + "value": 1 + }, + { + "documentation": "Modify the instance", + "key": "Modify", + "value": 2 + }, + { + "documentation": "Discard the instance", + "key": "Discard", + "value": 3 + } + ] + }, + { + "documentation": "The supported types of DICOM resources.", + "name": "OrthancPluginResourceType", + "values": [ + { + "documentation": "Patient", + "key": "Patient", + "value": 0 + }, + { + "documentation": "Study", + "key": "Study", + "value": 1 + }, + { + "documentation": "Series", + "key": "Series", + "value": 2 + }, + { + "documentation": "Instance", + "key": "Instance", + "value": 3 + }, + { + "documentation": "Unavailable resource type", + "key": "None", + "value": 4 + } + ] + }, + { + "documentation": "The \"Stable\" status of a resource.", + "name": "OrthancPluginStableStatus", + "since_sdk": [ + 1, + 12, + 9 + ], + "values": [ + { + "documentation": "The resource is stable", + "key": "Stable", + "value": 0 + }, + { + "documentation": "The resource is unstable", + "key": "Unstable", + "value": 1 + } + ] + }, + { + "documentation": "The available values for the Failure Reason (0008,1197) during storage commitment. http://dicom.nema.org/medical/dicom/2019e/output/chtml/part03/sect_C.14.html#sect_C.14.1.1", + "name": "OrthancPluginStorageCommitmentFailureReason", + "since_sdk": [ + 1, + 6, + 0 + ], + "values": [ + { + "documentation": "Success: The DICOM instance is properly stored in the SCP", + "key": "Success", + "value": 0 + }, + { + "documentation": "0110H: A general failure in processing the operation was encountered", + "key": "ProcessingFailure", + "value": 1 + }, + { + "documentation": "0112H: One or more of the elements in the Referenced SOP Instance Sequence was not available", + "key": "NoSuchObjectInstance", + "value": 2 + }, + { + "documentation": "0213H: The SCP does not currently have enough resources to store the requested SOP Instance(s)", + "key": "ResourceLimitation", + "value": 3 + }, + { + "documentation": "0122H: Storage Commitment has been requested for a SOP Instance with a SOP Class that is not supported by the SCP", + "key": "ReferencedSOPClassNotSupported", + "value": 4 + }, + { + "documentation": "0119H: The SOP Class of an element in the Referenced SOP Instance Sequence did not correspond to the SOP class registered for this SOP Instance at the SCP", + "key": "ClassInstanceConflict", + "value": 5 + }, + { + "documentation": "0131H: The Transaction UID of the Storage Commitment Request is already in use", + "key": "DuplicateTransactionUID", + "value": 6 + } + ] + }, + { + "documentation": "The store status related to the adoption of a DICOM instance.", + "name": "OrthancPluginStoreStatus", + "since_sdk": [ + 1, + 12, + 8 + ], + "values": [ + { + "documentation": "The file has been stored/adopted", + "key": "Success", + "value": 0 + }, + { + "documentation": "The file has already been stored/adopted (only if OverwriteInstances is set to false)", + "key": "AlreadyStored", + "value": 1 + }, + { + "documentation": "The file could not be stored/adopted", + "key": "Failure", + "value": 2 + }, + { + "documentation": "The file has been filtered out by a Lua script or a plugin", + "key": "FilteredOut", + "value": 3 + }, + { + "documentation": "The storage is full (only if MaximumStorageSize/MaximumPatientCount is set and MaximumStorageMode is Reject)", + "key": "StorageFull", + "value": 4 + } + ] + }, + { + "documentation": "The value representations present in the DICOM standard (version 2013).", + "name": "OrthancPluginValueRepresentation", + "values": [ + { + "documentation": "Application Entity", + "key": "AE", + "value": 1 + }, + { + "documentation": "Age String", + "key": "AS", + "value": 2 + }, + { + "documentation": "Attribute Tag", + "key": "AT", + "value": 3 + }, + { + "documentation": "Code String", + "key": "CS", + "value": 4 + }, + { + "documentation": "Date", + "key": "DA", + "value": 5 + }, + { + "documentation": "Decimal String", + "key": "DS", + "value": 6 + }, + { + "documentation": "Date Time", + "key": "DT", + "value": 7 + }, + { + "documentation": "Floating Point Double", + "key": "FD", + "value": 8 + }, + { + "documentation": "Floating Point Single", + "key": "FL", + "value": 9 + }, + { + "documentation": "Integer String", + "key": "IS", + "value": 10 + }, + { + "documentation": "Long String", + "key": "LO", + "value": 11 + }, + { + "documentation": "Long Text", + "key": "LT", + "value": 12 + }, + { + "documentation": "Other Byte String", + "key": "OB", + "value": 13 + }, + { + "documentation": "Other Float String", + "key": "OF", + "value": 14 + }, + { + "documentation": "Other Word String", + "key": "OW", + "value": 15 + }, + { + "documentation": "Person Name", + "key": "PN", + "value": 16 + }, + { + "documentation": "Short String", + "key": "SH", + "value": 17 + }, + { + "documentation": "Signed Long", + "key": "SL", + "value": 18 + }, + { + "documentation": "Sequence of Items", + "key": "SQ", + "value": 19 + }, + { + "documentation": "Signed Short", + "key": "SS", + "value": 20 + }, + { + "documentation": "Short Text", + "key": "ST", + "value": 21 + }, + { + "documentation": "Time", + "key": "TM", + "value": 22 + }, + { + "documentation": "Unique Identifier (UID)", + "key": "UI", + "value": 23 + }, + { + "documentation": "Unsigned Long", + "key": "UL", + "value": 24 + }, + { + "documentation": "Unknown", + "key": "UN", + "value": 25 + }, + { + "documentation": "Unsigned Short", + "key": "US", + "value": 26 + }, + { + "documentation": "Unlimited Text", + "key": "UT", + "value": 27 + } + ] + } + ], + "global_functions": [ + { + "args": [ + { + "name": "arg0", + "sdk_name": "expectedMajor", + "sdk_type": "int32_t" + }, + { + "name": "arg1", + "sdk_name": "expectedMinor", + "sdk_type": "int32_t" + }, + { + "name": "arg2", + "sdk_name": "expectedRevision", + "sdk_type": "int32_t" + } + ], + "c_function": "OrthancPluginCheckVersionAdvanced", + "documentation": { + "args": { + "expectedMajor": "Expected major version.", + "expectedMinor": "Expected minor version.", + "expectedRevision": "Expected revision." + }, + "description": [ + "This function checks whether the version of the Orthanc server running this plugin, is above the given version. Contrarily to OrthancPluginCheckVersion(), it is up to the developer of the plugin to make sure that all the Orthanc SDK services called by the plugin are actually implemented in the given version of Orthanc." + ], + "return": "1 if and only if the versions are compatible. If the result is 0, the initialization of the plugin should fail.", + "summary": "Check that the version of the hosting Orthanc is above a given version." + }, + "return_sdk_type": "int32_t", + "since_sdk": [ + 1, + 4, + 0 + ] + }, + { + "args": [], + "c_function": "OrthancPluginCheckVersion", + "documentation": { + "args": {}, + "description": [ + "This function checks whether the version of the Orthanc server running this plugin, is above the version of the current Orthanc SDK header. This guarantees that the plugin is compatible with the hosting Orthanc (i.e. it will not call unavailable services). The result of this function should always be checked in the OrthancPluginInitialize() entry point of the plugin." + ], + "return": "1 if and only if the versions are compatible. If the result is 0, the initialization of the plugin should fail.", + "summary": "Check the compatibility of the plugin wrt. the version of its hosting Orthanc." + }, + "return_sdk_type": "int32_t" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "message", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginLogError", + "documentation": { + "args": { + "message": "The message to be logged." + }, + "description": [ + "Log an error message using the Orthanc logging system." + ], + "summary": "Log an error." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "message", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginLogWarning", + "documentation": { + "args": { + "message": "The message to be logged." + }, + "description": [ + "Log a warning message using the Orthanc logging system." + ], + "summary": "Log a warning." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "message", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginLogInfo", + "documentation": { + "args": { + "message": "The message to be logged." + }, + "description": [ + "Log an information message using the Orthanc logging system." + ], + "summary": "Log an information." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "instanceId", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginGetDicomForInstance", + "documentation": { + "args": { + "instanceId": "The Orthanc identifier of the DICOM instance of interest.", + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer()." + }, + "description": [ + "Retrieve a DICOM instance using its Orthanc identifier. The DICOM file is stored into a newly allocated memory buffer." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Retrieve a DICOM instance using its Orthanc identifier." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "uri", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginRestApiGet", + "documentation": { + "args": { + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", + "uri": "The URI in the built-in Orthanc API." + }, + "description": [ + "Make a GET call to the built-in Orthanc REST API. The result to the query is stored into a newly allocated memory buffer.", + "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Make a GET call to the built-in Orthanc REST API." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "uri", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginRestApiGetAfterPlugins", + "documentation": { + "args": { + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", + "uri": "The URI in the built-in Orthanc API." + }, + "description": [ + "Make a GET call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. The result to the query is stored into a newly allocated memory buffer.", + "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Make a GET call to the REST API, as tainted by the plugins." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "uri", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "body", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginRestApiPost", + "documentation": { + "args": { + "body": "The body of the POST request.", + "bodySize": "The size of the body.", + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", + "uri": "The URI in the built-in Orthanc API." + }, + "description": [ + "Make a POST call to the built-in Orthanc REST API. The result to the query is stored into a newly allocated memory buffer.", + "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Make a POST call to the built-in Orthanc REST API." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "uri", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "body", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginRestApiPostAfterPlugins", + "documentation": { + "args": { + "body": "The body of the POST request.", + "bodySize": "The size of the body.", + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", + "uri": "The URI in the built-in Orthanc API." + }, + "description": [ + "Make a POST call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. The result to the query is stored into a newly allocated memory buffer.", + "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Make a POST call to the REST API, as tainted by the plugins." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "uri", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginRestApiDelete", + "documentation": { + "args": { + "uri": "The URI to delete in the built-in Orthanc API." + }, + "description": [ + "Make a DELETE call to the built-in Orthanc REST API.", + "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Make a DELETE call to the built-in Orthanc REST API." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "uri", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginRestApiDeleteAfterPlugins", + "documentation": { + "args": { + "uri": "The URI to delete in the built-in Orthanc API." + }, + "description": [ + "Make a DELETE call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin.", + "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Make a DELETE call to the REST API, as tainted by the plugins." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "uri", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "body", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginRestApiPut", + "documentation": { + "args": { + "body": "The body of the PUT request.", + "bodySize": "The size of the body.", + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", + "uri": "The URI in the built-in Orthanc API." + }, + "description": [ + "Make a PUT call to the built-in Orthanc REST API. The result to the query is stored into a newly allocated memory buffer.", + "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Make a PUT call to the built-in Orthanc REST API." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "uri", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "body", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginRestApiPutAfterPlugins", + "documentation": { + "args": { + "body": "The body of the PUT request.", + "bodySize": "The size of the body.", + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", + "uri": "The URI in the built-in Orthanc API." + }, + "description": [ + "Make a PUT call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. The result to the query is stored into a newly allocated memory buffer.", + "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Make a PUT call to the REST API, as tainted by the plugins." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "patientID", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginLookupPatient", + "documentation": { + "args": { + "patientID": "The Patient ID of interest." + }, + "description": [ + "Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020). This function uses the database index to run as fast as possible (it does not loop over all the stored patients)." + ], + "return": "The NULL value if the patient is non-existent, or a string containing the Orthanc ID of the patient. This string must be freed by OrthancPluginFreeString().", + "summary": "Look for a patient." + }, + "return_sdk_type": "char *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "studyUID", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginLookupStudy", + "documentation": { + "args": { + "studyUID": "The Study Instance UID of interest." + }, + "description": [ + "Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d). This function uses the database index to run as fast as possible (it does not loop over all the stored studies)." + ], + "return": "The NULL value if the study is non-existent, or a string containing the Orthanc ID of the study. This string must be freed by OrthancPluginFreeString().", + "summary": "Look for a study." + }, + "return_sdk_type": "char *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "accessionNumber", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginLookupStudyWithAccessionNumber", + "documentation": { + "args": { + "accessionNumber": "The Accession Number of interest." + }, + "description": [ + "Look for a study stored in Orthanc, using its Accession Number tag (0x0008, 0x0050). This function uses the database index to run as fast as possible (it does not loop over all the stored studies)." + ], + "return": "The NULL value if the study is non-existent, or a string containing the Orthanc ID of the study. This string must be freed by OrthancPluginFreeString().", + "summary": "Look for a study, using the accession number." + }, + "return_sdk_type": "char *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "seriesUID", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginLookupSeries", + "documentation": { + "args": { + "seriesUID": "The Series Instance UID of interest." + }, + "description": [ + "Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e). This function uses the database index to run as fast as possible (it does not loop over all the stored series)." + ], + "return": "The NULL value if the series is non-existent, or a string containing the Orthanc ID of the series. This string must be freed by OrthancPluginFreeString().", + "summary": "Look for a series." + }, + "return_sdk_type": "char *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "sopInstanceUID", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginLookupInstance", + "documentation": { + "args": { + "sopInstanceUID": "The SOP Instance UID of interest." + }, + "description": [ + "Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018). This function uses the database index to run as fast as possible (it does not loop over all the stored instances)." + ], + "return": "The NULL value if the instance is non-existent, or a string containing the Orthanc ID of the instance. This string must be freed by OrthancPluginFreeString().", + "summary": "Look for an instance." + }, + "return_sdk_type": "char *" + }, + { + "args": [], + "c_function": "OrthancPluginGetOrthancPath", + "documentation": { + "args": {}, + "description": [ + "This function returns the path to the Orthanc executable." + ], + "return": "NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString().", + "summary": "Return the path to the Orthanc executable." + }, + "return_sdk_type": "char *" + }, + { + "args": [], + "c_function": "OrthancPluginGetOrthancDirectory", + "documentation": { + "args": {}, + "description": [ + "This function returns the path to the directory containing the Orthanc executable." + ], + "return": "NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString().", + "summary": "Return the directory containing the Orthanc." + }, + "return_sdk_type": "char *" + }, + { + "args": [], + "c_function": "OrthancPluginGetConfigurationPath", + "documentation": { + "args": {}, + "description": [ + "This function returns the path to the configuration file(s) that was specified when starting Orthanc. Since version 0.9.1, this path can refer to a folder that stores a set of configuration files. This function is deprecated in favor of OrthancPluginGetConfiguration()." + ], + "return": "NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString().", + "summary": "Return the path to the configuration file(s)." + }, + "return_sdk_type": "char *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "uri", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginSetRootUri", + "documentation": { + "args": { + "uri": "The root URI for this plugin." + }, + "description": [ + "For plugins that come with a Web interface, this function declares the entry path where to find this interface. This information is notably used in the \"Plugins\" page of Orthanc Explorer." + ], + "summary": "Set the URI where the plugin provides its Web interface." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "plugin", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "uri", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginSetRootUri2", + "documentation": { + "args": { + "plugin": "Identifier of your plugin (it must match \"OrthancPluginGetName()\").", + "uri": "The root URI for this plugin." + }, + "description": [ + "For plugins that come with a Web interface, this function declares the entry path where to find this interface. This information is notably used in the \"Plugins\" page of Orthanc Explorer." + ], + "summary": "Set the URI where the plugin provides its Web interface." + }, + "return_sdk_type": "void", + "since_sdk": [ + 1, + 12, + 4 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "description", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginSetDescription", + "documentation": { + "args": { + "description": "The description." + }, + "description": [ + "Set a description for this plugin. It is displayed in the \"Plugins\" page of Orthanc Explorer." + ], + "summary": "Set a description for this plugin." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "plugin", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "description", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginSetDescription2", + "documentation": { + "args": { + "description": "The description.", + "plugin": "Identifier of your plugin (it must match \"OrthancPluginGetName()\")." + }, + "description": [ + "Set a description for this plugin. It is displayed in the \"Plugins\" page of Orthanc Explorer." + ], + "summary": "Set a description for this plugin." + }, + "return_sdk_type": "void", + "since_sdk": [ + 1, + 12, + 4 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "javascript", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginExtendOrthancExplorer", + "documentation": { + "args": { + "javascript": "The custom JavaScript code." + }, + "description": [ + "Add JavaScript code to customize the default behavior of Orthanc Explorer. This can for instance be used to add new buttons." + ], + "summary": "Extend the JavaScript code of Orthanc Explorer." + }, + "return_sdk_type": "void" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "plugin", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "javascript", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginExtendOrthancExplorer2", + "documentation": { + "args": { + "javascript": "The custom JavaScript code.", + "plugin": "Identifier of your plugin (it must match \"OrthancPluginGetName()\")." + }, + "description": [ + "Add JavaScript code to customize the default behavior of Orthanc Explorer. This can for instance be used to add new buttons." + ], + "summary": "Extend the JavaScript code of Orthanc Explorer." + }, + "return_sdk_type": "void", + "since_sdk": [ + 1, + 12, + 4 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "property", + "sdk_type": "int32_t" + }, + { + "name": "arg1", + "sdk_name": "defaultValue", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginGetGlobalProperty", + "documentation": { + "args": { + "defaultValue": "The value to return, if the global property is unset.", + "property": "The global property of interest." + }, + "description": [ + "Get the value of a global property that is stored in the Orthanc database. Global properties whose index is below 1024 are reserved by Orthanc." + ], + "return": "The value of the global property, or NULL in the case of an error. This string must be freed by OrthancPluginFreeString().", + "summary": "Get the value of a global property." + }, + "return_sdk_type": "char *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "property", + "sdk_type": "int32_t" + }, + { + "name": "arg1", + "sdk_name": "value", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginSetGlobalProperty", + "documentation": { + "args": { + "property": "The global property of interest.", + "value": "The value to be set in the global property." + }, + "description": [ + "Set the value of a global property into the Orthanc database. Setting a global property can be used by plugins to save their internal parameters. Plugins are only allowed to set properties whose index are above or equal to 1024 (properties below 1024 are read-only and reserved by Orthanc)." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Set the value of a global property." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration" + }, + { + "args": [], + "c_function": "OrthancPluginGetCommandLineArgumentsCount", + "documentation": { + "args": {}, + "description": [ + "Retrieve the number of command-line arguments that were used to launch Orthanc." + ], + "return": "The number of arguments.", + "summary": "Get the number of command-line arguments." + }, + "return_sdk_type": "uint32_t" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "argument", + "sdk_type": "uint32_t" + } + ], + "c_function": "OrthancPluginGetCommandLineArgument", + "documentation": { + "args": { + "argument": "The index of the argument." + }, + "description": [ + "Get the value of one of the command-line arguments that were used to launch Orthanc. The number of available arguments can be retrieved by OrthancPluginGetCommandLineArgumentsCount()." + ], + "return": "The value of the argument, or NULL in the case of an error. This string must be freed by OrthancPluginFreeString().", + "summary": "Get the value of a command-line argument." + }, + "return_sdk_type": "char *" + }, + { + "args": [], + "c_function": "OrthancPluginGetExpectedDatabaseVersion", + "documentation": { + "args": {}, + "description": [ + "Retrieve the expected version of the database schema." + ], + "return": "The version.", + "summary": "Get the expected version of the database schema." + }, + "return_sdk_type": "uint32_t" + }, + { + "args": [], + "c_function": "OrthancPluginGetConfiguration", + "documentation": { + "args": {}, + "description": [ + "This function returns the content of the configuration that is used by Orthanc, formatted as a JSON string." + ], + "return": "NULL in the case of an error, or a newly allocated string containing the configuration. This string must be freed by OrthancPluginFreeString().", + "summary": "Return the content of the configuration file(s)." + }, + "return_sdk_type": "char *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "source", + "sdk_type": "const_void_pointer_with_size" + }, + { + "name": "arg2", + "sdk_enumeration": "OrthancPluginCompressionType", + "sdk_name": "compression", + "sdk_type": "enumeration" + }, + { + "name": "arg3", + "sdk_name": "uncompress", + "sdk_type": "uint8_t" + } + ], + "c_function": "OrthancPluginBufferCompression", + "documentation": { + "args": { + "compression": "The compression algorithm.", + "size": "The size in bytes of the source buffer.", + "source": "The source buffer.", + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", + "uncompress": "If set to \"0\", the buffer must be compressed. If set to \"1\", the buffer must be uncompressed." + }, + "description": [ + "This function compresses or decompresses a buffer, using the version of the zlib library that is used by the Orthanc core." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Compress or decompress a buffer." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "path", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginReadFile", + "documentation": { + "args": { + "path": "The path of the file to be read.", + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer()." + }, + "description": [ + "Read the content of a file on the filesystem, and returns it into a newly allocated memory buffer." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Read a file." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "path", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "data", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginWriteFile", + "documentation": { + "args": { + "data": "The content of the memory buffer.", + "path": "The path of the file to be written.", + "size": "The size of the memory buffer." + }, + "description": [ + "Write the content of a memory buffer to the filesystem." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Write a file." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration" + }, + { + "args": [ + { + "name": "arg0", + "sdk_enumeration": "OrthancPluginErrorCode", + "sdk_name": "error", + "sdk_type": "enumeration" + } + ], + "c_function": "OrthancPluginGetErrorDescription", + "documentation": { + "args": { + "error": "The error code of interest." + }, + "description": [ + "This function returns the description of a given error code." + ], + "return": "The error description. This is a statically-allocated string, do not free it.", + "summary": "Get the description of a given error code." + }, + "return_sdk_type": "const char *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "data", + "sdk_type": "const_void_pointer_with_size" + }, + { + "name": "arg2", + "sdk_enumeration": "OrthancPluginImageFormat", + "sdk_name": "format", + "sdk_type": "enumeration" + } + ], + "c_function": "OrthancPluginUncompressImage", + "documentation": { + "args": { + "data": "Pointer to a memory buffer containing the compressed image.", + "format": "The file format of the compressed image.", + "size": "Size of the memory buffer containing the compressed image." + }, + "description": [ + "This function decodes a compressed image from a memory buffer." + ], + "return": "The uncompressed image. It must be freed with OrthancPluginFreeImage().", + "summary": "Decode a compressed image." + }, + "return_sdk_class": "OrthancPluginImage", + "return_sdk_type": "object" + }, + { + "args": [ + { + "name": "arg0", + "sdk_enumeration": "OrthancPluginPixelFormat", + "sdk_name": "format", + "sdk_type": "enumeration" + }, + { + "name": "arg1", + "sdk_name": "width", + "sdk_type": "uint32_t" + }, + { + "name": "arg2", + "sdk_name": "height", + "sdk_type": "uint32_t" + }, + { + "name": "arg3", + "sdk_name": "pitch", + "sdk_type": "uint32_t" + }, + { + "name": "arg4", + "sdk_name": "buffer", + "sdk_type": "const void *" + } + ], + "c_function": "OrthancPluginCompressPngImage", + "documentation": { + "args": { + "buffer": "The memory buffer containing the uncompressed image.", + "format": "The memory layout of the uncompressed image.", + "height": "The height of the image.", + "pitch": "The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer).", + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", + "width": "The width of the image." + }, + "description": [ + "This function compresses the given memory buffer containing an image using the PNG specification, and stores the result of the compression into a newly allocated memory buffer." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Encode a PNG image." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_enumeration": "OrthancPluginPixelFormat", + "sdk_name": "format", + "sdk_type": "enumeration" + }, + { + "name": "arg1", + "sdk_name": "width", + "sdk_type": "uint32_t" + }, + { + "name": "arg2", + "sdk_name": "height", + "sdk_type": "uint32_t" + }, + { + "name": "arg3", + "sdk_name": "pitch", + "sdk_type": "uint32_t" + }, + { + "name": "arg4", + "sdk_name": "buffer", + "sdk_type": "const void *" + }, + { + "name": "arg5", + "sdk_name": "quality", + "sdk_type": "uint8_t" + } + ], + "c_function": "OrthancPluginCompressJpegImage", + "documentation": { + "args": { + "buffer": "The memory buffer containing the uncompressed image.", + "format": "The memory layout of the uncompressed image.", + "height": "The height of the image.", + "pitch": "The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer).", + "quality": "The quality of the JPEG encoding, between 1 (worst quality, best compression) and 100 (best quality, worst compression).", + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", + "width": "The width of the image." + }, + "description": [ + "This function compresses the given memory buffer containing an image using the JPEG specification, and stores the result of the compression into a newly allocated memory buffer." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Encode a JPEG image." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "url", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "username", + "sdk_type": "const char *" + }, + { + "name": "arg2", + "sdk_name": "password", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginHttpGet", + "documentation": { + "args": { + "password": "The password (can be \"NULL\" if no password protection).", + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", + "url": "The URL of interest.", + "username": "The username (can be \"NULL\" if no password protection)." + }, + "description": [ + "Make a HTTP GET call to the given URL. The result to the query is stored into a newly allocated memory buffer. Favor OrthancPluginRestApiGet() if calling the built-in REST API of the Orthanc instance that hosts this plugin." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Issue a HTTP GET call." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "url", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "body", + "sdk_type": "const_void_pointer_with_size" + }, + { + "name": "arg3", + "sdk_name": "username", + "sdk_type": "const char *" + }, + { + "name": "arg4", + "sdk_name": "password", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginHttpPost", + "documentation": { + "args": { + "body": "The content of the body of the request.", + "bodySize": "The size of the body of the request.", + "password": "The password (can be \"NULL\" if no password protection).", + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", + "url": "The URL of interest.", + "username": "The username (can be \"NULL\" if no password protection)." + }, + "description": [ + "Make a HTTP POST call to the given URL. The result to the query is stored into a newly allocated memory buffer. Favor OrthancPluginRestApiPost() if calling the built-in REST API of the Orthanc instance that hosts this plugin." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Issue a HTTP POST call." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "url", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "body", + "sdk_type": "const_void_pointer_with_size" + }, + { + "name": "arg3", + "sdk_name": "username", + "sdk_type": "const char *" + }, + { + "name": "arg4", + "sdk_name": "password", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginHttpPut", + "documentation": { + "args": { + "body": "The content of the body of the request.", + "bodySize": "The size of the body of the request.", + "password": "The password (can be \"NULL\" if no password protection).", + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", + "url": "The URL of interest.", + "username": "The username (can be \"NULL\" if no password protection)." + }, + "description": [ + "Make a HTTP PUT call to the given URL. The result to the query is stored into a newly allocated memory buffer. Favor OrthancPluginRestApiPut() if calling the built-in REST API of the Orthanc instance that hosts this plugin." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Issue a HTTP PUT call." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "url", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "username", + "sdk_type": "const char *" + }, + { + "name": "arg2", + "sdk_name": "password", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginHttpDelete", + "documentation": { + "args": { + "password": "The password (can be \"NULL\" if no password protection).", + "url": "The URL of interest.", + "username": "The username (can be \"NULL\" if no password protection)." + }, + "description": [ + "Make a HTTP DELETE call to the given URL. Favor OrthancPluginRestApiDelete() if calling the built-in REST API of the Orthanc instance that hosts this plugin." + ], + "return": "0 if success, or the error code if failure.", + "summary": "Issue a HTTP DELETE call." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration" + }, + { + "args": [], + "c_function": "OrthancPluginGetFontsCount", + "documentation": { + "args": {}, + "description": [ + "This function returns the number of fonts that are built in the Orthanc core. These fonts can be used to draw texts on images through OrthancPluginDrawText()." + ], + "return": "The number of fonts.", + "summary": "Return the number of available fonts." + }, + "return_sdk_type": "uint32_t" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "fontIndex", + "sdk_type": "uint32_t" + } + ], + "c_function": "OrthancPluginGetFontName", + "documentation": { + "args": { + "fontIndex": "The index of the font. This value must be less than OrthancPluginGetFontsCount()." + }, + "description": [ + "This function returns the name of a font that is built in the Orthanc core." + ], + "return": "The font name. This is a statically-allocated string, do not free it.", + "summary": "Return the name of a font." + }, + "return_sdk_type": "const char *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "fontIndex", + "sdk_type": "uint32_t" + } + ], + "c_function": "OrthancPluginGetFontSize", + "documentation": { + "args": { + "fontIndex": "The index of the font. This value must be less than OrthancPluginGetFontsCount()." + }, + "description": [ + "This function returns the size of a font that is built in the Orthanc core." + ], + "return": "The font size.", + "summary": "Return the size of a font." + }, + "return_sdk_type": "uint32_t" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "code", + "sdk_type": "int32_t" + }, + { + "name": "arg1", + "sdk_name": "httpStatus", + "sdk_type": "uint16_t" + }, + { + "name": "arg2", + "sdk_name": "message", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginRegisterErrorCode", + "documentation": { + "args": { + "code": "The error code that is internal to this plugin.", + "httpStatus": "The HTTP status corresponding to this error.", + "message": "The description of the error." + }, + "description": [ + "This function declares a custom error code that can be generated by this plugin. This declaration is used to enrich the body of the HTTP answer in the case of an error, and to set the proper HTTP status code." + ], + "return": "The error code that has been assigned inside the Orthanc core.", + "summary": "Declare a custom error code for this plugin." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "group", + "sdk_type": "uint16_t" + }, + { + "name": "arg1", + "sdk_name": "element", + "sdk_type": "uint16_t" + }, + { + "name": "arg2", + "sdk_enumeration": "OrthancPluginValueRepresentation", + "sdk_name": "vr", + "sdk_type": "enumeration" + }, + { + "name": "arg3", + "sdk_name": "name", + "sdk_type": "const char *" + }, + { + "name": "arg4", + "sdk_name": "minMultiplicity", + "sdk_type": "uint32_t" + }, + { + "name": "arg5", + "sdk_name": "maxMultiplicity", + "sdk_type": "uint32_t" + } + ], + "c_function": "OrthancPluginRegisterDictionaryTag", + "documentation": { + "args": { + "element": "The element of the tag.", + "group": "The group of the tag.", + "maxMultiplicity": "The maximum multiplicity of the tag. A value of 0 means an arbitrary multiplicity (\"\"n\"\").", + "minMultiplicity": "The minimum multiplicity of the tag (must be above 0).", + "name": "The nickname of the tag.", + "vr": "The value representation of the tag." + }, + "description": [ + "This function declares a new public tag in the dictionary of DICOM tags that are known to Orthanc. This function should be used in the OrthancPluginInitialize() callback." + ], + "return": "0 if success, other value if error.", + "summary": "Register a new tag into the DICOM dictionary." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "group", + "sdk_type": "uint16_t" + }, + { + "name": "arg1", + "sdk_name": "element", + "sdk_type": "uint16_t" + }, + { + "name": "arg2", + "sdk_enumeration": "OrthancPluginValueRepresentation", + "sdk_name": "vr", + "sdk_type": "enumeration" + }, + { + "name": "arg3", + "sdk_name": "name", + "sdk_type": "const char *" + }, + { + "name": "arg4", + "sdk_name": "minMultiplicity", + "sdk_type": "uint32_t" + }, + { + "name": "arg5", + "sdk_name": "maxMultiplicity", + "sdk_type": "uint32_t" + }, + { + "name": "arg6", + "sdk_name": "privateCreator", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginRegisterPrivateDictionaryTag", + "documentation": { + "args": { + "element": "The element of the tag.", + "group": "The group of the tag.", + "maxMultiplicity": "The maximum multiplicity of the tag. A value of 0 means an arbitrary multiplicity (\"\"n\"\").", + "minMultiplicity": "The minimum multiplicity of the tag (must be above 0).", + "name": "The nickname of the tag.", + "privateCreator": "The private creator of this private tag.", + "vr": "The value representation of the tag." + }, + "description": [ + "This function declares a new private tag in the dictionary of DICOM tags that are known to Orthanc. This function should be used in the OrthancPluginInitialize() callback." + ], + "return": "0 if success, other value if error.", + "summary": "Register a new private tag into the DICOM dictionary." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration", + "since_sdk": [ + 1, + 2, + 0 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "buffer", + "sdk_type": "const_void_pointer_with_size" + }, + { + "name": "arg2", + "sdk_enumeration": "OrthancPluginDicomToJsonFormat", + "sdk_name": "format", + "sdk_type": "enumeration" + }, + { + "name": "arg3", + "sdk_enumeration": "OrthancPluginDicomToJsonFlags", + "sdk_name": "flags", + "sdk_type": "enumeration" + }, + { + "name": "arg4", + "sdk_name": "maxStringLength", + "sdk_type": "uint32_t" + } + ], + "c_function": "OrthancPluginDicomBufferToJson", + "documentation": { + "args": { + "buffer": "The memory buffer containing the DICOM file.", + "flags": "Flags governing the output.", + "format": "The output format.", + "maxStringLength": "The maximum length of a field. Too long fields will be output as \"null\". The 0 value means no maximum length.", + "size": "The size of the memory buffer." + }, + "description": [ + "This function takes as input a memory buffer containing a DICOM file, and outputs a JSON string representing the tags of this DICOM file." + ], + "return": "The NULL value if the case of an error, or the JSON string. This string must be freed by OrthancPluginFreeString().", + "summary": "Format a DICOM memory buffer as a JSON string." + }, + "return_sdk_type": "char *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "instanceId", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_enumeration": "OrthancPluginDicomToJsonFormat", + "sdk_name": "format", + "sdk_type": "enumeration" + }, + { + "name": "arg2", + "sdk_enumeration": "OrthancPluginDicomToJsonFlags", + "sdk_name": "flags", + "sdk_type": "enumeration" + }, + { + "name": "arg3", + "sdk_name": "maxStringLength", + "sdk_type": "uint32_t" + } + ], + "c_function": "OrthancPluginDicomInstanceToJson", + "documentation": { + "args": { + "flags": "Flags governing the output.", + "format": "The output format.", + "instanceId": "The Orthanc identifier of the instance.", + "maxStringLength": "The maximum length of a field. Too long fields will be output as \"null\". The 0 value means no maximum length." + }, + "description": [ + "This function formats a DICOM instance that is stored in Orthanc, and outputs a JSON string representing the tags of this DICOM instance." + ], + "return": "The NULL value if the case of an error, or the JSON string. This string must be freed by OrthancPluginFreeString().", + "summary": "Format a DICOM instance as a JSON string." + }, + "return_sdk_type": "char *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "json", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_class": "OrthancPluginImage", + "sdk_name": "pixelData", + "sdk_type": "const_object" + }, + { + "name": "arg2", + "sdk_enumeration": "OrthancPluginCreateDicomFlags", + "sdk_name": "flags", + "sdk_type": "enumeration" + } + ], + "c_function": "OrthancPluginCreateDicom", + "documentation": { + "args": { + "flags": "Flags governing the output.", + "json": "The input JSON file.", + "pixelData": "The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme.", + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer()." + }, + "description": [ + "This function takes as input a string containing a JSON file describing the content of a DICOM instance. As an output, it writes the corresponding DICOM instance to a newly allocated memory buffer. Additionally, an image to be encoded within the DICOM instance can also be provided.", + "Private tags will be associated with the private creator whose value is specified in the \"DefaultPrivateCreator\" configuration option of Orthanc. The function OrthancPluginCreateDicom2() can be used if another private creator must be used to create this instance." + ], + "return": "0 if success, other value if error.", + "summary": "Create a DICOM instance from a JSON string and an image." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_enumeration": "OrthancPluginPixelFormat", + "sdk_name": "format", + "sdk_type": "enumeration" + }, + { + "name": "arg1", + "sdk_name": "width", + "sdk_type": "uint32_t" + }, + { + "name": "arg2", + "sdk_name": "height", + "sdk_type": "uint32_t" + } + ], + "c_function": "OrthancPluginCreateImage", + "documentation": { + "args": { + "format": "The format of the pixels.", + "height": "The height of the image.", + "width": "The width of the image." + }, + "description": [ + "This function creates an image of given size and format." + ], + "return": "The newly allocated image. It must be freed with OrthancPluginFreeImage().", + "summary": "Create an image." + }, + "return_sdk_class": "OrthancPluginImage", + "return_sdk_type": "object" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "buffer", + "sdk_type": "const_void_pointer_with_size" + }, + { + "name": "arg2", + "sdk_name": "frameIndex", + "sdk_type": "uint32_t" + } + ], + "c_function": "OrthancPluginDecodeDicomImage", + "documentation": { + "args": { + "buffer": "Pointer to a memory buffer containing the DICOM image.", + "bufferSize": "Size of the memory buffer containing the DICOM image.", + "frameIndex": "The index of the frame of interest in a multi-frame image." + }, + "description": [ + "This function decodes one frame of a DICOM image that is stored in a memory buffer. This function will give the same result as OrthancPluginUncompressImage() for single-frame DICOM images." + ], + "return": "The uncompressed image. It must be freed with OrthancPluginFreeImage().", + "summary": "Decode one frame from a DICOM instance." + }, + "return_sdk_class": "OrthancPluginImage", + "return_sdk_type": "object" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "buffer", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginComputeMd5", + "documentation": { + "args": { + "buffer": "The source memory buffer.", + "size": "The size in bytes of the source buffer." + }, + "description": [ + "This functions computes the MD5 cryptographic hash of the given memory buffer." + ], + "return": "The NULL value in case of error, or a string containing the cryptographic hash. This string must be freed by OrthancPluginFreeString().", + "summary": "Compute an MD5 hash." + }, + "return_sdk_type": "char *" + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "buffer", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginComputeSha1", + "documentation": { + "args": { + "buffer": "The source memory buffer.", + "size": "The size in bytes of the source buffer." + }, + "description": [ + "This functions computes the SHA-1 cryptographic hash of the given memory buffer." + ], + "return": "The NULL value in case of error, or a string containing the cryptographic hash. This string must be freed by OrthancPluginFreeString().", + "summary": "Compute a SHA-1 hash." + }, + "return_sdk_type": "char *" + }, + { + "args": [], + "c_function": "OrthancPluginGenerateUuid", + "documentation": { + "args": {}, + "description": [ + "Generate a random GUID/UUID (globally unique identifier)." + ], + "return": "NULL in the case of an error, or a newly allocated string containing the UUID. This string must be freed by OrthancPluginFreeString().", + "summary": "Generate an UUID." + }, + "return_sdk_type": "char *", + "since_sdk": [ + 1, + 1, + 0 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "query", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginCreateFindMatcher", + "documentation": { + "args": { + "query": "The C-Find DICOM query.", + "size": "The size of the DICOM query." + }, + "description": [ + "This function creates a \"matcher\" object that can be used to check whether a DICOM instance matches a C-Find query. The C-Find query must be expressed as a DICOM buffer." + ], + "return": "The newly allocated matcher. It must be freed with OrthancPluginFreeFindMatcher().", + "summary": "Create a C-Find matcher." + }, + "return_sdk_class": "OrthancPluginFindMatcher", + "return_sdk_type": "object", + "since_sdk": [ + 1, + 2, + 0 + ] + }, + { + "args": [], + "c_function": "OrthancPluginGetPeers", + "documentation": { + "args": {}, + "description": [ + "This function returns the parameters of the Orthanc peers that are known to the Orthanc server hosting the plugin." + ], + "return": "NULL if error, or a newly allocated opaque data structure containing the peers. This structure must be freed with OrthancPluginFreePeers().", + "summary": "Return the list of available Orthanc peers." + }, + "return_sdk_class": "OrthancPluginPeers", + "return_sdk_type": "object", + "since_sdk": [ + 1, + 4, + 2 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "path", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginAutodetectMimeType", + "documentation": { + "args": { + "path": "Path to the file." + }, + "description": [ + "This function returns the MIME type of a file by inspecting its extension." + ], + "return": "The MIME type. This is a statically-allocated string, do not free it.", + "summary": "Detect the MIME type of a file." + }, + "return_sdk_type": "const char *", + "since_sdk": [ + 1, + 5, + 0 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "name", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "value", + "sdk_type": "float" + }, + { + "name": "arg2", + "sdk_enumeration": "OrthancPluginMetricsType", + "sdk_name": "type", + "sdk_type": "enumeration" + } + ], + "c_function": "OrthancPluginSetMetricsValue", + "documentation": { + "args": { + "name": "The name of the metrics to be set.", + "type": "The type of the metrics. This parameter is only taken into consideration the first time this metrics is set.", + "value": "The value of the metrics." + }, + "description": [ + "This function sets the value of a floating-point metrics to monitor the behavior of the plugin through tools such as Prometheus. The values of all the metrics are stored within the Orthanc context." + ], + "summary": "Set the value of a floating-point metrics." + }, + "return_sdk_type": "void", + "since_sdk": [ + 1, + 5, + 4 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "group", + "sdk_type": "uint16_t" + }, + { + "name": "arg1", + "sdk_name": "element", + "sdk_type": "uint16_t" + }, + { + "name": "arg2", + "sdk_name": "privateCreator", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginGetTagName", + "documentation": { + "args": { + "element": "The element of the tag.", + "group": "The group of the tag.", + "privateCreator": "For private tags, the name of the private creator (can be NULL)." + }, + "description": [ + "This function makes a lookup to the dictionary of DICOM tags that are known to Orthanc, and returns the symbolic name of a DICOM tag." + ], + "return": "NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString().", + "summary": "Returns the symbolic name of a DICOM tag." + }, + "return_sdk_type": "char *", + "since_sdk": [ + 1, + 5, + 7 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "buffer", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginCreateDicomInstance", + "documentation": { + "args": { + "buffer": "The memory buffer containing the DICOM instance.", + "size": "The size of the memory buffer." + }, + "description": [ + "This function parses a memory buffer that contains a DICOM file. The function returns a new pointer to a data structure that is managed by the Orthanc core." + ], + "return": "The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance().", + "summary": "Parse a DICOM instance." + }, + "return_sdk_class": "OrthancPluginDicomInstance", + "return_sdk_type": "object", + "since_sdk": [ + 1, + 7, + 0 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "buffer", + "sdk_type": "const_void_pointer_with_size" + }, + { + "name": "arg2", + "sdk_name": "transferSyntax", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginTranscodeDicomInstance", + "documentation": { + "args": { + "buffer": "The memory buffer containing the DICOM instance.", + "size": "The size of the memory buffer.", + "transferSyntax": "The transfer syntax UID for the transcoding." + }, + "description": [ + "This function parses a memory buffer that contains a DICOM file, then transcodes it to the given transfer syntax. The function returns a new pointer to a data structure that is managed by the Orthanc core." + ], + "return": "The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance().", + "summary": "Parse and transcode a DICOM instance." + }, + "return_sdk_class": "OrthancPluginDicomInstance", + "return_sdk_type": "object", + "since_sdk": [ + 1, + 7, + 0 + ] + }, + { + "args": [], + "c_function": "OrthancPluginGenerateRestApiAuthorizationToken", + "documentation": { + "args": {}, + "description": [ + "This function generates a token that can be set in the HTTP header \"Authorization\" so as to grant full access to the REST API of Orthanc using an external HTTP client. Using this function avoids the need of adding a separate user in the \"RegisteredUsers\" configuration of Orthanc, which eases deployments.", + "This feature is notably useful in multiprocess scenarios, where a subprocess created by a plugin has no access to the \"OrthancPluginContext\", and thus cannot call \"OrthancPluginRestApi[Get|Post|Put|Delete]()\".", + "This situation is frequently encountered in Python plugins, where the \"multiprocessing\" package can be used to bypass the Global Interpreter Lock (GIL) and thus to improve performance and concurrency." + ], + "return": "The authorization token, or NULL value in the case of an error. This string must be freed by OrthancPluginFreeString().", + "summary": "Generate a token to grant full access to the REST API of Orthanc." + }, + "return_sdk_type": "char *", + "since_sdk": [ + 1, + 8, + 1 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "json", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_class": "OrthancPluginImage", + "sdk_name": "pixelData", + "sdk_type": "const_object" + }, + { + "name": "arg2", + "sdk_enumeration": "OrthancPluginCreateDicomFlags", + "sdk_name": "flags", + "sdk_type": "enumeration" + }, + { + "name": "arg3", + "sdk_name": "privateCreator", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginCreateDicom2", + "documentation": { + "args": { + "flags": "Flags governing the output.", + "json": "The input JSON file.", + "pixelData": "The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme.", + "privateCreator": "The private creator to be used for the private DICOM tags. Check out the global configuration option \"Dictionary\" of Orthanc.", + "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer()." + }, + "description": [ + "This function takes as input a string containing a JSON file describing the content of a DICOM instance. As an output, it writes the corresponding DICOM instance to a newly allocated memory buffer. Additionally, an image to be encoded within the DICOM instance can also be provided.", + "Contrarily to the function OrthancPluginCreateDicom(), this function can be explicitly provided with a private creator." + ], + "return": "0 if success, other value if error.", + "summary": "Create a DICOM instance from a JSON string and an image, with a private creator." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *", + "since_sdk": [ + 1, + 9, + 0 + ] + }, + { + "args": [], + "c_function": "OrthancPluginGetDatabaseServerIdentifier", + "documentation": { + "args": {}, + "description": [], + "return": "the database server identifier. This is a statically-allocated string, do not free it.", + "summary": "Gets the DatabaseServerIdentifier." + }, + "return_sdk_type": "const char *", + "since_sdk": [ + 1, + 11, + 1 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "instanceId", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_enumeration": "OrthancPluginLoadDicomInstanceMode", + "sdk_name": "mode", + "sdk_type": "enumeration" + } + ], + "c_function": "OrthancPluginLoadDicomInstance", + "documentation": { + "args": { + "instanceId": "The Orthanc identifier of the DICOM instance of interest.", + "mode": "Flag specifying how to deal with pixel data." + }, + "description": [ + "This function loads a DICOM instance from the content of the Orthanc database. The function returns a new pointer to a data structure that is managed by the Orthanc core." + ], + "return": "The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance().", + "summary": "Load a DICOM instance from the Orthanc server." + }, + "return_sdk_class": "OrthancPluginDicomInstance", + "return_sdk_type": "object", + "since_sdk": [ + 1, + 12, + 1 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "name", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "value", + "sdk_type": "int64_t" + }, + { + "name": "arg2", + "sdk_enumeration": "OrthancPluginMetricsType", + "sdk_name": "type", + "sdk_type": "enumeration" + } + ], + "c_function": "OrthancPluginSetMetricsIntegerValue", + "documentation": { + "args": { + "name": "The name of the metrics to be set.", + "type": "The type of the metrics. This parameter is only taken into consideration the first time this metrics is set.", + "value": "The value of the metrics." + }, + "description": [ + "This function sets the value of an integer metrics to monitor the behavior of the plugin through tools such as Prometheus. The values of all the metrics are stored within the Orthanc context." + ], + "summary": "Set the value of an integer metrics." + }, + "return_sdk_type": "void", + "since_sdk": [ + 1, + 12, + 1 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "threadName", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginSetCurrentThreadName", + "documentation": { + "args": { + "threadName": "The name of the current thread. A thread name cannot be longer than 16 characters." + }, + "description": [ + "This function gives a name to the thread that is calling this function. This name is used in the Orthanc logs. This function must only be called from threads that the plugin has created itself." + ], + "return": "0 if success, other value if error.", + "summary": "Set the name of the current thread." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration", + "since_sdk": [ + 1, + 12, + 2 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "message", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "plugin", + "sdk_type": "const char *" + }, + { + "name": "arg2", + "sdk_name": "file", + "sdk_type": "const char *" + }, + { + "name": "arg3", + "sdk_name": "line", + "sdk_type": "uint32_t" + }, + { + "name": "arg4", + "sdk_enumeration": "OrthancPluginLogCategory", + "sdk_name": "category", + "sdk_type": "enumeration" + }, + { + "name": "arg5", + "sdk_enumeration": "OrthancPluginLogLevel", + "sdk_name": "level", + "sdk_type": "enumeration" + } + ], + "c_function": "OrthancPluginLogMessage", + "documentation": { + "args": { + "category": "The category.", + "file": "The filename in the plugin code.", + "level": "The level of the message.", + "line": "The file line in the plugin code.", + "message": "The message to be logged.", + "plugin": "The plugin name." + }, + "description": [ + "Log a message using the Orthanc logging system." + ], + "summary": "Log a message." + }, + "return_sdk_type": "void", + "since_sdk": [ + 1, + 12, + 4 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "attachmentUuid", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginGetAttachmentCustomData", + "documentation": { + "args": { + "attachmentUuid": "The UUID of the attachment of interest.", + "customData": "Memory buffer where to store the retrieved value. It must be freed by the plugin by calling OrthancPluginFreeMemoryBuffer()." + }, + "description": [ + "If no custom data is associated with the attachment of interest, the target memory buffer is filled with the NULL value and a zero size." + ], + "return": "0 if success, other value if error.", + "summary": "Retrieve the custom data associated with an attachment in the Orthanc database." + }, + "return_sdk_type": "OrthancPluginMemoryBuffer *", + "since_sdk": [ + 1, + 12, + 8 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "attachmentUuid", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "customData", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginSetAttachmentCustomData", + "documentation": { + "args": { + "attachmentUuid": "The UUID of the attachment of interest.", + "customData": "The value to store.", + "customDataSize": "The size of the value to store." + }, + "description": [ + "This function is notably used in the \"orthanc-advanced-storage\" when the plugin moves an attachment." + ], + "return": "0 if success, other value if error.", + "summary": "Update the custom data associated with an attachment in the Orthanc database." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration", + "since_sdk": [ + 1, + 12, + 8 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "storeId", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "key", + "sdk_type": "const char *" + }, + { + "name": "arg2", + "sdk_name": "value", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginStoreKeyValue", + "documentation": { + "args": { + "key": "The key of the value to store (note: storeId + key must be unique).", + "storeId": "A unique identifier identifying both the plugin and the key-value store.", + "value": "The value to store.", + "valueSize": "The length of the value to store." + }, + "description": [], + "return": "0 if success, other value if error.", + "summary": "Store a key-value pair in the Orthanc database." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration", + "since_sdk": [ + 1, + 12, + 8 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "storeId", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "key", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginDeleteKeyValue", + "documentation": { + "args": { + "key": "The key of the value to store (note: storeId + key must be unique).", + "storeId": "A unique identifier identifying both the plugin and the key-value store." + }, + "description": [], + "return": "0 if success, other value if error.", + "summary": "Delete a key-value pair from the Orthanc database." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration", + "since_sdk": [ + 1, + 12, + 8 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "storeId", + "sdk_type": "const char *" + } + ], + "c_function": "OrthancPluginCreateKeysValuesIterator", + "documentation": { + "args": { + "storeId": "A unique identifier identifying both the plugin and the key-value store." + }, + "description": [ + "The iterator loops over the keys according to the lexicographical order." + ], + "return": "The newly allocated iterator, or NULL in the case of an error. The iterator must be freed by calling OrthancPluginFreeKeysValuesIterator().", + "summary": "Create an iterator over the key-value pairs of a key-value store in the Orthanc database." + }, + "return_sdk_class": "OrthancPluginKeysValuesIterator", + "return_sdk_type": "object", + "since_sdk": [ + 1, + 12, + 8 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "queueId", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "value", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginEnqueueValue", + "documentation": { + "args": { + "queueId": "A unique identifier identifying both the plugin and the queue.", + "value": "The value to store.", + "valueSize": "The size of the value to store." + }, + "description": [], + "return": "0 if success, other value if error.", + "summary": "Append a value to the back of a queue." + }, + "return_sdk_enumeration": "OrthancPluginErrorCode", + "return_sdk_type": "enumeration", + "since_sdk": [ + 1, + 12, + 8 + ] + }, + { + "args": [ + { + "name": "arg0", + "sdk_name": "sourcePlugin", + "sdk_type": "const char *" + }, + { + "name": "arg1", + "sdk_name": "userId", + "sdk_type": "const char *" + }, + { + "name": "arg2", + "sdk_enumeration": "OrthancPluginResourceType", + "sdk_name": "resourceType", + "sdk_type": "enumeration" + }, + { + "name": "arg3", + "sdk_name": "resourceId", + "sdk_type": "const char *" + }, + { + "name": "arg4", + "sdk_name": "action", + "sdk_type": "const char *" + }, + { + "name": "arg5", + "sdk_name": "logData", + "sdk_type": "const_void_pointer_with_size" + } + ], + "c_function": "OrthancPluginEmitAuditLog", + "documentation": { + "args": { + "action": "The action that was performed on the resource.", + "logData": "A pointer to custom log data.", + "logDataSize": "The size of the custom log data.", + "resourceId": "The resource this audit log relates to.", + "resourceType": "The type of the resource this audit log relates to.", + "sourcePlugin": "The name of the source plugin, to properly interpret the content of \"action\" and \"logData\".", + "userId": "A string that uniquely identifies the user or entity that is executing the action on the resource." + }, + "description": [ + "Generate an audit log that will be broadcasted to all the plugins that have registered a callback handler using OrthancPluginRegisterAuditLogHandler(). If no plugin has registered such a callback, the audit log is ignored.", + "A typical handler would record the audit log in a database and/or relay the audit log to a message broker." + ], + "summary": "Generate an audit log to signal security-related events." + }, + "return_sdk_type": "void", + "since_sdk": [ + 1, + 12, + 9 + ] + } + ] +} \ No newline at end of file diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp --- a/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp Wed Aug 13 12:02:04 2025 +0200 @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -219,28 +220,6 @@ } -#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 7, 0) - MemoryBuffer::MemoryBuffer(const void* buffer, - size_t size) - { - uint32_t s = static_cast(size); - if (static_cast(s) != size) - { - ORTHANC_PLUGINS_THROW_EXCEPTION(NotEnoughMemory); - } - else if (OrthancPluginCreateMemoryBuffer(GetGlobalContext(), &buffer_, s) != - OrthancPluginErrorCode_Success) - { - ORTHANC_PLUGINS_THROW_EXCEPTION(NotEnoughMemory); - } - else - { - memcpy(buffer_.data, buffer, size); - } - } -#endif - - void MemoryBuffer::Clear() { if (buffer_.data != NULL) @@ -252,6 +231,51 @@ } +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 7, 0) + void MemoryBuffer::Assign(const void* buffer, + size_t size) + { + uint32_t s = static_cast(size); + if (static_cast(s) != size) + { + ORTHANC_PLUGINS_THROW_EXCEPTION(NotEnoughMemory); + } + + Clear(); + + if (OrthancPluginCreateMemoryBuffer(GetGlobalContext(), &buffer_, s) != + OrthancPluginErrorCode_Success) + { + ORTHANC_PLUGINS_THROW_EXCEPTION(NotEnoughMemory); + } + else + { + if (size > 0) + { + memcpy(buffer_.data, buffer, size); + } + } + } +#endif + +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 7, 0) + void MemoryBuffer::Assign(const std::string& s) + { + Assign(s.empty() ? NULL : s.c_str(), s.size()); + } +#endif + + +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 7, 0) + void MemoryBuffer::AssignJson(const Json::Value& value) + { + std::string s; + WriteFastJson(s, value); + Assign(s); + } +#endif + + void MemoryBuffer::Assign(OrthancPluginMemoryBuffer& other) { Clear(); @@ -672,7 +696,7 @@ { OrthancString str; str.Assign(OrthancPluginDicomBufferToJson - (GetGlobalContext(), GetData(), GetSize(), format, flags, maxStringLength)); + (GetGlobalContext(), reinterpret_cast(GetData()), GetSize(), format, flags, maxStringLength)); str.ToJson(target); } @@ -1565,7 +1589,7 @@ { if (!answer.IsEmpty()) { - result.assign(answer.GetData(), answer.GetSize()); + result.assign(reinterpret_cast(answer.GetData()), answer.GetSize()); } return true; } @@ -2051,6 +2075,26 @@ DoPost(target, index, uri, body, headers)); } + bool OrthancPeers::DoPost(Json::Value& target, + size_t index, + const std::string& uri, + const std::string& body, + const HttpHeaders& headers, + unsigned int timeout) const + { + MemoryBuffer buffer; + + if (DoPost(buffer, index, uri, body, headers, timeout)) + { + buffer.ToJson(target); + return true; + } + else + { + return false; + } + } + bool OrthancPeers::DoPost(Json::Value& target, size_t index, @@ -2098,6 +2142,17 @@ const std::string& body, const HttpHeaders& headers) const { + return DoPost(target, index, uri, body, headers, timeout_); + } + + + bool OrthancPeers::DoPost(MemoryBuffer& target, + size_t index, + const std::string& uri, + const std::string& body, + const HttpHeaders& headers, + unsigned int timeout) const + { if (index >= index_.size()) { ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); @@ -2116,7 +2171,7 @@ OrthancPluginErrorCode code = OrthancPluginCallPeerApi (GetGlobalContext(), *answer, NULL, &status, peers_, static_cast(index), OrthancPluginHttpMethod_Post, uri.c_str(), - pluginHeaders.GetSize(), pluginHeaders.GetKeys(), pluginHeaders.GetValues(), body.empty() ? NULL : body.c_str(), body.size(), timeout_); + pluginHeaders.GetSize(), pluginHeaders.GetKeys(), pluginHeaders.GetValues(), body.empty() ? NULL : body.c_str(), body.size(), timeout); if (code == OrthancPluginErrorCode_Success) { @@ -4067,6 +4122,16 @@ } #endif + void GetGetArguments(GetArguments& result, const OrthancPluginHttpRequest* request) + { + result.clear(); + + for (uint32_t i = 0; i < request->getCount; ++i) + { + result[request->getKeys[i]] = request->getValues[i]; + } + } + void GetHttpHeaders(HttpHeaders& result, const OrthancPluginHttpRequest* request) { result.clear(); @@ -4077,6 +4142,26 @@ } } + void SerializeGetArguments(std::string& output, const OrthancPluginHttpRequest* request) + { + output.clear(); + std::vector arguments; + for (uint32_t i = 0; i < request->getCount; ++i) + { + if (request->getValues[i] && strlen(request->getValues[i]) > 0) + { + arguments.push_back(std::string(request->getKeys[i]) + "=" + std::string(request->getValues[i])); + } + else + { + arguments.push_back(std::string(request->getKeys[i])); + } + } + + output = boost::algorithm::join(arguments, "&"); + } + + #if !ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 4) static void SetPluginProperty(const std::string& pluginIdentifier, _OrthancPluginProperty property, @@ -4130,6 +4215,29 @@ httpStatus_(0) { } + + RestApiClient::RestApiClient(const char* url, + const OrthancPluginHttpRequest* request) : + method_(request->method), + path_(url), + afterPlugins_(false), + httpStatus_(0) + { + OrthancPlugins::GetHttpHeaders(requestHeaders_, request); + + std::string getArguments; + OrthancPlugins::SerializeGetArguments(getArguments, request); + + if (!getArguments.empty()) + { + path_ += "?" + getArguments; + } + + if (request->bodySize > 0 && request->body != NULL) + { + requestBody_.assign(reinterpret_cast(request->body), request->bodySize); + } + } #endif @@ -4150,6 +4258,15 @@ #if HAS_ORTHANC_PLUGIN_GENERIC_CALL_REST_API == 1 + void RestApiClient::SetRequestHeader(const std::string& key, + const std::string& value) + { + requestHeaders_[key] = value; + } +#endif + + +#if HAS_ORTHANC_PLUGIN_GENERIC_CALL_REST_API == 1 bool RestApiClient::Execute() { if (requestBody_.size() > 0xffffffffu) @@ -4195,6 +4312,40 @@ } } } + + void RestApiClient::ExecuteAndForwardAnswer(OrthancPluginContext* context, OrthancPluginRestOutput* output) + { + if (Execute()) + { + ForwardAnswer(context, output); + } + } + + void RestApiClient::ForwardAnswer(OrthancPluginContext* context, OrthancPluginRestOutput* output) + { + if (httpStatus_ == 200) + { + const char* mimeType = NULL; + for (HttpHeaders::const_iterator h = answerHeaders_.begin(); h != answerHeaders_.end(); ++h) + { + if (h->first == "content-type") + { + mimeType = h->second.c_str(); + } + } + + AnswerString(answerBody_, mimeType, output); + } + else + { + AnswerHttpError(httpStatus_, output); + } + } + + bool RestApiClient::GetAnswerJson(Json::Value& output) const + { + return ReadJson(output, answerBody_); + } #endif @@ -4251,4 +4402,209 @@ } } #endif + + +#if HAS_ORTHANC_PLUGIN_KEY_VALUE_STORES == 1 + KeyValueStore::Iterator::Iterator(OrthancPluginKeysValuesIterator *iterator) : + iterator_(iterator) + { + if (iterator_ == NULL) + { + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); + } + } +#endif + + +#if HAS_ORTHANC_PLUGIN_KEY_VALUE_STORES == 1 + KeyValueStore::Iterator::~Iterator() + { + OrthancPluginFreeKeysValuesIterator(OrthancPlugins::GetGlobalContext(), iterator_); + } +#endif + + +#if HAS_ORTHANC_PLUGIN_KEY_VALUE_STORES == 1 + bool KeyValueStore::Iterator::Next() + { + uint8_t done; + OrthancPluginErrorCode code = OrthancPluginKeysValuesIteratorNext(OrthancPlugins::GetGlobalContext(), &done, iterator_); + + if (code != OrthancPluginErrorCode_Success) + { + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code); + } + else + { + return (done != 0); + } + } +#endif + + +#if HAS_ORTHANC_PLUGIN_KEY_VALUE_STORES == 1 + std::string KeyValueStore::Iterator::GetKey() const + { + const char* s = OrthancPluginKeysValuesIteratorGetKey(OrthancPlugins::GetGlobalContext(), iterator_); + if (s == NULL) + { + ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); + } + else + { + return s; + } + } +#endif + + +#if HAS_ORTHANC_PLUGIN_KEY_VALUE_STORES == 1 + void KeyValueStore::Iterator::GetValue(std::string& value) const + { + OrthancPlugins::MemoryBuffer valueBuffer; + OrthancPluginErrorCode code = OrthancPluginKeysValuesIteratorGetValue(OrthancPlugins::GetGlobalContext(), *valueBuffer, iterator_); + + if (code != OrthancPluginErrorCode_Success) + { + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code); + } + else + { + valueBuffer.ToString(value); + } + } +#endif + + +#if HAS_ORTHANC_PLUGIN_KEY_VALUE_STORES == 1 + void KeyValueStore::Store(const std::string& key, + const void* value, + size_t valueSize) + { + if (static_cast(static_cast(valueSize)) != valueSize) + { + ORTHANC_PLUGINS_THROW_EXCEPTION(NotEnoughMemory); + } + + OrthancPluginErrorCode code = OrthancPluginStoreKeyValue(OrthancPlugins::GetGlobalContext(), storeId_.c_str(), + key.c_str(), value, static_cast(valueSize)); + if (code != OrthancPluginErrorCode_Success) + { + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code); + } + } +#endif + + +#if HAS_ORTHANC_PLUGIN_KEY_VALUE_STORES == 1 + bool KeyValueStore::GetValue(std::string& value, + const std::string& key) + { + uint8_t found = false; + OrthancPlugins::MemoryBuffer valueBuffer; + OrthancPluginErrorCode code = OrthancPluginGetKeyValue(OrthancPlugins::GetGlobalContext(), &found, + *valueBuffer, storeId_.c_str(), key.c_str()); + + if (code != OrthancPluginErrorCode_Success) + { + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code); + } + else if (found) + { + valueBuffer.ToString(value); + return true; + } + else + { + return false; + } + } +#endif + + +#if HAS_ORTHANC_PLUGIN_KEY_VALUE_STORES == 1 + void KeyValueStore::DeleteKey(const std::string& key) + { + OrthancPluginErrorCode code = OrthancPluginDeleteKeyValue(OrthancPlugins::GetGlobalContext(), + storeId_.c_str(), key.c_str()); + + if (code != OrthancPluginErrorCode_Success) + { + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code); + } + } +#endif + + +#if HAS_ORTHANC_PLUGIN_KEY_VALUE_STORES == 1 + KeyValueStore::Iterator* KeyValueStore::CreateIterator() + { + return new Iterator(OrthancPluginCreateKeysValuesIterator(OrthancPlugins::GetGlobalContext(), storeId_.c_str())); + } +#endif + + +#if HAS_ORTHANC_PLUGIN_QUEUES == 1 + void Queue::Enqueue(const void* value, + size_t valueSize) + { + if (static_cast(static_cast(valueSize)) != valueSize) + { + ORTHANC_PLUGINS_THROW_EXCEPTION(NotEnoughMemory); + } + + OrthancPluginErrorCode code = OrthancPluginEnqueueValue(OrthancPlugins::GetGlobalContext(), + queueId_.c_str(), value, static_cast(valueSize)); + + if (code != OrthancPluginErrorCode_Success) + { + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code); + } + } +#endif + + +#if HAS_ORTHANC_PLUGIN_QUEUES == 1 + bool Queue::DequeueInternal(std::string& value, + OrthancPluginQueueOrigin origin) + { + uint8_t found = false; + OrthancPlugins::MemoryBuffer valueBuffer; + + OrthancPluginErrorCode code = OrthancPluginDequeueValue(OrthancPlugins::GetGlobalContext(), &found, + *valueBuffer, queueId_.c_str(), origin); + + if (code != OrthancPluginErrorCode_Success) + { + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code); + } + else if (found) + { + valueBuffer.ToString(value); + return true; + } + else + { + return false; + } + } +#endif + + +#if HAS_ORTHANC_PLUGIN_QUEUES == 1 + uint64_t Queue::GetSize() + { + uint64_t size = 0; + OrthancPluginErrorCode code = OrthancPluginGetQueueSize(OrthancPlugins::GetGlobalContext(), queueId_.c_str(), &size); + + if (code != OrthancPluginErrorCode_Success) + { + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code); + } + else + { + return size; + } + } +#endif } diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h --- a/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h Wed Aug 13 12:02:04 2025 +0200 @@ -134,6 +134,14 @@ # define HAS_ORTHANC_PLUGIN_LOG_MESSAGE 0 #endif +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 8) +# define HAS_ORTHANC_PLUGIN_KEY_VALUE_STORES 1 +# define HAS_ORTHANC_PLUGIN_QUEUES 1 +#else +# define HAS_ORTHANC_PLUGIN_KEY_VALUE_STORES 0 +# define HAS_ORTHANC_PLUGIN_QUEUES 0 +#endif + // Macro to tag a function as having been deprecated #if (__cplusplus >= 201402L) // C++14 @@ -172,6 +180,8 @@ { typedef std::map HttpHeaders; + typedef std::map GetArguments; + typedef void (*RestCallback) (OrthancPluginRestOutput* output, const char* url, const OrthancPluginHttpRequest* request); @@ -203,13 +213,6 @@ public: MemoryBuffer(); -#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 7, 0) - // This constructor makes a copy of the given buffer in the memory - // handled by the Orthanc core - MemoryBuffer(const void* buffer, - size_t size); -#endif - ~MemoryBuffer() { Clear(); @@ -220,6 +223,20 @@ return &buffer_; } +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 7, 0) + // Copy of the given buffer into the memory managed by the Orthanc core + void Assign(const void* buffer, + size_t size); +#endif + +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 7, 0) + void Assign(const std::string& s); +#endif + +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 7, 0) + void AssignJson(const Json::Value& value); +#endif + // This transfers ownership from "other" to "this" void Assign(OrthancPluginMemoryBuffer& other); @@ -227,11 +244,11 @@ OrthancPluginMemoryBuffer Release(); - const char* GetData() const + const void* GetData() const { if (buffer_.size > 0) { - return reinterpret_cast(buffer_.data); + return buffer_.data; } else { @@ -855,6 +872,13 @@ const HttpHeaders& headers) const; bool DoPost(MemoryBuffer& target, + size_t index, + const std::string& uri, + const std::string& body, + const HttpHeaders& headers, + unsigned int timeout) const; + + bool DoPost(MemoryBuffer& target, const std::string& name, const std::string& uri, const std::string& body, @@ -867,6 +891,13 @@ const HttpHeaders& headers) const; bool DoPost(Json::Value& target, + size_t index, + const std::string& uri, + const std::string& body, + const HttpHeaders& headers, + unsigned int timeout) const; + + bool DoPost(Json::Value& target, const std::string& name, const std::string& uri, const std::string& body, @@ -1399,6 +1430,12 @@ // helper method to convert Http headers from the plugin SDK to a std::map void GetHttpHeaders(HttpHeaders& result, const OrthancPluginHttpRequest* request); +// helper method to re-serialize the get arguments from the SDK into a string +void SerializeGetArguments(std::string& output, const OrthancPluginHttpRequest* request); + +// helper method to convert Get arguments from the plugin SDK to a std::map +void GetGetArguments(GetArguments& result, const OrthancPluginHttpRequest* request); + #if HAS_ORTHANC_PLUGIN_WEBDAV == 1 class IWebDavCollection : public boost::noncopyable { @@ -1528,6 +1565,10 @@ public: RestApiClient(); + + // used to forward a call from the plugin to the core + RestApiClient(const char* url, + const OrthancPluginHttpRequest* request); void SetMethod(OrthancPluginHttpMethod method) { @@ -1552,6 +1593,9 @@ void AddRequestHeader(const std::string& key, const std::string& value); + void SetRequestHeader(const std::string& key, + const std::string& value); + const HttpHeaders& GetRequestHeaders() const { return requestHeaders_; @@ -1582,14 +1626,120 @@ return requestBody_; } + // Execute only bool Execute(); + // Forward response as is + void ForwardAnswer(OrthancPluginContext* context, OrthancPluginRestOutput* output); + + // Execute and forward the response as is + void ExecuteAndForwardAnswer(OrthancPluginContext* context, OrthancPluginRestOutput* output); + uint16_t GetHttpStatus() const; bool LookupAnswerHeader(std::string& value, const std::string& key) const; const std::string& GetAnswerBody() const; + + bool GetAnswerJson(Json::Value& output) const; + }; +#endif + + +#if HAS_ORTHANC_PLUGIN_KEY_VALUE_STORES == 1 + class KeyValueStore : public boost::noncopyable + { + public: + class Iterator : public boost::noncopyable + { + private: + OrthancPluginKeysValuesIterator *iterator_; + + public: + explicit Iterator(OrthancPluginKeysValuesIterator *iterator); + + ~Iterator(); + + bool Next(); + + std::string GetKey() const; + + void GetValue(std::string& target) const; + }; + + private: + std::string storeId_; + + public: + explicit KeyValueStore(const std::string& storeId) : + storeId_(storeId) + { + } + + const std::string& GetStoreId() const + { + return storeId_; + } + + void Store(const std::string& key, + const void* value, + size_t valueSize); + + void Store(const std::string& key, + const std::string& value) + { + Store(key, value.empty() ? NULL : value.c_str(), value.size()); + } + + bool GetValue(std::string& value, + const std::string& key); + + void DeleteKey(const std::string& key); + + Iterator* CreateIterator(); + }; +#endif + + +#if HAS_ORTHANC_PLUGIN_QUEUES == 1 + class Queue : public boost::noncopyable + { + private: + std::string queueId_; + + bool DequeueInternal(std::string& value, OrthancPluginQueueOrigin origin); + + public: + explicit Queue(const std::string& queueId) : + queueId_(queueId) + { + } + + const std::string& GetQueueId() const + { + return queueId_; + } + + void Enqueue(const void* value, + size_t valueSize); + + void Enqueue(const std::string& value) + { + Enqueue(value.empty() ? NULL : value.c_str(), value.size()); + } + + bool DequeueBack(std::string& value) + { + return DequeueInternal(value, OrthancPluginQueueOrigin_Back); + } + + bool DequeueFront(std::string& value) + { + return DequeueInternal(value, OrthancPluginQueueOrigin_Front); + } + + uint64_t GetSize(); }; #endif } diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Orthanc/Sdk-1.10.0/ClassDocumentation.json --- a/Resources/Orthanc/Sdk-1.10.0/ClassDocumentation.json Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -{ - "OrthancPluginDicomInstance" : "DICOM instance managed by the Orthanc core", - "OrthancPluginDicomWebNode" : "Node visited by DICOMweb conversion", - "OrthancPluginFindAnswers" : "Answers to a DICOM C-FIND query", - "OrthancPluginFindMatcher" : "Matcher for DICOM C-FIND query", - "OrthancPluginFindQuery" : "DICOM C-FIND query", - "OrthancPluginImage" : "2D image managed by the Orthanc core", - "OrthancPluginJob" : "Orthanc job", - "OrthancPluginPeers" : "Orthanc peer", - "OrthancPluginRestOutput" : "Output for a call to the REST API of Orthanc", - "OrthancPluginServerChunkedRequestReader" : "Read for a chunked HTTP request", - "OrthancPluginStorageArea" : "Storage area plugin", - "OrthancPluginWebDavCollection" : "WebDAV collection", - "OrthancPluginWorklistAnswers" : "Answers to a DICOM C-FIND worklist query", - "OrthancPluginWorklistQuery" : "DICOM C-FIND worklist query" -} diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Orthanc/Sdk-1.10.0/ClassDocumentation.json.license --- a/Resources/Orthanc/Sdk-1.10.0/ClassDocumentation.json.license Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -# SPDX-FileCopyrightText: 2023-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium -# SPDX-License-Identifier: GPL-3.0-or-later diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Orthanc/Sdk-1.10.0/CodeModel.json --- a/Resources/Orthanc/Sdk-1.10.0/CodeModel.json Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4317 +0,0 @@ -{ - "classes": [ - { - "destructor": "OrthancPluginFreeDicomInstance", - "methods": [ - { - "args": [], - "c_function": "OrthancPluginGetInstanceRemoteAet", - "const": true, - "documentation": { - "args": {}, - "description": [ - "This function returns the Application Entity Title (AET) of the DICOM modality from which a DICOM instance originates." - ], - "return": "The AET if success, NULL if error.", - "summary": "Get the AET of a DICOM instance." - }, - "return_sdk_type": "const char *" - }, - { - "args": [], - "c_function": "OrthancPluginGetInstanceSize", - "const": true, - "documentation": { - "args": {}, - "description": [ - "This function returns the number of bytes of the given DICOM instance." - ], - "return": "The size of the file, -1 in case of error.", - "summary": "Get the size of a DICOM file." - }, - "return_sdk_type": "int64_t" - }, - { - "args": [], - "c_function": "OrthancPluginGetInstanceJson", - "const": true, - "documentation": { - "args": {}, - "description": [ - "This function returns a pointer to a newly created string containing a JSON file. This JSON file encodes the tag hierarchy of the given DICOM instance." - ], - "return": "The NULL value in case of error, or a string containing the JSON file. This string must be freed by OrthancPluginFreeString().", - "summary": "Get the DICOM tag hierarchy as a JSON file." - }, - "return_sdk_type": "char *" - }, - { - "args": [], - "c_function": "OrthancPluginGetInstanceSimplifiedJson", - "const": true, - "documentation": { - "args": {}, - "description": [ - "This function returns a pointer to a newly created string containing a JSON file. This JSON file encodes the tag hierarchy of the given DICOM instance. In contrast with ::OrthancPluginGetInstanceJson(), the returned JSON file is in its simplified version." - ], - "return": "The NULL value in case of error, or a string containing the JSON file. This string must be freed by OrthancPluginFreeString().", - "summary": "Get the DICOM tag hierarchy as a JSON file (with simplification)." - }, - "return_sdk_type": "char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "metadata", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginHasInstanceMetadata", - "const": true, - "documentation": { - "args": { - "metadata": "The metadata of interest." - }, - "description": [ - "This function checks whether the DICOM instance of interest is associated with some metadata. As of Orthanc 0.8.1, in the callbacks registered by ::OrthancPluginRegisterOnStoredInstanceCallback(), the only possibly available metadata are \"ReceptionDate\", \"RemoteAET\" and \"IndexInSeries\"." - ], - "return": "1 if the metadata is present, 0 if it is absent, -1 in case of error.", - "summary": "Check whether a DICOM instance is associated with some metadata." - }, - "return_sdk_type": "int32_t" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "metadata", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginGetInstanceMetadata", - "const": true, - "documentation": { - "args": { - "metadata": "The metadata of interest." - }, - "description": [ - "This functions returns the value of some metadata that is associated with the DICOM instance of interest. Before calling this function, the existence of the metadata must have been checked with ::OrthancPluginHasInstanceMetadata()." - ], - "return": "The metadata value if success, NULL if error. Please note that the returned string belongs to the instance object and must NOT be deallocated. Please make a copy of the string if you wish to access it later.", - "summary": "Get the value of some metadata associated with a given DICOM instance." - }, - "return_sdk_type": "const char *" - }, - { - "args": [], - "c_function": "OrthancPluginGetInstanceOrigin", - "const": true, - "documentation": { - "args": {}, - "description": [ - "This function returns the origin of a DICOM instance that has been received by Orthanc." - ], - "return": "The origin of the instance.", - "summary": "Get the origin of a DICOM file." - }, - "return_sdk_enumeration": "OrthancPluginInstanceOrigin", - "return_sdk_type": "enumeration" - }, - { - "args": [], - "c_function": "OrthancPluginGetInstanceTransferSyntaxUid", - "const": true, - "documentation": { - "args": {}, - "description": [ - "This function returns a pointer to a newly created string that contains the transfer syntax UID of the DICOM instance. The empty string might be returned if this information is unknown." - ], - "return": "The NULL value in case of error, or a string containing the transfer syntax UID. This string must be freed by OrthancPluginFreeString().", - "summary": "Get the transfer syntax of a DICOM file." - }, - "return_sdk_type": "char *" - }, - { - "args": [], - "c_function": "OrthancPluginHasInstancePixelData", - "const": true, - "documentation": { - "args": {}, - "description": [ - "This function returns a Boolean value indicating whether the DICOM instance contains the pixel data (7FE0,0010) tag." - ], - "return": "\"1\" if the DICOM instance contains pixel data, or \"0\" if the tag is missing, or \"-1\" in the case of an error.", - "summary": "Check whether the DICOM file has pixel data." - }, - "return_sdk_type": "int32_t" - }, - { - "args": [], - "c_function": "OrthancPluginGetInstanceFramesCount", - "const": true, - "documentation": { - "args": {}, - "description": [ - "This function returns the number of frames that are part of a DICOM image managed by the Orthanc core." - ], - "return": "The number of frames (will be zero in the case of an error).", - "summary": "Get the number of frames in a DICOM instance." - }, - "return_sdk_type": "uint32_t" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "frameIndex", - "sdk_type": "uint32_t" - } - ], - "c_function": "OrthancPluginGetInstanceRawFrame", - "const": true, - "documentation": { - "args": { - "frameIndex": "The index of the frame of interest.", - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer()." - }, - "description": [ - "This function returns a memory buffer containing the raw content of a frame in a DICOM instance that is managed by the Orthanc core. This is notably useful for compressed transfer syntaxes, as it gives access to the embedded files (such as JPEG, JPEG-LS or JPEG2k). The Orthanc core transparently reassembles the fragments to extract the raw frame." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Get the raw content of a frame in a DICOM instance." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "frameIndex", - "sdk_type": "uint32_t" - } - ], - "c_function": "OrthancPluginGetInstanceDecodedFrame", - "const": true, - "documentation": { - "args": { - "frameIndex": "The index of the frame of interest." - }, - "description": [ - "This function decodes one frame of a DICOM image that is managed by the Orthanc core." - ], - "return": "The uncompressed image. It must be freed with OrthancPluginFreeImage().", - "summary": "Decode one frame from a DICOM instance." - }, - "return_sdk_class": "OrthancPluginImage", - "return_sdk_type": "object" - }, - { - "args": [], - "c_function": "OrthancPluginSerializeDicomInstance", - "const": true, - "documentation": { - "args": { - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer()." - }, - "description": [ - "This function returns a memory buffer containing the serialization of a DICOM instance that is managed by the Orthanc core." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Writes a DICOM instance to a memory buffer." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_enumeration": "OrthancPluginDicomToJsonFormat", - "sdk_name": "format", - "sdk_type": "enumeration" - }, - { - "name": "arg1", - "sdk_enumeration": "OrthancPluginDicomToJsonFlags", - "sdk_name": "flags", - "sdk_type": "enumeration" - }, - { - "name": "arg2", - "sdk_name": "maxStringLength", - "sdk_type": "uint32_t" - } - ], - "c_function": "OrthancPluginGetInstanceAdvancedJson", - "const": true, - "documentation": { - "args": { - "flags": "Flags governing the output.", - "format": "The output format.", - "maxStringLength": "The maximum length of a field. Too long fields will be output as \"null\". The 0 value means no maximum length." - }, - "description": [ - "This function takes as DICOM instance managed by the Orthanc core, and outputs a JSON string representing the tags of this DICOM file." - ], - "return": "The NULL value if the case of an error, or the JSON string. This string must be freed by OrthancPluginFreeString().", - "summary": "Format a DICOM memory buffer as a JSON string." - }, - "return_sdk_type": "char *" - } - ], - "name": "OrthancPluginDicomInstance" - }, - { - "methods": [], - "name": "OrthancPluginDicomWebNode" - }, - { - "methods": [ - { - "args": [ - { - "name": "arg0", - "sdk_name": "dicom", - "sdk_type": "const_void_pointer_with_size" - } - ], - "c_function": "OrthancPluginFindAddAnswer", - "const": false, - "documentation": { - "args": { - "dicom": "The answer to be added, encoded as a DICOM file.", - "size": "The size of the DICOM file." - }, - "description": [ - "This function adds one answer (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request that is not related to modality worklists." - ], - "return": "0 if success, other value if error.", - "summary": "Add one answer to some C-Find request." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - }, - { - "args": [], - "c_function": "OrthancPluginFindMarkIncomplete", - "const": false, - "documentation": { - "args": {}, - "description": [ - "This function marks as incomplete the set of answers corresponding to some C-Find SCP request that is not related to modality worklists. This must be used if canceling the handling of a request when too many answers are to be returned." - ], - "return": "0 if success, other value if error.", - "summary": "Mark the set of C-Find answers as incomplete." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - } - ], - "name": "OrthancPluginFindAnswers" - }, - { - "destructor": "OrthancPluginFreeFindMatcher", - "methods": [ - { - "args": [ - { - "name": "arg0", - "sdk_name": "dicom", - "sdk_type": "const_void_pointer_with_size" - } - ], - "c_function": "OrthancPluginFindMatcherIsMatch", - "const": true, - "documentation": { - "args": { - "dicom": "The DICOM instance to be matched.", - "size": "The size of the DICOM instance." - }, - "description": [ - "This function checks whether one DICOM instance matches C-Find matcher that was previously allocated using OrthancPluginCreateFindMatcher()." - ], - "return": "1 if the DICOM instance matches the query, 0 otherwise.", - "summary": "Test whether a DICOM instance matches a C-Find query." - }, - "return_sdk_type": "int32_t" - } - ], - "name": "OrthancPluginFindMatcher" - }, - { - "methods": [ - { - "args": [], - "c_function": "OrthancPluginGetFindQuerySize", - "const": true, - "documentation": { - "args": {}, - "description": [ - "This function returns the number of tags that are contained in the given C-Find query." - ], - "return": "The number of tags.", - "summary": "Get the number of tags in a C-Find query." - }, - "return_sdk_type": "uint32_t" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "index", - "sdk_type": "uint32_t" - } - ], - "c_function": "OrthancPluginGetFindQueryTagName", - "const": true, - "documentation": { - "args": { - "index": "The index of the tag of interest." - }, - "description": [ - "This function returns the symbolic name of one DICOM tag in the given C-Find query." - ], - "return": "0 if success, other value if error.", - "summary": "Get the symbolic name of one tag in a C-Find query." - }, - "return_sdk_type": "char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "index", - "sdk_type": "uint32_t" - } - ], - "c_function": "OrthancPluginGetFindQueryValue", - "const": true, - "documentation": { - "args": { - "index": "The index of the tag of interest." - }, - "description": [ - "This function returns the value associated with one tag in the given C-Find query." - ], - "return": "0 if success, other value if error.", - "summary": "Get the value associated with one tag in a C-Find query." - }, - "return_sdk_type": "char *" - } - ], - "name": "OrthancPluginFindQuery" - }, - { - "destructor": "OrthancPluginFreeImage", - "methods": [ - { - "args": [], - "c_function": "OrthancPluginGetImagePixelFormat", - "const": true, - "documentation": { - "args": {}, - "description": [ - "This function returns the type of memory layout for the pixels of the given image." - ], - "return": "The pixel format.", - "summary": "Return the pixel format of an image." - }, - "return_sdk_enumeration": "OrthancPluginPixelFormat", - "return_sdk_type": "enumeration" - }, - { - "args": [], - "c_function": "OrthancPluginGetImageWidth", - "const": true, - "documentation": { - "args": {}, - "description": [ - "This function returns the width of the given image." - ], - "return": "The width.", - "summary": "Return the width of an image." - }, - "return_sdk_type": "uint32_t" - }, - { - "args": [], - "c_function": "OrthancPluginGetImageHeight", - "const": true, - "documentation": { - "args": {}, - "description": [ - "This function returns the height of the given image." - ], - "return": "The height.", - "summary": "Return the height of an image." - }, - "return_sdk_type": "uint32_t" - }, - { - "args": [], - "c_function": "OrthancPluginGetImagePitch", - "const": true, - "documentation": { - "args": {}, - "description": [ - "This function returns the pitch of the given image. The pitch is defined as the number of bytes between 2 successive lines of the image in the memory buffer." - ], - "return": "The pitch.", - "summary": "Return the pitch of an image." - }, - "return_sdk_type": "uint32_t" - }, - { - "args": [ - { - "name": "arg0", - "sdk_enumeration": "OrthancPluginPixelFormat", - "sdk_name": "targetFormat", - "sdk_type": "enumeration" - } - ], - "c_function": "OrthancPluginConvertPixelFormat", - "const": true, - "documentation": { - "args": { - "targetFormat": "The target pixel format." - }, - "description": [ - "This function creates a new image, changing the memory layout of the pixels." - ], - "return": "The resulting image. It must be freed with OrthancPluginFreeImage().", - "summary": "Change the pixel format of an image." - }, - "return_sdk_class": "OrthancPluginImage", - "return_sdk_type": "object" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "fontIndex", - "sdk_type": "uint32_t" - }, - { - "name": "arg1", - "sdk_name": "utf8Text", - "sdk_type": "const char *" - }, - { - "name": "arg2", - "sdk_name": "x", - "sdk_type": "int32_t" - }, - { - "name": "arg3", - "sdk_name": "y", - "sdk_type": "int32_t" - }, - { - "name": "arg4", - "sdk_name": "r", - "sdk_type": "uint8_t" - }, - { - "name": "arg5", - "sdk_name": "g", - "sdk_type": "uint8_t" - }, - { - "name": "arg6", - "sdk_name": "b", - "sdk_type": "uint8_t" - } - ], - "c_function": "OrthancPluginDrawText", - "const": false, - "documentation": { - "args": { - "b": "The value of the blue color channel of the text.", - "fontIndex": "The index of the font. This value must be less than OrthancPluginGetFontsCount().", - "g": "The value of the green color channel of the text.", - "r": "The value of the red color channel of the text.", - "utf8Text": "The text to be drawn, encoded as an UTF-8 zero-terminated string.", - "x": "The X position of the text over the image.", - "y": "The Y position of the text over the image." - }, - "description": [ - "This function draws some text on some image." - ], - "return": "0 if success, other value if error.", - "summary": "Draw text on an image." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - } - ], - "name": "OrthancPluginImage" - }, - { - "destructor": "OrthancPluginFreeJob", - "methods": [ - { - "args": [ - { - "name": "arg0", - "sdk_name": "priority", - "sdk_type": "int32_t" - } - ], - "c_function": "OrthancPluginSubmitJob", - "const": false, - "documentation": { - "args": { - "priority": "The priority of the job." - }, - "description": [ - "This function adds the given job to the pending jobs of Orthanc. Orthanc will take take of freeing it by invoking the finalization callback provided to OrthancPluginCreateJob()." - ], - "return": "ID of the newly-submitted job. This string must be freed by OrthancPluginFreeString().", - "summary": "Submit a new job to the jobs engine of Orthanc." - }, - "return_sdk_type": "char *" - } - ], - "name": "OrthancPluginJob" - }, - { - "destructor": "OrthancPluginFreePeers", - "methods": [ - { - "args": [], - "c_function": "OrthancPluginGetPeersCount", - "const": true, - "documentation": { - "args": {}, - "description": [ - "This function returns the number of Orthanc peers.", - "This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function." - ], - "return": "The number of peers.", - "summary": "Get the number of Orthanc peers." - }, - "return_sdk_type": "uint32_t" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "peerIndex", - "sdk_type": "uint32_t" - } - ], - "c_function": "OrthancPluginGetPeerName", - "const": true, - "documentation": { - "args": { - "peerIndex": "The index of the peer of interest. This value must be lower than OrthancPluginGetPeersCount()." - }, - "description": [ - "This function returns the symbolic name of the Orthanc peer, which corresponds to the key of the \"OrthancPeers\" configuration option of Orthanc.", - "This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function." - ], - "return": "The symbolic name, or NULL in the case of an error.", - "summary": "Get the symbolic name of an Orthanc peer." - }, - "return_sdk_type": "const char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "peerIndex", - "sdk_type": "uint32_t" - } - ], - "c_function": "OrthancPluginGetPeerUrl", - "const": true, - "documentation": { - "args": { - "peerIndex": "The index of the peer of interest. This value must be lower than OrthancPluginGetPeersCount()." - }, - "description": [ - "This function returns the base URL to the REST API of some Orthanc peer.", - "This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function." - ], - "return": "The URL, or NULL in the case of an error.", - "summary": "Get the base URL of an Orthanc peer." - }, - "return_sdk_type": "const char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "peerIndex", - "sdk_type": "uint32_t" - }, - { - "name": "arg1", - "sdk_name": "userProperty", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginGetPeerUserProperty", - "const": true, - "documentation": { - "args": { - "peerIndex": "The index of the peer of interest. This value must be lower than OrthancPluginGetPeersCount().", - "userProperty": "The user property of interest." - }, - "description": [ - "This function returns some user-defined property of some Orthanc peer. An user-defined property is a property that is associated with the peer in the Orthanc configuration file, but that is not recognized by the Orthanc core.", - "This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function." - ], - "return": "The value of the user property, or NULL if it is not defined.", - "summary": "Get some user-defined property of an Orthanc peer." - }, - "return_sdk_type": "const char *" - } - ], - "name": "OrthancPluginPeers" - }, - { - "methods": [ - { - "args": [ - { - "name": "arg0", - "sdk_name": "answer", - "sdk_type": "const_void_pointer_with_size" - }, - { - "name": "arg2", - "sdk_name": "mimeType", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginAnswerBuffer", - "const": false, - "documentation": { - "args": { - "answer": "Pointer to the memory buffer containing the answer.", - "answerSize": "Number of bytes of the answer.", - "mimeType": "The MIME type of the answer." - }, - "description": [ - "This function answers to a REST request with the content of a memory buffer." - ], - "summary": "Answer to a REST request." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_enumeration": "OrthancPluginPixelFormat", - "sdk_name": "format", - "sdk_type": "enumeration" - }, - { - "name": "arg1", - "sdk_name": "width", - "sdk_type": "uint32_t" - }, - { - "name": "arg2", - "sdk_name": "height", - "sdk_type": "uint32_t" - }, - { - "name": "arg3", - "sdk_name": "pitch", - "sdk_type": "uint32_t" - }, - { - "name": "arg4", - "sdk_name": "buffer", - "sdk_type": "const void *" - } - ], - "c_function": "OrthancPluginCompressAndAnswerPngImage", - "const": false, - "documentation": { - "args": { - "buffer": "The memory buffer containing the uncompressed image.", - "format": "The memory layout of the uncompressed image.", - "height": "The height of the image.", - "pitch": "The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer).", - "width": "The width of the image." - }, - "description": [ - "This function answers to a REST request with a PNG image. The parameters of this function describe a memory buffer that contains an uncompressed image. The image will be automatically compressed as a PNG image by the core system of Orthanc." - ], - "summary": "Answer to a REST request with a PNG image." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "redirection", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginRedirect", - "const": false, - "documentation": { - "args": { - "redirection": "Where to redirect." - }, - "description": [ - "This function answers to a REST request by redirecting the user to another URI using HTTP status 301." - ], - "summary": "Redirect a REST request." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "status", - "sdk_type": "uint16_t" - } - ], - "c_function": "OrthancPluginSendHttpStatusCode", - "const": false, - "documentation": { - "args": { - "status": "The HTTP status code to be sent." - }, - "description": [ - "This function answers to a REST request by sending a HTTP status code (such as \"400 - Bad Request\"). Note that: - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). - Redirections (status 301) must use ::OrthancPluginRedirect(). - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed()." - ], - "summary": "Send a HTTP status code." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "realm", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginSendUnauthorized", - "const": false, - "documentation": { - "args": { - "realm": "The realm for the authorization process." - }, - "description": [ - "This function answers to a REST request by signaling that it is not authorized." - ], - "summary": "Signal that a REST request is not authorized." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "allowedMethods", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginSendMethodNotAllowed", - "const": false, - "documentation": { - "args": { - "allowedMethods": "The allowed methods for this URI (e.g. \"GET,POST\" after a PUT or a POST request)." - }, - "description": [ - "This function answers to a REST request by signaling that the queried URI does not support this method." - ], - "summary": "Signal that this URI does not support this HTTP method." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "cookie", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_name": "value", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginSetCookie", - "const": false, - "documentation": { - "args": { - "cookie": "The cookie to be set.", - "value": "The value of the cookie." - }, - "description": [ - "This function sets a cookie in the HTTP client." - ], - "summary": "Set a cookie." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "key", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_name": "value", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginSetHttpHeader", - "const": false, - "documentation": { - "args": { - "key": "The HTTP header to be set.", - "value": "The value of the HTTP header." - }, - "description": [ - "This function sets a HTTP header in the HTTP answer." - ], - "summary": "Set some HTTP header." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "subType", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_name": "contentType", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginStartMultipartAnswer", - "const": false, - "documentation": { - "args": { - "contentType": "The MIME type of the items in the multipart answer.", - "subType": "The sub-type of the multipart answer (\"mixed\" or \"related\")." - }, - "description": [ - "Initiates a HTTP multipart answer, as the result of a REST request." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Start an HTTP multipart answer." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "answer", - "sdk_type": "const_void_pointer_with_size" - } - ], - "c_function": "OrthancPluginSendMultipartItem", - "const": false, - "documentation": { - "args": { - "answer": "Pointer to the memory buffer containing the item.", - "answerSize": "Number of bytes of the item." - }, - "description": [ - "This function sends an item as a part of some HTTP multipart answer that was initiated by OrthancPluginStartMultipartAnswer()." - ], - "return": "0 if success, or the error code if failure (this notably happens if the connection is closed by the client).", - "summary": "Send an item as a part of some HTTP multipart answer." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "status", - "sdk_type": "uint16_t" - }, - { - "name": "arg1", - "sdk_name": "body", - "sdk_type": "const_void_pointer_with_size" - } - ], - "c_function": "OrthancPluginSendHttpStatus", - "const": false, - "documentation": { - "args": { - "body": "The body of the answer.", - "bodySize": "The size of the body.", - "status": "The HTTP status code to be sent." - }, - "description": [ - "This function answers to a HTTP request by sending a HTTP status code (such as \"400 - Bad Request\"), together with a body describing the error. The body will only be returned if the configuration option \"HttpDescribeErrors\" of Orthanc is set to \"true\".", - "Note that: - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). - Redirections (status 301) must use ::OrthancPluginRedirect(). - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed()." - ], - "summary": "Send a HTTP status, with a custom body." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_enumeration": "OrthancPluginPixelFormat", - "sdk_name": "format", - "sdk_type": "enumeration" - }, - { - "name": "arg1", - "sdk_name": "width", - "sdk_type": "uint32_t" - }, - { - "name": "arg2", - "sdk_name": "height", - "sdk_type": "uint32_t" - }, - { - "name": "arg3", - "sdk_name": "pitch", - "sdk_type": "uint32_t" - }, - { - "name": "arg4", - "sdk_name": "buffer", - "sdk_type": "const void *" - }, - { - "name": "arg5", - "sdk_name": "quality", - "sdk_type": "uint8_t" - } - ], - "c_function": "OrthancPluginCompressAndAnswerJpegImage", - "const": false, - "documentation": { - "args": { - "buffer": "The memory buffer containing the uncompressed image.", - "format": "The memory layout of the uncompressed image.", - "height": "The height of the image.", - "pitch": "The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer).", - "quality": "The quality of the JPEG encoding, between 1 (worst quality, best compression) and 100 (best quality, worst compression).", - "width": "The width of the image." - }, - "description": [ - "This function answers to a REST request with a JPEG image. The parameters of this function describe a memory buffer that contains an uncompressed image. The image will be automatically compressed as a JPEG image by the core system of Orthanc." - ], - "summary": "Answer to a REST request with a JPEG image." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "details", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_name": "log", - "sdk_type": "uint8_t" - } - ], - "c_function": "OrthancPluginSetHttpErrorDetails", - "const": false, - "documentation": { - "args": { - "details": "The details of the error message.", - "log": "Whether to also write the detailed error to the Orthanc logs." - }, - "description": [ - "This function sets the detailed description associated with an HTTP error. This description will be displayed in the \"Details\" field of the JSON body of the HTTP answer. It is only taken into consideration if the REST callback returns an error code that is different from \"OrthancPluginErrorCode_Success\", and if the \"HttpDescribeErrors\" configuration option of Orthanc is set to \"true\"." - ], - "summary": "Provide a detailed description for an HTTP error." - }, - "return_sdk_type": "void" - } - ], - "name": "OrthancPluginRestOutput" - }, - { - "methods": [], - "name": "OrthancPluginServerChunkedRequestReader" - }, - { - "methods": [ - { - "args": [ - { - "name": "arg0", - "sdk_name": "uuid", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_name": "content", - "sdk_type": "const void *" - }, - { - "name": "arg2", - "sdk_name": "size", - "sdk_type": "uint64_t" - }, - { - "name": "arg3", - "sdk_enumeration": "OrthancPluginContentType", - "sdk_name": "type", - "sdk_type": "enumeration" - } - ], - "c_function": "OrthancPluginStorageAreaCreate", - "const": false, - "documentation": { - "args": { - "content": "The content to store in the newly created file.", - "size": "The size of the content.", - "type": "The type of the file content.", - "uuid": "The identifier of the file to be created." - }, - "description": [ - "This function creates a new file inside the storage area that is currently used by Orthanc." - ], - "return": "0 if success, other value if error.", - "summary": "Create a file inside the storage area." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "uuid", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_enumeration": "OrthancPluginContentType", - "sdk_name": "type", - "sdk_type": "enumeration" - } - ], - "c_function": "OrthancPluginStorageAreaRead", - "const": false, - "documentation": { - "args": { - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", - "type": "The type of the file content.", - "uuid": "The identifier of the file to be read." - }, - "description": [ - "This function reads the content of a given file from the storage area that is currently used by Orthanc." - ], - "return": "0 if success, other value if error.", - "summary": "Read a file from the storage area." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "uuid", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_enumeration": "OrthancPluginContentType", - "sdk_name": "type", - "sdk_type": "enumeration" - } - ], - "c_function": "OrthancPluginStorageAreaRemove", - "const": false, - "documentation": { - "args": { - "type": "The type of the file content.", - "uuid": "The identifier of the file to be removed." - }, - "description": [ - "This function removes a given file from the storage area that is currently used by Orthanc." - ], - "return": "0 if success, other value if error.", - "summary": "Remove a file from the storage area." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - }, - { - "args": [ - { - "name": "arg0", - "sdk_enumeration": "OrthancPluginResourceType", - "sdk_name": "level", - "sdk_type": "enumeration" - } - ], - "c_function": "OrthancPluginReconstructMainDicomTags", - "const": false, - "documentation": { - "args": { - "level": "The type of the resources of interest." - }, - "description": [ - "This function requests the Orthanc core to reconstruct the main DICOM tags of all the resources of the given type. This function can only be used as a part of the upgrade of a custom database back-end. A database transaction will be automatically setup." - ], - "return": "0 if success, other value if error.", - "summary": "Reconstruct the main DICOM tags." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - } - ], - "name": "OrthancPluginStorageArea" - }, - { - "methods": [ - { - "args": [ - { - "name": "arg0", - "sdk_class": "OrthancPluginWorklistQuery", - "sdk_name": "query", - "sdk_type": "const_object" - }, - { - "name": "arg1", - "sdk_name": "dicom", - "sdk_type": "const_void_pointer_with_size" - } - ], - "c_function": "OrthancPluginWorklistAddAnswer", - "const": false, - "documentation": { - "args": { - "dicom": "The worklist to answer, encoded as a DICOM file.", - "query": "The worklist query, as received by the callback.", - "size": "The size of the DICOM file." - }, - "description": [ - "This function adds one worklist (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request against modality worklists." - ], - "return": "0 if success, other value if error.", - "summary": "Add one answer to some modality worklist request." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - }, - { - "args": [], - "c_function": "OrthancPluginWorklistMarkIncomplete", - "const": false, - "documentation": { - "args": {}, - "description": [ - "This function marks as incomplete the set of answers corresponding to some C-Find SCP request against modality worklists. This must be used if canceling the handling of a request when too many answers are to be returned." - ], - "return": "0 if success, other value if error.", - "summary": "Mark the set of worklist answers as incomplete." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - } - ], - "name": "OrthancPluginWorklistAnswers" - }, - { - "methods": [ - { - "args": [ - { - "name": "arg0", - "sdk_name": "dicom", - "sdk_type": "const_void_pointer_with_size" - } - ], - "c_function": "OrthancPluginWorklistIsMatch", - "const": true, - "documentation": { - "args": { - "dicom": "The worklist to answer, encoded as a DICOM file.", - "size": "The size of the DICOM file." - }, - "description": [ - "This function checks whether one worklist (encoded as a DICOM file) matches the C-Find SCP query against modality worklists. This function must be called before adding the worklist as an answer through OrthancPluginWorklistAddAnswer()." - ], - "return": "1 if the worklist matches the query, 0 otherwise.", - "summary": "Test whether a worklist matches the query." - }, - "return_sdk_type": "int32_t" - }, - { - "args": [], - "c_function": "OrthancPluginWorklistGetDicomQuery", - "const": true, - "documentation": { - "args": { - "target": "Memory buffer where to store the DICOM file. It must be freed with OrthancPluginFreeMemoryBuffer()." - }, - "description": [ - "This function retrieves the DICOM file that underlies a C-Find SCP query against modality worklists." - ], - "return": "0 if success, other value if error.", - "summary": "Retrieve the worklist query as a DICOM file." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - } - ], - "name": "OrthancPluginWorklistQuery" - } - ], - "enumerations": [ - { - "documentation": "The supported types of changes that can be signaled to the change callback.", - "name": "OrthancPluginChangeType", - "values": [ - { - "documentation": "Series is now complete", - "key": "CompletedSeries", - "value": 0 - }, - { - "documentation": "Deleted resource", - "key": "Deleted", - "value": 1 - }, - { - "documentation": "A new instance was added to this resource", - "key": "NewChildInstance", - "value": 2 - }, - { - "documentation": "New instance received", - "key": "NewInstance", - "value": 3 - }, - { - "documentation": "New patient created", - "key": "NewPatient", - "value": 4 - }, - { - "documentation": "New series created", - "key": "NewSeries", - "value": 5 - }, - { - "documentation": "New study created", - "key": "NewStudy", - "value": 6 - }, - { - "documentation": "Timeout: No new instance in this patient", - "key": "StablePatient", - "value": 7 - }, - { - "documentation": "Timeout: No new instance in this series", - "key": "StableSeries", - "value": 8 - }, - { - "documentation": "Timeout: No new instance in this study", - "key": "StableStudy", - "value": 9 - }, - { - "documentation": "Orthanc has started", - "key": "OrthancStarted", - "value": 10 - }, - { - "documentation": "Orthanc is stopping", - "key": "OrthancStopped", - "value": 11 - }, - { - "documentation": "Some user-defined attachment has changed for this resource", - "key": "UpdatedAttachment", - "value": 12 - }, - { - "documentation": "Some user-defined metadata has changed for this resource", - "key": "UpdatedMetadata", - "value": 13 - }, - { - "documentation": "The list of Orthanc peers has changed", - "key": "UpdatedPeers", - "value": 14 - }, - { - "documentation": "The list of DICOM modalities has changed", - "key": "UpdatedModalities", - "value": 15 - }, - { - "documentation": "New Job submitted", - "key": "JobSubmitted", - "value": 16 - }, - { - "documentation": "A Job has completed successfully", - "key": "JobSuccess", - "value": 17 - }, - { - "documentation": "A Job has failed", - "key": "JobFailure", - "value": 18 - } - ] - }, - { - "documentation": "The compression algorithms that are supported by the Orthanc core.", - "name": "OrthancPluginCompressionType", - "values": [ - { - "documentation": "Standard zlib compression", - "key": "Zlib", - "value": 0 - }, - { - "documentation": "zlib, prefixed with uncompressed size (uint64_t)", - "key": "ZlibWithSize", - "value": 1 - }, - { - "documentation": "Standard gzip compression", - "key": "Gzip", - "value": 2 - }, - { - "documentation": "gzip, prefixed with uncompressed size (uint64_t)", - "key": "GzipWithSize", - "value": 3 - } - ] - }, - { - "documentation": "The constraints on the tags (main DICOM tags and identifier tags) that must be supported by the database plugins.", - "name": "OrthancPluginConstraintType", - "values": [ - { - "documentation": "Equal", - "key": "Equal", - "value": 1 - }, - { - "documentation": "Less or equal", - "key": "SmallerOrEqual", - "value": 2 - }, - { - "documentation": "More or equal", - "key": "GreaterOrEqual", - "value": 3 - }, - { - "documentation": "Wildcard matching", - "key": "Wildcard", - "value": 4 - }, - { - "documentation": "List of values", - "key": "List", - "value": 5 - } - ] - }, - { - "documentation": "The content types that are supported by Orthanc plugins.", - "name": "OrthancPluginContentType", - "values": [ - { - "documentation": "Unknown content type", - "key": "Unknown", - "value": 0 - }, - { - "documentation": "DICOM", - "key": "Dicom", - "value": 1 - }, - { - "documentation": "JSON summary of a DICOM file", - "key": "DicomAsJson", - "value": 2 - }, - { - "documentation": "DICOM Header till pixel data", - "key": "DicomUntilPixelData", - "value": 3 - } - ] - }, - { - "documentation": "Flags to the creation of a DICOM file.", - "name": "OrthancPluginCreateDicomFlags", - "values": [ - { - "documentation": "Default mode", - "key": "None", - "value": 0 - }, - { - "documentation": "Decode fields encoded using data URI scheme", - "key": "DecodeDataUriScheme", - "value": 1 - }, - { - "documentation": "Automatically generate DICOM identifiers", - "key": "GenerateIdentifiers", - "value": 2 - } - ] - }, - { - "documentation": "Flags to customize a DICOM-to-JSON conversion. By default, binary tags are formatted using Data URI scheme.", - "name": "OrthancPluginDicomToJsonFlags", - "values": [ - { - "documentation": "Default formatting", - "key": "None", - "value": 0 - }, - { - "documentation": "Include the binary tags", - "key": "IncludeBinary", - "value": 1 - }, - { - "documentation": "Include the private tags", - "key": "IncludePrivateTags", - "value": 2 - }, - { - "documentation": "Include the tags unknown by the dictionary", - "key": "IncludeUnknownTags", - "value": 4 - }, - { - "documentation": "Include the pixel data", - "key": "IncludePixelData", - "value": 8 - }, - { - "documentation": "Output binary tags as-is, dropping non-ASCII", - "key": "ConvertBinaryToAscii", - "value": 16 - }, - { - "documentation": "Signal binary tags as null values", - "key": "ConvertBinaryToNull", - "value": 32 - }, - { - "documentation": "Stop processing after pixel data (new in 1.9.1)", - "key": "StopAfterPixelData", - "value": 64 - }, - { - "documentation": "Skip tags whose element is zero (new in 1.9.1)", - "key": "SkipGroupLengths", - "value": 128 - } - ] - }, - { - "documentation": "The possible output formats for a DICOM-to-JSON conversion.", - "name": "OrthancPluginDicomToJsonFormat", - "values": [ - { - "documentation": "Full output, with most details", - "key": "Full", - "value": 1 - }, - { - "documentation": "Tags output as hexadecimal numbers", - "key": "Short", - "value": 2 - }, - { - "documentation": "Human-readable JSON", - "key": "Human", - "value": 3 - } - ] - }, - { - "documentation": "The available modes to export a binary DICOM tag into a DICOMweb JSON or XML document.", - "name": "OrthancPluginDicomWebBinaryMode", - "values": [ - { - "documentation": "Don't include binary tags", - "key": "Ignore", - "value": 0 - }, - { - "documentation": "Inline encoding using Base64", - "key": "InlineBinary", - "value": 1 - }, - { - "documentation": "Use a bulk data URI field", - "key": "BulkDataUri", - "value": 2 - } - ] - }, - { - "documentation": "The various error codes that can be returned by the Orthanc core.", - "name": "OrthancPluginErrorCode", - "values": [ - { - "documentation": "Internal error", - "key": "InternalError", - "value": -1 - }, - { - "documentation": "Success", - "key": "Success", - "value": 0 - }, - { - "documentation": "Error encountered within the plugin engine", - "key": "Plugin", - "value": 1 - }, - { - "documentation": "Not implemented yet", - "key": "NotImplemented", - "value": 2 - }, - { - "documentation": "Parameter out of range", - "key": "ParameterOutOfRange", - "value": 3 - }, - { - "documentation": "The server hosting Orthanc is running out of memory", - "key": "NotEnoughMemory", - "value": 4 - }, - { - "documentation": "Bad type for a parameter", - "key": "BadParameterType", - "value": 5 - }, - { - "documentation": "Bad sequence of calls", - "key": "BadSequenceOfCalls", - "value": 6 - }, - { - "documentation": "Accessing an inexistent item", - "key": "InexistentItem", - "value": 7 - }, - { - "documentation": "Bad request", - "key": "BadRequest", - "value": 8 - }, - { - "documentation": "Error in the network protocol", - "key": "NetworkProtocol", - "value": 9 - }, - { - "documentation": "Error while calling a system command", - "key": "SystemCommand", - "value": 10 - }, - { - "documentation": "Error with the database engine", - "key": "Database", - "value": 11 - }, - { - "documentation": "Badly formatted URI", - "key": "UriSyntax", - "value": 12 - }, - { - "documentation": "Inexistent file", - "key": "InexistentFile", - "value": 13 - }, - { - "documentation": "Cannot write to file", - "key": "CannotWriteFile", - "value": 14 - }, - { - "documentation": "Bad file format", - "key": "BadFileFormat", - "value": 15 - }, - { - "documentation": "Timeout", - "key": "Timeout", - "value": 16 - }, - { - "documentation": "Unknown resource", - "key": "UnknownResource", - "value": 17 - }, - { - "documentation": "Incompatible version of the database", - "key": "IncompatibleDatabaseVersion", - "value": 18 - }, - { - "documentation": "The file storage is full", - "key": "FullStorage", - "value": 19 - }, - { - "documentation": "Corrupted file (e.g. inconsistent MD5 hash)", - "key": "CorruptedFile", - "value": 20 - }, - { - "documentation": "Inexistent tag", - "key": "InexistentTag", - "value": 21 - }, - { - "documentation": "Cannot modify a read-only data structure", - "key": "ReadOnly", - "value": 22 - }, - { - "documentation": "Incompatible format of the images", - "key": "IncompatibleImageFormat", - "value": 23 - }, - { - "documentation": "Incompatible size of the images", - "key": "IncompatibleImageSize", - "value": 24 - }, - { - "documentation": "Error while using a shared library (plugin)", - "key": "SharedLibrary", - "value": 25 - }, - { - "documentation": "Plugin invoking an unknown service", - "key": "UnknownPluginService", - "value": 26 - }, - { - "documentation": "Unknown DICOM tag", - "key": "UnknownDicomTag", - "value": 27 - }, - { - "documentation": "Cannot parse a JSON document", - "key": "BadJson", - "value": 28 - }, - { - "documentation": "Bad credentials were provided to an HTTP request", - "key": "Unauthorized", - "value": 29 - }, - { - "documentation": "Badly formatted font file", - "key": "BadFont", - "value": 30 - }, - { - "documentation": "The plugin implementing a custom database back-end does not fulfill the proper interface", - "key": "DatabasePlugin", - "value": 31 - }, - { - "documentation": "Error in the plugin implementing a custom storage area", - "key": "StorageAreaPlugin", - "value": 32 - }, - { - "documentation": "The request is empty", - "key": "EmptyRequest", - "value": 33 - }, - { - "documentation": "Cannot send a response which is acceptable according to the Accept HTTP header", - "key": "NotAcceptable", - "value": 34 - }, - { - "documentation": "Cannot handle a NULL pointer", - "key": "NullPointer", - "value": 35 - }, - { - "documentation": "The database is currently not available (probably a transient situation)", - "key": "DatabaseUnavailable", - "value": 36 - }, - { - "documentation": "This job was canceled", - "key": "CanceledJob", - "value": 37 - }, - { - "documentation": "Geometry error encountered in Stone", - "key": "BadGeometry", - "value": 38 - }, - { - "documentation": "Cannot initialize SSL encryption, check out your certificates", - "key": "SslInitialization", - "value": 39 - }, - { - "documentation": "Calling a function that has been removed from the Orthanc Framework", - "key": "DiscontinuedAbi", - "value": 40 - }, - { - "documentation": "Incorrect range request", - "key": "BadRange", - "value": 41 - }, - { - "documentation": "Database could not serialize access due to concurrent update, the transaction should be retried", - "key": "DatabaseCannotSerialize", - "value": 42 - }, - { - "documentation": "A bad revision number was provided, which might indicate conflict between multiple writers", - "key": "Revision", - "value": 43 - }, - { - "documentation": "SQLite: The database is not opened", - "key": "SQLiteNotOpened", - "value": 1000 - }, - { - "documentation": "SQLite: Connection is already open", - "key": "SQLiteAlreadyOpened", - "value": 1001 - }, - { - "documentation": "SQLite: Unable to open the database", - "key": "SQLiteCannotOpen", - "value": 1002 - }, - { - "documentation": "SQLite: This cached statement is already being referred to", - "key": "SQLiteStatementAlreadyUsed", - "value": 1003 - }, - { - "documentation": "SQLite: Cannot execute a command", - "key": "SQLiteExecute", - "value": 1004 - }, - { - "documentation": "SQLite: Rolling back a nonexistent transaction (have you called Begin()?)", - "key": "SQLiteRollbackWithoutTransaction", - "value": 1005 - }, - { - "documentation": "SQLite: Committing a nonexistent transaction", - "key": "SQLiteCommitWithoutTransaction", - "value": 1006 - }, - { - "documentation": "SQLite: Unable to register a function", - "key": "SQLiteRegisterFunction", - "value": 1007 - }, - { - "documentation": "SQLite: Unable to flush the database", - "key": "SQLiteFlush", - "value": 1008 - }, - { - "documentation": "SQLite: Cannot run a cached statement", - "key": "SQLiteCannotRun", - "value": 1009 - }, - { - "documentation": "SQLite: Cannot step over a cached statement", - "key": "SQLiteCannotStep", - "value": 1010 - }, - { - "documentation": "SQLite: Bing a value while out of range (serious error)", - "key": "SQLiteBindOutOfRange", - "value": 1011 - }, - { - "documentation": "SQLite: Cannot prepare a cached statement", - "key": "SQLitePrepareStatement", - "value": 1012 - }, - { - "documentation": "SQLite: Beginning the same transaction twice", - "key": "SQLiteTransactionAlreadyStarted", - "value": 1013 - }, - { - "documentation": "SQLite: Failure when committing the transaction", - "key": "SQLiteTransactionCommit", - "value": 1014 - }, - { - "documentation": "SQLite: Cannot start a transaction", - "key": "SQLiteTransactionBegin", - "value": 1015 - }, - { - "documentation": "The directory to be created is already occupied by a regular file", - "key": "DirectoryOverFile", - "value": 2000 - }, - { - "documentation": "Unable to create a subdirectory or a file in the file storage", - "key": "FileStorageCannotWrite", - "value": 2001 - }, - { - "documentation": "The specified path does not point to a directory", - "key": "DirectoryExpected", - "value": 2002 - }, - { - "documentation": "The TCP port of the HTTP server is privileged or already in use", - "key": "HttpPortInUse", - "value": 2003 - }, - { - "documentation": "The TCP port of the DICOM server is privileged or already in use", - "key": "DicomPortInUse", - "value": 2004 - }, - { - "documentation": "This HTTP status is not allowed in a REST API", - "key": "BadHttpStatusInRest", - "value": 2005 - }, - { - "documentation": "The specified path does not point to a regular file", - "key": "RegularFileExpected", - "value": 2006 - }, - { - "documentation": "Unable to get the path to the executable", - "key": "PathToExecutable", - "value": 2007 - }, - { - "documentation": "Cannot create a directory", - "key": "MakeDirectory", - "value": 2008 - }, - { - "documentation": "An application entity title (AET) cannot be empty or be longer than 16 characters", - "key": "BadApplicationEntityTitle", - "value": 2009 - }, - { - "documentation": "No request handler factory for DICOM C-FIND SCP", - "key": "NoCFindHandler", - "value": 2010 - }, - { - "documentation": "No request handler factory for DICOM C-MOVE SCP", - "key": "NoCMoveHandler", - "value": 2011 - }, - { - "documentation": "No request handler factory for DICOM C-STORE SCP", - "key": "NoCStoreHandler", - "value": 2012 - }, - { - "documentation": "No application entity filter", - "key": "NoApplicationEntityFilter", - "value": 2013 - }, - { - "documentation": "DicomUserConnection: Unable to find the SOP class and instance", - "key": "NoSopClassOrInstance", - "value": 2014 - }, - { - "documentation": "DicomUserConnection: No acceptable presentation context for modality", - "key": "NoPresentationContext", - "value": 2015 - }, - { - "documentation": "DicomUserConnection: The C-FIND command is not supported by the remote SCP", - "key": "DicomFindUnavailable", - "value": 2016 - }, - { - "documentation": "DicomUserConnection: The C-MOVE command is not supported by the remote SCP", - "key": "DicomMoveUnavailable", - "value": 2017 - }, - { - "documentation": "Cannot store an instance", - "key": "CannotStoreInstance", - "value": 2018 - }, - { - "documentation": "Only string values are supported when creating DICOM instances", - "key": "CreateDicomNotString", - "value": 2019 - }, - { - "documentation": "Trying to override a value inherited from a parent module", - "key": "CreateDicomOverrideTag", - "value": 2020 - }, - { - "documentation": "Use \\\"Content\\\" to inject an image into a new DICOM instance", - "key": "CreateDicomUseContent", - "value": 2021 - }, - { - "documentation": "No payload is present for one instance in the series", - "key": "CreateDicomNoPayload", - "value": 2022 - }, - { - "documentation": "The payload of the DICOM instance must be specified according to Data URI scheme", - "key": "CreateDicomUseDataUriScheme", - "value": 2023 - }, - { - "documentation": "Trying to attach a new DICOM instance to an inexistent resource", - "key": "CreateDicomBadParent", - "value": 2024 - }, - { - "documentation": "Trying to attach a new DICOM instance to an instance (must be a series, study or patient)", - "key": "CreateDicomParentIsInstance", - "value": 2025 - }, - { - "documentation": "Unable to get the encoding of the parent resource", - "key": "CreateDicomParentEncoding", - "value": 2026 - }, - { - "documentation": "Unknown modality", - "key": "UnknownModality", - "value": 2027 - }, - { - "documentation": "Bad ordering of filters in a job", - "key": "BadJobOrdering", - "value": 2028 - }, - { - "documentation": "Cannot convert the given JSON object to a Lua table", - "key": "JsonToLuaTable", - "value": 2029 - }, - { - "documentation": "Cannot create the Lua context", - "key": "CannotCreateLua", - "value": 2030 - }, - { - "documentation": "Cannot execute a Lua command", - "key": "CannotExecuteLua", - "value": 2031 - }, - { - "documentation": "Arguments cannot be pushed after the Lua function is executed", - "key": "LuaAlreadyExecuted", - "value": 2032 - }, - { - "documentation": "The Lua function does not give the expected number of outputs", - "key": "LuaBadOutput", - "value": 2033 - }, - { - "documentation": "The Lua function is not a predicate (only true/false outputs allowed)", - "key": "NotLuaPredicate", - "value": 2034 - }, - { - "documentation": "The Lua function does not return a string", - "key": "LuaReturnsNoString", - "value": 2035 - }, - { - "documentation": "Another plugin has already registered a custom storage area", - "key": "StorageAreaAlreadyRegistered", - "value": 2036 - }, - { - "documentation": "Another plugin has already registered a custom database back-end", - "key": "DatabaseBackendAlreadyRegistered", - "value": 2037 - }, - { - "documentation": "Plugin trying to call the database during its initialization", - "key": "DatabaseNotInitialized", - "value": 2038 - }, - { - "documentation": "Orthanc has been built without SSL support", - "key": "SslDisabled", - "value": 2039 - }, - { - "documentation": "Unable to order the slices of the series", - "key": "CannotOrderSlices", - "value": 2040 - }, - { - "documentation": "No request handler factory for DICOM C-Find Modality SCP", - "key": "NoWorklistHandler", - "value": 2041 - }, - { - "documentation": "Cannot override the value of a tag that already exists", - "key": "AlreadyExistingTag", - "value": 2042 - }, - { - "documentation": "No request handler factory for DICOM N-ACTION SCP (storage commitment)", - "key": "NoStorageCommitmentHandler", - "value": 2043 - }, - { - "documentation": "No request handler factory for DICOM C-GET SCP", - "key": "NoCGetHandler", - "value": 2044 - }, - { - "documentation": "Unsupported media type", - "key": "UnsupportedMediaType", - "value": 3000 - } - ] - }, - { - "documentation": "The various HTTP methods for a REST call.", - "name": "OrthancPluginHttpMethod", - "values": [ - { - "documentation": "GET request", - "key": "Get", - "value": 1 - }, - { - "documentation": "POST request", - "key": "Post", - "value": 2 - }, - { - "documentation": "PUT request", - "key": "Put", - "value": 3 - }, - { - "documentation": "DELETE request", - "key": "Delete", - "value": 4 - } - ] - }, - { - "documentation": "The constraints on the DICOM identifiers that must be supported by the database plugins.", - "name": "OrthancPluginIdentifierConstraint", - "values": [ - { - "documentation": "Equal", - "key": "Equal", - "value": 1 - }, - { - "documentation": "Less or equal", - "key": "SmallerOrEqual", - "value": 2 - }, - { - "documentation": "More or equal", - "key": "GreaterOrEqual", - "value": 3 - }, - { - "documentation": "Case-sensitive wildcard matching (with * and ?)", - "key": "Wildcard", - "value": 4 - } - ] - }, - { - "documentation": "The image formats that are supported by the Orthanc core.", - "name": "OrthancPluginImageFormat", - "values": [ - { - "documentation": "Image compressed using PNG", - "key": "Png", - "value": 0 - }, - { - "documentation": "Image compressed using JPEG", - "key": "Jpeg", - "value": 1 - }, - { - "documentation": "Image compressed using DICOM", - "key": "Dicom", - "value": 2 - } - ] - }, - { - "documentation": "The origin of a DICOM instance that has been received by Orthanc.", - "name": "OrthancPluginInstanceOrigin", - "values": [ - { - "documentation": "Unknown origin", - "key": "Unknown", - "value": 1 - }, - { - "documentation": "Instance received through DICOM protocol", - "key": "DicomProtocol", - "value": 2 - }, - { - "documentation": "Instance received through REST API of Orthanc", - "key": "RestApi", - "value": 3 - }, - { - "documentation": "Instance added to Orthanc by a plugin", - "key": "Plugin", - "value": 4 - }, - { - "documentation": "Instance added to Orthanc by a Lua script", - "key": "Lua", - "value": 5 - }, - { - "documentation": "Instance received through WebDAV (new in 1.8.0)", - "key": "WebDav", - "value": 6 - } - ] - }, - { - "documentation": "The possible status for one single step of a job.", - "name": "OrthancPluginJobStepStatus", - "values": [ - { - "documentation": "The job has successfully executed all its steps", - "key": "Success", - "value": 1 - }, - { - "documentation": "The job has failed while executing this step", - "key": "Failure", - "value": 2 - }, - { - "documentation": "The job has still data to process after this step", - "key": "Continue", - "value": 3 - } - ] - }, - { - "documentation": "Explains why the job should stop and release the resources it has allocated. This is especially important to disambiguate between the \"paused\" condition and the \"final\" conditions (success, failure, or canceled).", - "name": "OrthancPluginJobStopReason", - "values": [ - { - "documentation": "The job has succeeded", - "key": "Success", - "value": 1 - }, - { - "documentation": "The job was paused, and will be resumed later", - "key": "Paused", - "value": 2 - }, - { - "documentation": "The job has failed, and might be resubmitted later", - "key": "Failure", - "value": 3 - }, - { - "documentation": "The job was canceled, and might be resubmitted later", - "key": "Canceled", - "value": 4 - } - ] - }, - { - "documentation": "The available types of metrics.", - "name": "OrthancPluginMetricsType", - "values": [ - { - "documentation": "Default metrics", - "key": "Default", - "value": 0 - }, - { - "documentation": "This metrics represents a time duration. Orthanc will keep the maximum value of the metrics over a sliding window of ten seconds, which is useful if the metrics is sampled frequently.", - "key": "Timer", - "value": 1 - } - ] - }, - { - "documentation": "The memory layout of the pixels of an image.", - "name": "OrthancPluginPixelFormat", - "values": [ - { - "documentation": "Graylevel 8bpp image. The image is graylevel. Each pixel is unsigned and stored in one byte.", - "key": "Grayscale8", - "value": 1 - }, - { - "documentation": "Graylevel, unsigned 16bpp image. The image is graylevel. Each pixel is unsigned and stored in two bytes.", - "key": "Grayscale16", - "value": 2 - }, - { - "documentation": "Graylevel, signed 16bpp image. The image is graylevel. Each pixel is signed and stored in two bytes.", - "key": "SignedGrayscale16", - "value": 3 - }, - { - "documentation": "Color image in RGB24 format. This format describes a color image. The pixels are stored in 3 consecutive bytes. The memory layout is RGB.", - "key": "RGB24", - "value": 4 - }, - { - "documentation": "Color image in RGBA32 format. This format describes a color image. The pixels are stored in 4 consecutive bytes. The memory layout is RGBA.", - "key": "RGBA32", - "value": 5 - }, - { - "documentation": "Unknown pixel format", - "key": "Unknown", - "value": 6 - }, - { - "documentation": "Color image in RGB48 format. This format describes a color image. The pixels are stored in 6 consecutive bytes. The memory layout is RRGGBB.", - "key": "RGB48", - "value": 7 - }, - { - "documentation": "Graylevel, unsigned 32bpp image. The image is graylevel. Each pixel is unsigned and stored in four bytes.", - "key": "Grayscale32", - "value": 8 - }, - { - "documentation": "Graylevel, floating-point 32bpp image. The image is graylevel. Each pixel is floating-point and stored in four bytes.", - "key": "Float32", - "value": 9 - }, - { - "documentation": "Color image in BGRA32 format. This format describes a color image. The pixels are stored in 4 consecutive bytes. The memory layout is BGRA.", - "key": "BGRA32", - "value": 10 - }, - { - "documentation": "Graylevel, unsigned 64bpp image. The image is graylevel. Each pixel is unsigned and stored in eight bytes.", - "key": "Grayscale64", - "value": 11 - } - ] - }, - { - "documentation": "The action to be taken after ReceivedInstanceCallback is triggered", - "name": "OrthancPluginReceivedInstanceAction", - "values": [ - { - "documentation": "Keep the instance as is", - "key": "KeepAsIs", - "value": 1 - }, - { - "documentation": "Modify the instance", - "key": "Modify", - "value": 2 - }, - { - "documentation": "Discard the instance", - "key": "Discard", - "value": 3 - } - ] - }, - { - "documentation": "The supported types of DICOM resources.", - "name": "OrthancPluginResourceType", - "values": [ - { - "documentation": "Patient", - "key": "Patient", - "value": 0 - }, - { - "documentation": "Study", - "key": "Study", - "value": 1 - }, - { - "documentation": "Series", - "key": "Series", - "value": 2 - }, - { - "documentation": "Instance", - "key": "Instance", - "value": 3 - }, - { - "documentation": "Unavailable resource type", - "key": "None", - "value": 4 - } - ] - }, - { - "documentation": "The available values for the Failure Reason (0008,1197) during storage commitment. http://dicom.nema.org/medical/dicom/2019e/output/chtml/part03/sect_C.14.html#sect_C.14.1.1", - "name": "OrthancPluginStorageCommitmentFailureReason", - "values": [ - { - "documentation": "Success: The DICOM instance is properly stored in the SCP", - "key": "Success", - "value": 0 - }, - { - "documentation": "0110H: A general failure in processing the operation was encountered", - "key": "ProcessingFailure", - "value": 1 - }, - { - "documentation": "0112H: One or more of the elements in the Referenced SOP Instance Sequence was not available", - "key": "NoSuchObjectInstance", - "value": 2 - }, - { - "documentation": "0213H: The SCP does not currently have enough resources to store the requested SOP Instance(s)", - "key": "ResourceLimitation", - "value": 3 - }, - { - "documentation": "0122H: Storage Commitment has been requested for a SOP Instance with a SOP Class that is not supported by the SCP", - "key": "ReferencedSOPClassNotSupported", - "value": 4 - }, - { - "documentation": "0119H: The SOP Class of an element in the Referenced SOP Instance Sequence did not correspond to the SOP class registered for this SOP Instance at the SCP", - "key": "ClassInstanceConflict", - "value": 5 - }, - { - "documentation": "0131H: The Transaction UID of the Storage Commitment Request is already in use", - "key": "DuplicateTransactionUID", - "value": 6 - } - ] - }, - { - "documentation": "The value representations present in the DICOM standard (version 2013).", - "name": "OrthancPluginValueRepresentation", - "values": [ - { - "documentation": "Application Entity", - "key": "AE", - "value": 1 - }, - { - "documentation": "Age String", - "key": "AS", - "value": 2 - }, - { - "documentation": "Attribute Tag", - "key": "AT", - "value": 3 - }, - { - "documentation": "Code String", - "key": "CS", - "value": 4 - }, - { - "documentation": "Date", - "key": "DA", - "value": 5 - }, - { - "documentation": "Decimal String", - "key": "DS", - "value": 6 - }, - { - "documentation": "Date Time", - "key": "DT", - "value": 7 - }, - { - "documentation": "Floating Point Double", - "key": "FD", - "value": 8 - }, - { - "documentation": "Floating Point Single", - "key": "FL", - "value": 9 - }, - { - "documentation": "Integer String", - "key": "IS", - "value": 10 - }, - { - "documentation": "Long String", - "key": "LO", - "value": 11 - }, - { - "documentation": "Long Text", - "key": "LT", - "value": 12 - }, - { - "documentation": "Other Byte String", - "key": "OB", - "value": 13 - }, - { - "documentation": "Other Float String", - "key": "OF", - "value": 14 - }, - { - "documentation": "Other Word String", - "key": "OW", - "value": 15 - }, - { - "documentation": "Person Name", - "key": "PN", - "value": 16 - }, - { - "documentation": "Short String", - "key": "SH", - "value": 17 - }, - { - "documentation": "Signed Long", - "key": "SL", - "value": 18 - }, - { - "documentation": "Sequence of Items", - "key": "SQ", - "value": 19 - }, - { - "documentation": "Signed Short", - "key": "SS", - "value": 20 - }, - { - "documentation": "Short Text", - "key": "ST", - "value": 21 - }, - { - "documentation": "Time", - "key": "TM", - "value": 22 - }, - { - "documentation": "Unique Identifier (UID)", - "key": "UI", - "value": 23 - }, - { - "documentation": "Unsigned Long", - "key": "UL", - "value": 24 - }, - { - "documentation": "Unknown", - "key": "UN", - "value": 25 - }, - { - "documentation": "Unsigned Short", - "key": "US", - "value": 26 - }, - { - "documentation": "Unlimited Text", - "key": "UT", - "value": 27 - } - ] - } - ], - "global_functions": [ - { - "args": [ - { - "name": "arg0", - "sdk_name": "expectedMajor", - "sdk_type": "int32_t" - }, - { - "name": "arg1", - "sdk_name": "expectedMinor", - "sdk_type": "int32_t" - }, - { - "name": "arg2", - "sdk_name": "expectedRevision", - "sdk_type": "int32_t" - } - ], - "c_function": "OrthancPluginCheckVersionAdvanced", - "documentation": { - "args": { - "expectedMajor": "Expected major version.", - "expectedMinor": "Expected minor version.", - "expectedRevision": "Expected revision." - }, - "description": [ - "This function checks whether the version of the Orthanc server running this plugin, is above the given version. Contrarily to OrthancPluginCheckVersion(), it is up to the developer of the plugin to make sure that all the Orthanc SDK services called by the plugin are actually implemented in the given version of Orthanc." - ], - "return": "1 if and only if the versions are compatible. If the result is 0, the initialization of the plugin should fail.", - "summary": "Check that the version of the hosting Orthanc is above a given version." - }, - "return_sdk_type": "int32_t" - }, - { - "args": [], - "c_function": "OrthancPluginCheckVersion", - "documentation": { - "args": {}, - "description": [ - "This function checks whether the version of the Orthanc server running this plugin, is above the version of the current Orthanc SDK header. This guarantees that the plugin is compatible with the hosting Orthanc (i.e. it will not call unavailable services). The result of this function should always be checked in the OrthancPluginInitialize() entry point of the plugin." - ], - "return": "1 if and only if the versions are compatible. If the result is 0, the initialization of the plugin should fail.", - "summary": "Check the compatibility of the plugin wrt. the version of its hosting Orthanc." - }, - "return_sdk_type": "int32_t" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "message", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginLogError", - "documentation": { - "args": { - "message": "The message to be logged." - }, - "description": [ - "Log an error message using the Orthanc logging system." - ], - "summary": "Log an error." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "message", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginLogWarning", - "documentation": { - "args": { - "message": "The message to be logged." - }, - "description": [ - "Log a warning message using the Orthanc logging system." - ], - "summary": "Log a warning." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "message", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginLogInfo", - "documentation": { - "args": { - "message": "The message to be logged." - }, - "description": [ - "Log an information message using the Orthanc logging system." - ], - "summary": "Log an information." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "instanceId", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginGetDicomForInstance", - "documentation": { - "args": { - "instanceId": "The Orthanc identifier of the DICOM instance of interest.", - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer()." - }, - "description": [ - "Retrieve a DICOM instance using its Orthanc identifier. The DICOM file is stored into a newly allocated memory buffer." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Retrieve a DICOM instance using its Orthanc identifier." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "uri", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginRestApiGet", - "documentation": { - "args": { - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", - "uri": "The URI in the built-in Orthanc API." - }, - "description": [ - "Make a GET call to the built-in Orthanc REST API. The result to the query is stored into a newly allocated memory buffer.", - "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Make a GET call to the built-in Orthanc REST API." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "uri", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginRestApiGetAfterPlugins", - "documentation": { - "args": { - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", - "uri": "The URI in the built-in Orthanc API." - }, - "description": [ - "Make a GET call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. The result to the query is stored into a newly allocated memory buffer.", - "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Make a GET call to the REST API, as tainted by the plugins." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "uri", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_name": "body", - "sdk_type": "const_void_pointer_with_size" - } - ], - "c_function": "OrthancPluginRestApiPost", - "documentation": { - "args": { - "body": "The body of the POST request.", - "bodySize": "The size of the body.", - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", - "uri": "The URI in the built-in Orthanc API." - }, - "description": [ - "Make a POST call to the built-in Orthanc REST API. The result to the query is stored into a newly allocated memory buffer.", - "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Make a POST call to the built-in Orthanc REST API." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "uri", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_name": "body", - "sdk_type": "const_void_pointer_with_size" - } - ], - "c_function": "OrthancPluginRestApiPostAfterPlugins", - "documentation": { - "args": { - "body": "The body of the POST request.", - "bodySize": "The size of the body.", - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", - "uri": "The URI in the built-in Orthanc API." - }, - "description": [ - "Make a POST call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. The result to the query is stored into a newly allocated memory buffer.", - "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Make a POST call to the REST API, as tainted by the plugins." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "uri", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginRestApiDelete", - "documentation": { - "args": { - "uri": "The URI to delete in the built-in Orthanc API." - }, - "description": [ - "Make a DELETE call to the built-in Orthanc REST API.", - "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Make a DELETE call to the built-in Orthanc REST API." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "uri", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginRestApiDeleteAfterPlugins", - "documentation": { - "args": { - "uri": "The URI to delete in the built-in Orthanc API." - }, - "description": [ - "Make a DELETE call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin.", - "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Make a DELETE call to the REST API, as tainted by the plugins." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "uri", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_name": "body", - "sdk_type": "const_void_pointer_with_size" - } - ], - "c_function": "OrthancPluginRestApiPut", - "documentation": { - "args": { - "body": "The body of the PUT request.", - "bodySize": "The size of the body.", - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", - "uri": "The URI in the built-in Orthanc API." - }, - "description": [ - "Make a PUT call to the built-in Orthanc REST API. The result to the query is stored into a newly allocated memory buffer.", - "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Make a PUT call to the built-in Orthanc REST API." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "uri", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_name": "body", - "sdk_type": "const_void_pointer_with_size" - } - ], - "c_function": "OrthancPluginRestApiPutAfterPlugins", - "documentation": { - "args": { - "body": "The body of the PUT request.", - "bodySize": "The size of the body.", - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", - "uri": "The URI in the built-in Orthanc API." - }, - "description": [ - "Make a PUT call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. The result to the query is stored into a newly allocated memory buffer.", - "Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Make a PUT call to the REST API, as tainted by the plugins." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "patientID", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginLookupPatient", - "documentation": { - "args": { - "patientID": "The Patient ID of interest." - }, - "description": [ - "Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020). This function uses the database index to run as fast as possible (it does not loop over all the stored patients)." - ], - "return": "The NULL value if the patient is non-existent, or a string containing the Orthanc ID of the patient. This string must be freed by OrthancPluginFreeString().", - "summary": "Look for a patient." - }, - "return_sdk_type": "char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "studyUID", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginLookupStudy", - "documentation": { - "args": { - "studyUID": "The Study Instance UID of interest." - }, - "description": [ - "Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d). This function uses the database index to run as fast as possible (it does not loop over all the stored studies)." - ], - "return": "The NULL value if the study is non-existent, or a string containing the Orthanc ID of the study. This string must be freed by OrthancPluginFreeString().", - "summary": "Look for a study." - }, - "return_sdk_type": "char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "accessionNumber", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginLookupStudyWithAccessionNumber", - "documentation": { - "args": { - "accessionNumber": "The Accession Number of interest." - }, - "description": [ - "Look for a study stored in Orthanc, using its Accession Number tag (0x0008, 0x0050). This function uses the database index to run as fast as possible (it does not loop over all the stored studies)." - ], - "return": "The NULL value if the study is non-existent, or a string containing the Orthanc ID of the study. This string must be freed by OrthancPluginFreeString().", - "summary": "Look for a study, using the accession number." - }, - "return_sdk_type": "char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "seriesUID", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginLookupSeries", - "documentation": { - "args": { - "seriesUID": "The Series Instance UID of interest." - }, - "description": [ - "Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e). This function uses the database index to run as fast as possible (it does not loop over all the stored series)." - ], - "return": "The NULL value if the series is non-existent, or a string containing the Orthanc ID of the series. This string must be freed by OrthancPluginFreeString().", - "summary": "Look for a series." - }, - "return_sdk_type": "char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "sopInstanceUID", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginLookupInstance", - "documentation": { - "args": { - "sopInstanceUID": "The SOP Instance UID of interest." - }, - "description": [ - "Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018). This function uses the database index to run as fast as possible (it does not loop over all the stored instances)." - ], - "return": "The NULL value if the instance is non-existent, or a string containing the Orthanc ID of the instance. This string must be freed by OrthancPluginFreeString().", - "summary": "Look for an instance." - }, - "return_sdk_type": "char *" - }, - { - "args": [], - "c_function": "OrthancPluginGetOrthancPath", - "documentation": { - "args": {}, - "description": [ - "This function returns the path to the Orthanc executable." - ], - "return": "NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString().", - "summary": "Return the path to the Orthanc executable." - }, - "return_sdk_type": "char *" - }, - { - "args": [], - "c_function": "OrthancPluginGetOrthancDirectory", - "documentation": { - "args": {}, - "description": [ - "This function returns the path to the directory containing the Orthanc executable." - ], - "return": "NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString().", - "summary": "Return the directory containing the Orthanc." - }, - "return_sdk_type": "char *" - }, - { - "args": [], - "c_function": "OrthancPluginGetConfigurationPath", - "documentation": { - "args": {}, - "description": [ - "This function returns the path to the configuration file(s) that was specified when starting Orthanc. Since version 0.9.1, this path can refer to a folder that stores a set of configuration files. This function is deprecated in favor of OrthancPluginGetConfiguration()." - ], - "return": "NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString().", - "summary": "Return the path to the configuration file(s)." - }, - "return_sdk_type": "char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "uri", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginSetRootUri", - "documentation": { - "args": { - "uri": "The root URI for this plugin." - }, - "description": [ - "For plugins that come with a Web interface, this function declares the entry path where to find this interface. This information is notably used in the \"Plugins\" page of Orthanc Explorer." - ], - "summary": "Set the URI where the plugin provides its Web interface." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "description", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginSetDescription", - "documentation": { - "args": { - "description": "The description." - }, - "description": [ - "Set a description for this plugin. It is displayed in the \"Plugins\" page of Orthanc Explorer." - ], - "summary": "Set a description for this plugin." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "javascript", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginExtendOrthancExplorer", - "documentation": { - "args": { - "javascript": "The custom JavaScript code." - }, - "description": [ - "Add JavaScript code to customize the default behavior of Orthanc Explorer. This can for instance be used to add new buttons." - ], - "summary": "Extend the JavaScript code of Orthanc Explorer." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "property", - "sdk_type": "int32_t" - }, - { - "name": "arg1", - "sdk_name": "defaultValue", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginGetGlobalProperty", - "documentation": { - "args": { - "defaultValue": "The value to return, if the global property is unset.", - "property": "The global property of interest." - }, - "description": [ - "Get the value of a global property that is stored in the Orthanc database. Global properties whose index is below 1024 are reserved by Orthanc." - ], - "return": "The value of the global property, or NULL in the case of an error. This string must be freed by OrthancPluginFreeString().", - "summary": "Get the value of a global property." - }, - "return_sdk_type": "char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "property", - "sdk_type": "int32_t" - }, - { - "name": "arg1", - "sdk_name": "value", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginSetGlobalProperty", - "documentation": { - "args": { - "property": "The global property of interest.", - "value": "The value to be set in the global property." - }, - "description": [ - "Set the value of a global property into the Orthanc database. Setting a global property can be used by plugins to save their internal parameters. Plugins are only allowed to set properties whose index are above or equal to 1024 (properties below 1024 are read-only and reserved by Orthanc)." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Set the value of a global property." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - }, - { - "args": [], - "c_function": "OrthancPluginGetCommandLineArgumentsCount", - "documentation": { - "args": {}, - "description": [ - "Retrieve the number of command-line arguments that were used to launch Orthanc." - ], - "return": "The number of arguments.", - "summary": "Get the number of command-line arguments." - }, - "return_sdk_type": "uint32_t" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "argument", - "sdk_type": "uint32_t" - } - ], - "c_function": "OrthancPluginGetCommandLineArgument", - "documentation": { - "args": { - "argument": "The index of the argument." - }, - "description": [ - "Get the value of one of the command-line arguments that were used to launch Orthanc. The number of available arguments can be retrieved by OrthancPluginGetCommandLineArgumentsCount()." - ], - "return": "The value of the argument, or NULL in the case of an error. This string must be freed by OrthancPluginFreeString().", - "summary": "Get the value of a command-line argument." - }, - "return_sdk_type": "char *" - }, - { - "args": [], - "c_function": "OrthancPluginGetExpectedDatabaseVersion", - "documentation": { - "args": {}, - "description": [ - "Retrieve the expected version of the database schema." - ], - "return": "The version.", - "summary": "Get the expected version of the database schema." - }, - "return_sdk_type": "uint32_t" - }, - { - "args": [], - "c_function": "OrthancPluginGetConfiguration", - "documentation": { - "args": {}, - "description": [ - "This function returns the content of the configuration that is used by Orthanc, formatted as a JSON string." - ], - "return": "NULL in the case of an error, or a newly allocated string containing the configuration. This string must be freed by OrthancPluginFreeString().", - "summary": "Return the content of the configuration file(s)." - }, - "return_sdk_type": "char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "source", - "sdk_type": "const_void_pointer_with_size" - }, - { - "name": "arg2", - "sdk_enumeration": "OrthancPluginCompressionType", - "sdk_name": "compression", - "sdk_type": "enumeration" - }, - { - "name": "arg3", - "sdk_name": "uncompress", - "sdk_type": "uint8_t" - } - ], - "c_function": "OrthancPluginBufferCompression", - "documentation": { - "args": { - "compression": "The compression algorithm.", - "size": "The size in bytes of the source buffer.", - "source": "The source buffer.", - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", - "uncompress": "If set to \"0\", the buffer must be compressed. If set to \"1\", the buffer must be uncompressed." - }, - "description": [ - "This function compresses or decompresses a buffer, using the version of the zlib library that is used by the Orthanc core." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Compress or decompress a buffer." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "path", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginReadFile", - "documentation": { - "args": { - "path": "The path of the file to be read.", - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer()." - }, - "description": [ - "Read the content of a file on the filesystem, and returns it into a newly allocated memory buffer." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Read a file." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "path", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_name": "data", - "sdk_type": "const_void_pointer_with_size" - } - ], - "c_function": "OrthancPluginWriteFile", - "documentation": { - "args": { - "data": "The content of the memory buffer.", - "path": "The path of the file to be written.", - "size": "The size of the memory buffer." - }, - "description": [ - "Write the content of a memory buffer to the filesystem." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Write a file." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - }, - { - "args": [ - { - "name": "arg0", - "sdk_enumeration": "OrthancPluginErrorCode", - "sdk_name": "error", - "sdk_type": "enumeration" - } - ], - "c_function": "OrthancPluginGetErrorDescription", - "documentation": { - "args": { - "error": "The error code of interest." - }, - "description": [ - "This function returns the description of a given error code." - ], - "return": "The error description. This is a statically-allocated string, do not free it.", - "summary": "Get the description of a given error code." - }, - "return_sdk_type": "const char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "data", - "sdk_type": "const_void_pointer_with_size" - }, - { - "name": "arg2", - "sdk_enumeration": "OrthancPluginImageFormat", - "sdk_name": "format", - "sdk_type": "enumeration" - } - ], - "c_function": "OrthancPluginUncompressImage", - "documentation": { - "args": { - "data": "Pointer to a memory buffer containing the compressed image.", - "format": "The file format of the compressed image.", - "size": "Size of the memory buffer containing the compressed image." - }, - "description": [ - "This function decodes a compressed image from a memory buffer." - ], - "return": "The uncompressed image. It must be freed with OrthancPluginFreeImage().", - "summary": "Decode a compressed image." - }, - "return_sdk_class": "OrthancPluginImage", - "return_sdk_type": "object" - }, - { - "args": [ - { - "name": "arg0", - "sdk_enumeration": "OrthancPluginPixelFormat", - "sdk_name": "format", - "sdk_type": "enumeration" - }, - { - "name": "arg1", - "sdk_name": "width", - "sdk_type": "uint32_t" - }, - { - "name": "arg2", - "sdk_name": "height", - "sdk_type": "uint32_t" - }, - { - "name": "arg3", - "sdk_name": "pitch", - "sdk_type": "uint32_t" - }, - { - "name": "arg4", - "sdk_name": "buffer", - "sdk_type": "const void *" - } - ], - "c_function": "OrthancPluginCompressPngImage", - "documentation": { - "args": { - "buffer": "The memory buffer containing the uncompressed image.", - "format": "The memory layout of the uncompressed image.", - "height": "The height of the image.", - "pitch": "The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer).", - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", - "width": "The width of the image." - }, - "description": [ - "This function compresses the given memory buffer containing an image using the PNG specification, and stores the result of the compression into a newly allocated memory buffer." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Encode a PNG image." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_enumeration": "OrthancPluginPixelFormat", - "sdk_name": "format", - "sdk_type": "enumeration" - }, - { - "name": "arg1", - "sdk_name": "width", - "sdk_type": "uint32_t" - }, - { - "name": "arg2", - "sdk_name": "height", - "sdk_type": "uint32_t" - }, - { - "name": "arg3", - "sdk_name": "pitch", - "sdk_type": "uint32_t" - }, - { - "name": "arg4", - "sdk_name": "buffer", - "sdk_type": "const void *" - }, - { - "name": "arg5", - "sdk_name": "quality", - "sdk_type": "uint8_t" - } - ], - "c_function": "OrthancPluginCompressJpegImage", - "documentation": { - "args": { - "buffer": "The memory buffer containing the uncompressed image.", - "format": "The memory layout of the uncompressed image.", - "height": "The height of the image.", - "pitch": "The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer).", - "quality": "The quality of the JPEG encoding, between 1 (worst quality, best compression) and 100 (best quality, worst compression).", - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", - "width": "The width of the image." - }, - "description": [ - "This function compresses the given memory buffer containing an image using the JPEG specification, and stores the result of the compression into a newly allocated memory buffer." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Encode a JPEG image." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "url", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_name": "username", - "sdk_type": "const char *" - }, - { - "name": "arg2", - "sdk_name": "password", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginHttpGet", - "documentation": { - "args": { - "password": "The password (can be \"NULL\" if no password protection).", - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", - "url": "The URL of interest.", - "username": "The username (can be \"NULL\" if no password protection)." - }, - "description": [ - "Make a HTTP GET call to the given URL. The result to the query is stored into a newly allocated memory buffer. Favor OrthancPluginRestApiGet() if calling the built-in REST API of the Orthanc instance that hosts this plugin." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Issue a HTTP GET call." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "url", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_name": "body", - "sdk_type": "const_void_pointer_with_size" - }, - { - "name": "arg3", - "sdk_name": "username", - "sdk_type": "const char *" - }, - { - "name": "arg4", - "sdk_name": "password", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginHttpPost", - "documentation": { - "args": { - "body": "The content of the body of the request.", - "bodySize": "The size of the body of the request.", - "password": "The password (can be \"NULL\" if no password protection).", - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", - "url": "The URL of interest.", - "username": "The username (can be \"NULL\" if no password protection)." - }, - "description": [ - "Make a HTTP POST call to the given URL. The result to the query is stored into a newly allocated memory buffer. Favor OrthancPluginRestApiPost() if calling the built-in REST API of the Orthanc instance that hosts this plugin." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Issue a HTTP POST call." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "url", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_name": "body", - "sdk_type": "const_void_pointer_with_size" - }, - { - "name": "arg3", - "sdk_name": "username", - "sdk_type": "const char *" - }, - { - "name": "arg4", - "sdk_name": "password", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginHttpPut", - "documentation": { - "args": { - "body": "The content of the body of the request.", - "bodySize": "The size of the body of the request.", - "password": "The password (can be \"NULL\" if no password protection).", - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer().", - "url": "The URL of interest.", - "username": "The username (can be \"NULL\" if no password protection)." - }, - "description": [ - "Make a HTTP PUT call to the given URL. The result to the query is stored into a newly allocated memory buffer. Favor OrthancPluginRestApiPut() if calling the built-in REST API of the Orthanc instance that hosts this plugin." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Issue a HTTP PUT call." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "url", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_name": "username", - "sdk_type": "const char *" - }, - { - "name": "arg2", - "sdk_name": "password", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginHttpDelete", - "documentation": { - "args": { - "password": "The password (can be \"NULL\" if no password protection).", - "url": "The URL of interest.", - "username": "The username (can be \"NULL\" if no password protection)." - }, - "description": [ - "Make a HTTP DELETE call to the given URL. Favor OrthancPluginRestApiDelete() if calling the built-in REST API of the Orthanc instance that hosts this plugin." - ], - "return": "0 if success, or the error code if failure.", - "summary": "Issue a HTTP DELETE call." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - }, - { - "args": [], - "c_function": "OrthancPluginGetFontsCount", - "documentation": { - "args": {}, - "description": [ - "This function returns the number of fonts that are built in the Orthanc core. These fonts can be used to draw texts on images through OrthancPluginDrawText()." - ], - "return": "The number of fonts.", - "summary": "Return the number of available fonts." - }, - "return_sdk_type": "uint32_t" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "fontIndex", - "sdk_type": "uint32_t" - } - ], - "c_function": "OrthancPluginGetFontName", - "documentation": { - "args": { - "fontIndex": "The index of the font. This value must be less than OrthancPluginGetFontsCount()." - }, - "description": [ - "This function returns the name of a font that is built in the Orthanc core." - ], - "return": "The font name. This is a statically-allocated string, do not free it.", - "summary": "Return the name of a font." - }, - "return_sdk_type": "const char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "fontIndex", - "sdk_type": "uint32_t" - } - ], - "c_function": "OrthancPluginGetFontSize", - "documentation": { - "args": { - "fontIndex": "The index of the font. This value must be less than OrthancPluginGetFontsCount()." - }, - "description": [ - "This function returns the size of a font that is built in the Orthanc core." - ], - "return": "The font size.", - "summary": "Return the size of a font." - }, - "return_sdk_type": "uint32_t" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "code", - "sdk_type": "int32_t" - }, - { - "name": "arg1", - "sdk_name": "httpStatus", - "sdk_type": "uint16_t" - }, - { - "name": "arg2", - "sdk_name": "message", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginRegisterErrorCode", - "documentation": { - "args": { - "code": "The error code that is internal to this plugin.", - "httpStatus": "The HTTP status corresponding to this error.", - "message": "The description of the error." - }, - "description": [ - "This function declares a custom error code that can be generated by this plugin. This declaration is used to enrich the body of the HTTP answer in the case of an error, and to set the proper HTTP status code." - ], - "return": "The error code that has been assigned inside the Orthanc core.", - "summary": "Declare a custom error code for this plugin." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "group", - "sdk_type": "uint16_t" - }, - { - "name": "arg1", - "sdk_name": "element", - "sdk_type": "uint16_t" - }, - { - "name": "arg2", - "sdk_enumeration": "OrthancPluginValueRepresentation", - "sdk_name": "vr", - "sdk_type": "enumeration" - }, - { - "name": "arg3", - "sdk_name": "name", - "sdk_type": "const char *" - }, - { - "name": "arg4", - "sdk_name": "minMultiplicity", - "sdk_type": "uint32_t" - }, - { - "name": "arg5", - "sdk_name": "maxMultiplicity", - "sdk_type": "uint32_t" - } - ], - "c_function": "OrthancPluginRegisterDictionaryTag", - "documentation": { - "args": { - "element": "The element of the tag.", - "group": "The group of the tag.", - "maxMultiplicity": "The maximum multiplicity of the tag. A value of 0 means an arbitrary multiplicity (\"\"n\"\").", - "minMultiplicity": "The minimum multiplicity of the tag (must be above 0).", - "name": "The nickname of the tag.", - "vr": "The value representation of the tag." - }, - "description": [ - "This function declares a new public tag in the dictionary of DICOM tags that are known to Orthanc. This function should be used in the OrthancPluginInitialize() callback." - ], - "return": "0 if success, other value if error.", - "summary": "Register a new tag into the DICOM dictionary." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "group", - "sdk_type": "uint16_t" - }, - { - "name": "arg1", - "sdk_name": "element", - "sdk_type": "uint16_t" - }, - { - "name": "arg2", - "sdk_enumeration": "OrthancPluginValueRepresentation", - "sdk_name": "vr", - "sdk_type": "enumeration" - }, - { - "name": "arg3", - "sdk_name": "name", - "sdk_type": "const char *" - }, - { - "name": "arg4", - "sdk_name": "minMultiplicity", - "sdk_type": "uint32_t" - }, - { - "name": "arg5", - "sdk_name": "maxMultiplicity", - "sdk_type": "uint32_t" - }, - { - "name": "arg6", - "sdk_name": "privateCreator", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginRegisterPrivateDictionaryTag", - "documentation": { - "args": { - "element": "The element of the tag.", - "group": "The group of the tag.", - "maxMultiplicity": "The maximum multiplicity of the tag. A value of 0 means an arbitrary multiplicity (\"\"n\"\").", - "minMultiplicity": "The minimum multiplicity of the tag (must be above 0).", - "name": "The nickname of the tag.", - "privateCreator": "The private creator of this private tag.", - "vr": "The value representation of the tag." - }, - "description": [ - "This function declares a new private tag in the dictionary of DICOM tags that are known to Orthanc. This function should be used in the OrthancPluginInitialize() callback." - ], - "return": "0 if success, other value if error.", - "summary": "Register a new private tag into the DICOM dictionary." - }, - "return_sdk_enumeration": "OrthancPluginErrorCode", - "return_sdk_type": "enumeration" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "buffer", - "sdk_type": "const_void_pointer_with_size" - }, - { - "name": "arg2", - "sdk_enumeration": "OrthancPluginDicomToJsonFormat", - "sdk_name": "format", - "sdk_type": "enumeration" - }, - { - "name": "arg3", - "sdk_enumeration": "OrthancPluginDicomToJsonFlags", - "sdk_name": "flags", - "sdk_type": "enumeration" - }, - { - "name": "arg4", - "sdk_name": "maxStringLength", - "sdk_type": "uint32_t" - } - ], - "c_function": "OrthancPluginDicomBufferToJson", - "documentation": { - "args": { - "buffer": "The memory buffer containing the DICOM file.", - "flags": "Flags governing the output.", - "format": "The output format.", - "maxStringLength": "The maximum length of a field. Too long fields will be output as \"null\". The 0 value means no maximum length.", - "size": "The size of the memory buffer." - }, - "description": [ - "This function takes as input a memory buffer containing a DICOM file, and outputs a JSON string representing the tags of this DICOM file." - ], - "return": "The NULL value if the case of an error, or the JSON string. This string must be freed by OrthancPluginFreeString().", - "summary": "Format a DICOM memory buffer as a JSON string." - }, - "return_sdk_type": "char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "instanceId", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_enumeration": "OrthancPluginDicomToJsonFormat", - "sdk_name": "format", - "sdk_type": "enumeration" - }, - { - "name": "arg2", - "sdk_enumeration": "OrthancPluginDicomToJsonFlags", - "sdk_name": "flags", - "sdk_type": "enumeration" - }, - { - "name": "arg3", - "sdk_name": "maxStringLength", - "sdk_type": "uint32_t" - } - ], - "c_function": "OrthancPluginDicomInstanceToJson", - "documentation": { - "args": { - "flags": "Flags governing the output.", - "format": "The output format.", - "instanceId": "The Orthanc identifier of the instance.", - "maxStringLength": "The maximum length of a field. Too long fields will be output as \"null\". The 0 value means no maximum length." - }, - "description": [ - "This function formats a DICOM instance that is stored in Orthanc, and outputs a JSON string representing the tags of this DICOM instance." - ], - "return": "The NULL value if the case of an error, or the JSON string. This string must be freed by OrthancPluginFreeString().", - "summary": "Format a DICOM instance as a JSON string." - }, - "return_sdk_type": "char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "json", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_class": "OrthancPluginImage", - "sdk_name": "pixelData", - "sdk_type": "const_object" - }, - { - "name": "arg2", - "sdk_enumeration": "OrthancPluginCreateDicomFlags", - "sdk_name": "flags", - "sdk_type": "enumeration" - } - ], - "c_function": "OrthancPluginCreateDicom", - "documentation": { - "args": { - "flags": "Flags governing the output.", - "json": "The input JSON file.", - "pixelData": "The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme.", - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer()." - }, - "description": [ - "This function takes as input a string containing a JSON file describing the content of a DICOM instance. As an output, it writes the corresponding DICOM instance to a newly allocated memory buffer. Additionally, an image to be encoded within the DICOM instance can also be provided.", - "Private tags will be associated with the private creator whose value is specified in the \"DefaultPrivateCreator\" configuration option of Orthanc. The function OrthancPluginCreateDicom2() can be used if another private creator must be used to create this instance." - ], - "return": "0 if success, other value if error.", - "summary": "Create a DICOM instance from a JSON string and an image." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_enumeration": "OrthancPluginPixelFormat", - "sdk_name": "format", - "sdk_type": "enumeration" - }, - { - "name": "arg1", - "sdk_name": "width", - "sdk_type": "uint32_t" - }, - { - "name": "arg2", - "sdk_name": "height", - "sdk_type": "uint32_t" - } - ], - "c_function": "OrthancPluginCreateImage", - "documentation": { - "args": { - "format": "The format of the pixels.", - "height": "The height of the image.", - "width": "The width of the image." - }, - "description": [ - "This function creates an image of given size and format." - ], - "return": "The newly allocated image. It must be freed with OrthancPluginFreeImage().", - "summary": "Create an image." - }, - "return_sdk_class": "OrthancPluginImage", - "return_sdk_type": "object" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "buffer", - "sdk_type": "const_void_pointer_with_size" - }, - { - "name": "arg2", - "sdk_name": "frameIndex", - "sdk_type": "uint32_t" - } - ], - "c_function": "OrthancPluginDecodeDicomImage", - "documentation": { - "args": { - "buffer": "Pointer to a memory buffer containing the DICOM image.", - "bufferSize": "Size of the memory buffer containing the DICOM image.", - "frameIndex": "The index of the frame of interest in a multi-frame image." - }, - "description": [ - "This function decodes one frame of a DICOM image that is stored in a memory buffer. This function will give the same result as OrthancPluginUncompressImage() for single-frame DICOM images." - ], - "return": "The uncompressed image. It must be freed with OrthancPluginFreeImage().", - "summary": "Decode one frame from a DICOM instance." - }, - "return_sdk_class": "OrthancPluginImage", - "return_sdk_type": "object" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "buffer", - "sdk_type": "const_void_pointer_with_size" - } - ], - "c_function": "OrthancPluginComputeMd5", - "documentation": { - "args": { - "buffer": "The source memory buffer.", - "size": "The size in bytes of the source buffer." - }, - "description": [ - "This functions computes the MD5 cryptographic hash of the given memory buffer." - ], - "return": "The NULL value in case of error, or a string containing the cryptographic hash. This string must be freed by OrthancPluginFreeString().", - "summary": "Compute an MD5 hash." - }, - "return_sdk_type": "char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "buffer", - "sdk_type": "const_void_pointer_with_size" - } - ], - "c_function": "OrthancPluginComputeSha1", - "documentation": { - "args": { - "buffer": "The source memory buffer.", - "size": "The size in bytes of the source buffer." - }, - "description": [ - "This functions computes the SHA-1 cryptographic hash of the given memory buffer." - ], - "return": "The NULL value in case of error, or a string containing the cryptographic hash. This string must be freed by OrthancPluginFreeString().", - "summary": "Compute a SHA-1 hash." - }, - "return_sdk_type": "char *" - }, - { - "args": [], - "c_function": "OrthancPluginGenerateUuid", - "documentation": { - "args": {}, - "description": [ - "Generate a random GUID/UUID (globally unique identifier)." - ], - "return": "NULL in the case of an error, or a newly allocated string containing the UUID. This string must be freed by OrthancPluginFreeString().", - "summary": "Generate an UUID." - }, - "return_sdk_type": "char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "query", - "sdk_type": "const_void_pointer_with_size" - } - ], - "c_function": "OrthancPluginCreateFindMatcher", - "documentation": { - "args": { - "query": "The C-Find DICOM query.", - "size": "The size of the DICOM query." - }, - "description": [ - "This function creates a \"matcher\" object that can be used to check whether a DICOM instance matches a C-Find query. The C-Find query must be expressed as a DICOM buffer." - ], - "return": "The newly allocated matcher. It must be freed with OrthancPluginFreeFindMatcher().", - "summary": "Create a C-Find matcher." - }, - "return_sdk_class": "OrthancPluginFindMatcher", - "return_sdk_type": "object" - }, - { - "args": [], - "c_function": "OrthancPluginGetPeers", - "documentation": { - "args": {}, - "description": [ - "This function returns the parameters of the Orthanc peers that are known to the Orthanc server hosting the plugin." - ], - "return": "NULL if error, or a newly allocated opaque data structure containing the peers. This structure must be freed with OrthancPluginFreePeers().", - "summary": "Return the list of available Orthanc peers." - }, - "return_sdk_class": "OrthancPluginPeers", - "return_sdk_type": "object" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "path", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginAutodetectMimeType", - "documentation": { - "args": { - "path": "Path to the file." - }, - "description": [ - "This function returns the MIME type of a file by inspecting its extension." - ], - "return": "The MIME type. This is a statically-allocated string, do not free it.", - "summary": "Detect the MIME type of a file." - }, - "return_sdk_type": "const char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "name", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_name": "value", - "sdk_type": "float" - }, - { - "name": "arg2", - "sdk_enumeration": "OrthancPluginMetricsType", - "sdk_name": "type", - "sdk_type": "enumeration" - } - ], - "c_function": "OrthancPluginSetMetricsValue", - "documentation": { - "args": { - "name": "The name of the metrics to be set.", - "type": "The type of the metrics. This parameter is only taken into consideration the first time this metrics is set.", - "value": "The value of the metrics." - }, - "description": [ - "This function sets the value of a metrics to monitor the behavior of the plugin through tools such as Prometheus. The values of all the metrics are stored within the Orthanc context." - ], - "summary": "Set the value of a metrics." - }, - "return_sdk_type": "void" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "group", - "sdk_type": "uint16_t" - }, - { - "name": "arg1", - "sdk_name": "element", - "sdk_type": "uint16_t" - }, - { - "name": "arg2", - "sdk_name": "privateCreator", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginGetTagName", - "documentation": { - "args": { - "element": "The element of the tag.", - "group": "The group of the tag.", - "privateCreator": "For private tags, the name of the private creator (can be NULL)." - }, - "description": [ - "This function makes a lookup to the dictionary of DICOM tags that are known to Orthanc, and returns the symbolic name of a DICOM tag." - ], - "return": "NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString().", - "summary": "Returns the symbolic name of a DICOM tag." - }, - "return_sdk_type": "char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "buffer", - "sdk_type": "const_void_pointer_with_size" - } - ], - "c_function": "OrthancPluginCreateDicomInstance", - "documentation": { - "args": { - "buffer": "The memory buffer containing the DICOM instance.", - "size": "The size of the memory buffer." - }, - "description": [ - "This function parses a memory buffer that contains a DICOM file. The function returns a new pointer to a data structure that is managed by the Orthanc core." - ], - "return": "The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance().", - "summary": "Parse a DICOM instance." - }, - "return_sdk_class": "OrthancPluginDicomInstance", - "return_sdk_type": "object" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "buffer", - "sdk_type": "const_void_pointer_with_size" - }, - { - "name": "arg2", - "sdk_name": "transferSyntax", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginTranscodeDicomInstance", - "documentation": { - "args": { - "buffer": "The memory buffer containing the DICOM instance.", - "size": "The size of the memory buffer.", - "transferSyntax": "The transfer syntax UID for the transcoding." - }, - "description": [ - "This function parses a memory buffer that contains a DICOM file, then transcodes it to the given transfer syntax. The function returns a new pointer to a data structure that is managed by the Orthanc core." - ], - "return": "The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance().", - "summary": "Parse and transcode a DICOM instance." - }, - "return_sdk_class": "OrthancPluginDicomInstance", - "return_sdk_type": "object" - }, - { - "args": [], - "c_function": "OrthancPluginGenerateRestApiAuthorizationToken", - "documentation": { - "args": {}, - "description": [ - "This function generates a token that can be set in the HTTP header \"Authorization\" so as to grant full access to the REST API of Orthanc using an external HTTP client. Using this function avoids the need of adding a separate user in the \"RegisteredUsers\" configuration of Orthanc, which eases deployments.", - "This feature is notably useful in multiprocess scenarios, where a subprocess created by a plugin has no access to the \"OrthancPluginContext\", and thus cannot call \"OrthancPluginRestApi[Get|Post|Put|Delete]()\".", - "This situation is frequently encountered in Python plugins, where the \"multiprocessing\" package can be used to bypass the Global Interpreter Lock (GIL) and thus to improve performance and concurrency." - ], - "return": "The authorization token, or NULL value in the case of an error. This string must be freed by OrthancPluginFreeString().", - "summary": "Generate a token to grant full access to the REST API of Orthanc" - }, - "return_sdk_type": "char *" - }, - { - "args": [ - { - "name": "arg0", - "sdk_name": "json", - "sdk_type": "const char *" - }, - { - "name": "arg1", - "sdk_class": "OrthancPluginImage", - "sdk_name": "pixelData", - "sdk_type": "const_object" - }, - { - "name": "arg2", - "sdk_enumeration": "OrthancPluginCreateDicomFlags", - "sdk_name": "flags", - "sdk_type": "enumeration" - }, - { - "name": "arg3", - "sdk_name": "privateCreator", - "sdk_type": "const char *" - } - ], - "c_function": "OrthancPluginCreateDicom2", - "documentation": { - "args": { - "flags": "Flags governing the output.", - "json": "The input JSON file.", - "pixelData": "The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme.", - "privateCreator": "The private creator to be used for the private DICOM tags. Check out the global configuration option \"Dictionary\" of Orthanc.", - "target": "The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer()." - }, - "description": [ - "This function takes as input a string containing a JSON file describing the content of a DICOM instance. As an output, it writes the corresponding DICOM instance to a newly allocated memory buffer. Additionally, an image to be encoded within the DICOM instance can also be provided.", - "Contrarily to the function OrthancPluginCreateDicom(), this function can be explicitly provided with a private creator." - ], - "return": "0 if success, other value if error.", - "summary": "Create a DICOM instance from a JSON string and an image, with a private creator." - }, - "return_sdk_type": "OrthancPluginMemoryBuffer *" - } - ] -} \ No newline at end of file diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Orthanc/Sdk-1.10.0/CodeModel.json.license --- a/Resources/Orthanc/Sdk-1.10.0/CodeModel.json.license Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -# SPDX-FileCopyrightText: 2023-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium -# SPDX-License-Identifier: GPL-3.0-or-later diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Orthanc/Sdk-1.10.0/orthanc/OrthancCPlugin.h --- a/Resources/Orthanc/Sdk-1.10.0/orthanc/OrthancCPlugin.h Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/Orthanc/Sdk-1.10.0/orthanc/OrthancCPlugin.h Wed Aug 13 12:02:04 2025 +0200 @@ -837,7 +837,7 @@ **/ typedef enum { - OrthancPluginDicomToJsonFlags_None = 0, /*!< Default formatting */ + OrthancPluginDicomToJsonFlags_None = 0, OrthancPluginDicomToJsonFlags_IncludeBinary = (1 << 0), /*!< Include the binary tags */ OrthancPluginDicomToJsonFlags_IncludePrivateTags = (1 << 1), /*!< Include the private tags */ OrthancPluginDicomToJsonFlags_IncludeUnknownTags = (1 << 2), /*!< Include the tags unknown by the dictionary */ @@ -858,7 +858,7 @@ **/ typedef enum { - OrthancPluginCreateDicomFlags_None = 0, /*!< Default mode */ + OrthancPluginCreateDicomFlags_None = 0, OrthancPluginCreateDicomFlags_DecodeDataUriScheme = (1 << 0), /*!< Decode fields encoded using data URI scheme */ OrthancPluginCreateDicomFlags_GenerateIdentifiers = (1 << 1), /*!< Automatically generate DICOM identifiers */ @@ -975,46 +975,32 @@ **/ typedef enum { - /** - * Success: The DICOM instance is properly stored in the SCP - **/ OrthancPluginStorageCommitmentFailureReason_Success = 0, - - /** - * 0110H: A general failure in processing the operation was encountered - **/ + /*!< Success: The DICOM instance is properly stored in the SCP */ + OrthancPluginStorageCommitmentFailureReason_ProcessingFailure = 1, - - /** - * 0112H: One or more of the elements in the Referenced SOP - * Instance Sequence was not available - **/ + /*!< 0110H: A general failure in processing the operation was encountered */ + OrthancPluginStorageCommitmentFailureReason_NoSuchObjectInstance = 2, - - /** - * 0213H: The SCP does not currently have enough resources to - * store the requested SOP Instance(s) - **/ + /*!< 0112H: One or more of the elements in the Referenced SOP + Instance Sequence was not available */ + OrthancPluginStorageCommitmentFailureReason_ResourceLimitation = 3, - - /** - * 0122H: Storage Commitment has been requested for a SOP Instance - * with a SOP Class that is not supported by the SCP - **/ + /*!< 0213H: The SCP does not currently have enough resources to + store the requested SOP Instance(s) */ + OrthancPluginStorageCommitmentFailureReason_ReferencedSOPClassNotSupported = 4, - - /** - * 0119H: The SOP Class of an element in the Referenced SOP - * Instance Sequence did not correspond to the SOP class - * registered for this SOP Instance at the SCP - **/ + /*!< 0122H: Storage Commitment has been requested for a SOP + Instance with a SOP Class that is not supported by the SCP */ + OrthancPluginStorageCommitmentFailureReason_ClassInstanceConflict = 5, - - /** - * 0131H: The Transaction UID of the Storage Commitment Request is - * already in use - **/ + /*!< 0119H: The SOP Class of an element in the Referenced SOP + Instance Sequence did not correspond to the SOP class registered + for this SOP Instance at the SCP */ + OrthancPluginStorageCommitmentFailureReason_DuplicateTransactionUID = 6 + /*!< 0131H: The Transaction UID of the Storage Commitment Request + is already in use */ } OrthancPluginStorageCommitmentFailureReason; @@ -1843,16 +1829,15 @@ * @see OrthancPluginCheckVersion * @ingroup Callbacks **/ - ORTHANC_PLUGIN_INLINE int32_t OrthancPluginCheckVersionAdvanced( + ORTHANC_PLUGIN_INLINE int OrthancPluginCheckVersionAdvanced( OrthancPluginContext* context, - int32_t expectedMajor, - int32_t expectedMinor, - int32_t expectedRevision) - { - int32_t major, minor, revision; - - if (sizeof(int) != sizeof(int32_t) || /* Ensure binary compatibility with Orthanc SDK <= 1.12.1 */ - sizeof(int32_t) != sizeof(OrthancPluginErrorCode) || + int expectedMajor, + int expectedMinor, + int expectedRevision) + { + int major, minor, revision; + + if (sizeof(int32_t) != sizeof(OrthancPluginErrorCode) || sizeof(int32_t) != sizeof(OrthancPluginHttpMethod) || sizeof(int32_t) != sizeof(_OrthancPluginService) || sizeof(int32_t) != sizeof(_OrthancPluginProperty) || @@ -1950,7 +1935,7 @@ * @see OrthancPluginCheckVersionAdvanced * @ingroup Callbacks **/ - ORTHANC_PLUGIN_INLINE int32_t OrthancPluginCheckVersion( + ORTHANC_PLUGIN_INLINE int OrthancPluginCheckVersion( OrthancPluginContext* context) { return OrthancPluginCheckVersionAdvanced( @@ -3092,7 +3077,7 @@ * @return 1 if the metadata is present, 0 if it is absent, -1 in case of error. * @ingroup DicomInstance **/ - ORTHANC_PLUGIN_INLINE int32_t OrthancPluginHasInstanceMetadata( + ORTHANC_PLUGIN_INLINE int OrthancPluginHasInstanceMetadata( OrthancPluginContext* context, const OrthancPluginDicomInstance* instance, const char* metadata) @@ -3871,13 +3856,13 @@ OrthancPluginContext* context, OrthancPluginRestOutput* output, uint16_t status, - const void* body, + const char* body, uint32_t bodySize) { _OrthancPluginSendHttpStatus params; params.output = output; params.status = status; - params.body = (const char*) body; + params.body = body; params.bodySize = bodySize; context->InvokeService(context, _OrthancPluginService_SendHttpStatus, ¶ms); } @@ -6775,7 +6760,7 @@ { char** resultId; OrthancPluginJob *job; - int32_t priority; + int priority; } _OrthancPluginSubmitJob; /** @@ -6794,7 +6779,7 @@ ORTHANC_PLUGIN_INLINE char *OrthancPluginSubmitJob( OrthancPluginContext *context, OrthancPluginJob *job, - int32_t priority) + int priority) { char* resultId = NULL; diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Orthanc/Sdk-1.12.6/orthanc/OrthancCPlugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Orthanc/Sdk-1.12.6/orthanc/OrthancCPlugin.h Wed Aug 13 12:02:04 2025 +0200 @@ -0,0 +1,9640 @@ +/** + * \mainpage + * + * This C/C++ SDK allows external developers to create plugins that + * can be loaded into Orthanc to extend its functionality. Each + * Orthanc plugin must expose 4 public functions with the following + * signatures: + * + * -# int32_t OrthancPluginInitialize(const OrthancPluginContext* context): + * This function is invoked by Orthanc when it loads the plugin on startup. + * The plugin must: + * - Check its compatibility with the Orthanc version using + * ::OrthancPluginCheckVersion(). + * - Store the context pointer so that it can use the plugin + * services of Orthanc. + * - Register all its REST callbacks using ::OrthancPluginRegisterRestCallback(). + * - Possibly register its callback for received DICOM instances using ::OrthancPluginRegisterOnStoredInstanceCallback(). + * - Possibly register its callback for changes to the DICOM store using ::OrthancPluginRegisterOnChangeCallback(). + * - Possibly register a custom storage area using ::OrthancPluginRegisterStorageArea2(). + * - Possibly register a custom database back-end area using OrthancPluginRegisterDatabaseBackendV4(). + * - Possibly register a handler for C-Find SCP using OrthancPluginRegisterFindCallback(). + * - Possibly register a handler for C-Find SCP against DICOM worklists using OrthancPluginRegisterWorklistCallback(). + * - Possibly register a handler for C-Move SCP using OrthancPluginRegisterMoveCallback(). + * - Possibly register a custom decoder for DICOM images using OrthancPluginRegisterDecodeImageCallback(). + * - Possibly register a callback to filter incoming HTTP requests using OrthancPluginRegisterIncomingHttpRequestFilter2(). + * - Possibly register a callback to unserialize jobs using OrthancPluginRegisterJobsUnserializer(). + * - Possibly register a callback to refresh its metrics using OrthancPluginRegisterRefreshMetricsCallback(). + * - Possibly register a callback to answer chunked HTTP transfers using ::OrthancPluginRegisterChunkedRestCallback(). + * - Possibly register a callback for Storage Commitment SCP using ::OrthancPluginRegisterStorageCommitmentScpCallback(). + * - Possibly register a callback to keep/discard/modify incoming DICOM instances using OrthancPluginRegisterReceivedInstanceCallback(). + * - Possibly register a custom transcoder for DICOM images using OrthancPluginRegisterTranscoderCallback(). + * - Possibly register a callback to discard instances received through DICOM C-STORE using OrthancPluginRegisterIncomingCStoreInstanceFilter(). + * - Possibly register a callback to branch a WebDAV virtual filesystem using OrthancPluginRegisterWebDavCollection(). + * -# void OrthancPluginFinalize(): + * This function is invoked by Orthanc during its shutdown. The plugin + * must free all its memory. + * -# const char* OrthancPluginGetName(): + * The plugin must return a short string to identify itself. + * -# const char* OrthancPluginGetVersion(): + * The plugin must return a string containing its version number. + * + * The name and the version of a plugin is only used to prevent it + * from being loaded twice. Note that, in C++, it is mandatory to + * declare these functions within an extern "C" section. + * + * To ensure multi-threading safety, the various REST callbacks are + * guaranteed to be executed in mutual exclusion since Orthanc + * 0.8.5. If this feature is undesired (notably when developing + * high-performance plugins handling simultaneous requests), use + * ::OrthancPluginRegisterRestCallbackNoLock(). + **/ + + + +/** + * @defgroup Images Images and compression + * @brief Functions to deal with images and compressed buffers. + * + * @defgroup REST REST + * @brief Functions to answer REST requests in a callback. + * + * @defgroup Callbacks Callbacks + * @brief Functions to register and manage callbacks by the plugins. + * + * @defgroup DicomCallbacks DicomCallbacks + * @brief Functions to register and manage DICOM callbacks (worklists, C-FIND, C-MOVE, storage commitment). + * + * @defgroup Orthanc Orthanc + * @brief Functions to access the content of the Orthanc server. + * + * @defgroup DicomInstance DicomInstance + * @brief Functions to access DICOM images that are managed by the Orthanc core. + **/ + + + +/** + * @defgroup Toolbox Toolbox + * @brief Generic functions to help with the creation of plugins. + **/ + + + +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2023 Osimis S.A., Belgium + * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium + * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + + +#pragma once + + +#include +#include + +#ifdef _WIN32 +# define ORTHANC_PLUGINS_API __declspec(dllexport) +#elif __GNUC__ >= 4 +# define ORTHANC_PLUGINS_API __attribute__ ((visibility ("default"))) +#else +# define ORTHANC_PLUGINS_API +#endif + +#define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 1 +#define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 12 +#define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 6 + + +#if !defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) +#define ORTHANC_PLUGINS_VERSION_IS_ABOVE(major, minor, revision) \ + (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER > major || \ + (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == major && \ + (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER > minor || \ + (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER == minor && \ + ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER >= revision)))) +#endif + + + +/******************************************************************** + ** Check that function inlining is properly supported. The use of + ** inlining is required, to avoid the duplication of object code + ** between two compilation modules that would use the Orthanc Plugin + ** API. + ********************************************************************/ + +/* If the auto-detection of the "inline" keyword below does not work + automatically and that your compiler is known to properly support + inlining, uncomment the following #define and adapt the definition + of "static inline". */ + +/* #define ORTHANC_PLUGIN_INLINE static inline */ + +#ifndef ORTHANC_PLUGIN_INLINE +# if __STDC_VERSION__ >= 199901L +/* This is C99 or above: http://predef.sourceforge.net/prestd.html */ +# define ORTHANC_PLUGIN_INLINE static inline +# elif defined(__cplusplus) +/* This is C++ */ +# define ORTHANC_PLUGIN_INLINE static inline +# elif defined(__GNUC__) +/* This is GCC running in C89 mode */ +# define ORTHANC_PLUGIN_INLINE static __inline +# elif defined(_MSC_VER) +/* This is Visual Studio running in C89 mode */ +# define ORTHANC_PLUGIN_INLINE static __inline +# else +# error Your compiler is not known to support the "inline" keyword +# endif +#endif + + +#ifndef ORTHANC_PLUGIN_DEPRECATED +# if defined(_MSC_VER) +# define ORTHANC_PLUGIN_DEPRECATED __declspec(deprecated) +# elif __GNUC__ >= 4 +# define ORTHANC_PLUGIN_DEPRECATED __attribute__ ((deprecated)) +# elif defined(__clang__) +# define ORTHANC_PLUGIN_DEPRECATED __attribute__ ((deprecated)) +# else +# pragma message("WARNING: You need to implement ORTHANC_PLUGINS_DEPRECATED for this compiler") +# define ORTHANC_PLUGIN_DEPRECATED +# endif +#endif + + + +/******************************************************************** + ** Inclusion of standard libraries. + ********************************************************************/ + +/** + * For Microsoft Visual Studio, a compatibility "stdint.h" can be + * downloaded at the following URL: + * https://orthanc.uclouvain.be/hg/orthanc/raw-file/default/OrthancFramework/Resources/ThirdParty/VisualStudio/stdint.h + **/ +#include + +#include + + + +/******************************************************************** + ** Definition of the Orthanc Plugin API. + ********************************************************************/ + +/** @{ */ + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * The various error codes that can be returned by the Orthanc core. + **/ + typedef enum + { + OrthancPluginErrorCode_InternalError = -1 /*!< Internal error */, + OrthancPluginErrorCode_Success = 0 /*!< Success */, + OrthancPluginErrorCode_Plugin = 1 /*!< Error encountered within the plugin engine */, + OrthancPluginErrorCode_NotImplemented = 2 /*!< Not implemented yet */, + OrthancPluginErrorCode_ParameterOutOfRange = 3 /*!< Parameter out of range */, + OrthancPluginErrorCode_NotEnoughMemory = 4 /*!< The server hosting Orthanc is running out of memory */, + OrthancPluginErrorCode_BadParameterType = 5 /*!< Bad type for a parameter */, + OrthancPluginErrorCode_BadSequenceOfCalls = 6 /*!< Bad sequence of calls */, + OrthancPluginErrorCode_InexistentItem = 7 /*!< Accessing an inexistent item */, + OrthancPluginErrorCode_BadRequest = 8 /*!< Bad request */, + OrthancPluginErrorCode_NetworkProtocol = 9 /*!< Error in the network protocol */, + OrthancPluginErrorCode_SystemCommand = 10 /*!< Error while calling a system command */, + OrthancPluginErrorCode_Database = 11 /*!< Error with the database engine */, + OrthancPluginErrorCode_UriSyntax = 12 /*!< Badly formatted URI */, + OrthancPluginErrorCode_InexistentFile = 13 /*!< Inexistent file */, + OrthancPluginErrorCode_CannotWriteFile = 14 /*!< Cannot write to file */, + OrthancPluginErrorCode_BadFileFormat = 15 /*!< Bad file format */, + OrthancPluginErrorCode_Timeout = 16 /*!< Timeout */, + OrthancPluginErrorCode_UnknownResource = 17 /*!< Unknown resource */, + OrthancPluginErrorCode_IncompatibleDatabaseVersion = 18 /*!< Incompatible version of the database */, + OrthancPluginErrorCode_FullStorage = 19 /*!< The file storage is full */, + OrthancPluginErrorCode_CorruptedFile = 20 /*!< Corrupted file (e.g. inconsistent MD5 hash) */, + OrthancPluginErrorCode_InexistentTag = 21 /*!< Inexistent tag */, + OrthancPluginErrorCode_ReadOnly = 22 /*!< Cannot modify a read-only data structure */, + OrthancPluginErrorCode_IncompatibleImageFormat = 23 /*!< Incompatible format of the images */, + OrthancPluginErrorCode_IncompatibleImageSize = 24 /*!< Incompatible size of the images */, + OrthancPluginErrorCode_SharedLibrary = 25 /*!< Error while using a shared library (plugin) */, + OrthancPluginErrorCode_UnknownPluginService = 26 /*!< Plugin invoking an unknown service */, + OrthancPluginErrorCode_UnknownDicomTag = 27 /*!< Unknown DICOM tag */, + OrthancPluginErrorCode_BadJson = 28 /*!< Cannot parse a JSON document */, + OrthancPluginErrorCode_Unauthorized = 29 /*!< Bad credentials were provided to an HTTP request */, + OrthancPluginErrorCode_BadFont = 30 /*!< Badly formatted font file */, + OrthancPluginErrorCode_DatabasePlugin = 31 /*!< The plugin implementing a custom database back-end does not fulfill the proper interface */, + OrthancPluginErrorCode_StorageAreaPlugin = 32 /*!< Error in the plugin implementing a custom storage area */, + OrthancPluginErrorCode_EmptyRequest = 33 /*!< The request is empty */, + OrthancPluginErrorCode_NotAcceptable = 34 /*!< Cannot send a response which is acceptable according to the Accept HTTP header */, + OrthancPluginErrorCode_NullPointer = 35 /*!< Cannot handle a NULL pointer */, + OrthancPluginErrorCode_DatabaseUnavailable = 36 /*!< The database is currently not available (probably a transient situation) */, + OrthancPluginErrorCode_CanceledJob = 37 /*!< This job was canceled */, + OrthancPluginErrorCode_BadGeometry = 38 /*!< Geometry error encountered in Stone */, + OrthancPluginErrorCode_SslInitialization = 39 /*!< Cannot initialize SSL encryption, check out your certificates */, + OrthancPluginErrorCode_DiscontinuedAbi = 40 /*!< Calling a function that has been removed from the Orthanc Framework */, + OrthancPluginErrorCode_BadRange = 41 /*!< Incorrect range request */, + OrthancPluginErrorCode_DatabaseCannotSerialize = 42 /*!< Database could not serialize access due to concurrent update, the transaction should be retried */, + OrthancPluginErrorCode_Revision = 43 /*!< A bad revision number was provided, which might indicate conflict between multiple writers */, + OrthancPluginErrorCode_MainDicomTagsMultiplyDefined = 44 /*!< A main DICOM Tag has been defined multiple times for the same resource level */, + OrthancPluginErrorCode_ForbiddenAccess = 45 /*!< Access to a resource is forbidden */, + OrthancPluginErrorCode_DuplicateResource = 46 /*!< Duplicate resource */, + OrthancPluginErrorCode_IncompatibleConfigurations = 47 /*!< Your configuration file contains configuration that are mutually incompatible */, + OrthancPluginErrorCode_SQLiteNotOpened = 1000 /*!< SQLite: The database is not opened */, + OrthancPluginErrorCode_SQLiteAlreadyOpened = 1001 /*!< SQLite: Connection is already open */, + OrthancPluginErrorCode_SQLiteCannotOpen = 1002 /*!< SQLite: Unable to open the database */, + OrthancPluginErrorCode_SQLiteStatementAlreadyUsed = 1003 /*!< SQLite: This cached statement is already being referred to */, + OrthancPluginErrorCode_SQLiteExecute = 1004 /*!< SQLite: Cannot execute a command */, + OrthancPluginErrorCode_SQLiteRollbackWithoutTransaction = 1005 /*!< SQLite: Rolling back a nonexistent transaction (have you called Begin()?) */, + OrthancPluginErrorCode_SQLiteCommitWithoutTransaction = 1006 /*!< SQLite: Committing a nonexistent transaction */, + OrthancPluginErrorCode_SQLiteRegisterFunction = 1007 /*!< SQLite: Unable to register a function */, + OrthancPluginErrorCode_SQLiteFlush = 1008 /*!< SQLite: Unable to flush the database */, + OrthancPluginErrorCode_SQLiteCannotRun = 1009 /*!< SQLite: Cannot run a cached statement */, + OrthancPluginErrorCode_SQLiteCannotStep = 1010 /*!< SQLite: Cannot step over a cached statement */, + OrthancPluginErrorCode_SQLiteBindOutOfRange = 1011 /*!< SQLite: Bind a value while out of range (serious error) */, + OrthancPluginErrorCode_SQLitePrepareStatement = 1012 /*!< SQLite: Cannot prepare a cached statement */, + OrthancPluginErrorCode_SQLiteTransactionAlreadyStarted = 1013 /*!< SQLite: Beginning the same transaction twice */, + OrthancPluginErrorCode_SQLiteTransactionCommit = 1014 /*!< SQLite: Failure when committing the transaction */, + OrthancPluginErrorCode_SQLiteTransactionBegin = 1015 /*!< SQLite: Cannot start a transaction */, + OrthancPluginErrorCode_DirectoryOverFile = 2000 /*!< The directory to be created is already occupied by a regular file */, + OrthancPluginErrorCode_FileStorageCannotWrite = 2001 /*!< Unable to create a subdirectory or a file in the file storage */, + OrthancPluginErrorCode_DirectoryExpected = 2002 /*!< The specified path does not point to a directory */, + OrthancPluginErrorCode_HttpPortInUse = 2003 /*!< The TCP port of the HTTP server is privileged or already in use */, + OrthancPluginErrorCode_DicomPortInUse = 2004 /*!< The TCP port of the DICOM server is privileged or already in use */, + OrthancPluginErrorCode_BadHttpStatusInRest = 2005 /*!< This HTTP status is not allowed in a REST API */, + OrthancPluginErrorCode_RegularFileExpected = 2006 /*!< The specified path does not point to a regular file */, + OrthancPluginErrorCode_PathToExecutable = 2007 /*!< Unable to get the path to the executable */, + OrthancPluginErrorCode_MakeDirectory = 2008 /*!< Cannot create a directory */, + OrthancPluginErrorCode_BadApplicationEntityTitle = 2009 /*!< An application entity title (AET) cannot be empty or be longer than 16 characters */, + OrthancPluginErrorCode_NoCFindHandler = 2010 /*!< No request handler factory for DICOM C-FIND SCP */, + OrthancPluginErrorCode_NoCMoveHandler = 2011 /*!< No request handler factory for DICOM C-MOVE SCP */, + OrthancPluginErrorCode_NoCStoreHandler = 2012 /*!< No request handler factory for DICOM C-STORE SCP */, + OrthancPluginErrorCode_NoApplicationEntityFilter = 2013 /*!< No application entity filter */, + OrthancPluginErrorCode_NoSopClassOrInstance = 2014 /*!< DicomUserConnection: Unable to find the SOP class and instance */, + OrthancPluginErrorCode_NoPresentationContext = 2015 /*!< DicomUserConnection: No acceptable presentation context for modality */, + OrthancPluginErrorCode_DicomFindUnavailable = 2016 /*!< DicomUserConnection: The C-FIND command is not supported by the remote SCP */, + OrthancPluginErrorCode_DicomMoveUnavailable = 2017 /*!< DicomUserConnection: The C-MOVE command is not supported by the remote SCP */, + OrthancPluginErrorCode_CannotStoreInstance = 2018 /*!< Cannot store an instance */, + OrthancPluginErrorCode_CreateDicomNotString = 2019 /*!< Only string values are supported when creating DICOM instances */, + OrthancPluginErrorCode_CreateDicomOverrideTag = 2020 /*!< Trying to override a value inherited from a parent module */, + OrthancPluginErrorCode_CreateDicomUseContent = 2021 /*!< Use \"Content\" to inject an image into a new DICOM instance */, + OrthancPluginErrorCode_CreateDicomNoPayload = 2022 /*!< No payload is present for one instance in the series */, + OrthancPluginErrorCode_CreateDicomUseDataUriScheme = 2023 /*!< The payload of the DICOM instance must be specified according to Data URI scheme */, + OrthancPluginErrorCode_CreateDicomBadParent = 2024 /*!< Trying to attach a new DICOM instance to an inexistent resource */, + OrthancPluginErrorCode_CreateDicomParentIsInstance = 2025 /*!< Trying to attach a new DICOM instance to an instance (must be a series, study or patient) */, + OrthancPluginErrorCode_CreateDicomParentEncoding = 2026 /*!< Unable to get the encoding of the parent resource */, + OrthancPluginErrorCode_UnknownModality = 2027 /*!< Unknown modality */, + OrthancPluginErrorCode_BadJobOrdering = 2028 /*!< Bad ordering of filters in a job */, + OrthancPluginErrorCode_JsonToLuaTable = 2029 /*!< Cannot convert the given JSON object to a Lua table */, + OrthancPluginErrorCode_CannotCreateLua = 2030 /*!< Cannot create the Lua context */, + OrthancPluginErrorCode_CannotExecuteLua = 2031 /*!< Cannot execute a Lua command */, + OrthancPluginErrorCode_LuaAlreadyExecuted = 2032 /*!< Arguments cannot be pushed after the Lua function is executed */, + OrthancPluginErrorCode_LuaBadOutput = 2033 /*!< The Lua function does not give the expected number of outputs */, + OrthancPluginErrorCode_NotLuaPredicate = 2034 /*!< The Lua function is not a predicate (only true/false outputs allowed) */, + OrthancPluginErrorCode_LuaReturnsNoString = 2035 /*!< The Lua function does not return a string */, + OrthancPluginErrorCode_StorageAreaAlreadyRegistered = 2036 /*!< Another plugin has already registered a custom storage area */, + OrthancPluginErrorCode_DatabaseBackendAlreadyRegistered = 2037 /*!< Another plugin has already registered a custom database back-end */, + OrthancPluginErrorCode_DatabaseNotInitialized = 2038 /*!< Plugin trying to call the database during its initialization */, + OrthancPluginErrorCode_SslDisabled = 2039 /*!< Orthanc has been built without SSL support */, + OrthancPluginErrorCode_CannotOrderSlices = 2040 /*!< Unable to order the slices of the series */, + OrthancPluginErrorCode_NoWorklistHandler = 2041 /*!< No request handler factory for DICOM C-Find Modality SCP */, + OrthancPluginErrorCode_AlreadyExistingTag = 2042 /*!< Cannot override the value of a tag that already exists */, + OrthancPluginErrorCode_NoStorageCommitmentHandler = 2043 /*!< No request handler factory for DICOM N-ACTION SCP (storage commitment) */, + OrthancPluginErrorCode_NoCGetHandler = 2044 /*!< No request handler factory for DICOM C-GET SCP */, + OrthancPluginErrorCode_DicomGetUnavailable = 2045 /*!< DicomUserConnection: The C-GET command is not supported by the remote SCP */, + OrthancPluginErrorCode_UnsupportedMediaType = 3000 /*!< Unsupported media type */, + + _OrthancPluginErrorCode_INTERNAL = 0x7fffffff + } OrthancPluginErrorCode; + + + /** + * Forward declaration of one of the mandatory functions for Orthanc + * plugins. + **/ + ORTHANC_PLUGINS_API const char* OrthancPluginGetName(); + + + /** + * The various HTTP methods for a REST call. + **/ + typedef enum + { + OrthancPluginHttpMethod_Get = 1, /*!< GET request */ + OrthancPluginHttpMethod_Post = 2, /*!< POST request */ + OrthancPluginHttpMethod_Put = 3, /*!< PUT request */ + OrthancPluginHttpMethod_Delete = 4, /*!< DELETE request */ + + _OrthancPluginHttpMethod_INTERNAL = 0x7fffffff + } OrthancPluginHttpMethod; + + + /** + * @brief The parameters of a REST request. + * @ingroup Callbacks + **/ + typedef struct + { + /** + * @brief The HTTP method. + **/ + OrthancPluginHttpMethod method; + + /** + * @brief The number of groups of the regular expression. + **/ + uint32_t groupsCount; + + /** + * @brief The matched values for the groups of the regular expression. + **/ + const char* const* groups; + + /** + * @brief For a GET request, the number of GET parameters. + **/ + uint32_t getCount; + + /** + * @brief For a GET request, the keys of the GET parameters. + **/ + const char* const* getKeys; + + /** + * @brief For a GET request, the values of the GET parameters. + **/ + const char* const* getValues; + + /** + * @brief For a PUT or POST request, the content of the body. + **/ + const void* body; + + /** + * @brief For a PUT or POST request, the number of bytes of the body. + **/ + uint32_t bodySize; + + + /* -------------------------------------------------- + New in version 0.8.1 + -------------------------------------------------- */ + + /** + * @brief The number of HTTP headers. + **/ + uint32_t headersCount; + + /** + * @brief The keys of the HTTP headers (always converted to low-case). + **/ + const char* const* headersKeys; + + /** + * @brief The values of the HTTP headers. + **/ + const char* const* headersValues; + + } OrthancPluginHttpRequest; + + + typedef enum + { + /* Generic services */ + _OrthancPluginService_LogInfo = 1, + _OrthancPluginService_LogWarning = 2, + _OrthancPluginService_LogError = 3, + _OrthancPluginService_GetOrthancPath = 4, + _OrthancPluginService_GetOrthancDirectory = 5, + _OrthancPluginService_GetConfigurationPath = 6, + _OrthancPluginService_SetPluginProperty = 7, + _OrthancPluginService_GetGlobalProperty = 8, + _OrthancPluginService_SetGlobalProperty = 9, + _OrthancPluginService_GetCommandLineArgumentsCount = 10, + _OrthancPluginService_GetCommandLineArgument = 11, + _OrthancPluginService_GetExpectedDatabaseVersion = 12, + _OrthancPluginService_GetConfiguration = 13, + _OrthancPluginService_BufferCompression = 14, + _OrthancPluginService_ReadFile = 15, + _OrthancPluginService_WriteFile = 16, + _OrthancPluginService_GetErrorDescription = 17, + _OrthancPluginService_CallHttpClient = 18, + _OrthancPluginService_RegisterErrorCode = 19, + _OrthancPluginService_RegisterDictionaryTag = 20, + _OrthancPluginService_DicomBufferToJson = 21, + _OrthancPluginService_DicomInstanceToJson = 22, + _OrthancPluginService_CreateDicom = 23, + _OrthancPluginService_ComputeMd5 = 24, + _OrthancPluginService_ComputeSha1 = 25, + _OrthancPluginService_LookupDictionary = 26, + _OrthancPluginService_CallHttpClient2 = 27, + _OrthancPluginService_GenerateUuid = 28, + _OrthancPluginService_RegisterPrivateDictionaryTag = 29, + _OrthancPluginService_AutodetectMimeType = 30, + _OrthancPluginService_SetMetricsValue = 31, + _OrthancPluginService_EncodeDicomWebJson = 32, + _OrthancPluginService_EncodeDicomWebXml = 33, + _OrthancPluginService_ChunkedHttpClient = 34, /* New in Orthanc 1.5.7 */ + _OrthancPluginService_GetTagName = 35, /* New in Orthanc 1.5.7 */ + _OrthancPluginService_EncodeDicomWebJson2 = 36, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_EncodeDicomWebXml2 = 37, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_CreateMemoryBuffer = 38, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GenerateRestApiAuthorizationToken = 39, /* New in Orthanc 1.8.1 */ + _OrthancPluginService_CreateMemoryBuffer64 = 40, /* New in Orthanc 1.9.0 */ + _OrthancPluginService_CreateDicom2 = 41, /* New in Orthanc 1.9.0 */ + _OrthancPluginService_GetDatabaseServerIdentifier = 42, /* New in Orthanc 1.11.1 */ + _OrthancPluginService_SetMetricsIntegerValue = 43, /* New in Orthanc 1.12.1 */ + _OrthancPluginService_SetCurrentThreadName = 44, /* New in Orthanc 1.12.2 */ + _OrthancPluginService_LogMessage = 45, /* New in Orthanc 1.12.4 */ + + + /* Registration of callbacks */ + _OrthancPluginService_RegisterRestCallback = 1000, + _OrthancPluginService_RegisterOnStoredInstanceCallback = 1001, + _OrthancPluginService_RegisterStorageArea = 1002, + _OrthancPluginService_RegisterOnChangeCallback = 1003, + _OrthancPluginService_RegisterRestCallbackNoLock = 1004, + _OrthancPluginService_RegisterWorklistCallback = 1005, + _OrthancPluginService_RegisterDecodeImageCallback = 1006, + _OrthancPluginService_RegisterIncomingHttpRequestFilter = 1007, + _OrthancPluginService_RegisterFindCallback = 1008, + _OrthancPluginService_RegisterMoveCallback = 1009, + _OrthancPluginService_RegisterIncomingHttpRequestFilter2 = 1010, + _OrthancPluginService_RegisterRefreshMetricsCallback = 1011, + _OrthancPluginService_RegisterChunkedRestCallback = 1012, /* New in Orthanc 1.5.7 */ + _OrthancPluginService_RegisterStorageCommitmentScpCallback = 1013, + _OrthancPluginService_RegisterIncomingDicomInstanceFilter = 1014, + _OrthancPluginService_RegisterTranscoderCallback = 1015, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_RegisterStorageArea2 = 1016, /* New in Orthanc 1.9.0 */ + _OrthancPluginService_RegisterIncomingCStoreInstanceFilter = 1017, /* New in Orthanc 1.10.0 */ + _OrthancPluginService_RegisterReceivedInstanceCallback = 1018, /* New in Orthanc 1.10.0 */ + _OrthancPluginService_RegisterWebDavCollection = 1019, /* New in Orthanc 1.10.1 */ + + /* Sending answers to REST calls */ + _OrthancPluginService_AnswerBuffer = 2000, + _OrthancPluginService_CompressAndAnswerPngImage = 2001, /* Unused as of Orthanc 0.9.4 */ + _OrthancPluginService_Redirect = 2002, + _OrthancPluginService_SendHttpStatusCode = 2003, + _OrthancPluginService_SendUnauthorized = 2004, + _OrthancPluginService_SendMethodNotAllowed = 2005, + _OrthancPluginService_SetCookie = 2006, + _OrthancPluginService_SetHttpHeader = 2007, + _OrthancPluginService_StartMultipartAnswer = 2008, + _OrthancPluginService_SendMultipartItem = 2009, + _OrthancPluginService_SendHttpStatus = 2010, + _OrthancPluginService_CompressAndAnswerImage = 2011, + _OrthancPluginService_SendMultipartItem2 = 2012, + _OrthancPluginService_SetHttpErrorDetails = 2013, + _OrthancPluginService_StartStreamAnswer = 2014, + _OrthancPluginService_SendStreamChunk = 2015, + + /* Access to the Orthanc database and API */ + _OrthancPluginService_GetDicomForInstance = 3000, + _OrthancPluginService_RestApiGet = 3001, + _OrthancPluginService_RestApiPost = 3002, + _OrthancPluginService_RestApiDelete = 3003, + _OrthancPluginService_RestApiPut = 3004, + _OrthancPluginService_LookupPatient = 3005, + _OrthancPluginService_LookupStudy = 3006, + _OrthancPluginService_LookupSeries = 3007, + _OrthancPluginService_LookupInstance = 3008, + _OrthancPluginService_LookupStudyWithAccessionNumber = 3009, + _OrthancPluginService_RestApiGetAfterPlugins = 3010, + _OrthancPluginService_RestApiPostAfterPlugins = 3011, + _OrthancPluginService_RestApiDeleteAfterPlugins = 3012, + _OrthancPluginService_RestApiPutAfterPlugins = 3013, + _OrthancPluginService_ReconstructMainDicomTags = 3014, + _OrthancPluginService_RestApiGet2 = 3015, + _OrthancPluginService_CallRestApi = 3016, /* New in Orthanc 1.9.2 */ + + /* Access to DICOM instances */ + _OrthancPluginService_GetInstanceRemoteAet = 4000, + _OrthancPluginService_GetInstanceSize = 4001, + _OrthancPluginService_GetInstanceData = 4002, + _OrthancPluginService_GetInstanceJson = 4003, + _OrthancPluginService_GetInstanceSimplifiedJson = 4004, + _OrthancPluginService_HasInstanceMetadata = 4005, + _OrthancPluginService_GetInstanceMetadata = 4006, + _OrthancPluginService_GetInstanceOrigin = 4007, + _OrthancPluginService_GetInstanceTransferSyntaxUid = 4008, + _OrthancPluginService_HasInstancePixelData = 4009, + _OrthancPluginService_CreateDicomInstance = 4010, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_FreeDicomInstance = 4011, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceFramesCount = 4012, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceRawFrame = 4013, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceDecodedFrame = 4014, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_TranscodeDicomInstance = 4015, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_SerializeDicomInstance = 4016, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceAdvancedJson = 4017, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceDicomWebJson = 4018, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceDicomWebXml = 4019, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_LoadDicomInstance = 4020, /* New in Orthanc 1.12.1 */ + + /* Services for plugins implementing a database back-end */ + _OrthancPluginService_RegisterDatabaseBackend = 5000, /* New in Orthanc 0.8.6 */ + _OrthancPluginService_DatabaseAnswer = 5001, + _OrthancPluginService_RegisterDatabaseBackendV2 = 5002, /* New in Orthanc 0.9.4 */ + _OrthancPluginService_StorageAreaCreate = 5003, + _OrthancPluginService_StorageAreaRead = 5004, + _OrthancPluginService_StorageAreaRemove = 5005, + _OrthancPluginService_RegisterDatabaseBackendV3 = 5006, /* New in Orthanc 1.9.2 */ + _OrthancPluginService_RegisterDatabaseBackendV4 = 5007, /* New in Orthanc 1.12.0 */ + + /* Primitives for handling images */ + _OrthancPluginService_GetImagePixelFormat = 6000, + _OrthancPluginService_GetImageWidth = 6001, + _OrthancPluginService_GetImageHeight = 6002, + _OrthancPluginService_GetImagePitch = 6003, + _OrthancPluginService_GetImageBuffer = 6004, + _OrthancPluginService_UncompressImage = 6005, + _OrthancPluginService_FreeImage = 6006, + _OrthancPluginService_CompressImage = 6007, + _OrthancPluginService_ConvertPixelFormat = 6008, + _OrthancPluginService_GetFontsCount = 6009, + _OrthancPluginService_GetFontInfo = 6010, + _OrthancPluginService_DrawText = 6011, + _OrthancPluginService_CreateImage = 6012, + _OrthancPluginService_CreateImageAccessor = 6013, + _OrthancPluginService_DecodeDicomImage = 6014, + + /* Primitives for handling C-Find, C-Move and worklists */ + _OrthancPluginService_WorklistAddAnswer = 7000, + _OrthancPluginService_WorklistMarkIncomplete = 7001, + _OrthancPluginService_WorklistIsMatch = 7002, + _OrthancPluginService_WorklistGetDicomQuery = 7003, + _OrthancPluginService_FindAddAnswer = 7004, + _OrthancPluginService_FindMarkIncomplete = 7005, + _OrthancPluginService_GetFindQuerySize = 7006, + _OrthancPluginService_GetFindQueryTag = 7007, + _OrthancPluginService_GetFindQueryTagName = 7008, + _OrthancPluginService_GetFindQueryValue = 7009, + _OrthancPluginService_CreateFindMatcher = 7010, + _OrthancPluginService_FreeFindMatcher = 7011, + _OrthancPluginService_FindMatcherIsMatch = 7012, + + /* Primitives for accessing Orthanc Peers (new in 1.4.2) */ + _OrthancPluginService_GetPeers = 8000, + _OrthancPluginService_FreePeers = 8001, + _OrthancPluginService_GetPeersCount = 8003, + _OrthancPluginService_GetPeerName = 8004, + _OrthancPluginService_GetPeerUrl = 8005, + _OrthancPluginService_CallPeerApi = 8006, + _OrthancPluginService_GetPeerUserProperty = 8007, + + /* Primitives for handling jobs (new in 1.4.2) */ + _OrthancPluginService_CreateJob = 9000, /* Deprecated since SDK 1.11.3 */ + _OrthancPluginService_FreeJob = 9001, + _OrthancPluginService_SubmitJob = 9002, + _OrthancPluginService_RegisterJobsUnserializer = 9003, + _OrthancPluginService_CreateJob2 = 9004, /* New in SDK 1.11.3 */ + + _OrthancPluginService_INTERNAL = 0x7fffffff + } _OrthancPluginService; + + + typedef enum + { + _OrthancPluginProperty_Description = 1, + _OrthancPluginProperty_RootUri = 2, + _OrthancPluginProperty_OrthancExplorer = 3, + + _OrthancPluginProperty_INTERNAL = 0x7fffffff + } _OrthancPluginProperty; + + + + /** + * The memory layout of the pixels of an image. + * @ingroup Images + **/ + typedef enum + { + /** + * @brief Graylevel 8bpp image. + * + * The image is graylevel. Each pixel is unsigned and stored in + * one byte. + **/ + OrthancPluginPixelFormat_Grayscale8 = 1, + + /** + * @brief Graylevel, unsigned 16bpp image. + * + * The image is graylevel. Each pixel is unsigned and stored in + * two bytes. + **/ + OrthancPluginPixelFormat_Grayscale16 = 2, + + /** + * @brief Graylevel, signed 16bpp image. + * + * The image is graylevel. Each pixel is signed and stored in two + * bytes. + **/ + OrthancPluginPixelFormat_SignedGrayscale16 = 3, + + /** + * @brief Color image in RGB24 format. + * + * This format describes a color image. The pixels are stored in 3 + * consecutive bytes. The memory layout is RGB. + **/ + OrthancPluginPixelFormat_RGB24 = 4, + + /** + * @brief Color image in RGBA32 format. + * + * This format describes a color image. The pixels are stored in 4 + * consecutive bytes. The memory layout is RGBA. + **/ + OrthancPluginPixelFormat_RGBA32 = 5, + + OrthancPluginPixelFormat_Unknown = 6, /*!< Unknown pixel format */ + + /** + * @brief Color image in RGB48 format. + * + * This format describes a color image. The pixels are stored in 6 + * consecutive bytes. The memory layout is RRGGBB. + **/ + OrthancPluginPixelFormat_RGB48 = 7, + + /** + * @brief Graylevel, unsigned 32bpp image. + * + * The image is graylevel. Each pixel is unsigned and stored in + * four bytes. + **/ + OrthancPluginPixelFormat_Grayscale32 = 8, + + /** + * @brief Graylevel, floating-point 32bpp image. + * + * The image is graylevel. Each pixel is floating-point and stored + * in four bytes. + **/ + OrthancPluginPixelFormat_Float32 = 9, + + /** + * @brief Color image in BGRA32 format. + * + * This format describes a color image. The pixels are stored in 4 + * consecutive bytes. The memory layout is BGRA. + **/ + OrthancPluginPixelFormat_BGRA32 = 10, + + /** + * @brief Graylevel, unsigned 64bpp image. + * + * The image is graylevel. Each pixel is unsigned and stored in + * eight bytes. + **/ + OrthancPluginPixelFormat_Grayscale64 = 11, + + _OrthancPluginPixelFormat_INTERNAL = 0x7fffffff + } OrthancPluginPixelFormat; + + + + /** + * The content types that are supported by Orthanc plugins. + **/ + typedef enum + { + OrthancPluginContentType_Unknown = 0, /*!< Unknown content type */ + OrthancPluginContentType_Dicom = 1, /*!< DICOM */ + OrthancPluginContentType_DicomAsJson = 2, /*!< JSON summary of a DICOM file */ + OrthancPluginContentType_DicomUntilPixelData = 3, /*!< DICOM Header till pixel data */ + + _OrthancPluginContentType_INTERNAL = 0x7fffffff + } OrthancPluginContentType; + + + + /** + * The supported types of DICOM resources. + **/ + typedef enum + { + OrthancPluginResourceType_Patient = 0, /*!< Patient */ + OrthancPluginResourceType_Study = 1, /*!< Study */ + OrthancPluginResourceType_Series = 2, /*!< Series */ + OrthancPluginResourceType_Instance = 3, /*!< Instance */ + OrthancPluginResourceType_None = 4, /*!< Unavailable resource type */ + + _OrthancPluginResourceType_INTERNAL = 0x7fffffff + } OrthancPluginResourceType; + + + + /** + * The supported types of changes that can be signaled to the change callback. + * Note: this enum is not used to store changes in the DB ! + * @ingroup Callbacks + **/ + typedef enum + { + OrthancPluginChangeType_CompletedSeries = 0, /*!< Series is now complete */ + OrthancPluginChangeType_Deleted = 1, /*!< Deleted resource */ + OrthancPluginChangeType_NewChildInstance = 2, /*!< A new instance was added to this resource */ + OrthancPluginChangeType_NewInstance = 3, /*!< New instance received */ + OrthancPluginChangeType_NewPatient = 4, /*!< New patient created */ + OrthancPluginChangeType_NewSeries = 5, /*!< New series created */ + OrthancPluginChangeType_NewStudy = 6, /*!< New study created */ + OrthancPluginChangeType_StablePatient = 7, /*!< Timeout: No new instance in this patient */ + OrthancPluginChangeType_StableSeries = 8, /*!< Timeout: No new instance in this series */ + OrthancPluginChangeType_StableStudy = 9, /*!< Timeout: No new instance in this study */ + OrthancPluginChangeType_OrthancStarted = 10, /*!< Orthanc has started */ + OrthancPluginChangeType_OrthancStopped = 11, /*!< Orthanc is stopping */ + OrthancPluginChangeType_UpdatedAttachment = 12, /*!< Some user-defined attachment has changed for this resource */ + OrthancPluginChangeType_UpdatedMetadata = 13, /*!< Some user-defined metadata has changed for this resource */ + OrthancPluginChangeType_UpdatedPeers = 14, /*!< The list of Orthanc peers has changed */ + OrthancPluginChangeType_UpdatedModalities = 15, /*!< The list of DICOM modalities has changed */ + OrthancPluginChangeType_JobSubmitted = 16, /*!< New Job submitted */ + OrthancPluginChangeType_JobSuccess = 17, /*!< A Job has completed successfully */ + OrthancPluginChangeType_JobFailure = 18, /*!< A Job has failed */ + + _OrthancPluginChangeType_INTERNAL = 0x7fffffff + } OrthancPluginChangeType; + + + /** + * The compression algorithms that are supported by the Orthanc core. + * @ingroup Images + **/ + typedef enum + { + OrthancPluginCompressionType_Zlib = 0, /*!< Standard zlib compression */ + OrthancPluginCompressionType_ZlibWithSize = 1, /*!< zlib, prefixed with uncompressed size (uint64_t) */ + OrthancPluginCompressionType_Gzip = 2, /*!< Standard gzip compression */ + OrthancPluginCompressionType_GzipWithSize = 3, /*!< gzip, prefixed with uncompressed size (uint64_t) */ + + _OrthancPluginCompressionType_INTERNAL = 0x7fffffff + } OrthancPluginCompressionType; + + + /** + * The image formats that are supported by the Orthanc core. + * @ingroup Images + **/ + typedef enum + { + OrthancPluginImageFormat_Png = 0, /*!< Image compressed using PNG */ + OrthancPluginImageFormat_Jpeg = 1, /*!< Image compressed using JPEG */ + OrthancPluginImageFormat_Dicom = 2, /*!< Image compressed using DICOM */ + + _OrthancPluginImageFormat_INTERNAL = 0x7fffffff + } OrthancPluginImageFormat; + + + /** + * The value representations present in the DICOM standard (version 2013). + * @ingroup Toolbox + **/ + typedef enum + { + OrthancPluginValueRepresentation_AE = 1, /*!< Application Entity */ + OrthancPluginValueRepresentation_AS = 2, /*!< Age String */ + OrthancPluginValueRepresentation_AT = 3, /*!< Attribute Tag */ + OrthancPluginValueRepresentation_CS = 4, /*!< Code String */ + OrthancPluginValueRepresentation_DA = 5, /*!< Date */ + OrthancPluginValueRepresentation_DS = 6, /*!< Decimal String */ + OrthancPluginValueRepresentation_DT = 7, /*!< Date Time */ + OrthancPluginValueRepresentation_FD = 8, /*!< Floating Point Double */ + OrthancPluginValueRepresentation_FL = 9, /*!< Floating Point Single */ + OrthancPluginValueRepresentation_IS = 10, /*!< Integer String */ + OrthancPluginValueRepresentation_LO = 11, /*!< Long String */ + OrthancPluginValueRepresentation_LT = 12, /*!< Long Text */ + OrthancPluginValueRepresentation_OB = 13, /*!< Other Byte String */ + OrthancPluginValueRepresentation_OF = 14, /*!< Other Float String */ + OrthancPluginValueRepresentation_OW = 15, /*!< Other Word String */ + OrthancPluginValueRepresentation_PN = 16, /*!< Person Name */ + OrthancPluginValueRepresentation_SH = 17, /*!< Short String */ + OrthancPluginValueRepresentation_SL = 18, /*!< Signed Long */ + OrthancPluginValueRepresentation_SQ = 19, /*!< Sequence of Items */ + OrthancPluginValueRepresentation_SS = 20, /*!< Signed Short */ + OrthancPluginValueRepresentation_ST = 21, /*!< Short Text */ + OrthancPluginValueRepresentation_TM = 22, /*!< Time */ + OrthancPluginValueRepresentation_UI = 23, /*!< Unique Identifier (UID) */ + OrthancPluginValueRepresentation_UL = 24, /*!< Unsigned Long */ + OrthancPluginValueRepresentation_UN = 25, /*!< Unknown */ + OrthancPluginValueRepresentation_US = 26, /*!< Unsigned Short */ + OrthancPluginValueRepresentation_UT = 27, /*!< Unlimited Text */ + + _OrthancPluginValueRepresentation_INTERNAL = 0x7fffffff + } OrthancPluginValueRepresentation; + + + /** + * The possible output formats for a DICOM-to-JSON conversion. + * @ingroup Toolbox + * @see OrthancPluginDicomToJson() + **/ + typedef enum + { + OrthancPluginDicomToJsonFormat_Full = 1, /*!< Full output, with most details */ + OrthancPluginDicomToJsonFormat_Short = 2, /*!< Tags output as hexadecimal numbers */ + OrthancPluginDicomToJsonFormat_Human = 3, /*!< Human-readable JSON */ + + _OrthancPluginDicomToJsonFormat_INTERNAL = 0x7fffffff + } OrthancPluginDicomToJsonFormat; + + + /** + * Flags to customize a DICOM-to-JSON conversion. By default, binary + * tags are formatted using Data URI scheme. + * @ingroup Toolbox + **/ + typedef enum + { + OrthancPluginDicomToJsonFlags_None = 0, /*!< Default formatting */ + OrthancPluginDicomToJsonFlags_IncludeBinary = (1 << 0), /*!< Include the binary tags */ + OrthancPluginDicomToJsonFlags_IncludePrivateTags = (1 << 1), /*!< Include the private tags */ + OrthancPluginDicomToJsonFlags_IncludeUnknownTags = (1 << 2), /*!< Include the tags unknown by the dictionary */ + OrthancPluginDicomToJsonFlags_IncludePixelData = (1 << 3), /*!< Include the pixel data */ + OrthancPluginDicomToJsonFlags_ConvertBinaryToAscii = (1 << 4), /*!< Output binary tags as-is, dropping non-ASCII */ + OrthancPluginDicomToJsonFlags_ConvertBinaryToNull = (1 << 5), /*!< Signal binary tags as null values */ + OrthancPluginDicomToJsonFlags_StopAfterPixelData = (1 << 6), /*!< Stop processing after pixel data (new in 1.9.1) */ + OrthancPluginDicomToJsonFlags_SkipGroupLengths = (1 << 7), /*!< Skip tags whose element is zero (new in 1.9.1) */ + + _OrthancPluginDicomToJsonFlags_INTERNAL = 0x7fffffff + } OrthancPluginDicomToJsonFlags; + + + /** + * Flags for the creation of a DICOM file. + * @ingroup Toolbox + * @see OrthancPluginCreateDicom() + **/ + typedef enum + { + OrthancPluginCreateDicomFlags_None = 0, /*!< Default mode */ + OrthancPluginCreateDicomFlags_DecodeDataUriScheme = (1 << 0), /*!< Decode fields encoded using data URI scheme */ + OrthancPluginCreateDicomFlags_GenerateIdentifiers = (1 << 1), /*!< Automatically generate DICOM identifiers */ + + _OrthancPluginCreateDicomFlags_INTERNAL = 0x7fffffff + } OrthancPluginCreateDicomFlags; + + + /** + * The constraints on the DICOM identifiers that must be supported + * by the database plugins. + * @deprecated Plugins using OrthancPluginConstraintType will be faster + **/ + typedef enum + { + OrthancPluginIdentifierConstraint_Equal = 1, /*!< Equal */ + OrthancPluginIdentifierConstraint_SmallerOrEqual = 2, /*!< Less or equal */ + OrthancPluginIdentifierConstraint_GreaterOrEqual = 3, /*!< More or equal */ + OrthancPluginIdentifierConstraint_Wildcard = 4, /*!< Case-sensitive wildcard matching (with * and ?) */ + + _OrthancPluginIdentifierConstraint_INTERNAL = 0x7fffffff + } OrthancPluginIdentifierConstraint; + + + /** + * The constraints on the tags (main DICOM tags and identifier tags) + * that must be supported by the database plugins. + **/ + typedef enum + { + OrthancPluginConstraintType_Equal = 1, /*!< Equal */ + OrthancPluginConstraintType_SmallerOrEqual = 2, /*!< Less or equal */ + OrthancPluginConstraintType_GreaterOrEqual = 3, /*!< More or equal */ + OrthancPluginConstraintType_Wildcard = 4, /*!< Wildcard matching */ + OrthancPluginConstraintType_List = 5, /*!< List of values */ + + _OrthancPluginConstraintType_INTERNAL = 0x7fffffff + } OrthancPluginConstraintType; + + + /** + * The origin of a DICOM instance that has been received by Orthanc. + **/ + typedef enum + { + OrthancPluginInstanceOrigin_Unknown = 1, /*!< Unknown origin */ + OrthancPluginInstanceOrigin_DicomProtocol = 2, /*!< Instance received through DICOM protocol */ + OrthancPluginInstanceOrigin_RestApi = 3, /*!< Instance received through REST API of Orthanc */ + OrthancPluginInstanceOrigin_Plugin = 4, /*!< Instance added to Orthanc by a plugin */ + OrthancPluginInstanceOrigin_Lua = 5, /*!< Instance added to Orthanc by a Lua script */ + OrthancPluginInstanceOrigin_WebDav = 6, /*!< Instance received through WebDAV (new in 1.8.0) */ + + _OrthancPluginInstanceOrigin_INTERNAL = 0x7fffffff + } OrthancPluginInstanceOrigin; + + + /** + * The possible status for one single step of a job. + **/ + typedef enum + { + OrthancPluginJobStepStatus_Success = 1, /*!< The job has successfully executed all its steps */ + OrthancPluginJobStepStatus_Failure = 2, /*!< The job has failed while executing this step */ + OrthancPluginJobStepStatus_Continue = 3 /*!< The job has still data to process after this step */ + } OrthancPluginJobStepStatus; + + + /** + * Explains why the job should stop and release the resources it has + * allocated. This is especially important to disambiguate between + * the "paused" condition and the "final" conditions (success, + * failure, or canceled). + **/ + typedef enum + { + OrthancPluginJobStopReason_Success = 1, /*!< The job has succeeded */ + OrthancPluginJobStopReason_Paused = 2, /*!< The job was paused, and will be resumed later */ + OrthancPluginJobStopReason_Failure = 3, /*!< The job has failed, and might be resubmitted later */ + OrthancPluginJobStopReason_Canceled = 4 /*!< The job was canceled, and might be resubmitted later */ + } OrthancPluginJobStopReason; + + + /** + * The available types of metrics. + **/ + typedef enum + { + OrthancPluginMetricsType_Default = 0, /*!< Default metrics */ + + /** + * This metrics represents a time duration. Orthanc will keep the + * maximum value of the metrics over a sliding window of ten + * seconds, which is useful if the metrics is sampled frequently. + **/ + OrthancPluginMetricsType_Timer = 1 + } OrthancPluginMetricsType; + + + /** + * The available modes to export a binary DICOM tag into a DICOMweb + * JSON or XML document. + **/ + typedef enum + { + OrthancPluginDicomWebBinaryMode_Ignore = 0, /*!< Don't include binary tags */ + OrthancPluginDicomWebBinaryMode_InlineBinary = 1, /*!< Inline encoding using Base64 */ + OrthancPluginDicomWebBinaryMode_BulkDataUri = 2 /*!< Use a bulk data URI field */ + } OrthancPluginDicomWebBinaryMode; + + + /** + * The available values for the Failure Reason (0008,1197) during + * storage commitment. + * http://dicom.nema.org/medical/dicom/2019e/output/chtml/part03/sect_C.14.html#sect_C.14.1.1 + **/ + typedef enum + { + /** + * Success: The DICOM instance is properly stored in the SCP + **/ + OrthancPluginStorageCommitmentFailureReason_Success = 0, + + /** + * 0110H: A general failure in processing the operation was encountered + **/ + OrthancPluginStorageCommitmentFailureReason_ProcessingFailure = 1, + + /** + * 0112H: One or more of the elements in the Referenced SOP + * Instance Sequence was not available + **/ + OrthancPluginStorageCommitmentFailureReason_NoSuchObjectInstance = 2, + + /** + * 0213H: The SCP does not currently have enough resources to + * store the requested SOP Instance(s) + **/ + OrthancPluginStorageCommitmentFailureReason_ResourceLimitation = 3, + + /** + * 0122H: Storage Commitment has been requested for a SOP Instance + * with a SOP Class that is not supported by the SCP + **/ + OrthancPluginStorageCommitmentFailureReason_ReferencedSOPClassNotSupported = 4, + + /** + * 0119H: The SOP Class of an element in the Referenced SOP + * Instance Sequence did not correspond to the SOP class + * registered for this SOP Instance at the SCP + **/ + OrthancPluginStorageCommitmentFailureReason_ClassInstanceConflict = 5, + + /** + * 0131H: The Transaction UID of the Storage Commitment Request is + * already in use + **/ + OrthancPluginStorageCommitmentFailureReason_DuplicateTransactionUID = 6 + } OrthancPluginStorageCommitmentFailureReason; + + + /** + * The action to be taken after ReceivedInstanceCallback is triggered + **/ + typedef enum + { + OrthancPluginReceivedInstanceAction_KeepAsIs = 1, /*!< Keep the instance as is */ + OrthancPluginReceivedInstanceAction_Modify = 2, /*!< Modify the instance */ + OrthancPluginReceivedInstanceAction_Discard = 3, /*!< Discard the instance */ + + _OrthancPluginReceivedInstanceAction_INTERNAL = 0x7fffffff + } OrthancPluginReceivedInstanceAction; + + + /** + * Mode specifying how to load a DICOM instance. + * @see OrthancPluginLoadDicomInstance() + **/ + typedef enum + { + /** + * Load the whole DICOM file, including pixel data + **/ + OrthancPluginLoadDicomInstanceMode_WholeDicom = 1, + + /** + * Load the whole DICOM file until pixel data, which speeds up the + * loading + **/ + OrthancPluginLoadDicomInstanceMode_UntilPixelData = 2, + + /** + * Load the whole DICOM file until pixel data, and replace pixel + * data by an empty tag whose VR (value representation) is the + * same as those of the original DICOM file + **/ + OrthancPluginLoadDicomInstanceMode_EmptyPixelData = 3, + + _OrthancPluginLoadDicomInstanceMode_INTERNAL = 0x7fffffff + } OrthancPluginLoadDicomInstanceMode; + + + /** + * The log levels supported by Orthanc. + * + * These values must match those of enumeration "LogLevel" in the + * Orthanc Core. + **/ + typedef enum + { + OrthancPluginLogLevel_Error = 0, /*!< Error log level */ + OrthancPluginLogLevel_Warning = 1, /*!< Warning log level */ + OrthancPluginLogLevel_Info = 2, /*!< Info log level */ + OrthancPluginLogLevel_Trace = 3, /*!< Trace log level */ + + _OrthancPluginLogLevel_INTERNAL = 0x7fffffff + } OrthancPluginLogLevel; + + + /** + * The log categories supported by Orthanc. + * + * These values must match those of enumeration "LogCategory" in the + * Orthanc Core. + **/ + typedef enum + { + OrthancPluginLogCategory_Generic = (1 << 0), /*!< Generic (default) category */ + OrthancPluginLogCategory_Plugins = (1 << 1), /*!< Plugin engine related logs (shall not be used by plugins) */ + OrthancPluginLogCategory_Http = (1 << 2), /*!< HTTP related logs */ + OrthancPluginLogCategory_Sqlite = (1 << 3), /*!< SQLite related logs (shall not be used by plugins) */ + OrthancPluginLogCategory_Dicom = (1 << 4), /*!< DICOM related logs */ + OrthancPluginLogCategory_Jobs = (1 << 5), /*!< jobs related logs */ + OrthancPluginLogCategory_Lua = (1 << 6), /*!< Lua related logs (shall not be used by plugins) */ + + _OrthancPluginLogCategory_INTERNAL = 0x7fffffff + } OrthancPluginLogCategory; + + + /** + * @brief A 32-bit memory buffer allocated by the core system of Orthanc. + * + * A memory buffer allocated by the core system of Orthanc. When the + * content of the buffer is not useful anymore, it must be free by a + * call to ::OrthancPluginFreeMemoryBuffer(). + **/ + typedef struct + { + /** + * @brief The content of the buffer. + **/ + void* data; + + /** + * @brief The number of bytes in the buffer. + **/ + uint32_t size; + } OrthancPluginMemoryBuffer; + + + + /** + * @brief A 64-bit memory buffer allocated by the core system of Orthanc. + * + * A memory buffer allocated by the core system of Orthanc. When the + * content of the buffer is not useful anymore, it must be free by a + * call to ::OrthancPluginFreeMemoryBuffer64(). + **/ + typedef struct + { + /** + * @brief The content of the buffer. + **/ + void* data; + + /** + * @brief The number of bytes in the buffer. + **/ + uint64_t size; + } OrthancPluginMemoryBuffer64; + + + + + /** + * @brief Opaque structure that represents the HTTP connection to the client application. + * @ingroup Callbacks + **/ + typedef struct _OrthancPluginRestOutput_t OrthancPluginRestOutput; + + + + /** + * @brief Opaque structure that represents a DICOM instance that is managed by the Orthanc core. + * @ingroup DicomInstance + **/ + typedef struct _OrthancPluginDicomInstance_t OrthancPluginDicomInstance; + + + + /** + * @brief Opaque structure that represents an image that is uncompressed in memory. + * @ingroup Images + **/ + typedef struct _OrthancPluginImage_t OrthancPluginImage; + + + + /** + * @brief Opaque structure that represents the storage area that is actually used by Orthanc. + * @ingroup Images + **/ + typedef struct _OrthancPluginStorageArea_t OrthancPluginStorageArea; + + + + /** + * @brief Opaque structure to an object that represents a C-Find query for worklists. + * @ingroup DicomCallbacks + **/ + typedef struct _OrthancPluginWorklistQuery_t OrthancPluginWorklistQuery; + + + + /** + * @brief Opaque structure to an object that represents the answers to a C-Find query for worklists. + * @ingroup DicomCallbacks + **/ + typedef struct _OrthancPluginWorklistAnswers_t OrthancPluginWorklistAnswers; + + + + /** + * @brief Opaque structure to an object that represents a C-Find query. + * @ingroup DicomCallbacks + **/ + typedef struct _OrthancPluginFindQuery_t OrthancPluginFindQuery; + + + + /** + * @brief Opaque structure to an object that represents the answers to a C-Find query for worklists. + * @ingroup DicomCallbacks + **/ + typedef struct _OrthancPluginFindAnswers_t OrthancPluginFindAnswers; + + + + /** + * @brief Opaque structure to an object that can be used to check whether a DICOM instance matches a C-Find query. + * @ingroup Toolbox + **/ + typedef struct _OrthancPluginFindMatcher_t OrthancPluginFindMatcher; + + + + /** + * @brief Opaque structure to the set of remote Orthanc Peers that are known to the local Orthanc server. + * @ingroup Toolbox + **/ + typedef struct _OrthancPluginPeers_t OrthancPluginPeers; + + + + /** + * @brief Opaque structure to a job to be executed by Orthanc. + * @ingroup Toolbox + **/ + typedef struct _OrthancPluginJob_t OrthancPluginJob; + + + + /** + * @brief Opaque structure that represents a node in a JSON or XML + * document used in DICOMweb. + * @ingroup Toolbox + **/ + typedef struct _OrthancPluginDicomWebNode_t OrthancPluginDicomWebNode; + + + + /** + * @brief Signature of a callback function that answers to a REST request. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginRestCallback) ( + OrthancPluginRestOutput* output, + const char* url, + const OrthancPluginHttpRequest* request); + + + + /** + * @brief Signature of a callback function that is triggered when Orthanc stores a new DICOM instance. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginOnStoredInstanceCallback) ( + const OrthancPluginDicomInstance* instance, + const char* instanceId); + + + + /** + * @brief Signature of a callback function that is triggered when a change happens to some DICOM resource. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginOnChangeCallback) ( + OrthancPluginChangeType changeType, + OrthancPluginResourceType resourceType, + const char* resourceId); + + + + /** + * @brief Signature of a callback function to decode a DICOM instance as an image. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginDecodeImageCallback) ( + OrthancPluginImage** target, + const void* dicom, + const uint32_t size, + uint32_t frameIndex); + + + + /** + * @brief Signature of a function to free dynamic memory. + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginFree) (void* buffer); + + + + /** + * @brief Signature of a function to set the content of a node + * encoding a binary DICOM tag, into a JSON or XML document + * generated for DICOMweb. + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginDicomWebSetBinaryNode) ( + OrthancPluginDicomWebNode* node, + OrthancPluginDicomWebBinaryMode mode, + const char* bulkDataUri); + + + + /** + * @brief Callback for writing to the storage area. + * + * Signature of a callback function that is triggered when Orthanc writes a file to the storage area. + * + * @param uuid The UUID of the file. + * @param content The content of the file. + * @param size The size of the file. + * @param type The content type corresponding to this file. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageCreate) ( + const char* uuid, + const void* content, + int64_t size, + OrthancPluginContentType type); + + + + /** + * @brief Callback for reading from the storage area. + * + * Signature of a callback function that is triggered when Orthanc reads a file from the storage area. + * + * @param content The content of the file (output). + * @param size The size of the file (output). + * @param uuid The UUID of the file of interest. + * @param type The content type corresponding to this file. + * @return 0 if success, other value if error. + * @ingroup Callbacks + * @deprecated New plugins should use OrthancPluginStorageRead2 + * + * @warning The "content" buffer *must* have been allocated using + * the "malloc()" function of your C standard library (i.e. nor + * "new[]", neither a pointer to a buffer). The "free()" function of + * your C standard library will automatically be invoked on the + * "content" pointer. + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageRead) ( + void** content, + int64_t* size, + const char* uuid, + OrthancPluginContentType type); + + + + /** + * @brief Callback for reading a whole file from the storage area. + * + * Signature of a callback function that is triggered when Orthanc + * reads a whole file from the storage area. + * + * @param target Memory buffer where to store the content of the file. It must be allocated by the + * plugin using OrthancPluginCreateMemoryBuffer64(). The core of Orthanc will free it. + * @param uuid The UUID of the file of interest. + * @param type The content type corresponding to this file. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageReadWhole) ( + OrthancPluginMemoryBuffer64* target, + const char* uuid, + OrthancPluginContentType type); + + + + /** + * @brief Callback for reading a range of a file from the storage area. + * + * Signature of a callback function that is triggered when Orthanc + * reads a portion of a file from the storage area. Orthanc + * indicates the start position and the length of the range. + * + * @param target Memory buffer where to store the content of the range. + * The memory buffer is allocated and freed by Orthanc. The length of the range + * of interest corresponds to the size of this buffer. + * @param uuid The UUID of the file of interest. + * @param type The content type corresponding to this file. + * @param rangeStart Start position of the requested range in the file. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageReadRange) ( + OrthancPluginMemoryBuffer64* target, + const char* uuid, + OrthancPluginContentType type, + uint64_t rangeStart); + + + + /** + * @brief Callback for removing a file from the storage area. + * + * Signature of a callback function that is triggered when Orthanc deletes a file from the storage area. + * + * @param uuid The UUID of the file to be removed. + * @param type The content type corresponding to this file. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageRemove) ( + const char* uuid, + OrthancPluginContentType type); + + + + /** + * @brief Callback to handle the C-Find SCP requests for worklists. + * + * Signature of a callback function that is triggered when Orthanc + * receives a C-Find SCP request against modality worklists. + * + * @param answers The target structure where answers must be stored. + * @param query The worklist query. + * @param issuerAet The Application Entity Title (AET) of the modality from which the request originates. + * @param calledAet The Application Entity Title (AET) of the modality that is called by the request. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWorklistCallback) ( + OrthancPluginWorklistAnswers* answers, + const OrthancPluginWorklistQuery* query, + const char* issuerAet, + const char* calledAet); + + + + /** + * @brief Callback to filter incoming HTTP requests received by Orthanc. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives an HTTP/REST request, and that answers whether + * this request should be allowed. If the callback returns "0" + * ("false"), the server answers with HTTP status code 403 + * (Forbidden). + * + * Pay attention to the fact that this function may be invoked + * concurrently by different threads of the Web server of + * Orthanc. You must implement proper locking if applicable. + * + * @param method The HTTP method used by the request. + * @param uri The URI of interest. + * @param ip The IP address of the HTTP client. + * @param headersCount The number of HTTP headers. + * @param headersKeys The keys of the HTTP headers (always converted to low-case). + * @param headersValues The values of the HTTP headers. + * @return 0 if forbidden access, 1 if allowed access, -1 if error. + * @ingroup Callbacks + * @deprecated Please instead use OrthancPluginIncomingHttpRequestFilter2() + **/ + typedef int32_t (*OrthancPluginIncomingHttpRequestFilter) ( + OrthancPluginHttpMethod method, + const char* uri, + const char* ip, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues); + + + + /** + * @brief Callback to filter incoming HTTP requests received by Orthanc. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives an HTTP/REST request, and that answers whether + * this request should be allowed. If the callback returns "0" + * ("false"), the server answers with HTTP status code 403 + * (Forbidden). + * + * Pay attention to the fact that this function may be invoked + * concurrently by different threads of the Web server of + * Orthanc. You must implement proper locking if applicable. + * + * @param method The HTTP method used by the request. + * @param uri The URI of interest. + * @param ip The IP address of the HTTP client. + * @param headersCount The number of HTTP headers. + * @param headersKeys The keys of the HTTP headers (always converted to low-case). + * @param headersValues The values of the HTTP headers. + * @param getArgumentsCount The number of GET arguments (only for the GET HTTP method). + * @param getArgumentsKeys The keys of the GET arguments (only for the GET HTTP method). + * @param getArgumentsValues The values of the GET arguments (only for the GET HTTP method). + * @return 0 if forbidden access, 1 if allowed access, -1 if error. + * @ingroup Callbacks + **/ + typedef int32_t (*OrthancPluginIncomingHttpRequestFilter2) ( + OrthancPluginHttpMethod method, + const char* uri, + const char* ip, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues, + uint32_t getArgumentsCount, + const char* const* getArgumentsKeys, + const char* const* getArgumentsValues); + + + + /** + * @brief Callback to handle incoming C-Find SCP requests. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives a C-Find SCP request not concerning modality + * worklists. + * + * @param answers The target structure where answers must be stored. + * @param query The worklist query. + * @param issuerAet The Application Entity Title (AET) of the modality from which the request originates. + * @param calledAet The Application Entity Title (AET) of the modality that is called by the request. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginFindCallback) ( + OrthancPluginFindAnswers* answers, + const OrthancPluginFindQuery* query, + const char* issuerAet, + const char* calledAet); + + + + /** + * @brief Callback to handle incoming C-Move SCP requests. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives a C-Move SCP request. The callback receives the + * type of the resource of interest (study, series, instance...) + * together with the DICOM tags containing its identifiers. In turn, + * the plugin must create a driver object that will be responsible + * for driving the successive move suboperations. + * + * @param resourceType The type of the resource of interest. Note + * that this might be set to ResourceType_None if the + * QueryRetrieveLevel (0008,0052) tag was not provided by the + * issuer (i.e. the originator modality). + * @param patientId Content of the PatientID (0x0010, 0x0020) tag of the resource of interest. Might be NULL. + * @param accessionNumber Content of the AccessionNumber (0x0008, 0x0050) tag. Might be NULL. + * @param studyInstanceUid Content of the StudyInstanceUID (0x0020, 0x000d) tag. Might be NULL. + * @param seriesInstanceUid Content of the SeriesInstanceUID (0x0020, 0x000e) tag. Might be NULL. + * @param sopInstanceUid Content of the SOPInstanceUID (0x0008, 0x0018) tag. Might be NULL. + * @param originatorAet The Application Entity Title (AET) of the + * modality from which the request originates. + * @param sourceAet The Application Entity Title (AET) of the + * modality that should send its DICOM files to another modality. + * @param targetAet The Application Entity Title (AET) of the + * modality that should receive the DICOM files. + * @param originatorId The Message ID issued by the originator modality, + * as found in tag (0000,0110) of the DICOM query emitted by the issuer. + * + * @return The NULL value if the plugin cannot deal with this query, + * or a pointer to the driver object that is responsible for + * handling the successive move suboperations. + * + * @note If targetAet equals sourceAet, this is actually a query/retrieve operation. + * @ingroup DicomCallbacks + **/ + typedef void* (*OrthancPluginMoveCallback) ( + OrthancPluginResourceType resourceType, + const char* patientId, + const char* accessionNumber, + const char* studyInstanceUid, + const char* seriesInstanceUid, + const char* sopInstanceUid, + const char* originatorAet, + const char* sourceAet, + const char* targetAet, + uint16_t originatorId); + + + /** + * @brief Callback to read the size of a C-Move driver. + * + * Signature of a callback function that returns the number of + * C-Move suboperations that are to be achieved by the given C-Move + * driver. This driver is the return value of a previous call to the + * OrthancPluginMoveCallback() callback. + * + * @param moveDriver The C-Move driver of interest. + * @return The number of suboperations. + * @ingroup DicomCallbacks + **/ + typedef uint32_t (*OrthancPluginGetMoveSize) (void* moveDriver); + + + /** + * @brief Callback to apply one C-Move suboperation. + * + * Signature of a callback function that applies the next C-Move + * suboperation that os to be achieved by the given C-Move + * driver. This driver is the return value of a previous call to the + * OrthancPluginMoveCallback() callback. + * + * @param moveDriver The C-Move driver of interest. + * @return 0 if success, or the error code if failure. + * @ingroup DicomCallbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginApplyMove) (void* moveDriver); + + + /** + * @brief Callback to free one C-Move driver. + * + * Signature of a callback function that releases the resources + * allocated by the given C-Move driver. This driver is the return + * value of a previous call to the OrthancPluginMoveCallback() + * callback. + * + * @param moveDriver The C-Move driver of interest. + * @ingroup DicomCallbacks + **/ + typedef void (*OrthancPluginFreeMove) (void* moveDriver); + + + /** + * @brief Callback to finalize one custom job. + * + * Signature of a callback function that releases all the resources + * allocated by the given job. This job is the argument provided to + * OrthancPluginCreateJob(). + * + * @param job The job of interest. + * @ingroup Toolbox + **/ + typedef void (*OrthancPluginJobFinalize) (void* job); + + + /** + * @brief Callback to check the progress of one custom job. + * + * Signature of a callback function that returns the progress of the + * job. + * + * @param job The job of interest. + * @return The progress, as a floating-point number ranging from 0 to 1. + * @ingroup Toolbox + **/ + typedef float (*OrthancPluginJobGetProgress) (void* job); + + + /** + * @brief Callback to retrieve the content of one custom job. + * + * Signature of a callback function that returns human-readable + * statistics about the job. This statistics must be formatted as a + * JSON object. This information is notably displayed in the "Jobs" + * tab of "Orthanc Explorer". + * + * @param job The job of interest. + * @return The statistics, as a JSON object encoded as a string. + * @ingroup Toolbox + * @deprecated This signature should not be used anymore since Orthanc SDK 1.11.3. + **/ + typedef const char* (*OrthancPluginJobGetContent) (void* job); + + + /** + * @brief Callback to retrieve the content of one custom job. + * + * Signature of a callback function that returns human-readable + * statistics about the job. This statistics must be formatted as a + * JSON object. This information is notably displayed in the "Jobs" + * tab of "Orthanc Explorer". + * + * @param target The target memory buffer where to store the JSON string. + * This buffer must be allocated using OrthancPluginCreateMemoryBuffer() + * and will be freed by the Orthanc core. + * @param job The job of interest. + * @return 0 if success, other value if error. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginJobGetContent2) (OrthancPluginMemoryBuffer* target, + void* job); + + + /** + * @brief Callback to serialize one custom job. + * + * Signature of a callback function that returns a serialized + * version of the job, formatted as a JSON object. This + * serialization is stored in the Orthanc database, and is used to + * reload the job on the restart of Orthanc. The "unserialization" + * callback (with OrthancPluginJobsUnserializer signature) will + * receive this serialized object. + * + * @param job The job of interest. + * @return The serialized job, as a JSON object encoded as a string. + * @see OrthancPluginRegisterJobsUnserializer() + * @ingroup Toolbox + * @deprecated This signature should not be used anymore since Orthanc SDK 1.11.3. + **/ + typedef const char* (*OrthancPluginJobGetSerialized) (void* job); + + + /** + * @brief Callback to serialize one custom job. + * + * Signature of a callback function that returns a serialized + * version of the job, formatted as a JSON object. This + * serialization is stored in the Orthanc database, and is used to + * reload the job on the restart of Orthanc. The "unserialization" + * callback (with OrthancPluginJobsUnserializer signature) will + * receive this serialized object. + * + * @param target The target memory buffer where to store the JSON string. + * This buffer must be allocated using OrthancPluginCreateMemoryBuffer() + * and will be freed by the Orthanc core. + * @param job The job of interest. + * @return 1 if the serialization has succeeded, 0 if serialization is + * not implemented for this type of job, or -1 in case of error. + **/ + typedef int32_t (*OrthancPluginJobGetSerialized2) (OrthancPluginMemoryBuffer* target, + void* job); + + + /** + * @brief Callback to execute one step of a custom job. + * + * Signature of a callback function that executes one step in the + * job. The jobs engine of Orthanc will make successive calls to + * this method, as long as it returns + * OrthancPluginJobStepStatus_Continue. + * + * @param job The job of interest. + * @return The status of execution. + * @ingroup Toolbox + **/ + typedef OrthancPluginJobStepStatus (*OrthancPluginJobStep) (void* job); + + + /** + * @brief Callback executed once one custom job leaves the "running" state. + * + * Signature of a callback function that is invoked once a job + * leaves the "running" state. This can happen if the previous call + * to OrthancPluginJobStep has failed/succeeded, if the host Orthanc + * server is being stopped, or if the user manually tags the job as + * paused/canceled. This callback allows the plugin to free + * resources allocated for running this custom job (e.g. to stop + * threads, or to remove temporary files). + * + * Note that handling pauses might involves a specific treatment + * (such a stopping threads, but keeping temporary files on the + * disk). This "paused" situation can be checked by looking at the + * "reason" parameter. + * + * @param job The job of interest. + * @param reason The reason for leaving the "running" state. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginJobStop) (void* job, + OrthancPluginJobStopReason reason); + + + /** + * @brief Callback executed once one stopped custom job is started again. + * + * Signature of a callback function that is invoked once a job + * leaves the "failure/canceled" state, to be started again. This + * function will typically reset the progress to zero. Note that + * before being actually executed, the job would first be tagged as + * "pending" in the Orthanc jobs engine. + * + * @param job The job of interest. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginJobReset) (void* job); + + + /** + * @brief Callback executed to unserialize a custom job. + * + * Signature of a callback function that unserializes a job that was + * saved in the Orthanc database. + * + * @param jobType The type of the job, as provided to OrthancPluginCreateJob(). + * @param serialized The serialization of the job, as provided by OrthancPluginJobGetSerialized. + * @return The unserialized job (as created by OrthancPluginCreateJob()), or NULL + * if this unserializer cannot handle this job type. + * @see OrthancPluginRegisterJobsUnserializer() + * @ingroup Callbacks + **/ + typedef OrthancPluginJob* (*OrthancPluginJobsUnserializer) (const char* jobType, + const char* serialized); + + + + /** + * @brief Callback executed to update the metrics of the plugin. + * + * Signature of a callback function that is called by Orthanc + * whenever a monitoring tool (such as Prometheus) asks the current + * values of the metrics. This callback gives the plugin a chance to + * update its metrics, by calling OrthancPluginSetMetricsValue() or + * OrthancPluginSetMetricsIntegerValue(). + * This is typically useful for metrics that are expensive to + * acquire. + * + * @see OrthancPluginRegisterRefreshMetrics() + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginRefreshMetricsCallback) (); + + + + /** + * @brief Callback executed to encode a binary tag in DICOMweb. + * + * Signature of a callback function that is called by Orthanc + * whenever a DICOM tag that contains a binary value must be written + * to a JSON or XML node, while a DICOMweb document is being + * generated. The value representation (VR) of the DICOM tag can be + * OB, OD, OF, OL, OW, or UN. + * + * @see OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml() + * @param node The node being generated, as provided by Orthanc. + * @param setter The setter to be used to encode the content of the node. If + * the setter is not called, the binary tag is not written to the output document. + * @param levelDepth The depth of the node in the DICOM hierarchy of sequences. + * This parameter gives the number of elements in the "levelTagGroup", + * "levelTagElement", and "levelIndex" arrays. + * @param levelTagGroup The group of the parent DICOM tags in the hierarchy. + * @param levelTagElement The element of the parent DICOM tags in the hierarchy. + * @param levelIndex The index of the node in the parent sequences of the hierarchy. + * @param tagGroup The group of the DICOM tag of interest. + * @param tagElement The element of the DICOM tag of interest. + * @param vr The value representation of the binary DICOM node. + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginDicomWebBinaryCallback) ( + OrthancPluginDicomWebNode* node, + OrthancPluginDicomWebSetBinaryNode setter, + uint32_t levelDepth, + const uint16_t* levelTagGroup, + const uint16_t* levelTagElement, + const uint32_t* levelIndex, + uint16_t tagGroup, + uint16_t tagElement, + OrthancPluginValueRepresentation vr); + + + + /** + * @brief Callback executed to encode a binary tag in DICOMweb. + * + * Signature of a callback function that is called by Orthanc + * whenever a DICOM tag that contains a binary value must be written + * to a JSON or XML node, while a DICOMweb document is being + * generated. The value representation (VR) of the DICOM tag can be + * OB, OD, OF, OL, OW, or UN. + * + * @see OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml() + * @param node The node being generated, as provided by Orthanc. + * @param setter The setter to be used to encode the content of the node. If + * the setter is not called, the binary tag is not written to the output document. + * @param levelDepth The depth of the node in the DICOM hierarchy of sequences. + * This parameter gives the number of elements in the "levelTagGroup", + * "levelTagElement", and "levelIndex" arrays. + * @param levelTagGroup The group of the parent DICOM tags in the hierarchy. + * @param levelTagElement The element of the parent DICOM tags in the hierarchy. + * @param levelIndex The index of the node in the parent sequences of the hierarchy. + * @param tagGroup The group of the DICOM tag of interest. + * @param tagElement The element of the DICOM tag of interest. + * @param vr The value representation of the binary DICOM node. + * @param payload The user payload. + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginDicomWebBinaryCallback2) ( + OrthancPluginDicomWebNode* node, + OrthancPluginDicomWebSetBinaryNode setter, + uint32_t levelDepth, + const uint16_t* levelTagGroup, + const uint16_t* levelTagElement, + const uint32_t* levelIndex, + uint16_t tagGroup, + uint16_t tagElement, + OrthancPluginValueRepresentation vr, + void* payload); + + + + /** + * @brief Data structure that contains information about the Orthanc core. + **/ + typedef struct _OrthancPluginContext_t + { + void* pluginsManager; + const char* orthancVersion; + OrthancPluginFree Free; + OrthancPluginErrorCode (*InvokeService) (struct _OrthancPluginContext_t* context, + _OrthancPluginService service, + const void* params); + } OrthancPluginContext; + + + + /** + * @brief An entry in the dictionary of DICOM tags. + **/ + typedef struct + { + uint16_t group; /*!< The group of the tag */ + uint16_t element; /*!< The element of the tag */ + OrthancPluginValueRepresentation vr; /*!< The value representation of the tag */ + uint32_t minMultiplicity; /*!< The minimum multiplicity of the tag */ + uint32_t maxMultiplicity; /*!< The maximum multiplicity of the tag (0 means arbitrary) */ + } OrthancPluginDictionaryEntry; + + + + /** + * @brief Free a string. + * + * Free a string that was allocated by the core system of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param str The string to be freed. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeString( + OrthancPluginContext* context, + char* str) + { + if (str != NULL) + { + context->Free(str); + } + } + + + /** + * @brief Check that the version of the hosting Orthanc is above a given version. + * + * This function checks whether the version of the Orthanc server + * running this plugin, is above the given version. Contrarily to + * OrthancPluginCheckVersion(), it is up to the developer of the + * plugin to make sure that all the Orthanc SDK services called by + * the plugin are actually implemented in the given version of + * Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param expectedMajor Expected major version. + * @param expectedMinor Expected minor version. + * @param expectedRevision Expected revision. + * @return 1 if and only if the versions are compatible. If the + * result is 0, the initialization of the plugin should fail. + * @see OrthancPluginCheckVersion() + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE int32_t OrthancPluginCheckVersionAdvanced( + OrthancPluginContext* context, + int32_t expectedMajor, + int32_t expectedMinor, + int32_t expectedRevision) + { + int32_t major, minor, revision; + + if (sizeof(int) != sizeof(int32_t) || /* Ensure binary compatibility with Orthanc SDK <= 1.12.1 */ + sizeof(int32_t) != sizeof(OrthancPluginErrorCode) || + sizeof(int32_t) != sizeof(OrthancPluginHttpMethod) || + sizeof(int32_t) != sizeof(_OrthancPluginService) || + sizeof(int32_t) != sizeof(_OrthancPluginProperty) || + sizeof(int32_t) != sizeof(OrthancPluginPixelFormat) || + sizeof(int32_t) != sizeof(OrthancPluginContentType) || + sizeof(int32_t) != sizeof(OrthancPluginResourceType) || + sizeof(int32_t) != sizeof(OrthancPluginChangeType) || + sizeof(int32_t) != sizeof(OrthancPluginCompressionType) || + sizeof(int32_t) != sizeof(OrthancPluginImageFormat) || + sizeof(int32_t) != sizeof(OrthancPluginValueRepresentation) || + sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFormat) || + sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFlags) || + sizeof(int32_t) != sizeof(OrthancPluginCreateDicomFlags) || + sizeof(int32_t) != sizeof(OrthancPluginIdentifierConstraint) || + sizeof(int32_t) != sizeof(OrthancPluginInstanceOrigin) || + sizeof(int32_t) != sizeof(OrthancPluginJobStepStatus) || + sizeof(int32_t) != sizeof(OrthancPluginConstraintType) || + sizeof(int32_t) != sizeof(OrthancPluginMetricsType) || + sizeof(int32_t) != sizeof(OrthancPluginDicomWebBinaryMode) || + sizeof(int32_t) != sizeof(OrthancPluginStorageCommitmentFailureReason) || + sizeof(int32_t) != sizeof(OrthancPluginLoadDicomInstanceMode) || + sizeof(int32_t) != sizeof(OrthancPluginLogLevel) || + sizeof(int32_t) != sizeof(OrthancPluginLogCategory)) + { + /* Mismatch in the size of the enumerations */ + return 0; + } + + /* Assume compatibility with the mainline */ + if (!strcmp(context->orthancVersion, "mainline")) + { + return 1; + } + + /* Parse the version of the Orthanc core */ + if ( +#ifdef _MSC_VER + sscanf_s +#else + sscanf +#endif + (context->orthancVersion, "%4d.%4d.%4d", &major, &minor, &revision) != 3) + { + return 0; + } + + /* Check the major number of the version */ + + if (major > expectedMajor) + { + return 1; + } + + if (major < expectedMajor) + { + return 0; + } + + /* Check the minor number of the version */ + + if (minor > expectedMinor) + { + return 1; + } + + if (minor < expectedMinor) + { + return 0; + } + + /* Check the revision number of the version */ + + if (revision >= expectedRevision) + { + return 1; + } + else + { + return 0; + } + } + + + /** + * @brief Check the compatibility of the plugin wrt. the version of its hosting Orthanc. + * + * This function checks whether the version of the Orthanc server + * running this plugin, is above the version of the current Orthanc + * SDK header. This guarantees that the plugin is compatible with + * the hosting Orthanc (i.e. it will not call unavailable services). + * The result of this function should always be checked in the + * OrthancPluginInitialize() entry point of the plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return 1 if and only if the versions are compatible. If the + * result is 0, the initialization of the plugin should fail. + * @see OrthancPluginCheckVersionAdvanced() + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE int32_t OrthancPluginCheckVersion( + OrthancPluginContext* context) + { + return OrthancPluginCheckVersionAdvanced( + context, + ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, + ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, + ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); + } + + + /** + * @brief Free a memory buffer. + * + * Free a memory buffer that was allocated by the core system of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The memory buffer to release. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeMemoryBuffer( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* buffer) + { + context->Free(buffer->data); + } + + + /** + * @brief Free a memory buffer. + * + * Free a memory buffer that was allocated by the core system of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The memory buffer to release. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeMemoryBuffer64( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer64* buffer) + { + context->Free(buffer->data); + } + + + /** + * @brief Log an error. + * + * Log an error message using the Orthanc logging system. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param message The message to be logged. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginLogError( + OrthancPluginContext* context, + const char* message) + { + context->InvokeService(context, _OrthancPluginService_LogError, message); + } + + + /** + * @brief Log a warning. + * + * Log a warning message using the Orthanc logging system. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param message The message to be logged. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginLogWarning( + OrthancPluginContext* context, + const char* message) + { + context->InvokeService(context, _OrthancPluginService_LogWarning, message); + } + + + /** + * @brief Log an information. + * + * Log an information message using the Orthanc logging system. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param message The message to be logged. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginLogInfo( + OrthancPluginContext* context, + const char* message) + { + context->InvokeService(context, _OrthancPluginService_LogInfo, message); + } + + + + typedef struct + { + const char* pathRegularExpression; + OrthancPluginRestCallback callback; + } _OrthancPluginRestCallback; + + /** + * @brief Register a REST callback. + * + * This function registers a REST callback against a regular + * expression for a URI. This function must be called during the + * initialization of the plugin, i.e. inside the + * OrthancPluginInitialize() public function. + * + * Each REST callback is guaranteed to run in mutual exclusion. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param pathRegularExpression Regular expression for the URI. May contain groups. + * @param callback The callback function to handle the REST call. + * @see OrthancPluginRegisterRestCallbackNoLock() + * + * @note + * The regular expression is case sensitive and must follow the + * [Perl syntax](https://www.boost.org/doc/libs/1_67_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html). + * + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallback( + OrthancPluginContext* context, + const char* pathRegularExpression, + OrthancPluginRestCallback callback) + { + _OrthancPluginRestCallback params; + params.pathRegularExpression = pathRegularExpression; + params.callback = callback; + context->InvokeService(context, _OrthancPluginService_RegisterRestCallback, ¶ms); + } + + + + /** + * @brief Register a REST callback, without locking. + * + * This function registers a REST callback against a regular + * expression for a URI. This function must be called during the + * initialization of the plugin, i.e. inside the + * OrthancPluginInitialize() public function. + * + * Contrarily to OrthancPluginRegisterRestCallback(), the callback + * will NOT be invoked in mutual exclusion. This can be useful for + * high-performance plugins that must handle concurrent requests + * (Orthanc uses a pool of threads, one thread being assigned to + * each incoming HTTP request). Of course, if using this function, + * it is up to the plugin to implement the required locking + * mechanisms. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param pathRegularExpression Regular expression for the URI. May contain groups. + * @param callback The callback function to handle the REST call. + * @see OrthancPluginRegisterRestCallback() + * + * @note + * The regular expression is case sensitive and must follow the + * [Perl syntax](https://www.boost.org/doc/libs/1_67_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html). + * + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallbackNoLock( + OrthancPluginContext* context, + const char* pathRegularExpression, + OrthancPluginRestCallback callback) + { + _OrthancPluginRestCallback params; + params.pathRegularExpression = pathRegularExpression; + params.callback = callback; + context->InvokeService(context, _OrthancPluginService_RegisterRestCallbackNoLock, ¶ms); + } + + + + typedef struct + { + OrthancPluginOnStoredInstanceCallback callback; + } _OrthancPluginOnStoredInstanceCallback; + + /** + * @brief Register a callback for received instances. + * + * This function registers a callback function that is called + * whenever a new DICOM instance is stored into the Orthanc core. + * + * @warning Your callback function will be called synchronously with + * the core of Orthanc. This implies that deadlocks might emerge if + * you call other core primitives of Orthanc in your callback (such + * deadlocks are particularly visible in the presence of other plugins + * or Lua scripts). It is thus strongly advised to avoid any call to + * the REST API of Orthanc in the callback. If you have to call + * other primitives of Orthanc, you should make these calls in a + * separate thread, passing the pending events to be processed + * through a message queue. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback function. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterOnStoredInstanceCallback( + OrthancPluginContext* context, + OrthancPluginOnStoredInstanceCallback callback) + { + _OrthancPluginOnStoredInstanceCallback params; + params.callback = callback; + + context->InvokeService(context, _OrthancPluginService_RegisterOnStoredInstanceCallback, ¶ms); + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + const void* answer; + uint32_t answerSize; + const char* mimeType; + } _OrthancPluginAnswerBuffer; + + /** + * @brief Answer to a REST request. + * + * This function answers to a REST request with the content of a memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param answer Pointer to the memory buffer containing the answer. + * @param answerSize Number of bytes of the answer. + * @param mimeType The MIME type of the answer. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginAnswerBuffer( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const void* answer, + uint32_t answerSize, + const char* mimeType) + { + _OrthancPluginAnswerBuffer params; + params.output = output; + params.answer = answer; + params.answerSize = answerSize; + params.mimeType = mimeType; + context->InvokeService(context, _OrthancPluginService_AnswerBuffer, ¶ms); + } + + + typedef struct + { + OrthancPluginRestOutput* output; + OrthancPluginPixelFormat format; + uint32_t width; + uint32_t height; + uint32_t pitch; + const void* buffer; + } _OrthancPluginCompressAndAnswerPngImage; + + typedef struct + { + OrthancPluginRestOutput* output; + OrthancPluginImageFormat imageFormat; + OrthancPluginPixelFormat pixelFormat; + uint32_t width; + uint32_t height; + uint32_t pitch; + const void* buffer; + uint8_t quality; + } _OrthancPluginCompressAndAnswerImage; + + + /** + * @brief Answer to a REST request with a PNG image. + * + * This function answers to a REST request with a PNG image. The + * parameters of this function describe a memory buffer that + * contains an uncompressed image. The image will be automatically compressed + * as a PNG image by the core system of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param format The memory layout of the uncompressed image. + * @param width The width of the image. + * @param height The height of the image. + * @param pitch The pitch of the image (i.e. the number of bytes + * between 2 successive lines of the image in the memory buffer). + * @param buffer The memory buffer containing the uncompressed image. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerPngImage( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height, + uint32_t pitch, + const void* buffer) + { + _OrthancPluginCompressAndAnswerImage params; + params.output = output; + params.imageFormat = OrthancPluginImageFormat_Png; + params.pixelFormat = format; + params.width = width; + params.height = height; + params.pitch = pitch; + params.buffer = buffer; + params.quality = 0; /* No quality for PNG */ + context->InvokeService(context, _OrthancPluginService_CompressAndAnswerImage, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* instanceId; + } _OrthancPluginGetDicomForInstance; + + /** + * @brief Retrieve a DICOM instance using its Orthanc identifier. + * + * Retrieve a DICOM instance using its Orthanc identifier. The DICOM + * file is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param instanceId The Orthanc identifier of the DICOM instance of interest. + * @return 0 if success, or the error code if failure. + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetDicomForInstance( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* instanceId) + { + _OrthancPluginGetDicomForInstance params; + params.target = target; + params.instanceId = instanceId; + return context->InvokeService(context, _OrthancPluginService_GetDicomForInstance, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* uri; + } _OrthancPluginRestApiGet; + + /** + * @brief Make a GET call to the built-in Orthanc REST API. + * + * Make a GET call to the built-in Orthanc REST API. The result to + * the query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiGetAfterPlugins() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGet( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri) + { + _OrthancPluginRestApiGet params; + params.target = target; + params.uri = uri; + return context->InvokeService(context, _OrthancPluginService_RestApiGet, ¶ms); + } + + + + /** + * @brief Make a GET call to the REST API, as tainted by the plugins. + * + * Make a GET call to the Orthanc REST API, after all the plugins + * are applied. In other words, if some plugin overrides or adds the + * called URI to the built-in Orthanc REST API, this call will + * return the result provided by this plugin. The result to the + * query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiGet() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGetAfterPlugins( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri) + { + _OrthancPluginRestApiGet params; + params.target = target; + params.uri = uri; + return context->InvokeService(context, _OrthancPluginService_RestApiGetAfterPlugins, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* uri; + const void* body; + uint32_t bodySize; + } _OrthancPluginRestApiPostPut; + + /** + * @brief Make a POST call to the built-in Orthanc REST API. + * + * Make a POST call to the built-in Orthanc REST API. The result to + * the query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @param body The body of the POST request. + * @param bodySize The size of the body. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiPostAfterPlugins() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPost( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri, + const void* body, + uint32_t bodySize) + { + _OrthancPluginRestApiPostPut params; + params.target = target; + params.uri = uri; + params.body = body; + params.bodySize = bodySize; + return context->InvokeService(context, _OrthancPluginService_RestApiPost, ¶ms); + } + + + /** + * @brief Make a POST call to the REST API, as tainted by the plugins. + * + * Make a POST call to the Orthanc REST API, after all the plugins + * are applied. In other words, if some plugin overrides or adds the + * called URI to the built-in Orthanc REST API, this call will + * return the result provided by this plugin. The result to the + * query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @param body The body of the POST request. + * @param bodySize The size of the body. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiPost() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPostAfterPlugins( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri, + const void* body, + uint32_t bodySize) + { + _OrthancPluginRestApiPostPut params; + params.target = target; + params.uri = uri; + params.body = body; + params.bodySize = bodySize; + return context->InvokeService(context, _OrthancPluginService_RestApiPostAfterPlugins, ¶ms); + } + + + + /** + * @brief Make a DELETE call to the built-in Orthanc REST API. + * + * Make a DELETE call to the built-in Orthanc REST API. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param uri The URI to delete in the built-in Orthanc API. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiDeleteAfterPlugins() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiDelete( + OrthancPluginContext* context, + const char* uri) + { + return context->InvokeService(context, _OrthancPluginService_RestApiDelete, uri); + } + + + /** + * @brief Make a DELETE call to the REST API, as tainted by the plugins. + * + * Make a DELETE call to the Orthanc REST API, after all the plugins + * are applied. In other words, if some plugin overrides or adds the + * called URI to the built-in Orthanc REST API, this call will + * return the result provided by this plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param uri The URI to delete in the built-in Orthanc API. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiDelete() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiDeleteAfterPlugins( + OrthancPluginContext* context, + const char* uri) + { + return context->InvokeService(context, _OrthancPluginService_RestApiDeleteAfterPlugins, uri); + } + + + + /** + * @brief Make a PUT call to the built-in Orthanc REST API. + * + * Make a PUT call to the built-in Orthanc REST API. The result to + * the query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @param body The body of the PUT request. + * @param bodySize The size of the body. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiPutAfterPlugins() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPut( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri, + const void* body, + uint32_t bodySize) + { + _OrthancPluginRestApiPostPut params; + params.target = target; + params.uri = uri; + params.body = body; + params.bodySize = bodySize; + return context->InvokeService(context, _OrthancPluginService_RestApiPut, ¶ms); + } + + + + /** + * @brief Make a PUT call to the REST API, as tainted by the plugins. + * + * Make a PUT call to the Orthanc REST API, after all the plugins + * are applied. In other words, if some plugin overrides or adds the + * called URI to the built-in Orthanc REST API, this call will + * return the result provided by this plugin. The result to the + * query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @param body The body of the PUT request. + * @param bodySize The size of the body. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiPut() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPutAfterPlugins( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri, + const void* body, + uint32_t bodySize) + { + _OrthancPluginRestApiPostPut params; + params.target = target; + params.uri = uri; + params.body = body; + params.bodySize = bodySize; + return context->InvokeService(context, _OrthancPluginService_RestApiPutAfterPlugins, ¶ms); + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + const char* argument; + } _OrthancPluginOutputPlusArgument; + + /** + * @brief Redirect a REST request. + * + * This function answers to a REST request by redirecting the user + * to another URI using HTTP status 301. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param redirection Where to redirect. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRedirect( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* redirection) + { + _OrthancPluginOutputPlusArgument params; + params.output = output; + params.argument = redirection; + context->InvokeService(context, _OrthancPluginService_Redirect, ¶ms); + } + + + + typedef struct + { + char** result; + const char* argument; + } _OrthancPluginRetrieveDynamicString; + + /** + * @brief Look for a patient. + * + * Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020). + * This function uses the database index to run as fast as possible (it does not loop + * over all the stored patients). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param patientID The Patient ID of interest. + * @return The NULL value if the patient is non-existent, or a string containing the + * Orthanc ID of the patient. This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupPatient( + OrthancPluginContext* context, + const char* patientID) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = patientID; + + if (context->InvokeService(context, _OrthancPluginService_LookupPatient, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Look for a study. + * + * Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d). + * This function uses the database index to run as fast as possible (it does not loop + * over all the stored studies). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param studyUID The Study Instance UID of interest. + * @return The NULL value if the study is non-existent, or a string containing the + * Orthanc ID of the study. This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudy( + OrthancPluginContext* context, + const char* studyUID) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = studyUID; + + if (context->InvokeService(context, _OrthancPluginService_LookupStudy, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Look for a study, using the accession number. + * + * Look for a study stored in Orthanc, using its Accession Number tag (0x0008, 0x0050). + * This function uses the database index to run as fast as possible (it does not loop + * over all the stored studies). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param accessionNumber The Accession Number of interest. + * @return The NULL value if the study is non-existent, or a string containing the + * Orthanc ID of the study. This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudyWithAccessionNumber( + OrthancPluginContext* context, + const char* accessionNumber) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = accessionNumber; + + if (context->InvokeService(context, _OrthancPluginService_LookupStudyWithAccessionNumber, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Look for a series. + * + * Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e). + * This function uses the database index to run as fast as possible (it does not loop + * over all the stored series). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param seriesUID The Series Instance UID of interest. + * @return The NULL value if the series is non-existent, or a string containing the + * Orthanc ID of the series. This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupSeries( + OrthancPluginContext* context, + const char* seriesUID) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = seriesUID; + + if (context->InvokeService(context, _OrthancPluginService_LookupSeries, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Look for an instance. + * + * Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018). + * This function uses the database index to run as fast as possible (it does not loop + * over all the stored instances). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param sopInstanceUID The SOP Instance UID of interest. + * @return The NULL value if the instance is non-existent, or a string containing the + * Orthanc ID of the instance. This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupInstance( + OrthancPluginContext* context, + const char* sopInstanceUID) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = sopInstanceUID; + + if (context->InvokeService(context, _OrthancPluginService_LookupInstance, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + uint16_t status; + } _OrthancPluginSendHttpStatusCode; + + /** + * @brief Send a HTTP status code. + * + * This function answers to a REST request by sending a HTTP status + * code (such as "400 - Bad Request"). Note that: + * - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). + * - Redirections (status 301) must use ::OrthancPluginRedirect(). + * - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). + * - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param status The HTTP status code to be sent. + * @ingroup REST + * @see OrthancPluginSendHttpStatus() + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSendHttpStatusCode( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + uint16_t status) + { + _OrthancPluginSendHttpStatusCode params; + params.output = output; + params.status = status; + context->InvokeService(context, _OrthancPluginService_SendHttpStatusCode, ¶ms); + } + + + /** + * @brief Signal that a REST request is not authorized. + * + * This function answers to a REST request by signaling that it is + * not authorized. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param realm The realm for the authorization process. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSendUnauthorized( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* realm) + { + _OrthancPluginOutputPlusArgument params; + params.output = output; + params.argument = realm; + context->InvokeService(context, _OrthancPluginService_SendUnauthorized, ¶ms); + } + + + /** + * @brief Signal that this URI does not support this HTTP method. + * + * This function answers to a REST request by signaling that the + * queried URI does not support this method. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param allowedMethods The allowed methods for this URI (e.g. "GET,POST" after a PUT or a POST request). + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSendMethodNotAllowed( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* allowedMethods) + { + _OrthancPluginOutputPlusArgument params; + params.output = output; + params.argument = allowedMethods; + context->InvokeService(context, _OrthancPluginService_SendMethodNotAllowed, ¶ms); + } + + + typedef struct + { + OrthancPluginRestOutput* output; + const char* key; + const char* value; + } _OrthancPluginSetHttpHeader; + + /** + * @brief Set a cookie. + * + * This function sets a cookie in the HTTP client. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param cookie The cookie to be set. + * @param value The value of the cookie. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetCookie( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* cookie, + const char* value) + { + _OrthancPluginSetHttpHeader params; + params.output = output; + params.key = cookie; + params.value = value; + context->InvokeService(context, _OrthancPluginService_SetCookie, ¶ms); + } + + + /** + * @brief Set some HTTP header. + * + * This function sets a HTTP header in the HTTP answer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param key The HTTP header to be set. + * @param value The value of the HTTP header. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetHttpHeader( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* key, + const char* value) + { + _OrthancPluginSetHttpHeader params; + params.output = output; + params.key = key; + params.value = value; + context->InvokeService(context, _OrthancPluginService_SetHttpHeader, ¶ms); + } + + + typedef struct + { + char** resultStringToFree; + const char** resultString; + int64_t* resultInt64; + const char* key; + const OrthancPluginDicomInstance* instance; + OrthancPluginInstanceOrigin* resultOrigin; /* New in Orthanc 0.9.5 SDK */ + } _OrthancPluginAccessDicomInstance; + + + /** + * @brief Get the AET of a DICOM instance. + * + * This function returns the Application Entity Title (AET) of the + * DICOM modality from which a DICOM instance originates. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The AET if success, NULL if error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceRemoteAet( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + const char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultString = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceRemoteAet, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the size of a DICOM file. + * + * This function returns the number of bytes of the given DICOM instance. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The size of the file, -1 in case of error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE int64_t OrthancPluginGetInstanceSize( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + int64_t size; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultInt64 = &size; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceSize, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return -1; + } + else + { + return size; + } + } + + + /** + * @brief Get the data of a DICOM file. + * + * This function returns a pointer to the content of the given DICOM instance. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The pointer to the DICOM data, NULL in case of error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE const void* OrthancPluginGetInstanceData( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + const char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultString = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceData, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the DICOM tag hierarchy as a JSON file. + * + * This function returns a pointer to a newly created string + * containing a JSON file. This JSON file encodes the tag hierarchy + * of the given DICOM instance. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The NULL value in case of error, or a string containing the JSON file. + * This string must be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceJson( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultStringToFree = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the DICOM tag hierarchy as a JSON file (with simplification). + * + * This function returns a pointer to a newly created string + * containing a JSON file. This JSON file encodes the tag hierarchy + * of the given DICOM instance. In contrast with + * ::OrthancPluginGetInstanceJson(), the returned JSON file is in + * its simplified version. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The NULL value in case of error, or a string containing the JSON file. + * This string must be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceSimplifiedJson( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultStringToFree = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceSimplifiedJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Check whether a DICOM instance is associated with some metadata. + * + * This function checks whether the DICOM instance of interest is + * associated with some metadata. As of Orthanc 0.8.1, in the + * callbacks registered by + * ::OrthancPluginRegisterOnStoredInstanceCallback(), the only + * possibly available metadata are "ReceptionDate", "RemoteAET" and + * "IndexInSeries". + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @param metadata The metadata of interest. + * @return 1 if the metadata is present, 0 if it is absent, -1 in case of error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE int32_t OrthancPluginHasInstanceMetadata( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + const char* metadata) + { + int64_t result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultInt64 = &result; + params.instance = instance; + params.key = metadata; + + if (context->InvokeService(context, _OrthancPluginService_HasInstanceMetadata, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return -1; + } + else + { + return (result != 0); + } + } + + + /** + * @brief Get the value of some metadata associated with a given DICOM instance. + * + * This functions returns the value of some metadata that is associated with the DICOM instance of interest. + * Before calling this function, the existence of the metadata must have been checked with + * ::OrthancPluginHasInstanceMetadata(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @param metadata The metadata of interest. + * @return The metadata value if success, NULL if error. Please note that the + * returned string belongs to the instance object and must NOT be + * deallocated. Please make a copy of the string if you wish to access + * it later. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceMetadata( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + const char* metadata) + { + const char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultString = &result; + params.instance = instance; + params.key = metadata; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceMetadata, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginStorageCreate create; + OrthancPluginStorageRead read; + OrthancPluginStorageRemove remove; + OrthancPluginFree free; + } _OrthancPluginRegisterStorageArea; + + /** + * @brief Register a custom storage area. + * + * This function registers a custom storage area, to replace the + * built-in way Orthanc stores its files on the filesystem. This + * function must be called during the initialization of the plugin, + * i.e. inside the OrthancPluginInitialize() public function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param create The callback function to store a file on the custom storage area. + * @param read The callback function to read a file from the custom storage area. + * @param remove The callback function to remove a file from the custom storage area. + * @ingroup Callbacks + * @deprecated Please use OrthancPluginRegisterStorageArea2() + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterStorageArea( + OrthancPluginContext* context, + OrthancPluginStorageCreate create, + OrthancPluginStorageRead read, + OrthancPluginStorageRemove remove) + { + _OrthancPluginRegisterStorageArea params; + params.create = create; + params.read = read; + params.remove = remove; + +#ifdef __cplusplus + params.free = ::free; +#else + params.free = free; +#endif + + context->InvokeService(context, _OrthancPluginService_RegisterStorageArea, ¶ms); + } + + + + /** + * @brief Return the path to the Orthanc executable. + * + * This function returns the path to the Orthanc executable. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL in the case of an error, or a newly allocated string + * containing the path. This string must be freed by + * OrthancPluginFreeString(). + **/ + ORTHANC_PLUGIN_INLINE char *OrthancPluginGetOrthancPath(OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetOrthancPath, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Return the directory containing the Orthanc. + * + * This function returns the path to the directory containing the Orthanc executable. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL in the case of an error, or a newly allocated string + * containing the path. This string must be freed by + * OrthancPluginFreeString(). + **/ + ORTHANC_PLUGIN_INLINE char *OrthancPluginGetOrthancDirectory(OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetOrthancDirectory, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Return the path to the configuration file(s). + * + * This function returns the path to the configuration file(s) that + * was specified when starting Orthanc. Since version 0.9.1, this + * path can refer to a folder that stores a set of configuration + * files. This function is deprecated in favor of + * OrthancPluginGetConfiguration(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL in the case of an error, or a newly allocated string + * containing the path. This string must be freed by + * OrthancPluginFreeString(). + * @see OrthancPluginGetConfiguration() + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE char *OrthancPluginGetConfigurationPath(OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetConfigurationPath, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginOnChangeCallback callback; + } _OrthancPluginOnChangeCallback; + + /** + * @brief Register a callback to monitor changes. + * + * This function registers a callback function that is called + * whenever a change happens to some DICOM resource. + * + * @warning Your callback function will be called synchronously with + * the core of Orthanc. This implies that deadlocks might emerge if + * you call other core primitives of Orthanc in your callback (such + * deadlocks are particularly visible in the presence of other plugins + * or Lua scripts). It is thus strongly advised to avoid any call to + * the REST API of Orthanc in the callback. If you have to call + * other primitives of Orthanc, you should make these calls in a + * separate thread, passing the pending events to be processed + * through a message queue. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback function. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterOnChangeCallback( + OrthancPluginContext* context, + OrthancPluginOnChangeCallback callback) + { + _OrthancPluginOnChangeCallback params; + params.callback = callback; + + context->InvokeService(context, _OrthancPluginService_RegisterOnChangeCallback, ¶ms); + } + + + + typedef struct + { + const char* plugin; + _OrthancPluginProperty property; + const char* value; + } _OrthancPluginSetPluginProperty; + + + /** + * @brief Set the URI where the plugin provides its Web interface. + * + * For plugins that come with a Web interface, this function + * declares the entry path where to find this interface. This + * information is notably used in the "Plugins" page of Orthanc + * Explorer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param uri The root URI for this plugin. + * + * @deprecated This function should not be used anymore because the + * result of the call to "OrthancPluginGetName()" depends on the + * system. Use "OrthancPluginSetRootUri2()" instead. + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE void OrthancPluginSetRootUri( + OrthancPluginContext* context, + const char* uri) + { + _OrthancPluginSetPluginProperty params; + params.plugin = OrthancPluginGetName(); + params.property = _OrthancPluginProperty_RootUri; + params.value = uri; + + context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); + } + + + /** + * @brief Set the URI where the plugin provides its Web interface. + * + * For plugins that come with a Web interface, this function + * declares the entry path where to find this interface. This + * information is notably used in the "Plugins" page of Orthanc + * Explorer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param plugin Identifier of your plugin (it must match "OrthancPluginGetName()"). + * @param uri The root URI for this plugin. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetRootUri2( + OrthancPluginContext* context, + const char* plugin, + const char* uri) + { + _OrthancPluginSetPluginProperty params; + params.plugin = plugin; + params.property = _OrthancPluginProperty_RootUri; + params.value = uri; + + context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); + } + + + /** + * @brief Set a description for this plugin. + * + * Set a description for this plugin. It is displayed in the + * "Plugins" page of Orthanc Explorer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param description The description. + * + * @deprecated This function should not be used anymore because the + * result of the call to "OrthancPluginGetName()" depends on the + * system. Use "OrthancPluginSetDescription2()" instead. + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE void OrthancPluginSetDescription( + OrthancPluginContext* context, + const char* description) + { + _OrthancPluginSetPluginProperty params; + params.plugin = OrthancPluginGetName(); + params.property = _OrthancPluginProperty_Description; + params.value = description; + + context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); + } + + + /** + * @brief Set a description for this plugin. + * + * Set a description for this plugin. It is displayed in the + * "Plugins" page of Orthanc Explorer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param plugin Identifier of your plugin (it must match "OrthancPluginGetName()"). + * @param description The description. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetDescription2( + OrthancPluginContext* context, + const char* plugin, + const char* description) + { + _OrthancPluginSetPluginProperty params; + params.plugin = plugin; + params.property = _OrthancPluginProperty_Description; + params.value = description; + + context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); + } + + + /** + * @brief Extend the JavaScript code of Orthanc Explorer. + * + * Add JavaScript code to customize the default behavior of Orthanc + * Explorer. This can for instance be used to add new buttons. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param javascript The custom JavaScript code. + * + * @deprecated This function should not be used anymore because the + * result of the call to "OrthancPluginGetName()" depends on the + * system. Use "OrthancPluginExtendOrthancExplorer2()" instead. + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE void OrthancPluginExtendOrthancExplorer( + OrthancPluginContext* context, + const char* javascript) + { + _OrthancPluginSetPluginProperty params; + params.plugin = OrthancPluginGetName(); + params.property = _OrthancPluginProperty_OrthancExplorer; + params.value = javascript; + + context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); + } + + + /** + * @brief Extend the JavaScript code of Orthanc Explorer. + * + * Add JavaScript code to customize the default behavior of Orthanc + * Explorer. This can for instance be used to add new buttons. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param plugin Identifier of your plugin (it must match "OrthancPluginGetName()"). + * @param javascript The custom JavaScript code. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginExtendOrthancExplorer2( + OrthancPluginContext* context, + const char* plugin, + const char* javascript) + { + _OrthancPluginSetPluginProperty params; + params.plugin = plugin; + params.property = _OrthancPluginProperty_OrthancExplorer; + params.value = javascript; + + context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); + } + + + typedef struct + { + char** result; + int32_t property; + const char* value; + } _OrthancPluginGlobalProperty; + + + /** + * @brief Get the value of a global property. + * + * Get the value of a global property that is stored in the Orthanc database. Global + * properties whose index is below 1024 are reserved by Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param property The global property of interest. + * @param defaultValue The value to return, if the global property is unset. + * @return The value of the global property, or NULL in the case of an error. This + * string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetGlobalProperty( + OrthancPluginContext* context, + int32_t property, + const char* defaultValue) + { + char* result; + + _OrthancPluginGlobalProperty params; + params.result = &result; + params.property = property; + params.value = defaultValue; + + if (context->InvokeService(context, _OrthancPluginService_GetGlobalProperty, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Set the value of a global property. + * + * Set the value of a global property into the Orthanc + * database. Setting a global property can be used by plugins to + * save their internal parameters. Plugins are only allowed to set + * properties whose index are above or equal to 1024 (properties + * below 1024 are read-only and reserved by Orthanc). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param property The global property of interest. + * @param value The value to be set in the global property. + * @return 0 if success, or the error code if failure. + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSetGlobalProperty( + OrthancPluginContext* context, + int32_t property, + const char* value) + { + _OrthancPluginGlobalProperty params; + params.result = NULL; + params.property = property; + params.value = value; + + return context->InvokeService(context, _OrthancPluginService_SetGlobalProperty, ¶ms); + } + + + + typedef struct + { + int32_t *resultInt32; + uint32_t *resultUint32; + int64_t *resultInt64; + uint64_t *resultUint64; + } _OrthancPluginReturnSingleValue; + + /** + * @brief Get the number of command-line arguments. + * + * Retrieve the number of command-line arguments that were used to launch Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return The number of arguments. + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetCommandLineArgumentsCount( + OrthancPluginContext* context) + { + uint32_t count = 0; + + _OrthancPluginReturnSingleValue params; + memset(¶ms, 0, sizeof(params)); + params.resultUint32 = &count; + + if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgumentsCount, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return count; + } + } + + + + /** + * @brief Get the value of a command-line argument. + * + * Get the value of one of the command-line arguments that were used + * to launch Orthanc. The number of available arguments can be + * retrieved by OrthancPluginGetCommandLineArgumentsCount(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param argument The index of the argument. + * @return The value of the argument, or NULL in the case of an error. This + * string must be freed by OrthancPluginFreeString(). + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetCommandLineArgument( + OrthancPluginContext* context, + uint32_t argument) + { + char* result; + + _OrthancPluginGlobalProperty params; + params.result = &result; + params.property = (int32_t) argument; + params.value = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgument, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the expected version of the database schema. + * + * Retrieve the expected version of the database schema. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return The version. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetExpectedDatabaseVersion( + OrthancPluginContext* context) + { + uint32_t count = 0; + + _OrthancPluginReturnSingleValue params; + memset(¶ms, 0, sizeof(params)); + params.resultUint32 = &count; + + if (context->InvokeService(context, _OrthancPluginService_GetExpectedDatabaseVersion, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return count; + } + } + + + + /** + * @brief Return the content of the configuration file(s). + * + * This function returns the content of the configuration that is + * used by Orthanc, formatted as a JSON string. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL in the case of an error, or a newly allocated string + * containing the configuration. This string must be freed by + * OrthancPluginFreeString(). + **/ + ORTHANC_PLUGIN_INLINE char *OrthancPluginGetConfiguration(OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetConfiguration, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + const char* subType; + const char* contentType; + } _OrthancPluginStartMultipartAnswer; + + /** + * @brief Start an HTTP multipart answer. + * + * Initiates a HTTP multipart answer, as the result of a REST request. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param subType The sub-type of the multipart answer ("mixed" or "related"). + * @param contentType The MIME type of the items in the multipart answer. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginSendMultipartItem(), OrthancPluginSendMultipartItem2() + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStartMultipartAnswer( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* subType, + const char* contentType) + { + _OrthancPluginStartMultipartAnswer params; + params.output = output; + params.subType = subType; + params.contentType = contentType; + return context->InvokeService(context, _OrthancPluginService_StartMultipartAnswer, ¶ms); + } + + + /** + * @brief Send an item as a part of some HTTP multipart answer. + * + * This function sends an item as a part of some HTTP multipart + * answer that was initiated by OrthancPluginStartMultipartAnswer(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param answer Pointer to the memory buffer containing the item. + * @param answerSize Number of bytes of the item. + * @return 0 if success, or the error code if failure (this notably happens + * if the connection is closed by the client). + * @see OrthancPluginSendMultipartItem2() + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSendMultipartItem( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const void* answer, + uint32_t answerSize) + { + _OrthancPluginAnswerBuffer params; + params.output = output; + params.answer = answer; + params.answerSize = answerSize; + params.mimeType = NULL; + return context->InvokeService(context, _OrthancPluginService_SendMultipartItem, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const void* source; + uint32_t size; + OrthancPluginCompressionType compression; + uint8_t uncompress; + } _OrthancPluginBufferCompression; + + + /** + * @brief Compress or decompress a buffer. + * + * This function compresses or decompresses a buffer, using the + * version of the zlib library that is used by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param source The source buffer. + * @param size The size in bytes of the source buffer. + * @param compression The compression algorithm. + * @param uncompress If set to "0", the buffer must be compressed. + * If set to "1", the buffer must be uncompressed. + * @return 0 if success, or the error code if failure. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginBufferCompression( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const void* source, + uint32_t size, + OrthancPluginCompressionType compression, + uint8_t uncompress) + { + _OrthancPluginBufferCompression params; + params.target = target; + params.source = source; + params.size = size; + params.compression = compression; + params.uncompress = uncompress; + + return context->InvokeService(context, _OrthancPluginService_BufferCompression, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* path; + } _OrthancPluginReadFile; + + /** + * @brief Read a file. + * + * Read the content of a file on the filesystem, and returns it into + * a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param path The path of the file to be read. + * @return 0 if success, or the error code if failure. + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginReadFile( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* path) + { + _OrthancPluginReadFile params; + params.target = target; + params.path = path; + return context->InvokeService(context, _OrthancPluginService_ReadFile, ¶ms); + } + + + + typedef struct + { + const char* path; + const void* data; + uint32_t size; + } _OrthancPluginWriteFile; + + /** + * @brief Write a file. + * + * Write the content of a memory buffer to the filesystem. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param path The path of the file to be written. + * @param data The content of the memory buffer. + * @param size The size of the memory buffer. + * @return 0 if success, or the error code if failure. + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWriteFile( + OrthancPluginContext* context, + const char* path, + const void* data, + uint32_t size) + { + _OrthancPluginWriteFile params; + params.path = path; + params.data = data; + params.size = size; + return context->InvokeService(context, _OrthancPluginService_WriteFile, ¶ms); + } + + + + typedef struct + { + const char** target; + OrthancPluginErrorCode error; + } _OrthancPluginGetErrorDescription; + + /** + * @brief Get the description of a given error code. + * + * This function returns the description of a given error code. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param error The error code of interest. + * @return The error description. This is a statically-allocated + * string, do not free it. + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetErrorDescription( + OrthancPluginContext* context, + OrthancPluginErrorCode error) + { + const char* result = NULL; + + _OrthancPluginGetErrorDescription params; + params.target = &result; + params.error = error; + + if (context->InvokeService(context, _OrthancPluginService_GetErrorDescription, ¶ms) != OrthancPluginErrorCode_Success || + result == NULL) + { + return "Unknown error code"; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + uint16_t status; + const void* body; + uint32_t bodySize; + } _OrthancPluginSendHttpStatus; + + /** + * @brief Send a HTTP status, with a custom body. + * + * This function answers to a HTTP request by sending a HTTP status + * code (such as "400 - Bad Request"), together with a body + * describing the error. The body will only be returned if the + * configuration option "HttpDescribeErrors" of Orthanc is set to "true". + * + * Note that: + * - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). + * - Redirections (status 301) must use ::OrthancPluginRedirect(). + * - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). + * - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param status The HTTP status code to be sent. + * @param body The body of the answer. + * @param bodySize The size of the body. + * @see OrthancPluginSendHttpStatusCode() + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSendHttpStatus( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + uint16_t status, + const void* body, + uint32_t bodySize) + { + _OrthancPluginSendHttpStatus params; + params.output = output; + params.status = status; + params.body = body; + params.bodySize = bodySize; + context->InvokeService(context, _OrthancPluginService_SendHttpStatus, ¶ms); + } + + + + typedef struct + { + const OrthancPluginImage* image; + uint32_t* resultUint32; + OrthancPluginPixelFormat* resultPixelFormat; + void** resultBuffer; + } _OrthancPluginGetImageInfo; + + + /** + * @brief Return the pixel format of an image. + * + * This function returns the type of memory layout for the pixels of the given image. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image of interest. + * @return The pixel format. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginPixelFormat OrthancPluginGetImagePixelFormat( + OrthancPluginContext* context, + const OrthancPluginImage* image) + { + OrthancPluginPixelFormat target; + + _OrthancPluginGetImageInfo params; + memset(¶ms, 0, sizeof(params)); + params.image = image; + params.resultPixelFormat = ⌖ + + if (context->InvokeService(context, _OrthancPluginService_GetImagePixelFormat, ¶ms) != OrthancPluginErrorCode_Success) + { + return OrthancPluginPixelFormat_Unknown; + } + else + { + return (OrthancPluginPixelFormat) target; + } + } + + + + /** + * @brief Return the width of an image. + * + * This function returns the width of the given image. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image of interest. + * @return The width. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImageWidth( + OrthancPluginContext* context, + const OrthancPluginImage* image) + { + uint32_t width; + + _OrthancPluginGetImageInfo params; + memset(¶ms, 0, sizeof(params)); + params.image = image; + params.resultUint32 = &width; + + if (context->InvokeService(context, _OrthancPluginService_GetImageWidth, ¶ms) != OrthancPluginErrorCode_Success) + { + return 0; + } + else + { + return width; + } + } + + + + /** + * @brief Return the height of an image. + * + * This function returns the height of the given image. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image of interest. + * @return The height. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImageHeight( + OrthancPluginContext* context, + const OrthancPluginImage* image) + { + uint32_t height; + + _OrthancPluginGetImageInfo params; + memset(¶ms, 0, sizeof(params)); + params.image = image; + params.resultUint32 = &height; + + if (context->InvokeService(context, _OrthancPluginService_GetImageHeight, ¶ms) != OrthancPluginErrorCode_Success) + { + return 0; + } + else + { + return height; + } + } + + + + /** + * @brief Return the pitch of an image. + * + * This function returns the pitch of the given image. The pitch is + * defined as the number of bytes between 2 successive lines of the + * image in the memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image of interest. + * @return The pitch. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImagePitch( + OrthancPluginContext* context, + const OrthancPluginImage* image) + { + uint32_t pitch; + + _OrthancPluginGetImageInfo params; + memset(¶ms, 0, sizeof(params)); + params.image = image; + params.resultUint32 = &pitch; + + if (context->InvokeService(context, _OrthancPluginService_GetImagePitch, ¶ms) != OrthancPluginErrorCode_Success) + { + return 0; + } + else + { + return pitch; + } + } + + + + /** + * @brief Return a pointer to the content of an image. + * + * This function returns a pointer to the memory buffer that + * contains the pixels of the image. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image of interest. + * @return The pointer. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE void* OrthancPluginGetImageBuffer( + OrthancPluginContext* context, + const OrthancPluginImage* image) + { + void* target = NULL; + + _OrthancPluginGetImageInfo params; + memset(¶ms, 0, sizeof(params)); + params.resultBuffer = ⌖ + params.image = image; + + if (context->InvokeService(context, _OrthancPluginService_GetImageBuffer, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + typedef struct + { + OrthancPluginImage** target; + const void* data; + uint32_t size; + OrthancPluginImageFormat format; + } _OrthancPluginUncompressImage; + + + /** + * @brief Decode a compressed image. + * + * This function decodes a compressed image from a memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param data Pointer to a memory buffer containing the compressed image. + * @param size Size of the memory buffer containing the compressed image. + * @param format The file format of the compressed image. + * @return The uncompressed image. It must be freed with OrthancPluginFreeImage(). + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage *OrthancPluginUncompressImage( + OrthancPluginContext* context, + const void* data, + uint32_t size, + OrthancPluginImageFormat format) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginUncompressImage params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.data = data; + params.size = size; + params.format = format; + + if (context->InvokeService(context, _OrthancPluginService_UncompressImage, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + + + typedef struct + { + OrthancPluginImage* image; + } _OrthancPluginFreeImage; + + /** + * @brief Free an image. + * + * This function frees an image that was decoded with OrthancPluginUncompressImage(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeImage( + OrthancPluginContext* context, + OrthancPluginImage* image) + { + _OrthancPluginFreeImage params; + params.image = image; + + context->InvokeService(context, _OrthancPluginService_FreeImage, ¶ms); + } + + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + OrthancPluginImageFormat imageFormat; + OrthancPluginPixelFormat pixelFormat; + uint32_t width; + uint32_t height; + uint32_t pitch; + const void* buffer; + uint8_t quality; + } _OrthancPluginCompressImage; + + + /** + * @brief Encode a PNG image. + * + * This function compresses the given memory buffer containing an + * image using the PNG specification, and stores the result of the + * compression into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param format The memory layout of the uncompressed image. + * @param width The width of the image. + * @param height The height of the image. + * @param pitch The pitch of the image (i.e. the number of bytes + * between 2 successive lines of the image in the memory buffer). + * @param buffer The memory buffer containing the uncompressed image. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginCompressAndAnswerPngImage() + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCompressPngImage( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height, + uint32_t pitch, + const void* buffer) + { + _OrthancPluginCompressImage params; + memset(¶ms, 0, sizeof(params)); + params.target = target; + params.imageFormat = OrthancPluginImageFormat_Png; + params.pixelFormat = format; + params.width = width; + params.height = height; + params.pitch = pitch; + params.buffer = buffer; + params.quality = 0; /* Unused for PNG */ + + return context->InvokeService(context, _OrthancPluginService_CompressImage, ¶ms); + } + + + /** + * @brief Encode a JPEG image. + * + * This function compresses the given memory buffer containing an + * image using the JPEG specification, and stores the result of the + * compression into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param format The memory layout of the uncompressed image. + * @param width The width of the image. + * @param height The height of the image. + * @param pitch The pitch of the image (i.e. the number of bytes + * between 2 successive lines of the image in the memory buffer). + * @param buffer The memory buffer containing the uncompressed image. + * @param quality The quality of the JPEG encoding, between 1 (worst + * quality, best compression) and 100 (best quality, worst + * compression). + * @return 0 if success, or the error code if failure. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCompressJpegImage( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height, + uint32_t pitch, + const void* buffer, + uint8_t quality) + { + _OrthancPluginCompressImage params; + memset(¶ms, 0, sizeof(params)); + params.target = target; + params.imageFormat = OrthancPluginImageFormat_Jpeg; + params.pixelFormat = format; + params.width = width; + params.height = height; + params.pitch = pitch; + params.buffer = buffer; + params.quality = quality; + + return context->InvokeService(context, _OrthancPluginService_CompressImage, ¶ms); + } + + + + /** + * @brief Answer to a REST request with a JPEG image. + * + * This function answers to a REST request with a JPEG image. The + * parameters of this function describe a memory buffer that + * contains an uncompressed image. The image will be automatically compressed + * as a JPEG image by the core system of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param format The memory layout of the uncompressed image. + * @param width The width of the image. + * @param height The height of the image. + * @param pitch The pitch of the image (i.e. the number of bytes + * between 2 successive lines of the image in the memory buffer). + * @param buffer The memory buffer containing the uncompressed image. + * @param quality The quality of the JPEG encoding, between 1 (worst + * quality, best compression) and 100 (best quality, worst + * compression). + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerJpegImage( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height, + uint32_t pitch, + const void* buffer, + uint8_t quality) + { + _OrthancPluginCompressAndAnswerImage params; + params.output = output; + params.imageFormat = OrthancPluginImageFormat_Jpeg; + params.pixelFormat = format; + params.width = width; + params.height = height; + params.pitch = pitch; + params.buffer = buffer; + params.quality = quality; + context->InvokeService(context, _OrthancPluginService_CompressAndAnswerImage, ¶ms); + } + + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + OrthancPluginHttpMethod method; + const char* url; + const char* username; + const char* password; + const void* body; + uint32_t bodySize; + } _OrthancPluginCallHttpClient; + + + /** + * @brief Issue a HTTP GET call. + * + * Make a HTTP GET call to the given URL. The result to the query is + * stored into a newly allocated memory buffer. Favor + * OrthancPluginRestApiGet() if calling the built-in REST API of the + * Orthanc instance that hosts this plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param url The URL of interest. + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpGet( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* url, + const char* username, + const char* password) + { + _OrthancPluginCallHttpClient params; + memset(¶ms, 0, sizeof(params)); + + params.target = target; + params.method = OrthancPluginHttpMethod_Get; + params.url = url; + params.username = username; + params.password = password; + + return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); + } + + + /** + * @brief Issue a HTTP POST call. + * + * Make a HTTP POST call to the given URL. The result to the query + * is stored into a newly allocated memory buffer. Favor + * OrthancPluginRestApiPost() if calling the built-in REST API of + * the Orthanc instance that hosts this plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param url The URL of interest. + * @param body The content of the body of the request. + * @param bodySize The size of the body of the request. + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpPost( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* url, + const void* body, + uint32_t bodySize, + const char* username, + const char* password) + { + _OrthancPluginCallHttpClient params; + memset(¶ms, 0, sizeof(params)); + + params.target = target; + params.method = OrthancPluginHttpMethod_Post; + params.url = url; + params.body = body; + params.bodySize = bodySize; + params.username = username; + params.password = password; + + return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); + } + + + /** + * @brief Issue a HTTP PUT call. + * + * Make a HTTP PUT call to the given URL. The result to the query is + * stored into a newly allocated memory buffer. Favor + * OrthancPluginRestApiPut() if calling the built-in REST API of the + * Orthanc instance that hosts this plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param url The URL of interest. + * @param body The content of the body of the request. + * @param bodySize The size of the body of the request. + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpPut( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* url, + const void* body, + uint32_t bodySize, + const char* username, + const char* password) + { + _OrthancPluginCallHttpClient params; + memset(¶ms, 0, sizeof(params)); + + params.target = target; + params.method = OrthancPluginHttpMethod_Put; + params.url = url; + params.body = body; + params.bodySize = bodySize; + params.username = username; + params.password = password; + + return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); + } + + + /** + * @brief Issue a HTTP DELETE call. + * + * Make a HTTP DELETE call to the given URL. Favor + * OrthancPluginRestApiDelete() if calling the built-in REST API of + * the Orthanc instance that hosts this plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param url The URL of interest. + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpDelete( + OrthancPluginContext* context, + const char* url, + const char* username, + const char* password) + { + _OrthancPluginCallHttpClient params; + memset(¶ms, 0, sizeof(params)); + + params.method = OrthancPluginHttpMethod_Delete; + params.url = url; + params.username = username; + params.password = password; + + return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); + } + + + + typedef struct + { + OrthancPluginImage** target; + const OrthancPluginImage* source; + OrthancPluginPixelFormat targetFormat; + } _OrthancPluginConvertPixelFormat; + + + /** + * @brief Change the pixel format of an image. + * + * This function creates a new image, changing the memory layout of the pixels. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param source The source image. + * @param targetFormat The target pixel format. + * @return The resulting image. It must be freed with OrthancPluginFreeImage(). + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage *OrthancPluginConvertPixelFormat( + OrthancPluginContext* context, + const OrthancPluginImage* source, + OrthancPluginPixelFormat targetFormat) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginConvertPixelFormat params; + params.target = ⌖ + params.source = source; + params.targetFormat = targetFormat; + + if (context->InvokeService(context, _OrthancPluginService_ConvertPixelFormat, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + + /** + * @brief Return the number of available fonts. + * + * This function returns the number of fonts that are built in the + * Orthanc core. These fonts can be used to draw texts on images + * through OrthancPluginDrawText(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return The number of fonts. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFontsCount( + OrthancPluginContext* context) + { + uint32_t count = 0; + + _OrthancPluginReturnSingleValue params; + memset(¶ms, 0, sizeof(params)); + params.resultUint32 = &count; + + if (context->InvokeService(context, _OrthancPluginService_GetFontsCount, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return count; + } + } + + + + + typedef struct + { + uint32_t fontIndex; /* in */ + const char** name; /* out */ + uint32_t* size; /* out */ + } _OrthancPluginGetFontInfo; + + /** + * @brief Return the name of a font. + * + * This function returns the name of a font that is built in the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount(). + * @return The font name. This is a statically-allocated string, do not free it. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetFontName( + OrthancPluginContext* context, + uint32_t fontIndex) + { + const char* result = NULL; + + _OrthancPluginGetFontInfo params; + memset(¶ms, 0, sizeof(params)); + params.name = &result; + params.fontIndex = fontIndex; + + if (context->InvokeService(context, _OrthancPluginService_GetFontInfo, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Return the size of a font. + * + * This function returns the size of a font that is built in the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount(). + * @return The font size. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFontSize( + OrthancPluginContext* context, + uint32_t fontIndex) + { + uint32_t result; + + _OrthancPluginGetFontInfo params; + memset(¶ms, 0, sizeof(params)); + params.size = &result; + params.fontIndex = fontIndex; + + if (context->InvokeService(context, _OrthancPluginService_GetFontInfo, ¶ms) != OrthancPluginErrorCode_Success) + { + return 0; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginImage* image; + uint32_t fontIndex; + const char* utf8Text; + int32_t x; + int32_t y; + uint8_t r; + uint8_t g; + uint8_t b; + } _OrthancPluginDrawText; + + + /** + * @brief Draw text on an image. + * + * This function draws some text on some image. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image upon which to draw the text. + * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount(). + * @param utf8Text The text to be drawn, encoded as an UTF-8 zero-terminated string. + * @param x The X position of the text over the image. + * @param y The Y position of the text over the image. + * @param r The value of the red color channel of the text. + * @param g The value of the green color channel of the text. + * @param b The value of the blue color channel of the text. + * @return 0 if success, other value if error. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginDrawText( + OrthancPluginContext* context, + OrthancPluginImage* image, + uint32_t fontIndex, + const char* utf8Text, + int32_t x, + int32_t y, + uint8_t r, + uint8_t g, + uint8_t b) + { + _OrthancPluginDrawText params; + memset(¶ms, 0, sizeof(params)); + params.image = image; + params.fontIndex = fontIndex; + params.utf8Text = utf8Text; + params.x = x; + params.y = y; + params.r = r; + params.g = g; + params.b = b; + + return context->InvokeService(context, _OrthancPluginService_DrawText, ¶ms); + } + + + + typedef struct + { + OrthancPluginStorageArea* storageArea; + const char* uuid; + const void* content; + uint64_t size; + OrthancPluginContentType type; + } _OrthancPluginStorageAreaCreate; + + + /** + * @brief Create a file inside the storage area. + * + * This function creates a new file inside the storage area that is + * currently used by Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param storageArea The storage area. + * @param uuid The identifier of the file to be created. + * @param content The content to store in the newly created file. + * @param size The size of the content. + * @param type The type of the file content. + * @return 0 if success, other value if error. + * @ingroup Callbacks + * @deprecated This function should not be used anymore. Use "OrthancPluginRestApiPut()" on + * "/{patients|studies|series|instances}/{id}/attachments/{name}" instead. + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaCreate( + OrthancPluginContext* context, + OrthancPluginStorageArea* storageArea, + const char* uuid, + const void* content, + uint64_t size, + OrthancPluginContentType type) + { + _OrthancPluginStorageAreaCreate params; + params.storageArea = storageArea; + params.uuid = uuid; + params.content = content; + params.size = size; + params.type = type; + + return context->InvokeService(context, _OrthancPluginService_StorageAreaCreate, ¶ms); + } + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + OrthancPluginStorageArea* storageArea; + const char* uuid; + OrthancPluginContentType type; + } _OrthancPluginStorageAreaRead; + + + /** + * @brief Read a file from the storage area. + * + * This function reads the content of a given file from the storage + * area that is currently used by Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param storageArea The storage area. + * @param uuid The identifier of the file to be read. + * @param type The type of the file content. + * @return 0 if success, other value if error. + * @ingroup Callbacks + * @deprecated This function should not be used anymore. Use "OrthancPluginRestApiGet()" on + * "/{patients|studies|series|instances}/{id}/attachments/{name}" instead. + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaRead( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + OrthancPluginStorageArea* storageArea, + const char* uuid, + OrthancPluginContentType type) + { + _OrthancPluginStorageAreaRead params; + params.target = target; + params.storageArea = storageArea; + params.uuid = uuid; + params.type = type; + + return context->InvokeService(context, _OrthancPluginService_StorageAreaRead, ¶ms); + } + + + typedef struct + { + OrthancPluginStorageArea* storageArea; + const char* uuid; + OrthancPluginContentType type; + } _OrthancPluginStorageAreaRemove; + + /** + * @brief Remove a file from the storage area. + * + * This function removes a given file from the storage area that is + * currently used by Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param storageArea The storage area. + * @param uuid The identifier of the file to be removed. + * @param type The type of the file content. + * @return 0 if success, other value if error. + * @ingroup Callbacks + * @deprecated This function should not be used anymore. Use "OrthancPluginRestApiDelete()" on + * "/{patients|studies|series|instances}/{id}/attachments/{name}" instead. + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaRemove( + OrthancPluginContext* context, + OrthancPluginStorageArea* storageArea, + const char* uuid, + OrthancPluginContentType type) + { + _OrthancPluginStorageAreaRemove params; + params.storageArea = storageArea; + params.uuid = uuid; + params.type = type; + + return context->InvokeService(context, _OrthancPluginService_StorageAreaRemove, ¶ms); + } + + + + typedef struct + { + OrthancPluginErrorCode* target; + int32_t code; + uint16_t httpStatus; + const char* message; + } _OrthancPluginRegisterErrorCode; + + /** + * @brief Declare a custom error code for this plugin. + * + * This function declares a custom error code that can be generated + * by this plugin. This declaration is used to enrich the body of + * the HTTP answer in the case of an error, and to set the proper + * HTTP status code. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param code The error code that is internal to this plugin. + * @param httpStatus The HTTP status corresponding to this error. + * @param message The description of the error. + * @return The error code that has been assigned inside the Orthanc core. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterErrorCode( + OrthancPluginContext* context, + int32_t code, + uint16_t httpStatus, + const char* message) + { + OrthancPluginErrorCode target; + + _OrthancPluginRegisterErrorCode params; + params.target = ⌖ + params.code = code; + params.httpStatus = httpStatus; + params.message = message; + + if (context->InvokeService(context, _OrthancPluginService_RegisterErrorCode, ¶ms) == OrthancPluginErrorCode_Success) + { + return target; + } + else + { + /* There was an error while assigned the error. Use a generic code. */ + return OrthancPluginErrorCode_Plugin; + } + } + + + + typedef struct + { + uint16_t group; + uint16_t element; + OrthancPluginValueRepresentation vr; + const char* name; + uint32_t minMultiplicity; + uint32_t maxMultiplicity; + } _OrthancPluginRegisterDictionaryTag; + + /** + * @brief Register a new tag into the DICOM dictionary. + * + * This function declares a new public tag in the dictionary of + * DICOM tags that are known to Orthanc. This function should be + * used in the OrthancPluginInitialize() callback. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param group The group of the tag. + * @param element The element of the tag. + * @param vr The value representation of the tag. + * @param name The nickname of the tag. + * @param minMultiplicity The minimum multiplicity of the tag (must be above 0). + * @param maxMultiplicity The maximum multiplicity of the tag. A value of 0 means + * an arbitrary multiplicity ("n"). + * @return 0 if success, other value if error. + * @see OrthancPluginRegisterPrivateDictionaryTag() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDictionaryTag( + OrthancPluginContext* context, + uint16_t group, + uint16_t element, + OrthancPluginValueRepresentation vr, + const char* name, + uint32_t minMultiplicity, + uint32_t maxMultiplicity) + { + _OrthancPluginRegisterDictionaryTag params; + params.group = group; + params.element = element; + params.vr = vr; + params.name = name; + params.minMultiplicity = minMultiplicity; + params.maxMultiplicity = maxMultiplicity; + + return context->InvokeService(context, _OrthancPluginService_RegisterDictionaryTag, ¶ms); + } + + + + typedef struct + { + uint16_t group; + uint16_t element; + OrthancPluginValueRepresentation vr; + const char* name; + uint32_t minMultiplicity; + uint32_t maxMultiplicity; + const char* privateCreator; + } _OrthancPluginRegisterPrivateDictionaryTag; + + /** + * @brief Register a new private tag into the DICOM dictionary. + * + * This function declares a new private tag in the dictionary of + * DICOM tags that are known to Orthanc. This function should be + * used in the OrthancPluginInitialize() callback. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param group The group of the tag. + * @param element The element of the tag. + * @param vr The value representation of the tag. + * @param name The nickname of the tag. + * @param minMultiplicity The minimum multiplicity of the tag (must be above 0). + * @param maxMultiplicity The maximum multiplicity of the tag. A value of 0 means + * an arbitrary multiplicity ("n"). + * @param privateCreator The private creator of this private tag. + * @return 0 if success, other value if error. + * @see OrthancPluginRegisterDictionaryTag() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterPrivateDictionaryTag( + OrthancPluginContext* context, + uint16_t group, + uint16_t element, + OrthancPluginValueRepresentation vr, + const char* name, + uint32_t minMultiplicity, + uint32_t maxMultiplicity, + const char* privateCreator) + { + _OrthancPluginRegisterPrivateDictionaryTag params; + params.group = group; + params.element = element; + params.vr = vr; + params.name = name; + params.minMultiplicity = minMultiplicity; + params.maxMultiplicity = maxMultiplicity; + params.privateCreator = privateCreator; + + return context->InvokeService(context, _OrthancPluginService_RegisterPrivateDictionaryTag, ¶ms); + } + + + + typedef struct + { + OrthancPluginStorageArea* storageArea; + OrthancPluginResourceType level; + } _OrthancPluginReconstructMainDicomTags; + + /** + * @brief Reconstruct the main DICOM tags. + * + * This function requests the Orthanc core to reconstruct the main + * DICOM tags of all the resources of the given type. This function + * can only be used as a part of the upgrade of a custom database + * back-end. A database transaction will be automatically setup. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param storageArea The storage area. + * @param level The type of the resources of interest. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginReconstructMainDicomTags( + OrthancPluginContext* context, + OrthancPluginStorageArea* storageArea, + OrthancPluginResourceType level) + { + _OrthancPluginReconstructMainDicomTags params; + params.level = level; + params.storageArea = storageArea; + + return context->InvokeService(context, _OrthancPluginService_ReconstructMainDicomTags, ¶ms); + } + + + typedef struct + { + char** result; + const char* instanceId; + const void* buffer; + uint32_t size; + OrthancPluginDicomToJsonFormat format; + OrthancPluginDicomToJsonFlags flags; + uint32_t maxStringLength; + } _OrthancPluginDicomToJson; + + + /** + * @brief Format a DICOM memory buffer as a JSON string. + * + * This function takes as input a memory buffer containing a DICOM + * file, and outputs a JSON string representing the tags of this + * DICOM file. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The memory buffer containing the DICOM file. + * @param size The size of the memory buffer. + * @param format The output format. + * @param flags Flags governing the output. + * @param maxStringLength The maximum length of a field. Too long fields will + * be output as "null". The 0 value means no maximum length. + * @return The NULL value if the case of an error, or the JSON + * string. This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + * @see OrthancPluginDicomInstanceToJson() + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginDicomBufferToJson( + OrthancPluginContext* context, + const void* buffer, + uint32_t size, + OrthancPluginDicomToJsonFormat format, + OrthancPluginDicomToJsonFlags flags, + uint32_t maxStringLength) + { + char* result; + + _OrthancPluginDicomToJson params; + memset(¶ms, 0, sizeof(params)); + params.result = &result; + params.buffer = buffer; + params.size = size; + params.format = format; + params.flags = flags; + params.maxStringLength = maxStringLength; + + if (context->InvokeService(context, _OrthancPluginService_DicomBufferToJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Format a DICOM instance as a JSON string. + * + * This function formats a DICOM instance that is stored in Orthanc, + * and outputs a JSON string representing the tags of this DICOM + * instance. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instanceId The Orthanc identifier of the instance. + * @param format The output format. + * @param flags Flags governing the output. + * @param maxStringLength The maximum length of a field. Too long fields will + * be output as "null". The 0 value means no maximum length. + * @return The NULL value if the case of an error, or the JSON + * string. This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + * @see OrthancPluginDicomInstanceToJson() + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginDicomInstanceToJson( + OrthancPluginContext* context, + const char* instanceId, + OrthancPluginDicomToJsonFormat format, + OrthancPluginDicomToJsonFlags flags, + uint32_t maxStringLength) + { + char* result; + + _OrthancPluginDicomToJson params; + memset(¶ms, 0, sizeof(params)); + params.result = &result; + params.instanceId = instanceId; + params.format = format; + params.flags = flags; + params.maxStringLength = maxStringLength; + + if (context->InvokeService(context, _OrthancPluginService_DicomInstanceToJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* uri; + uint32_t headersCount; + const char* const* headersKeys; + const char* const* headersValues; + int32_t afterPlugins; + } _OrthancPluginRestApiGet2; + + /** + * @brief Make a GET call to the Orthanc REST API, with custom HTTP headers. + * + * Make a GET call to the Orthanc REST API with extended + * parameters. The result to the query is stored into a newly + * allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @param headersCount The number of HTTP headers. + * @param headersKeys Array containing the keys of the HTTP headers (can be NULL if no header). + * @param headersValues Array containing the values of the HTTP headers (can be NULL if no header). + * @param afterPlugins If 0, the built-in API of Orthanc is used. + * If 1, the API is tainted by the plugins. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginRestApiGet(), OrthancPluginRestApiGetAfterPlugins() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGet2( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues, + int32_t afterPlugins) + { + _OrthancPluginRestApiGet2 params; + params.target = target; + params.uri = uri; + params.headersCount = headersCount; + params.headersKeys = headersKeys; + params.headersValues = headersValues; + params.afterPlugins = afterPlugins; + + return context->InvokeService(context, _OrthancPluginService_RestApiGet2, ¶ms); + } + + + + typedef struct + { + OrthancPluginWorklistCallback callback; + } _OrthancPluginWorklistCallback; + + /** + * @brief Register a callback to handle modality worklists requests. + * + * This function registers a callback to handle C-Find SCP requests + * on modality worklists. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterWorklistCallback( + OrthancPluginContext* context, + OrthancPluginWorklistCallback callback) + { + _OrthancPluginWorklistCallback params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterWorklistCallback, ¶ms); + } + + + + typedef struct + { + OrthancPluginWorklistAnswers* answers; + const OrthancPluginWorklistQuery* query; + const void* dicom; + uint32_t size; + } _OrthancPluginWorklistAnswersOperation; + + /** + * @brief Add one answer to some modality worklist request. + * + * This function adds one worklist (encoded as a DICOM file) to the + * set of answers corresponding to some C-Find SCP request against + * modality worklists. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answers The set of answers. + * @param query The worklist query, as received by the callback. + * @param dicom The worklist to answer, encoded as a DICOM file. + * @param size The size of the DICOM file. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + * @see OrthancPluginCreateDicom() + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistAddAnswer( + OrthancPluginContext* context, + OrthancPluginWorklistAnswers* answers, + const OrthancPluginWorklistQuery* query, + const void* dicom, + uint32_t size) + { + _OrthancPluginWorklistAnswersOperation params; + params.answers = answers; + params.query = query; + params.dicom = dicom; + params.size = size; + + return context->InvokeService(context, _OrthancPluginService_WorklistAddAnswer, ¶ms); + } + + + /** + * @brief Mark the set of worklist answers as incomplete. + * + * This function marks as incomplete the set of answers + * corresponding to some C-Find SCP request against modality + * worklists. This must be used if canceling the handling of a + * request when too many answers are to be returned. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answers The set of answers. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistMarkIncomplete( + OrthancPluginContext* context, + OrthancPluginWorklistAnswers* answers) + { + _OrthancPluginWorklistAnswersOperation params; + params.answers = answers; + params.query = NULL; + params.dicom = NULL; + params.size = 0; + + return context->InvokeService(context, _OrthancPluginService_WorklistMarkIncomplete, ¶ms); + } + + + typedef struct + { + const OrthancPluginWorklistQuery* query; + const void* dicom; + uint32_t size; + int32_t* isMatch; + OrthancPluginMemoryBuffer* target; + } _OrthancPluginWorklistQueryOperation; + + /** + * @brief Test whether a worklist matches the query. + * + * This function checks whether one worklist (encoded as a DICOM + * file) matches the C-Find SCP query against modality + * worklists. This function must be called before adding the + * worklist as an answer through OrthancPluginWorklistAddAnswer(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param query The worklist query, as received by the callback. + * @param dicom The worklist to answer, encoded as a DICOM file. + * @param size The size of the DICOM file. + * @return 1 if the worklist matches the query, 0 otherwise. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE int32_t OrthancPluginWorklistIsMatch( + OrthancPluginContext* context, + const OrthancPluginWorklistQuery* query, + const void* dicom, + uint32_t size) + { + int32_t isMatch = 0; + + _OrthancPluginWorklistQueryOperation params; + params.query = query; + params.dicom = dicom; + params.size = size; + params.isMatch = &isMatch; + params.target = NULL; + + if (context->InvokeService(context, _OrthancPluginService_WorklistIsMatch, ¶ms) == OrthancPluginErrorCode_Success) + { + return isMatch; + } + else + { + /* Error: Assume non-match */ + return 0; + } + } + + + /** + * @brief Retrieve the worklist query as a DICOM file. + * + * This function retrieves the DICOM file that underlies a C-Find + * SCP query against modality worklists. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target Memory buffer where to store the DICOM file. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param query The worklist query, as received by the callback. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistGetDicomQuery( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const OrthancPluginWorklistQuery* query) + { + _OrthancPluginWorklistQueryOperation params; + params.query = query; + params.dicom = NULL; + params.size = 0; + params.isMatch = NULL; + params.target = target; + + return context->InvokeService(context, _OrthancPluginService_WorklistGetDicomQuery, ¶ms); + } + + + /** + * @brief Get the origin of a DICOM file. + * + * This function returns the origin of a DICOM instance that has been received by Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The origin of the instance. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginInstanceOrigin OrthancPluginGetInstanceOrigin( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + OrthancPluginInstanceOrigin origin; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultOrigin = &origin; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceOrigin, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return OrthancPluginInstanceOrigin_Unknown; + } + else + { + return origin; + } + } + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* json; + const OrthancPluginImage* pixelData; + OrthancPluginCreateDicomFlags flags; + } _OrthancPluginCreateDicom; + + /** + * @brief Create a DICOM instance from a JSON string and an image. + * + * This function takes as input a string containing a JSON file + * describing the content of a DICOM instance. As an output, it + * writes the corresponding DICOM instance to a newly allocated + * memory buffer. Additionally, an image to be encoded within the + * DICOM instance can also be provided. + * + * Private tags will be associated with the private creator whose + * value is specified in the "DefaultPrivateCreator" configuration + * option of Orthanc. The function OrthancPluginCreateDicom2() can + * be used if another private creator must be used to create this + * instance. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param json The input JSON file. + * @param pixelData The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme. + * @param flags Flags governing the output. + * @return 0 if success, other value if error. + * @ingroup Toolbox + * @see OrthancPluginCreateDicom2() + * @see OrthancPluginDicomBufferToJson() + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateDicom( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* json, + const OrthancPluginImage* pixelData, + OrthancPluginCreateDicomFlags flags) + { + _OrthancPluginCreateDicom params; + params.target = target; + params.json = json; + params.pixelData = pixelData; + params.flags = flags; + + return context->InvokeService(context, _OrthancPluginService_CreateDicom, ¶ms); + } + + + typedef struct + { + OrthancPluginDecodeImageCallback callback; + } _OrthancPluginDecodeImageCallback; + + /** + * @brief Register a callback to handle the decoding of DICOM images. + * + * This function registers a custom callback to decode DICOM images, + * extending the built-in decoder of Orthanc that uses + * DCMTK. Starting with Orthanc 1.7.0, the exact behavior is + * affected by the configuration option + * "BuiltinDecoderTranscoderOrder" of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDecodeImageCallback( + OrthancPluginContext* context, + OrthancPluginDecodeImageCallback callback) + { + _OrthancPluginDecodeImageCallback params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterDecodeImageCallback, ¶ms); + } + + + + typedef struct + { + OrthancPluginImage** target; + OrthancPluginPixelFormat format; + uint32_t width; + uint32_t height; + uint32_t pitch; + void* buffer; + const void* constBuffer; + uint32_t bufferSize; + uint32_t frameIndex; + } _OrthancPluginCreateImage; + + + /** + * @brief Create an image. + * + * This function creates an image of given size and format. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param format The format of the pixels. + * @param width The width of the image. + * @param height The height of the image. + * @return The newly allocated image. It must be freed with OrthancPluginFreeImage(). + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginCreateImage( + OrthancPluginContext* context, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginCreateImage params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.format = format; + params.width = width; + params.height = height; + + if (context->InvokeService(context, _OrthancPluginService_CreateImage, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Create an image pointing to a memory buffer. + * + * This function creates an image whose content points to a memory + * buffer managed by the plugin. Note that the buffer is directly + * accessed, no memory is allocated and no data is copied. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param format The format of the pixels. + * @param width The width of the image. + * @param height The height of the image. + * @param pitch The pitch of the image (i.e. the number of bytes + * between 2 successive lines of the image in the memory buffer). + * @param buffer The memory buffer. + * @return The newly allocated image. It must be freed with OrthancPluginFreeImage(). + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginCreateImageAccessor( + OrthancPluginContext* context, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height, + uint32_t pitch, + void* buffer) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginCreateImage params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.format = format; + params.width = width; + params.height = height; + params.pitch = pitch; + params.buffer = buffer; + + if (context->InvokeService(context, _OrthancPluginService_CreateImageAccessor, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + + /** + * @brief Decode one frame from a DICOM instance. + * + * This function decodes one frame of a DICOM image that is stored + * in a memory buffer. This function will give the same result as + * OrthancPluginUncompressImage() for single-frame DICOM images. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer Pointer to a memory buffer containing the DICOM image. + * @param bufferSize Size of the memory buffer containing the DICOM image. + * @param frameIndex The index of the frame of interest in a multi-frame image. + * @return The uncompressed image. It must be freed with OrthancPluginFreeImage(). + * @ingroup Images + * @see OrthancPluginGetInstanceDecodedFrame() + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginDecodeDicomImage( + OrthancPluginContext* context, + const void* buffer, + uint32_t bufferSize, + uint32_t frameIndex) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginCreateImage params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.constBuffer = buffer; + params.bufferSize = bufferSize; + params.frameIndex = frameIndex; + + if (context->InvokeService(context, _OrthancPluginService_DecodeDicomImage, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + + typedef struct + { + char** result; + const void* buffer; + uint32_t size; + } _OrthancPluginComputeHash; + + /** + * @brief Compute an MD5 hash. + * + * This functions computes the MD5 cryptographic hash of the given memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The source memory buffer. + * @param size The size in bytes of the source buffer. + * @return The NULL value in case of error, or a string containing the cryptographic hash. + * This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginComputeMd5( + OrthancPluginContext* context, + const void* buffer, + uint32_t size) + { + char* result; + + _OrthancPluginComputeHash params; + params.result = &result; + params.buffer = buffer; + params.size = size; + + if (context->InvokeService(context, _OrthancPluginService_ComputeMd5, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Compute a SHA-1 hash. + * + * This functions computes the SHA-1 cryptographic hash of the given memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The source memory buffer. + * @param size The size in bytes of the source buffer. + * @return The NULL value in case of error, or a string containing the cryptographic hash. + * This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginComputeSha1( + OrthancPluginContext* context, + const void* buffer, + uint32_t size) + { + char* result; + + _OrthancPluginComputeHash params; + params.result = &result; + params.buffer = buffer; + params.size = size; + + if (context->InvokeService(context, _OrthancPluginService_ComputeSha1, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginDictionaryEntry* target; + const char* name; + } _OrthancPluginLookupDictionary; + + /** + * @brief Get information about the given DICOM tag. + * + * This functions makes a lookup in the dictionary of DICOM tags + * that are known to Orthanc, and returns information about this + * tag. The tag can be specified using its human-readable name + * (e.g. "PatientName") or a set of two hexadecimal numbers + * (e.g. "0010-0020"). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target Where to store the information about the tag. + * @param name The name of the DICOM tag. + * @return 0 if success, other value if error. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginLookupDictionary( + OrthancPluginContext* context, + OrthancPluginDictionaryEntry* target, + const char* name) + { + _OrthancPluginLookupDictionary params; + params.target = target; + params.name = name; + return context->InvokeService(context, _OrthancPluginService_LookupDictionary, ¶ms); + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + const void* answer; + uint32_t answerSize; + uint32_t headersCount; + const char* const* headersKeys; + const char* const* headersValues; + } _OrthancPluginSendMultipartItem2; + + /** + * @brief Send an item as a part of some HTTP multipart answer, with custom headers. + * + * This function sends an item as a part of some HTTP multipart + * answer that was initiated by OrthancPluginStartMultipartAnswer(). In addition to + * OrthancPluginSendMultipartItem(), this function will set HTTP header associated + * with the item. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param answer Pointer to the memory buffer containing the item. + * @param answerSize Number of bytes of the item. + * @param headersCount The number of HTTP headers. + * @param headersKeys Array containing the keys of the HTTP headers. + * @param headersValues Array containing the values of the HTTP headers. + * @return 0 if success, or the error code if failure (this notably happens + * if the connection is closed by the client). + * @see OrthancPluginSendMultipartItem() + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSendMultipartItem2( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const void* answer, + uint32_t answerSize, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues) + { + _OrthancPluginSendMultipartItem2 params; + params.output = output; + params.answer = answer; + params.answerSize = answerSize; + params.headersCount = headersCount; + params.headersKeys = headersKeys; + params.headersValues = headersValues; + + return context->InvokeService(context, _OrthancPluginService_SendMultipartItem2, ¶ms); + } + + + typedef struct + { + OrthancPluginIncomingHttpRequestFilter callback; + } _OrthancPluginIncomingHttpRequestFilter; + + /** + * @brief Register a callback to filter incoming HTTP requests. + * + * This function registers a custom callback to filter incoming HTTP/REST + * requests received by the HTTP server of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + * @deprecated Please instead use OrthancPluginRegisterIncomingHttpRequestFilter2() + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingHttpRequestFilter( + OrthancPluginContext* context, + OrthancPluginIncomingHttpRequestFilter callback) + { + _OrthancPluginIncomingHttpRequestFilter params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterIncomingHttpRequestFilter, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* answerBody; + OrthancPluginMemoryBuffer* answerHeaders; + uint16_t* httpStatus; + OrthancPluginHttpMethod method; + const char* url; + uint32_t headersCount; + const char* const* headersKeys; + const char* const* headersValues; + const void* body; + uint32_t bodySize; + const char* username; + const char* password; + uint32_t timeout; + const char* certificateFile; + const char* certificateKeyFile; + const char* certificateKeyPassword; + uint8_t pkcs11; + } _OrthancPluginCallHttpClient2; + + + + /** + * @brief Issue a HTTP call with full flexibility. + * + * Make a HTTP call to the given URL. The result to the query is + * stored into a newly allocated memory buffer. The HTTP request + * will be done accordingly to the global configuration of Orthanc + * (in particular, the options "HttpProxy", "HttpTimeout", + * "HttpsVerifyPeers", "HttpsCACertificates", and "Pkcs11" will be + * taken into account). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answerBody The target memory buffer (out argument). + * It must be freed with OrthancPluginFreeMemoryBuffer(). + * The value of this argument is ignored if the HTTP method is DELETE. + * @param answerHeaders The target memory buffer for the HTTP headers in the answers (out argument). + * The answer headers are formatted as a JSON object (associative array). + * The buffer must be freed with OrthancPluginFreeMemoryBuffer(). + * This argument can be set to NULL if the plugin has no interest in the HTTP headers. + * @param httpStatus The HTTP status after the execution of the request (out argument). + * @param method HTTP method to be used. + * @param url The URL of interest. + * @param headersCount The number of HTTP headers. + * @param headersKeys Array containing the keys of the HTTP headers (can be NULL if no header). + * @param headersValues Array containing the values of the HTTP headers (can be NULL if no header). + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @param body The HTTP body for a POST or PUT request. + * @param bodySize The size of the body. + * @param timeout Timeout in seconds (0 for default timeout). + * @param certificateFile Path to the client certificate for HTTPS, in PEM format + * (can be NULL if no client certificate or if not using HTTPS). + * @param certificateKeyFile Path to the key of the client certificate for HTTPS, in PEM format + * (can be NULL if no client certificate or if not using HTTPS). + * @param certificateKeyPassword Password to unlock the key of the client certificate + * (can be NULL if no client certificate or if not using HTTPS). + * @param pkcs11 Enable PKCS#11 client authentication for hardware security modules and smart cards. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginCallPeerApi() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpClient( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* answerBody, + OrthancPluginMemoryBuffer* answerHeaders, + uint16_t* httpStatus, + OrthancPluginHttpMethod method, + const char* url, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues, + const void* body, + uint32_t bodySize, + const char* username, + const char* password, + uint32_t timeout, + const char* certificateFile, + const char* certificateKeyFile, + const char* certificateKeyPassword, + uint8_t pkcs11) + { + _OrthancPluginCallHttpClient2 params; + memset(¶ms, 0, sizeof(params)); + + params.answerBody = answerBody; + params.answerHeaders = answerHeaders; + params.httpStatus = httpStatus; + params.method = method; + params.url = url; + params.headersCount = headersCount; + params.headersKeys = headersKeys; + params.headersValues = headersValues; + params.body = body; + params.bodySize = bodySize; + params.username = username; + params.password = password; + params.timeout = timeout; + params.certificateFile = certificateFile; + params.certificateKeyFile = certificateKeyFile; + params.certificateKeyPassword = certificateKeyPassword; + params.pkcs11 = pkcs11; + + return context->InvokeService(context, _OrthancPluginService_CallHttpClient2, ¶ms); + } + + + /** + * @brief Generate an UUID. + * + * Generate a random GUID/UUID (globally unique identifier). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL in the case of an error, or a newly allocated string + * containing the UUID. This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGenerateUuid( + OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GenerateUuid, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + + typedef struct + { + OrthancPluginFindCallback callback; + } _OrthancPluginFindCallback; + + /** + * @brief Register a callback to handle C-Find requests. + * + * This function registers a callback to handle C-Find SCP requests + * that are not related to modality worklists. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterFindCallback( + OrthancPluginContext* context, + OrthancPluginFindCallback callback) + { + _OrthancPluginFindCallback params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterFindCallback, ¶ms); + } + + + typedef struct + { + OrthancPluginFindAnswers *answers; + const OrthancPluginFindQuery *query; + const void *dicom; + uint32_t size; + uint32_t index; + uint32_t *resultUint32; + uint16_t *resultGroup; + uint16_t *resultElement; + char **resultString; + } _OrthancPluginFindOperation; + + /** + * @brief Add one answer to some C-Find request. + * + * This function adds one answer (encoded as a DICOM file) to the + * set of answers corresponding to some C-Find SCP request that is + * not related to modality worklists. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answers The set of answers. + * @param dicom The answer to be added, encoded as a DICOM file. + * @param size The size of the DICOM file. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + * @see OrthancPluginCreateDicom() + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginFindAddAnswer( + OrthancPluginContext* context, + OrthancPluginFindAnswers* answers, + const void* dicom, + uint32_t size) + { + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.answers = answers; + params.dicom = dicom; + params.size = size; + + return context->InvokeService(context, _OrthancPluginService_FindAddAnswer, ¶ms); + } + + + /** + * @brief Mark the set of C-Find answers as incomplete. + * + * This function marks as incomplete the set of answers + * corresponding to some C-Find SCP request that is not related to + * modality worklists. This must be used if canceling the handling + * of a request when too many answers are to be returned. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answers The set of answers. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginFindMarkIncomplete( + OrthancPluginContext* context, + OrthancPluginFindAnswers* answers) + { + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.answers = answers; + + return context->InvokeService(context, _OrthancPluginService_FindMarkIncomplete, ¶ms); + } + + + + /** + * @brief Get the number of tags in a C-Find query. + * + * This function returns the number of tags that are contained in + * the given C-Find query. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param query The C-Find query. + * @return The number of tags. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFindQuerySize( + OrthancPluginContext* context, + const OrthancPluginFindQuery* query) + { + uint32_t count = 0; + + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.query = query; + params.resultUint32 = &count; + + if (context->InvokeService(context, _OrthancPluginService_GetFindQuerySize, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return count; + } + } + + + /** + * @brief Get one tag in a C-Find query. + * + * This function returns the group and the element of one DICOM tag + * in the given C-Find query. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param group The group of the tag (output). + * @param element The element of the tag (output). + * @param query The C-Find query. + * @param index The index of the tag of interest. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetFindQueryTag( + OrthancPluginContext* context, + uint16_t* group, + uint16_t* element, + const OrthancPluginFindQuery* query, + uint32_t index) + { + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.query = query; + params.index = index; + params.resultGroup = group; + params.resultElement = element; + + return context->InvokeService(context, _OrthancPluginService_GetFindQueryTag, ¶ms); + } + + + /** + * @brief Get the symbolic name of one tag in a C-Find query. + * + * This function returns the symbolic name of one DICOM tag in the + * given C-Find query. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param query The C-Find query. + * @param index The index of the tag of interest. + * @return The NULL value in case of error, or a string containing the name of the tag. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetFindQueryTagName( + OrthancPluginContext* context, + const OrthancPluginFindQuery* query, + uint32_t index) + { + char* result; + + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.query = query; + params.index = index; + params.resultString = &result; + + if (context->InvokeService(context, _OrthancPluginService_GetFindQueryTagName, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the value associated with one tag in a C-Find query. + * + * This function returns the value associated with one tag in the + * given C-Find query. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param query The C-Find query. + * @param index The index of the tag of interest. + * @return The NULL value in case of error, or a string containing the value of the tag. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetFindQueryValue( + OrthancPluginContext* context, + const OrthancPluginFindQuery* query, + uint32_t index) + { + char* result; + + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.query = query; + params.index = index; + params.resultString = &result; + + if (context->InvokeService(context, _OrthancPluginService_GetFindQueryValue, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + + typedef struct + { + OrthancPluginMoveCallback callback; + OrthancPluginGetMoveSize getMoveSize; + OrthancPluginApplyMove applyMove; + OrthancPluginFreeMove freeMove; + } _OrthancPluginMoveCallback; + + /** + * @brief Register a callback to handle C-Move requests. + * + * This function registers a callback to handle C-Move SCP requests. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The main callback. + * @param getMoveSize Callback to read the number of C-Move suboperations. + * @param applyMove Callback to apply one C-Move suboperation. + * @param freeMove Callback to free the C-Move driver. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterMoveCallback( + OrthancPluginContext* context, + OrthancPluginMoveCallback callback, + OrthancPluginGetMoveSize getMoveSize, + OrthancPluginApplyMove applyMove, + OrthancPluginFreeMove freeMove) + { + _OrthancPluginMoveCallback params; + params.callback = callback; + params.getMoveSize = getMoveSize; + params.applyMove = applyMove; + params.freeMove = freeMove; + + return context->InvokeService(context, _OrthancPluginService_RegisterMoveCallback, ¶ms); + } + + + + typedef struct + { + OrthancPluginFindMatcher** target; + const void* query; + uint32_t size; + } _OrthancPluginCreateFindMatcher; + + + /** + * @brief Create a C-Find matcher. + * + * This function creates a "matcher" object that can be used to + * check whether a DICOM instance matches a C-Find query. The C-Find + * query must be expressed as a DICOM buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param query The C-Find DICOM query. + * @param size The size of the DICOM query. + * @return The newly allocated matcher. It must be freed with OrthancPluginFreeFindMatcher(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginFindMatcher* OrthancPluginCreateFindMatcher( + OrthancPluginContext* context, + const void* query, + uint32_t size) + { + OrthancPluginFindMatcher* target = NULL; + + _OrthancPluginCreateFindMatcher params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.query = query; + params.size = size; + + if (context->InvokeService(context, _OrthancPluginService_CreateFindMatcher, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + typedef struct + { + OrthancPluginFindMatcher* matcher; + } _OrthancPluginFreeFindMatcher; + + /** + * @brief Free a C-Find matcher. + * + * This function frees a matcher that was created using OrthancPluginCreateFindMatcher(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param matcher The matcher of interest. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeFindMatcher( + OrthancPluginContext* context, + OrthancPluginFindMatcher* matcher) + { + _OrthancPluginFreeFindMatcher params; + params.matcher = matcher; + + context->InvokeService(context, _OrthancPluginService_FreeFindMatcher, ¶ms); + } + + + typedef struct + { + const OrthancPluginFindMatcher* matcher; + const void* dicom; + uint32_t size; + int32_t* isMatch; + } _OrthancPluginFindMatcherIsMatch; + + /** + * @brief Test whether a DICOM instance matches a C-Find query. + * + * This function checks whether one DICOM instance matches C-Find + * matcher that was previously allocated using + * OrthancPluginCreateFindMatcher(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param matcher The matcher of interest. + * @param dicom The DICOM instance to be matched. + * @param size The size of the DICOM instance. + * @return 1 if the DICOM instance matches the query, 0 otherwise. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE int32_t OrthancPluginFindMatcherIsMatch( + OrthancPluginContext* context, + const OrthancPluginFindMatcher* matcher, + const void* dicom, + uint32_t size) + { + int32_t isMatch = 0; + + _OrthancPluginFindMatcherIsMatch params; + params.matcher = matcher; + params.dicom = dicom; + params.size = size; + params.isMatch = &isMatch; + + if (context->InvokeService(context, _OrthancPluginService_FindMatcherIsMatch, ¶ms) == OrthancPluginErrorCode_Success) + { + return isMatch; + } + else + { + /* Error: Assume non-match */ + return 0; + } + } + + + typedef struct + { + OrthancPluginIncomingHttpRequestFilter2 callback; + } _OrthancPluginIncomingHttpRequestFilter2; + + /** + * @brief Register a callback to filter incoming HTTP requests. + * + * This function registers a custom callback to filter incoming HTTP/REST + * requests received by the HTTP server of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingHttpRequestFilter2( + OrthancPluginContext* context, + OrthancPluginIncomingHttpRequestFilter2 callback) + { + _OrthancPluginIncomingHttpRequestFilter2 params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterIncomingHttpRequestFilter2, ¶ms); + } + + + + typedef struct + { + OrthancPluginPeers** peers; + } _OrthancPluginGetPeers; + + /** + * @brief Return the list of available Orthanc peers. + * + * This function returns the parameters of the Orthanc peers that are known to + * the Orthanc server hosting the plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL if error, or a newly allocated opaque data structure containing the peers. + * This structure must be freed with OrthancPluginFreePeers(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginPeers* OrthancPluginGetPeers( + OrthancPluginContext* context) + { + OrthancPluginPeers* peers = NULL; + + _OrthancPluginGetPeers params; + memset(¶ms, 0, sizeof(params)); + params.peers = &peers; + + if (context->InvokeService(context, _OrthancPluginService_GetPeers, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return peers; + } + } + + + typedef struct + { + OrthancPluginPeers* peers; + } _OrthancPluginFreePeers; + + /** + * @brief Free the list of available Orthanc peers. + * + * This function frees the data structure returned by OrthancPluginGetPeers(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param peers The data structure describing the Orthanc peers. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreePeers( + OrthancPluginContext* context, + OrthancPluginPeers* peers) + { + _OrthancPluginFreePeers params; + params.peers = peers; + + context->InvokeService(context, _OrthancPluginService_FreePeers, ¶ms); + } + + + typedef struct + { + uint32_t* target; + const OrthancPluginPeers* peers; + } _OrthancPluginGetPeersCount; + + /** + * @brief Get the number of Orthanc peers. + * + * This function returns the number of Orthanc peers. + * + * This function is thread-safe: Several threads sharing the same + * OrthancPluginPeers object can simultaneously call this function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param peers The data structure describing the Orthanc peers. + * @result The number of peers. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetPeersCount( + OrthancPluginContext* context, + const OrthancPluginPeers* peers) + { + uint32_t target = 0; + + _OrthancPluginGetPeersCount params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.peers = peers; + + if (context->InvokeService(context, _OrthancPluginService_GetPeersCount, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return target; + } + } + + + typedef struct + { + const char** target; + const OrthancPluginPeers* peers; + uint32_t peerIndex; + const char* userProperty; + } _OrthancPluginGetPeerProperty; + + /** + * @brief Get the symbolic name of an Orthanc peer. + * + * This function returns the symbolic name of the Orthanc peer, + * which corresponds to the key of the "OrthancPeers" configuration + * option of Orthanc. + * + * This function is thread-safe: Several threads sharing the same + * OrthancPluginPeers object can simultaneously call this function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param peers The data structure describing the Orthanc peers. + * @param peerIndex The index of the peer of interest. + * This value must be lower than OrthancPluginGetPeersCount(). + * @result The symbolic name, or NULL in the case of an error. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetPeerName( + OrthancPluginContext* context, + const OrthancPluginPeers* peers, + uint32_t peerIndex) + { + const char* target = NULL; + + _OrthancPluginGetPeerProperty params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.peers = peers; + params.peerIndex = peerIndex; + params.userProperty = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetPeerName, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Get the base URL of an Orthanc peer. + * + * This function returns the base URL to the REST API of some Orthanc peer. + * + * This function is thread-safe: Several threads sharing the same + * OrthancPluginPeers object can simultaneously call this function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param peers The data structure describing the Orthanc peers. + * @param peerIndex The index of the peer of interest. + * This value must be lower than OrthancPluginGetPeersCount(). + * @result The URL, or NULL in the case of an error. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetPeerUrl( + OrthancPluginContext* context, + const OrthancPluginPeers* peers, + uint32_t peerIndex) + { + const char* target = NULL; + + _OrthancPluginGetPeerProperty params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.peers = peers; + params.peerIndex = peerIndex; + params.userProperty = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetPeerUrl, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + + /** + * @brief Get some user-defined property of an Orthanc peer. + * + * This function returns some user-defined property of some Orthanc + * peer. An user-defined property is a property that is associated + * with the peer in the Orthanc configuration file, but that is not + * recognized by the Orthanc core. + * + * This function is thread-safe: Several threads sharing the same + * OrthancPluginPeers object can simultaneously call this function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param peers The data structure describing the Orthanc peers. + * @param peerIndex The index of the peer of interest. + * This value must be lower than OrthancPluginGetPeersCount(). + * @param userProperty The user property of interest. + * @result The value of the user property, or NULL if it is not defined. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetPeerUserProperty( + OrthancPluginContext* context, + const OrthancPluginPeers* peers, + uint32_t peerIndex, + const char* userProperty) + { + const char* target = NULL; + + _OrthancPluginGetPeerProperty params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.peers = peers; + params.peerIndex = peerIndex; + params.userProperty = userProperty; + + if (context->InvokeService(context, _OrthancPluginService_GetPeerUserProperty, ¶ms) != OrthancPluginErrorCode_Success) + { + /* No such user property */ + return NULL; + } + else + { + return target; + } + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* answerBody; + OrthancPluginMemoryBuffer* answerHeaders; + uint16_t* httpStatus; + const OrthancPluginPeers* peers; + uint32_t peerIndex; + OrthancPluginHttpMethod method; + const char* uri; + uint32_t additionalHeadersCount; + const char* const* additionalHeadersKeys; + const char* const* additionalHeadersValues; + const void* body; + uint32_t bodySize; + uint32_t timeout; + } _OrthancPluginCallPeerApi; + + /** + * @brief Call the REST API of an Orthanc peer. + * + * Make a REST call to the given URI in the REST API of a remote + * Orthanc peer. The result to the query is stored into a newly + * allocated memory buffer. The HTTP request will be done according + * to the "OrthancPeers" configuration option of Orthanc. + * + * This function is thread-safe: Several threads sharing the same + * OrthancPluginPeers object can simultaneously call this function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answerBody The target memory buffer (out argument). + * It must be freed with OrthancPluginFreeMemoryBuffer(). + * The value of this argument is ignored if the HTTP method is DELETE. + * @param answerHeaders The target memory buffer for the HTTP headers in the answers (out argument). + * The answer headers are formatted as a JSON object (associative array). + * The buffer must be freed with OrthancPluginFreeMemoryBuffer(). + * This argument can be set to NULL if the plugin has no interest in the HTTP headers. + * @param httpStatus The HTTP status after the execution of the request (out argument). + * @param peers The data structure describing the Orthanc peers. + * @param peerIndex The index of the peer of interest. + * This value must be lower than OrthancPluginGetPeersCount(). + * @param method HTTP method to be used. + * @param uri The URI of interest in the REST API. + * @param additionalHeadersCount The number of HTTP headers to be added to the + * HTTP headers provided in the global configuration of Orthanc. + * @param additionalHeadersKeys Array containing the keys of the HTTP headers (can be NULL if no header). + * @param additionalHeadersValues Array containing the values of the HTTP headers (can be NULL if no header). + * @param body The HTTP body for a POST or PUT request. + * @param bodySize The size of the body. + * @param timeout Timeout in seconds (0 for default timeout). + * @return 0 if success, or the error code if failure. + * @see OrthancPluginHttpClient() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCallPeerApi( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* answerBody, + OrthancPluginMemoryBuffer* answerHeaders, + uint16_t* httpStatus, + const OrthancPluginPeers* peers, + uint32_t peerIndex, + OrthancPluginHttpMethod method, + const char* uri, + uint32_t additionalHeadersCount, + const char* const* additionalHeadersKeys, + const char* const* additionalHeadersValues, + const void* body, + uint32_t bodySize, + uint32_t timeout) + { + _OrthancPluginCallPeerApi params; + memset(¶ms, 0, sizeof(params)); + + params.answerBody = answerBody; + params.answerHeaders = answerHeaders; + params.httpStatus = httpStatus; + params.peers = peers; + params.peerIndex = peerIndex; + params.method = method; + params.uri = uri; + params.additionalHeadersCount = additionalHeadersCount; + params.additionalHeadersKeys = additionalHeadersKeys; + params.additionalHeadersValues = additionalHeadersValues; + params.body = body; + params.bodySize = bodySize; + params.timeout = timeout; + + return context->InvokeService(context, _OrthancPluginService_CallPeerApi, ¶ms); + } + + + + + + typedef struct + { + OrthancPluginJob** target; + void *job; + OrthancPluginJobFinalize finalize; + const char *type; + OrthancPluginJobGetProgress getProgress; + OrthancPluginJobGetContent getContent; + OrthancPluginJobGetSerialized getSerialized; + OrthancPluginJobStep step; + OrthancPluginJobStop stop; + OrthancPluginJobReset reset; + } _OrthancPluginCreateJob; + + /** + * @brief Create a custom job. + * + * This function creates a custom job to be run by the jobs engine + * of Orthanc. + * + * Orthanc starts one dedicated thread per custom job that is + * running. It is guaranteed that all the callbacks will only be + * called from this single dedicated thread, in mutual exclusion: As + * a consequence, it is *not* mandatory to protect the various + * callbacks by mutexes. + * + * The custom job can nonetheless launch its own processing threads + * on the first call to the "step()" callback, and stop them once + * the "stop()" callback is called. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param job The job to be executed. + * @param finalize The finalization callback. + * @param type The type of the job, provided to the job unserializer. + * See OrthancPluginRegisterJobsUnserializer(). + * @param getProgress The progress callback. + * @param getContent The content callback. + * @param getSerialized The serialization callback. + * @param step The callback to execute the individual steps of the job. + * @param stop The callback that is invoked once the job leaves the "running" state. + * @param reset The callback that is invoked if a stopped job is started again. + * @return The newly allocated job. It must be freed with OrthancPluginFreeJob(), + * as long as it is not submitted with OrthancPluginSubmitJob(). + * @ingroup Toolbox + * @deprecated This signature should not be used anymore since Orthanc SDK 1.11.3. + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE OrthancPluginJob *OrthancPluginCreateJob( + OrthancPluginContext *context, + void *job, + OrthancPluginJobFinalize finalize, + const char *type, + OrthancPluginJobGetProgress getProgress, + OrthancPluginJobGetContent getContent, + OrthancPluginJobGetSerialized getSerialized, + OrthancPluginJobStep step, + OrthancPluginJobStop stop, + OrthancPluginJobReset reset) + { + OrthancPluginJob* target = NULL; + + _OrthancPluginCreateJob params; + memset(¶ms, 0, sizeof(params)); + + params.target = ⌖ + params.job = job; + params.finalize = finalize; + params.type = type; + params.getProgress = getProgress; + params.getContent = getContent; + params.getSerialized = getSerialized; + params.step = step; + params.stop = stop; + params.reset = reset; + + if (context->InvokeService(context, _OrthancPluginService_CreateJob, ¶ms) != OrthancPluginErrorCode_Success || + target == NULL) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + typedef struct + { + OrthancPluginJob** target; + void *job; + OrthancPluginJobFinalize finalize; + const char *type; + OrthancPluginJobGetProgress getProgress; + OrthancPluginJobGetContent2 getContent; + OrthancPluginJobGetSerialized2 getSerialized; + OrthancPluginJobStep step; + OrthancPluginJobStop stop; + OrthancPluginJobReset reset; + } _OrthancPluginCreateJob2; + + /** + * @brief Create a custom job. + * + * This function creates a custom job to be run by the jobs engine + * of Orthanc. + * + * Orthanc starts one dedicated thread per custom job that is + * running. It is guaranteed that all the callbacks will only be + * called from this single dedicated thread, in mutual exclusion: As + * a consequence, it is *not* mandatory to protect the various + * callbacks by mutexes. + * + * The custom job can nonetheless launch its own processing threads + * on the first call to the "step()" callback, and stop them once + * the "stop()" callback is called. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param job The job to be executed. + * @param finalize The finalization callback. + * @param type The type of the job, provided to the job unserializer. + * See OrthancPluginRegisterJobsUnserializer(). + * @param getProgress The progress callback. + * @param getContent The content callback. + * @param getSerialized The serialization callback. + * @param step The callback to execute the individual steps of the job. + * @param stop The callback that is invoked once the job leaves the "running" state. + * @param reset The callback that is invoked if a stopped job is started again. + * @return The newly allocated job. It must be freed with OrthancPluginFreeJob(), + * as long as it is not submitted with OrthancPluginSubmitJob(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginJob *OrthancPluginCreateJob2( + OrthancPluginContext *context, + void *job, + OrthancPluginJobFinalize finalize, + const char *type, + OrthancPluginJobGetProgress getProgress, + OrthancPluginJobGetContent2 getContent, + OrthancPluginJobGetSerialized2 getSerialized, + OrthancPluginJobStep step, + OrthancPluginJobStop stop, + OrthancPluginJobReset reset) + { + OrthancPluginJob* target = NULL; + + _OrthancPluginCreateJob2 params; + memset(¶ms, 0, sizeof(params)); + + params.target = ⌖ + params.job = job; + params.finalize = finalize; + params.type = type; + params.getProgress = getProgress; + params.getContent = getContent; + params.getSerialized = getSerialized; + params.step = step; + params.stop = stop; + params.reset = reset; + + if (context->InvokeService(context, _OrthancPluginService_CreateJob2, ¶ms) != OrthancPluginErrorCode_Success || + target == NULL) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + typedef struct + { + OrthancPluginJob* job; + } _OrthancPluginFreeJob; + + /** + * @brief Free a custom job. + * + * This function frees an image that was created with OrthancPluginCreateJob(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param job The job. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeJob( + OrthancPluginContext* context, + OrthancPluginJob* job) + { + _OrthancPluginFreeJob params; + params.job = job; + + context->InvokeService(context, _OrthancPluginService_FreeJob, ¶ms); + } + + + + typedef struct + { + char** resultId; + OrthancPluginJob *job; + int32_t priority; + } _OrthancPluginSubmitJob; + + /** + * @brief Submit a new job to the jobs engine of Orthanc. + * + * This function adds the given job to the pending jobs of + * Orthanc. Orthanc will take take of freeing it by invoking the + * finalization callback provided to OrthancPluginCreateJob(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param job The job, as received by OrthancPluginCreateJob(). + * @param priority The priority of the job. + * @return ID of the newly-submitted job. This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char *OrthancPluginSubmitJob( + OrthancPluginContext *context, + OrthancPluginJob *job, + int32_t priority) + { + char* resultId = NULL; + + _OrthancPluginSubmitJob params; + memset(¶ms, 0, sizeof(params)); + + params.resultId = &resultId; + params.job = job; + params.priority = priority; + + if (context->InvokeService(context, _OrthancPluginService_SubmitJob, ¶ms) != OrthancPluginErrorCode_Success || + resultId == NULL) + { + /* Error */ + return NULL; + } + else + { + return resultId; + } + } + + + + typedef struct + { + OrthancPluginJobsUnserializer unserializer; + } _OrthancPluginJobsUnserializer; + + /** + * @brief Register an unserializer for custom jobs. + * + * This function registers an unserializer that decodes custom jobs + * from a JSON string. This callback is invoked when the jobs engine + * of Orthanc is started (on Orthanc initialization), for each job + * that is stored in the Orthanc database. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param unserializer The job unserializer. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterJobsUnserializer( + OrthancPluginContext* context, + OrthancPluginJobsUnserializer unserializer) + { + _OrthancPluginJobsUnserializer params; + params.unserializer = unserializer; + + context->InvokeService(context, _OrthancPluginService_RegisterJobsUnserializer, ¶ms); + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + const char* details; + uint8_t log; + } _OrthancPluginSetHttpErrorDetails; + + /** + * @brief Provide a detailed description for an HTTP error. + * + * This function sets the detailed description associated with an + * HTTP error. This description will be displayed in the "Details" + * field of the JSON body of the HTTP answer. It is only taken into + * consideration if the REST callback returns an error code that is + * different from "OrthancPluginErrorCode_Success", and if the + * "HttpDescribeErrors" configuration option of Orthanc is set to + * "true". + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param details The details of the error message. + * @param log Whether to also write the detailed error to the Orthanc logs. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetHttpErrorDetails( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* details, + uint8_t log) + { + _OrthancPluginSetHttpErrorDetails params; + params.output = output; + params.details = details; + params.log = log; + context->InvokeService(context, _OrthancPluginService_SetHttpErrorDetails, ¶ms); + } + + + + typedef struct + { + const char** result; + const char* argument; + } _OrthancPluginRetrieveStaticString; + + /** + * @brief Detect the MIME type of a file. + * + * This function returns the MIME type of a file by inspecting its extension. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param path Path to the file. + * @return The MIME type. This is a statically-allocated + * string, do not free it. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginAutodetectMimeType( + OrthancPluginContext* context, + const char* path) + { + const char* result = NULL; + + _OrthancPluginRetrieveStaticString params; + params.result = &result; + params.argument = path; + + if (context->InvokeService(context, _OrthancPluginService_AutodetectMimeType, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + const char* name; + float value; + OrthancPluginMetricsType type; + } _OrthancPluginSetMetricsValue; + + /** + * @brief Set the value of a floating-point metrics. + * + * This function sets the value of a floating-point metrics to + * monitor the behavior of the plugin through tools such as + * Prometheus. The values of all the metrics are stored within the + * Orthanc context. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param name The name of the metrics to be set. + * @param value The value of the metrics. + * @param type The type of the metrics. This parameter is only taken into consideration + * the first time this metrics is set. + * @ingroup Toolbox + * @see OrthancPluginSetMetricsIntegerValue() + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetMetricsValue( + OrthancPluginContext* context, + const char* name, + float value, + OrthancPluginMetricsType type) + { + _OrthancPluginSetMetricsValue params; + params.name = name; + params.value = value; + params.type = type; + context->InvokeService(context, _OrthancPluginService_SetMetricsValue, ¶ms); + } + + + + typedef struct + { + OrthancPluginRefreshMetricsCallback callback; + } _OrthancPluginRegisterRefreshMetricsCallback; + + /** + * @brief Register a callback to refresh the metrics. + * + * This function registers a callback to refresh the metrics. The + * callback must make calls to OrthancPluginSetMetricsValue() or + * OrthancPluginSetMetricsIntegerValue(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback function to handle the refresh. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRefreshMetricsCallback( + OrthancPluginContext* context, + OrthancPluginRefreshMetricsCallback callback) + { + _OrthancPluginRegisterRefreshMetricsCallback params; + params.callback = callback; + context->InvokeService(context, _OrthancPluginService_RegisterRefreshMetricsCallback, ¶ms); + } + + + + + typedef struct + { + char** target; + const void* dicom; + uint32_t dicomSize; + OrthancPluginDicomWebBinaryCallback callback; + } _OrthancPluginEncodeDicomWeb; + + /** + * @brief Convert a DICOM instance to DICOMweb JSON. + * + * This function converts a memory buffer containing a DICOM instance, + * into its DICOMweb JSON representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param dicom Pointer to the DICOM instance. + * @param dicomSize Size of the DICOM instance. + * @param callback Callback to set the value of the binary tags. + * @see OrthancPluginCreateDicom() + * @return The NULL value in case of error, or the JSON document. This string must + * be freed by OrthancPluginFreeString(). + * @deprecated OrthancPluginEncodeDicomWebJson2() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebJson( + OrthancPluginContext* context, + const void* dicom, + uint32_t dicomSize, + OrthancPluginDicomWebBinaryCallback callback) + { + char* target = NULL; + + _OrthancPluginEncodeDicomWeb params; + params.target = ⌖ + params.dicom = dicom; + params.dicomSize = dicomSize; + params.callback = callback; + + if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Convert a DICOM instance to DICOMweb XML. + * + * This function converts a memory buffer containing a DICOM instance, + * into its DICOMweb XML representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param dicom Pointer to the DICOM instance. + * @param dicomSize Size of the DICOM instance. + * @param callback Callback to set the value of the binary tags. + * @return The NULL value in case of error, or the XML document. This string must + * be freed by OrthancPluginFreeString(). + * @see OrthancPluginCreateDicom() + * @deprecated OrthancPluginEncodeDicomWebXml2() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebXml( + OrthancPluginContext* context, + const void* dicom, + uint32_t dicomSize, + OrthancPluginDicomWebBinaryCallback callback) + { + char* target = NULL; + + _OrthancPluginEncodeDicomWeb params; + params.target = ⌖ + params.dicom = dicom; + params.dicomSize = dicomSize; + params.callback = callback; + + if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebXml, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + + typedef struct + { + char** target; + const void* dicom; + uint32_t dicomSize; + OrthancPluginDicomWebBinaryCallback2 callback; + void* payload; + } _OrthancPluginEncodeDicomWeb2; + + /** + * @brief Convert a DICOM instance to DICOMweb JSON. + * + * This function converts a memory buffer containing a DICOM instance, + * into its DICOMweb JSON representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param dicom Pointer to the DICOM instance. + * @param dicomSize Size of the DICOM instance. + * @param callback Callback to set the value of the binary tags. + * @param payload User payload. + * @return The NULL value in case of error, or the JSON document. This string must + * be freed by OrthancPluginFreeString(). + * @see OrthancPluginCreateDicom() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebJson2( + OrthancPluginContext* context, + const void* dicom, + uint32_t dicomSize, + OrthancPluginDicomWebBinaryCallback2 callback, + void* payload) + { + char* target = NULL; + + _OrthancPluginEncodeDicomWeb2 params; + params.target = ⌖ + params.dicom = dicom; + params.dicomSize = dicomSize; + params.callback = callback; + params.payload = payload; + + if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebJson2, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Convert a DICOM instance to DICOMweb XML. + * + * This function converts a memory buffer containing a DICOM instance, + * into its DICOMweb XML representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param dicom Pointer to the DICOM instance. + * @param dicomSize Size of the DICOM instance. + * @param callback Callback to set the value of the binary tags. + * @param payload User payload. + * @return The NULL value in case of error, or the XML document. This string must + * be freed by OrthancPluginFreeString(). + * @see OrthancPluginCreateDicom() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebXml2( + OrthancPluginContext* context, + const void* dicom, + uint32_t dicomSize, + OrthancPluginDicomWebBinaryCallback2 callback, + void* payload) + { + char* target = NULL; + + _OrthancPluginEncodeDicomWeb2 params; + params.target = ⌖ + params.dicom = dicom; + params.dicomSize = dicomSize; + params.callback = callback; + params.payload = payload; + + if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebXml2, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + + /** + * @brief Callback executed when a HTTP header is received during a chunked transfer. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, as soon as it + * receives one HTTP header from the answer of the remote HTTP + * server. + * + * @see OrthancPluginChunkedHttpClient() + * @param answer The user payload, as provided by the calling plugin. + * @param key The key of the HTTP header. + * @param value The value of the HTTP header. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginChunkedClientAnswerAddHeader) ( + void* answer, + const char* key, + const char* value); + + + /** + * @brief Callback executed when an answer chunk is received during a chunked transfer. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, as soon as it + * receives one data chunk from the answer of the remote HTTP + * server. + * + * @see OrthancPluginChunkedHttpClient() + * @param answer The user payload, as provided by the calling plugin. + * @param data The content of the data chunk. + * @param size The size of the data chunk. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginChunkedClientAnswerAddChunk) ( + void* answer, + const void* data, + uint32_t size); + + + /** + * @brief Callback to know whether the request body is entirely read during a chunked transfer + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, while reading + * the body of a POST or PUT request. The plugin must answer "1" as + * soon as the body is entirely read: The "request" data structure + * must act as an iterator. + * + * @see OrthancPluginChunkedHttpClient() + * @param request The user payload, as provided by the calling plugin. + * @return "1" if the body is over, or "0" if there is still data to be read. + * @ingroup Toolbox + **/ + typedef uint8_t (*OrthancPluginChunkedClientRequestIsDone) (void* request); + + + /** + * @brief Callback to advance in the request body during a chunked transfer + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, while reading + * the body of a POST or PUT request. This function asks the plugin + * to advance to the next chunk of data of the request body: The + * "request" data structure must act as an iterator. + * + * @see OrthancPluginChunkedHttpClient() + * @param request The user payload, as provided by the calling plugin. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginChunkedClientRequestNext) (void* request); + + + /** + * @brief Callback to read the current chunk of the request body during a chunked transfer + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, while reading + * the body of a POST or PUT request. The plugin must provide the + * content of the current chunk of data of the request body. + * + * @see OrthancPluginChunkedHttpClient() + * @param request The user payload, as provided by the calling plugin. + * @return The content of the current request chunk. + * @ingroup Toolbox + **/ + typedef const void* (*OrthancPluginChunkedClientRequestGetChunkData) (void* request); + + + /** + * @brief Callback to read the size of the current request chunk during a chunked transfer + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, while reading + * the body of a POST or PUT request. The plugin must provide the + * size of the current chunk of data of the request body. + * + * @see OrthancPluginChunkedHttpClient() + * @param request The user payload, as provided by the calling plugin. + * @return The size of the current request chunk. + * @ingroup Toolbox + **/ + typedef uint32_t (*OrthancPluginChunkedClientRequestGetChunkSize) (void* request); + + + typedef struct + { + void* answer; + OrthancPluginChunkedClientAnswerAddChunk answerAddChunk; + OrthancPluginChunkedClientAnswerAddHeader answerAddHeader; + uint16_t* httpStatus; + OrthancPluginHttpMethod method; + const char* url; + uint32_t headersCount; + const char* const* headersKeys; + const char* const* headersValues; + void* request; + OrthancPluginChunkedClientRequestIsDone requestIsDone; + OrthancPluginChunkedClientRequestGetChunkData requestChunkData; + OrthancPluginChunkedClientRequestGetChunkSize requestChunkSize; + OrthancPluginChunkedClientRequestNext requestNext; + const char* username; + const char* password; + uint32_t timeout; + const char* certificateFile; + const char* certificateKeyFile; + const char* certificateKeyPassword; + uint8_t pkcs11; + } _OrthancPluginChunkedHttpClient; + + + /** + * @brief Issue a HTTP call, using chunked HTTP transfers. + * + * Make a HTTP call to the given URL using chunked HTTP + * transfers. The request body is provided as an iterator over data + * chunks. The answer is provided as a sequence of function calls + * with the individual HTTP headers and answer chunks. + * + * Contrarily to OrthancPluginHttpClient() that entirely stores the + * request body and the answer body in memory buffers, this function + * uses chunked HTTP transfers. This results in a lower memory + * consumption. Pay attention to the fact that Orthanc servers with + * version <= 1.5.6 do not support chunked transfers: You must use + * OrthancPluginHttpClient() if contacting such older servers. + * + * The HTTP request will be done accordingly to the global + * configuration of Orthanc (in particular, the options "HttpProxy", + * "HttpTimeout", "HttpsVerifyPeers", "HttpsCACertificates", and + * "Pkcs11" will be taken into account). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answer The user payload for the answer body. It will be provided to the callbacks for the answer. + * @param answerAddChunk Callback function to report a data chunk from the answer body. + * @param answerAddHeader Callback function to report an HTTP header sent by the remote server. + * @param httpStatus The HTTP status after the execution of the request (out argument). + * @param method HTTP method to be used. + * @param url The URL of interest. + * @param headersCount The number of HTTP headers. + * @param headersKeys Array containing the keys of the HTTP headers (can be NULL if no header). + * @param headersValues Array containing the values of the HTTP headers (can be NULL if no header). + * @param request The user payload containing the request body, and acting as an iterator. + * It will be provided to the callbacks for the request. + * @param requestIsDone Callback function to tell whether the request body is entirely read. + * @param requestChunkData Callback function to get the content of the current data chunk of the request body. + * @param requestChunkSize Callback function to get the size of the current data chunk of the request body. + * @param requestNext Callback function to advance to the next data chunk of the request body. + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @param timeout Timeout in seconds (0 for default timeout). + * @param certificateFile Path to the client certificate for HTTPS, in PEM format + * (can be NULL if no client certificate or if not using HTTPS). + * @param certificateKeyFile Path to the key of the client certificate for HTTPS, in PEM format + * (can be NULL if no client certificate or if not using HTTPS). + * @param certificateKeyPassword Password to unlock the key of the client certificate + * (can be NULL if no client certificate or if not using HTTPS). + * @param pkcs11 Enable PKCS#11 client authentication for hardware security modules and smart cards. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginHttpClient() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginChunkedHttpClient( + OrthancPluginContext* context, + void* answer, + OrthancPluginChunkedClientAnswerAddChunk answerAddChunk, + OrthancPluginChunkedClientAnswerAddHeader answerAddHeader, + uint16_t* httpStatus, + OrthancPluginHttpMethod method, + const char* url, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues, + void* request, + OrthancPluginChunkedClientRequestIsDone requestIsDone, + OrthancPluginChunkedClientRequestGetChunkData requestChunkData, + OrthancPluginChunkedClientRequestGetChunkSize requestChunkSize, + OrthancPluginChunkedClientRequestNext requestNext, + const char* username, + const char* password, + uint32_t timeout, + const char* certificateFile, + const char* certificateKeyFile, + const char* certificateKeyPassword, + uint8_t pkcs11) + { + _OrthancPluginChunkedHttpClient params; + memset(¶ms, 0, sizeof(params)); + + /* In common with OrthancPluginHttpClient() */ + params.httpStatus = httpStatus; + params.method = method; + params.url = url; + params.headersCount = headersCount; + params.headersKeys = headersKeys; + params.headersValues = headersValues; + params.username = username; + params.password = password; + params.timeout = timeout; + params.certificateFile = certificateFile; + params.certificateKeyFile = certificateKeyFile; + params.certificateKeyPassword = certificateKeyPassword; + params.pkcs11 = pkcs11; + + /* For chunked body/answer */ + params.answer = answer; + params.answerAddChunk = answerAddChunk; + params.answerAddHeader = answerAddHeader; + params.request = request; + params.requestIsDone = requestIsDone; + params.requestChunkData = requestChunkData; + params.requestChunkSize = requestChunkSize; + params.requestNext = requestNext; + + return context->InvokeService(context, _OrthancPluginService_ChunkedHttpClient, ¶ms); + } + + + + /** + * @brief Opaque structure that reads the content of a HTTP request body during a chunked HTTP transfer. + * @ingroup Callbacks + **/ + typedef struct _OrthancPluginServerChunkedRequestReader_t OrthancPluginServerChunkedRequestReader; + + + + /** + * @brief Callback to create a reader to handle incoming chunked HTTP transfers. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP server that supports chunked HTTP transfers. This + * callback is only invoked if the HTTP method is POST or PUT. The + * callback must create an user-specific "reader" object that will + * be fed with the body of the incoming body. + * + * @see OrthancPluginRegisterChunkedRestCallback() + * @param reader Memory location that must be filled with the newly-created reader. + * @param url The URI that is accessed. + * @param request The body of the HTTP request. Note that "body" and "bodySize" are not used. + * @return 0 if success, or the error code if failure. + **/ + typedef OrthancPluginErrorCode (*OrthancPluginServerChunkedRequestReaderFactory) ( + OrthancPluginServerChunkedRequestReader** reader, + const char* url, + const OrthancPluginHttpRequest* request); + + + /** + * @brief Callback invoked whenever a new data chunk is available during a chunked transfer. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP server that supports chunked HTTP transfers. This callback + * is invoked as soon as a new data chunk is available for the request body. + * + * @see OrthancPluginRegisterChunkedRestCallback() + * @param reader The user payload, as created by the OrthancPluginServerChunkedRequestReaderFactory() callback. + * @param data The content of the data chunk. + * @param size The size of the data chunk. + * @return 0 if success, or the error code if failure. + **/ + typedef OrthancPluginErrorCode (*OrthancPluginServerChunkedRequestReaderAddChunk) ( + OrthancPluginServerChunkedRequestReader* reader, + const void* data, + uint32_t size); + + + /** + * @brief Callback invoked whenever the request body is entirely received. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP server that supports chunked HTTP transfers. This + * callback is invoked as soon as the full body of the HTTP request + * is available. The plugin can then send its answer thanks to the + * provided "output" object. + * + * @see OrthancPluginRegisterChunkedRestCallback() + * @param reader The user payload, as created by the OrthancPluginServerChunkedRequestReaderFactory() callback. + * @param output The HTTP connection to the client application. + * @return 0 if success, or the error code if failure. + **/ + typedef OrthancPluginErrorCode (*OrthancPluginServerChunkedRequestReaderExecute) ( + OrthancPluginServerChunkedRequestReader* reader, + OrthancPluginRestOutput* output); + + + /** + * @brief Callback invoked to release the resources associated with an incoming HTTP chunked transfer. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP server that supports chunked HTTP transfers. This + * callback is invoked to release all the resources allocated by the + * given reader. Note that this function might be invoked even if + * the entire body was not read, to deal with client error or + * disconnection. + * + * @see OrthancPluginRegisterChunkedRestCallback() + * @param reader The user payload, as created by the OrthancPluginServerChunkedRequestReaderFactory() callback. + **/ + typedef void (*OrthancPluginServerChunkedRequestReaderFinalize) ( + OrthancPluginServerChunkedRequestReader* reader); + + typedef struct + { + const char* pathRegularExpression; + OrthancPluginRestCallback getHandler; + OrthancPluginServerChunkedRequestReaderFactory postHandler; + OrthancPluginRestCallback deleteHandler; + OrthancPluginServerChunkedRequestReaderFactory putHandler; + OrthancPluginServerChunkedRequestReaderAddChunk addChunk; + OrthancPluginServerChunkedRequestReaderExecute execute; + OrthancPluginServerChunkedRequestReaderFinalize finalize; + } _OrthancPluginChunkedRestCallback; + + + /** + * @brief Register a REST callback to handle chunked HTTP transfers. + * + * This function registers a REST callback against a regular + * expression for a URI. This function must be called during the + * initialization of the plugin, i.e. inside the + * OrthancPluginInitialize() public function. + * + * Contrarily to OrthancPluginRegisterRestCallback(), the callbacks + * will NOT be invoked in mutual exclusion, so it is up to the + * plugin to implement the required locking mechanisms. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param pathRegularExpression Regular expression for the URI. May contain groups. + * @param getHandler The callback function to handle REST calls using the GET HTTP method. + * @param postHandler The callback function to handle REST calls using the POST HTTP method. + * @param deleteHandler The callback function to handle REST calls using the DELETE HTTP method. + * @param putHandler The callback function to handle REST calls using the PUT HTTP method. + * @param addChunk The callback invoked when a new chunk is available for the request body of a POST or PUT call. + * @param execute The callback invoked once the entire body of a POST or PUT call is read. + * @param finalize The callback invoked to release the resources associated with a POST or PUT call. + * @see OrthancPluginRegisterRestCallbackNoLock() + * + * @note + * The regular expression is case sensitive and must follow the + * [Perl syntax](https://www.boost.org/doc/libs/1_67_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html). + * + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterChunkedRestCallback( + OrthancPluginContext* context, + const char* pathRegularExpression, + OrthancPluginRestCallback getHandler, + OrthancPluginServerChunkedRequestReaderFactory postHandler, + OrthancPluginRestCallback deleteHandler, + OrthancPluginServerChunkedRequestReaderFactory putHandler, + OrthancPluginServerChunkedRequestReaderAddChunk addChunk, + OrthancPluginServerChunkedRequestReaderExecute execute, + OrthancPluginServerChunkedRequestReaderFinalize finalize) + { + _OrthancPluginChunkedRestCallback params; + params.pathRegularExpression = pathRegularExpression; + params.getHandler = getHandler; + params.postHandler = postHandler; + params.deleteHandler = deleteHandler; + params.putHandler = putHandler; + params.addChunk = addChunk; + params.execute = execute; + params.finalize = finalize; + + context->InvokeService(context, _OrthancPluginService_RegisterChunkedRestCallback, ¶ms); + } + + + + + + typedef struct + { + char** result; + uint16_t group; + uint16_t element; + const char* privateCreator; + } _OrthancPluginGetTagName; + + /** + * @brief Returns the symbolic name of a DICOM tag. + * + * This function makes a lookup to the dictionary of DICOM tags that + * are known to Orthanc, and returns the symbolic name of a DICOM tag. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param group The group of the tag. + * @param element The element of the tag. + * @param privateCreator For private tags, the name of the private creator (can be NULL). + * @return NULL in the case of an error, or a newly allocated string + * containing the path. This string must be freed by + * OrthancPluginFreeString(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetTagName( + OrthancPluginContext* context, + uint16_t group, + uint16_t element, + const char* privateCreator) + { + char* result; + + _OrthancPluginGetTagName params; + params.result = &result; + params.group = group; + params.element = element; + params.privateCreator = privateCreator; + + if (context->InvokeService(context, _OrthancPluginService_GetTagName, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + /** + * @brief Callback executed by the storage commitment SCP. + * + * Signature of a factory function that creates an object to handle + * one incoming storage commitment request. + * + * @remark The factory receives the list of the SOP class/instance + * UIDs of interest to the remote storage commitment SCU. This gives + * the factory the possibility to start some prefetch process + * upfront in the background, before the handler object is actually + * queried about the status of these DICOM instances. + * + * @param handler Output variable where the factory puts the handler object it created. + * @param jobId ID of the Orthanc job that is responsible for handling + * the storage commitment request. This job will successively look for the + * status of all the individual queried DICOM instances. + * @param transactionUid UID of the storage commitment transaction + * provided by the storage commitment SCU. It contains the value of the + * (0008,1195) DICOM tag. + * @param sopClassUids Array of the SOP class UIDs (0008,0016) that are queried by the SCU. + * @param sopInstanceUids Array of the SOP instance UIDs (0008,0018) that are queried by the SCU. + * @param countInstances Number of DICOM instances that are queried. This is the size + * of the `sopClassUids` and `sopInstanceUids` arrays. + * @param remoteAet The AET of the storage commitment SCU. + * @param calledAet The AET used by the SCU to contact the storage commitment SCP (i.e. Orthanc). + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageCommitmentFactory) ( + void** handler /* out */, + const char* jobId, + const char* transactionUid, + const char* const* sopClassUids, + const char* const* sopInstanceUids, + uint32_t countInstances, + const char* remoteAet, + const char* calledAet); + + + /** + * @brief Callback to free one storage commitment SCP handler. + * + * Signature of a callback function that releases the resources + * allocated by the factory of the storage commitment SCP. The + * handler is the return value of a previous call to the + * OrthancPluginStorageCommitmentFactory() callback. + * + * @param handler The handler object to be destructed. + * @ingroup DicomCallbacks + **/ + typedef void (*OrthancPluginStorageCommitmentDestructor) (void* handler); + + + /** + * @brief Callback to get the status of one DICOM instance in the + * storage commitment SCP. + * + * Signature of a callback function that is successively invoked for + * each DICOM instance that is queried by the remote storage + * commitment SCU. The function must be tought of as a method of + * the handler object that was created by a previous call to the + * OrthancPluginStorageCommitmentFactory() callback. After each call + * to this method, the progress of the associated Orthanc job is + * updated. + * + * @param target Output variable where to put the status for the queried instance. + * @param handler The handler object associated with this storage commitment request. + * @param sopClassUid The SOP class UID (0008,0016) of interest. + * @param sopInstanceUid The SOP instance UID (0008,0018) of interest. + * @ingroup DicomCallbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageCommitmentLookup) ( + OrthancPluginStorageCommitmentFailureReason* target, + void* handler, + const char* sopClassUid, + const char* sopInstanceUid); + + + typedef struct + { + OrthancPluginStorageCommitmentFactory factory; + OrthancPluginStorageCommitmentDestructor destructor; + OrthancPluginStorageCommitmentLookup lookup; + } _OrthancPluginRegisterStorageCommitmentScpCallback; + + /** + * @brief Register a callback to handle incoming requests to the storage commitment SCP. + * + * This function registers a callback to handle storage commitment SCP requests. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param factory Factory function that creates the handler object + * for incoming storage commitment requests. + * @param destructor Destructor function to destroy the handler object. + * @param lookup Callback function to get the status of one DICOM instance. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterStorageCommitmentScpCallback( + OrthancPluginContext* context, + OrthancPluginStorageCommitmentFactory factory, + OrthancPluginStorageCommitmentDestructor destructor, + OrthancPluginStorageCommitmentLookup lookup) + { + _OrthancPluginRegisterStorageCommitmentScpCallback params; + params.factory = factory; + params.destructor = destructor; + params.lookup = lookup; + return context->InvokeService(context, _OrthancPluginService_RegisterStorageCommitmentScpCallback, ¶ms); + } + + + + /** + * @brief Callback to filter incoming DICOM instances received by Orthanc. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives a new DICOM instance (e.g. through REST API or + * DICOM protocol), and that answers whether this DICOM instance + * should be accepted or discarded by Orthanc. + * + * Note that the metadata information is not available + * (i.e. GetInstanceMetadata() should not be used on "instance"). + * + * @warning Your callback function will be called synchronously with + * the core of Orthanc. This implies that deadlocks might emerge if + * you call other core primitives of Orthanc in your callback (such + * deadlocks are particularly visible in the presence of other plugins + * or Lua scripts). It is thus strongly advised to avoid any call to + * the REST API of Orthanc in the callback. If you have to call + * other primitives of Orthanc, you should make these calls in a + * separate thread, passing the pending events to be processed + * through a message queue. + * + * @param instance The received DICOM instance. + * @return 0 to discard the instance, 1 to store the instance, -1 if error. + * @ingroup Callbacks + **/ + typedef int32_t (*OrthancPluginIncomingDicomInstanceFilter) ( + const OrthancPluginDicomInstance* instance); + + + typedef struct + { + OrthancPluginIncomingDicomInstanceFilter callback; + } _OrthancPluginIncomingDicomInstanceFilter; + + /** + * @brief Register a callback to filter incoming DICOM instances. + * + * This function registers a custom callback to filter incoming + * DICOM instances received by Orthanc (either through the REST API + * or through the DICOM protocol). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingDicomInstanceFilter( + OrthancPluginContext* context, + OrthancPluginIncomingDicomInstanceFilter callback) + { + _OrthancPluginIncomingDicomInstanceFilter params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterIncomingDicomInstanceFilter, ¶ms); + } + + + /** + * @brief Callback to filter incoming DICOM instances received by + * Orthanc through C-STORE. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives a new DICOM instance using DICOM C-STORE, and + * that answers whether this DICOM instance should be accepted or + * discarded by Orthanc. If the instance is discarded, the callback + * can specify the DIMSE error code answered by the Orthanc C-STORE + * SCP. + * + * Note that the metadata information is not available + * (i.e. GetInstanceMetadata() should not be used on "instance"). + * + * @warning Your callback function will be called synchronously with + * the core of Orthanc. This implies that deadlocks might emerge if + * you call other core primitives of Orthanc in your callback (such + * deadlocks are particularly visible in the presence of other plugins + * or Lua scripts). It is thus strongly advised to avoid any call to + * the REST API of Orthanc in the callback. If you have to call + * other primitives of Orthanc, you should make these calls in a + * separate thread, passing the pending events to be processed + * through a message queue. + * + * @param dimseStatus If the DICOM instance is discarded, + * DIMSE status to be sent by the C-STORE SCP of Orthanc + * @param instance The received DICOM instance. + * @return 0 to discard the instance, 1 to store the instance, -1 if error. + * @ingroup Callbacks + **/ + typedef int32_t (*OrthancPluginIncomingCStoreInstanceFilter) ( + uint16_t* dimseStatus /* out */, + const OrthancPluginDicomInstance* instance); + + + typedef struct + { + OrthancPluginIncomingCStoreInstanceFilter callback; + } _OrthancPluginIncomingCStoreInstanceFilter; + + /** + * @brief Register a callback to filter incoming DICOM instances + * received by Orthanc through C-STORE. + * + * This function registers a custom callback to filter incoming + * DICOM instances received by Orthanc through the DICOM protocol. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingCStoreInstanceFilter( + OrthancPluginContext* context, + OrthancPluginIncomingCStoreInstanceFilter callback) + { + _OrthancPluginIncomingCStoreInstanceFilter params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterIncomingCStoreInstanceFilter, ¶ms); + } + + /** + * @brief Callback to keep/discard/modify a DICOM instance received + * by Orthanc from any source (C-STORE or REST API) + * + * Signature of a callback function that is triggered whenever + * Orthanc receives a new DICOM instance (through DICOM protocol or + * REST API), and that specifies an action to be applied to this + * newly received instance. The instance can be kept as it is, can + * be modified by the plugin, or can be discarded. + * + * This callback is invoked immediately after reception, i.e. before + * transcoding and before filtering + * (cf. OrthancPluginRegisterIncomingDicomInstanceFilter()). + * + * @warning Your callback function will be called synchronously with + * the core of Orthanc. This implies that deadlocks might emerge if + * you call other core primitives of Orthanc in your callback (such + * deadlocks are particularly visible in the presence of other plugins + * or Lua scripts). It is thus strongly advised to avoid any call to + * the REST API of Orthanc in the callback. If you have to call + * other primitives of Orthanc, you should make these calls in a + * separate thread, passing the pending events to be processed + * through a message queue. + * + * @param modifiedDicomBuffer A buffer containing the modified DICOM (output). + * This buffer must be allocated using OrthancPluginCreateMemoryBuffer64() + * and will be freed by the Orthanc core. + * @param receivedDicomBuffer A buffer containing the received DICOM (input). + * @param receivedDicomBufferSize The size of the received DICOM (input). + * @param origin The origin of the DICOM instance (input). + * @return `OrthancPluginReceivedInstanceAction_KeepAsIs` to accept the instance as is,
+ * `OrthancPluginReceivedInstanceAction_Modify` to store the modified DICOM contained in `modifiedDicomBuffer`,
+ * `OrthancPluginReceivedInstanceAction_Discard` to tell Orthanc to discard the instance. + * @ingroup Callbacks + **/ + typedef OrthancPluginReceivedInstanceAction (*OrthancPluginReceivedInstanceCallback) ( + OrthancPluginMemoryBuffer64* modifiedDicomBuffer, + const void* receivedDicomBuffer, + uint64_t receivedDicomBufferSize, + OrthancPluginInstanceOrigin origin); + + + typedef struct + { + OrthancPluginReceivedInstanceCallback callback; + } _OrthancPluginReceivedInstanceCallback; + + /** + * @brief Register a callback to keep/discard/modify a DICOM instance received + * by Orthanc from any source (C-STORE or REST API) + * + * This function registers a custom callback to keep/discard/modify + * incoming DICOM instances received by Orthanc from any source + * (C-STORE or REST API). + * + * @warning Contrarily to + * OrthancPluginRegisterIncomingCStoreInstanceFilter() and + * OrthancPluginRegisterIncomingDicomInstanceFilter() that can be + * called by multiple plugins, + * OrthancPluginRegisterReceivedInstanceCallback() can only be used + * by one single plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterReceivedInstanceCallback( + OrthancPluginContext* context, + OrthancPluginReceivedInstanceCallback callback) + { + _OrthancPluginReceivedInstanceCallback params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterReceivedInstanceCallback, ¶ms); + } + + /** + * @brief Get the transfer syntax of a DICOM file. + * + * This function returns a pointer to a newly created string that + * contains the transfer syntax UID of the DICOM instance. The empty + * string might be returned if this information is unknown. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The NULL value in case of error, or a string containing the + * transfer syntax UID. This string must be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceTransferSyntaxUid( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultStringToFree = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceTransferSyntaxUid, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Check whether the DICOM file has pixel data. + * + * This function returns a Boolean value indicating whether the + * DICOM instance contains the pixel data (7FE0,0010) tag. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return "1" if the DICOM instance contains pixel data, or "0" if + * the tag is missing, or "-1" in the case of an error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE int32_t OrthancPluginHasInstancePixelData( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + int64_t hasPixelData; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultInt64 = &hasPixelData; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_HasInstancePixelData, ¶ms) != OrthancPluginErrorCode_Success || + hasPixelData < 0 || + hasPixelData > 1) + { + /* Error */ + return -1; + } + else + { + return (hasPixelData != 0); + } + } + + + + + + + typedef struct + { + OrthancPluginDicomInstance** target; + const void* buffer; + uint32_t size; + const char* transferSyntax; + } _OrthancPluginCreateDicomInstance; + + /** + * @brief Parse a DICOM instance. + * + * This function parses a memory buffer that contains a DICOM + * file. The function returns a new pointer to a data structure that + * is managed by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The memory buffer containing the DICOM instance. + * @param size The size of the memory buffer. + * @return The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginDicomInstance* OrthancPluginCreateDicomInstance( + OrthancPluginContext* context, + const void* buffer, + uint32_t size) + { + OrthancPluginDicomInstance* target = NULL; + + _OrthancPluginCreateDicomInstance params; + params.target = ⌖ + params.buffer = buffer; + params.size = size; + + if (context->InvokeService(context, _OrthancPluginService_CreateDicomInstance, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + typedef struct + { + OrthancPluginDicomInstance* dicom; + } _OrthancPluginFreeDicomInstance; + + /** + * @brief Free a DICOM instance. + * + * This function frees a DICOM instance that was parsed using + * OrthancPluginCreateDicomInstance(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param dicom The DICOM instance. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeDicomInstance( + OrthancPluginContext* context, + OrthancPluginDicomInstance* dicom) + { + _OrthancPluginFreeDicomInstance params; + params.dicom = dicom; + + context->InvokeService(context, _OrthancPluginService_FreeDicomInstance, ¶ms); + } + + + typedef struct + { + uint32_t* targetUint32; + OrthancPluginMemoryBuffer* targetBuffer; + OrthancPluginImage** targetImage; + char** targetStringToFree; + const OrthancPluginDicomInstance* instance; + uint32_t frameIndex; + OrthancPluginDicomToJsonFormat format; + OrthancPluginDicomToJsonFlags flags; + uint32_t maxStringLength; + OrthancPluginDicomWebBinaryCallback2 dicomWebCallback; + void* dicomWebPayload; + } _OrthancPluginAccessDicomInstance2; + + /** + * @brief Get the number of frames in a DICOM instance. + * + * This function returns the number of frames that are part of a + * DICOM image managed by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The number of frames (will be zero in the case of an error). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetInstanceFramesCount( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + uint32_t count; + + _OrthancPluginAccessDicomInstance2 params; + memset(¶ms, 0, sizeof(params)); + params.targetUint32 = &count; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceFramesCount, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return count; + } + } + + + /** + * @brief Get the raw content of a frame in a DICOM instance. + * + * This function returns a memory buffer containing the raw content + * of a frame in a DICOM instance that is managed by the Orthanc + * core. This is notably useful for compressed transfer syntaxes, as + * it gives access to the embedded files (such as JPEG, JPEG-LS or + * JPEG2k). The Orthanc core transparently reassembles the fragments + * to extract the raw frame. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param instance The instance of interest. + * @param frameIndex The index of the frame of interest. + * @return 0 if success, or the error code if failure. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetInstanceRawFrame( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const OrthancPluginDicomInstance* instance, + uint32_t frameIndex) + { + _OrthancPluginAccessDicomInstance2 params; + memset(¶ms, 0, sizeof(params)); + params.targetBuffer = target; + params.instance = instance; + params.frameIndex = frameIndex; + + return context->InvokeService(context, _OrthancPluginService_GetInstanceRawFrame, ¶ms); + } + + + /** + * @brief Decode one frame from a DICOM instance. + * + * This function decodes one frame of a DICOM image that is managed + * by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @param frameIndex The index of the frame of interest. + * @return The uncompressed image. It must be freed with OrthancPluginFreeImage(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginGetInstanceDecodedFrame( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + uint32_t frameIndex) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginAccessDicomInstance2 params; + memset(¶ms, 0, sizeof(params)); + params.targetImage = ⌖ + params.instance = instance; + params.frameIndex = frameIndex; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceDecodedFrame, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Parse and transcode a DICOM instance. + * + * This function parses a memory buffer that contains a DICOM file, + * then transcodes it to the given transfer syntax. The function + * returns a new pointer to a data structure that is managed by the + * Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The memory buffer containing the DICOM instance. + * @param size The size of the memory buffer. + * @param transferSyntax The transfer syntax UID for the transcoding. + * @return The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginDicomInstance* OrthancPluginTranscodeDicomInstance( + OrthancPluginContext* context, + const void* buffer, + uint32_t size, + const char* transferSyntax) + { + OrthancPluginDicomInstance* target = NULL; + + _OrthancPluginCreateDicomInstance params; + params.target = ⌖ + params.buffer = buffer; + params.size = size; + params.transferSyntax = transferSyntax; + + if (context->InvokeService(context, _OrthancPluginService_TranscodeDicomInstance, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + /** + * @brief Writes a DICOM instance to a memory buffer. + * + * This function returns a memory buffer containing the + * serialization of a DICOM instance that is managed by the Orthanc + * core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param instance The instance of interest. + * @return 0 if success, or the error code if failure. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSerializeDicomInstance( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const OrthancPluginDicomInstance* instance) + { + _OrthancPluginAccessDicomInstance2 params; + memset(¶ms, 0, sizeof(params)); + params.targetBuffer = target; + params.instance = instance; + + return context->InvokeService(context, _OrthancPluginService_SerializeDicomInstance, ¶ms); + } + + + /** + * @brief Format a DICOM memory buffer as a JSON string. + * + * This function takes as DICOM instance managed by the Orthanc + * core, and outputs a JSON string representing the tags of this + * DICOM file. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The DICOM instance of interest. + * @param format The output format. + * @param flags Flags governing the output. + * @param maxStringLength The maximum length of a field. Too long fields will + * be output as "null". The 0 value means no maximum length. + * @return The NULL value if the case of an error, or the JSON + * string. This string must be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + * @see OrthancPluginDicomBufferToJson() + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceAdvancedJson( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + OrthancPluginDicomToJsonFormat format, + OrthancPluginDicomToJsonFlags flags, + uint32_t maxStringLength) + { + char* result = NULL; + + _OrthancPluginAccessDicomInstance2 params; + memset(¶ms, 0, sizeof(params)); + params.targetStringToFree = &result; + params.instance = instance; + params.format = format; + params.flags = flags; + params.maxStringLength = maxStringLength; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceAdvancedJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Convert a DICOM instance to DICOMweb JSON. + * + * This function converts a DICOM instance that is managed by the + * Orthanc core, into its DICOMweb JSON representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The DICOM instance of interest. + * @param callback Callback to set the value of the binary tags. + * @param payload User payload. + * @return The NULL value in case of error, or the JSON document. This string must + * be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceDicomWebJson( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + OrthancPluginDicomWebBinaryCallback2 callback, + void* payload) + { + char* target = NULL; + + _OrthancPluginAccessDicomInstance2 params; + params.targetStringToFree = ⌖ + params.instance = instance; + params.dicomWebCallback = callback; + params.dicomWebPayload = payload; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceDicomWebJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Convert a DICOM instance to DICOMweb XML. + * + * This function converts a DICOM instance that is managed by the + * Orthanc core, into its DICOMweb XML representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The DICOM instance of interest. + * @param callback Callback to set the value of the binary tags. + * @param payload User payload. + * @return The NULL value in case of error, or the XML document. This string must + * be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceDicomWebXml( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + OrthancPluginDicomWebBinaryCallback2 callback, + void* payload) + { + char* target = NULL; + + _OrthancPluginAccessDicomInstance2 params; + params.targetStringToFree = ⌖ + params.instance = instance; + params.dicomWebCallback = callback; + params.dicomWebPayload = payload; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceDicomWebXml, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + + /** + * @brief Signature of a callback function to transcode a DICOM instance. + * @param transcoded Target memory buffer. It must be allocated by the + * plugin using OrthancPluginCreateMemoryBuffer(). + * @param buffer Memory buffer containing the source DICOM instance. + * @param size Size of the source memory buffer. + * @param allowedSyntaxes A C array of possible transfer syntaxes UIDs for the + * result of the transcoding. The plugin must choose by itself the + * transfer syntax that will be used for the resulting DICOM image. + * @param countSyntaxes The number of transfer syntaxes that are contained + * in the "allowedSyntaxes" array. + * @param allowNewSopInstanceUid Whether the transcoding plugin can select + * a transfer syntax that will change the SOP instance UID (or, in other + * terms, whether the plugin can transcode using lossy compression). + * @return 0 if success (i.e. image successfully transcoded and stored into + * "transcoded"), or the error code if failure. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginTranscoderCallback) ( + OrthancPluginMemoryBuffer* transcoded /* out */, + const void* buffer, + uint64_t size, + const char* const* allowedSyntaxes, + uint32_t countSyntaxes, + uint8_t allowNewSopInstanceUid); + + + typedef struct + { + OrthancPluginTranscoderCallback callback; + } _OrthancPluginTranscoderCallback; + + /** + * @brief Register a callback to handle the transcoding of DICOM images. + * + * This function registers a custom callback to transcode DICOM + * images, extending the built-in transcoder of Orthanc that uses + * DCMTK. The exact behavior is affected by the configuration option + * "BuiltinDecoderTranscoderOrder" of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterTranscoderCallback( + OrthancPluginContext* context, + OrthancPluginTranscoderCallback callback) + { + _OrthancPluginTranscoderCallback params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterTranscoderCallback, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + uint32_t size; + } _OrthancPluginCreateMemoryBuffer; + + /** + * @brief Create a 32-bit memory buffer. + * + * This function creates a memory buffer that is managed by the + * Orthanc core. The main use case of this function is for plugins + * that act as DICOM transcoders. + * + * Your plugin should never call "free()" on the resulting memory + * buffer, as the C library that is used by the plugin is in general + * not the same as the one used by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param size Size of the memory buffer to be created. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateMemoryBuffer( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + uint32_t size) + { + _OrthancPluginCreateMemoryBuffer params; + params.target = target; + params.size = size; + + return context->InvokeService(context, _OrthancPluginService_CreateMemoryBuffer, ¶ms); + } + + + /** + * @brief Generate a token to grant full access to the REST API of Orthanc. + * + * This function generates a token that can be set in the HTTP + * header "Authorization" so as to grant full access to the REST API + * of Orthanc using an external HTTP client. Using this function + * avoids the need of adding a separate user in the + * "RegisteredUsers" configuration of Orthanc, which eases + * deployments. + * + * This feature is notably useful in multiprocess scenarios, where a + * subprocess created by a plugin has no access to the + * "OrthancPluginContext", and thus cannot call + * "OrthancPluginRestApi[Get|Post|Put|Delete]()". + * + * This situation is frequently encountered in Python plugins, where + * the "multiprocessing" package can be used to bypass the Global + * Interpreter Lock (GIL) and thus to improve performance and + * concurrency. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return The authorization token, or NULL value in the case of an error. + * This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGenerateRestApiAuthorizationToken( + OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GenerateRestApiAuthorizationToken, + ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginMemoryBuffer64* target; + uint64_t size; + } _OrthancPluginCreateMemoryBuffer64; + + /** + * @brief Create a 64-bit memory buffer. + * + * This function creates a 64-bit memory buffer that is managed by + * the Orthanc core. The main use case of this function is for + * plugins that read files from the storage area. + * + * Your plugin should never call "free()" on the resulting memory + * buffer, as the C library that is used by the plugin is in general + * not the same as the one used by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param size Size of the memory buffer to be created. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateMemoryBuffer64( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer64* target, + uint64_t size) + { + _OrthancPluginCreateMemoryBuffer64 params; + params.target = target; + params.size = size; + + return context->InvokeService(context, _OrthancPluginService_CreateMemoryBuffer64, ¶ms); + } + + + typedef struct + { + OrthancPluginStorageCreate create; + OrthancPluginStorageReadWhole readWhole; + OrthancPluginStorageReadRange readRange; + OrthancPluginStorageRemove remove; + } _OrthancPluginRegisterStorageArea2; + + /** + * @brief Register a custom storage area, with support for range request. + * + * This function registers a custom storage area, to replace the + * built-in way Orthanc stores its files on the filesystem. This + * function must be called during the initialization of the plugin, + * i.e. inside the OrthancPluginInitialize() public function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param create The callback function to store a file on the custom storage area. + * @param readWhole The callback function to read a whole file from the custom storage area. + * @param readRange The callback function to read some range of a file from the custom storage area. + * If this feature is not supported by the plugin, this value can be set to NULL. + * @param remove The callback function to remove a file from the custom storage area. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterStorageArea2( + OrthancPluginContext* context, + OrthancPluginStorageCreate create, + OrthancPluginStorageReadWhole readWhole, + OrthancPluginStorageReadRange readRange, + OrthancPluginStorageRemove remove) + { + _OrthancPluginRegisterStorageArea2 params; + params.create = create; + params.readWhole = readWhole; + params.readRange = readRange; + params.remove = remove; + context->InvokeService(context, _OrthancPluginService_RegisterStorageArea2, ¶ms); + } + + + + typedef struct + { + _OrthancPluginCreateDicom createDicom; + const char* privateCreator; + } _OrthancPluginCreateDicom2; + + /** + * @brief Create a DICOM instance from a JSON string and an image, with a private creator. + * + * This function takes as input a string containing a JSON file + * describing the content of a DICOM instance. As an output, it + * writes the corresponding DICOM instance to a newly allocated + * memory buffer. Additionally, an image to be encoded within the + * DICOM instance can also be provided. + * + * Contrarily to the function OrthancPluginCreateDicom(), this + * function can be explicitly provided with a private creator. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param json The input JSON file. + * @param pixelData The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme. + * @param flags Flags governing the output. + * @param privateCreator The private creator to be used for the private DICOM tags. + * Check out the global configuration option "Dictionary" of Orthanc. + * @return 0 if success, other value if error. + * @ingroup Toolbox + * @see OrthancPluginCreateDicom() + * @see OrthancPluginDicomBufferToJson() + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateDicom2( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* json, + const OrthancPluginImage* pixelData, + OrthancPluginCreateDicomFlags flags, + const char* privateCreator) + { + _OrthancPluginCreateDicom2 params; + params.createDicom.target = target; + params.createDicom.json = json; + params.createDicom.pixelData = pixelData; + params.createDicom.flags = flags; + params.privateCreator = privateCreator; + + return context->InvokeService(context, _OrthancPluginService_CreateDicom2, ¶ms); + } + + + + + + + typedef struct + { + OrthancPluginMemoryBuffer* answerBody; + OrthancPluginMemoryBuffer* answerHeaders; + uint16_t* httpStatus; + OrthancPluginHttpMethod method; + const char* uri; + uint32_t headersCount; + const char* const* headersKeys; + const char* const* headersValues; + const void* body; + uint32_t bodySize; + uint8_t afterPlugins; + } _OrthancPluginCallRestApi; + + /** + * @brief Call the REST API of Orthanc with full flexibility. + * + * Make a call to the given URI in the REST API of Orthanc. The + * result to the query is stored into a newly allocated memory + * buffer. This function is always granted full access to the REST + * API (no credentials, nor security token is needed). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answerBody The target memory buffer (out argument). + * It must be freed with OrthancPluginFreeMemoryBuffer(). + * The value of this argument is ignored if the HTTP method is DELETE. + * @param answerHeaders The target memory buffer for the HTTP headers in the answer (out argument). + * The answer headers are formatted as a JSON object (associative array). + * The buffer must be freed with OrthancPluginFreeMemoryBuffer(). + * This argument can be set to NULL if the plugin has no interest in the answer HTTP headers. + * @param httpStatus The HTTP status after the execution of the request (out argument). + * @param method HTTP method to be used. + * @param uri The URI of interest. + * @param headersCount The number of HTTP headers. + * @param headersKeys Array containing the keys of the HTTP headers (can be NULL if no header). + * @param headersValues Array containing the values of the HTTP headers (can be NULL if no header). + * @param body The HTTP body for a POST or PUT request. + * @param bodySize The size of the body. + * @param afterPlugins If 0, the built-in API of Orthanc is used. + * If 1, the API is tainted by the plugins. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginRestApiGet2(), OrthancPluginRestApiPost(), OrthancPluginRestApiPut(), OrthancPluginRestApiDelete() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCallRestApi( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* answerBody, + OrthancPluginMemoryBuffer* answerHeaders, + uint16_t* httpStatus, + OrthancPluginHttpMethod method, + const char* uri, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues, + const void* body, + uint32_t bodySize, + uint8_t afterPlugins) + { + _OrthancPluginCallRestApi params; + memset(¶ms, 0, sizeof(params)); + + params.answerBody = answerBody; + params.answerHeaders = answerHeaders; + params.httpStatus = httpStatus; + params.method = method; + params.uri = uri; + params.headersCount = headersCount; + params.headersKeys = headersKeys; + params.headersValues = headersValues; + params.body = body; + params.bodySize = bodySize; + params.afterPlugins = afterPlugins; + + return context->InvokeService(context, _OrthancPluginService_CallRestApi, ¶ms); + } + + + + /** + * @brief Opaque structure that represents a WebDAV collection. + * @ingroup Callbacks + **/ + typedef struct _OrthancPluginWebDavCollection_t OrthancPluginWebDavCollection; + + + /** + * @brief Declare a file while returning the content of a folder. + * + * This function declares a file while returning the content of a + * WebDAV folder. + * + * @param collection Context of the collection. + * @param name Base name of the file. + * @param dateTime The date and time of creation of the file. + * Check out the documentation of OrthancPluginWebDavRetrieveFile() for more information. + * @param size Size of the file. + * @param mimeType The MIME type of the file. If empty or set to `NULL`, + * Orthanc will do a best guess depending on the file extension. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavAddFile) ( + OrthancPluginWebDavCollection* collection, + const char* name, + uint64_t size, + const char* mimeType, + const char* dateTime); + + + /** + * @brief Declare a subfolder while returning the content of a folder. + * + * This function declares a subfolder while returning the content of a + * WebDAV folder. + * + * @param collection Context of the collection. + * @param name Base name of the subfolder. + * @param dateTime The date and time of creation of the subfolder. + * Check out the documentation of OrthancPluginWebDavRetrieveFile() for more information. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavAddFolder) ( + OrthancPluginWebDavCollection* collection, + const char* name, + const char* dateTime); + + + /** + * @brief Retrieve the content of a file. + * + * This function is used to forward the content of a file from a + * WebDAV collection, to the core of Orthanc. + * + * @param collection Context of the collection. + * @param data Content of the file. + * @param size Size of the file. + * @param mimeType The MIME type of the file. If empty or set to `NULL`, + * Orthanc will do a best guess depending on the file extension. + * @param dateTime The date and time of creation of the file. + * It must be formatted as an ISO string of form + * `YYYYMMDDTHHMMSS,fffffffff` where T is the date-time + * separator. It must be expressed in UTC (it is the responsibility + * of the plugin to do the possible timezone + * conversions). Internally, this string will be parsed using + * `boost::posix_time::from_iso_string()`. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavRetrieveFile) ( + OrthancPluginWebDavCollection* collection, + const void* data, + uint64_t size, + const char* mimeType, + const char* dateTime); + + + /** + * @brief Callback for testing the existence of a folder. + * + * Signature of a callback function that tests whether the given + * path in the WebDAV collection exists and corresponds to a folder. + * + * @param isExisting Pointer to a Boolean that must be set to `1` if the folder exists, or `0` otherwise. + * @param pathSize Number of levels in the path. + * @param pathItems Items making the path. + * @param payload The user payload. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavIsExistingFolderCallback) ( + uint8_t* isExisting, /* out */ + uint32_t pathSize, + const char* const* pathItems, + void* payload); + + + /** + * @brief Callback for listing the content of a folder. + * + * Signature of a callback function that lists the content of a + * folder in the WebDAV collection. The callback must call the + * provided `addFile()` and `addFolder()` functions to emit the + * content of the folder. + * + * @param isExisting Pointer to a Boolean that must be set to `1` if the folder exists, or `0` otherwise. + * @param collection Context to be provided to `addFile()` and `addFolder()` functions. + * @param addFile Function to add a file to the list. + * @param addFolder Function to add a folder to the list. + * @param pathSize Number of levels in the path. + * @param pathItems Items making the path. + * @param payload The user payload. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavListFolderCallback) ( + uint8_t* isExisting, /* out */ + OrthancPluginWebDavCollection* collection, + OrthancPluginWebDavAddFile addFile, + OrthancPluginWebDavAddFolder addFolder, + uint32_t pathSize, + const char* const* pathItems, + void* payload); + + + /** + * @brief Callback for retrieving the content of a file. + * + * Signature of a callback function that retrieves the content of a + * file in the WebDAV collection. The callback must call the + * provided `retrieveFile()` function to emit the actual content of + * the file. + * + * @param collection Context to be provided to `retrieveFile()` function. + * @param retrieveFile Function to return the content of the file. + * @param pathSize Number of levels in the path. + * @param pathItems Items making the path. + * @param payload The user payload. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavRetrieveFileCallback) ( + OrthancPluginWebDavCollection* collection, + OrthancPluginWebDavRetrieveFile retrieveFile, + uint32_t pathSize, + const char* const* pathItems, + void* payload); + + + /** + * @brief Callback to store a file. + * + * Signature of a callback function that stores a file into the + * WebDAV collection. + * + * @param isReadOnly Pointer to a Boolean that must be set to `1` if the collection is read-only, or `0` otherwise. + * @param pathSize Number of levels in the path. + * @param pathItems Items making the path. + * @param data Content of the file to be stored. + * @param size Size of the file to be stored. + * @param payload The user payload. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavStoreFileCallback) ( + uint8_t* isReadOnly, /* out */ + uint32_t pathSize, + const char* const* pathItems, + const void* data, + uint64_t size, + void* payload); + + + /** + * @brief Callback to create a folder. + * + * Signature of a callback function that creates a folder in the + * WebDAV collection. + * + * @param isReadOnly Pointer to a Boolean that must be set to `1` if the collection is read-only, or `0` otherwise. + * @param pathSize Number of levels in the path. + * @param pathItems Items making the path. + * @param payload The user payload. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavCreateFolderCallback) ( + uint8_t* isReadOnly, /* out */ + uint32_t pathSize, + const char* const* pathItems, + void* payload); + + + /** + * @brief Callback to remove a file or a folder. + * + * Signature of a callback function that removes a file or a folder + * from the WebDAV collection. + * + * @param isReadOnly Pointer to a Boolean that must be set to `1` if the collection is read-only, or `0` otherwise. + * @param pathSize Number of levels in the path. + * @param pathItems Items making the path. + * @param payload The user payload. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavDeleteItemCallback) ( + uint8_t* isReadOnly, /* out */ + uint32_t pathSize, + const char* const* pathItems, + void* payload); + + + typedef struct + { + const char* uri; + OrthancPluginWebDavIsExistingFolderCallback isExistingFolder; + OrthancPluginWebDavListFolderCallback listFolder; + OrthancPluginWebDavRetrieveFileCallback retrieveFile; + OrthancPluginWebDavStoreFileCallback storeFile; + OrthancPluginWebDavCreateFolderCallback createFolder; + OrthancPluginWebDavDeleteItemCallback deleteItem; + void* payload; + } _OrthancPluginRegisterWebDavCollection; + + /** + * @brief Register a WebDAV virtual filesystem. + * + * This function maps a WebDAV collection onto the given URI in the + * REST API of Orthanc. This function must be called during the + * initialization of the plugin, i.e. inside the + * OrthancPluginInitialize() public function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param uri URI where to map the WebDAV collection (must start with a `/` character). + * @param isExistingFolder Callback method to test for the existence of a folder. + * @param listFolder Callback method to list the content of a folder. + * @param retrieveFile Callback method to retrieve the content of a file. + * @param storeFile Callback method to store a file into the WebDAV collection. + * @param createFolder Callback method to create a folder. + * @param deleteItem Callback method to delete a file or a folder. + * @param payload The user payload. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterWebDavCollection( + OrthancPluginContext* context, + const char* uri, + OrthancPluginWebDavIsExistingFolderCallback isExistingFolder, + OrthancPluginWebDavListFolderCallback listFolder, + OrthancPluginWebDavRetrieveFileCallback retrieveFile, + OrthancPluginWebDavStoreFileCallback storeFile, + OrthancPluginWebDavCreateFolderCallback createFolder, + OrthancPluginWebDavDeleteItemCallback deleteItem, + void* payload) + { + _OrthancPluginRegisterWebDavCollection params; + params.uri = uri; + params.isExistingFolder = isExistingFolder; + params.listFolder = listFolder; + params.retrieveFile = retrieveFile; + params.storeFile = storeFile; + params.createFolder = createFolder; + params.deleteItem = deleteItem; + params.payload = payload; + + return context->InvokeService(context, _OrthancPluginService_RegisterWebDavCollection, ¶ms); + } + + + /** + * @brief Gets the DatabaseServerIdentifier. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return the database server identifier. This is a statically-allocated + * string, do not free it. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetDatabaseServerIdentifier( + OrthancPluginContext* context) + { + const char* result; + + _OrthancPluginRetrieveStaticString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetDatabaseServerIdentifier, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Signature of a callback function that is triggered when + * the Orthanc core requests an operation from the database plugin. + * Both request and response are encoded as protobuf buffers. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginCallDatabaseBackendV4) ( + OrthancPluginMemoryBuffer64* response, + void* backend, + const void* request, + uint64_t requestSize); + + /** + * @brief Signature of a callback function that is triggered when + * the database plugin must be finalized. + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginFinalizeDatabaseBackendV4) (void* backend); + + typedef struct + { + void* backend; + uint32_t maxDatabaseRetries; + OrthancPluginCallDatabaseBackendV4 operations; + OrthancPluginFinalizeDatabaseBackendV4 finalize; + } _OrthancPluginRegisterDatabaseBackendV4; + + /** + * @brief Register a custom database back-end. + * + * This function was added in Orthanc SDK 1.12.0. It uses Google + * Protocol Buffers for the communications between the Orthanc core + * and database plugins. Check out "OrthancDatabasePlugin.proto" for + * the definition of the protobuf messages. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param backend Pointer to the custom database backend. + * @param maxDatabaseRetries Maximum number of retries if transaction doesn't succeed. + * If no retry is successful, OrthancPluginErrorCode_DatabaseCannotSerialize is generated. + * @param operations Access to the operations of the custom database backend. + * @param finalize Callback to deallocate the custom database backend. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDatabaseBackendV4( + OrthancPluginContext* context, + void* backend, + uint32_t maxDatabaseRetries, + OrthancPluginCallDatabaseBackendV4 operations, + OrthancPluginFinalizeDatabaseBackendV4 finalize) + { + _OrthancPluginRegisterDatabaseBackendV4 params; + params.backend = backend; + params.maxDatabaseRetries = maxDatabaseRetries; + params.operations = operations; + params.finalize = finalize; + + return context->InvokeService(context, _OrthancPluginService_RegisterDatabaseBackendV4, ¶ms); + } + + + typedef struct + { + OrthancPluginDicomInstance** target; + const char* instanceId; + OrthancPluginLoadDicomInstanceMode mode; + } _OrthancPluginLoadDicomInstance; + + /** + * @brief Load a DICOM instance from the Orthanc server. + * + * This function loads a DICOM instance from the content of the + * Orthanc database. The function returns a new pointer to a data + * structure that is managed by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instanceId The Orthanc identifier of the DICOM instance of interest. + * @param mode Flag specifying how to deal with pixel data. + * @return The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginDicomInstance* OrthancPluginLoadDicomInstance( + OrthancPluginContext* context, + const char* instanceId, + OrthancPluginLoadDicomInstanceMode mode) + { + OrthancPluginDicomInstance* target = NULL; + + _OrthancPluginLoadDicomInstance params; + params.target = ⌖ + params.instanceId = instanceId; + params.mode = mode; + + if (context->InvokeService(context, _OrthancPluginService_LoadDicomInstance, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + typedef struct + { + const char* name; + int64_t value; + OrthancPluginMetricsType type; + } _OrthancPluginSetMetricsIntegerValue; + + /** + * @brief Set the value of an integer metrics. + * + * This function sets the value of an integer metrics to monitor the + * behavior of the plugin through tools such as Prometheus. The + * values of all the metrics are stored within the Orthanc context. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param name The name of the metrics to be set. + * @param value The value of the metrics. + * @param type The type of the metrics. This parameter is only taken into consideration + * the first time this metrics is set. + * @ingroup Toolbox + * @see OrthancPluginSetMetricsValue() + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetMetricsIntegerValue( + OrthancPluginContext* context, + const char* name, + int64_t value, + OrthancPluginMetricsType type) + { + _OrthancPluginSetMetricsIntegerValue params; + params.name = name; + params.value = value; + params.type = type; + context->InvokeService(context, _OrthancPluginService_SetMetricsIntegerValue, ¶ms); + } + + + /** + * @brief Set the name of the current thread. + * + * This function gives a name to the thread that is calling this + * function. This name is used in the Orthanc logs. This function + * must only be called from threads that the plugin has created + * itself. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param threadName The name of the current thread. A thread name cannot be longer than 16 characters. + * @return 0 if success, other value if error. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSetCurrentThreadName( + OrthancPluginContext* context, + const char* threadName) + { + return context->InvokeService(context, _OrthancPluginService_SetCurrentThreadName, threadName); + } + + + typedef struct + { + /* Note: This structure is also defined in Logging.h and it must be binary compatible */ + const char* message; + const char* plugin; + const char* file; + uint32_t line; + OrthancPluginLogCategory category; + OrthancPluginLogLevel level; + } _OrthancPluginLogMessage; + + + /** + * @brief Log a message. + * + * Log a message using the Orthanc logging system. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param message The message to be logged. + * @param plugin The plugin name. + * @param file The filename in the plugin code. + * @param line The file line in the plugin code. + * @param category The category. + * @param level The level of the message. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginLogMessage( + OrthancPluginContext* context, + const char* message, + const char* plugin, + const char* file, + uint32_t line, + OrthancPluginLogCategory category, + OrthancPluginLogLevel level) + { + _OrthancPluginLogMessage m; + m.message = message; + m.plugin = plugin; + m.file = file; + m.line = line; + m.category = category; + m.level = level; + context->InvokeService(context, _OrthancPluginService_LogMessage, &m); + } + + + typedef struct + { + OrthancPluginRestOutput* output; + const char* contentType; + } _OrthancPluginStartStreamAnswer; + + /** + * @brief Start an HTTP stream answer. + * + * Initiates an HTTP stream answer, as the result of a REST request. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param contentType The MIME type of the items in the stream answer. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginSendStreamChunk() + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStartStreamAnswer( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* contentType) + { + _OrthancPluginStartStreamAnswer params; + params.output = output; + params.contentType = contentType; + return context->InvokeService(context, _OrthancPluginService_StartStreamAnswer, ¶ms); + } + + + /** + * @brief Send a chunk as a part of an HTTP stream answer. + * + * This function sends a chunk as part of an HTTP stream + * answer that was initiated by OrthancPluginStartStreamAnswer(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param answer Pointer to the memory buffer containing the item. + * @param answerSize Number of bytes of the item. + * @return 0 if success, or the error code if failure (this notably happens + * if the connection is closed by the client). + * @see OrthancPluginStartStreamAnswer() + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSendStreamChunk( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const void* answer, + uint32_t answerSize) + { + _OrthancPluginAnswerBuffer params; + params.output = output; + params.answer = answer; + params.answerSize = answerSize; + params.mimeType = NULL; + return context->InvokeService(context, _OrthancPluginService_SendStreamChunk, ¶ms); + } + + +#ifdef __cplusplus +} +#endif + + +/** @} */ + diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Orthanc/Sdk-1.12.9/orthanc/OrthancCPlugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Orthanc/Sdk-1.12.9/orthanc/OrthancCPlugin.h Wed Aug 13 12:02:04 2025 +0200 @@ -0,0 +1,10711 @@ +/** + * \mainpage + * + * This C/C++ SDK allows external developers to create plugins that + * can be loaded into Orthanc to extend its functionality. Each + * Orthanc plugin must expose 4 public functions with the following + * signatures: + * + * -# int32_t OrthancPluginInitialize(const OrthancPluginContext* context): + * This function is invoked by Orthanc when it loads the plugin on startup. + * The plugin must: + * - Check its compatibility with the Orthanc version using + * ::OrthancPluginCheckVersion(). + * - Store the context pointer so that it can use the plugin + * services of Orthanc. + * - Register all its REST callbacks using ::OrthancPluginRegisterRestCallback(). + * - Possibly register its callback for received DICOM instances using ::OrthancPluginRegisterOnStoredInstanceCallback(). + * - Possibly register its callback for changes to the DICOM store using ::OrthancPluginRegisterOnChangeCallback(). + * - Possibly register a custom storage area using ::OrthancPluginRegisterStorageArea3(). + * - Possibly register a custom database back-end area using OrthancPluginRegisterDatabaseBackendV4(). + * - Possibly register a handler for C-Find SCP using OrthancPluginRegisterFindCallback(). + * - Possibly register a handler for C-Find SCP against DICOM worklists using OrthancPluginRegisterWorklistCallback(). + * - Possibly register a handler for C-Move SCP using OrthancPluginRegisterMoveCallback(). + * - Possibly register a custom decoder for DICOM images using OrthancPluginRegisterDecodeImageCallback(). + * - Possibly register a callback to filter incoming HTTP requests using OrthancPluginRegisterIncomingHttpRequestFilter2(). + * - Possibly register a callback to unserialize jobs using OrthancPluginRegisterJobsUnserializer(). + * - Possibly register a callback to refresh its metrics using OrthancPluginRegisterRefreshMetricsCallback(). + * - Possibly register a callback to answer chunked HTTP transfers using ::OrthancPluginRegisterChunkedRestCallback(). + * - Possibly register a callback for Storage Commitment SCP using ::OrthancPluginRegisterStorageCommitmentScpCallback(). + * - Possibly register a callback to keep/discard/modify incoming DICOM instances using OrthancPluginRegisterReceivedInstanceCallback(). + * - Possibly register a custom transcoder for DICOM images using OrthancPluginRegisterTranscoderCallback(). + * - Possibly register a callback to discard instances received through DICOM C-STORE using OrthancPluginRegisterIncomingCStoreInstanceFilter(). + * - Possibly register a callback to branch a WebDAV virtual filesystem using OrthancPluginRegisterWebDavCollection(). + * - Possibly register a callback to authenticate HTTP requests using OrthancPluginRegisterHttpAuthentication(). + * - Possibly register a callback to store audit logs using OrthancPluginRegisterAuditLogHandler(). + * -# void OrthancPluginFinalize(): + * This function is invoked by Orthanc during its shutdown. The plugin + * must free all its memory. + * -# const char* OrthancPluginGetName(): + * The plugin must return a short string to identify itself. + * -# const char* OrthancPluginGetVersion(): + * The plugin must return a string containing its version number. + * + * The name and the version of a plugin is only used to prevent it + * from being loaded twice. Note that, in C++, it is mandatory to + * declare these functions within an extern "C" section. + * + * To ensure multi-threading safety, the various REST callbacks are + * guaranteed to be executed in mutual exclusion since Orthanc + * 0.8.5. If this feature is undesired (notably when developing + * high-performance plugins handling simultaneous requests), use + * ::OrthancPluginRegisterRestCallbackNoLock(). + **/ + + + +/** + * @defgroup Images Images and compression + * @brief Functions to deal with images and compressed buffers. + * + * @defgroup REST REST + * @brief Functions to answer REST requests in a callback. + * + * @defgroup Callbacks Callbacks + * @brief Functions to register and manage callbacks by the plugins. + * + * @defgroup DicomCallbacks DicomCallbacks + * @brief Functions to register and manage DICOM callbacks (worklists, C-FIND, C-MOVE, storage commitment). + * + * @defgroup Orthanc Orthanc + * @brief Functions to access the content of the Orthanc server. + * + * @defgroup DicomInstance DicomInstance + * @brief Functions to access DICOM images that are managed by the Orthanc core. + **/ + + + +/** + * @defgroup Toolbox Toolbox + * @brief Generic functions to help with the creation of plugins. + **/ + + + +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2023 Osimis S.A., Belgium + * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium + * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + + +#pragma once + + +#include +#include + +#ifdef _WIN32 +# define ORTHANC_PLUGINS_API __declspec(dllexport) +#elif __GNUC__ >= 4 +# define ORTHANC_PLUGINS_API __attribute__ ((visibility ("default"))) +#else +# define ORTHANC_PLUGINS_API +#endif + +#define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 1 +#define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 12 +#define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 9 + + +#if !defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) +#define ORTHANC_PLUGINS_VERSION_IS_ABOVE(major, minor, revision) \ + (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER > major || \ + (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == major && \ + (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER > minor || \ + (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER == minor && \ + ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER >= revision)))) +#endif + + + +/******************************************************************** + ** Check that function inlining is properly supported. The use of + ** inlining is required, to avoid the duplication of object code + ** between two compilation modules that would use the Orthanc Plugin + ** API. + ********************************************************************/ + +/* If the auto-detection of the "inline" keyword below does not work + automatically and that your compiler is known to properly support + inlining, uncomment the following #define and adapt the definition + of "static inline". */ + +/* #define ORTHANC_PLUGIN_INLINE static inline */ + +#ifndef ORTHANC_PLUGIN_INLINE +# if __STDC_VERSION__ >= 199901L +/* This is C99 or above: http://predef.sourceforge.net/prestd.html */ +# define ORTHANC_PLUGIN_INLINE static inline +# elif defined(__cplusplus) +/* This is C++ */ +# define ORTHANC_PLUGIN_INLINE static inline +# elif defined(__GNUC__) +/* This is GCC running in C89 mode */ +# define ORTHANC_PLUGIN_INLINE static __inline +# elif defined(_MSC_VER) +/* This is Visual Studio running in C89 mode */ +# define ORTHANC_PLUGIN_INLINE static __inline +# else +# error Your compiler is not known to support the "inline" keyword +# endif +#endif + + +#ifndef ORTHANC_PLUGIN_DEPRECATED +# if defined(_MSC_VER) +# define ORTHANC_PLUGIN_DEPRECATED __declspec(deprecated) +# elif __GNUC__ >= 4 +# define ORTHANC_PLUGIN_DEPRECATED __attribute__ ((deprecated)) +# elif defined(__clang__) +# define ORTHANC_PLUGIN_DEPRECATED __attribute__ ((deprecated)) +# else +# pragma message("WARNING: You need to implement ORTHANC_PLUGINS_DEPRECATED for this compiler") +# define ORTHANC_PLUGIN_DEPRECATED +# endif +#endif + + +#ifndef ORTHANC_PLUGIN_SINCE_SDK +/** + * This macro is used by the code model generator that produces the + * "OrthancPluginCodeModel.json" file. The code model is notably used + * to generate the Python and Java wrappers. Primitives that are not + * tagged with this macro were introduced before Orthanc 1.0.0. + **/ +# if defined(__clang__) +# define ORTHANC_PLUGIN_SINCE_SDK(version) __attribute__ ((annotate("ORTHANC_PLUGIN_SINCE_SDK " version))) +# else +# define ORTHANC_PLUGIN_SINCE_SDK(version) +# endif +#endif + + + +/******************************************************************** + ** Inclusion of standard libraries. + ********************************************************************/ + +/** + * For Microsoft Visual Studio, a compatibility "stdint.h" can be + * downloaded at the following URL: + * https://orthanc.uclouvain.be/hg/orthanc/raw-file/default/OrthancFramework/Resources/ThirdParty/VisualStudio/stdint.h + **/ +#include + +#include + + + +/******************************************************************** + ** Definition of the Orthanc Plugin API. + ********************************************************************/ + +/** @{ */ + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * The various error codes that can be returned by the Orthanc core. + **/ + typedef enum + { + OrthancPluginErrorCode_InternalError = -1 /*!< Internal error */, + OrthancPluginErrorCode_Success = 0 /*!< Success */, + OrthancPluginErrorCode_Plugin = 1 /*!< Error encountered within the plugin engine */, + OrthancPluginErrorCode_NotImplemented = 2 /*!< Not implemented yet */, + OrthancPluginErrorCode_ParameterOutOfRange = 3 /*!< Parameter out of range */, + OrthancPluginErrorCode_NotEnoughMemory = 4 /*!< The server hosting Orthanc is running out of memory */, + OrthancPluginErrorCode_BadParameterType = 5 /*!< Bad type for a parameter */, + OrthancPluginErrorCode_BadSequenceOfCalls = 6 /*!< Bad sequence of calls */, + OrthancPluginErrorCode_InexistentItem = 7 /*!< Accessing an inexistent item */, + OrthancPluginErrorCode_BadRequest = 8 /*!< Bad request */, + OrthancPluginErrorCode_NetworkProtocol = 9 /*!< Error in the network protocol */, + OrthancPluginErrorCode_SystemCommand = 10 /*!< Error while calling a system command */, + OrthancPluginErrorCode_Database = 11 /*!< Error with the database engine */, + OrthancPluginErrorCode_UriSyntax = 12 /*!< Badly formatted URI */, + OrthancPluginErrorCode_InexistentFile = 13 /*!< Inexistent file */, + OrthancPluginErrorCode_CannotWriteFile = 14 /*!< Cannot write to file */, + OrthancPluginErrorCode_BadFileFormat = 15 /*!< Bad file format */, + OrthancPluginErrorCode_Timeout = 16 /*!< Timeout */, + OrthancPluginErrorCode_UnknownResource = 17 /*!< Unknown resource */, + OrthancPluginErrorCode_IncompatibleDatabaseVersion = 18 /*!< Incompatible version of the database */, + OrthancPluginErrorCode_FullStorage = 19 /*!< The file storage is full */, + OrthancPluginErrorCode_CorruptedFile = 20 /*!< Corrupted file (e.g. inconsistent MD5 hash) */, + OrthancPluginErrorCode_InexistentTag = 21 /*!< Inexistent tag */, + OrthancPluginErrorCode_ReadOnly = 22 /*!< Cannot modify a read-only data structure */, + OrthancPluginErrorCode_IncompatibleImageFormat = 23 /*!< Incompatible format of the images */, + OrthancPluginErrorCode_IncompatibleImageSize = 24 /*!< Incompatible size of the images */, + OrthancPluginErrorCode_SharedLibrary = 25 /*!< Error while using a shared library (plugin) */, + OrthancPluginErrorCode_UnknownPluginService = 26 /*!< Plugin invoking an unknown service */, + OrthancPluginErrorCode_UnknownDicomTag = 27 /*!< Unknown DICOM tag */, + OrthancPluginErrorCode_BadJson = 28 /*!< Cannot parse a JSON document */, + OrthancPluginErrorCode_Unauthorized = 29 /*!< Bad credentials were provided to an HTTP request */, + OrthancPluginErrorCode_BadFont = 30 /*!< Badly formatted font file */, + OrthancPluginErrorCode_DatabasePlugin = 31 /*!< The plugin implementing a custom database back-end does not fulfill the proper interface */, + OrthancPluginErrorCode_StorageAreaPlugin = 32 /*!< Error in the plugin implementing a custom storage area */, + OrthancPluginErrorCode_EmptyRequest = 33 /*!< The request is empty */, + OrthancPluginErrorCode_NotAcceptable = 34 /*!< Cannot send a response which is acceptable according to the Accept HTTP header */, + OrthancPluginErrorCode_NullPointer = 35 /*!< Cannot handle a NULL pointer */, + OrthancPluginErrorCode_DatabaseUnavailable = 36 /*!< The database is currently not available (probably a transient situation) */, + OrthancPluginErrorCode_CanceledJob = 37 /*!< This job was canceled */, + OrthancPluginErrorCode_BadGeometry = 38 /*!< Geometry error encountered in Stone */, + OrthancPluginErrorCode_SslInitialization = 39 /*!< Cannot initialize SSL encryption, check out your certificates */, + OrthancPluginErrorCode_DiscontinuedAbi = 40 /*!< Calling a function that has been removed from the Orthanc Framework */, + OrthancPluginErrorCode_BadRange = 41 /*!< Incorrect range request */, + OrthancPluginErrorCode_DatabaseCannotSerialize = 42 /*!< Database could not serialize access due to concurrent update, the transaction should be retried */, + OrthancPluginErrorCode_Revision = 43 /*!< A bad revision number was provided, which might indicate conflict between multiple writers */, + OrthancPluginErrorCode_MainDicomTagsMultiplyDefined = 44 /*!< A main DICOM Tag has been defined multiple times for the same resource level */, + OrthancPluginErrorCode_ForbiddenAccess = 45 /*!< Access to a resource is forbidden */, + OrthancPluginErrorCode_DuplicateResource = 46 /*!< Duplicate resource */, + OrthancPluginErrorCode_IncompatibleConfigurations = 47 /*!< Your configuration file contains configuration that are mutually incompatible */, + OrthancPluginErrorCode_SQLiteNotOpened = 1000 /*!< SQLite: The database is not opened */, + OrthancPluginErrorCode_SQLiteAlreadyOpened = 1001 /*!< SQLite: Connection is already open */, + OrthancPluginErrorCode_SQLiteCannotOpen = 1002 /*!< SQLite: Unable to open the database */, + OrthancPluginErrorCode_SQLiteStatementAlreadyUsed = 1003 /*!< SQLite: This cached statement is already being referred to */, + OrthancPluginErrorCode_SQLiteExecute = 1004 /*!< SQLite: Cannot execute a command */, + OrthancPluginErrorCode_SQLiteRollbackWithoutTransaction = 1005 /*!< SQLite: Rolling back a nonexistent transaction (have you called Begin()?) */, + OrthancPluginErrorCode_SQLiteCommitWithoutTransaction = 1006 /*!< SQLite: Committing a nonexistent transaction */, + OrthancPluginErrorCode_SQLiteRegisterFunction = 1007 /*!< SQLite: Unable to register a function */, + OrthancPluginErrorCode_SQLiteFlush = 1008 /*!< SQLite: Unable to flush the database */, + OrthancPluginErrorCode_SQLiteCannotRun = 1009 /*!< SQLite: Cannot run a cached statement */, + OrthancPluginErrorCode_SQLiteCannotStep = 1010 /*!< SQLite: Cannot step over a cached statement */, + OrthancPluginErrorCode_SQLiteBindOutOfRange = 1011 /*!< SQLite: Bind a value while out of range (serious error) */, + OrthancPluginErrorCode_SQLitePrepareStatement = 1012 /*!< SQLite: Cannot prepare a cached statement */, + OrthancPluginErrorCode_SQLiteTransactionAlreadyStarted = 1013 /*!< SQLite: Beginning the same transaction twice */, + OrthancPluginErrorCode_SQLiteTransactionCommit = 1014 /*!< SQLite: Failure when committing the transaction */, + OrthancPluginErrorCode_SQLiteTransactionBegin = 1015 /*!< SQLite: Cannot start a transaction */, + OrthancPluginErrorCode_DirectoryOverFile = 2000 /*!< The directory to be created is already occupied by a regular file */, + OrthancPluginErrorCode_FileStorageCannotWrite = 2001 /*!< Unable to create a subdirectory or a file in the file storage */, + OrthancPluginErrorCode_DirectoryExpected = 2002 /*!< The specified path does not point to a directory */, + OrthancPluginErrorCode_HttpPortInUse = 2003 /*!< The TCP port of the HTTP server is privileged or already in use */, + OrthancPluginErrorCode_DicomPortInUse = 2004 /*!< The TCP port of the DICOM server is privileged or already in use */, + OrthancPluginErrorCode_BadHttpStatusInRest = 2005 /*!< This HTTP status is not allowed in a REST API */, + OrthancPluginErrorCode_RegularFileExpected = 2006 /*!< The specified path does not point to a regular file */, + OrthancPluginErrorCode_PathToExecutable = 2007 /*!< Unable to get the path to the executable */, + OrthancPluginErrorCode_MakeDirectory = 2008 /*!< Cannot create a directory */, + OrthancPluginErrorCode_BadApplicationEntityTitle = 2009 /*!< An application entity title (AET) cannot be empty or be longer than 16 characters */, + OrthancPluginErrorCode_NoCFindHandler = 2010 /*!< No request handler factory for DICOM C-FIND SCP */, + OrthancPluginErrorCode_NoCMoveHandler = 2011 /*!< No request handler factory for DICOM C-MOVE SCP */, + OrthancPluginErrorCode_NoCStoreHandler = 2012 /*!< No request handler factory for DICOM C-STORE SCP */, + OrthancPluginErrorCode_NoApplicationEntityFilter = 2013 /*!< No application entity filter */, + OrthancPluginErrorCode_NoSopClassOrInstance = 2014 /*!< DicomUserConnection: Unable to find the SOP class and instance */, + OrthancPluginErrorCode_NoPresentationContext = 2015 /*!< DicomUserConnection: No acceptable presentation context for modality */, + OrthancPluginErrorCode_DicomFindUnavailable = 2016 /*!< DicomUserConnection: The C-FIND command is not supported by the remote SCP */, + OrthancPluginErrorCode_DicomMoveUnavailable = 2017 /*!< DicomUserConnection: The C-MOVE command is not supported by the remote SCP */, + OrthancPluginErrorCode_CannotStoreInstance = 2018 /*!< Cannot store an instance */, + OrthancPluginErrorCode_CreateDicomNotString = 2019 /*!< Only string values are supported when creating DICOM instances */, + OrthancPluginErrorCode_CreateDicomOverrideTag = 2020 /*!< Trying to override a value inherited from a parent module */, + OrthancPluginErrorCode_CreateDicomUseContent = 2021 /*!< Use \"Content\" to inject an image into a new DICOM instance */, + OrthancPluginErrorCode_CreateDicomNoPayload = 2022 /*!< No payload is present for one instance in the series */, + OrthancPluginErrorCode_CreateDicomUseDataUriScheme = 2023 /*!< The payload of the DICOM instance must be specified according to Data URI scheme */, + OrthancPluginErrorCode_CreateDicomBadParent = 2024 /*!< Trying to attach a new DICOM instance to an inexistent resource */, + OrthancPluginErrorCode_CreateDicomParentIsInstance = 2025 /*!< Trying to attach a new DICOM instance to an instance (must be a series, study or patient) */, + OrthancPluginErrorCode_CreateDicomParentEncoding = 2026 /*!< Unable to get the encoding of the parent resource */, + OrthancPluginErrorCode_UnknownModality = 2027 /*!< Unknown modality */, + OrthancPluginErrorCode_BadJobOrdering = 2028 /*!< Bad ordering of filters in a job */, + OrthancPluginErrorCode_JsonToLuaTable = 2029 /*!< Cannot convert the given JSON object to a Lua table */, + OrthancPluginErrorCode_CannotCreateLua = 2030 /*!< Cannot create the Lua context */, + OrthancPluginErrorCode_CannotExecuteLua = 2031 /*!< Cannot execute a Lua command */, + OrthancPluginErrorCode_LuaAlreadyExecuted = 2032 /*!< Arguments cannot be pushed after the Lua function is executed */, + OrthancPluginErrorCode_LuaBadOutput = 2033 /*!< The Lua function does not give the expected number of outputs */, + OrthancPluginErrorCode_NotLuaPredicate = 2034 /*!< The Lua function is not a predicate (only true/false outputs allowed) */, + OrthancPluginErrorCode_LuaReturnsNoString = 2035 /*!< The Lua function does not return a string */, + OrthancPluginErrorCode_StorageAreaAlreadyRegistered = 2036 /*!< Another plugin has already registered a custom storage area */, + OrthancPluginErrorCode_DatabaseBackendAlreadyRegistered = 2037 /*!< Another plugin has already registered a custom database back-end */, + OrthancPluginErrorCode_DatabaseNotInitialized = 2038 /*!< Plugin trying to call the database during its initialization */, + OrthancPluginErrorCode_SslDisabled = 2039 /*!< Orthanc has been built without SSL support */, + OrthancPluginErrorCode_CannotOrderSlices = 2040 /*!< Unable to order the slices of the series */, + OrthancPluginErrorCode_NoWorklistHandler = 2041 /*!< No request handler factory for DICOM C-Find Modality SCP */, + OrthancPluginErrorCode_AlreadyExistingTag = 2042 /*!< Cannot override the value of a tag that already exists */, + OrthancPluginErrorCode_NoStorageCommitmentHandler = 2043 /*!< No request handler factory for DICOM N-ACTION SCP (storage commitment) */, + OrthancPluginErrorCode_NoCGetHandler = 2044 /*!< No request handler factory for DICOM C-GET SCP */, + OrthancPluginErrorCode_DicomGetUnavailable = 2045 /*!< DicomUserConnection: The C-GET command is not supported by the remote SCP */, + OrthancPluginErrorCode_UnsupportedMediaType = 3000 /*!< Unsupported media type */, + + _OrthancPluginErrorCode_INTERNAL = 0x7fffffff + } OrthancPluginErrorCode; + + + /** + * Forward declaration of one of the mandatory functions for Orthanc + * plugins. + **/ + ORTHANC_PLUGINS_API const char* OrthancPluginGetName(); + + + /** + * The various HTTP methods for a REST call. + **/ + typedef enum + { + OrthancPluginHttpMethod_Get = 1, /*!< GET request */ + OrthancPluginHttpMethod_Post = 2, /*!< POST request */ + OrthancPluginHttpMethod_Put = 3, /*!< PUT request */ + OrthancPluginHttpMethod_Delete = 4, /*!< DELETE request */ + + _OrthancPluginHttpMethod_INTERNAL = 0x7fffffff + } OrthancPluginHttpMethod; + + + /** + * @brief The parameters of a REST request. + * @ingroup Callbacks + **/ + typedef struct + { + /** + * @brief The HTTP method. + **/ + OrthancPluginHttpMethod method; + + /** + * @brief The number of groups of the regular expression. + **/ + uint32_t groupsCount; + + /** + * @brief The matched values for the groups of the regular expression. + **/ + const char* const* groups; + + /** + * @brief For a GET request, the number of GET parameters. + **/ + uint32_t getCount; + + /** + * @brief For a GET request, the keys of the GET parameters. + **/ + const char* const* getKeys; + + /** + * @brief For a GET request, the values of the GET parameters. + **/ + const char* const* getValues; + + /** + * @brief For a PUT or POST request, the content of the body. + **/ + const void* body; + + /** + * @brief For a PUT or POST request, the number of bytes of the body. + **/ + uint32_t bodySize; + + + /* -------------------------------------------------- + New in version 0.8.1 + -------------------------------------------------- */ + + /** + * @brief The number of HTTP headers. + **/ + uint32_t headersCount; + + /** + * @brief The keys of the HTTP headers (always converted to low-case). + **/ + const char* const* headersKeys; + + /** + * @brief The values of the HTTP headers. + **/ + const char* const* headersValues; + + + /* -------------------------------------------------- + New in version 1.12.9 + -------------------------------------------------- */ + + /** + * @brief If a HTTP authentication callback is registered, the + * content of the custom payload generated by the callback. + **/ + const void* authenticationPayload; + + /** + * @brief The size of the custom authentication payload (0 if no + * authentication callback is registered). + **/ + uint32_t authenticationPayloadSize; + + } OrthancPluginHttpRequest; + + + typedef enum + { + /* Generic services */ + _OrthancPluginService_LogInfo = 1, + _OrthancPluginService_LogWarning = 2, + _OrthancPluginService_LogError = 3, + _OrthancPluginService_GetOrthancPath = 4, + _OrthancPluginService_GetOrthancDirectory = 5, + _OrthancPluginService_GetConfigurationPath = 6, + _OrthancPluginService_SetPluginProperty = 7, + _OrthancPluginService_GetGlobalProperty = 8, + _OrthancPluginService_SetGlobalProperty = 9, + _OrthancPluginService_GetCommandLineArgumentsCount = 10, + _OrthancPluginService_GetCommandLineArgument = 11, + _OrthancPluginService_GetExpectedDatabaseVersion = 12, + _OrthancPluginService_GetConfiguration = 13, + _OrthancPluginService_BufferCompression = 14, + _OrthancPluginService_ReadFile = 15, + _OrthancPluginService_WriteFile = 16, + _OrthancPluginService_GetErrorDescription = 17, + _OrthancPluginService_CallHttpClient = 18, + _OrthancPluginService_RegisterErrorCode = 19, + _OrthancPluginService_RegisterDictionaryTag = 20, + _OrthancPluginService_DicomBufferToJson = 21, + _OrthancPluginService_DicomInstanceToJson = 22, + _OrthancPluginService_CreateDicom = 23, + _OrthancPluginService_ComputeMd5 = 24, + _OrthancPluginService_ComputeSha1 = 25, + _OrthancPluginService_LookupDictionary = 26, + _OrthancPluginService_CallHttpClient2 = 27, + _OrthancPluginService_GenerateUuid = 28, + _OrthancPluginService_RegisterPrivateDictionaryTag = 29, + _OrthancPluginService_AutodetectMimeType = 30, + _OrthancPluginService_SetMetricsValue = 31, + _OrthancPluginService_EncodeDicomWebJson = 32, + _OrthancPluginService_EncodeDicomWebXml = 33, + _OrthancPluginService_ChunkedHttpClient = 34, /* New in Orthanc 1.5.7 */ + _OrthancPluginService_GetTagName = 35, /* New in Orthanc 1.5.7 */ + _OrthancPluginService_EncodeDicomWebJson2 = 36, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_EncodeDicomWebXml2 = 37, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_CreateMemoryBuffer = 38, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GenerateRestApiAuthorizationToken = 39, /* New in Orthanc 1.8.1 */ + _OrthancPluginService_CreateMemoryBuffer64 = 40, /* New in Orthanc 1.9.0 */ + _OrthancPluginService_CreateDicom2 = 41, /* New in Orthanc 1.9.0 */ + _OrthancPluginService_GetDatabaseServerIdentifier = 42, /* New in Orthanc 1.11.1 */ + _OrthancPluginService_SetMetricsIntegerValue = 43, /* New in Orthanc 1.12.1 */ + _OrthancPluginService_SetCurrentThreadName = 44, /* New in Orthanc 1.12.2 */ + _OrthancPluginService_LogMessage = 45, /* New in Orthanc 1.12.4 */ + _OrthancPluginService_AdoptDicomInstance = 46, /* New in Orthanc 1.12.8 */ + _OrthancPluginService_GetAttachmentCustomData = 47, /* New in Orthanc 1.12.8 */ + _OrthancPluginService_SetAttachmentCustomData = 48, /* New in Orthanc 1.12.8 */ + _OrthancPluginService_StoreKeyValue = 49, /* New in Orthanc 1.12.8 */ + _OrthancPluginService_DeleteKeyValue = 50, /* New in Orthanc 1.12.8 */ + _OrthancPluginService_GetKeyValue = 51, /* New in Orthanc 1.12.8 */ + _OrthancPluginService_CreateKeysValuesIterator = 52, /* New in Orthanc 1.12.8 */ + _OrthancPluginService_FreeKeysValuesIterator = 53, /* New in Orthanc 1.12.8 */ + _OrthancPluginService_KeysValuesIteratorNext = 54, /* New in Orthanc 1.12.8 */ + _OrthancPluginService_KeysValuesIteratorGetKey = 55, /* New in Orthanc 1.12.8 */ + _OrthancPluginService_KeysValuesIteratorGetValue = 56, /* New in Orthanc 1.12.8 */ + _OrthancPluginService_EnqueueValue = 57, /* New in Orthanc 1.12.8 */ + _OrthancPluginService_DequeueValue = 58, /* New in Orthanc 1.12.8 */ + _OrthancPluginService_GetQueueSize = 59, /* New in Orthanc 1.12.8 */ + _OrthancPluginService_SetStableStatus = 60, /* New in Orthanc 1.12.9 */ + _OrthancPluginService_EmitAuditLog = 61, /* New in Orthanc 1.12.9 */ + + /* Registration of callbacks */ + _OrthancPluginService_RegisterRestCallback = 1000, + _OrthancPluginService_RegisterOnStoredInstanceCallback = 1001, + _OrthancPluginService_RegisterStorageArea = 1002, + _OrthancPluginService_RegisterOnChangeCallback = 1003, + _OrthancPluginService_RegisterRestCallbackNoLock = 1004, + _OrthancPluginService_RegisterWorklistCallback = 1005, + _OrthancPluginService_RegisterDecodeImageCallback = 1006, + _OrthancPluginService_RegisterIncomingHttpRequestFilter = 1007, + _OrthancPluginService_RegisterFindCallback = 1008, + _OrthancPluginService_RegisterMoveCallback = 1009, + _OrthancPluginService_RegisterIncomingHttpRequestFilter2 = 1010, + _OrthancPluginService_RegisterRefreshMetricsCallback = 1011, + _OrthancPluginService_RegisterChunkedRestCallback = 1012, /* New in Orthanc 1.5.7 */ + _OrthancPluginService_RegisterStorageCommitmentScpCallback = 1013, /* New in Orthanc 1.6.0 */ + _OrthancPluginService_RegisterIncomingDicomInstanceFilter = 1014, /* New in Orthanc 1.6.1 */ + _OrthancPluginService_RegisterTranscoderCallback = 1015, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_RegisterStorageArea2 = 1016, /* New in Orthanc 1.9.0 */ + _OrthancPluginService_RegisterIncomingCStoreInstanceFilter = 1017, /* New in Orthanc 1.10.0 */ + _OrthancPluginService_RegisterReceivedInstanceCallback = 1018, /* New in Orthanc 1.10.0 */ + _OrthancPluginService_RegisterWebDavCollection = 1019, /* New in Orthanc 1.10.1 */ + _OrthancPluginService_RegisterStorageArea3 = 1020, /* New in Orthanc 1.12.8 */ + _OrthancPluginService_RegisterHttpAuthentication = 1021, /* New in Orthanc 1.12.9 */ + _OrthancPluginService_RegisterAuditLogHandler = 1022, /* New in Orthanc 1.12.9 */ + + /* Sending answers to REST calls */ + _OrthancPluginService_AnswerBuffer = 2000, + _OrthancPluginService_CompressAndAnswerPngImage = 2001, /* Unused as of Orthanc 0.9.4 */ + _OrthancPluginService_Redirect = 2002, + _OrthancPluginService_SendHttpStatusCode = 2003, + _OrthancPluginService_SendUnauthorized = 2004, + _OrthancPluginService_SendMethodNotAllowed = 2005, + _OrthancPluginService_SetCookie = 2006, + _OrthancPluginService_SetHttpHeader = 2007, + _OrthancPluginService_StartMultipartAnswer = 2008, + _OrthancPluginService_SendMultipartItem = 2009, + _OrthancPluginService_SendHttpStatus = 2010, + _OrthancPluginService_CompressAndAnswerImage = 2011, + _OrthancPluginService_SendMultipartItem2 = 2012, + _OrthancPluginService_SetHttpErrorDetails = 2013, + _OrthancPluginService_StartStreamAnswer = 2014, + _OrthancPluginService_SendStreamChunk = 2015, + + /* Access to the Orthanc database and API */ + _OrthancPluginService_GetDicomForInstance = 3000, + _OrthancPluginService_RestApiGet = 3001, + _OrthancPluginService_RestApiPost = 3002, + _OrthancPluginService_RestApiDelete = 3003, + _OrthancPluginService_RestApiPut = 3004, + _OrthancPluginService_LookupPatient = 3005, + _OrthancPluginService_LookupStudy = 3006, + _OrthancPluginService_LookupSeries = 3007, + _OrthancPluginService_LookupInstance = 3008, + _OrthancPluginService_LookupStudyWithAccessionNumber = 3009, + _OrthancPluginService_RestApiGetAfterPlugins = 3010, + _OrthancPluginService_RestApiPostAfterPlugins = 3011, + _OrthancPluginService_RestApiDeleteAfterPlugins = 3012, + _OrthancPluginService_RestApiPutAfterPlugins = 3013, + _OrthancPluginService_ReconstructMainDicomTags = 3014, + _OrthancPluginService_RestApiGet2 = 3015, + _OrthancPluginService_CallRestApi = 3016, /* New in Orthanc 1.9.2 */ + + /* Access to DICOM instances */ + _OrthancPluginService_GetInstanceRemoteAet = 4000, + _OrthancPluginService_GetInstanceSize = 4001, + _OrthancPluginService_GetInstanceData = 4002, + _OrthancPluginService_GetInstanceJson = 4003, + _OrthancPluginService_GetInstanceSimplifiedJson = 4004, + _OrthancPluginService_HasInstanceMetadata = 4005, + _OrthancPluginService_GetInstanceMetadata = 4006, + _OrthancPluginService_GetInstanceOrigin = 4007, + _OrthancPluginService_GetInstanceTransferSyntaxUid = 4008, + _OrthancPluginService_HasInstancePixelData = 4009, + _OrthancPluginService_CreateDicomInstance = 4010, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_FreeDicomInstance = 4011, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceFramesCount = 4012, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceRawFrame = 4013, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceDecodedFrame = 4014, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_TranscodeDicomInstance = 4015, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_SerializeDicomInstance = 4016, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceAdvancedJson = 4017, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceDicomWebJson = 4018, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceDicomWebXml = 4019, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_LoadDicomInstance = 4020, /* New in Orthanc 1.12.1 */ + + /* Services for plugins implementing a database back-end */ + _OrthancPluginService_RegisterDatabaseBackend = 5000, /* New in Orthanc 0.8.6 */ + _OrthancPluginService_DatabaseAnswer = 5001, + _OrthancPluginService_RegisterDatabaseBackendV2 = 5002, /* New in Orthanc 0.9.4 */ + _OrthancPluginService_StorageAreaCreate = 5003, + _OrthancPluginService_StorageAreaRead = 5004, + _OrthancPluginService_StorageAreaRemove = 5005, + _OrthancPluginService_RegisterDatabaseBackendV3 = 5006, /* New in Orthanc 1.9.2 */ + _OrthancPluginService_RegisterDatabaseBackendV4 = 5007, /* New in Orthanc 1.12.0 */ + + /* Primitives for handling images */ + _OrthancPluginService_GetImagePixelFormat = 6000, + _OrthancPluginService_GetImageWidth = 6001, + _OrthancPluginService_GetImageHeight = 6002, + _OrthancPluginService_GetImagePitch = 6003, + _OrthancPluginService_GetImageBuffer = 6004, + _OrthancPluginService_UncompressImage = 6005, + _OrthancPluginService_FreeImage = 6006, + _OrthancPluginService_CompressImage = 6007, + _OrthancPluginService_ConvertPixelFormat = 6008, + _OrthancPluginService_GetFontsCount = 6009, + _OrthancPluginService_GetFontInfo = 6010, + _OrthancPluginService_DrawText = 6011, + _OrthancPluginService_CreateImage = 6012, + _OrthancPluginService_CreateImageAccessor = 6013, + _OrthancPluginService_DecodeDicomImage = 6014, + + /* Primitives for handling C-Find, C-Move and worklists */ + _OrthancPluginService_WorklistAddAnswer = 7000, + _OrthancPluginService_WorklistMarkIncomplete = 7001, + _OrthancPluginService_WorklistIsMatch = 7002, + _OrthancPluginService_WorklistGetDicomQuery = 7003, + _OrthancPluginService_FindAddAnswer = 7004, + _OrthancPluginService_FindMarkIncomplete = 7005, + _OrthancPluginService_GetFindQuerySize = 7006, + _OrthancPluginService_GetFindQueryTag = 7007, + _OrthancPluginService_GetFindQueryTagName = 7008, + _OrthancPluginService_GetFindQueryValue = 7009, + _OrthancPluginService_CreateFindMatcher = 7010, + _OrthancPluginService_FreeFindMatcher = 7011, + _OrthancPluginService_FindMatcherIsMatch = 7012, + + /* Primitives for accessing Orthanc Peers (new in 1.4.2) */ + _OrthancPluginService_GetPeers = 8000, + _OrthancPluginService_FreePeers = 8001, + _OrthancPluginService_GetPeersCount = 8003, + _OrthancPluginService_GetPeerName = 8004, + _OrthancPluginService_GetPeerUrl = 8005, + _OrthancPluginService_CallPeerApi = 8006, + _OrthancPluginService_GetPeerUserProperty = 8007, + + /* Primitives for handling jobs (new in 1.4.2) */ + _OrthancPluginService_CreateJob = 9000, /* Deprecated since SDK 1.11.3 */ + _OrthancPluginService_FreeJob = 9001, + _OrthancPluginService_SubmitJob = 9002, + _OrthancPluginService_RegisterJobsUnserializer = 9003, + _OrthancPluginService_CreateJob2 = 9004, /* New in SDK 1.11.3 */ + + _OrthancPluginService_INTERNAL = 0x7fffffff + } _OrthancPluginService; + + + typedef enum + { + _OrthancPluginProperty_Description = 1, + _OrthancPluginProperty_RootUri = 2, + _OrthancPluginProperty_OrthancExplorer = 3, + + _OrthancPluginProperty_INTERNAL = 0x7fffffff + } _OrthancPluginProperty; + + + + /** + * The memory layout of the pixels of an image. + * @ingroup Images + **/ + typedef enum + { + /** + * @brief Graylevel 8bpp image. + * + * The image is graylevel. Each pixel is unsigned and stored in + * one byte. + **/ + OrthancPluginPixelFormat_Grayscale8 = 1, + + /** + * @brief Graylevel, unsigned 16bpp image. + * + * The image is graylevel. Each pixel is unsigned and stored in + * two bytes. + **/ + OrthancPluginPixelFormat_Grayscale16 = 2, + + /** + * @brief Graylevel, signed 16bpp image. + * + * The image is graylevel. Each pixel is signed and stored in two + * bytes. + **/ + OrthancPluginPixelFormat_SignedGrayscale16 = 3, + + /** + * @brief Color image in RGB24 format. + * + * This format describes a color image. The pixels are stored in 3 + * consecutive bytes. The memory layout is RGB. + **/ + OrthancPluginPixelFormat_RGB24 = 4, + + /** + * @brief Color image in RGBA32 format. + * + * This format describes a color image. The pixels are stored in 4 + * consecutive bytes. The memory layout is RGBA. + **/ + OrthancPluginPixelFormat_RGBA32 = 5, + + OrthancPluginPixelFormat_Unknown = 6, /*!< Unknown pixel format */ + + /** + * @brief Color image in RGB48 format. + * + * This format describes a color image. The pixels are stored in 6 + * consecutive bytes. The memory layout is RRGGBB. + **/ + OrthancPluginPixelFormat_RGB48 ORTHANC_PLUGIN_SINCE_SDK("1.3.1") = 7, + + /** + * @brief Graylevel, unsigned 32bpp image. + * + * The image is graylevel. Each pixel is unsigned and stored in + * four bytes. + **/ + OrthancPluginPixelFormat_Grayscale32 ORTHANC_PLUGIN_SINCE_SDK("1.3.1") = 8, + + /** + * @brief Graylevel, floating-point 32bpp image. + * + * The image is graylevel. Each pixel is floating-point and stored + * in four bytes. + **/ + OrthancPluginPixelFormat_Float32 ORTHANC_PLUGIN_SINCE_SDK("1.3.1") = 9, + + /** + * @brief Color image in BGRA32 format. + * + * This format describes a color image. The pixels are stored in 4 + * consecutive bytes. The memory layout is BGRA. + **/ + OrthancPluginPixelFormat_BGRA32 ORTHANC_PLUGIN_SINCE_SDK("1.3.1") = 10, + + /** + * @brief Graylevel, unsigned 64bpp image. + * + * The image is graylevel. Each pixel is unsigned and stored in + * eight bytes. + **/ + OrthancPluginPixelFormat_Grayscale64 ORTHANC_PLUGIN_SINCE_SDK("1.4.0") = 11, + + _OrthancPluginPixelFormat_INTERNAL = 0x7fffffff + } OrthancPluginPixelFormat; + + + + /** + * The content types that are supported by Orthanc plugins. + **/ + typedef enum + { + OrthancPluginContentType_Unknown = 0, /*!< Unknown content type */ + OrthancPluginContentType_Dicom = 1, /*!< DICOM */ + OrthancPluginContentType_DicomAsJson = 2, /*!< JSON summary of a DICOM file */ + OrthancPluginContentType_DicomUntilPixelData ORTHANC_PLUGIN_SINCE_SDK("1.9.2") = 3, /*!< DICOM Header till pixel data */ + + _OrthancPluginContentType_INTERNAL = 0x7fffffff + } OrthancPluginContentType; + + + + /** + * The supported types of DICOM resources. + **/ + typedef enum + { + OrthancPluginResourceType_Patient = 0, /*!< Patient */ + OrthancPluginResourceType_Study = 1, /*!< Study */ + OrthancPluginResourceType_Series = 2, /*!< Series */ + OrthancPluginResourceType_Instance = 3, /*!< Instance */ + OrthancPluginResourceType_None = 4, /*!< Unavailable resource type */ + + _OrthancPluginResourceType_INTERNAL = 0x7fffffff + } OrthancPluginResourceType; + + + + /** + * The supported types of changes that can be signaled to the change callback. + * Note: This enumeration is not used to store changes in the database! + * @ingroup Callbacks + **/ + typedef enum + { + OrthancPluginChangeType_CompletedSeries = 0, /*!< Series is now complete */ + OrthancPluginChangeType_Deleted = 1, /*!< Deleted resource */ + OrthancPluginChangeType_NewChildInstance = 2, /*!< A new instance was added to this resource */ + OrthancPluginChangeType_NewInstance = 3, /*!< New instance received */ + OrthancPluginChangeType_NewPatient = 4, /*!< New patient created */ + OrthancPluginChangeType_NewSeries = 5, /*!< New series created */ + OrthancPluginChangeType_NewStudy = 6, /*!< New study created */ + OrthancPluginChangeType_StablePatient = 7, /*!< Timeout: No new instance in this patient */ + OrthancPluginChangeType_StableSeries = 8, /*!< Timeout: No new instance in this series */ + OrthancPluginChangeType_StableStudy = 9, /*!< Timeout: No new instance in this study */ + OrthancPluginChangeType_OrthancStarted = 10, /*!< Orthanc has started */ + OrthancPluginChangeType_OrthancStopped = 11, /*!< Orthanc is stopping */ + OrthancPluginChangeType_UpdatedAttachment = 12, /*!< Some user-defined attachment has changed for this resource */ + OrthancPluginChangeType_UpdatedMetadata = 13, /*!< Some user-defined metadata has changed for this resource */ + OrthancPluginChangeType_UpdatedPeers ORTHANC_PLUGIN_SINCE_SDK("1.4.2") = 14, /*!< The list of Orthanc peers has changed */ + OrthancPluginChangeType_UpdatedModalities ORTHANC_PLUGIN_SINCE_SDK("1.4.2") = 15, /*!< The list of DICOM modalities has changed */ + OrthancPluginChangeType_JobSubmitted ORTHANC_PLUGIN_SINCE_SDK("1.7.2") = 16, /*!< New Job submitted */ + OrthancPluginChangeType_JobSuccess ORTHANC_PLUGIN_SINCE_SDK("1.7.2") = 17, /*!< A Job has completed successfully */ + OrthancPluginChangeType_JobFailure ORTHANC_PLUGIN_SINCE_SDK("1.7.2") = 18, /*!< A Job has failed */ + + _OrthancPluginChangeType_INTERNAL = 0x7fffffff + } OrthancPluginChangeType; + + + /** + * The compression algorithms that are supported by the Orthanc core. + * @ingroup Images + **/ + typedef enum + { + OrthancPluginCompressionType_Zlib = 0, /*!< Standard zlib compression */ + OrthancPluginCompressionType_ZlibWithSize = 1, /*!< zlib, prefixed with uncompressed size (uint64_t) */ + OrthancPluginCompressionType_Gzip = 2, /*!< Standard gzip compression */ + OrthancPluginCompressionType_GzipWithSize = 3, /*!< gzip, prefixed with uncompressed size (uint64_t) */ + OrthancPluginCompressionType_None ORTHANC_PLUGIN_SINCE_SDK("1.12.8") = 4, /*!< No compression (new in Orthanc 1.12.8) */ + + _OrthancPluginCompressionType_INTERNAL = 0x7fffffff + } OrthancPluginCompressionType; + + + /** + * The image formats that are supported by the Orthanc core. + * @ingroup Images + **/ + typedef enum + { + OrthancPluginImageFormat_Png = 0, /*!< Image compressed using PNG */ + OrthancPluginImageFormat_Jpeg = 1, /*!< Image compressed using JPEG */ + OrthancPluginImageFormat_Dicom = 2, /*!< Image compressed using DICOM */ + + _OrthancPluginImageFormat_INTERNAL = 0x7fffffff + } OrthancPluginImageFormat; + + + /** + * The value representations present in the DICOM standard (version 2013). + * @ingroup Toolbox + **/ + typedef enum + { + OrthancPluginValueRepresentation_AE = 1, /*!< Application Entity */ + OrthancPluginValueRepresentation_AS = 2, /*!< Age String */ + OrthancPluginValueRepresentation_AT = 3, /*!< Attribute Tag */ + OrthancPluginValueRepresentation_CS = 4, /*!< Code String */ + OrthancPluginValueRepresentation_DA = 5, /*!< Date */ + OrthancPluginValueRepresentation_DS = 6, /*!< Decimal String */ + OrthancPluginValueRepresentation_DT = 7, /*!< Date Time */ + OrthancPluginValueRepresentation_FD = 8, /*!< Floating Point Double */ + OrthancPluginValueRepresentation_FL = 9, /*!< Floating Point Single */ + OrthancPluginValueRepresentation_IS = 10, /*!< Integer String */ + OrthancPluginValueRepresentation_LO = 11, /*!< Long String */ + OrthancPluginValueRepresentation_LT = 12, /*!< Long Text */ + OrthancPluginValueRepresentation_OB = 13, /*!< Other Byte String */ + OrthancPluginValueRepresentation_OF = 14, /*!< Other Float String */ + OrthancPluginValueRepresentation_OW = 15, /*!< Other Word String */ + OrthancPluginValueRepresentation_PN = 16, /*!< Person Name */ + OrthancPluginValueRepresentation_SH = 17, /*!< Short String */ + OrthancPluginValueRepresentation_SL = 18, /*!< Signed Long */ + OrthancPluginValueRepresentation_SQ = 19, /*!< Sequence of Items */ + OrthancPluginValueRepresentation_SS = 20, /*!< Signed Short */ + OrthancPluginValueRepresentation_ST = 21, /*!< Short Text */ + OrthancPluginValueRepresentation_TM = 22, /*!< Time */ + OrthancPluginValueRepresentation_UI = 23, /*!< Unique Identifier (UID) */ + OrthancPluginValueRepresentation_UL = 24, /*!< Unsigned Long */ + OrthancPluginValueRepresentation_UN = 25, /*!< Unknown */ + OrthancPluginValueRepresentation_US = 26, /*!< Unsigned Short */ + OrthancPluginValueRepresentation_UT = 27, /*!< Unlimited Text */ + + _OrthancPluginValueRepresentation_INTERNAL = 0x7fffffff + } OrthancPluginValueRepresentation; + + + /** + * The possible output formats for a DICOM-to-JSON conversion. + * @ingroup Toolbox + * @see OrthancPluginDicomToJson() + **/ + typedef enum + { + OrthancPluginDicomToJsonFormat_Full = 1, /*!< Full output, with most details */ + OrthancPluginDicomToJsonFormat_Short = 2, /*!< Tags output as hexadecimal numbers */ + OrthancPluginDicomToJsonFormat_Human = 3, /*!< Human-readable JSON */ + + _OrthancPluginDicomToJsonFormat_INTERNAL = 0x7fffffff + } OrthancPluginDicomToJsonFormat; + + + /** + * Flags to customize a DICOM-to-JSON conversion. By default, binary + * tags are formatted using Data URI scheme. + * @ingroup Toolbox + **/ + typedef enum + { + OrthancPluginDicomToJsonFlags_None = 0, /*!< Default formatting */ + OrthancPluginDicomToJsonFlags_IncludeBinary = (1 << 0), /*!< Include the binary tags */ + OrthancPluginDicomToJsonFlags_IncludePrivateTags = (1 << 1), /*!< Include the private tags */ + OrthancPluginDicomToJsonFlags_IncludeUnknownTags = (1 << 2), /*!< Include the tags unknown by the dictionary */ + OrthancPluginDicomToJsonFlags_IncludePixelData = (1 << 3), /*!< Include the pixel data */ + OrthancPluginDicomToJsonFlags_ConvertBinaryToAscii = (1 << 4), /*!< Output binary tags as-is, dropping non-ASCII */ + OrthancPluginDicomToJsonFlags_ConvertBinaryToNull = (1 << 5), /*!< Signal binary tags as null values */ + OrthancPluginDicomToJsonFlags_StopAfterPixelData ORTHANC_PLUGIN_SINCE_SDK("1.9.1") = (1 << 6), /*!< Stop processing after pixel data (new in 1.9.1) */ + OrthancPluginDicomToJsonFlags_SkipGroupLengths ORTHANC_PLUGIN_SINCE_SDK("1.9.1") = (1 << 7), /*!< Skip tags whose element is zero (new in 1.9.1) */ + + _OrthancPluginDicomToJsonFlags_INTERNAL = 0x7fffffff + } OrthancPluginDicomToJsonFlags; + + + /** + * Flags for the creation of a DICOM file. + * @ingroup Toolbox + * @see OrthancPluginCreateDicom() + **/ + typedef enum + { + OrthancPluginCreateDicomFlags_None ORTHANC_PLUGIN_SINCE_SDK("1.2.0") = 0, /*!< Default mode */ + OrthancPluginCreateDicomFlags_DecodeDataUriScheme = (1 << 0), /*!< Decode fields encoded using data URI scheme */ + OrthancPluginCreateDicomFlags_GenerateIdentifiers = (1 << 1), /*!< Automatically generate DICOM identifiers */ + + _OrthancPluginCreateDicomFlags_INTERNAL = 0x7fffffff + } OrthancPluginCreateDicomFlags; + + + /** + * The constraints on the DICOM identifiers that must be supported + * by the database plugins. + * @deprecated Plugins using OrthancPluginConstraintType will be faster + **/ + typedef enum + { + OrthancPluginIdentifierConstraint_Equal = 1, /*!< Equal */ + OrthancPluginIdentifierConstraint_SmallerOrEqual = 2, /*!< Less or equal */ + OrthancPluginIdentifierConstraint_GreaterOrEqual = 3, /*!< More or equal */ + OrthancPluginIdentifierConstraint_Wildcard = 4, /*!< Case-sensitive wildcard matching (with * and ?) */ + + _OrthancPluginIdentifierConstraint_INTERNAL = 0x7fffffff + } OrthancPluginIdentifierConstraint; + + + /** + * The constraints on the tags (main DICOM tags and identifier tags) + * that must be supported by the database plugins. + **/ + typedef enum + { + OrthancPluginConstraintType_Equal = 1, /*!< Equal */ + OrthancPluginConstraintType_SmallerOrEqual = 2, /*!< Less or equal */ + OrthancPluginConstraintType_GreaterOrEqual = 3, /*!< More or equal */ + OrthancPluginConstraintType_Wildcard = 4, /*!< Wildcard matching */ + OrthancPluginConstraintType_List = 5, /*!< List of values */ + + _OrthancPluginConstraintType_INTERNAL = 0x7fffffff + } OrthancPluginConstraintType; + + + /** + * The origin of a DICOM instance that has been received by Orthanc. + **/ + typedef enum + { + OrthancPluginInstanceOrigin_Unknown = 1, /*!< Unknown origin */ + OrthancPluginInstanceOrigin_DicomProtocol = 2, /*!< Instance received through DICOM protocol */ + OrthancPluginInstanceOrigin_RestApi = 3, /*!< Instance received through REST API of Orthanc */ + OrthancPluginInstanceOrigin_Plugin = 4, /*!< Instance added to Orthanc by a plugin */ + OrthancPluginInstanceOrigin_Lua = 5, /*!< Instance added to Orthanc by a Lua script */ + OrthancPluginInstanceOrigin_WebDav ORTHANC_PLUGIN_SINCE_SDK("1.8.0") = 6, /*!< Instance received through WebDAV (new in 1.8.0) */ + + _OrthancPluginInstanceOrigin_INTERNAL = 0x7fffffff + } OrthancPluginInstanceOrigin; + + + /** + * The possible status for one single step of a job. + **/ + typedef enum ORTHANC_PLUGIN_SINCE_SDK("1.4.2") + { + OrthancPluginJobStepStatus_Success = 1, /*!< The job has successfully executed all its steps */ + OrthancPluginJobStepStatus_Failure = 2, /*!< The job has failed while executing this step */ + OrthancPluginJobStepStatus_Continue = 3 /*!< The job has still data to process after this step */ + } OrthancPluginJobStepStatus; + + + /** + * Explains why the job should stop and release the resources it has + * allocated. This is especially important to disambiguate between + * the "paused" condition and the "final" conditions (success, + * failure, or canceled). + **/ + typedef enum ORTHANC_PLUGIN_SINCE_SDK("1.4.2") + { + OrthancPluginJobStopReason_Success = 1, /*!< The job has succeeded */ + OrthancPluginJobStopReason_Paused = 2, /*!< The job was paused, and will be resumed later */ + OrthancPluginJobStopReason_Failure = 3, /*!< The job has failed, and might be resubmitted later */ + OrthancPluginJobStopReason_Canceled = 4 /*!< The job was canceled, and might be resubmitted later */ + } OrthancPluginJobStopReason; + + + /** + * The available types of metrics. + **/ + typedef enum ORTHANC_PLUGIN_SINCE_SDK("1.5.4") + { + OrthancPluginMetricsType_Default = 0, /*!< Default metrics */ + + /** + * This metrics represents a time duration. Orthanc will keep the + * maximum value of the metrics over a sliding window of ten + * seconds, which is useful if the metrics is sampled frequently. + **/ + OrthancPluginMetricsType_Timer = 1 + } OrthancPluginMetricsType; + + + /** + * The available modes to export a binary DICOM tag into a DICOMweb + * JSON or XML document. + **/ + typedef enum ORTHANC_PLUGIN_SINCE_SDK("1.5.4") + { + OrthancPluginDicomWebBinaryMode_Ignore = 0, /*!< Don't include binary tags */ + OrthancPluginDicomWebBinaryMode_InlineBinary = 1, /*!< Inline encoding using Base64 */ + OrthancPluginDicomWebBinaryMode_BulkDataUri = 2 /*!< Use a bulk data URI field */ + } OrthancPluginDicomWebBinaryMode; + + + /** + * The available values for the Failure Reason (0008,1197) during + * storage commitment. + * http://dicom.nema.org/medical/dicom/2019e/output/chtml/part03/sect_C.14.html#sect_C.14.1.1 + **/ + typedef enum ORTHANC_PLUGIN_SINCE_SDK("1.6.0") + { + /** + * Success: The DICOM instance is properly stored in the SCP + **/ + OrthancPluginStorageCommitmentFailureReason_Success = 0, + + /** + * 0110H: A general failure in processing the operation was encountered + **/ + OrthancPluginStorageCommitmentFailureReason_ProcessingFailure = 1, + + /** + * 0112H: One or more of the elements in the Referenced SOP + * Instance Sequence was not available + **/ + OrthancPluginStorageCommitmentFailureReason_NoSuchObjectInstance = 2, + + /** + * 0213H: The SCP does not currently have enough resources to + * store the requested SOP Instance(s) + **/ + OrthancPluginStorageCommitmentFailureReason_ResourceLimitation = 3, + + /** + * 0122H: Storage Commitment has been requested for a SOP Instance + * with a SOP Class that is not supported by the SCP + **/ + OrthancPluginStorageCommitmentFailureReason_ReferencedSOPClassNotSupported = 4, + + /** + * 0119H: The SOP Class of an element in the Referenced SOP + * Instance Sequence did not correspond to the SOP class + * registered for this SOP Instance at the SCP + **/ + OrthancPluginStorageCommitmentFailureReason_ClassInstanceConflict = 5, + + /** + * 0131H: The Transaction UID of the Storage Commitment Request is + * already in use + **/ + OrthancPluginStorageCommitmentFailureReason_DuplicateTransactionUID = 6 + } OrthancPluginStorageCommitmentFailureReason; + + + /** + * The action to be taken after ReceivedInstanceCallback is triggered + **/ + typedef enum ORTHANC_PLUGIN_SINCE_SDK("1.10.0") + { + OrthancPluginReceivedInstanceAction_KeepAsIs = 1, /*!< Keep the instance as is */ + OrthancPluginReceivedInstanceAction_Modify = 2, /*!< Modify the instance */ + OrthancPluginReceivedInstanceAction_Discard = 3, /*!< Discard the instance */ + + _OrthancPluginReceivedInstanceAction_INTERNAL = 0x7fffffff + } OrthancPluginReceivedInstanceAction; + + + /** + * Mode specifying how to load a DICOM instance. + * @see OrthancPluginLoadDicomInstance() + **/ + typedef enum ORTHANC_PLUGIN_SINCE_SDK("1.12.1") + { + /** + * Load the whole DICOM file, including pixel data + **/ + OrthancPluginLoadDicomInstanceMode_WholeDicom = 1, + + /** + * Load the whole DICOM file until pixel data, which speeds up the + * loading + **/ + OrthancPluginLoadDicomInstanceMode_UntilPixelData = 2, + + /** + * Load the whole DICOM file until pixel data, and replace pixel + * data by an empty tag whose VR (value representation) is the + * same as those of the original DICOM file + **/ + OrthancPluginLoadDicomInstanceMode_EmptyPixelData = 3, + + _OrthancPluginLoadDicomInstanceMode_INTERNAL = 0x7fffffff + } OrthancPluginLoadDicomInstanceMode; + + + /** + * The log levels supported by Orthanc. + * + * These values must match those of enumeration "LogLevel" in the + * Orthanc Core. + **/ + typedef enum ORTHANC_PLUGIN_SINCE_SDK("1.12.4") + { + OrthancPluginLogLevel_Error = 0, /*!< Error log level */ + OrthancPluginLogLevel_Warning = 1, /*!< Warning log level */ + OrthancPluginLogLevel_Info = 2, /*!< Info log level */ + OrthancPluginLogLevel_Trace = 3, /*!< Trace log level */ + + _OrthancPluginLogLevel_INTERNAL = 0x7fffffff + } OrthancPluginLogLevel; + + + /** + * The log categories supported by Orthanc. + * + * These values must match those of enumeration "LogCategory" in the + * Orthanc Core. + **/ + typedef enum ORTHANC_PLUGIN_SINCE_SDK("1.12.4") + { + OrthancPluginLogCategory_Generic = (1 << 0), /*!< Generic (default) category */ + OrthancPluginLogCategory_Plugins = (1 << 1), /*!< Plugin engine related logs (shall not be used by plugins) */ + OrthancPluginLogCategory_Http = (1 << 2), /*!< HTTP related logs */ + OrthancPluginLogCategory_Sqlite = (1 << 3), /*!< SQLite related logs (shall not be used by plugins) */ + OrthancPluginLogCategory_Dicom = (1 << 4), /*!< DICOM related logs */ + OrthancPluginLogCategory_Jobs = (1 << 5), /*!< jobs related logs */ + OrthancPluginLogCategory_Lua = (1 << 6), /*!< Lua related logs (shall not be used by plugins) */ + + _OrthancPluginLogCategory_INTERNAL = 0x7fffffff + } OrthancPluginLogCategory; + + + /** + * The store status related to the adoption of a DICOM instance. + **/ + typedef enum ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + { + OrthancPluginStoreStatus_Success = 0, /*!< The file has been stored/adopted */ + OrthancPluginStoreStatus_AlreadyStored = 1, /*!< The file has already been stored/adopted (only if OverwriteInstances is set to false)*/ + OrthancPluginStoreStatus_Failure = 2, /*!< The file could not be stored/adopted */ + OrthancPluginStoreStatus_FilteredOut = 3, /*!< The file has been filtered out by a Lua script or a plugin */ + OrthancPluginStoreStatus_StorageFull = 4, /*!< The storage is full (only if MaximumStorageSize/MaximumPatientCount is set and MaximumStorageMode is Reject)*/ + + _OrthancPluginStoreStatus_INTERNAL = 0x7fffffff + } OrthancPluginStoreStatus; + + + /** + * The supported modes to remove an element from a queue. + **/ + typedef enum ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + { + OrthancPluginQueueOrigin_Front = 0, /*!< Dequeue from the front of the queue */ + OrthancPluginQueueOrigin_Back = 1, /*!< Dequeue from the back of the queue */ + + _OrthancPluginQueueOrigin_INTERNAL = 0x7fffffff + } OrthancPluginQueueOrigin; + + + /** + * The "Stable" status of a resource. + **/ + typedef enum ORTHANC_PLUGIN_SINCE_SDK("1.12.9") + { + OrthancPluginStableStatus_Stable = 0, /*!< The resource is stable */ + OrthancPluginStableStatus_Unstable = 1, /*!< The resource is unstable */ + + _OrthancPluginStableStatus_INTERNAL = 0x7fffffff + } OrthancPluginStableStatus; + + + /** + * Status associated with the authentication of a HTTP request. + **/ + typedef enum ORTHANC_PLUGIN_SINCE_SDK("1.12.9") + { + OrthancPluginHttpAuthenticationStatus_Granted = 0, /*!< The authentication has been granted */ + OrthancPluginHttpAuthenticationStatus_Unauthorized = 1, /*!< The authentication has failed (401 HTTP status) */ + OrthancPluginHttpAuthenticationStatus_Forbidden = 2, /*!< The authorization has failed (403 HTTP status) */ + OrthancPluginHttpAuthenticationStatus_Redirect = 3, /*!< Redirect to another path (307 HTTP status, e.g., for login) */ + + _OrthancPluginHttpAuthenticationStatus_INTERNAL = 0x7fffffff + } OrthancPluginHttpAuthenticationStatus; + + + /** + * @brief A 32-bit memory buffer allocated by the core system of Orthanc. + * + * A memory buffer allocated by the core system of Orthanc. When the + * content of the buffer is not useful anymore, it must be free by a + * call to ::OrthancPluginFreeMemoryBuffer(). + **/ + typedef struct + { + /** + * @brief The content of the buffer. + **/ + void* data; + + /** + * @brief The number of bytes in the buffer. + **/ + uint32_t size; + } OrthancPluginMemoryBuffer; + + + + /** + * @brief A 64-bit memory buffer allocated by the core system of Orthanc. + * + * A memory buffer allocated by the core system of Orthanc. When the + * content of the buffer is not useful anymore, it must be free by a + * call to ::OrthancPluginFreeMemoryBuffer64(). + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.9.0") typedef struct + { + /** + * @brief The content of the buffer. + **/ + void* data; + + /** + * @brief The number of bytes in the buffer. + **/ + uint64_t size; + } OrthancPluginMemoryBuffer64; + + + + + /** + * @brief Opaque structure that represents the HTTP connection to the client application. + * @ingroup Callbacks + **/ + typedef struct _OrthancPluginRestOutput_t OrthancPluginRestOutput; + + + + /** + * @brief Opaque structure that represents a DICOM instance that is managed by the Orthanc core. + * @ingroup DicomInstance + **/ + typedef struct _OrthancPluginDicomInstance_t OrthancPluginDicomInstance; + + + + /** + * @brief Opaque structure that represents an image that is uncompressed in memory. + * @ingroup Images + **/ + typedef struct _OrthancPluginImage_t OrthancPluginImage; + + + + /** + * @brief Opaque structure that represents the storage area that is actually used by Orthanc. + * @ingroup Images + **/ + typedef struct _OrthancPluginStorageArea_t OrthancPluginStorageArea; + + + + /** + * @brief Opaque structure to an object that represents a C-Find query for worklists. + * @ingroup DicomCallbacks + **/ + typedef struct _OrthancPluginWorklistQuery_t OrthancPluginWorklistQuery; + + + + /** + * @brief Opaque structure to an object that represents the answers to a C-Find query for worklists. + * @ingroup DicomCallbacks + **/ + typedef struct _OrthancPluginWorklistAnswers_t OrthancPluginWorklistAnswers; + + + + /** + * @brief Opaque structure to an object that represents a C-Find query. + * @ingroup DicomCallbacks + **/ + typedef struct ORTHANC_PLUGIN_SINCE_SDK("1.1.0") + _OrthancPluginFindQuery_t OrthancPluginFindQuery; + + + + /** + * @brief Opaque structure to an object that represents the answers to a C-Find query for worklists. + * @ingroup DicomCallbacks + **/ + typedef struct ORTHANC_PLUGIN_SINCE_SDK("1.1.0") + _OrthancPluginFindAnswers_t OrthancPluginFindAnswers; + + + + /** + * @brief Opaque structure to an object that can be used to check whether a DICOM instance matches a C-Find query. + * @ingroup Toolbox + **/ + typedef struct ORTHANC_PLUGIN_SINCE_SDK("1.2.0") + _OrthancPluginFindMatcher_t OrthancPluginFindMatcher; + + + + /** + * @brief Opaque structure to the set of remote Orthanc Peers that are known to the local Orthanc server. + * @ingroup Toolbox + **/ + typedef struct ORTHANC_PLUGIN_SINCE_SDK("1.4.2") + _OrthancPluginPeers_t OrthancPluginPeers; + + + + /** + * @brief Opaque structure to a job to be executed by Orthanc. + * @ingroup Toolbox + **/ + typedef struct ORTHANC_PLUGIN_SINCE_SDK("1.4.2") + _OrthancPluginJob_t OrthancPluginJob; + + + + /** + * @brief Opaque structure that represents a node in a JSON or XML + * document used in DICOMweb. + * @ingroup Toolbox + **/ + typedef struct ORTHANC_PLUGIN_SINCE_SDK("1.5.4") + _OrthancPluginDicomWebNode_t OrthancPluginDicomWebNode; + + + + /** + * @brief Signature of a callback function that answers to a REST request. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginRestCallback) ( + OrthancPluginRestOutput* output, + const char* uri, + const OrthancPluginHttpRequest* request); + + + + /** + * @brief Signature of a callback function that is triggered when Orthanc stores a new DICOM instance. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginOnStoredInstanceCallback) ( + const OrthancPluginDicomInstance* instance, + const char* instanceId); + + + + /** + * @brief Signature of a callback function that is triggered when a change happens to some DICOM resource. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginOnChangeCallback) ( + OrthancPluginChangeType changeType, + OrthancPluginResourceType resourceType, + const char* resourceId); + + + + /** + * @brief Signature of a callback function to decode a DICOM instance as an image. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginDecodeImageCallback) ( + OrthancPluginImage** target, + const void* dicom, + const uint32_t size, + uint32_t frameIndex); + + + + /** + * @brief Signature of a function to free dynamic memory. + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginFree) (void* buffer); + + + + /** + * @brief Signature of a function to set the content of a node + * encoding a binary DICOM tag, into a JSON or XML document + * generated for DICOMweb. + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginDicomWebSetBinaryNode) ( + OrthancPluginDicomWebNode* node, + OrthancPluginDicomWebBinaryMode mode, + const char* bulkDataUri); + + + + /** + * @brief Callback for writing to the storage area. + * + * Signature of a callback function that is triggered when Orthanc writes a file to the storage area. + * + * @param uuid The UUID of the file. + * @param content The content of the file. + * @param size The size of the file. + * @param type The content type corresponding to this file. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageCreate) ( + const char* uuid, + const void* content, + int64_t size, + OrthancPluginContentType type); + + + + /** + * @brief Callback for reading from the storage area. + * + * Signature of a callback function that is triggered when Orthanc reads a file from the storage area. + * + * @param content The content of the file (output). + * @param size The size of the file (output). + * @param uuid The UUID of the file of interest. + * @param type The content type corresponding to this file. + * @return 0 if success, other value if error. + * @ingroup Callbacks + * + * @warning The "content" buffer *must* have been allocated using + * the "malloc()" function of your C standard library (i.e. nor + * "new[]", neither a pointer to a buffer). The "free()" function of + * your C standard library will automatically be invoked on the + * "content" pointer. + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageRead) ( + void** content, + int64_t* size, + const char* uuid, + OrthancPluginContentType type); + + + + /** + * @brief Callback for reading a whole file from the storage area. + * + * Signature of a callback function that is triggered when Orthanc + * reads a whole file from the storage area. + * + * @param target Memory buffer where to store the content of the file. It must be allocated by the + * plugin using OrthancPluginCreateMemoryBuffer64(). The core of Orthanc will free it. + * @param uuid The UUID of the file of interest. + * @param type The content type corresponding to this file. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageReadWhole) ( + OrthancPluginMemoryBuffer64* target, + const char* uuid, + OrthancPluginContentType type); + + + + /** + * @brief Callback for reading a range of a file from the storage area. + * + * Signature of a callback function that is triggered when Orthanc + * reads a portion of a file from the storage area. Orthanc + * indicates the start position and the length of the range. + * + * @param target Memory buffer where to store the content of the range. + * The memory buffer is allocated and freed by Orthanc. The length of the range + * of interest corresponds to the size of this buffer. + * @param uuid The UUID of the file of interest. + * @param type The content type corresponding to this file. + * @param rangeStart Start position of the requested range in the file. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageReadRange) ( + OrthancPluginMemoryBuffer64* target, + const char* uuid, + OrthancPluginContentType type, + uint64_t rangeStart); + + + + /** + * @brief Callback for removing a file from the storage area. + * + * Signature of a callback function that is triggered when Orthanc deletes a file from the storage area. + * + * @param uuid The UUID of the file to be removed. + * @param type The content type corresponding to this file. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageRemove) ( + const char* uuid, + OrthancPluginContentType type); + + + + /** + * @brief Callback for writing to the storage area. + * + * Signature of a callback function that is triggered when Orthanc writes a file to the storage area. + * + * @param customData Custom, plugin-specific data associated with the attachment (out). + * It must be allocated by the plugin using OrthancPluginCreateMemoryBuffer(). The core of Orthanc will free it. + * If the plugin does not generate custom data, leave `customData` unchanged; it will default to an empty value. + * @param uuid The UUID of the file. + * @param content The content of the file (might be compressed data). + * @param size The size of the file. + * @param type The content type corresponding to this file. + * @param compressionType The compression algorithm that was used to encode `content` + * (the absence of compression is indicated using `OrthancPluginCompressionType_None`). + * @param dicomInstance The DICOM instance being stored. Equals `NULL` if not storing a DICOM instance. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageCreate2) ( + OrthancPluginMemoryBuffer* customData, + const char* uuid, + const void* content, + uint64_t size, + OrthancPluginContentType type, + OrthancPluginCompressionType compressionType, + const OrthancPluginDicomInstance* dicomInstance); + + + + /** + * @brief Callback for reading a range of a file from the storage area. + * + * Signature of a callback function that is triggered when Orthanc + * reads a portion of a file from the storage area. Orthanc + * indicates the start position and the length of the range. + * + * @param target Memory buffer where to store the content of the range. + * The memory buffer is allocated and freed by Orthanc. The length of the range + * of interest corresponds to the size of this buffer. + * @param uuid The UUID of the file of interest. + * @param type The content type corresponding to this file. + * @param rangeStart Start position of the requested range in the file. + * @param customData The custom data of the file of interest. + * @param customDataSize The size of the custom data. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageReadRange2) ( + OrthancPluginMemoryBuffer64* target, + const char* uuid, + OrthancPluginContentType type, + uint64_t rangeStart, + const void* customData, + uint32_t customDataSize); + + + + /** + * @brief Callback for removing a file from the storage area. + * + * Signature of a callback function that is triggered when Orthanc + * deletes a file from the storage area. + * + * @param uuid The UUID of the file to be removed. + * @param type The content type corresponding to this file. + * @param customData The custom data of the file to be removed. + * @param customDataSize The size of the custom data. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageRemove2) ( + const char* uuid, + OrthancPluginContentType type, + const void* customData, + uint32_t customDataSize); + + + /** + * @brief Callback to handle the C-Find SCP requests for worklists. + * + * Signature of a callback function that is triggered when Orthanc + * receives a C-Find SCP request against modality worklists. + * + * @param answers The target structure where answers must be stored. + * @param query The worklist query. + * @param issuerAet The Application Entity Title (AET) of the modality from which the request originates. + * @param calledAet The Application Entity Title (AET) of the modality that is called by the request. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWorklistCallback) ( + OrthancPluginWorklistAnswers* answers, + const OrthancPluginWorklistQuery* query, + const char* issuerAet, + const char* calledAet); + + + + /** + * @brief Callback to filter incoming HTTP requests received by Orthanc. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives an HTTP/REST request, and that answers whether + * this request should be allowed. If the callback returns "0" + * ("false"), the server answers with HTTP status code 403 + * (Forbidden). + * + * Pay attention to the fact that this function may be invoked + * concurrently by different threads of the Web server of + * Orthanc. You must implement proper locking if applicable. + * + * @param method The HTTP method used by the request. + * @param uri The URI of interest. + * @param ip The IP address of the HTTP client. + * @param headersCount The number of HTTP headers. + * @param headersKeys The keys of the HTTP headers (always converted to low-case). + * @param headersValues The values of the HTTP headers. + * @return 0 if forbidden access, 1 if allowed access, -1 if error. + * @ingroup Callbacks + * @deprecated Please instead use OrthancPluginIncomingHttpRequestFilter2() + **/ + typedef int32_t (*OrthancPluginIncomingHttpRequestFilter) ( + OrthancPluginHttpMethod method, + const char* uri, + const char* ip, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues); + + + + /** + * @brief Callback to filter incoming HTTP requests received by Orthanc. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives an HTTP/REST request, and that answers whether + * this request should be allowed. If the callback returns "0" + * ("false"), the server answers with HTTP status code 403 + * (Forbidden). + * + * Pay attention to the fact that this function may be invoked + * concurrently by different threads of the Web server of + * Orthanc. You must implement proper locking if applicable. + * + * Note that if you are using HTTP basic authentication, you can + * extract the username from the "Authorization" HTTP header. The + * value of that header contains username:pwd encoded in base64. + * + * @param method The HTTP method used by the request. + * @param uri The URI of interest. + * @param ip The IP address of the HTTP client. + * @param headersCount The number of HTTP headers. + * @param headersKeys The keys of the HTTP headers (always converted to low-case). + * @param headersValues The values of the HTTP headers. + * @param getArgumentsCount The number of GET arguments (only for the GET HTTP method). + * @param getArgumentsKeys The keys of the GET arguments (only for the GET HTTP method). + * @param getArgumentsValues The values of the GET arguments (only for the GET HTTP method). + * @return 0 if forbidden access, 1 if allowed access, -1 if error. + * @ingroup Callbacks + **/ + typedef int32_t (*OrthancPluginIncomingHttpRequestFilter2) ( + OrthancPluginHttpMethod method, + const char* uri, + const char* ip, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues, + uint32_t getArgumentsCount, + const char* const* getArgumentsKeys, + const char* const* getArgumentsValues); + + + + /** + * @brief Callback to handle incoming C-Find SCP requests. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives a C-Find SCP request not concerning modality + * worklists. + * + * @param answers The target structure where answers must be stored. + * @param query The worklist query. + * @param issuerAet The Application Entity Title (AET) of the modality from which the request originates. + * @param calledAet The Application Entity Title (AET) of the modality that is called by the request. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginFindCallback) ( + OrthancPluginFindAnswers* answers, + const OrthancPluginFindQuery* query, + const char* issuerAet, + const char* calledAet); + + + + /** + * @brief Callback to handle incoming C-Move SCP requests. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives a C-Move SCP request. The callback receives the + * type of the resource of interest (study, series, instance...) + * together with the DICOM tags containing its identifiers. In turn, + * the plugin must create a driver object that will be responsible + * for driving the successive move suboperations. + * + * @param resourceType The type of the resource of interest. Note + * that this might be set to ResourceType_None if the + * QueryRetrieveLevel (0008,0052) tag was not provided by the + * issuer (i.e. the originator modality). + * @param patientId Content of the PatientID (0x0010, 0x0020) tag of the resource of interest. Might be NULL. + * @param accessionNumber Content of the AccessionNumber (0x0008, 0x0050) tag. Might be NULL. + * @param studyInstanceUid Content of the StudyInstanceUID (0x0020, 0x000d) tag. Might be NULL. + * @param seriesInstanceUid Content of the SeriesInstanceUID (0x0020, 0x000e) tag. Might be NULL. + * @param sopInstanceUid Content of the SOPInstanceUID (0x0008, 0x0018) tag. Might be NULL. + * @param originatorAet The Application Entity Title (AET) of the + * modality from which the request originates. + * @param sourceAet The Application Entity Title (AET) of the + * modality that should send its DICOM files to another modality. + * @param targetAet The Application Entity Title (AET) of the + * modality that should receive the DICOM files. + * @param originatorId The Message ID issued by the originator modality, + * as found in tag (0000,0110) of the DICOM query emitted by the issuer. + * + * @return The NULL value if the plugin cannot deal with this query, + * or a pointer to the driver object that is responsible for + * handling the successive move suboperations. + * + * @note If targetAet equals sourceAet, this is actually a query/retrieve operation. + * @ingroup DicomCallbacks + **/ + typedef void* (*OrthancPluginMoveCallback) ( + OrthancPluginResourceType resourceType, + const char* patientId, + const char* accessionNumber, + const char* studyInstanceUid, + const char* seriesInstanceUid, + const char* sopInstanceUid, + const char* originatorAet, + const char* sourceAet, + const char* targetAet, + uint16_t originatorId); + + + /** + * @brief Callback to read the size of a C-Move driver. + * + * Signature of a callback function that returns the number of + * C-Move suboperations that are to be achieved by the given C-Move + * driver. This driver is the return value of a previous call to the + * OrthancPluginMoveCallback() callback. + * + * @param moveDriver The C-Move driver of interest. + * @return The number of suboperations. + * @ingroup DicomCallbacks + **/ + typedef uint32_t (*OrthancPluginGetMoveSize) (void* moveDriver); + + + /** + * @brief Callback to apply one C-Move suboperation. + * + * Signature of a callback function that applies the next C-Move + * suboperation that os to be achieved by the given C-Move + * driver. This driver is the return value of a previous call to the + * OrthancPluginMoveCallback() callback. + * + * @param moveDriver The C-Move driver of interest. + * @return 0 if success, or the error code if failure. + * @ingroup DicomCallbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginApplyMove) (void* moveDriver); + + + /** + * @brief Callback to free one C-Move driver. + * + * Signature of a callback function that releases the resources + * allocated by the given C-Move driver. This driver is the return + * value of a previous call to the OrthancPluginMoveCallback() + * callback. + * + * @param moveDriver The C-Move driver of interest. + * @ingroup DicomCallbacks + **/ + typedef void (*OrthancPluginFreeMove) (void* moveDriver); + + + /** + * @brief Callback to finalize one custom job. + * + * Signature of a callback function that releases all the resources + * allocated by the given job. This job is the argument provided to + * OrthancPluginCreateJob(). + * + * @param job The job of interest. + * @ingroup Toolbox + **/ + typedef void (*OrthancPluginJobFinalize) (void* job); + + + /** + * @brief Callback to check the progress of one custom job. + * + * Signature of a callback function that returns the progress of the + * job. + * + * @param job The job of interest. + * @return The progress, as a floating-point number ranging from 0 to 1. + * @ingroup Toolbox + **/ + typedef float (*OrthancPluginJobGetProgress) (void* job); + + + /** + * @brief Callback to retrieve the content of one custom job. + * + * Signature of a callback function that returns human-readable + * statistics about the job. This statistics must be formatted as a + * JSON object. This information is notably displayed in the "Jobs" + * tab of "Orthanc Explorer". + * + * @param job The job of interest. + * @return The statistics, as a JSON object encoded as a string. + * @ingroup Toolbox + * @deprecated This signature should not be used anymore since Orthanc SDK 1.11.3. + **/ + typedef const char* (*OrthancPluginJobGetContent) (void* job); + + + /** + * @brief Callback to retrieve the content of one custom job. + * + * Signature of a callback function that returns human-readable + * statistics about the job. This statistics must be formatted as a + * JSON object. This information is notably displayed in the "Jobs" + * tab of "Orthanc Explorer". + * + * @param target The target memory buffer where to store the JSON string. + * This buffer must be allocated using OrthancPluginCreateMemoryBuffer() + * and will be freed by the Orthanc core. + * @param job The job of interest. + * @return 0 if success, other value if error. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginJobGetContent2) (OrthancPluginMemoryBuffer* target, + void* job); + + + /** + * @brief Callback to serialize one custom job. + * + * Signature of a callback function that returns a serialized + * version of the job, formatted as a JSON object. This + * serialization is stored in the Orthanc database, and is used to + * reload the job on the restart of Orthanc. The "unserialization" + * callback (with OrthancPluginJobsUnserializer signature) will + * receive this serialized object. + * + * @param job The job of interest. + * @return The serialized job, as a JSON object encoded as a string. + * @see OrthancPluginRegisterJobsUnserializer() + * @ingroup Toolbox + * @deprecated This signature should not be used anymore since Orthanc SDK 1.11.3. + **/ + typedef const char* (*OrthancPluginJobGetSerialized) (void* job); + + + /** + * @brief Callback to serialize one custom job. + * + * Signature of a callback function that returns a serialized + * version of the job, formatted as a JSON object. This + * serialization is stored in the Orthanc database, and is used to + * reload the job on the restart of Orthanc. The "unserialization" + * callback (with OrthancPluginJobsUnserializer signature) will + * receive this serialized object. + * + * @param target The target memory buffer where to store the JSON string. + * This buffer must be allocated using OrthancPluginCreateMemoryBuffer() + * and will be freed by the Orthanc core. + * @param job The job of interest. + * @return 1 if the serialization has succeeded, 0 if serialization is + * not implemented for this type of job, or -1 in case of error. + **/ + typedef int32_t (*OrthancPluginJobGetSerialized2) (OrthancPluginMemoryBuffer* target, + void* job); + + + /** + * @brief Callback to execute one step of a custom job. + * + * Signature of a callback function that executes one step in the + * job. The jobs engine of Orthanc will make successive calls to + * this method, as long as it returns + * OrthancPluginJobStepStatus_Continue. + * + * @param job The job of interest. + * @return The status of execution. + * @ingroup Toolbox + **/ + typedef OrthancPluginJobStepStatus (*OrthancPluginJobStep) (void* job); + + + /** + * @brief Callback executed once one custom job leaves the "running" state. + * + * Signature of a callback function that is invoked once a job + * leaves the "running" state. This can happen if the previous call + * to OrthancPluginJobStep has failed/succeeded, if the host Orthanc + * server is being stopped, or if the user manually tags the job as + * paused/canceled. This callback allows the plugin to free + * resources allocated for running this custom job (e.g. to stop + * threads, or to remove temporary files). + * + * Note that handling pauses might involves a specific treatment + * (such a stopping threads, but keeping temporary files on the + * disk). This "paused" situation can be checked by looking at the + * "reason" parameter. + * + * @param job The job of interest. + * @param reason The reason for leaving the "running" state. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginJobStop) (void* job, + OrthancPluginJobStopReason reason); + + + /** + * @brief Callback executed once one stopped custom job is started again. + * + * Signature of a callback function that is invoked once a job + * leaves the "failure/canceled" state, to be started again. This + * function will typically reset the progress to zero. Note that + * before being actually executed, the job would first be tagged as + * "pending" in the Orthanc jobs engine. + * + * @param job The job of interest. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginJobReset) (void* job); + + + /** + * @brief Callback executed to unserialize a custom job. + * + * Signature of a callback function that unserializes a job that was + * saved in the Orthanc database. + * + * @param jobType The type of the job, as provided to OrthancPluginCreateJob(). + * @param serialized The serialization of the job, as provided by OrthancPluginJobGetSerialized. + * @return The unserialized job (as created by OrthancPluginCreateJob()), or NULL + * if this unserializer cannot handle this job type. + * @see OrthancPluginRegisterJobsUnserializer() + * @ingroup Callbacks + **/ + typedef OrthancPluginJob* (*OrthancPluginJobsUnserializer) (const char* jobType, + const char* serialized); + + + + /** + * @brief Callback executed to update the metrics of the plugin. + * + * Signature of a callback function that is called by Orthanc + * whenever a monitoring tool (such as Prometheus) asks the current + * values of the metrics. This callback gives the plugin a chance to + * update its metrics, by calling OrthancPluginSetMetricsValue() or + * OrthancPluginSetMetricsIntegerValue(). + * This is typically useful for metrics that are expensive to + * acquire. + * + * @see OrthancPluginRegisterRefreshMetrics() + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginRefreshMetricsCallback) (); + + + + /** + * @brief Callback executed to encode a binary tag in DICOMweb. + * + * Signature of a callback function that is called by Orthanc + * whenever a DICOM tag that contains a binary value must be written + * to a JSON or XML node, while a DICOMweb document is being + * generated. The value representation (VR) of the DICOM tag can be + * OB, OD, OF, OL, OW, or UN. + * + * @see OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml() + * @param node The node being generated, as provided by Orthanc. + * @param setter The setter to be used to encode the content of the node. If + * the setter is not called, the binary tag is not written to the output document. + * @param levelDepth The depth of the node in the DICOM hierarchy of sequences. + * This parameter gives the number of elements in the "levelTagGroup", + * "levelTagElement", and "levelIndex" arrays. + * @param levelTagGroup The group of the parent DICOM tags in the hierarchy. + * @param levelTagElement The element of the parent DICOM tags in the hierarchy. + * @param levelIndex The index of the node in the parent sequences of the hierarchy. + * @param tagGroup The group of the DICOM tag of interest. + * @param tagElement The element of the DICOM tag of interest. + * @param vr The value representation of the binary DICOM node. + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginDicomWebBinaryCallback) ( + OrthancPluginDicomWebNode* node, + OrthancPluginDicomWebSetBinaryNode setter, + uint32_t levelDepth, + const uint16_t* levelTagGroup, + const uint16_t* levelTagElement, + const uint32_t* levelIndex, + uint16_t tagGroup, + uint16_t tagElement, + OrthancPluginValueRepresentation vr); + + + + /** + * @brief Callback executed to encode a binary tag in DICOMweb. + * + * Signature of a callback function that is called by Orthanc + * whenever a DICOM tag that contains a binary value must be written + * to a JSON or XML node, while a DICOMweb document is being + * generated. The value representation (VR) of the DICOM tag can be + * OB, OD, OF, OL, OW, or UN. + * + * @see OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml() + * @param node The node being generated, as provided by Orthanc. + * @param setter The setter to be used to encode the content of the node. If + * the setter is not called, the binary tag is not written to the output document. + * @param levelDepth The depth of the node in the DICOM hierarchy of sequences. + * This parameter gives the number of elements in the "levelTagGroup", + * "levelTagElement", and "levelIndex" arrays. + * @param levelTagGroup The group of the parent DICOM tags in the hierarchy. + * @param levelTagElement The element of the parent DICOM tags in the hierarchy. + * @param levelIndex The index of the node in the parent sequences of the hierarchy. + * @param tagGroup The group of the DICOM tag of interest. + * @param tagElement The element of the DICOM tag of interest. + * @param vr The value representation of the binary DICOM node. + * @param payload The user payload. + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginDicomWebBinaryCallback2) ( + OrthancPluginDicomWebNode* node, + OrthancPluginDicomWebSetBinaryNode setter, + uint32_t levelDepth, + const uint16_t* levelTagGroup, + const uint16_t* levelTagElement, + const uint32_t* levelIndex, + uint16_t tagGroup, + uint16_t tagElement, + OrthancPluginValueRepresentation vr, + void* payload); + + + + /** + * @brief Data structure that contains information about the Orthanc core. + **/ + typedef struct _OrthancPluginContext_t + { + void* pluginsManager; + const char* orthancVersion; + OrthancPluginFree Free; + OrthancPluginErrorCode (*InvokeService) (struct _OrthancPluginContext_t* context, + _OrthancPluginService service, + const void* params); + } OrthancPluginContext; + + + + /** + * @brief An entry in the dictionary of DICOM tags. + **/ + typedef struct + { + uint16_t group; /*!< The group of the tag */ + uint16_t element; /*!< The element of the tag */ + OrthancPluginValueRepresentation vr; /*!< The value representation of the tag */ + uint32_t minMultiplicity; /*!< The minimum multiplicity of the tag */ + uint32_t maxMultiplicity; /*!< The maximum multiplicity of the tag (0 means arbitrary) */ + } OrthancPluginDictionaryEntry; + + + + /** + * @brief Free a string. + * + * Free a string that was allocated by the core system of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param str The string to be freed. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeString( + OrthancPluginContext* context, + char* str) + { + if (str != NULL) + { + context->Free(str); + } + } + + + /** + * @brief Check that the version of the hosting Orthanc is above a given version. + * + * This function checks whether the version of the Orthanc server + * running this plugin, is above the given version. Contrarily to + * OrthancPluginCheckVersion(), it is up to the developer of the + * plugin to make sure that all the Orthanc SDK services called by + * the plugin are actually implemented in the given version of + * Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param expectedMajor Expected major version. + * @param expectedMinor Expected minor version. + * @param expectedRevision Expected revision. + * @return 1 if and only if the versions are compatible. If the + * result is 0, the initialization of the plugin should fail. + * @see OrthancPluginCheckVersion() + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.4.0") + ORTHANC_PLUGIN_INLINE int32_t OrthancPluginCheckVersionAdvanced( + OrthancPluginContext* context, + int32_t expectedMajor, + int32_t expectedMinor, + int32_t expectedRevision) + { + int32_t major, minor, revision; + + if (sizeof(int) != sizeof(int32_t) || /* Ensure binary compatibility with Orthanc SDK <= 1.12.1 */ + sizeof(int32_t) != sizeof(OrthancPluginErrorCode) || + sizeof(int32_t) != sizeof(OrthancPluginHttpMethod) || + sizeof(int32_t) != sizeof(_OrthancPluginService) || + sizeof(int32_t) != sizeof(_OrthancPluginProperty) || + sizeof(int32_t) != sizeof(OrthancPluginPixelFormat) || + sizeof(int32_t) != sizeof(OrthancPluginContentType) || + sizeof(int32_t) != sizeof(OrthancPluginResourceType) || + sizeof(int32_t) != sizeof(OrthancPluginChangeType) || + sizeof(int32_t) != sizeof(OrthancPluginCompressionType) || + sizeof(int32_t) != sizeof(OrthancPluginImageFormat) || + sizeof(int32_t) != sizeof(OrthancPluginValueRepresentation) || + sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFormat) || + sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFlags) || + sizeof(int32_t) != sizeof(OrthancPluginCreateDicomFlags) || + sizeof(int32_t) != sizeof(OrthancPluginIdentifierConstraint) || + sizeof(int32_t) != sizeof(OrthancPluginInstanceOrigin) || + sizeof(int32_t) != sizeof(OrthancPluginJobStepStatus) || + sizeof(int32_t) != sizeof(OrthancPluginJobStopReason) || + sizeof(int32_t) != sizeof(OrthancPluginConstraintType) || + sizeof(int32_t) != sizeof(OrthancPluginMetricsType) || + sizeof(int32_t) != sizeof(OrthancPluginDicomWebBinaryMode) || + sizeof(int32_t) != sizeof(OrthancPluginStorageCommitmentFailureReason) || + sizeof(int32_t) != sizeof(OrthancPluginReceivedInstanceAction) || + sizeof(int32_t) != sizeof(OrthancPluginLoadDicomInstanceMode) || + sizeof(int32_t) != sizeof(OrthancPluginLogLevel) || + sizeof(int32_t) != sizeof(OrthancPluginLogCategory) || + sizeof(int32_t) != sizeof(OrthancPluginStoreStatus) || + sizeof(int32_t) != sizeof(OrthancPluginQueueOrigin) || + sizeof(int32_t) != sizeof(OrthancPluginStableStatus) || + sizeof(int32_t) != sizeof(OrthancPluginHttpAuthenticationStatus)) + { + /* Mismatch in the size of the enumerations */ + return 0; + } + + /* Assume compatibility with the mainline */ + if (!strcmp(context->orthancVersion, "mainline")) + { + return 1; + } + + /* Parse the version of the Orthanc core */ + if ( +#ifdef _MSC_VER + sscanf_s +#else + sscanf +#endif + (context->orthancVersion, "%4d.%4d.%4d", &major, &minor, &revision) != 3) + { + return 0; + } + + /* Check the major number of the version */ + + if (major > expectedMajor) + { + return 1; + } + + if (major < expectedMajor) + { + return 0; + } + + /* Check the minor number of the version */ + + if (minor > expectedMinor) + { + return 1; + } + + if (minor < expectedMinor) + { + return 0; + } + + /* Check the revision number of the version */ + + if (revision >= expectedRevision) + { + return 1; + } + else + { + return 0; + } + } + + + /** + * @brief Check the compatibility of the plugin wrt. the version of its hosting Orthanc. + * + * This function checks whether the version of the Orthanc server + * running this plugin, is above the version of the current Orthanc + * SDK header. This guarantees that the plugin is compatible with + * the hosting Orthanc (i.e. it will not call unavailable services). + * The result of this function should always be checked in the + * OrthancPluginInitialize() entry point of the plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return 1 if and only if the versions are compatible. If the + * result is 0, the initialization of the plugin should fail. + * @see OrthancPluginCheckVersionAdvanced() + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE int32_t OrthancPluginCheckVersion( + OrthancPluginContext* context) + { + return OrthancPluginCheckVersionAdvanced( + context, + ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, + ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, + ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); + } + + + /** + * @brief Free a memory buffer. + * + * Free a memory buffer that was allocated by the core system of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The memory buffer to release. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeMemoryBuffer( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* buffer) + { + context->Free(buffer->data); + } + + + /** + * @brief Free a memory buffer. + * + * Free a memory buffer that was allocated by the core system of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The memory buffer to release. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.9.0") + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeMemoryBuffer64( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer64* buffer) + { + context->Free(buffer->data); + } + + + /** + * @brief Log an error. + * + * Log an error message using the Orthanc logging system. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param message The message to be logged. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginLogError( + OrthancPluginContext* context, + const char* message) + { + context->InvokeService(context, _OrthancPluginService_LogError, message); + } + + + /** + * @brief Log a warning. + * + * Log a warning message using the Orthanc logging system. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param message The message to be logged. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginLogWarning( + OrthancPluginContext* context, + const char* message) + { + context->InvokeService(context, _OrthancPluginService_LogWarning, message); + } + + + /** + * @brief Log an information. + * + * Log an information message using the Orthanc logging system. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param message The message to be logged. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginLogInfo( + OrthancPluginContext* context, + const char* message) + { + context->InvokeService(context, _OrthancPluginService_LogInfo, message); + } + + + + typedef struct + { + const char* pathRegularExpression; + OrthancPluginRestCallback callback; + } _OrthancPluginRestCallback; + + /** + * @brief Register a REST callback. + * + * This function registers a REST callback against a regular + * expression for a URI. This function must be called during the + * initialization of the plugin, i.e. inside the + * OrthancPluginInitialize() public function. + * + * Each REST callback is guaranteed to run in mutual exclusion. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param pathRegularExpression Regular expression for the URI. May contain groups. + * @param callback The callback function to handle the REST call. + * @see OrthancPluginRegisterRestCallbackNoLock() + * + * @note + * The regular expression is case sensitive and must follow the + * [Perl syntax](https://www.boost.org/doc/libs/1_67_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html). + * + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallback( + OrthancPluginContext* context, + const char* pathRegularExpression, + OrthancPluginRestCallback callback) + { + _OrthancPluginRestCallback params; + params.pathRegularExpression = pathRegularExpression; + params.callback = callback; + context->InvokeService(context, _OrthancPluginService_RegisterRestCallback, ¶ms); + } + + + + /** + * @brief Register a REST callback, without locking. + * + * This function registers a REST callback against a regular + * expression for a URI. This function must be called during the + * initialization of the plugin, i.e. inside the + * OrthancPluginInitialize() public function. + * + * Contrarily to OrthancPluginRegisterRestCallback(), the callback + * will NOT be invoked in mutual exclusion. This can be useful for + * high-performance plugins that must handle concurrent requests + * (Orthanc uses a pool of threads, one thread being assigned to + * each incoming HTTP request). Of course, if using this function, + * it is up to the plugin to implement the required locking + * mechanisms. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param pathRegularExpression Regular expression for the URI. May contain groups. + * @param callback The callback function to handle the REST call. + * @see OrthancPluginRegisterRestCallback() + * + * @note + * The regular expression is case sensitive and must follow the + * [Perl syntax](https://www.boost.org/doc/libs/1_67_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html). + * + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallbackNoLock( + OrthancPluginContext* context, + const char* pathRegularExpression, + OrthancPluginRestCallback callback) + { + _OrthancPluginRestCallback params; + params.pathRegularExpression = pathRegularExpression; + params.callback = callback; + context->InvokeService(context, _OrthancPluginService_RegisterRestCallbackNoLock, ¶ms); + } + + + + typedef struct + { + OrthancPluginOnStoredInstanceCallback callback; + } _OrthancPluginOnStoredInstanceCallback; + + /** + * @brief Register a callback for received instances. + * + * This function registers a callback function that is called + * whenever a new DICOM instance is stored into the Orthanc core. + * + * @warning Your callback function will be called synchronously with + * the core of Orthanc. This implies that deadlocks might emerge if + * you call other core primitives of Orthanc in your callback (such + * deadlocks are particularly visible in the presence of other plugins + * or Lua scripts). It is thus strongly advised to avoid any call to + * the REST API of Orthanc in the callback. If you have to call + * other primitives of Orthanc, you should make these calls in a + * separate thread, passing the pending events to be processed + * through a message queue. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback function. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterOnStoredInstanceCallback( + OrthancPluginContext* context, + OrthancPluginOnStoredInstanceCallback callback) + { + _OrthancPluginOnStoredInstanceCallback params; + params.callback = callback; + + context->InvokeService(context, _OrthancPluginService_RegisterOnStoredInstanceCallback, ¶ms); + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + const void* answer; + uint32_t answerSize; + const char* mimeType; + } _OrthancPluginAnswerBuffer; + + /** + * @brief Answer to a REST request. + * + * This function answers to a REST request with the content of a memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param answer Pointer to the memory buffer containing the answer. + * @param answerSize Number of bytes of the answer. + * @param mimeType The MIME type of the answer. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginAnswerBuffer( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const void* answer, + uint32_t answerSize, + const char* mimeType) + { + _OrthancPluginAnswerBuffer params; + params.output = output; + params.answer = answer; + params.answerSize = answerSize; + params.mimeType = mimeType; + context->InvokeService(context, _OrthancPluginService_AnswerBuffer, ¶ms); + } + + + typedef struct + { + OrthancPluginRestOutput* output; + OrthancPluginPixelFormat format; + uint32_t width; + uint32_t height; + uint32_t pitch; + const void* buffer; + } _OrthancPluginCompressAndAnswerPngImage; + + typedef struct + { + OrthancPluginRestOutput* output; + OrthancPluginImageFormat imageFormat; + OrthancPluginPixelFormat pixelFormat; + uint32_t width; + uint32_t height; + uint32_t pitch; + const void* buffer; + uint8_t quality; + } _OrthancPluginCompressAndAnswerImage; + + + /** + * @brief Answer to a REST request with a PNG image. + * + * This function answers to a REST request with a PNG image. The + * parameters of this function describe a memory buffer that + * contains an uncompressed image. The image will be automatically compressed + * as a PNG image by the core system of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param format The memory layout of the uncompressed image. + * @param width The width of the image. + * @param height The height of the image. + * @param pitch The pitch of the image (i.e. the number of bytes + * between 2 successive lines of the image in the memory buffer). + * @param buffer The memory buffer containing the uncompressed image. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerPngImage( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height, + uint32_t pitch, + const void* buffer) + { + _OrthancPluginCompressAndAnswerImage params; + params.output = output; + params.imageFormat = OrthancPluginImageFormat_Png; + params.pixelFormat = format; + params.width = width; + params.height = height; + params.pitch = pitch; + params.buffer = buffer; + params.quality = 0; /* No quality for PNG */ + context->InvokeService(context, _OrthancPluginService_CompressAndAnswerImage, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* instanceId; + } _OrthancPluginGetDicomForInstance; + + /** + * @brief Retrieve a DICOM instance using its Orthanc identifier. + * + * Retrieve a DICOM instance using its Orthanc identifier. The DICOM + * file is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param instanceId The Orthanc identifier of the DICOM instance of interest. + * @return 0 if success, or the error code if failure. + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetDicomForInstance( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* instanceId) + { + _OrthancPluginGetDicomForInstance params; + params.target = target; + params.instanceId = instanceId; + return context->InvokeService(context, _OrthancPluginService_GetDicomForInstance, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* uri; + } _OrthancPluginRestApiGet; + + /** + * @brief Make a GET call to the built-in Orthanc REST API. + * + * Make a GET call to the built-in Orthanc REST API. The result to + * the query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiGetAfterPlugins() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGet( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri) + { + _OrthancPluginRestApiGet params; + params.target = target; + params.uri = uri; + return context->InvokeService(context, _OrthancPluginService_RestApiGet, ¶ms); + } + + + + /** + * @brief Make a GET call to the REST API, as tainted by the plugins. + * + * Make a GET call to the Orthanc REST API, after all the plugins + * are applied. In other words, if some plugin overrides or adds the + * called URI to the built-in Orthanc REST API, this call will + * return the result provided by this plugin. The result to the + * query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiGet() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGetAfterPlugins( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri) + { + _OrthancPluginRestApiGet params; + params.target = target; + params.uri = uri; + return context->InvokeService(context, _OrthancPluginService_RestApiGetAfterPlugins, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* uri; + const void* body; + uint32_t bodySize; + } _OrthancPluginRestApiPostPut; + + /** + * @brief Make a POST call to the built-in Orthanc REST API. + * + * Make a POST call to the built-in Orthanc REST API. The result to + * the query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @param body The body of the POST request. + * @param bodySize The size of the body. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiPostAfterPlugins() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPost( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri, + const void* body, + uint32_t bodySize) + { + _OrthancPluginRestApiPostPut params; + params.target = target; + params.uri = uri; + params.body = body; + params.bodySize = bodySize; + return context->InvokeService(context, _OrthancPluginService_RestApiPost, ¶ms); + } + + + /** + * @brief Make a POST call to the REST API, as tainted by the plugins. + * + * Make a POST call to the Orthanc REST API, after all the plugins + * are applied. In other words, if some plugin overrides or adds the + * called URI to the built-in Orthanc REST API, this call will + * return the result provided by this plugin. The result to the + * query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @param body The body of the POST request. + * @param bodySize The size of the body. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiPost() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPostAfterPlugins( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri, + const void* body, + uint32_t bodySize) + { + _OrthancPluginRestApiPostPut params; + params.target = target; + params.uri = uri; + params.body = body; + params.bodySize = bodySize; + return context->InvokeService(context, _OrthancPluginService_RestApiPostAfterPlugins, ¶ms); + } + + + + /** + * @brief Make a DELETE call to the built-in Orthanc REST API. + * + * Make a DELETE call to the built-in Orthanc REST API. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param uri The URI to delete in the built-in Orthanc API. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiDeleteAfterPlugins() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiDelete( + OrthancPluginContext* context, + const char* uri) + { + return context->InvokeService(context, _OrthancPluginService_RestApiDelete, uri); + } + + + /** + * @brief Make a DELETE call to the REST API, as tainted by the plugins. + * + * Make a DELETE call to the Orthanc REST API, after all the plugins + * are applied. In other words, if some plugin overrides or adds the + * called URI to the built-in Orthanc REST API, this call will + * return the result provided by this plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param uri The URI to delete in the built-in Orthanc API. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiDelete() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiDeleteAfterPlugins( + OrthancPluginContext* context, + const char* uri) + { + return context->InvokeService(context, _OrthancPluginService_RestApiDeleteAfterPlugins, uri); + } + + + + /** + * @brief Make a PUT call to the built-in Orthanc REST API. + * + * Make a PUT call to the built-in Orthanc REST API. The result to + * the query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @param body The body of the PUT request. + * @param bodySize The size of the body. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiPutAfterPlugins() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPut( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri, + const void* body, + uint32_t bodySize) + { + _OrthancPluginRestApiPostPut params; + params.target = target; + params.uri = uri; + params.body = body; + params.bodySize = bodySize; + return context->InvokeService(context, _OrthancPluginService_RestApiPut, ¶ms); + } + + + + /** + * @brief Make a PUT call to the REST API, as tainted by the plugins. + * + * Make a PUT call to the Orthanc REST API, after all the plugins + * are applied. In other words, if some plugin overrides or adds the + * called URI to the built-in Orthanc REST API, this call will + * return the result provided by this plugin. The result to the + * query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @param body The body of the PUT request. + * @param bodySize The size of the body. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiPut() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPutAfterPlugins( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri, + const void* body, + uint32_t bodySize) + { + _OrthancPluginRestApiPostPut params; + params.target = target; + params.uri = uri; + params.body = body; + params.bodySize = bodySize; + return context->InvokeService(context, _OrthancPluginService_RestApiPutAfterPlugins, ¶ms); + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + const char* argument; + } _OrthancPluginOutputPlusArgument; + + /** + * @brief Redirect a REST request. + * + * This function answers to a REST request by redirecting the user + * to another URI using HTTP status 301. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param redirection Where to redirect. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRedirect( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* redirection) + { + _OrthancPluginOutputPlusArgument params; + params.output = output; + params.argument = redirection; + context->InvokeService(context, _OrthancPluginService_Redirect, ¶ms); + } + + + + typedef struct + { + char** result; + const char* argument; + } _OrthancPluginRetrieveDynamicString; + + /** + * @brief Look for a patient. + * + * Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020). + * This function uses the database index to run as fast as possible (it does not loop + * over all the stored patients). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param patientID The Patient ID of interest. + * @return The NULL value if the patient is non-existent, or a string containing the + * Orthanc ID of the patient. This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupPatient( + OrthancPluginContext* context, + const char* patientID) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = patientID; + + if (context->InvokeService(context, _OrthancPluginService_LookupPatient, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Look for a study. + * + * Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d). + * This function uses the database index to run as fast as possible (it does not loop + * over all the stored studies). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param studyUID The Study Instance UID of interest. + * @return The NULL value if the study is non-existent, or a string containing the + * Orthanc ID of the study. This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudy( + OrthancPluginContext* context, + const char* studyUID) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = studyUID; + + if (context->InvokeService(context, _OrthancPluginService_LookupStudy, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Look for a study, using the accession number. + * + * Look for a study stored in Orthanc, using its Accession Number tag (0x0008, 0x0050). + * This function uses the database index to run as fast as possible (it does not loop + * over all the stored studies). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param accessionNumber The Accession Number of interest. + * @return The NULL value if the study is non-existent, or a string containing the + * Orthanc ID of the study. This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudyWithAccessionNumber( + OrthancPluginContext* context, + const char* accessionNumber) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = accessionNumber; + + if (context->InvokeService(context, _OrthancPluginService_LookupStudyWithAccessionNumber, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Look for a series. + * + * Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e). + * This function uses the database index to run as fast as possible (it does not loop + * over all the stored series). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param seriesUID The Series Instance UID of interest. + * @return The NULL value if the series is non-existent, or a string containing the + * Orthanc ID of the series. This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupSeries( + OrthancPluginContext* context, + const char* seriesUID) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = seriesUID; + + if (context->InvokeService(context, _OrthancPluginService_LookupSeries, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Look for an instance. + * + * Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018). + * This function uses the database index to run as fast as possible (it does not loop + * over all the stored instances). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param sopInstanceUID The SOP Instance UID of interest. + * @return The NULL value if the instance is non-existent, or a string containing the + * Orthanc ID of the instance. This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupInstance( + OrthancPluginContext* context, + const char* sopInstanceUID) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = sopInstanceUID; + + if (context->InvokeService(context, _OrthancPluginService_LookupInstance, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + uint16_t status; + } _OrthancPluginSendHttpStatusCode; + + /** + * @brief Send a HTTP status code. + * + * This function answers to a REST request by sending a HTTP status + * code (such as "400 - Bad Request"). Note that: + * - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). + * - Redirections (status 301) must use ::OrthancPluginRedirect(). + * - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). + * - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param status The HTTP status code to be sent. + * @ingroup REST + * @see OrthancPluginSendHttpStatus() + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSendHttpStatusCode( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + uint16_t status) + { + _OrthancPluginSendHttpStatusCode params; + params.output = output; + params.status = status; + context->InvokeService(context, _OrthancPluginService_SendHttpStatusCode, ¶ms); + } + + + /** + * @brief Signal that a REST request is not authorized. + * + * This function answers to a REST request by signaling that it is + * not authorized. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param realm The realm for the authorization process. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSendUnauthorized( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* realm) + { + _OrthancPluginOutputPlusArgument params; + params.output = output; + params.argument = realm; + context->InvokeService(context, _OrthancPluginService_SendUnauthorized, ¶ms); + } + + + /** + * @brief Signal that this URI does not support this HTTP method. + * + * This function answers to a REST request by signaling that the + * queried URI does not support this method. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param allowedMethods The allowed methods for this URI (e.g. "GET,POST" after a PUT or a POST request). + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSendMethodNotAllowed( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* allowedMethods) + { + _OrthancPluginOutputPlusArgument params; + params.output = output; + params.argument = allowedMethods; + context->InvokeService(context, _OrthancPluginService_SendMethodNotAllowed, ¶ms); + } + + + typedef struct + { + OrthancPluginRestOutput* output; + const char* key; + const char* value; + } _OrthancPluginSetHttpHeader; + + /** + * @brief Set a cookie. + * + * This function sets a cookie in the HTTP client. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param cookie The cookie to be set. + * @param value The value of the cookie. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetCookie( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* cookie, + const char* value) + { + _OrthancPluginSetHttpHeader params; + params.output = output; + params.key = cookie; + params.value = value; + context->InvokeService(context, _OrthancPluginService_SetCookie, ¶ms); + } + + + /** + * @brief Set some HTTP header. + * + * This function sets a HTTP header in the HTTP answer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param key The HTTP header to be set. + * @param value The value of the HTTP header. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetHttpHeader( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* key, + const char* value) + { + _OrthancPluginSetHttpHeader params; + params.output = output; + params.key = key; + params.value = value; + context->InvokeService(context, _OrthancPluginService_SetHttpHeader, ¶ms); + } + + + typedef struct + { + char** resultStringToFree; + const char** resultString; + int64_t* resultInt64; + const char* key; + const OrthancPluginDicomInstance* instance; + OrthancPluginInstanceOrigin* resultOrigin; /* New in Orthanc 0.9.5 SDK */ + } _OrthancPluginAccessDicomInstance; + + + /** + * @brief Get the AET of a DICOM instance. + * + * This function returns the Application Entity Title (AET) of the + * DICOM modality from which a DICOM instance originates. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The AET if success, NULL if error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceRemoteAet( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + const char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultString = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceRemoteAet, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the size of a DICOM file. + * + * This function returns the number of bytes of the given DICOM instance. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The size of the file, -1 in case of error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE int64_t OrthancPluginGetInstanceSize( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + int64_t size; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultInt64 = &size; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceSize, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return -1; + } + else + { + return size; + } + } + + + /** + * @brief Get the data of a DICOM file. + * + * This function returns a pointer to the content of the given DICOM instance. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The pointer to the DICOM data, NULL in case of error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE const void* OrthancPluginGetInstanceData( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + const char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultString = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceData, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the DICOM tag hierarchy as a JSON file. + * + * This function returns a pointer to a newly created string + * containing a JSON file. This JSON file encodes the tag hierarchy + * of the given DICOM instance. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The NULL value in case of error, or a string containing the JSON file. + * This string must be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceJson( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultStringToFree = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the DICOM tag hierarchy as a JSON file (with simplification). + * + * This function returns a pointer to a newly created string + * containing a JSON file. This JSON file encodes the tag hierarchy + * of the given DICOM instance. In contrast with + * ::OrthancPluginGetInstanceJson(), the returned JSON file is in + * its simplified version. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The NULL value in case of error, or a string containing the JSON file. + * This string must be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceSimplifiedJson( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultStringToFree = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceSimplifiedJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Check whether a DICOM instance is associated with some metadata. + * + * This function checks whether the DICOM instance of interest is + * associated with some metadata. As of Orthanc 0.8.1, in the + * callbacks registered by + * ::OrthancPluginRegisterOnStoredInstanceCallback(), the only + * possibly available metadata are "ReceptionDate", "RemoteAET" and + * "IndexInSeries". + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @param metadata The metadata of interest. + * @return 1 if the metadata is present, 0 if it is absent, -1 in case of error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE int32_t OrthancPluginHasInstanceMetadata( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + const char* metadata) + { + int64_t result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultInt64 = &result; + params.instance = instance; + params.key = metadata; + + if (context->InvokeService(context, _OrthancPluginService_HasInstanceMetadata, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return -1; + } + else + { + return (result != 0); + } + } + + + /** + * @brief Get the value of some metadata associated with a given DICOM instance. + * + * This functions returns the value of some metadata that is associated with the DICOM instance of interest. + * Before calling this function, the existence of the metadata must have been checked with + * ::OrthancPluginHasInstanceMetadata(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @param metadata The metadata of interest. + * @return The metadata value if success, NULL if error. Please note that the + * returned string belongs to the instance object and must NOT be + * deallocated. Please make a copy of the string if you wish to access + * it later. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceMetadata( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + const char* metadata) + { + const char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultString = &result; + params.instance = instance; + params.key = metadata; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceMetadata, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginStorageCreate create; + OrthancPluginStorageRead read; + OrthancPluginStorageRemove remove; + OrthancPluginFree free; + } _OrthancPluginRegisterStorageArea; + + /** + * @brief Register a custom storage area. + * + * This function registers a custom storage area, to replace the + * built-in way Orthanc stores its files on the filesystem. This + * function must be called during the initialization of the plugin, + * i.e. inside the OrthancPluginInitialize() public function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param create The callback function to store a file on the custom storage area. + * @param read The callback function to read a file from the custom storage area. + * @param remove The callback function to remove a file from the custom storage area. + * @ingroup Callbacks + * @deprecated New plugins should use OrthancPluginRegisterStorageArea3() + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterStorageArea( + OrthancPluginContext* context, + OrthancPluginStorageCreate create, + OrthancPluginStorageRead read, + OrthancPluginStorageRemove remove) + { + _OrthancPluginRegisterStorageArea params; + params.create = create; + params.read = read; + params.remove = remove; + +#ifdef __cplusplus + params.free = ::free; +#else + params.free = free; +#endif + + context->InvokeService(context, _OrthancPluginService_RegisterStorageArea, ¶ms); + } + + + + /** + * @brief Return the path to the Orthanc executable. + * + * This function returns the path to the Orthanc executable. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL in the case of an error, or a newly allocated string + * containing the path. This string must be freed by + * OrthancPluginFreeString(). + **/ + ORTHANC_PLUGIN_INLINE char *OrthancPluginGetOrthancPath(OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetOrthancPath, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Return the directory containing the Orthanc. + * + * This function returns the path to the directory containing the Orthanc executable. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL in the case of an error, or a newly allocated string + * containing the path. This string must be freed by + * OrthancPluginFreeString(). + **/ + ORTHANC_PLUGIN_INLINE char *OrthancPluginGetOrthancDirectory(OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetOrthancDirectory, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Return the path to the configuration file(s). + * + * This function returns the path to the configuration file(s) that + * was specified when starting Orthanc. Since version 0.9.1, this + * path can refer to a folder that stores a set of configuration + * files. This function is deprecated in favor of + * OrthancPluginGetConfiguration(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL in the case of an error, or a newly allocated string + * containing the path. This string must be freed by + * OrthancPluginFreeString(). + * @see OrthancPluginGetConfiguration() + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE char *OrthancPluginGetConfigurationPath(OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetConfigurationPath, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginOnChangeCallback callback; + } _OrthancPluginOnChangeCallback; + + /** + * @brief Register a callback to monitor changes. + * + * This function registers a callback function that is called + * whenever a change happens to some DICOM resource. + * + * @warning Your callback function will be called synchronously with + * the core of Orthanc. This implies that deadlocks might emerge if + * you call other core primitives of Orthanc in your callback (such + * deadlocks are particularly visible in the presence of other plugins + * or Lua scripts). It is thus strongly advised to avoid any call to + * the REST API of Orthanc in the callback. If you have to call + * other primitives of Orthanc, you should make these calls in a + * separate thread, passing the pending events to be processed + * through a message queue. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback function. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterOnChangeCallback( + OrthancPluginContext* context, + OrthancPluginOnChangeCallback callback) + { + _OrthancPluginOnChangeCallback params; + params.callback = callback; + + context->InvokeService(context, _OrthancPluginService_RegisterOnChangeCallback, ¶ms); + } + + + + typedef struct + { + const char* plugin; + _OrthancPluginProperty property; + const char* value; + } _OrthancPluginSetPluginProperty; + + + /** + * @brief Set the URI where the plugin provides its Web interface. + * + * For plugins that come with a Web interface, this function + * declares the entry path where to find this interface. This + * information is notably used in the "Plugins" page of Orthanc + * Explorer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param uri The root URI for this plugin. + * + * @deprecated This function should not be used anymore because the + * result of the call to "OrthancPluginGetName()" depends on the + * system. Use "OrthancPluginSetRootUri2()" instead. + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE void OrthancPluginSetRootUri( + OrthancPluginContext* context, + const char* uri) + { + _OrthancPluginSetPluginProperty params; + params.plugin = OrthancPluginGetName(); + params.property = _OrthancPluginProperty_RootUri; + params.value = uri; + + context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); + } + + + /** + * @brief Set the URI where the plugin provides its Web interface. + * + * For plugins that come with a Web interface, this function + * declares the entry path where to find this interface. This + * information is notably used in the "Plugins" page of Orthanc + * Explorer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param plugin Identifier of your plugin (it must match "OrthancPluginGetName()"). + * @param uri The root URI for this plugin. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetRootUri2( + OrthancPluginContext* context, + const char* plugin, + const char* uri) + { + _OrthancPluginSetPluginProperty params; + params.plugin = plugin; + params.property = _OrthancPluginProperty_RootUri; + params.value = uri; + + context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); + } + + + /** + * @brief Set a description for this plugin. + * + * Set a description for this plugin. It is displayed in the + * "Plugins" page of Orthanc Explorer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param description The description. + * + * @deprecated This function should not be used anymore because the + * result of the call to "OrthancPluginGetName()" depends on the + * system. Use "OrthancPluginSetDescription2()" instead. + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE void OrthancPluginSetDescription( + OrthancPluginContext* context, + const char* description) + { + _OrthancPluginSetPluginProperty params; + params.plugin = OrthancPluginGetName(); + params.property = _OrthancPluginProperty_Description; + params.value = description; + + context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); + } + + + /** + * @brief Set a description for this plugin. + * + * Set a description for this plugin. It is displayed in the + * "Plugins" page of Orthanc Explorer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param plugin Identifier of your plugin (it must match "OrthancPluginGetName()"). + * @param description The description. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetDescription2( + OrthancPluginContext* context, + const char* plugin, + const char* description) + { + _OrthancPluginSetPluginProperty params; + params.plugin = plugin; + params.property = _OrthancPluginProperty_Description; + params.value = description; + + context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); + } + + + /** + * @brief Extend the JavaScript code of Orthanc Explorer. + * + * Add JavaScript code to customize the default behavior of Orthanc + * Explorer. This can for instance be used to add new buttons. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param javascript The custom JavaScript code. + * + * @deprecated This function should not be used anymore because the + * result of the call to "OrthancPluginGetName()" depends on the + * system. Use "OrthancPluginExtendOrthancExplorer2()" instead. + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE void OrthancPluginExtendOrthancExplorer( + OrthancPluginContext* context, + const char* javascript) + { + _OrthancPluginSetPluginProperty params; + params.plugin = OrthancPluginGetName(); + params.property = _OrthancPluginProperty_OrthancExplorer; + params.value = javascript; + + context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); + } + + + /** + * @brief Extend the JavaScript code of Orthanc Explorer. + * + * Add JavaScript code to customize the default behavior of Orthanc + * Explorer. This can for instance be used to add new buttons. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param plugin Identifier of your plugin (it must match "OrthancPluginGetName()"). + * @param javascript The custom JavaScript code. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginExtendOrthancExplorer2( + OrthancPluginContext* context, + const char* plugin, + const char* javascript) + { + _OrthancPluginSetPluginProperty params; + params.plugin = plugin; + params.property = _OrthancPluginProperty_OrthancExplorer; + params.value = javascript; + + context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); + } + + + typedef struct + { + char** result; + int32_t property; + const char* value; + } _OrthancPluginGlobalProperty; + + + /** + * @brief Get the value of a global property. + * + * Get the value of a global property that is stored in the Orthanc database. Global + * properties whose index is below 1024 are reserved by Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param property The global property of interest. + * @param defaultValue The value to return, if the global property is unset. + * @return The value of the global property, or NULL in the case of an error. This + * string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetGlobalProperty( + OrthancPluginContext* context, + int32_t property, + const char* defaultValue) + { + char* result; + + _OrthancPluginGlobalProperty params; + params.result = &result; + params.property = property; + params.value = defaultValue; + + if (context->InvokeService(context, _OrthancPluginService_GetGlobalProperty, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Set the value of a global property. + * + * Set the value of a global property into the Orthanc + * database. Setting a global property can be used by plugins to + * save their internal parameters. Plugins are only allowed to set + * properties whose index are above or equal to 1024 (properties + * below 1024 are read-only and reserved by Orthanc). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param property The global property of interest. + * @param value The value to be set in the global property. + * @return 0 if success, or the error code if failure. + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSetGlobalProperty( + OrthancPluginContext* context, + int32_t property, + const char* value) + { + _OrthancPluginGlobalProperty params; + params.result = NULL; + params.property = property; + params.value = value; + + return context->InvokeService(context, _OrthancPluginService_SetGlobalProperty, ¶ms); + } + + + + typedef struct + { + int32_t *resultInt32; + uint32_t *resultUint32; + int64_t *resultInt64; + uint64_t *resultUint64; + } _OrthancPluginReturnSingleValue; + + /** + * @brief Get the number of command-line arguments. + * + * Retrieve the number of command-line arguments that were used to launch Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return The number of arguments. + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetCommandLineArgumentsCount( + OrthancPluginContext* context) + { + uint32_t count = 0; + + _OrthancPluginReturnSingleValue params; + memset(¶ms, 0, sizeof(params)); + params.resultUint32 = &count; + + if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgumentsCount, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return count; + } + } + + + + /** + * @brief Get the value of a command-line argument. + * + * Get the value of one of the command-line arguments that were used + * to launch Orthanc. The number of available arguments can be + * retrieved by OrthancPluginGetCommandLineArgumentsCount(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param argument The index of the argument. + * @return The value of the argument, or NULL in the case of an error. This + * string must be freed by OrthancPluginFreeString(). + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetCommandLineArgument( + OrthancPluginContext* context, + uint32_t argument) + { + char* result; + + _OrthancPluginGlobalProperty params; + params.result = &result; + params.property = (int32_t) argument; + params.value = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgument, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the expected version of the database schema. + * + * Retrieve the expected version of the database schema. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return The version. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetExpectedDatabaseVersion( + OrthancPluginContext* context) + { + uint32_t count = 0; + + _OrthancPluginReturnSingleValue params; + memset(¶ms, 0, sizeof(params)); + params.resultUint32 = &count; + + if (context->InvokeService(context, _OrthancPluginService_GetExpectedDatabaseVersion, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return count; + } + } + + + + /** + * @brief Return the content of the configuration file(s). + * + * This function returns the content of the configuration that is + * used by Orthanc, formatted as a JSON string. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL in the case of an error, or a newly allocated string + * containing the configuration. This string must be freed by + * OrthancPluginFreeString(). + **/ + ORTHANC_PLUGIN_INLINE char *OrthancPluginGetConfiguration(OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetConfiguration, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + const char* subType; + const char* contentType; + } _OrthancPluginStartMultipartAnswer; + + /** + * @brief Start an HTTP multipart answer. + * + * Initiates a HTTP multipart answer, as the result of a REST request. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param subType The sub-type of the multipart answer ("mixed" or "related"). + * @param contentType The MIME type of the items in the multipart answer. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginSendMultipartItem(), OrthancPluginSendMultipartItem2() + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStartMultipartAnswer( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* subType, + const char* contentType) + { + _OrthancPluginStartMultipartAnswer params; + params.output = output; + params.subType = subType; + params.contentType = contentType; + return context->InvokeService(context, _OrthancPluginService_StartMultipartAnswer, ¶ms); + } + + + /** + * @brief Send an item as a part of some HTTP multipart answer. + * + * This function sends an item as a part of some HTTP multipart + * answer that was initiated by OrthancPluginStartMultipartAnswer(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param answer Pointer to the memory buffer containing the item. + * @param answerSize Number of bytes of the item. + * @return 0 if success, or the error code if failure (this notably happens + * if the connection is closed by the client). + * @see OrthancPluginSendMultipartItem2() + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSendMultipartItem( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const void* answer, + uint32_t answerSize) + { + _OrthancPluginAnswerBuffer params; + params.output = output; + params.answer = answer; + params.answerSize = answerSize; + params.mimeType = NULL; + return context->InvokeService(context, _OrthancPluginService_SendMultipartItem, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const void* source; + uint32_t size; + OrthancPluginCompressionType compression; + uint8_t uncompress; + } _OrthancPluginBufferCompression; + + + /** + * @brief Compress or decompress a buffer. + * + * This function compresses or decompresses a buffer, using the + * version of the zlib library that is used by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param source The source buffer. + * @param size The size in bytes of the source buffer. + * @param compression The compression algorithm. + * @param uncompress If set to "0", the buffer must be compressed. + * If set to "1", the buffer must be uncompressed. + * @return 0 if success, or the error code if failure. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginBufferCompression( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const void* source, + uint32_t size, + OrthancPluginCompressionType compression, + uint8_t uncompress) + { + _OrthancPluginBufferCompression params; + params.target = target; + params.source = source; + params.size = size; + params.compression = compression; + params.uncompress = uncompress; + + return context->InvokeService(context, _OrthancPluginService_BufferCompression, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* path; + } _OrthancPluginReadFile; + + /** + * @brief Read a file. + * + * Read the content of a file on the filesystem, and returns it into + * a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param path The path of the file to be read. + * @return 0 if success, or the error code if failure. + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginReadFile( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* path) + { + _OrthancPluginReadFile params; + params.target = target; + params.path = path; + return context->InvokeService(context, _OrthancPluginService_ReadFile, ¶ms); + } + + + + typedef struct + { + const char* path; + const void* data; + uint32_t size; + } _OrthancPluginWriteFile; + + /** + * @brief Write a file. + * + * Write the content of a memory buffer to the filesystem. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param path The path of the file to be written. + * @param data The content of the memory buffer. + * @param size The size of the memory buffer. + * @return 0 if success, or the error code if failure. + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWriteFile( + OrthancPluginContext* context, + const char* path, + const void* data, + uint32_t size) + { + _OrthancPluginWriteFile params; + params.path = path; + params.data = data; + params.size = size; + return context->InvokeService(context, _OrthancPluginService_WriteFile, ¶ms); + } + + + + typedef struct + { + const char** target; + OrthancPluginErrorCode error; + } _OrthancPluginGetErrorDescription; + + /** + * @brief Get the description of a given error code. + * + * This function returns the description of a given error code. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param error The error code of interest. + * @return The error description. This is a statically-allocated + * string, do not free it. + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetErrorDescription( + OrthancPluginContext* context, + OrthancPluginErrorCode error) + { + const char* result = NULL; + + _OrthancPluginGetErrorDescription params; + params.target = &result; + params.error = error; + + if (context->InvokeService(context, _OrthancPluginService_GetErrorDescription, ¶ms) != OrthancPluginErrorCode_Success || + result == NULL) + { + return "Unknown error code"; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + uint16_t status; + const void* body; + uint32_t bodySize; + } _OrthancPluginSendHttpStatus; + + /** + * @brief Send a HTTP status, with a custom body. + * + * This function answers to a HTTP request by sending a HTTP status + * code (such as "400 - Bad Request"), together with a body + * describing the error. The body will only be returned if the + * configuration option "HttpDescribeErrors" of Orthanc is set to "true". + * + * Note that: + * - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). + * - Redirections (status 301) must use ::OrthancPluginRedirect(). + * - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). + * - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param status The HTTP status code to be sent. + * @param body The body of the answer. + * @param bodySize The size of the body. + * @see OrthancPluginSendHttpStatusCode() + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSendHttpStatus( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + uint16_t status, + const void* body, + uint32_t bodySize) + { + _OrthancPluginSendHttpStatus params; + params.output = output; + params.status = status; + params.body = body; + params.bodySize = bodySize; + context->InvokeService(context, _OrthancPluginService_SendHttpStatus, ¶ms); + } + + + + typedef struct + { + const OrthancPluginImage* image; + uint32_t* resultUint32; + OrthancPluginPixelFormat* resultPixelFormat; + void** resultBuffer; + } _OrthancPluginGetImageInfo; + + + /** + * @brief Return the pixel format of an image. + * + * This function returns the type of memory layout for the pixels of the given image. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image of interest. + * @return The pixel format. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginPixelFormat OrthancPluginGetImagePixelFormat( + OrthancPluginContext* context, + const OrthancPluginImage* image) + { + OrthancPluginPixelFormat target; + + _OrthancPluginGetImageInfo params; + memset(¶ms, 0, sizeof(params)); + params.image = image; + params.resultPixelFormat = ⌖ + + if (context->InvokeService(context, _OrthancPluginService_GetImagePixelFormat, ¶ms) != OrthancPluginErrorCode_Success) + { + return OrthancPluginPixelFormat_Unknown; + } + else + { + return (OrthancPluginPixelFormat) target; + } + } + + + + /** + * @brief Return the width of an image. + * + * This function returns the width of the given image. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image of interest. + * @return The width. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImageWidth( + OrthancPluginContext* context, + const OrthancPluginImage* image) + { + uint32_t width; + + _OrthancPluginGetImageInfo params; + memset(¶ms, 0, sizeof(params)); + params.image = image; + params.resultUint32 = &width; + + if (context->InvokeService(context, _OrthancPluginService_GetImageWidth, ¶ms) != OrthancPluginErrorCode_Success) + { + return 0; + } + else + { + return width; + } + } + + + + /** + * @brief Return the height of an image. + * + * This function returns the height of the given image. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image of interest. + * @return The height. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImageHeight( + OrthancPluginContext* context, + const OrthancPluginImage* image) + { + uint32_t height; + + _OrthancPluginGetImageInfo params; + memset(¶ms, 0, sizeof(params)); + params.image = image; + params.resultUint32 = &height; + + if (context->InvokeService(context, _OrthancPluginService_GetImageHeight, ¶ms) != OrthancPluginErrorCode_Success) + { + return 0; + } + else + { + return height; + } + } + + + + /** + * @brief Return the pitch of an image. + * + * This function returns the pitch of the given image. The pitch is + * defined as the number of bytes between 2 successive lines of the + * image in the memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image of interest. + * @return The pitch. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImagePitch( + OrthancPluginContext* context, + const OrthancPluginImage* image) + { + uint32_t pitch; + + _OrthancPluginGetImageInfo params; + memset(¶ms, 0, sizeof(params)); + params.image = image; + params.resultUint32 = &pitch; + + if (context->InvokeService(context, _OrthancPluginService_GetImagePitch, ¶ms) != OrthancPluginErrorCode_Success) + { + return 0; + } + else + { + return pitch; + } + } + + + + /** + * @brief Return a pointer to the content of an image. + * + * This function returns a pointer to the memory buffer that + * contains the pixels of the image. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image of interest. + * @return The pointer. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE void* OrthancPluginGetImageBuffer( + OrthancPluginContext* context, + const OrthancPluginImage* image) + { + void* target = NULL; + + _OrthancPluginGetImageInfo params; + memset(¶ms, 0, sizeof(params)); + params.resultBuffer = ⌖ + params.image = image; + + if (context->InvokeService(context, _OrthancPluginService_GetImageBuffer, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + typedef struct + { + OrthancPluginImage** target; + const void* data; + uint32_t size; + OrthancPluginImageFormat format; + } _OrthancPluginUncompressImage; + + + /** + * @brief Decode a compressed image. + * + * This function decodes a compressed image from a memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param data Pointer to a memory buffer containing the compressed image. + * @param size Size of the memory buffer containing the compressed image. + * @param format The file format of the compressed image. + * @return The uncompressed image. It must be freed with OrthancPluginFreeImage(). + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage *OrthancPluginUncompressImage( + OrthancPluginContext* context, + const void* data, + uint32_t size, + OrthancPluginImageFormat format) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginUncompressImage params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.data = data; + params.size = size; + params.format = format; + + if (context->InvokeService(context, _OrthancPluginService_UncompressImage, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + + + typedef struct + { + OrthancPluginImage* image; + } _OrthancPluginFreeImage; + + /** + * @brief Free an image. + * + * This function frees an image that was decoded with OrthancPluginUncompressImage(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeImage( + OrthancPluginContext* context, + OrthancPluginImage* image) + { + _OrthancPluginFreeImage params; + params.image = image; + + context->InvokeService(context, _OrthancPluginService_FreeImage, ¶ms); + } + + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + OrthancPluginImageFormat imageFormat; + OrthancPluginPixelFormat pixelFormat; + uint32_t width; + uint32_t height; + uint32_t pitch; + const void* buffer; + uint8_t quality; + } _OrthancPluginCompressImage; + + + /** + * @brief Encode a PNG image. + * + * This function compresses the given memory buffer containing an + * image using the PNG specification, and stores the result of the + * compression into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param format The memory layout of the uncompressed image. + * @param width The width of the image. + * @param height The height of the image. + * @param pitch The pitch of the image (i.e. the number of bytes + * between 2 successive lines of the image in the memory buffer). + * @param buffer The memory buffer containing the uncompressed image. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginCompressAndAnswerPngImage() + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCompressPngImage( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height, + uint32_t pitch, + const void* buffer) + { + _OrthancPluginCompressImage params; + memset(¶ms, 0, sizeof(params)); + params.target = target; + params.imageFormat = OrthancPluginImageFormat_Png; + params.pixelFormat = format; + params.width = width; + params.height = height; + params.pitch = pitch; + params.buffer = buffer; + params.quality = 0; /* Unused for PNG */ + + return context->InvokeService(context, _OrthancPluginService_CompressImage, ¶ms); + } + + + /** + * @brief Encode a JPEG image. + * + * This function compresses the given memory buffer containing an + * image using the JPEG specification, and stores the result of the + * compression into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param format The memory layout of the uncompressed image. + * @param width The width of the image. + * @param height The height of the image. + * @param pitch The pitch of the image (i.e. the number of bytes + * between 2 successive lines of the image in the memory buffer). + * @param buffer The memory buffer containing the uncompressed image. + * @param quality The quality of the JPEG encoding, between 1 (worst + * quality, best compression) and 100 (best quality, worst + * compression). + * @return 0 if success, or the error code if failure. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCompressJpegImage( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height, + uint32_t pitch, + const void* buffer, + uint8_t quality) + { + _OrthancPluginCompressImage params; + memset(¶ms, 0, sizeof(params)); + params.target = target; + params.imageFormat = OrthancPluginImageFormat_Jpeg; + params.pixelFormat = format; + params.width = width; + params.height = height; + params.pitch = pitch; + params.buffer = buffer; + params.quality = quality; + + return context->InvokeService(context, _OrthancPluginService_CompressImage, ¶ms); + } + + + + /** + * @brief Answer to a REST request with a JPEG image. + * + * This function answers to a REST request with a JPEG image. The + * parameters of this function describe a memory buffer that + * contains an uncompressed image. The image will be automatically compressed + * as a JPEG image by the core system of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param format The memory layout of the uncompressed image. + * @param width The width of the image. + * @param height The height of the image. + * @param pitch The pitch of the image (i.e. the number of bytes + * between 2 successive lines of the image in the memory buffer). + * @param buffer The memory buffer containing the uncompressed image. + * @param quality The quality of the JPEG encoding, between 1 (worst + * quality, best compression) and 100 (best quality, worst + * compression). + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerJpegImage( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height, + uint32_t pitch, + const void* buffer, + uint8_t quality) + { + _OrthancPluginCompressAndAnswerImage params; + params.output = output; + params.imageFormat = OrthancPluginImageFormat_Jpeg; + params.pixelFormat = format; + params.width = width; + params.height = height; + params.pitch = pitch; + params.buffer = buffer; + params.quality = quality; + context->InvokeService(context, _OrthancPluginService_CompressAndAnswerImage, ¶ms); + } + + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + OrthancPluginHttpMethod method; + const char* url; + const char* username; + const char* password; + const void* body; + uint32_t bodySize; + } _OrthancPluginCallHttpClient; + + + /** + * @brief Issue a HTTP GET call. + * + * Make a HTTP GET call to the given URL. The result to the query is + * stored into a newly allocated memory buffer. Favor + * OrthancPluginRestApiGet() if calling the built-in REST API of the + * Orthanc instance that hosts this plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param url The URL of interest. + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpGet( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* url, + const char* username, + const char* password) + { + _OrthancPluginCallHttpClient params; + memset(¶ms, 0, sizeof(params)); + + params.target = target; + params.method = OrthancPluginHttpMethod_Get; + params.url = url; + params.username = username; + params.password = password; + + return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); + } + + + /** + * @brief Issue a HTTP POST call. + * + * Make a HTTP POST call to the given URL. The result to the query + * is stored into a newly allocated memory buffer. Favor + * OrthancPluginRestApiPost() if calling the built-in REST API of + * the Orthanc instance that hosts this plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param url The URL of interest. + * @param body The content of the body of the request. + * @param bodySize The size of the body of the request. + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpPost( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* url, + const void* body, + uint32_t bodySize, + const char* username, + const char* password) + { + _OrthancPluginCallHttpClient params; + memset(¶ms, 0, sizeof(params)); + + params.target = target; + params.method = OrthancPluginHttpMethod_Post; + params.url = url; + params.body = body; + params.bodySize = bodySize; + params.username = username; + params.password = password; + + return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); + } + + + /** + * @brief Issue a HTTP PUT call. + * + * Make a HTTP PUT call to the given URL. The result to the query is + * stored into a newly allocated memory buffer. Favor + * OrthancPluginRestApiPut() if calling the built-in REST API of the + * Orthanc instance that hosts this plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param url The URL of interest. + * @param body The content of the body of the request. + * @param bodySize The size of the body of the request. + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpPut( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* url, + const void* body, + uint32_t bodySize, + const char* username, + const char* password) + { + _OrthancPluginCallHttpClient params; + memset(¶ms, 0, sizeof(params)); + + params.target = target; + params.method = OrthancPluginHttpMethod_Put; + params.url = url; + params.body = body; + params.bodySize = bodySize; + params.username = username; + params.password = password; + + return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); + } + + + /** + * @brief Issue a HTTP DELETE call. + * + * Make a HTTP DELETE call to the given URL. Favor + * OrthancPluginRestApiDelete() if calling the built-in REST API of + * the Orthanc instance that hosts this plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param url The URL of interest. + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpDelete( + OrthancPluginContext* context, + const char* url, + const char* username, + const char* password) + { + _OrthancPluginCallHttpClient params; + memset(¶ms, 0, sizeof(params)); + + params.method = OrthancPluginHttpMethod_Delete; + params.url = url; + params.username = username; + params.password = password; + + return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); + } + + + + typedef struct + { + OrthancPluginImage** target; + const OrthancPluginImage* source; + OrthancPluginPixelFormat targetFormat; + } _OrthancPluginConvertPixelFormat; + + + /** + * @brief Change the pixel format of an image. + * + * This function creates a new image, changing the memory layout of the pixels. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param source The source image. + * @param targetFormat The target pixel format. + * @return The resulting image. It must be freed with OrthancPluginFreeImage(). + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage *OrthancPluginConvertPixelFormat( + OrthancPluginContext* context, + const OrthancPluginImage* source, + OrthancPluginPixelFormat targetFormat) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginConvertPixelFormat params; + params.target = ⌖ + params.source = source; + params.targetFormat = targetFormat; + + if (context->InvokeService(context, _OrthancPluginService_ConvertPixelFormat, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + + /** + * @brief Return the number of available fonts. + * + * This function returns the number of fonts that are built in the + * Orthanc core. These fonts can be used to draw texts on images + * through OrthancPluginDrawText(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return The number of fonts. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFontsCount( + OrthancPluginContext* context) + { + uint32_t count = 0; + + _OrthancPluginReturnSingleValue params; + memset(¶ms, 0, sizeof(params)); + params.resultUint32 = &count; + + if (context->InvokeService(context, _OrthancPluginService_GetFontsCount, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return count; + } + } + + + + + typedef struct + { + uint32_t fontIndex; /* in */ + const char** name; /* out */ + uint32_t* size; /* out */ + } _OrthancPluginGetFontInfo; + + /** + * @brief Return the name of a font. + * + * This function returns the name of a font that is built in the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount(). + * @return The font name. This is a statically-allocated string, do not free it. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetFontName( + OrthancPluginContext* context, + uint32_t fontIndex) + { + const char* result = NULL; + + _OrthancPluginGetFontInfo params; + memset(¶ms, 0, sizeof(params)); + params.name = &result; + params.fontIndex = fontIndex; + + if (context->InvokeService(context, _OrthancPluginService_GetFontInfo, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Return the size of a font. + * + * This function returns the size of a font that is built in the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount(). + * @return The font size. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFontSize( + OrthancPluginContext* context, + uint32_t fontIndex) + { + uint32_t result; + + _OrthancPluginGetFontInfo params; + memset(¶ms, 0, sizeof(params)); + params.size = &result; + params.fontIndex = fontIndex; + + if (context->InvokeService(context, _OrthancPluginService_GetFontInfo, ¶ms) != OrthancPluginErrorCode_Success) + { + return 0; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginImage* image; + uint32_t fontIndex; + const char* utf8Text; + int32_t x; + int32_t y; + uint8_t r; + uint8_t g; + uint8_t b; + } _OrthancPluginDrawText; + + + /** + * @brief Draw text on an image. + * + * This function draws some text on some image. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image upon which to draw the text. + * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount(). + * @param utf8Text The text to be drawn, encoded as an UTF-8 zero-terminated string. + * @param x The X position of the text over the image. + * @param y The Y position of the text over the image. + * @param r The value of the red color channel of the text. + * @param g The value of the green color channel of the text. + * @param b The value of the blue color channel of the text. + * @return 0 if success, other value if error. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginDrawText( + OrthancPluginContext* context, + OrthancPluginImage* image, + uint32_t fontIndex, + const char* utf8Text, + int32_t x, + int32_t y, + uint8_t r, + uint8_t g, + uint8_t b) + { + _OrthancPluginDrawText params; + memset(¶ms, 0, sizeof(params)); + params.image = image; + params.fontIndex = fontIndex; + params.utf8Text = utf8Text; + params.x = x; + params.y = y; + params.r = r; + params.g = g; + params.b = b; + + return context->InvokeService(context, _OrthancPluginService_DrawText, ¶ms); + } + + + + typedef struct + { + OrthancPluginStorageArea* storageArea; + const char* uuid; + const void* content; + uint64_t size; + OrthancPluginContentType type; + } _OrthancPluginStorageAreaCreate; + + + /** + * @brief Create a file inside the storage area. + * + * This function creates a new file inside the storage area that is + * currently used by Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param storageArea The storage area. + * @param uuid The identifier of the file to be created. + * @param content The content to store in the newly created file. + * @param size The size of the content. + * @param type The type of the file content. + * @return 0 if success, other value if error. + * @ingroup Callbacks + * @deprecated This function should not be used anymore. Use "OrthancPluginRestApiPut()" on + * "/{patients|studies|series|instances}/{id}/attachments/{name}" instead. + * @warning This function will result in a "not implemented" error on versions of the + * Orthanc core above 1.12.6. + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaCreate( + OrthancPluginContext* context, + OrthancPluginStorageArea* storageArea, + const char* uuid, + const void* content, + uint64_t size, + OrthancPluginContentType type) + { + _OrthancPluginStorageAreaCreate params; + params.storageArea = storageArea; + params.uuid = uuid; + params.content = content; + params.size = size; + params.type = type; + + return context->InvokeService(context, _OrthancPluginService_StorageAreaCreate, ¶ms); + } + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + OrthancPluginStorageArea* storageArea; + const char* uuid; + OrthancPluginContentType type; + } _OrthancPluginStorageAreaRead; + + + /** + * @brief Read a file from the storage area. + * + * This function reads the content of a given file from the storage + * area that is currently used by Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param storageArea The storage area. + * @param uuid The identifier of the file to be read. + * @param type The type of the file content. + * @return 0 if success, other value if error. + * @ingroup Callbacks + * @deprecated This function should not be used anymore. Use "OrthancPluginRestApiGet()" on + * "/{patients|studies|series|instances}/{id}/attachments/{name}" instead. + * @warning This function will result in a "not implemented" error on versions of the + * Orthanc core above 1.12.6. + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaRead( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + OrthancPluginStorageArea* storageArea, + const char* uuid, + OrthancPluginContentType type) + { + _OrthancPluginStorageAreaRead params; + params.target = target; + params.storageArea = storageArea; + params.uuid = uuid; + params.type = type; + + return context->InvokeService(context, _OrthancPluginService_StorageAreaRead, ¶ms); + } + + + typedef struct + { + OrthancPluginStorageArea* storageArea; + const char* uuid; + OrthancPluginContentType type; + } _OrthancPluginStorageAreaRemove; + + /** + * @brief Remove a file from the storage area. + * + * This function removes a given file from the storage area that is + * currently used by Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param storageArea The storage area. + * @param uuid The identifier of the file to be removed. + * @param type The type of the file content. + * @return 0 if success, other value if error. + * @ingroup Callbacks + * @deprecated This function should not be used anymore. Use "OrthancPluginRestApiDelete()" on + * "/{patients|studies|series|instances}/{id}/attachments/{name}" instead. + * @warning This function will result in a "not implemented" error on versions of the + * Orthanc core above 1.12.6. + **/ + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaRemove( + OrthancPluginContext* context, + OrthancPluginStorageArea* storageArea, + const char* uuid, + OrthancPluginContentType type) + { + _OrthancPluginStorageAreaRemove params; + params.storageArea = storageArea; + params.uuid = uuid; + params.type = type; + + return context->InvokeService(context, _OrthancPluginService_StorageAreaRemove, ¶ms); + } + + + + typedef struct + { + OrthancPluginErrorCode* target; + int32_t code; + uint16_t httpStatus; + const char* message; + } _OrthancPluginRegisterErrorCode; + + /** + * @brief Declare a custom error code for this plugin. + * + * This function declares a custom error code that can be generated + * by this plugin. This declaration is used to enrich the body of + * the HTTP answer in the case of an error, and to set the proper + * HTTP status code. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param code The error code that is internal to this plugin. + * @param httpStatus The HTTP status corresponding to this error. + * @param message The description of the error. + * @return The error code that has been assigned inside the Orthanc core. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterErrorCode( + OrthancPluginContext* context, + int32_t code, + uint16_t httpStatus, + const char* message) + { + OrthancPluginErrorCode target; + + _OrthancPluginRegisterErrorCode params; + params.target = ⌖ + params.code = code; + params.httpStatus = httpStatus; + params.message = message; + + if (context->InvokeService(context, _OrthancPluginService_RegisterErrorCode, ¶ms) == OrthancPluginErrorCode_Success) + { + return target; + } + else + { + /* There was an error while assigned the error. Use a generic code. */ + return OrthancPluginErrorCode_Plugin; + } + } + + + + typedef struct + { + uint16_t group; + uint16_t element; + OrthancPluginValueRepresentation vr; + const char* name; + uint32_t minMultiplicity; + uint32_t maxMultiplicity; + } _OrthancPluginRegisterDictionaryTag; + + /** + * @brief Register a new tag into the DICOM dictionary. + * + * This function declares a new public tag in the dictionary of + * DICOM tags that are known to Orthanc. This function should be + * used in the OrthancPluginInitialize() callback. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param group The group of the tag. + * @param element The element of the tag. + * @param vr The value representation of the tag. + * @param name The nickname of the tag. + * @param minMultiplicity The minimum multiplicity of the tag (must be above 0). + * @param maxMultiplicity The maximum multiplicity of the tag. A value of 0 means + * an arbitrary multiplicity ("n"). + * @return 0 if success, other value if error. + * @see OrthancPluginRegisterPrivateDictionaryTag() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDictionaryTag( + OrthancPluginContext* context, + uint16_t group, + uint16_t element, + OrthancPluginValueRepresentation vr, + const char* name, + uint32_t minMultiplicity, + uint32_t maxMultiplicity) + { + _OrthancPluginRegisterDictionaryTag params; + params.group = group; + params.element = element; + params.vr = vr; + params.name = name; + params.minMultiplicity = minMultiplicity; + params.maxMultiplicity = maxMultiplicity; + + return context->InvokeService(context, _OrthancPluginService_RegisterDictionaryTag, ¶ms); + } + + + + typedef struct + { + uint16_t group; + uint16_t element; + OrthancPluginValueRepresentation vr; + const char* name; + uint32_t minMultiplicity; + uint32_t maxMultiplicity; + const char* privateCreator; + } _OrthancPluginRegisterPrivateDictionaryTag; + + /** + * @brief Register a new private tag into the DICOM dictionary. + * + * This function declares a new private tag in the dictionary of + * DICOM tags that are known to Orthanc. This function should be + * used in the OrthancPluginInitialize() callback. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param group The group of the tag. + * @param element The element of the tag. + * @param vr The value representation of the tag. + * @param name The nickname of the tag. + * @param minMultiplicity The minimum multiplicity of the tag (must be above 0). + * @param maxMultiplicity The maximum multiplicity of the tag. A value of 0 means + * an arbitrary multiplicity ("n"). + * @param privateCreator The private creator of this private tag. + * @return 0 if success, other value if error. + * @see OrthancPluginRegisterDictionaryTag() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.2.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterPrivateDictionaryTag( + OrthancPluginContext* context, + uint16_t group, + uint16_t element, + OrthancPluginValueRepresentation vr, + const char* name, + uint32_t minMultiplicity, + uint32_t maxMultiplicity, + const char* privateCreator) + { + _OrthancPluginRegisterPrivateDictionaryTag params; + params.group = group; + params.element = element; + params.vr = vr; + params.name = name; + params.minMultiplicity = minMultiplicity; + params.maxMultiplicity = maxMultiplicity; + params.privateCreator = privateCreator; + + return context->InvokeService(context, _OrthancPluginService_RegisterPrivateDictionaryTag, ¶ms); + } + + + + typedef struct + { + OrthancPluginStorageArea* storageArea; + OrthancPluginResourceType level; + } _OrthancPluginReconstructMainDicomTags; + + /** + * @brief Reconstruct the main DICOM tags. + * + * This function requests the Orthanc core to reconstruct the main + * DICOM tags of all the resources of the given type. This function + * can only be used as a part of the upgrade of a custom database + * back-end. A database transaction will be automatically setup. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param storageArea The storage area. + * @param level The type of the resources of interest. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginReconstructMainDicomTags( + OrthancPluginContext* context, + OrthancPluginStorageArea* storageArea, + OrthancPluginResourceType level) + { + _OrthancPluginReconstructMainDicomTags params; + params.level = level; + params.storageArea = storageArea; + + return context->InvokeService(context, _OrthancPluginService_ReconstructMainDicomTags, ¶ms); + } + + + typedef struct + { + char** result; + const char* instanceId; + const void* buffer; + uint32_t size; + OrthancPluginDicomToJsonFormat format; + OrthancPluginDicomToJsonFlags flags; + uint32_t maxStringLength; + } _OrthancPluginDicomToJson; + + + /** + * @brief Format a DICOM memory buffer as a JSON string. + * + * This function takes as input a memory buffer containing a DICOM + * file, and outputs a JSON string representing the tags of this + * DICOM file. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The memory buffer containing the DICOM file. + * @param size The size of the memory buffer. + * @param format The output format. + * @param flags Flags governing the output. + * @param maxStringLength The maximum length of a field. Too long fields will + * be output as "null". The 0 value means no maximum length. + * @return The NULL value if the case of an error, or the JSON + * string. This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + * @see OrthancPluginDicomInstanceToJson() + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginDicomBufferToJson( + OrthancPluginContext* context, + const void* buffer, + uint32_t size, + OrthancPluginDicomToJsonFormat format, + OrthancPluginDicomToJsonFlags flags, + uint32_t maxStringLength) + { + char* result; + + _OrthancPluginDicomToJson params; + memset(¶ms, 0, sizeof(params)); + params.result = &result; + params.buffer = buffer; + params.size = size; + params.format = format; + params.flags = flags; + params.maxStringLength = maxStringLength; + + if (context->InvokeService(context, _OrthancPluginService_DicomBufferToJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Format a DICOM instance as a JSON string. + * + * This function formats a DICOM instance that is stored in Orthanc, + * and outputs a JSON string representing the tags of this DICOM + * instance. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instanceId The Orthanc identifier of the instance. + * @param format The output format. + * @param flags Flags governing the output. + * @param maxStringLength The maximum length of a field. Too long fields will + * be output as "null". The 0 value means no maximum length. + * @return The NULL value if the case of an error, or the JSON + * string. This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + * @see OrthancPluginDicomInstanceToJson() + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginDicomInstanceToJson( + OrthancPluginContext* context, + const char* instanceId, + OrthancPluginDicomToJsonFormat format, + OrthancPluginDicomToJsonFlags flags, + uint32_t maxStringLength) + { + char* result; + + _OrthancPluginDicomToJson params; + memset(¶ms, 0, sizeof(params)); + params.result = &result; + params.instanceId = instanceId; + params.format = format; + params.flags = flags; + params.maxStringLength = maxStringLength; + + if (context->InvokeService(context, _OrthancPluginService_DicomInstanceToJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* uri; + uint32_t headersCount; + const char* const* headersKeys; + const char* const* headersValues; + int32_t afterPlugins; + } _OrthancPluginRestApiGet2; + + /** + * @brief Make a GET call to the Orthanc REST API, with custom HTTP headers. + * + * Make a GET call to the Orthanc REST API with extended + * parameters. The result to the query is stored into a newly + * allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @param headersCount The number of HTTP headers. + * @param headersKeys Array containing the keys of the HTTP headers (can be NULL if no header). + * @param headersValues Array containing the values of the HTTP headers (can be NULL if no header). + * @param afterPlugins If 0, the built-in API of Orthanc is used. + * If 1, the API is tainted by the plugins. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginRestApiGet(), OrthancPluginRestApiGetAfterPlugins() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGet2( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues, + int32_t afterPlugins) + { + _OrthancPluginRestApiGet2 params; + params.target = target; + params.uri = uri; + params.headersCount = headersCount; + params.headersKeys = headersKeys; + params.headersValues = headersValues; + params.afterPlugins = afterPlugins; + + return context->InvokeService(context, _OrthancPluginService_RestApiGet2, ¶ms); + } + + + + typedef struct + { + OrthancPluginWorklistCallback callback; + } _OrthancPluginWorklistCallback; + + /** + * @brief Register a callback to handle modality worklists requests. + * + * This function registers a callback to handle C-Find SCP requests + * on modality worklists. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterWorklistCallback( + OrthancPluginContext* context, + OrthancPluginWorklistCallback callback) + { + _OrthancPluginWorklistCallback params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterWorklistCallback, ¶ms); + } + + + + typedef struct + { + OrthancPluginWorklistAnswers* answers; + const OrthancPluginWorklistQuery* query; + const void* dicom; + uint32_t size; + } _OrthancPluginWorklistAnswersOperation; + + /** + * @brief Add one answer to some modality worklist request. + * + * This function adds one worklist (encoded as a DICOM file) to the + * set of answers corresponding to some C-Find SCP request against + * modality worklists. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answers The set of answers. + * @param query The worklist query, as received by the callback. + * @param dicom The worklist to answer, encoded as a DICOM file. + * @param size The size of the DICOM file. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + * @see OrthancPluginCreateDicom() + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistAddAnswer( + OrthancPluginContext* context, + OrthancPluginWorklistAnswers* answers, + const OrthancPluginWorklistQuery* query, + const void* dicom, + uint32_t size) + { + _OrthancPluginWorklistAnswersOperation params; + params.answers = answers; + params.query = query; + params.dicom = dicom; + params.size = size; + + return context->InvokeService(context, _OrthancPluginService_WorklistAddAnswer, ¶ms); + } + + + /** + * @brief Mark the set of worklist answers as incomplete. + * + * This function marks as incomplete the set of answers + * corresponding to some C-Find SCP request against modality + * worklists. This must be used if canceling the handling of a + * request when too many answers are to be returned. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answers The set of answers. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistMarkIncomplete( + OrthancPluginContext* context, + OrthancPluginWorklistAnswers* answers) + { + _OrthancPluginWorklistAnswersOperation params; + params.answers = answers; + params.query = NULL; + params.dicom = NULL; + params.size = 0; + + return context->InvokeService(context, _OrthancPluginService_WorklistMarkIncomplete, ¶ms); + } + + + typedef struct + { + const OrthancPluginWorklistQuery* query; + const void* dicom; + uint32_t size; + int32_t* isMatch; + OrthancPluginMemoryBuffer* target; + } _OrthancPluginWorklistQueryOperation; + + /** + * @brief Test whether a worklist matches the query. + * + * This function checks whether one worklist (encoded as a DICOM + * file) matches the C-Find SCP query against modality + * worklists. This function must be called before adding the + * worklist as an answer through OrthancPluginWorklistAddAnswer(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param query The worklist query, as received by the callback. + * @param dicom The worklist to answer, encoded as a DICOM file. + * @param size The size of the DICOM file. + * @return 1 if the worklist matches the query, 0 otherwise. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE int32_t OrthancPluginWorklistIsMatch( + OrthancPluginContext* context, + const OrthancPluginWorklistQuery* query, + const void* dicom, + uint32_t size) + { + int32_t isMatch = 0; + + _OrthancPluginWorklistQueryOperation params; + params.query = query; + params.dicom = dicom; + params.size = size; + params.isMatch = &isMatch; + params.target = NULL; + + if (context->InvokeService(context, _OrthancPluginService_WorklistIsMatch, ¶ms) == OrthancPluginErrorCode_Success) + { + return isMatch; + } + else + { + /* Error: Assume non-match */ + return 0; + } + } + + + /** + * @brief Retrieve the worklist query as a DICOM file. + * + * This function retrieves the DICOM file that underlies a C-Find + * SCP query against modality worklists. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target Memory buffer where to store the DICOM file. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param query The worklist query, as received by the callback. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistGetDicomQuery( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const OrthancPluginWorklistQuery* query) + { + _OrthancPluginWorklistQueryOperation params; + params.query = query; + params.dicom = NULL; + params.size = 0; + params.isMatch = NULL; + params.target = target; + + return context->InvokeService(context, _OrthancPluginService_WorklistGetDicomQuery, ¶ms); + } + + + /** + * @brief Get the origin of a DICOM file. + * + * This function returns the origin of a DICOM instance that has been received by Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The origin of the instance. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginInstanceOrigin OrthancPluginGetInstanceOrigin( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + OrthancPluginInstanceOrigin origin; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultOrigin = &origin; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceOrigin, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return OrthancPluginInstanceOrigin_Unknown; + } + else + { + return origin; + } + } + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* json; + const OrthancPluginImage* pixelData; + OrthancPluginCreateDicomFlags flags; + } _OrthancPluginCreateDicom; + + /** + * @brief Create a DICOM instance from a JSON string and an image. + * + * This function takes as input a string containing a JSON file + * describing the content of a DICOM instance. As an output, it + * writes the corresponding DICOM instance to a newly allocated + * memory buffer. Additionally, an image to be encoded within the + * DICOM instance can also be provided. + * + * Private tags will be associated with the private creator whose + * value is specified in the "DefaultPrivateCreator" configuration + * option of Orthanc. The function OrthancPluginCreateDicom2() can + * be used if another private creator must be used to create this + * instance. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param json The input JSON file. + * @param pixelData The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme. + * @param flags Flags governing the output. + * @return 0 if success, other value if error. + * @ingroup Toolbox + * @see OrthancPluginCreateDicom2() + * @see OrthancPluginDicomBufferToJson() + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateDicom( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* json, + const OrthancPluginImage* pixelData, + OrthancPluginCreateDicomFlags flags) + { + _OrthancPluginCreateDicom params; + params.target = target; + params.json = json; + params.pixelData = pixelData; + params.flags = flags; + + return context->InvokeService(context, _OrthancPluginService_CreateDicom, ¶ms); + } + + + typedef struct + { + OrthancPluginDecodeImageCallback callback; + } _OrthancPluginDecodeImageCallback; + + /** + * @brief Register a callback to handle the decoding of DICOM images. + * + * This function registers a custom callback to decode DICOM images, + * extending the built-in decoder of Orthanc that uses + * DCMTK. Starting with Orthanc 1.7.0, the exact behavior is + * affected by the configuration option + * "BuiltinDecoderTranscoderOrder" of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDecodeImageCallback( + OrthancPluginContext* context, + OrthancPluginDecodeImageCallback callback) + { + _OrthancPluginDecodeImageCallback params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterDecodeImageCallback, ¶ms); + } + + + + typedef struct + { + OrthancPluginImage** target; + OrthancPluginPixelFormat format; + uint32_t width; + uint32_t height; + uint32_t pitch; + void* buffer; + const void* constBuffer; + uint32_t bufferSize; + uint32_t frameIndex; + } _OrthancPluginCreateImage; + + + /** + * @brief Create an image. + * + * This function creates an image of given size and format. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param format The format of the pixels. + * @param width The width of the image. + * @param height The height of the image. + * @return The newly allocated image. It must be freed with OrthancPluginFreeImage(). + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginCreateImage( + OrthancPluginContext* context, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginCreateImage params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.format = format; + params.width = width; + params.height = height; + + if (context->InvokeService(context, _OrthancPluginService_CreateImage, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Create an image pointing to a memory buffer. + * + * This function creates an image whose content points to a memory + * buffer managed by the plugin. Note that the buffer is directly + * accessed, no memory is allocated and no data is copied. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param format The format of the pixels. + * @param width The width of the image. + * @param height The height of the image. + * @param pitch The pitch of the image (i.e. the number of bytes + * between 2 successive lines of the image in the memory buffer). + * @param buffer The memory buffer. + * @return The newly allocated image. It must be freed with OrthancPluginFreeImage(). + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginCreateImageAccessor( + OrthancPluginContext* context, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height, + uint32_t pitch, + void* buffer) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginCreateImage params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.format = format; + params.width = width; + params.height = height; + params.pitch = pitch; + params.buffer = buffer; + + if (context->InvokeService(context, _OrthancPluginService_CreateImageAccessor, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + + /** + * @brief Decode one frame from a DICOM instance. + * + * This function decodes one frame of a DICOM image that is stored + * in a memory buffer. This function will give the same result as + * OrthancPluginUncompressImage() for single-frame DICOM images. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer Pointer to a memory buffer containing the DICOM image. + * @param bufferSize Size of the memory buffer containing the DICOM image. + * @param frameIndex The index of the frame of interest in a multi-frame image. + * @return The uncompressed image. It must be freed with OrthancPluginFreeImage(). + * @ingroup Images + * @see OrthancPluginGetInstanceDecodedFrame() + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginDecodeDicomImage( + OrthancPluginContext* context, + const void* buffer, + uint32_t bufferSize, + uint32_t frameIndex) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginCreateImage params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.constBuffer = buffer; + params.bufferSize = bufferSize; + params.frameIndex = frameIndex; + + if (context->InvokeService(context, _OrthancPluginService_DecodeDicomImage, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + + typedef struct + { + char** result; + const void* buffer; + uint32_t size; + } _OrthancPluginComputeHash; + + /** + * @brief Compute an MD5 hash. + * + * This functions computes the MD5 cryptographic hash of the given memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The source memory buffer. + * @param size The size in bytes of the source buffer. + * @return The NULL value in case of error, or a string containing the cryptographic hash. + * This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginComputeMd5( + OrthancPluginContext* context, + const void* buffer, + uint32_t size) + { + char* result; + + _OrthancPluginComputeHash params; + params.result = &result; + params.buffer = buffer; + params.size = size; + + if (context->InvokeService(context, _OrthancPluginService_ComputeMd5, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Compute a SHA-1 hash. + * + * This functions computes the SHA-1 cryptographic hash of the given memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The source memory buffer. + * @param size The size in bytes of the source buffer. + * @return The NULL value in case of error, or a string containing the cryptographic hash. + * This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginComputeSha1( + OrthancPluginContext* context, + const void* buffer, + uint32_t size) + { + char* result; + + _OrthancPluginComputeHash params; + params.result = &result; + params.buffer = buffer; + params.size = size; + + if (context->InvokeService(context, _OrthancPluginService_ComputeSha1, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginDictionaryEntry* target; + const char* name; + } _OrthancPluginLookupDictionary; + + /** + * @brief Get information about the given DICOM tag. + * + * This functions makes a lookup in the dictionary of DICOM tags + * that are known to Orthanc, and returns information about this + * tag. The tag can be specified using its human-readable name + * (e.g. "PatientName") or a set of two hexadecimal numbers + * (e.g. "0010-0020"). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target Where to store the information about the tag. + * @param name The name of the DICOM tag. + * @return 0 if success, other value if error. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginLookupDictionary( + OrthancPluginContext* context, + OrthancPluginDictionaryEntry* target, + const char* name) + { + _OrthancPluginLookupDictionary params; + params.target = target; + params.name = name; + return context->InvokeService(context, _OrthancPluginService_LookupDictionary, ¶ms); + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + const void* answer; + uint32_t answerSize; + uint32_t headersCount; + const char* const* headersKeys; + const char* const* headersValues; + } _OrthancPluginSendMultipartItem2; + + /** + * @brief Send an item as a part of some HTTP multipart answer, with custom headers. + * + * This function sends an item as a part of some HTTP multipart + * answer that was initiated by OrthancPluginStartMultipartAnswer(). In addition to + * OrthancPluginSendMultipartItem(), this function will set HTTP header associated + * with the item. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param answer Pointer to the memory buffer containing the item. + * @param answerSize Number of bytes of the item. + * @param headersCount The number of HTTP headers. + * @param headersKeys Array containing the keys of the HTTP headers. + * @param headersValues Array containing the values of the HTTP headers. + * @return 0 if success, or the error code if failure (this notably happens + * if the connection is closed by the client). + * @see OrthancPluginSendMultipartItem() + * @ingroup REST + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.0.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSendMultipartItem2( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const void* answer, + uint32_t answerSize, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues) + { + _OrthancPluginSendMultipartItem2 params; + params.output = output; + params.answer = answer; + params.answerSize = answerSize; + params.headersCount = headersCount; + params.headersKeys = headersKeys; + params.headersValues = headersValues; + + return context->InvokeService(context, _OrthancPluginService_SendMultipartItem2, ¶ms); + } + + + typedef struct + { + OrthancPluginIncomingHttpRequestFilter callback; + } _OrthancPluginIncomingHttpRequestFilter; + + /** + * @brief Register a callback to filter incoming HTTP requests. + * + * This function registers a custom callback to filter incoming HTTP/REST + * requests received by the HTTP server of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + * @deprecated Please instead use OrthancPluginRegisterIncomingHttpRequestFilter2() + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.1.0") + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingHttpRequestFilter( + OrthancPluginContext* context, + OrthancPluginIncomingHttpRequestFilter callback) + { + _OrthancPluginIncomingHttpRequestFilter params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterIncomingHttpRequestFilter, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* answerBody; + OrthancPluginMemoryBuffer* answerHeaders; + uint16_t* httpStatus; + OrthancPluginHttpMethod method; + const char* url; + uint32_t headersCount; + const char* const* headersKeys; + const char* const* headersValues; + const void* body; + uint32_t bodySize; + const char* username; + const char* password; + uint32_t timeout; + const char* certificateFile; + const char* certificateKeyFile; + const char* certificateKeyPassword; + uint8_t pkcs11; + } _OrthancPluginCallHttpClient2; + + + + /** + * @brief Issue a HTTP call with full flexibility. + * + * Make a HTTP call to the given URL. The result to the query is + * stored into a newly allocated memory buffer. The HTTP request + * will be done accordingly to the global configuration of Orthanc + * (in particular, the options "HttpProxy", "HttpTimeout", + * "HttpsVerifyPeers", "HttpsCACertificates", and "Pkcs11" will be + * taken into account). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answerBody The target memory buffer (out argument). + * It must be freed with OrthancPluginFreeMemoryBuffer(). + * The value of this argument is ignored if the HTTP method is DELETE. + * @param answerHeaders The target memory buffer for the HTTP headers in the answers (out argument). + * The answer headers are formatted as a JSON object (associative array). + * The buffer must be freed with OrthancPluginFreeMemoryBuffer(). + * This argument can be set to NULL if the plugin has no interest in the HTTP headers. + * @param httpStatus The HTTP status after the execution of the request (out argument). + * @param method HTTP method to be used. + * @param url The URL of interest. + * @param headersCount The number of HTTP headers. + * @param headersKeys Array containing the keys of the HTTP headers (can be NULL if no header). + * @param headersValues Array containing the values of the HTTP headers (can be NULL if no header). + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @param body The HTTP body for a POST or PUT request. + * @param bodySize The size of the body. + * @param timeout Timeout in seconds (0 for default timeout). + * @param certificateFile Path to the client certificate for HTTPS, in PEM format + * (can be NULL if no client certificate or if not using HTTPS). + * @param certificateKeyFile Path to the key of the client certificate for HTTPS, in PEM format + * (can be NULL if no client certificate or if not using HTTPS). + * @param certificateKeyPassword Password to unlock the key of the client certificate + * (can be NULL if no client certificate or if not using HTTPS). + * @param pkcs11 Enable PKCS#11 client authentication for hardware security modules and smart cards. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginCallPeerApi() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.1.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpClient( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* answerBody, + OrthancPluginMemoryBuffer* answerHeaders, + uint16_t* httpStatus, + OrthancPluginHttpMethod method, + const char* url, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues, + const void* body, + uint32_t bodySize, + const char* username, + const char* password, + uint32_t timeout, + const char* certificateFile, + const char* certificateKeyFile, + const char* certificateKeyPassword, + uint8_t pkcs11) + { + _OrthancPluginCallHttpClient2 params; + memset(¶ms, 0, sizeof(params)); + + params.answerBody = answerBody; + params.answerHeaders = answerHeaders; + params.httpStatus = httpStatus; + params.method = method; + params.url = url; + params.headersCount = headersCount; + params.headersKeys = headersKeys; + params.headersValues = headersValues; + params.body = body; + params.bodySize = bodySize; + params.username = username; + params.password = password; + params.timeout = timeout; + params.certificateFile = certificateFile; + params.certificateKeyFile = certificateKeyFile; + params.certificateKeyPassword = certificateKeyPassword; + params.pkcs11 = pkcs11; + + return context->InvokeService(context, _OrthancPluginService_CallHttpClient2, ¶ms); + } + + + /** + * @brief Generate an UUID. + * + * Generate a random GUID/UUID (globally unique identifier). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL in the case of an error, or a newly allocated string + * containing the UUID. This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.1.0") + ORTHANC_PLUGIN_INLINE char* OrthancPluginGenerateUuid( + OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GenerateUuid, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + + typedef struct + { + OrthancPluginFindCallback callback; + } _OrthancPluginFindCallback; + + /** + * @brief Register a callback to handle C-Find requests. + * + * This function registers a callback to handle C-Find SCP requests + * that are not related to modality worklists. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.1.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterFindCallback( + OrthancPluginContext* context, + OrthancPluginFindCallback callback) + { + _OrthancPluginFindCallback params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterFindCallback, ¶ms); + } + + + typedef struct + { + OrthancPluginFindAnswers *answers; + const OrthancPluginFindQuery *query; + const void *dicom; + uint32_t size; + uint32_t index; + uint32_t *resultUint32; + uint16_t *resultGroup; + uint16_t *resultElement; + char **resultString; + } _OrthancPluginFindOperation; + + /** + * @brief Add one answer to some C-Find request. + * + * This function adds one answer (encoded as a DICOM file) to the + * set of answers corresponding to some C-Find SCP request that is + * not related to modality worklists. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answers The set of answers. + * @param dicom The answer to be added, encoded as a DICOM file. + * @param size The size of the DICOM file. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + * @see OrthancPluginCreateDicom() + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.1.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginFindAddAnswer( + OrthancPluginContext* context, + OrthancPluginFindAnswers* answers, + const void* dicom, + uint32_t size) + { + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.answers = answers; + params.dicom = dicom; + params.size = size; + + return context->InvokeService(context, _OrthancPluginService_FindAddAnswer, ¶ms); + } + + + /** + * @brief Mark the set of C-Find answers as incomplete. + * + * This function marks as incomplete the set of answers + * corresponding to some C-Find SCP request that is not related to + * modality worklists. This must be used if canceling the handling + * of a request when too many answers are to be returned. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answers The set of answers. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.1.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginFindMarkIncomplete( + OrthancPluginContext* context, + OrthancPluginFindAnswers* answers) + { + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.answers = answers; + + return context->InvokeService(context, _OrthancPluginService_FindMarkIncomplete, ¶ms); + } + + + + /** + * @brief Get the number of tags in a C-Find query. + * + * This function returns the number of tags that are contained in + * the given C-Find query. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param query The C-Find query. + * @return The number of tags. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.1.0") + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFindQuerySize( + OrthancPluginContext* context, + const OrthancPluginFindQuery* query) + { + uint32_t count = 0; + + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.query = query; + params.resultUint32 = &count; + + if (context->InvokeService(context, _OrthancPluginService_GetFindQuerySize, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return count; + } + } + + + /** + * @brief Get one tag in a C-Find query. + * + * This function returns the group and the element of one DICOM tag + * in the given C-Find query. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param group The group of the tag (output). + * @param element The element of the tag (output). + * @param query The C-Find query. + * @param index The index of the tag of interest. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.1.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetFindQueryTag( + OrthancPluginContext* context, + uint16_t* group, + uint16_t* element, + const OrthancPluginFindQuery* query, + uint32_t index) + { + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.query = query; + params.index = index; + params.resultGroup = group; + params.resultElement = element; + + return context->InvokeService(context, _OrthancPluginService_GetFindQueryTag, ¶ms); + } + + + /** + * @brief Get the symbolic name of one tag in a C-Find query. + * + * This function returns the symbolic name of one DICOM tag in the + * given C-Find query. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param query The C-Find query. + * @param index The index of the tag of interest. + * @return The NULL value in case of error, or a string containing the name of the tag. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.1.0") + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetFindQueryTagName( + OrthancPluginContext* context, + const OrthancPluginFindQuery* query, + uint32_t index) + { + char* result; + + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.query = query; + params.index = index; + params.resultString = &result; + + if (context->InvokeService(context, _OrthancPluginService_GetFindQueryTagName, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the value associated with one tag in a C-Find query. + * + * This function returns the value associated with one tag in the + * given C-Find query. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param query The C-Find query. + * @param index The index of the tag of interest. + * @return The NULL value in case of error, or a string containing the value of the tag. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.1.0") + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetFindQueryValue( + OrthancPluginContext* context, + const OrthancPluginFindQuery* query, + uint32_t index) + { + char* result; + + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.query = query; + params.index = index; + params.resultString = &result; + + if (context->InvokeService(context, _OrthancPluginService_GetFindQueryValue, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + + typedef struct + { + OrthancPluginMoveCallback callback; + OrthancPluginGetMoveSize getMoveSize; + OrthancPluginApplyMove applyMove; + OrthancPluginFreeMove freeMove; + } _OrthancPluginMoveCallback; + + /** + * @brief Register a callback to handle C-Move requests. + * + * This function registers a callback to handle C-Move SCP requests. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The main callback. + * @param getMoveSize Callback to read the number of C-Move suboperations. + * @param applyMove Callback to apply one C-Move suboperation. + * @param freeMove Callback to free the C-Move driver. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.1.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterMoveCallback( + OrthancPluginContext* context, + OrthancPluginMoveCallback callback, + OrthancPluginGetMoveSize getMoveSize, + OrthancPluginApplyMove applyMove, + OrthancPluginFreeMove freeMove) + { + _OrthancPluginMoveCallback params; + params.callback = callback; + params.getMoveSize = getMoveSize; + params.applyMove = applyMove; + params.freeMove = freeMove; + + return context->InvokeService(context, _OrthancPluginService_RegisterMoveCallback, ¶ms); + } + + + + typedef struct + { + OrthancPluginFindMatcher** target; + const void* query; + uint32_t size; + } _OrthancPluginCreateFindMatcher; + + + /** + * @brief Create a C-Find matcher. + * + * This function creates a "matcher" object that can be used to + * check whether a DICOM instance matches a C-Find query. The C-Find + * query must be expressed as a DICOM buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param query The C-Find DICOM query. + * @param size The size of the DICOM query. + * @return The newly allocated matcher. It must be freed with OrthancPluginFreeFindMatcher(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.2.0") + ORTHANC_PLUGIN_INLINE OrthancPluginFindMatcher* OrthancPluginCreateFindMatcher( + OrthancPluginContext* context, + const void* query, + uint32_t size) + { + OrthancPluginFindMatcher* target = NULL; + + _OrthancPluginCreateFindMatcher params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.query = query; + params.size = size; + + if (context->InvokeService(context, _OrthancPluginService_CreateFindMatcher, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + typedef struct + { + OrthancPluginFindMatcher* matcher; + } _OrthancPluginFreeFindMatcher; + + /** + * @brief Free a C-Find matcher. + * + * This function frees a matcher that was created using OrthancPluginCreateFindMatcher(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param matcher The matcher of interest. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.2.0") + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeFindMatcher( + OrthancPluginContext* context, + OrthancPluginFindMatcher* matcher) + { + _OrthancPluginFreeFindMatcher params; + params.matcher = matcher; + + context->InvokeService(context, _OrthancPluginService_FreeFindMatcher, ¶ms); + } + + + typedef struct + { + const OrthancPluginFindMatcher* matcher; + const void* dicom; + uint32_t size; + int32_t* isMatch; + } _OrthancPluginFindMatcherIsMatch; + + /** + * @brief Test whether a DICOM instance matches a C-Find query. + * + * This function checks whether one DICOM instance matches C-Find + * matcher that was previously allocated using + * OrthancPluginCreateFindMatcher(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param matcher The matcher of interest. + * @param dicom The DICOM instance to be matched. + * @param size The size of the DICOM instance. + * @return 1 if the DICOM instance matches the query, 0 otherwise. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.2.0") + ORTHANC_PLUGIN_INLINE int32_t OrthancPluginFindMatcherIsMatch( + OrthancPluginContext* context, + const OrthancPluginFindMatcher* matcher, + const void* dicom, + uint32_t size) + { + int32_t isMatch = 0; + + _OrthancPluginFindMatcherIsMatch params; + params.matcher = matcher; + params.dicom = dicom; + params.size = size; + params.isMatch = &isMatch; + + if (context->InvokeService(context, _OrthancPluginService_FindMatcherIsMatch, ¶ms) == OrthancPluginErrorCode_Success) + { + return isMatch; + } + else + { + /* Error: Assume non-match */ + return 0; + } + } + + + typedef struct + { + OrthancPluginIncomingHttpRequestFilter2 callback; + } _OrthancPluginIncomingHttpRequestFilter2; + + /** + * @brief Register a callback to filter incoming HTTP requests. + * + * This function registers a custom callback to filter incoming HTTP/REST + * requests received by the HTTP server of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.3.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingHttpRequestFilter2( + OrthancPluginContext* context, + OrthancPluginIncomingHttpRequestFilter2 callback) + { + _OrthancPluginIncomingHttpRequestFilter2 params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterIncomingHttpRequestFilter2, ¶ms); + } + + + + typedef struct + { + OrthancPluginPeers** peers; + } _OrthancPluginGetPeers; + + /** + * @brief Return the list of available Orthanc peers. + * + * This function returns the parameters of the Orthanc peers that are known to + * the Orthanc server hosting the plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL if error, or a newly allocated opaque data structure containing the peers. + * This structure must be freed with OrthancPluginFreePeers(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.4.2") + ORTHANC_PLUGIN_INLINE OrthancPluginPeers* OrthancPluginGetPeers( + OrthancPluginContext* context) + { + OrthancPluginPeers* peers = NULL; + + _OrthancPluginGetPeers params; + memset(¶ms, 0, sizeof(params)); + params.peers = &peers; + + if (context->InvokeService(context, _OrthancPluginService_GetPeers, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return peers; + } + } + + + typedef struct + { + OrthancPluginPeers* peers; + } _OrthancPluginFreePeers; + + /** + * @brief Free the list of available Orthanc peers. + * + * This function frees the data structure returned by OrthancPluginGetPeers(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param peers The data structure describing the Orthanc peers. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.4.2") + ORTHANC_PLUGIN_INLINE void OrthancPluginFreePeers( + OrthancPluginContext* context, + OrthancPluginPeers* peers) + { + _OrthancPluginFreePeers params; + params.peers = peers; + + context->InvokeService(context, _OrthancPluginService_FreePeers, ¶ms); + } + + + typedef struct + { + uint32_t* target; + const OrthancPluginPeers* peers; + } _OrthancPluginGetPeersCount; + + /** + * @brief Get the number of Orthanc peers. + * + * This function returns the number of Orthanc peers. + * + * This function is thread-safe: Several threads sharing the same + * OrthancPluginPeers object can simultaneously call this function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param peers The data structure describing the Orthanc peers. + * @result The number of peers. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.4.2") + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetPeersCount( + OrthancPluginContext* context, + const OrthancPluginPeers* peers) + { + uint32_t target = 0; + + _OrthancPluginGetPeersCount params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.peers = peers; + + if (context->InvokeService(context, _OrthancPluginService_GetPeersCount, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return target; + } + } + + + typedef struct + { + const char** target; + const OrthancPluginPeers* peers; + uint32_t peerIndex; + const char* userProperty; + } _OrthancPluginGetPeerProperty; + + /** + * @brief Get the symbolic name of an Orthanc peer. + * + * This function returns the symbolic name of the Orthanc peer, + * which corresponds to the key of the "OrthancPeers" configuration + * option of Orthanc. + * + * This function is thread-safe: Several threads sharing the same + * OrthancPluginPeers object can simultaneously call this function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param peers The data structure describing the Orthanc peers. + * @param peerIndex The index of the peer of interest. + * This value must be lower than OrthancPluginGetPeersCount(). + * @result The symbolic name, or NULL in the case of an error. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.4.2") + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetPeerName( + OrthancPluginContext* context, + const OrthancPluginPeers* peers, + uint32_t peerIndex) + { + const char* target = NULL; + + _OrthancPluginGetPeerProperty params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.peers = peers; + params.peerIndex = peerIndex; + params.userProperty = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetPeerName, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Get the base URL of an Orthanc peer. + * + * This function returns the base URL to the REST API of some Orthanc peer. + * + * This function is thread-safe: Several threads sharing the same + * OrthancPluginPeers object can simultaneously call this function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param peers The data structure describing the Orthanc peers. + * @param peerIndex The index of the peer of interest. + * This value must be lower than OrthancPluginGetPeersCount(). + * @result The URL, or NULL in the case of an error. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.4.2") + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetPeerUrl( + OrthancPluginContext* context, + const OrthancPluginPeers* peers, + uint32_t peerIndex) + { + const char* target = NULL; + + _OrthancPluginGetPeerProperty params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.peers = peers; + params.peerIndex = peerIndex; + params.userProperty = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetPeerUrl, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + + /** + * @brief Get some user-defined property of an Orthanc peer. + * + * This function returns some user-defined property of some Orthanc + * peer. An user-defined property is a property that is associated + * with the peer in the Orthanc configuration file, but that is not + * recognized by the Orthanc core. + * + * This function is thread-safe: Several threads sharing the same + * OrthancPluginPeers object can simultaneously call this function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param peers The data structure describing the Orthanc peers. + * @param peerIndex The index of the peer of interest. + * This value must be lower than OrthancPluginGetPeersCount(). + * @param userProperty The user property of interest. + * @result The value of the user property, or NULL if it is not defined. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.4.2") + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetPeerUserProperty( + OrthancPluginContext* context, + const OrthancPluginPeers* peers, + uint32_t peerIndex, + const char* userProperty) + { + const char* target = NULL; + + _OrthancPluginGetPeerProperty params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.peers = peers; + params.peerIndex = peerIndex; + params.userProperty = userProperty; + + if (context->InvokeService(context, _OrthancPluginService_GetPeerUserProperty, ¶ms) != OrthancPluginErrorCode_Success) + { + /* No such user property */ + return NULL; + } + else + { + return target; + } + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* answerBody; + OrthancPluginMemoryBuffer* answerHeaders; + uint16_t* httpStatus; + const OrthancPluginPeers* peers; + uint32_t peerIndex; + OrthancPluginHttpMethod method; + const char* uri; + uint32_t additionalHeadersCount; + const char* const* additionalHeadersKeys; + const char* const* additionalHeadersValues; + const void* body; + uint32_t bodySize; + uint32_t timeout; + } _OrthancPluginCallPeerApi; + + /** + * @brief Call the REST API of an Orthanc peer. + * + * Make a REST call to the given URI in the REST API of a remote + * Orthanc peer. The result to the query is stored into a newly + * allocated memory buffer. The HTTP request will be done according + * to the "OrthancPeers" configuration option of Orthanc. + * + * This function is thread-safe: Several threads sharing the same + * OrthancPluginPeers object can simultaneously call this function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answerBody The target memory buffer (out argument). + * It must be freed with OrthancPluginFreeMemoryBuffer(). + * The value of this argument is ignored if the HTTP method is DELETE. + * @param answerHeaders The target memory buffer for the HTTP headers in the answers (out argument). + * The answer headers are formatted as a JSON object (associative array). + * The buffer must be freed with OrthancPluginFreeMemoryBuffer(). + * This argument can be set to NULL if the plugin has no interest in the HTTP headers. + * @param httpStatus The HTTP status after the execution of the request (out argument). + * @param peers The data structure describing the Orthanc peers. + * @param peerIndex The index of the peer of interest. + * This value must be lower than OrthancPluginGetPeersCount(). + * @param method HTTP method to be used. + * @param uri The URI of interest in the REST API. + * @param additionalHeadersCount The number of HTTP headers to be added to the + * HTTP headers provided in the global configuration of Orthanc. + * @param additionalHeadersKeys Array containing the keys of the HTTP headers (can be NULL if no header). + * @param additionalHeadersValues Array containing the values of the HTTP headers (can be NULL if no header). + * @param body The HTTP body for a POST or PUT request. + * @param bodySize The size of the body. + * @param timeout Timeout in seconds (0 for default timeout). + * @return 0 if success, or the error code if failure. + * @see OrthancPluginHttpClient() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.4.2") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCallPeerApi( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* answerBody, + OrthancPluginMemoryBuffer* answerHeaders, + uint16_t* httpStatus, + const OrthancPluginPeers* peers, + uint32_t peerIndex, + OrthancPluginHttpMethod method, + const char* uri, + uint32_t additionalHeadersCount, + const char* const* additionalHeadersKeys, + const char* const* additionalHeadersValues, + const void* body, + uint32_t bodySize, + uint32_t timeout) + { + _OrthancPluginCallPeerApi params; + memset(¶ms, 0, sizeof(params)); + + params.answerBody = answerBody; + params.answerHeaders = answerHeaders; + params.httpStatus = httpStatus; + params.peers = peers; + params.peerIndex = peerIndex; + params.method = method; + params.uri = uri; + params.additionalHeadersCount = additionalHeadersCount; + params.additionalHeadersKeys = additionalHeadersKeys; + params.additionalHeadersValues = additionalHeadersValues; + params.body = body; + params.bodySize = bodySize; + params.timeout = timeout; + + return context->InvokeService(context, _OrthancPluginService_CallPeerApi, ¶ms); + } + + + + + + typedef struct + { + OrthancPluginJob** target; + void *job; + OrthancPluginJobFinalize finalize; + const char *type; + OrthancPluginJobGetProgress getProgress; + OrthancPluginJobGetContent getContent; + OrthancPluginJobGetSerialized getSerialized; + OrthancPluginJobStep step; + OrthancPluginJobStop stop; + OrthancPluginJobReset reset; + } _OrthancPluginCreateJob; + + /** + * @brief Create a custom job. + * + * This function creates a custom job to be run by the jobs engine + * of Orthanc. + * + * Orthanc starts one dedicated thread per custom job that is + * running. It is guaranteed that all the callbacks will only be + * called from this single dedicated thread, in mutual exclusion: As + * a consequence, it is *not* mandatory to protect the various + * callbacks by mutexes. + * + * The custom job can nonetheless launch its own processing threads + * on the first call to the "step()" callback, and stop them once + * the "stop()" callback is called. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param job The job to be executed. + * @param finalize The finalization callback. + * @param type The type of the job, provided to the job unserializer. + * See OrthancPluginRegisterJobsUnserializer(). + * @param getProgress The progress callback. + * @param getContent The content callback. + * @param getSerialized The serialization callback. + * @param step The callback to execute the individual steps of the job. + * @param stop The callback that is invoked once the job leaves the "running" state. + * @param reset The callback that is invoked if a stopped job is started again. + * @return The newly allocated job. It must be freed with OrthancPluginFreeJob(), + * as long as it is not submitted with OrthancPluginSubmitJob(). + * @ingroup Toolbox + * @deprecated This signature should not be used anymore since Orthanc SDK 1.11.3. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.4.2") + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE OrthancPluginJob *OrthancPluginCreateJob( + OrthancPluginContext *context, + void *job, + OrthancPluginJobFinalize finalize, + const char *type, + OrthancPluginJobGetProgress getProgress, + OrthancPluginJobGetContent getContent, + OrthancPluginJobGetSerialized getSerialized, + OrthancPluginJobStep step, + OrthancPluginJobStop stop, + OrthancPluginJobReset reset) + { + OrthancPluginJob* target = NULL; + + _OrthancPluginCreateJob params; + memset(¶ms, 0, sizeof(params)); + + params.target = ⌖ + params.job = job; + params.finalize = finalize; + params.type = type; + params.getProgress = getProgress; + params.getContent = getContent; + params.getSerialized = getSerialized; + params.step = step; + params.stop = stop; + params.reset = reset; + + if (context->InvokeService(context, _OrthancPluginService_CreateJob, ¶ms) != OrthancPluginErrorCode_Success || + target == NULL) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + typedef struct + { + OrthancPluginJob** target; + void *job; + OrthancPluginJobFinalize finalize; + const char *type; + OrthancPluginJobGetProgress getProgress; + OrthancPluginJobGetContent2 getContent; + OrthancPluginJobGetSerialized2 getSerialized; + OrthancPluginJobStep step; + OrthancPluginJobStop stop; + OrthancPluginJobReset reset; + } _OrthancPluginCreateJob2; + + /** + * @brief Create a custom job. + * + * This function creates a custom job to be run by the jobs engine + * of Orthanc. + * + * Orthanc starts one dedicated thread per custom job that is + * running. It is guaranteed that all the callbacks will only be + * called from this single dedicated thread, in mutual exclusion: As + * a consequence, it is *not* mandatory to protect the various + * callbacks by mutexes. + * + * The custom job can nonetheless launch its own processing threads + * on the first call to the "step()" callback, and stop them once + * the "stop()" callback is called. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param job The job to be executed. + * @param finalize The finalization callback. + * @param type The type of the job, provided to the job unserializer. + * See OrthancPluginRegisterJobsUnserializer(). + * @param getProgress The progress callback. + * @param getContent The content callback. + * @param getSerialized The serialization callback. + * @param step The callback to execute the individual steps of the job. + * @param stop The callback that is invoked once the job leaves the "running" state. + * @param reset The callback that is invoked if a stopped job is started again. + * @return The newly allocated job. It must be freed with OrthancPluginFreeJob(), + * as long as it is not submitted with OrthancPluginSubmitJob(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.11.3") + ORTHANC_PLUGIN_INLINE OrthancPluginJob *OrthancPluginCreateJob2( + OrthancPluginContext *context, + void *job, + OrthancPluginJobFinalize finalize, + const char *type, + OrthancPluginJobGetProgress getProgress, + OrthancPluginJobGetContent2 getContent, + OrthancPluginJobGetSerialized2 getSerialized, + OrthancPluginJobStep step, + OrthancPluginJobStop stop, + OrthancPluginJobReset reset) + { + OrthancPluginJob* target = NULL; + + _OrthancPluginCreateJob2 params; + memset(¶ms, 0, sizeof(params)); + + params.target = ⌖ + params.job = job; + params.finalize = finalize; + params.type = type; + params.getProgress = getProgress; + params.getContent = getContent; + params.getSerialized = getSerialized; + params.step = step; + params.stop = stop; + params.reset = reset; + + if (context->InvokeService(context, _OrthancPluginService_CreateJob2, ¶ms) != OrthancPluginErrorCode_Success || + target == NULL) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + typedef struct + { + OrthancPluginJob* job; + } _OrthancPluginFreeJob; + + /** + * @brief Free a custom job. + * + * This function frees an image that was created with OrthancPluginCreateJob(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param job The job. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.4.2") + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeJob( + OrthancPluginContext* context, + OrthancPluginJob* job) + { + _OrthancPluginFreeJob params; + params.job = job; + + context->InvokeService(context, _OrthancPluginService_FreeJob, ¶ms); + } + + + + typedef struct + { + char** resultId; + OrthancPluginJob *job; + int32_t priority; + } _OrthancPluginSubmitJob; + + /** + * @brief Submit a new job to the jobs engine of Orthanc. + * + * This function adds the given job to the pending jobs of + * Orthanc. Orthanc will take take of freeing it by invoking the + * finalization callback provided to OrthancPluginCreateJob(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param job The job, as received by OrthancPluginCreateJob(). + * @param priority The priority of the job. + * @return ID of the newly-submitted job. This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.4.2") + ORTHANC_PLUGIN_INLINE char *OrthancPluginSubmitJob( + OrthancPluginContext *context, + OrthancPluginJob *job, + int32_t priority) + { + char* resultId = NULL; + + _OrthancPluginSubmitJob params; + memset(¶ms, 0, sizeof(params)); + + params.resultId = &resultId; + params.job = job; + params.priority = priority; + + if (context->InvokeService(context, _OrthancPluginService_SubmitJob, ¶ms) != OrthancPluginErrorCode_Success || + resultId == NULL) + { + /* Error */ + return NULL; + } + else + { + return resultId; + } + } + + + + typedef struct + { + OrthancPluginJobsUnserializer unserializer; + } _OrthancPluginJobsUnserializer; + + /** + * @brief Register an unserializer for custom jobs. + * + * This function registers an unserializer that decodes custom jobs + * from a JSON string. This callback is invoked when the jobs engine + * of Orthanc is started (on Orthanc initialization), for each job + * that is stored in the Orthanc database. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param unserializer The job unserializer. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.4.2") + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterJobsUnserializer( + OrthancPluginContext* context, + OrthancPluginJobsUnserializer unserializer) + { + _OrthancPluginJobsUnserializer params; + params.unserializer = unserializer; + + context->InvokeService(context, _OrthancPluginService_RegisterJobsUnserializer, ¶ms); + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + const char* details; + uint8_t log; + } _OrthancPluginSetHttpErrorDetails; + + /** + * @brief Provide a detailed description for an HTTP error. + * + * This function sets the detailed description associated with an + * HTTP error. This description will be displayed in the "Details" + * field of the JSON body of the HTTP answer. It is only taken into + * consideration if the REST callback returns an error code that is + * different from "OrthancPluginErrorCode_Success", and if the + * "HttpDescribeErrors" configuration option of Orthanc is set to + * "true". + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param details The details of the error message. + * @param log Whether to also write the detailed error to the Orthanc logs. + * @ingroup REST + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.5.0") + ORTHANC_PLUGIN_INLINE void OrthancPluginSetHttpErrorDetails( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* details, + uint8_t log) + { + _OrthancPluginSetHttpErrorDetails params; + params.output = output; + params.details = details; + params.log = log; + context->InvokeService(context, _OrthancPluginService_SetHttpErrorDetails, ¶ms); + } + + + + typedef struct + { + const char** result; + const char* argument; + } _OrthancPluginRetrieveStaticString; + + /** + * @brief Detect the MIME type of a file. + * + * This function returns the MIME type of a file by inspecting its extension. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param path Path to the file. + * @return The MIME type. This is a statically-allocated + * string, do not free it. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.5.0") + ORTHANC_PLUGIN_INLINE const char* OrthancPluginAutodetectMimeType( + OrthancPluginContext* context, + const char* path) + { + const char* result = NULL; + + _OrthancPluginRetrieveStaticString params; + params.result = &result; + params.argument = path; + + if (context->InvokeService(context, _OrthancPluginService_AutodetectMimeType, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + const char* name; + float value; + OrthancPluginMetricsType type; + } _OrthancPluginSetMetricsValue; + + /** + * @brief Set the value of a floating-point metrics. + * + * This function sets the value of a floating-point metrics to + * monitor the behavior of the plugin through tools such as + * Prometheus. The values of all the metrics are stored within the + * Orthanc context. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param name The name of the metrics to be set. + * @param value The value of the metrics. + * @param type The type of the metrics. This parameter is only taken into consideration + * the first time this metrics is set. + * @ingroup Toolbox + * @see OrthancPluginSetMetricsIntegerValue() + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.5.4") + ORTHANC_PLUGIN_INLINE void OrthancPluginSetMetricsValue( + OrthancPluginContext* context, + const char* name, + float value, + OrthancPluginMetricsType type) + { + _OrthancPluginSetMetricsValue params; + params.name = name; + params.value = value; + params.type = type; + context->InvokeService(context, _OrthancPluginService_SetMetricsValue, ¶ms); + } + + + + typedef struct + { + OrthancPluginRefreshMetricsCallback callback; + } _OrthancPluginRegisterRefreshMetricsCallback; + + /** + * @brief Register a callback to refresh the metrics. + * + * This function registers a callback to refresh the metrics. The + * callback must make calls to OrthancPluginSetMetricsValue() or + * OrthancPluginSetMetricsIntegerValue(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback function to handle the refresh. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.5.4") + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRefreshMetricsCallback( + OrthancPluginContext* context, + OrthancPluginRefreshMetricsCallback callback) + { + _OrthancPluginRegisterRefreshMetricsCallback params; + params.callback = callback; + context->InvokeService(context, _OrthancPluginService_RegisterRefreshMetricsCallback, ¶ms); + } + + + + + typedef struct + { + char** target; + const void* dicom; + uint32_t dicomSize; + OrthancPluginDicomWebBinaryCallback callback; + } _OrthancPluginEncodeDicomWeb; + + /** + * @brief Convert a DICOM instance to DICOMweb JSON. + * + * This function converts a memory buffer containing a DICOM instance, + * into its DICOMweb JSON representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param dicom Pointer to the DICOM instance. + * @param dicomSize Size of the DICOM instance. + * @param callback Callback to set the value of the binary tags. + * @see OrthancPluginCreateDicom() + * @return The NULL value in case of error, or the JSON document. This string must + * be freed by OrthancPluginFreeString(). + * @deprecated OrthancPluginEncodeDicomWebJson2() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.5.4") + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebJson( + OrthancPluginContext* context, + const void* dicom, + uint32_t dicomSize, + OrthancPluginDicomWebBinaryCallback callback) + { + char* target = NULL; + + _OrthancPluginEncodeDicomWeb params; + params.target = ⌖ + params.dicom = dicom; + params.dicomSize = dicomSize; + params.callback = callback; + + if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Convert a DICOM instance to DICOMweb XML. + * + * This function converts a memory buffer containing a DICOM instance, + * into its DICOMweb XML representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param dicom Pointer to the DICOM instance. + * @param dicomSize Size of the DICOM instance. + * @param callback Callback to set the value of the binary tags. + * @return The NULL value in case of error, or the XML document. This string must + * be freed by OrthancPluginFreeString(). + * @see OrthancPluginCreateDicom() + * @deprecated OrthancPluginEncodeDicomWebXml2() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.5.4") + ORTHANC_PLUGIN_DEPRECATED ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebXml( + OrthancPluginContext* context, + const void* dicom, + uint32_t dicomSize, + OrthancPluginDicomWebBinaryCallback callback) + { + char* target = NULL; + + _OrthancPluginEncodeDicomWeb params; + params.target = ⌖ + params.dicom = dicom; + params.dicomSize = dicomSize; + params.callback = callback; + + if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebXml, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + + typedef struct + { + char** target; + const void* dicom; + uint32_t dicomSize; + OrthancPluginDicomWebBinaryCallback2 callback; + void* payload; + } _OrthancPluginEncodeDicomWeb2; + + /** + * @brief Convert a DICOM instance to DICOMweb JSON. + * + * This function converts a memory buffer containing a DICOM instance, + * into its DICOMweb JSON representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param dicom Pointer to the DICOM instance. + * @param dicomSize Size of the DICOM instance. + * @param callback Callback to set the value of the binary tags. + * @param payload User payload. + * @return The NULL value in case of error, or the JSON document. This string must + * be freed by OrthancPluginFreeString(). + * @see OrthancPluginCreateDicom() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.7.0") + ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebJson2( + OrthancPluginContext* context, + const void* dicom, + uint32_t dicomSize, + OrthancPluginDicomWebBinaryCallback2 callback, + void* payload) + { + char* target = NULL; + + _OrthancPluginEncodeDicomWeb2 params; + params.target = ⌖ + params.dicom = dicom; + params.dicomSize = dicomSize; + params.callback = callback; + params.payload = payload; + + if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebJson2, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Convert a DICOM instance to DICOMweb XML. + * + * This function converts a memory buffer containing a DICOM instance, + * into its DICOMweb XML representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param dicom Pointer to the DICOM instance. + * @param dicomSize Size of the DICOM instance. + * @param callback Callback to set the value of the binary tags. + * @param payload User payload. + * @return The NULL value in case of error, or the XML document. This string must + * be freed by OrthancPluginFreeString(). + * @see OrthancPluginCreateDicom() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.7.0") + ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebXml2( + OrthancPluginContext* context, + const void* dicom, + uint32_t dicomSize, + OrthancPluginDicomWebBinaryCallback2 callback, + void* payload) + { + char* target = NULL; + + _OrthancPluginEncodeDicomWeb2 params; + params.target = ⌖ + params.dicom = dicom; + params.dicomSize = dicomSize; + params.callback = callback; + params.payload = payload; + + if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebXml2, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + + /** + * @brief Callback executed when a HTTP header is received during a chunked transfer. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, as soon as it + * receives one HTTP header from the answer of the remote HTTP + * server. + * + * @see OrthancPluginChunkedHttpClient() + * @param answer The user payload, as provided by the calling plugin. + * @param key The key of the HTTP header. + * @param value The value of the HTTP header. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginChunkedClientAnswerAddHeader) ( + void* answer, + const char* key, + const char* value); + + + /** + * @brief Callback executed when an answer chunk is received during a chunked transfer. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, as soon as it + * receives one data chunk from the answer of the remote HTTP + * server. + * + * @see OrthancPluginChunkedHttpClient() + * @param answer The user payload, as provided by the calling plugin. + * @param data The content of the data chunk. + * @param size The size of the data chunk. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginChunkedClientAnswerAddChunk) ( + void* answer, + const void* data, + uint32_t size); + + + /** + * @brief Callback to know whether the request body is entirely read during a chunked transfer + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, while reading + * the body of a POST or PUT request. The plugin must answer "1" as + * soon as the body is entirely read: The "request" data structure + * must act as an iterator. + * + * @see OrthancPluginChunkedHttpClient() + * @param request The user payload, as provided by the calling plugin. + * @return "1" if the body is over, or "0" if there is still data to be read. + * @ingroup Toolbox + **/ + typedef uint8_t (*OrthancPluginChunkedClientRequestIsDone) (void* request); + + + /** + * @brief Callback to advance in the request body during a chunked transfer + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, while reading + * the body of a POST or PUT request. This function asks the plugin + * to advance to the next chunk of data of the request body: The + * "request" data structure must act as an iterator. + * + * @see OrthancPluginChunkedHttpClient() + * @param request The user payload, as provided by the calling plugin. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginChunkedClientRequestNext) (void* request); + + + /** + * @brief Callback to read the current chunk of the request body during a chunked transfer + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, while reading + * the body of a POST or PUT request. The plugin must provide the + * content of the current chunk of data of the request body. + * + * @see OrthancPluginChunkedHttpClient() + * @param request The user payload, as provided by the calling plugin. + * @return The content of the current request chunk. + * @ingroup Toolbox + **/ + typedef const void* (*OrthancPluginChunkedClientRequestGetChunkData) (void* request); + + + /** + * @brief Callback to read the size of the current request chunk during a chunked transfer + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, while reading + * the body of a POST or PUT request. The plugin must provide the + * size of the current chunk of data of the request body. + * + * @see OrthancPluginChunkedHttpClient() + * @param request The user payload, as provided by the calling plugin. + * @return The size of the current request chunk. + * @ingroup Toolbox + **/ + typedef uint32_t (*OrthancPluginChunkedClientRequestGetChunkSize) (void* request); + + + typedef struct + { + void* answer; + OrthancPluginChunkedClientAnswerAddChunk answerAddChunk; + OrthancPluginChunkedClientAnswerAddHeader answerAddHeader; + uint16_t* httpStatus; + OrthancPluginHttpMethod method; + const char* url; + uint32_t headersCount; + const char* const* headersKeys; + const char* const* headersValues; + void* request; + OrthancPluginChunkedClientRequestIsDone requestIsDone; + OrthancPluginChunkedClientRequestGetChunkData requestChunkData; + OrthancPluginChunkedClientRequestGetChunkSize requestChunkSize; + OrthancPluginChunkedClientRequestNext requestNext; + const char* username; + const char* password; + uint32_t timeout; + const char* certificateFile; + const char* certificateKeyFile; + const char* certificateKeyPassword; + uint8_t pkcs11; + } _OrthancPluginChunkedHttpClient; + + + /** + * @brief Issue a HTTP call, using chunked HTTP transfers. + * + * Make a HTTP call to the given URL using chunked HTTP + * transfers. The request body is provided as an iterator over data + * chunks. The answer is provided as a sequence of function calls + * with the individual HTTP headers and answer chunks. + * + * Contrarily to OrthancPluginHttpClient() that entirely stores the + * request body and the answer body in memory buffers, this function + * uses chunked HTTP transfers. This results in a lower memory + * consumption. Pay attention to the fact that Orthanc servers with + * version <= 1.5.6 do not support chunked transfers: You must use + * OrthancPluginHttpClient() if contacting such older servers. + * + * The HTTP request will be done accordingly to the global + * configuration of Orthanc (in particular, the options "HttpProxy", + * "HttpTimeout", "HttpsVerifyPeers", "HttpsCACertificates", and + * "Pkcs11" will be taken into account). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answer The user payload for the answer body. It will be provided to the callbacks for the answer. + * @param answerAddChunk Callback function to report a data chunk from the answer body. + * @param answerAddHeader Callback function to report an HTTP header sent by the remote server. + * @param httpStatus The HTTP status after the execution of the request (out argument). + * @param method HTTP method to be used. + * @param url The URL of interest. + * @param headersCount The number of HTTP headers. + * @param headersKeys Array containing the keys of the HTTP headers (can be NULL if no header). + * @param headersValues Array containing the values of the HTTP headers (can be NULL if no header). + * @param request The user payload containing the request body, and acting as an iterator. + * It will be provided to the callbacks for the request. + * @param requestIsDone Callback function to tell whether the request body is entirely read. + * @param requestChunkData Callback function to get the content of the current data chunk of the request body. + * @param requestChunkSize Callback function to get the size of the current data chunk of the request body. + * @param requestNext Callback function to advance to the next data chunk of the request body. + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @param timeout Timeout in seconds (0 for default timeout). + * @param certificateFile Path to the client certificate for HTTPS, in PEM format + * (can be NULL if no client certificate or if not using HTTPS). + * @param certificateKeyFile Path to the key of the client certificate for HTTPS, in PEM format + * (can be NULL if no client certificate or if not using HTTPS). + * @param certificateKeyPassword Password to unlock the key of the client certificate + * (can be NULL if no client certificate or if not using HTTPS). + * @param pkcs11 Enable PKCS#11 client authentication for hardware security modules and smart cards. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginHttpClient() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.5.7") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginChunkedHttpClient( + OrthancPluginContext* context, + void* answer, + OrthancPluginChunkedClientAnswerAddChunk answerAddChunk, + OrthancPluginChunkedClientAnswerAddHeader answerAddHeader, + uint16_t* httpStatus, + OrthancPluginHttpMethod method, + const char* url, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues, + void* request, + OrthancPluginChunkedClientRequestIsDone requestIsDone, + OrthancPluginChunkedClientRequestGetChunkData requestChunkData, + OrthancPluginChunkedClientRequestGetChunkSize requestChunkSize, + OrthancPluginChunkedClientRequestNext requestNext, + const char* username, + const char* password, + uint32_t timeout, + const char* certificateFile, + const char* certificateKeyFile, + const char* certificateKeyPassword, + uint8_t pkcs11) + { + _OrthancPluginChunkedHttpClient params; + memset(¶ms, 0, sizeof(params)); + + /* In common with OrthancPluginHttpClient() */ + params.httpStatus = httpStatus; + params.method = method; + params.url = url; + params.headersCount = headersCount; + params.headersKeys = headersKeys; + params.headersValues = headersValues; + params.username = username; + params.password = password; + params.timeout = timeout; + params.certificateFile = certificateFile; + params.certificateKeyFile = certificateKeyFile; + params.certificateKeyPassword = certificateKeyPassword; + params.pkcs11 = pkcs11; + + /* For chunked body/answer */ + params.answer = answer; + params.answerAddChunk = answerAddChunk; + params.answerAddHeader = answerAddHeader; + params.request = request; + params.requestIsDone = requestIsDone; + params.requestChunkData = requestChunkData; + params.requestChunkSize = requestChunkSize; + params.requestNext = requestNext; + + return context->InvokeService(context, _OrthancPluginService_ChunkedHttpClient, ¶ms); + } + + + + /** + * @brief Opaque structure that reads the content of a HTTP request body during a chunked HTTP transfer. + * @ingroup Callbacks + **/ + typedef struct ORTHANC_PLUGIN_SINCE_SDK("1.5.7") + _OrthancPluginServerChunkedRequestReader_t OrthancPluginServerChunkedRequestReader; + + + + /** + * @brief Callback to create a reader to handle incoming chunked HTTP transfers. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP server that supports chunked HTTP transfers. This + * callback is only invoked if the HTTP method is POST or PUT. The + * callback must create an user-specific "reader" object that will + * be fed with the body of the incoming body. + * + * @see OrthancPluginRegisterChunkedRestCallback() + * @param reader Memory location that must be filled with the newly-created reader. + * @param uri The URI that is accessed. + * @param request The body of the HTTP request. Note that "body" and "bodySize" are not used. + * @return 0 if success, or the error code if failure. + **/ + typedef OrthancPluginErrorCode (*OrthancPluginServerChunkedRequestReaderFactory) ( + OrthancPluginServerChunkedRequestReader** reader, + const char* uri, + const OrthancPluginHttpRequest* request); + + + /** + * @brief Callback invoked whenever a new data chunk is available during a chunked transfer. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP server that supports chunked HTTP transfers. This callback + * is invoked as soon as a new data chunk is available for the request body. + * + * @see OrthancPluginRegisterChunkedRestCallback() + * @param reader The user payload, as created by the OrthancPluginServerChunkedRequestReaderFactory() callback. + * @param data The content of the data chunk. + * @param size The size of the data chunk. + * @return 0 if success, or the error code if failure. + **/ + typedef OrthancPluginErrorCode (*OrthancPluginServerChunkedRequestReaderAddChunk) ( + OrthancPluginServerChunkedRequestReader* reader, + const void* data, + uint32_t size); + + + /** + * @brief Callback invoked whenever the request body is entirely received. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP server that supports chunked HTTP transfers. This + * callback is invoked as soon as the full body of the HTTP request + * is available. The plugin can then send its answer thanks to the + * provided "output" object. + * + * @see OrthancPluginRegisterChunkedRestCallback() + * @param reader The user payload, as created by the OrthancPluginServerChunkedRequestReaderFactory() callback. + * @param output The HTTP connection to the client application. + * @return 0 if success, or the error code if failure. + **/ + typedef OrthancPluginErrorCode (*OrthancPluginServerChunkedRequestReaderExecute) ( + OrthancPluginServerChunkedRequestReader* reader, + OrthancPluginRestOutput* output); + + + /** + * @brief Callback invoked to release the resources associated with an incoming HTTP chunked transfer. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP server that supports chunked HTTP transfers. This + * callback is invoked to release all the resources allocated by the + * given reader. Note that this function might be invoked even if + * the entire body was not read, to deal with client error or + * disconnection. + * + * @see OrthancPluginRegisterChunkedRestCallback() + * @param reader The user payload, as created by the OrthancPluginServerChunkedRequestReaderFactory() callback. + **/ + typedef void (*OrthancPluginServerChunkedRequestReaderFinalize) ( + OrthancPluginServerChunkedRequestReader* reader); + + typedef struct + { + const char* pathRegularExpression; + OrthancPluginRestCallback getHandler; + OrthancPluginServerChunkedRequestReaderFactory postHandler; + OrthancPluginRestCallback deleteHandler; + OrthancPluginServerChunkedRequestReaderFactory putHandler; + OrthancPluginServerChunkedRequestReaderAddChunk addChunk; + OrthancPluginServerChunkedRequestReaderExecute execute; + OrthancPluginServerChunkedRequestReaderFinalize finalize; + } _OrthancPluginChunkedRestCallback; + + + /** + * @brief Register a REST callback to handle chunked HTTP transfers. + * + * This function registers a REST callback against a regular + * expression for a URI. This function must be called during the + * initialization of the plugin, i.e. inside the + * OrthancPluginInitialize() public function. + * + * Contrarily to OrthancPluginRegisterRestCallback(), the callbacks + * will NOT be invoked in mutual exclusion, so it is up to the + * plugin to implement the required locking mechanisms. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param pathRegularExpression Regular expression for the URI. May contain groups. + * @param getHandler The callback function to handle REST calls using the GET HTTP method. + * @param postHandler The callback function to handle REST calls using the POST HTTP method. + * @param deleteHandler The callback function to handle REST calls using the DELETE HTTP method. + * @param putHandler The callback function to handle REST calls using the PUT HTTP method. + * @param addChunk The callback invoked when a new chunk is available for the request body of a POST or PUT call. + * @param execute The callback invoked once the entire body of a POST or PUT call is read. + * @param finalize The callback invoked to release the resources associated with a POST or PUT call. + * @see OrthancPluginRegisterRestCallbackNoLock() + * + * @note + * The regular expression is case sensitive and must follow the + * [Perl syntax](https://www.boost.org/doc/libs/1_67_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html). + * + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.5.7") + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterChunkedRestCallback( + OrthancPluginContext* context, + const char* pathRegularExpression, + OrthancPluginRestCallback getHandler, + OrthancPluginServerChunkedRequestReaderFactory postHandler, + OrthancPluginRestCallback deleteHandler, + OrthancPluginServerChunkedRequestReaderFactory putHandler, + OrthancPluginServerChunkedRequestReaderAddChunk addChunk, + OrthancPluginServerChunkedRequestReaderExecute execute, + OrthancPluginServerChunkedRequestReaderFinalize finalize) + { + _OrthancPluginChunkedRestCallback params; + params.pathRegularExpression = pathRegularExpression; + params.getHandler = getHandler; + params.postHandler = postHandler; + params.deleteHandler = deleteHandler; + params.putHandler = putHandler; + params.addChunk = addChunk; + params.execute = execute; + params.finalize = finalize; + + context->InvokeService(context, _OrthancPluginService_RegisterChunkedRestCallback, ¶ms); + } + + + + + + typedef struct + { + char** result; + uint16_t group; + uint16_t element; + const char* privateCreator; + } _OrthancPluginGetTagName; + + /** + * @brief Returns the symbolic name of a DICOM tag. + * + * This function makes a lookup to the dictionary of DICOM tags that + * are known to Orthanc, and returns the symbolic name of a DICOM tag. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param group The group of the tag. + * @param element The element of the tag. + * @param privateCreator For private tags, the name of the private creator (can be NULL). + * @return NULL in the case of an error, or a newly allocated string + * containing the path. This string must be freed by + * OrthancPluginFreeString(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.5.7") + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetTagName( + OrthancPluginContext* context, + uint16_t group, + uint16_t element, + const char* privateCreator) + { + char* result; + + _OrthancPluginGetTagName params; + params.result = &result; + params.group = group; + params.element = element; + params.privateCreator = privateCreator; + + if (context->InvokeService(context, _OrthancPluginService_GetTagName, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + /** + * @brief Callback executed by the storage commitment SCP. + * + * Signature of a factory function that creates an object to handle + * one incoming storage commitment request. + * + * @remark The factory receives the list of the SOP class/instance + * UIDs of interest to the remote storage commitment SCU. This gives + * the factory the possibility to start some prefetch process + * upfront in the background, before the handler object is actually + * queried about the status of these DICOM instances. + * + * @param handler Output variable where the factory puts the handler object it created. + * @param jobId ID of the Orthanc job that is responsible for handling + * the storage commitment request. This job will successively look for the + * status of all the individual queried DICOM instances. + * @param transactionUid UID of the storage commitment transaction + * provided by the storage commitment SCU. It contains the value of the + * (0008,1195) DICOM tag. + * @param sopClassUids Array of the SOP class UIDs (0008,0016) that are queried by the SCU. + * @param sopInstanceUids Array of the SOP instance UIDs (0008,0018) that are queried by the SCU. + * @param countInstances Number of DICOM instances that are queried. This is the size + * of the `sopClassUids` and `sopInstanceUids` arrays. + * @param remoteAet The AET of the storage commitment SCU. + * @param calledAet The AET used by the SCU to contact the storage commitment SCP (i.e. Orthanc). + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageCommitmentFactory) ( + void** handler /* out */, + const char* jobId, + const char* transactionUid, + const char* const* sopClassUids, + const char* const* sopInstanceUids, + uint32_t countInstances, + const char* remoteAet, + const char* calledAet); + + + /** + * @brief Callback to free one storage commitment SCP handler. + * + * Signature of a callback function that releases the resources + * allocated by the factory of the storage commitment SCP. The + * handler is the return value of a previous call to the + * OrthancPluginStorageCommitmentFactory() callback. + * + * @param handler The handler object to be destructed. + * @ingroup DicomCallbacks + **/ + typedef void (*OrthancPluginStorageCommitmentDestructor) (void* handler); + + + /** + * @brief Callback to get the status of one DICOM instance in the + * storage commitment SCP. + * + * Signature of a callback function that is successively invoked for + * each DICOM instance that is queried by the remote storage + * commitment SCU. The function must be tought of as a method of + * the handler object that was created by a previous call to the + * OrthancPluginStorageCommitmentFactory() callback. After each call + * to this method, the progress of the associated Orthanc job is + * updated. + * + * @param target Output variable where to put the status for the queried instance. + * @param handler The handler object associated with this storage commitment request. + * @param sopClassUid The SOP class UID (0008,0016) of interest. + * @param sopInstanceUid The SOP instance UID (0008,0018) of interest. + * @ingroup DicomCallbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageCommitmentLookup) ( + OrthancPluginStorageCommitmentFailureReason* target, + void* handler, + const char* sopClassUid, + const char* sopInstanceUid); + + + typedef struct + { + OrthancPluginStorageCommitmentFactory factory; + OrthancPluginStorageCommitmentDestructor destructor; + OrthancPluginStorageCommitmentLookup lookup; + } _OrthancPluginRegisterStorageCommitmentScpCallback; + + /** + * @brief Register a callback to handle incoming requests to the storage commitment SCP. + * + * This function registers a callback to handle storage commitment SCP requests. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param factory Factory function that creates the handler object + * for incoming storage commitment requests. + * @param destructor Destructor function to destroy the handler object. + * @param lookup Callback function to get the status of one DICOM instance. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.6.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterStorageCommitmentScpCallback( + OrthancPluginContext* context, + OrthancPluginStorageCommitmentFactory factory, + OrthancPluginStorageCommitmentDestructor destructor, + OrthancPluginStorageCommitmentLookup lookup) + { + _OrthancPluginRegisterStorageCommitmentScpCallback params; + params.factory = factory; + params.destructor = destructor; + params.lookup = lookup; + return context->InvokeService(context, _OrthancPluginService_RegisterStorageCommitmentScpCallback, ¶ms); + } + + + + /** + * @brief Callback to filter incoming DICOM instances received by Orthanc. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives a new DICOM instance (e.g. through REST API or + * DICOM protocol), and that answers whether this DICOM instance + * should be accepted or discarded by Orthanc. + * + * Note that the metadata information is not available + * (i.e. GetInstanceMetadata() should not be used on "instance"). + * + * @warning Your callback function will be called synchronously with + * the core of Orthanc. This implies that deadlocks might emerge if + * you call other core primitives of Orthanc in your callback (such + * deadlocks are particularly visible in the presence of other plugins + * or Lua scripts). It is thus strongly advised to avoid any call to + * the REST API of Orthanc in the callback. If you have to call + * other primitives of Orthanc, you should make these calls in a + * separate thread, passing the pending events to be processed + * through a message queue. + * + * @param instance The received DICOM instance. + * @return 0 to discard the instance, 1 to store the instance, -1 if error. + * @ingroup Callbacks + **/ + typedef int32_t (*OrthancPluginIncomingDicomInstanceFilter) ( + const OrthancPluginDicomInstance* instance); + + + typedef struct + { + OrthancPluginIncomingDicomInstanceFilter callback; + } _OrthancPluginIncomingDicomInstanceFilter; + + /** + * @brief Register a callback to filter incoming DICOM instances. + * + * This function registers a custom callback to filter incoming + * DICOM instances received by Orthanc (either through the REST API + * or through the DICOM protocol). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.6.1") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingDicomInstanceFilter( + OrthancPluginContext* context, + OrthancPluginIncomingDicomInstanceFilter callback) + { + _OrthancPluginIncomingDicomInstanceFilter params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterIncomingDicomInstanceFilter, ¶ms); + } + + + /** + * @brief Callback to filter incoming DICOM instances received by + * Orthanc through C-STORE. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives a new DICOM instance using DICOM C-STORE, and + * that answers whether this DICOM instance should be accepted or + * discarded by Orthanc. If the instance is discarded, the callback + * can specify the DIMSE error code answered by the Orthanc C-STORE + * SCP. + * + * Note that the metadata information is not available + * (i.e. GetInstanceMetadata() should not be used on "instance"). + * + * @warning Your callback function will be called synchronously with + * the core of Orthanc. This implies that deadlocks might emerge if + * you call other core primitives of Orthanc in your callback (such + * deadlocks are particularly visible in the presence of other plugins + * or Lua scripts). It is thus strongly advised to avoid any call to + * the REST API of Orthanc in the callback. If you have to call + * other primitives of Orthanc, you should make these calls in a + * separate thread, passing the pending events to be processed + * through a message queue. + * + * @param dimseStatus If the DICOM instance is discarded, + * DIMSE status to be sent by the C-STORE SCP of Orthanc + * @param instance The received DICOM instance. + * @return 0 to discard the instance, 1 to store the instance, -1 if error. + * @ingroup Callbacks + **/ + typedef int32_t (*OrthancPluginIncomingCStoreInstanceFilter) ( + uint16_t* dimseStatus /* out */, + const OrthancPluginDicomInstance* instance); + + + typedef struct + { + OrthancPluginIncomingCStoreInstanceFilter callback; + } _OrthancPluginIncomingCStoreInstanceFilter; + + /** + * @brief Register a callback to filter incoming DICOM instances + * received by Orthanc through C-STORE. + * + * This function registers a custom callback to filter incoming + * DICOM instances received by Orthanc through the DICOM protocol. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.10.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingCStoreInstanceFilter( + OrthancPluginContext* context, + OrthancPluginIncomingCStoreInstanceFilter callback) + { + _OrthancPluginIncomingCStoreInstanceFilter params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterIncomingCStoreInstanceFilter, ¶ms); + } + + /** + * @brief Callback to keep/discard/modify a DICOM instance received + * by Orthanc from any source (C-STORE or REST API) + * + * Signature of a callback function that is triggered whenever + * Orthanc receives a new DICOM instance (through DICOM protocol or + * REST API), and that specifies an action to be applied to this + * newly received instance. The instance can be kept as it is, can + * be modified by the plugin, or can be discarded. + * + * This callback is invoked immediately after reception, i.e. before + * transcoding and before filtering + * (cf. OrthancPluginRegisterIncomingDicomInstanceFilter()). + * + * @warning Your callback function will be called synchronously with + * the core of Orthanc. This implies that deadlocks might emerge if + * you call other core primitives of Orthanc in your callback (such + * deadlocks are particularly visible in the presence of other plugins + * or Lua scripts). It is thus strongly advised to avoid any call to + * the REST API of Orthanc in the callback. If you have to call + * other primitives of Orthanc, you should make these calls in a + * separate thread, passing the pending events to be processed + * through a message queue. + * + * @param modifiedDicomBuffer A buffer containing the modified DICOM (output). + * This buffer must be allocated using OrthancPluginCreateMemoryBuffer64() + * and will be freed by the Orthanc core. + * @param receivedDicomBuffer A buffer containing the received DICOM (input). + * @param receivedDicomBufferSize The size of the received DICOM (input). + * @param origin The origin of the DICOM instance (input). + * @return `OrthancPluginReceivedInstanceAction_KeepAsIs` to accept the instance as is,
+ * `OrthancPluginReceivedInstanceAction_Modify` to store the modified DICOM contained in `modifiedDicomBuffer`,
+ * `OrthancPluginReceivedInstanceAction_Discard` to tell Orthanc to discard the instance. + * @ingroup Callbacks + **/ + typedef OrthancPluginReceivedInstanceAction (*OrthancPluginReceivedInstanceCallback) ( + OrthancPluginMemoryBuffer64* modifiedDicomBuffer, + const void* receivedDicomBuffer, + uint64_t receivedDicomBufferSize, + OrthancPluginInstanceOrigin origin); + + + typedef struct + { + OrthancPluginReceivedInstanceCallback callback; + } _OrthancPluginReceivedInstanceCallback; + + /** + * @brief Register a callback to keep/discard/modify a DICOM instance received + * by Orthanc from any source (C-STORE or REST API) + * + * This function registers a custom callback to keep/discard/modify + * incoming DICOM instances received by Orthanc from any source + * (C-STORE or REST API). + * + * @warning Contrarily to + * OrthancPluginRegisterIncomingCStoreInstanceFilter() and + * OrthancPluginRegisterIncomingDicomInstanceFilter() that can be + * called by multiple plugins, + * OrthancPluginRegisterReceivedInstanceCallback() can only be used + * by one single plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.10.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterReceivedInstanceCallback( + OrthancPluginContext* context, + OrthancPluginReceivedInstanceCallback callback) + { + _OrthancPluginReceivedInstanceCallback params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterReceivedInstanceCallback, ¶ms); + } + + /** + * @brief Get the transfer syntax of a DICOM file. + * + * This function returns a pointer to a newly created string that + * contains the transfer syntax UID of the DICOM instance. The empty + * string might be returned if this information is unknown. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The NULL value in case of error, or a string containing the + * transfer syntax UID. This string must be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.6.1") + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceTransferSyntaxUid( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultStringToFree = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceTransferSyntaxUid, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Check whether the DICOM file has pixel data. + * + * This function returns a Boolean value indicating whether the + * DICOM instance contains the pixel data (7FE0,0010) tag. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return "1" if the DICOM instance contains pixel data, or "0" if + * the tag is missing, or "-1" in the case of an error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.6.1") + ORTHANC_PLUGIN_INLINE int32_t OrthancPluginHasInstancePixelData( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + int64_t hasPixelData; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultInt64 = &hasPixelData; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_HasInstancePixelData, ¶ms) != OrthancPluginErrorCode_Success || + hasPixelData < 0 || + hasPixelData > 1) + { + /* Error */ + return -1; + } + else + { + return (hasPixelData != 0); + } + } + + + + + + + typedef struct + { + OrthancPluginDicomInstance** target; + const void* buffer; + uint32_t size; + const char* transferSyntax; + } _OrthancPluginCreateDicomInstance; + + /** + * @brief Parse a DICOM instance. + * + * This function parses a memory buffer that contains a DICOM + * file. The function returns a new pointer to a data structure that + * is managed by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The memory buffer containing the DICOM instance. + * @param size The size of the memory buffer. + * @return The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.7.0") + ORTHANC_PLUGIN_INLINE OrthancPluginDicomInstance* OrthancPluginCreateDicomInstance( + OrthancPluginContext* context, + const void* buffer, + uint32_t size) + { + OrthancPluginDicomInstance* target = NULL; + + _OrthancPluginCreateDicomInstance params; + params.target = ⌖ + params.buffer = buffer; + params.size = size; + + if (context->InvokeService(context, _OrthancPluginService_CreateDicomInstance, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + typedef struct + { + OrthancPluginDicomInstance* dicom; + } _OrthancPluginFreeDicomInstance; + + /** + * @brief Free a DICOM instance. + * + * This function frees a DICOM instance that was parsed using + * OrthancPluginCreateDicomInstance(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param dicom The DICOM instance. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.7.0") + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeDicomInstance( + OrthancPluginContext* context, + OrthancPluginDicomInstance* dicom) + { + _OrthancPluginFreeDicomInstance params; + params.dicom = dicom; + + context->InvokeService(context, _OrthancPluginService_FreeDicomInstance, ¶ms); + } + + + typedef struct + { + uint32_t* targetUint32; + OrthancPluginMemoryBuffer* targetBuffer; + OrthancPluginImage** targetImage; + char** targetStringToFree; + const OrthancPluginDicomInstance* instance; + uint32_t frameIndex; + OrthancPluginDicomToJsonFormat format; + OrthancPluginDicomToJsonFlags flags; + uint32_t maxStringLength; + OrthancPluginDicomWebBinaryCallback2 dicomWebCallback; + void* dicomWebPayload; + } _OrthancPluginAccessDicomInstance2; + + /** + * @brief Get the number of frames in a DICOM instance. + * + * This function returns the number of frames that are part of a + * DICOM image managed by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The number of frames (will be zero in the case of an error). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.7.0") + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetInstanceFramesCount( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + uint32_t count; + + _OrthancPluginAccessDicomInstance2 params; + memset(¶ms, 0, sizeof(params)); + params.targetUint32 = &count; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceFramesCount, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return count; + } + } + + + /** + * @brief Get the raw content of a frame in a DICOM instance. + * + * This function returns a memory buffer containing the raw content + * of a frame in a DICOM instance that is managed by the Orthanc + * core. This is notably useful for compressed transfer syntaxes, as + * it gives access to the embedded files (such as JPEG, JPEG-LS or + * JPEG2k). The Orthanc core transparently reassembles the fragments + * to extract the raw frame. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param instance The instance of interest. + * @param frameIndex The index of the frame of interest. + * @return 0 if success, or the error code if failure. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.7.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetInstanceRawFrame( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const OrthancPluginDicomInstance* instance, + uint32_t frameIndex) + { + _OrthancPluginAccessDicomInstance2 params; + memset(¶ms, 0, sizeof(params)); + params.targetBuffer = target; + params.instance = instance; + params.frameIndex = frameIndex; + + return context->InvokeService(context, _OrthancPluginService_GetInstanceRawFrame, ¶ms); + } + + + /** + * @brief Decode one frame from a DICOM instance. + * + * This function decodes one frame of a DICOM image that is managed + * by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @param frameIndex The index of the frame of interest. + * @return The uncompressed image. It must be freed with OrthancPluginFreeImage(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.7.0") + ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginGetInstanceDecodedFrame( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + uint32_t frameIndex) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginAccessDicomInstance2 params; + memset(¶ms, 0, sizeof(params)); + params.targetImage = ⌖ + params.instance = instance; + params.frameIndex = frameIndex; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceDecodedFrame, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Parse and transcode a DICOM instance. + * + * This function parses a memory buffer that contains a DICOM file, + * then transcodes it to the given transfer syntax. The function + * returns a new pointer to a data structure that is managed by the + * Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The memory buffer containing the DICOM instance. + * @param size The size of the memory buffer. + * @param transferSyntax The transfer syntax UID for the transcoding. + * @return The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.7.0") + ORTHANC_PLUGIN_INLINE OrthancPluginDicomInstance* OrthancPluginTranscodeDicomInstance( + OrthancPluginContext* context, + const void* buffer, + uint32_t size, + const char* transferSyntax) + { + OrthancPluginDicomInstance* target = NULL; + + _OrthancPluginCreateDicomInstance params; + params.target = ⌖ + params.buffer = buffer; + params.size = size; + params.transferSyntax = transferSyntax; + + if (context->InvokeService(context, _OrthancPluginService_TranscodeDicomInstance, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + /** + * @brief Writes a DICOM instance to a memory buffer. + * + * This function returns a memory buffer containing the + * serialization of a DICOM instance that is managed by the Orthanc + * core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param instance The instance of interest. + * @return 0 if success, or the error code if failure. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.7.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSerializeDicomInstance( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const OrthancPluginDicomInstance* instance) + { + _OrthancPluginAccessDicomInstance2 params; + memset(¶ms, 0, sizeof(params)); + params.targetBuffer = target; + params.instance = instance; + + return context->InvokeService(context, _OrthancPluginService_SerializeDicomInstance, ¶ms); + } + + + /** + * @brief Format a DICOM memory buffer as a JSON string. + * + * This function takes as DICOM instance managed by the Orthanc + * core, and outputs a JSON string representing the tags of this + * DICOM file. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The DICOM instance of interest. + * @param format The output format. + * @param flags Flags governing the output. + * @param maxStringLength The maximum length of a field. Too long fields will + * be output as "null". The 0 value means no maximum length. + * @return The NULL value if the case of an error, or the JSON + * string. This string must be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + * @see OrthancPluginDicomBufferToJson() + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.7.0") + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceAdvancedJson( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + OrthancPluginDicomToJsonFormat format, + OrthancPluginDicomToJsonFlags flags, + uint32_t maxStringLength) + { + char* result = NULL; + + _OrthancPluginAccessDicomInstance2 params; + memset(¶ms, 0, sizeof(params)); + params.targetStringToFree = &result; + params.instance = instance; + params.format = format; + params.flags = flags; + params.maxStringLength = maxStringLength; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceAdvancedJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Convert a DICOM instance to DICOMweb JSON. + * + * This function converts a DICOM instance that is managed by the + * Orthanc core, into its DICOMweb JSON representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The DICOM instance of interest. + * @param callback Callback to set the value of the binary tags. + * @param payload User payload. + * @return The NULL value in case of error, or the JSON document. This string must + * be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.7.0") + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceDicomWebJson( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + OrthancPluginDicomWebBinaryCallback2 callback, + void* payload) + { + char* target = NULL; + + _OrthancPluginAccessDicomInstance2 params; + params.targetStringToFree = ⌖ + params.instance = instance; + params.dicomWebCallback = callback; + params.dicomWebPayload = payload; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceDicomWebJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Convert a DICOM instance to DICOMweb XML. + * + * This function converts a DICOM instance that is managed by the + * Orthanc core, into its DICOMweb XML representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The DICOM instance of interest. + * @param callback Callback to set the value of the binary tags. + * @param payload User payload. + * @return The NULL value in case of error, or the XML document. This string must + * be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.7.0") + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceDicomWebXml( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + OrthancPluginDicomWebBinaryCallback2 callback, + void* payload) + { + char* target = NULL; + + _OrthancPluginAccessDicomInstance2 params; + params.targetStringToFree = ⌖ + params.instance = instance; + params.dicomWebCallback = callback; + params.dicomWebPayload = payload; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceDicomWebXml, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + + /** + * @brief Signature of a callback function to transcode a DICOM instance. + * @param transcoded Target memory buffer. It must be allocated by the + * plugin using OrthancPluginCreateMemoryBuffer(). + * @param buffer Memory buffer containing the source DICOM instance. + * @param size Size of the source memory buffer. + * @param allowedSyntaxes A C array of possible transfer syntaxes UIDs for the + * result of the transcoding. The plugin must choose by itself the + * transfer syntax that will be used for the resulting DICOM image. + * @param countSyntaxes The number of transfer syntaxes that are contained + * in the "allowedSyntaxes" array. + * @param allowNewSopInstanceUid Whether the transcoding plugin can select + * a transfer syntax that will change the SOP instance UID (or, in other + * terms, whether the plugin can transcode using lossy compression). + * @return 0 if success (i.e. image successfully transcoded and stored into + * "transcoded"), or the error code if failure. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginTranscoderCallback) ( + OrthancPluginMemoryBuffer* transcoded /* out */, + const void* buffer, + uint64_t size, + const char* const* allowedSyntaxes, + uint32_t countSyntaxes, + uint8_t allowNewSopInstanceUid); + + + typedef struct + { + OrthancPluginTranscoderCallback callback; + } _OrthancPluginTranscoderCallback; + + /** + * @brief Register a callback to handle the transcoding of DICOM images. + * + * This function registers a custom callback to transcode DICOM + * images, extending the built-in transcoder of Orthanc that uses + * DCMTK. The exact behavior is affected by the configuration option + * "BuiltinDecoderTranscoderOrder" of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.7.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterTranscoderCallback( + OrthancPluginContext* context, + OrthancPluginTranscoderCallback callback) + { + _OrthancPluginTranscoderCallback params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterTranscoderCallback, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + uint32_t size; + } _OrthancPluginCreateMemoryBuffer; + + /** + * @brief Create a 32-bit memory buffer. + * + * This function creates a memory buffer that is managed by the + * Orthanc core. The main use case of this function is for plugins + * that act as DICOM transcoders. + * + * Your plugin should never call "free()" on the resulting memory + * buffer, as the C library that is used by the plugin is in general + * not the same as the one used by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param size Size of the memory buffer to be created. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.7.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateMemoryBuffer( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + uint32_t size) + { + _OrthancPluginCreateMemoryBuffer params; + params.target = target; + params.size = size; + + return context->InvokeService(context, _OrthancPluginService_CreateMemoryBuffer, ¶ms); + } + + + /** + * @brief Generate a token to grant full access to the REST API of Orthanc. + * + * This function generates a token that can be set in the HTTP + * header "Authorization" so as to grant full access to the REST API + * of Orthanc using an external HTTP client. Using this function + * avoids the need of adding a separate user in the + * "RegisteredUsers" configuration of Orthanc, which eases + * deployments. + * + * This feature is notably useful in multiprocess scenarios, where a + * subprocess created by a plugin has no access to the + * "OrthancPluginContext", and thus cannot call + * "OrthancPluginRestApi[Get|Post|Put|Delete]()". + * + * This situation is frequently encountered in Python plugins, where + * the "multiprocessing" package can be used to bypass the Global + * Interpreter Lock (GIL) and thus to improve performance and + * concurrency. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return The authorization token, or NULL value in the case of an error. + * This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.8.1") + ORTHANC_PLUGIN_INLINE char* OrthancPluginGenerateRestApiAuthorizationToken( + OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GenerateRestApiAuthorizationToken, + ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginMemoryBuffer64* target; + uint64_t size; + } _OrthancPluginCreateMemoryBuffer64; + + /** + * @brief Create a 64-bit memory buffer. + * + * This function creates a 64-bit memory buffer that is managed by + * the Orthanc core. The main use case of this function is for + * plugins that read files from the storage area. + * + * Your plugin should never call "free()" on the resulting memory + * buffer, as the C library that is used by the plugin is in general + * not the same as the one used by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param size Size of the memory buffer to be created. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.9.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateMemoryBuffer64( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer64* target, + uint64_t size) + { + _OrthancPluginCreateMemoryBuffer64 params; + params.target = target; + params.size = size; + + return context->InvokeService(context, _OrthancPluginService_CreateMemoryBuffer64, ¶ms); + } + + + typedef struct + { + OrthancPluginStorageCreate create; + OrthancPluginStorageReadWhole readWhole; + OrthancPluginStorageReadRange readRange; + OrthancPluginStorageRemove remove; + } _OrthancPluginRegisterStorageArea2; + + /** + * @brief Register a custom storage area, with support for range request. + * + * This function registers a custom storage area, to replace the + * built-in way Orthanc stores its files on the filesystem. This + * function must be called during the initialization of the plugin, + * i.e. inside the OrthancPluginInitialize() public function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param create The callback function to store a file on the custom storage area. + * @param readWhole The callback function to read a whole file from the custom storage area. + * @param readRange The callback function to read some range of a file from the custom storage area. + * If this feature is not supported by the plugin, this value can be set to NULL. + * @param remove The callback function to remove a file from the custom storage area. + * @ingroup Callbacks + * @deprecated New plugins should use OrthancPluginRegisterStorageArea3() + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.9.0") + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterStorageArea2( + OrthancPluginContext* context, + OrthancPluginStorageCreate create, + OrthancPluginStorageReadWhole readWhole, + OrthancPluginStorageReadRange readRange, + OrthancPluginStorageRemove remove) + { + _OrthancPluginRegisterStorageArea2 params; + params.create = create; + params.readWhole = readWhole; + params.readRange = readRange; + params.remove = remove; + context->InvokeService(context, _OrthancPluginService_RegisterStorageArea2, ¶ms); + } + + + + typedef struct + { + _OrthancPluginCreateDicom createDicom; + const char* privateCreator; + } _OrthancPluginCreateDicom2; + + /** + * @brief Create a DICOM instance from a JSON string and an image, with a private creator. + * + * This function takes as input a string containing a JSON file + * describing the content of a DICOM instance. As an output, it + * writes the corresponding DICOM instance to a newly allocated + * memory buffer. Additionally, an image to be encoded within the + * DICOM instance can also be provided. + * + * Contrarily to the function OrthancPluginCreateDicom(), this + * function can be explicitly provided with a private creator. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param json The input JSON file. + * @param pixelData The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme. + * @param flags Flags governing the output. + * @param privateCreator The private creator to be used for the private DICOM tags. + * Check out the global configuration option "Dictionary" of Orthanc. + * @return 0 if success, other value if error. + * @ingroup Toolbox + * @see OrthancPluginCreateDicom() + * @see OrthancPluginDicomBufferToJson() + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.9.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateDicom2( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* json, + const OrthancPluginImage* pixelData, + OrthancPluginCreateDicomFlags flags, + const char* privateCreator) + { + _OrthancPluginCreateDicom2 params; + params.createDicom.target = target; + params.createDicom.json = json; + params.createDicom.pixelData = pixelData; + params.createDicom.flags = flags; + params.privateCreator = privateCreator; + + return context->InvokeService(context, _OrthancPluginService_CreateDicom2, ¶ms); + } + + + + + + + typedef struct + { + OrthancPluginMemoryBuffer* answerBody; + OrthancPluginMemoryBuffer* answerHeaders; + uint16_t* httpStatus; + OrthancPluginHttpMethod method; + const char* uri; + uint32_t headersCount; + const char* const* headersKeys; + const char* const* headersValues; + const void* body; + uint32_t bodySize; + uint8_t afterPlugins; + } _OrthancPluginCallRestApi; + + /** + * @brief Call the REST API of Orthanc with full flexibility. + * + * Make a call to the given URI in the REST API of Orthanc. The + * result to the query is stored into a newly allocated memory + * buffer. This function is always granted full access to the REST + * API (no credentials, nor security token is needed). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answerBody The target memory buffer (out argument). + * It must be freed with OrthancPluginFreeMemoryBuffer(). + * The value of this argument is ignored if the HTTP method is DELETE. + * @param answerHeaders The target memory buffer for the HTTP headers in the answer (out argument). + * The answer headers are formatted as a JSON object (associative array). + * The buffer must be freed with OrthancPluginFreeMemoryBuffer(). + * This argument can be set to NULL if the plugin has no interest in the answer HTTP headers. + * @param httpStatus The HTTP status after the execution of the request (out argument). + * @param method HTTP method to be used. + * @param uri The URI of interest. + * @param headersCount The number of HTTP headers. + * @param headersKeys Array containing the keys of the HTTP headers (can be NULL if no header). + * @param headersValues Array containing the values of the HTTP headers (can be NULL if no header). + * @param body The HTTP body for a POST or PUT request. + * @param bodySize The size of the body. + * @param afterPlugins If 0, the built-in API of Orthanc is used. + * If 1, the API is tainted by the plugins. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginRestApiGet2(), OrthancPluginRestApiPost(), OrthancPluginRestApiPut(), OrthancPluginRestApiDelete() + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.9.2") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCallRestApi( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* answerBody, + OrthancPluginMemoryBuffer* answerHeaders, + uint16_t* httpStatus, + OrthancPluginHttpMethod method, + const char* uri, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues, + const void* body, + uint32_t bodySize, + uint8_t afterPlugins) + { + _OrthancPluginCallRestApi params; + memset(¶ms, 0, sizeof(params)); + + params.answerBody = answerBody; + params.answerHeaders = answerHeaders; + params.httpStatus = httpStatus; + params.method = method; + params.uri = uri; + params.headersCount = headersCount; + params.headersKeys = headersKeys; + params.headersValues = headersValues; + params.body = body; + params.bodySize = bodySize; + params.afterPlugins = afterPlugins; + + return context->InvokeService(context, _OrthancPluginService_CallRestApi, ¶ms); + } + + + + /** + * @brief Opaque structure that represents a WebDAV collection. + * @ingroup Callbacks + **/ + typedef struct ORTHANC_PLUGIN_SINCE_SDK("1.10.1") + _OrthancPluginWebDavCollection_t OrthancPluginWebDavCollection; + + + /** + * @brief Declare a file while returning the content of a folder. + * + * This function declares a file while returning the content of a + * WebDAV folder. + * + * @param collection Context of the collection. + * @param name Base name of the file. + * @param dateTime The date and time of creation of the file. + * Check out the documentation of OrthancPluginWebDavRetrieveFile() for more information. + * @param size Size of the file. + * @param mimeType The MIME type of the file. If empty or set to `NULL`, + * Orthanc will do a best guess depending on the file extension. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavAddFile) ( + OrthancPluginWebDavCollection* collection, + const char* name, + uint64_t size, + const char* mimeType, + const char* dateTime); + + + /** + * @brief Declare a subfolder while returning the content of a folder. + * + * This function declares a subfolder while returning the content of a + * WebDAV folder. + * + * @param collection Context of the collection. + * @param name Base name of the subfolder. + * @param dateTime The date and time of creation of the subfolder. + * Check out the documentation of OrthancPluginWebDavRetrieveFile() for more information. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavAddFolder) ( + OrthancPluginWebDavCollection* collection, + const char* name, + const char* dateTime); + + + /** + * @brief Retrieve the content of a file. + * + * This function is used to forward the content of a file from a + * WebDAV collection, to the core of Orthanc. + * + * @param collection Context of the collection. + * @param data Content of the file. + * @param size Size of the file. + * @param mimeType The MIME type of the file. If empty or set to `NULL`, + * Orthanc will do a best guess depending on the file extension. + * @param dateTime The date and time of creation of the file. + * It must be formatted as an ISO string of form + * `YYYYMMDDTHHMMSS,fffffffff` where T is the date-time + * separator. It must be expressed in UTC (it is the responsibility + * of the plugin to do the possible timezone + * conversions). Internally, this string will be parsed using + * `boost::posix_time::from_iso_string()`. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavRetrieveFile) ( + OrthancPluginWebDavCollection* collection, + const void* data, + uint64_t size, + const char* mimeType, + const char* dateTime); + + + /** + * @brief Callback for testing the existence of a folder. + * + * Signature of a callback function that tests whether the given + * path in the WebDAV collection exists and corresponds to a folder. + * + * @param isExisting Pointer to a Boolean that must be set to `1` if the folder exists, or `0` otherwise. + * @param pathSize Number of levels in the path. + * @param pathItems Items making the path. + * @param payload The user payload. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavIsExistingFolderCallback) ( + uint8_t* isExisting, /* out */ + uint32_t pathSize, + const char* const* pathItems, + void* payload); + + + /** + * @brief Callback for listing the content of a folder. + * + * Signature of a callback function that lists the content of a + * folder in the WebDAV collection. The callback must call the + * provided `addFile()` and `addFolder()` functions to emit the + * content of the folder. + * + * @param isExisting Pointer to a Boolean that must be set to `1` if the folder exists, or `0` otherwise. + * @param collection Context to be provided to `addFile()` and `addFolder()` functions. + * @param addFile Function to add a file to the list. + * @param addFolder Function to add a folder to the list. + * @param pathSize Number of levels in the path. + * @param pathItems Items making the path. + * @param payload The user payload. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavListFolderCallback) ( + uint8_t* isExisting, /* out */ + OrthancPluginWebDavCollection* collection, + OrthancPluginWebDavAddFile addFile, + OrthancPluginWebDavAddFolder addFolder, + uint32_t pathSize, + const char* const* pathItems, + void* payload); + + + /** + * @brief Callback for retrieving the content of a file. + * + * Signature of a callback function that retrieves the content of a + * file in the WebDAV collection. The callback must call the + * provided `retrieveFile()` function to emit the actual content of + * the file. + * + * @param collection Context to be provided to `retrieveFile()` function. + * @param retrieveFile Function to return the content of the file. + * @param pathSize Number of levels in the path. + * @param pathItems Items making the path. + * @param payload The user payload. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavRetrieveFileCallback) ( + OrthancPluginWebDavCollection* collection, + OrthancPluginWebDavRetrieveFile retrieveFile, + uint32_t pathSize, + const char* const* pathItems, + void* payload); + + + /** + * @brief Callback to store a file. + * + * Signature of a callback function that stores a file into the + * WebDAV collection. + * + * @param isReadOnly Pointer to a Boolean that must be set to `1` if the collection is read-only, or `0` otherwise. + * @param pathSize Number of levels in the path. + * @param pathItems Items making the path. + * @param data Content of the file to be stored. + * @param size Size of the file to be stored. + * @param payload The user payload. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavStoreFileCallback) ( + uint8_t* isReadOnly, /* out */ + uint32_t pathSize, + const char* const* pathItems, + const void* data, + uint64_t size, + void* payload); + + + /** + * @brief Callback to create a folder. + * + * Signature of a callback function that creates a folder in the + * WebDAV collection. + * + * @param isReadOnly Pointer to a Boolean that must be set to `1` if the collection is read-only, or `0` otherwise. + * @param pathSize Number of levels in the path. + * @param pathItems Items making the path. + * @param payload The user payload. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavCreateFolderCallback) ( + uint8_t* isReadOnly, /* out */ + uint32_t pathSize, + const char* const* pathItems, + void* payload); + + + /** + * @brief Callback to remove a file or a folder. + * + * Signature of a callback function that removes a file or a folder + * from the WebDAV collection. + * + * @param isReadOnly Pointer to a Boolean that must be set to `1` if the collection is read-only, or `0` otherwise. + * @param pathSize Number of levels in the path. + * @param pathItems Items making the path. + * @param payload The user payload. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWebDavDeleteItemCallback) ( + uint8_t* isReadOnly, /* out */ + uint32_t pathSize, + const char* const* pathItems, + void* payload); + + + typedef struct + { + const char* uri; + OrthancPluginWebDavIsExistingFolderCallback isExistingFolder; + OrthancPluginWebDavListFolderCallback listFolder; + OrthancPluginWebDavRetrieveFileCallback retrieveFile; + OrthancPluginWebDavStoreFileCallback storeFile; + OrthancPluginWebDavCreateFolderCallback createFolder; + OrthancPluginWebDavDeleteItemCallback deleteItem; + void* payload; + } _OrthancPluginRegisterWebDavCollection; + + /** + * @brief Register a WebDAV virtual filesystem. + * + * This function maps a WebDAV collection onto the given URI in the + * REST API of Orthanc. This function must be called during the + * initialization of the plugin, i.e. inside the + * OrthancPluginInitialize() public function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param uri URI where to map the WebDAV collection (must start with a `/` character). + * @param isExistingFolder Callback method to test for the existence of a folder. + * @param listFolder Callback method to list the content of a folder. + * @param retrieveFile Callback method to retrieve the content of a file. + * @param storeFile Callback method to store a file into the WebDAV collection. + * @param createFolder Callback method to create a folder. + * @param deleteItem Callback method to delete a file or a folder. + * @param payload The user payload. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.10.1") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterWebDavCollection( + OrthancPluginContext* context, + const char* uri, + OrthancPluginWebDavIsExistingFolderCallback isExistingFolder, + OrthancPluginWebDavListFolderCallback listFolder, + OrthancPluginWebDavRetrieveFileCallback retrieveFile, + OrthancPluginWebDavStoreFileCallback storeFile, + OrthancPluginWebDavCreateFolderCallback createFolder, + OrthancPluginWebDavDeleteItemCallback deleteItem, + void* payload) + { + _OrthancPluginRegisterWebDavCollection params; + params.uri = uri; + params.isExistingFolder = isExistingFolder; + params.listFolder = listFolder; + params.retrieveFile = retrieveFile; + params.storeFile = storeFile; + params.createFolder = createFolder; + params.deleteItem = deleteItem; + params.payload = payload; + + return context->InvokeService(context, _OrthancPluginService_RegisterWebDavCollection, ¶ms); + } + + + /** + * @brief Gets the DatabaseServerIdentifier. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return the database server identifier. This is a statically-allocated + * string, do not free it. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.11.1") + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetDatabaseServerIdentifier( + OrthancPluginContext* context) + { + const char* result; + + _OrthancPluginRetrieveStaticString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetDatabaseServerIdentifier, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + typedef struct + { + OrthancPluginStorageCreate2 create; + OrthancPluginStorageReadRange2 readRange; + OrthancPluginStorageRemove2 remove; + } _OrthancPluginRegisterStorageArea3; + + /** + * @brief Register a custom storage area, with support for custom data. + * + * This function registers a custom storage area, to replace the + * built-in way Orthanc stores its files on the filesystem. This + * function must be called during the initialization of the plugin, + * i.e. inside the OrthancPluginInitialize() public function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param create The callback function to store a file on the custom storage area. + * @param readRange The callback function to read some range of a file from the custom storage area. + * @param remove The callback function to remove a file from the custom storage area. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterStorageArea3( + OrthancPluginContext* context, + OrthancPluginStorageCreate2 create, + OrthancPluginStorageReadRange2 readRange, + OrthancPluginStorageRemove2 remove) + { + _OrthancPluginRegisterStorageArea3 params; + params.create = create; + params.readRange = readRange; + params.remove = remove; + context->InvokeService(context, _OrthancPluginService_RegisterStorageArea3, ¶ms); + } + + /** + * @brief Signature of a callback function that is triggered when + * the Orthanc core requests an operation from the database plugin. + * Both request and response are encoded as protobuf buffers. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginCallDatabaseBackendV4) ( + OrthancPluginMemoryBuffer64* response, + void* backend, + const void* request, + uint64_t requestSize); + + /** + * @brief Signature of a callback function that is triggered when + * the database plugin must be finalized. + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginFinalizeDatabaseBackendV4) (void* backend); + + typedef struct + { + void* backend; + uint32_t maxDatabaseRetries; + OrthancPluginCallDatabaseBackendV4 operations; + OrthancPluginFinalizeDatabaseBackendV4 finalize; + } _OrthancPluginRegisterDatabaseBackendV4; + + /** + * @brief Register a custom database back-end. + * + * This function was added in Orthanc SDK 1.12.0. It uses Google + * Protocol Buffers for the communications between the Orthanc core + * and database plugins. Check out "OrthancDatabasePlugin.proto" for + * the definition of the protobuf messages. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param backend Pointer to the custom database backend. + * @param maxDatabaseRetries Maximum number of retries if transaction doesn't succeed. + * If no retry is successful, OrthancPluginErrorCode_DatabaseCannotSerialize is generated. + * @param operations Access to the operations of the custom database backend. + * @param finalize Callback to deallocate the custom database backend. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.0") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDatabaseBackendV4( + OrthancPluginContext* context, + void* backend, + uint32_t maxDatabaseRetries, + OrthancPluginCallDatabaseBackendV4 operations, + OrthancPluginFinalizeDatabaseBackendV4 finalize) + { + _OrthancPluginRegisterDatabaseBackendV4 params; + params.backend = backend; + params.maxDatabaseRetries = maxDatabaseRetries; + params.operations = operations; + params.finalize = finalize; + + return context->InvokeService(context, _OrthancPluginService_RegisterDatabaseBackendV4, ¶ms); + } + + + typedef struct + { + OrthancPluginDicomInstance** target; + const char* instanceId; + OrthancPluginLoadDicomInstanceMode mode; + } _OrthancPluginLoadDicomInstance; + + /** + * @brief Load a DICOM instance from the Orthanc server. + * + * This function loads a DICOM instance from the content of the + * Orthanc database. The function returns a new pointer to a data + * structure that is managed by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instanceId The Orthanc identifier of the DICOM instance of interest. + * @param mode Flag specifying how to deal with pixel data. + * @return The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.1") + ORTHANC_PLUGIN_INLINE OrthancPluginDicomInstance* OrthancPluginLoadDicomInstance( + OrthancPluginContext* context, + const char* instanceId, + OrthancPluginLoadDicomInstanceMode mode) + { + OrthancPluginDicomInstance* target = NULL; + + _OrthancPluginLoadDicomInstance params; + params.target = ⌖ + params.instanceId = instanceId; + params.mode = mode; + + if (context->InvokeService(context, _OrthancPluginService_LoadDicomInstance, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + typedef struct + { + const char* name; + int64_t value; + OrthancPluginMetricsType type; + } _OrthancPluginSetMetricsIntegerValue; + + /** + * @brief Set the value of an integer metrics. + * + * This function sets the value of an integer metrics to monitor the + * behavior of the plugin through tools such as Prometheus. The + * values of all the metrics are stored within the Orthanc context. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param name The name of the metrics to be set. + * @param value The value of the metrics. + * @param type The type of the metrics. This parameter is only taken into consideration + * the first time this metrics is set. + * @ingroup Toolbox + * @see OrthancPluginSetMetricsValue() + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.1") + ORTHANC_PLUGIN_INLINE void OrthancPluginSetMetricsIntegerValue( + OrthancPluginContext* context, + const char* name, + int64_t value, + OrthancPluginMetricsType type) + { + _OrthancPluginSetMetricsIntegerValue params; + params.name = name; + params.value = value; + params.type = type; + context->InvokeService(context, _OrthancPluginService_SetMetricsIntegerValue, ¶ms); + } + + + /** + * @brief Set the name of the current thread. + * + * This function gives a name to the thread that is calling this + * function. This name is used in the Orthanc logs. This function + * must only be called from threads that the plugin has created + * itself. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param threadName The name of the current thread. A thread name cannot be longer than 16 characters. + * @return 0 if success, other value if error. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.2") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSetCurrentThreadName( + OrthancPluginContext* context, + const char* threadName) + { + return context->InvokeService(context, _OrthancPluginService_SetCurrentThreadName, threadName); + } + + + typedef struct + { + /* Note: This structure is also defined in Logging.h and it must be binary compatible */ + const char* message; + const char* plugin; + const char* file; + uint32_t line; + OrthancPluginLogCategory category; + OrthancPluginLogLevel level; + } _OrthancPluginLogMessage; + + + /** + * @brief Log a message. + * + * Log a message using the Orthanc logging system. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param message The message to be logged. + * @param plugin The plugin name. + * @param file The filename in the plugin code. + * @param line The file line in the plugin code. + * @param category The category. + * @param level The level of the message. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.4") + ORTHANC_PLUGIN_INLINE void OrthancPluginLogMessage( + OrthancPluginContext* context, + const char* message, + const char* plugin, + const char* file, + uint32_t line, + OrthancPluginLogCategory category, + OrthancPluginLogLevel level) + { + _OrthancPluginLogMessage m; + m.message = message; + m.plugin = plugin; + m.file = file; + m.line = line; + m.category = category; + m.level = level; + context->InvokeService(context, _OrthancPluginService_LogMessage, &m); + } + + + typedef struct + { + OrthancPluginRestOutput* output; + const char* contentType; + } _OrthancPluginStartStreamAnswer; + + /** + * @brief Start an HTTP stream answer. + * + * Initiates an HTTP stream answer, as the result of a REST request. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param contentType The MIME type of the items in the stream answer. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginSendStreamChunk() + * @ingroup REST + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.6") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStartStreamAnswer( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* contentType) + { + _OrthancPluginStartStreamAnswer params; + params.output = output; + params.contentType = contentType; + return context->InvokeService(context, _OrthancPluginService_StartStreamAnswer, ¶ms); + } + + + /** + * @brief Send a chunk as a part of an HTTP stream answer. + * + * This function sends a chunk as part of an HTTP stream + * answer that was initiated by OrthancPluginStartStreamAnswer(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param answer Pointer to the memory buffer containing the item. + * @param answerSize Number of bytes of the item. + * @return 0 if success, or the error code if failure (this notably happens + * if the connection is closed by the client). + * @see OrthancPluginStartStreamAnswer() + * @ingroup REST + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.6") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSendStreamChunk( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const void* answer, + uint32_t answerSize) + { + _OrthancPluginAnswerBuffer params; + params.output = output; + params.answer = answer; + params.answerSize = answerSize; + params.mimeType = NULL; + return context->InvokeService(context, _OrthancPluginService_SendStreamChunk, ¶ms); + } + + + typedef struct + { + OrthancPluginMemoryBuffer* instanceId; + OrthancPluginMemoryBuffer* attachmentUuid; + OrthancPluginStoreStatus* storeStatus; + const void* dicom; + uint64_t dicomSize; + const void* customData; + uint32_t customDataSize; + } _OrthancPluginAdoptDicomInstance; + + /** + * @brief Adopt a DICOM instance read from the filesystem. + * + * This function requests Orthanc to create a DICOM resource at the + * "Instance" level in its database, using the content of a DICOM + * instance read from the filesystem. The newly created DICOM + * resource is associated with an attachment whose content type is + * "OrthancPluginContentType_Dicom". The attachment is associated + * with the provided custom data. + * + * This function should only be used in combination with a custom + * storage area featuring support for custom data (i.e., installed + * using OrthancPluginRegisterStorageArea3()). The custom storage + * area is responsible for *not* duplicating the DICOM file into the + * storage area of Orthanc, hence the name "Adopt". The support for + * custom data is necessary for the custom storage area to + * distinguish between adopted and non-adopted DICOM instances. + * + * Check out the "AdoptDicomInstance" plugin in the source + * distribution of Orthanc for a working sample: + * https://orthanc.uclouvain.be/hg/orthanc/file/default/OrthancServer/Plugins/Samples/AdoptDicomInstance/ + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instanceId The target memory buffer that will be filled by + * the Orthanc core with the public identifier of the newly created + * instance. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param attachmentUuid The target memory buffer that will be + * filled by the Orthanc core with the UUID of the newly created + * attachment corresponding to the adopted DICOM instance. It must + * be freed with OrthancPluginFreeMemoryBuffer(). + * @param storeStatus Variable that will be filled by the Orthanc core + * with the status of store operation. + * @param dicom Pointer to the DICOM instance read from the filesystem. + * @param dicomSize Size of the DICOM instance. + * @param customData The custom data to associated with the attachment. + * @param customDataSize The size of the custom data. + * @return 0 if success, other value if error. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginAdoptDicomInstance( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* instanceId, /* out */ + OrthancPluginMemoryBuffer* attachmentUuid, /* out */ + OrthancPluginStoreStatus* storeStatus, /* out */ + const void* dicom, + uint64_t dicomSize, + const void* customData, + uint32_t customDataSize) + { + _OrthancPluginAdoptDicomInstance params; + params.instanceId = instanceId; + params.attachmentUuid = attachmentUuid; + params.storeStatus = storeStatus; + params.dicom = dicom; + params.dicomSize = dicomSize; + params.customData = customData; + params.customDataSize = customDataSize; + + return context->InvokeService(context, _OrthancPluginService_AdoptDicomInstance, ¶ms); + } + + + typedef struct + { + OrthancPluginMemoryBuffer* customData; + const char* attachmentUuid; + } _OrthancPluginGetAttachmentCustomData; + + /** + * @brief Retrieve the custom data associated with an attachment in the Orthanc database. + * + * If no custom data is associated with the attachment of interest, + * the target memory buffer is filled with the NULL value and a zero size. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param customData Memory buffer where to store the retrieved value. It must be freed + * by the plugin by calling OrthancPluginFreeMemoryBuffer(). + * @param attachmentUuid The UUID of the attachment of interest. + * @return 0 if success, other value if error. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetAttachmentCustomData( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* customData, /* out */ + const char* attachmentUuid /* in */) + { + _OrthancPluginGetAttachmentCustomData params; + params.customData = customData; + params.attachmentUuid = attachmentUuid; + + return context->InvokeService(context, _OrthancPluginService_GetAttachmentCustomData, ¶ms); + } + + + typedef struct + { + const char* attachmentUuid; + const void* customData; + uint32_t customDataSize; + } _OrthancPluginSetAttachmentCustomData; + + /** + * @brief Update the custom data associated with an attachment in the Orthanc database. + * + * This function is notably used in the "orthanc-advanced-storage" + * when the plugin moves an attachment. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param attachmentUuid The UUID of the attachment of interest. + * @param customData The value to store. + * @param customDataSize The size of the value to store. + * @return 0 if success, other value if error. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSetAttachmentCustomData( + OrthancPluginContext* context, + const char* attachmentUuid, /* in */ + const void* customData, /* in */ + uint32_t customDataSize /* in */) + { + _OrthancPluginSetAttachmentCustomData params; + params.attachmentUuid = attachmentUuid; + params.customData = customData; + params.customDataSize = customDataSize; + + return context->InvokeService(context, _OrthancPluginService_SetAttachmentCustomData, ¶ms); + } + + + typedef struct + { + const char* storeId; + const char* key; + const void* value; + uint32_t valueSize; + } _OrthancPluginStoreKeyValue; + + /** + * @brief Store a key-value pair in the Orthanc database. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param storeId A unique identifier identifying both the plugin and the key-value store. + * @param key The key of the value to store (note: storeId + key must be unique). + * @param value The value to store. + * @param valueSize The length of the value to store. + * @return 0 if success, other value if error. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStoreKeyValue( + OrthancPluginContext* context, + const char* storeId, /* in */ + const char* key, /* in */ + const void* value, /* in */ + uint32_t valueSize /* in */) + { + _OrthancPluginStoreKeyValue params; + params.storeId = storeId; + params.key = key; + params.value = value; + params.valueSize = valueSize; + + return context->InvokeService(context, _OrthancPluginService_StoreKeyValue, ¶ms); + } + + + typedef struct + { + const char* storeId; + const char* key; + } _OrthancPluginDeleteKeyValue; + + /** + * @brief Delete a key-value pair from the Orthanc database. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param storeId A unique identifier identifying both the plugin and the key-value store. + * @param key The key of the value to store (note: storeId + key must be unique). + * @return 0 if success, other value if error. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginDeleteKeyValue( + OrthancPluginContext* context, + const char* storeId, /* in */ + const char* key /* in */) + { + _OrthancPluginDeleteKeyValue params; + params.storeId = storeId; + params.key = key; + + return context->InvokeService(context, _OrthancPluginService_DeleteKeyValue, ¶ms); + } + + + typedef struct + { + uint8_t* found; + OrthancPluginMemoryBuffer* target; + const char* storeId; + const char* key; + } _OrthancPluginGetKeyValue; + + /** + * @brief Get the value associated with a key in the Orthanc key-value store. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param found Pointer to a Boolean that is set to "true" iff. the key exists in the key-value store. + * @param target Memory buffer where to store the retrieved value. It must be freed + * by the plugin by calling OrthancPluginFreeMemoryBuffer(). + * @param storeId A unique identifier identifying both the plugin and the key-value store. + * @param key The key of the value to retrieve from the store (note: storeId + key must be unique). + * @return 0 if success, other value if error. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetKeyValue( + OrthancPluginContext* context, + uint8_t* found, /* out */ + OrthancPluginMemoryBuffer* target, /* out */ + const char* storeId, /* in */ + const char* key /* in */) + { + _OrthancPluginGetKeyValue params; + params.found = found; + params.target = target; + params.storeId = storeId; + params.key = key; + + return context->InvokeService(context, _OrthancPluginService_GetKeyValue, ¶ms); + } + + + /** + * @brief Opaque structure that represents an iterator over the keys and values of + * a key-value store. + * @ingroup Callbacks + **/ + typedef struct ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + _OrthancPluginKeysValuesIterator_t OrthancPluginKeysValuesIterator; + + + typedef struct + { + OrthancPluginKeysValuesIterator** target; + const char* storeId; + } _OrthancPluginCreateKeysValuesIterator; + + + /** + * @brief Create an iterator over the key-value pairs of a key-value store in the Orthanc database. + * + * The iterator loops over the keys according to the lexicographical order. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param storeId A unique identifier identifying both the plugin and the key-value store. + * @return The newly allocated iterator, or NULL in the case of an error. + * The iterator must be freed by calling OrthancPluginFreeKeysValuesIterator(). + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + ORTHANC_PLUGIN_INLINE OrthancPluginKeysValuesIterator* OrthancPluginCreateKeysValuesIterator( + OrthancPluginContext* context, + const char* storeId) + { + OrthancPluginKeysValuesIterator* target = NULL; + + _OrthancPluginCreateKeysValuesIterator params; + params.target = ⌖ + params.storeId = storeId; + + if (context->InvokeService(context, _OrthancPluginService_CreateKeysValuesIterator, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + typedef struct + { + OrthancPluginKeysValuesIterator* iterator; + } _OrthancPluginFreeKeysValuesIterator; + + /** + * @brief Free an iterator over a key-value store. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param iterator The iterator of interest. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeKeysValuesIterator( + OrthancPluginContext* context, + OrthancPluginKeysValuesIterator* iterator) + { + _OrthancPluginFreeKeysValuesIterator params; + params.iterator = iterator; + + context->InvokeService(context, _OrthancPluginService_FreeKeysValuesIterator, ¶ms); + } + + + typedef struct + { + uint8_t* done; + OrthancPluginKeysValuesIterator* iterator; + } _OrthancPluginKeysValuesIteratorNext; + + /** + * @brief Read the next element of an iterator over a key-value store. + * + * The iterator loops over the keys according to the lexicographical order. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param done Pointer to a Boolean that is set to "true" iff. the iterator has reached the end of the store. + * @param iterator The iterator of interest. + * @return 0 if success, other value if error. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginKeysValuesIteratorNext( + OrthancPluginContext* context, + uint8_t* done, /* out */ + OrthancPluginKeysValuesIterator* iterator /* in */) + { + _OrthancPluginKeysValuesIteratorNext params; + params.done = done; + params.iterator = iterator; + + return context->InvokeService(context, _OrthancPluginService_KeysValuesIteratorNext, ¶ms); + } + + + typedef struct + { + const char** target; + OrthancPluginKeysValuesIterator* iterator; + } _OrthancPluginKeysValuesIteratorGetKey; + + /** + * @brief Get the current key of an iterator over a key-value store. + * + * Before using this function, the function OrthancPluginKeysValuesIteratorNext() + * must have been called at least once. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param iterator The iterator of interest. + * @return The current key, or NULL in the case of an error. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + ORTHANC_PLUGIN_INLINE const char* OrthancPluginKeysValuesIteratorGetKey( + OrthancPluginContext* context, + OrthancPluginKeysValuesIterator* iterator) + { + const char* target = NULL; + + _OrthancPluginKeysValuesIteratorGetKey params; + params.target = ⌖ + params.iterator = iterator; + + if (context->InvokeService(context, _OrthancPluginService_KeysValuesIteratorGetKey, ¶ms) == OrthancPluginErrorCode_Success) + { + return target; + } + else + { + return NULL; + } + } + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + OrthancPluginKeysValuesIterator* iterator; + } _OrthancPluginKeysValuesIteratorGetValue; + + /** + * @brief Get the current value of an iterator over a key-value store. + * + * Before using this function, the function OrthancPluginKeysValuesIteratorNext() + * must have been called at least once. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target Memory buffer where to store the value that has been retrieved from the key-value store. + * It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param iterator The iterator of interest. + * @return The current value, or NULL in the case of an error. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginKeysValuesIteratorGetValue( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target /* out */, + OrthancPluginKeysValuesIterator* iterator /* in */) + { + _OrthancPluginKeysValuesIteratorGetValue params; + params.target = target; + params.iterator = iterator; + + return context->InvokeService(context, _OrthancPluginService_KeysValuesIteratorGetValue, ¶ms); + } + + + typedef struct + { + const char* queueId; + const void* value; + uint32_t valueSize; + } _OrthancPluginEnqueueValue; + + /** + * @brief Append a value to the back of a queue. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param queueId A unique identifier identifying both the plugin and the queue. + * @param value The value to store. + * @param valueSize The size of the value to store. + * @return 0 if success, other value if error. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginEnqueueValue( + OrthancPluginContext* context, + const char* queueId, /* in */ + const void* value, /* in */ + uint32_t valueSize /* in */) + { + _OrthancPluginEnqueueValue params; + params.queueId = queueId; + params.value = value; + params.valueSize = valueSize; + + return context->InvokeService(context, _OrthancPluginService_EnqueueValue, ¶ms); + } + + + typedef struct + { + uint8_t* found; + OrthancPluginMemoryBuffer* target; + const char* queueId; + OrthancPluginQueueOrigin origin; + } _OrthancPluginDequeueValue; + + /** + * @brief Dequeue a value from a queue. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param found Pointer to a Boolean that is set to "true" iff. a value has been dequeued. + * @param target Memory buffer where to store the value that has been retrieved from the queue. + * It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param queueId A unique identifier identifying both the plugin and the queue. + * @param origin The position from where the value is dequeued (back for LIFO, front for FIFO). + * @return 0 if success, other value if error. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginDequeueValue( + OrthancPluginContext* context, + uint8_t* found, /* out */ + OrthancPluginMemoryBuffer* target, /* out */ + const char* queueId, /* in */ + OrthancPluginQueueOrigin origin /* in */) + { + _OrthancPluginDequeueValue params; + params.found = found; + params.target = target; + params.queueId = queueId; + params.origin = origin; + + return context->InvokeService(context, _OrthancPluginService_DequeueValue, ¶ms); + } + + + typedef struct + { + const char* queueId; + uint64_t* size; + } _OrthancPluginGetQueueSize; + + /** + * @brief Get the number of elements in a queue. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param queueId A unique identifier identifying both the plugin and the queue. + * @param size The number of elements in the queue. + * @return 0 if success, other value if error. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.8") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetQueueSize( + OrthancPluginContext* context, + const char* queueId, /* in */ + uint64_t* size /* out */) + { + _OrthancPluginGetQueueSize params; + params.queueId = queueId; + params.size = size; + + return context->InvokeService(context, _OrthancPluginService_GetQueueSize, ¶ms); + } + + + typedef struct + { + const char* resourceId; + OrthancPluginStableStatus stableStatus; + uint8_t* statusHasChanged; + } _OrthancPluginSetStableStatus; + + /** + * @brief Change the "Stable" status of a resource. + * + * Forcing a resource to "Stable" if it is currently "Unstable" will + * change its "Stable" status AND trigger a new "Stable" change, + * which will also trigger listener callbacks. + * + * Forcing a resource to "Stable" if it is already "Stable" has no + * effect (no-op). + * + * Forcing a resource to "Unstable" will change its "Stable" status + * to "Unstable" AND reset its stabilization period, no matter its + * initial state. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param statusHasChanged Whether the status has changed (1) or not (0) during the execution of this command. + * @param resourceId The Orthanc identifier of the DICOM resource of interest. + * @param stableStatus The new stable status of the resource of interest. + * @return 0 if success, other value if error. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.9") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSetStableStatus( + OrthancPluginContext* context, + uint8_t* statusHasChanged, /* out */ + const char* resourceId, /* in */ + OrthancPluginStableStatus stableStatus /* in */) + { + _OrthancPluginSetStableStatus params; + params.resourceId = resourceId; + params.stableStatus= stableStatus; + params.statusHasChanged = statusHasChanged; + + return context->InvokeService(context, _OrthancPluginService_SetStableStatus, ¶ms); + } + + + /** + * @brief Callback to authenticate a HTTP request. + * + * Signature of a callback function that authenticates every incoming HTTP request. + * + * @param status The output status of the authentication. + * @param customPayload If status is `OrthancPluginHttpAuthenticationStatus_Granted`, + * a custom payload that will be provided to the HTTP handler callback. + * @param redirection If status is `OrthancPluginHttpAuthenticationStatus_Redirect`, + * a buffer filled with the path where to redirect the user (typically, a login page). + * The path is relative to the root of the Web server of Orthanc. + * @param uri The URI of interest (without the possible GET arguments). + * @param ip The IP address of the HTTP client. + * @param headersCount The number of HTTP headers. + * @param headersKeys The keys of the HTTP headers (always converted to low-case). + * @param headersValues The values of the HTTP headers. + * @param getCount For a GET request, the number of GET parameters. + * @param getKeys For a GET request, the keys of the GET parameters. + * @param getValues For a GET request, the values of the GET parameters. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginHttpAuthentication) ( + OrthancPluginHttpAuthenticationStatus* status, /* out */ + OrthancPluginMemoryBuffer* customPayload, /* out */ + OrthancPluginMemoryBuffer* redirection, /* out */ + const char* uri, + const char* ip, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues, + uint32_t getCount, + const char* const* getKeys, + const char* const* getValues); + + + typedef struct + { + OrthancPluginHttpAuthentication callback; + } _OrthancPluginHttpAuthentication; + + /** + * @brief Register a callback to handle HTTP authentication (and + * possibly HTTP authorization). + * + * This function installs a callback that is executed for each + * incoming HTTP request to handle HTTP authentication. At most one + * plugin can register such a callback. This gives the opportunity + * to the plugin to validate access tokens (such as a JWT), possibly + * redirecting the user to a login page. The authentication callback + * can generate a custom payload that will be provided to the + * subsequent REST handling callback (cf. `authenticationPayload` in + * `OrthancPluginHttpRequest`). + * + * If one plugin installs a HTTP authentication callback, the + * built-in HTTP authentication of Orthanc is disabled. This means + * that the "RegisteredUsers" and "AuthenticationEnabled" + * configuration options of Orthanc are totally ignored. In + * addition, tokens generated by + * OrthancPluginGenerateRestApiAuthorizationToken() become + * ineffective. + * + * This HTTP authentication callback can notably be used if some + * resource in the REST API must be available for public access, if + * the "RemoteAccessAllowed" configuration option is set to "true" + * (which necessitates bypassing the built-in HTTP authentication of + * Orthanc). + * + * In addition, the callback can handle HTTP authorization + * simultaneously with HTTP authentication, by reporting the + * "OrthancPluginHttpAuthenticationStatus_Forbidden" status. This + * corresponds to the behavior of callbacks installed using + * OrthancPluginRegisterIncomingHttpRequestFilter2(), but the latter + * callbacks do not provide access to the authentication payload. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The HTTP authentication callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.9") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterHttpAuthentication( + OrthancPluginContext* context, + OrthancPluginHttpAuthentication callback) + { + _OrthancPluginHttpAuthentication params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterHttpAuthentication, ¶ms); + } + + + typedef struct + { + const char* sourcePlugin; + const char* userId; + OrthancPluginResourceType resourceType; + const char* resourceId; + const char* action; + const void* logData; + uint32_t logDataSize; + } _OrthancPluginEmitAuditLog; + + + /** + * @brief Generate an audit log to signal security-related events. + * + * Generate an audit log that will be broadcasted to all the plugins + * that have registered a callback handler using + * OrthancPluginRegisterAuditLogHandler(). If no plugin has + * registered such a callback, the audit log is ignored. + * + * A typical handler would record the audit log in a database and/or + * relay the audit log to a message broker. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param sourcePlugin The name of the source plugin, to properly interpret the + * content of "action" and "logData". + * @param userId A string that uniquely identifies the user or + * entity that is executing the action on the resource. + * @param resourceType The type of the resource this audit log relates to. + * @param resourceId The resource this audit log relates to. + * @param action The action that was performed on the resource. + * @param logData A pointer to custom log data. + * @param logDataSize The size of the custom log data. + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.9") + ORTHANC_PLUGIN_INLINE void OrthancPluginEmitAuditLog( + OrthancPluginContext* context, + const char* sourcePlugin, + const char* userId, + OrthancPluginResourceType resourceType, + const char* resourceId, + const char* action, + const void* logData, + uint32_t logDataSize) + { + _OrthancPluginEmitAuditLog m; + m.sourcePlugin = sourcePlugin; + m.userId = userId; + m.resourceType = resourceType; + m.resourceId = resourceId; + m.action = action; + m.logData = logData; + m.logDataSize = logDataSize; + context->InvokeService(context, _OrthancPluginService_EmitAuditLog, &m); + } + + + /** + * @brief Callback to handle an audit log. + * + * Signature of a callback function that handles an audit log + * emitted by a source plugin. + * + * @param sourcePlugin The name of the source plugin. This information can + * be used to properly interpret the content of the "action" and + * "logData" arguments. + * @param userId A string uniquely identifying the user or entity that is executing the action on the resource. + * @param resourceType The type of the resource this log relates to. + * @param resourceId The resource this log relates to. + * @param action The action that is performed on the resource. + * @param logData A pointer to custom log data. + * @param logDataSize The size of the custom log data. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginAuditLogHandler) ( + const char* sourcePlugin, + const char* userId, + OrthancPluginResourceType resourceType, + const char* resourceId, + const char* action, + const void* logData, + uint32_t logDataSize); + + typedef struct + { + OrthancPluginAuditLogHandler handler; + } _OrthancPluginAuditLogHandler; + + /** + * @brief Register a callback to handle audit logs. + * + * This function installs a callback to listen to each audit log + * that is generated by some other plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param handler The audit log handler. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_SINCE_SDK("1.12.9") + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterAuditLogHandler( + OrthancPluginContext* context, + OrthancPluginAuditLogHandler handler) + { + _OrthancPluginAuditLogHandler params; + params.handler = handler; + + return context->InvokeService(context, _OrthancPluginService_RegisterAuditLogHandler, ¶ms); + } + + +#ifdef __cplusplus +} +#endif + + +/** @} */ diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/Orthanc/Sdk-1.7.2/orthanc/OrthancCPlugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Orthanc/Sdk-1.7.2/orthanc/OrthancCPlugin.h Wed Aug 13 12:02:04 2025 +0200 @@ -0,0 +1,8181 @@ +/** + * \mainpage + * + * This C/C++ SDK allows external developers to create plugins that + * can be loaded into Orthanc to extend its functionality. Each + * Orthanc plugin must expose 4 public functions with the following + * signatures: + * + * -# int32_t OrthancPluginInitialize(const OrthancPluginContext* context): + * This function is invoked by Orthanc when it loads the plugin on startup. + * The plugin must: + * - Check its compatibility with the Orthanc version using + * ::OrthancPluginCheckVersion(). + * - Store the context pointer so that it can use the plugin + * services of Orthanc. + * - Register all its REST callbacks using ::OrthancPluginRegisterRestCallback(). + * - Possibly register its callback for received DICOM instances using ::OrthancPluginRegisterOnStoredInstanceCallback(). + * - Possibly register its callback for changes to the DICOM store using ::OrthancPluginRegisterOnChangeCallback(). + * - Possibly register a custom storage area using ::OrthancPluginRegisterStorageArea(). + * - Possibly register a custom database back-end area using OrthancPluginRegisterDatabaseBackendV2(). + * - Possibly register a handler for C-Find SCP using OrthancPluginRegisterFindCallback(). + * - Possibly register a handler for C-Find SCP against DICOM worklists using OrthancPluginRegisterWorklistCallback(). + * - Possibly register a handler for C-Move SCP using OrthancPluginRegisterMoveCallback(). + * - Possibly register a custom decoder for DICOM images using OrthancPluginRegisterDecodeImageCallback(). + * - Possibly register a callback to filter incoming HTTP requests using OrthancPluginRegisterIncomingHttpRequestFilter2(). + * - Possibly register a callback to unserialize jobs using OrthancPluginRegisterJobsUnserializer(). + * - Possibly register a callback to refresh its metrics using OrthancPluginRegisterRefreshMetricsCallback(). + * - Possibly register a callback to answer chunked HTTP transfers using ::OrthancPluginRegisterChunkedRestCallback(). + * - Possibly register a callback for Storage Commitment SCP using ::OrthancPluginRegisterStorageCommitmentScpCallback(). + * - Possibly register a callback to filter incoming DICOM instance using OrthancPluginRegisterIncomingDicomInstanceFilter(). + * - Possibly register a custom transcoder for DICOM images using OrthancPluginRegisterTranscoderCallback(). + * -# void OrthancPluginFinalize(): + * This function is invoked by Orthanc during its shutdown. The plugin + * must free all its memory. + * -# const char* OrthancPluginGetName(): + * The plugin must return a short string to identify itself. + * -# const char* OrthancPluginGetVersion(): + * The plugin must return a string containing its version number. + * + * The name and the version of a plugin is only used to prevent it + * from being loaded twice. Note that, in C++, it is mandatory to + * declare these functions within an extern "C" section. + * + * To ensure multi-threading safety, the various REST callbacks are + * guaranteed to be executed in mutual exclusion since Orthanc + * 0.8.5. If this feature is undesired (notably when developing + * high-performance plugins handling simultaneous requests), use + * ::OrthancPluginRegisterRestCallbackNoLock(). + **/ + + + +/** + * @defgroup Images Images and compression + * @brief Functions to deal with images and compressed buffers. + * + * @defgroup REST REST + * @brief Functions to answer REST requests in a callback. + * + * @defgroup Callbacks Callbacks + * @brief Functions to register and manage callbacks by the plugins. + * + * @defgroup DicomCallbacks DicomCallbacks + * @brief Functions to register and manage DICOM callbacks (worklists, C-FIND, C-MOVE, storage commitment). + * + * @defgroup Orthanc Orthanc + * @brief Functions to access the content of the Orthanc server. + * + * @defgroup DicomInstance DicomInstance + * @brief Functions to access DICOM images that are managed by the Orthanc core. + **/ + + + +/** + * @defgroup Toolbox Toolbox + * @brief Generic functions to help with the creation of plugins. + **/ + + + +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2020 Osimis S.A., Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + + +#pragma once + + +#include +#include + +#ifdef WIN32 +# define ORTHANC_PLUGINS_API __declspec(dllexport) +#elif __GNUC__ >= 4 +# define ORTHANC_PLUGINS_API __attribute__ ((visibility ("default"))) +#else +# define ORTHANC_PLUGINS_API +#endif + +#define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 1 +#define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 7 +#define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 2 + + +#if !defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) +#define ORTHANC_PLUGINS_VERSION_IS_ABOVE(major, minor, revision) \ + (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER > major || \ + (ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER == major && \ + (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER > minor || \ + (ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER == minor && \ + ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER >= revision)))) +#endif + + + +/******************************************************************** + ** Check that function inlining is properly supported. The use of + ** inlining is required, to avoid the duplication of object code + ** between two compilation modules that would use the Orthanc Plugin + ** API. + ********************************************************************/ + +/* If the auto-detection of the "inline" keyword below does not work + automatically and that your compiler is known to properly support + inlining, uncomment the following #define and adapt the definition + of "static inline". */ + +/* #define ORTHANC_PLUGIN_INLINE static inline */ + +#ifndef ORTHANC_PLUGIN_INLINE +# if __STDC_VERSION__ >= 199901L +/* This is C99 or above: http://predef.sourceforge.net/prestd.html */ +# define ORTHANC_PLUGIN_INLINE static inline +# elif defined(__cplusplus) +/* This is C++ */ +# define ORTHANC_PLUGIN_INLINE static inline +# elif defined(__GNUC__) +/* This is GCC running in C89 mode */ +# define ORTHANC_PLUGIN_INLINE static __inline +# elif defined(_MSC_VER) +/* This is Visual Studio running in C89 mode */ +# define ORTHANC_PLUGIN_INLINE static __inline +# else +# error Your compiler is not known to support the "inline" keyword +# endif +#endif + + + +/******************************************************************** + ** Inclusion of standard libraries. + ********************************************************************/ + +/** + * For Microsoft Visual Studio, a compatibility "stdint.h" can be + * downloaded at the following URL: + * https://hg.orthanc-server.com/orthanc/raw-file/tip/Resources/ThirdParty/VisualStudio/stdint.h + **/ +#include + +#include + + + +/******************************************************************** + ** Definition of the Orthanc Plugin API. + ********************************************************************/ + +/** @{ */ + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * The various error codes that can be returned by the Orthanc core. + **/ + typedef enum + { + OrthancPluginErrorCode_InternalError = -1 /*!< Internal error */, + OrthancPluginErrorCode_Success = 0 /*!< Success */, + OrthancPluginErrorCode_Plugin = 1 /*!< Error encountered within the plugin engine */, + OrthancPluginErrorCode_NotImplemented = 2 /*!< Not implemented yet */, + OrthancPluginErrorCode_ParameterOutOfRange = 3 /*!< Parameter out of range */, + OrthancPluginErrorCode_NotEnoughMemory = 4 /*!< The server hosting Orthanc is running out of memory */, + OrthancPluginErrorCode_BadParameterType = 5 /*!< Bad type for a parameter */, + OrthancPluginErrorCode_BadSequenceOfCalls = 6 /*!< Bad sequence of calls */, + OrthancPluginErrorCode_InexistentItem = 7 /*!< Accessing an inexistent item */, + OrthancPluginErrorCode_BadRequest = 8 /*!< Bad request */, + OrthancPluginErrorCode_NetworkProtocol = 9 /*!< Error in the network protocol */, + OrthancPluginErrorCode_SystemCommand = 10 /*!< Error while calling a system command */, + OrthancPluginErrorCode_Database = 11 /*!< Error with the database engine */, + OrthancPluginErrorCode_UriSyntax = 12 /*!< Badly formatted URI */, + OrthancPluginErrorCode_InexistentFile = 13 /*!< Inexistent file */, + OrthancPluginErrorCode_CannotWriteFile = 14 /*!< Cannot write to file */, + OrthancPluginErrorCode_BadFileFormat = 15 /*!< Bad file format */, + OrthancPluginErrorCode_Timeout = 16 /*!< Timeout */, + OrthancPluginErrorCode_UnknownResource = 17 /*!< Unknown resource */, + OrthancPluginErrorCode_IncompatibleDatabaseVersion = 18 /*!< Incompatible version of the database */, + OrthancPluginErrorCode_FullStorage = 19 /*!< The file storage is full */, + OrthancPluginErrorCode_CorruptedFile = 20 /*!< Corrupted file (e.g. inconsistent MD5 hash) */, + OrthancPluginErrorCode_InexistentTag = 21 /*!< Inexistent tag */, + OrthancPluginErrorCode_ReadOnly = 22 /*!< Cannot modify a read-only data structure */, + OrthancPluginErrorCode_IncompatibleImageFormat = 23 /*!< Incompatible format of the images */, + OrthancPluginErrorCode_IncompatibleImageSize = 24 /*!< Incompatible size of the images */, + OrthancPluginErrorCode_SharedLibrary = 25 /*!< Error while using a shared library (plugin) */, + OrthancPluginErrorCode_UnknownPluginService = 26 /*!< Plugin invoking an unknown service */, + OrthancPluginErrorCode_UnknownDicomTag = 27 /*!< Unknown DICOM tag */, + OrthancPluginErrorCode_BadJson = 28 /*!< Cannot parse a JSON document */, + OrthancPluginErrorCode_Unauthorized = 29 /*!< Bad credentials were provided to an HTTP request */, + OrthancPluginErrorCode_BadFont = 30 /*!< Badly formatted font file */, + OrthancPluginErrorCode_DatabasePlugin = 31 /*!< The plugin implementing a custom database back-end does not fulfill the proper interface */, + OrthancPluginErrorCode_StorageAreaPlugin = 32 /*!< Error in the plugin implementing a custom storage area */, + OrthancPluginErrorCode_EmptyRequest = 33 /*!< The request is empty */, + OrthancPluginErrorCode_NotAcceptable = 34 /*!< Cannot send a response which is acceptable according to the Accept HTTP header */, + OrthancPluginErrorCode_NullPointer = 35 /*!< Cannot handle a NULL pointer */, + OrthancPluginErrorCode_DatabaseUnavailable = 36 /*!< The database is currently not available (probably a transient situation) */, + OrthancPluginErrorCode_CanceledJob = 37 /*!< This job was canceled */, + OrthancPluginErrorCode_BadGeometry = 38 /*!< Geometry error encountered in Stone */, + OrthancPluginErrorCode_SslInitialization = 39 /*!< Cannot initialize SSL encryption, check out your certificates */, + OrthancPluginErrorCode_SQLiteNotOpened = 1000 /*!< SQLite: The database is not opened */, + OrthancPluginErrorCode_SQLiteAlreadyOpened = 1001 /*!< SQLite: Connection is already open */, + OrthancPluginErrorCode_SQLiteCannotOpen = 1002 /*!< SQLite: Unable to open the database */, + OrthancPluginErrorCode_SQLiteStatementAlreadyUsed = 1003 /*!< SQLite: This cached statement is already being referred to */, + OrthancPluginErrorCode_SQLiteExecute = 1004 /*!< SQLite: Cannot execute a command */, + OrthancPluginErrorCode_SQLiteRollbackWithoutTransaction = 1005 /*!< SQLite: Rolling back a nonexistent transaction (have you called Begin()?) */, + OrthancPluginErrorCode_SQLiteCommitWithoutTransaction = 1006 /*!< SQLite: Committing a nonexistent transaction */, + OrthancPluginErrorCode_SQLiteRegisterFunction = 1007 /*!< SQLite: Unable to register a function */, + OrthancPluginErrorCode_SQLiteFlush = 1008 /*!< SQLite: Unable to flush the database */, + OrthancPluginErrorCode_SQLiteCannotRun = 1009 /*!< SQLite: Cannot run a cached statement */, + OrthancPluginErrorCode_SQLiteCannotStep = 1010 /*!< SQLite: Cannot step over a cached statement */, + OrthancPluginErrorCode_SQLiteBindOutOfRange = 1011 /*!< SQLite: Bing a value while out of range (serious error) */, + OrthancPluginErrorCode_SQLitePrepareStatement = 1012 /*!< SQLite: Cannot prepare a cached statement */, + OrthancPluginErrorCode_SQLiteTransactionAlreadyStarted = 1013 /*!< SQLite: Beginning the same transaction twice */, + OrthancPluginErrorCode_SQLiteTransactionCommit = 1014 /*!< SQLite: Failure when committing the transaction */, + OrthancPluginErrorCode_SQLiteTransactionBegin = 1015 /*!< SQLite: Cannot start a transaction */, + OrthancPluginErrorCode_DirectoryOverFile = 2000 /*!< The directory to be created is already occupied by a regular file */, + OrthancPluginErrorCode_FileStorageCannotWrite = 2001 /*!< Unable to create a subdirectory or a file in the file storage */, + OrthancPluginErrorCode_DirectoryExpected = 2002 /*!< The specified path does not point to a directory */, + OrthancPluginErrorCode_HttpPortInUse = 2003 /*!< The TCP port of the HTTP server is privileged or already in use */, + OrthancPluginErrorCode_DicomPortInUse = 2004 /*!< The TCP port of the DICOM server is privileged or already in use */, + OrthancPluginErrorCode_BadHttpStatusInRest = 2005 /*!< This HTTP status is not allowed in a REST API */, + OrthancPluginErrorCode_RegularFileExpected = 2006 /*!< The specified path does not point to a regular file */, + OrthancPluginErrorCode_PathToExecutable = 2007 /*!< Unable to get the path to the executable */, + OrthancPluginErrorCode_MakeDirectory = 2008 /*!< Cannot create a directory */, + OrthancPluginErrorCode_BadApplicationEntityTitle = 2009 /*!< An application entity title (AET) cannot be empty or be longer than 16 characters */, + OrthancPluginErrorCode_NoCFindHandler = 2010 /*!< No request handler factory for DICOM C-FIND SCP */, + OrthancPluginErrorCode_NoCMoveHandler = 2011 /*!< No request handler factory for DICOM C-MOVE SCP */, + OrthancPluginErrorCode_NoCStoreHandler = 2012 /*!< No request handler factory for DICOM C-STORE SCP */, + OrthancPluginErrorCode_NoApplicationEntityFilter = 2013 /*!< No application entity filter */, + OrthancPluginErrorCode_NoSopClassOrInstance = 2014 /*!< DicomUserConnection: Unable to find the SOP class and instance */, + OrthancPluginErrorCode_NoPresentationContext = 2015 /*!< DicomUserConnection: No acceptable presentation context for modality */, + OrthancPluginErrorCode_DicomFindUnavailable = 2016 /*!< DicomUserConnection: The C-FIND command is not supported by the remote SCP */, + OrthancPluginErrorCode_DicomMoveUnavailable = 2017 /*!< DicomUserConnection: The C-MOVE command is not supported by the remote SCP */, + OrthancPluginErrorCode_CannotStoreInstance = 2018 /*!< Cannot store an instance */, + OrthancPluginErrorCode_CreateDicomNotString = 2019 /*!< Only string values are supported when creating DICOM instances */, + OrthancPluginErrorCode_CreateDicomOverrideTag = 2020 /*!< Trying to override a value inherited from a parent module */, + OrthancPluginErrorCode_CreateDicomUseContent = 2021 /*!< Use \"Content\" to inject an image into a new DICOM instance */, + OrthancPluginErrorCode_CreateDicomNoPayload = 2022 /*!< No payload is present for one instance in the series */, + OrthancPluginErrorCode_CreateDicomUseDataUriScheme = 2023 /*!< The payload of the DICOM instance must be specified according to Data URI scheme */, + OrthancPluginErrorCode_CreateDicomBadParent = 2024 /*!< Trying to attach a new DICOM instance to an inexistent resource */, + OrthancPluginErrorCode_CreateDicomParentIsInstance = 2025 /*!< Trying to attach a new DICOM instance to an instance (must be a series, study or patient) */, + OrthancPluginErrorCode_CreateDicomParentEncoding = 2026 /*!< Unable to get the encoding of the parent resource */, + OrthancPluginErrorCode_UnknownModality = 2027 /*!< Unknown modality */, + OrthancPluginErrorCode_BadJobOrdering = 2028 /*!< Bad ordering of filters in a job */, + OrthancPluginErrorCode_JsonToLuaTable = 2029 /*!< Cannot convert the given JSON object to a Lua table */, + OrthancPluginErrorCode_CannotCreateLua = 2030 /*!< Cannot create the Lua context */, + OrthancPluginErrorCode_CannotExecuteLua = 2031 /*!< Cannot execute a Lua command */, + OrthancPluginErrorCode_LuaAlreadyExecuted = 2032 /*!< Arguments cannot be pushed after the Lua function is executed */, + OrthancPluginErrorCode_LuaBadOutput = 2033 /*!< The Lua function does not give the expected number of outputs */, + OrthancPluginErrorCode_NotLuaPredicate = 2034 /*!< The Lua function is not a predicate (only true/false outputs allowed) */, + OrthancPluginErrorCode_LuaReturnsNoString = 2035 /*!< The Lua function does not return a string */, + OrthancPluginErrorCode_StorageAreaAlreadyRegistered = 2036 /*!< Another plugin has already registered a custom storage area */, + OrthancPluginErrorCode_DatabaseBackendAlreadyRegistered = 2037 /*!< Another plugin has already registered a custom database back-end */, + OrthancPluginErrorCode_DatabaseNotInitialized = 2038 /*!< Plugin trying to call the database during its initialization */, + OrthancPluginErrorCode_SslDisabled = 2039 /*!< Orthanc has been built without SSL support */, + OrthancPluginErrorCode_CannotOrderSlices = 2040 /*!< Unable to order the slices of the series */, + OrthancPluginErrorCode_NoWorklistHandler = 2041 /*!< No request handler factory for DICOM C-Find Modality SCP */, + OrthancPluginErrorCode_AlreadyExistingTag = 2042 /*!< Cannot override the value of a tag that already exists */, + OrthancPluginErrorCode_NoStorageCommitmentHandler = 2043 /*!< No request handler factory for DICOM N-ACTION SCP (storage commitment) */, + OrthancPluginErrorCode_NoCGetHandler = 2044 /*!< No request handler factory for DICOM C-GET SCP */, + OrthancPluginErrorCode_UnsupportedMediaType = 3000 /*!< Unsupported media type */, + + _OrthancPluginErrorCode_INTERNAL = 0x7fffffff + } OrthancPluginErrorCode; + + + /** + * Forward declaration of one of the mandatory functions for Orthanc + * plugins. + **/ + ORTHANC_PLUGINS_API const char* OrthancPluginGetName(); + + + /** + * The various HTTP methods for a REST call. + **/ + typedef enum + { + OrthancPluginHttpMethod_Get = 1, /*!< GET request */ + OrthancPluginHttpMethod_Post = 2, /*!< POST request */ + OrthancPluginHttpMethod_Put = 3, /*!< PUT request */ + OrthancPluginHttpMethod_Delete = 4, /*!< DELETE request */ + + _OrthancPluginHttpMethod_INTERNAL = 0x7fffffff + } OrthancPluginHttpMethod; + + + /** + * @brief The parameters of a REST request. + * @ingroup Callbacks + **/ + typedef struct + { + /** + * @brief The HTTP method. + **/ + OrthancPluginHttpMethod method; + + /** + * @brief The number of groups of the regular expression. + **/ + uint32_t groupsCount; + + /** + * @brief The matched values for the groups of the regular expression. + **/ + const char* const* groups; + + /** + * @brief For a GET request, the number of GET parameters. + **/ + uint32_t getCount; + + /** + * @brief For a GET request, the keys of the GET parameters. + **/ + const char* const* getKeys; + + /** + * @brief For a GET request, the values of the GET parameters. + **/ + const char* const* getValues; + + /** + * @brief For a PUT or POST request, the content of the body. + **/ + const void* body; + + /** + * @brief For a PUT or POST request, the number of bytes of the body. + **/ + uint32_t bodySize; + + + /* -------------------------------------------------- + New in version 0.8.1 + -------------------------------------------------- */ + + /** + * @brief The number of HTTP headers. + **/ + uint32_t headersCount; + + /** + * @brief The keys of the HTTP headers (always converted to low-case). + **/ + const char* const* headersKeys; + + /** + * @brief The values of the HTTP headers. + **/ + const char* const* headersValues; + + } OrthancPluginHttpRequest; + + + typedef enum + { + /* Generic services */ + _OrthancPluginService_LogInfo = 1, + _OrthancPluginService_LogWarning = 2, + _OrthancPluginService_LogError = 3, + _OrthancPluginService_GetOrthancPath = 4, + _OrthancPluginService_GetOrthancDirectory = 5, + _OrthancPluginService_GetConfigurationPath = 6, + _OrthancPluginService_SetPluginProperty = 7, + _OrthancPluginService_GetGlobalProperty = 8, + _OrthancPluginService_SetGlobalProperty = 9, + _OrthancPluginService_GetCommandLineArgumentsCount = 10, + _OrthancPluginService_GetCommandLineArgument = 11, + _OrthancPluginService_GetExpectedDatabaseVersion = 12, + _OrthancPluginService_GetConfiguration = 13, + _OrthancPluginService_BufferCompression = 14, + _OrthancPluginService_ReadFile = 15, + _OrthancPluginService_WriteFile = 16, + _OrthancPluginService_GetErrorDescription = 17, + _OrthancPluginService_CallHttpClient = 18, + _OrthancPluginService_RegisterErrorCode = 19, + _OrthancPluginService_RegisterDictionaryTag = 20, + _OrthancPluginService_DicomBufferToJson = 21, + _OrthancPluginService_DicomInstanceToJson = 22, + _OrthancPluginService_CreateDicom = 23, + _OrthancPluginService_ComputeMd5 = 24, + _OrthancPluginService_ComputeSha1 = 25, + _OrthancPluginService_LookupDictionary = 26, + _OrthancPluginService_CallHttpClient2 = 27, + _OrthancPluginService_GenerateUuid = 28, + _OrthancPluginService_RegisterPrivateDictionaryTag = 29, + _OrthancPluginService_AutodetectMimeType = 30, + _OrthancPluginService_SetMetricsValue = 31, + _OrthancPluginService_EncodeDicomWebJson = 32, + _OrthancPluginService_EncodeDicomWebXml = 33, + _OrthancPluginService_ChunkedHttpClient = 34, /* New in Orthanc 1.5.7 */ + _OrthancPluginService_GetTagName = 35, /* New in Orthanc 1.5.7 */ + _OrthancPluginService_EncodeDicomWebJson2 = 36, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_EncodeDicomWebXml2 = 37, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_CreateMemoryBuffer = 38, /* New in Orthanc 1.7.0 */ + + /* Registration of callbacks */ + _OrthancPluginService_RegisterRestCallback = 1000, + _OrthancPluginService_RegisterOnStoredInstanceCallback = 1001, + _OrthancPluginService_RegisterStorageArea = 1002, + _OrthancPluginService_RegisterOnChangeCallback = 1003, + _OrthancPluginService_RegisterRestCallbackNoLock = 1004, + _OrthancPluginService_RegisterWorklistCallback = 1005, + _OrthancPluginService_RegisterDecodeImageCallback = 1006, + _OrthancPluginService_RegisterIncomingHttpRequestFilter = 1007, + _OrthancPluginService_RegisterFindCallback = 1008, + _OrthancPluginService_RegisterMoveCallback = 1009, + _OrthancPluginService_RegisterIncomingHttpRequestFilter2 = 1010, + _OrthancPluginService_RegisterRefreshMetricsCallback = 1011, + _OrthancPluginService_RegisterChunkedRestCallback = 1012, /* New in Orthanc 1.5.7 */ + _OrthancPluginService_RegisterStorageCommitmentScpCallback = 1013, + _OrthancPluginService_RegisterIncomingDicomInstanceFilter = 1014, + _OrthancPluginService_RegisterTranscoderCallback = 1015, /* New in Orthanc 1.7.0 */ + + /* Sending answers to REST calls */ + _OrthancPluginService_AnswerBuffer = 2000, + _OrthancPluginService_CompressAndAnswerPngImage = 2001, /* Unused as of Orthanc 0.9.4 */ + _OrthancPluginService_Redirect = 2002, + _OrthancPluginService_SendHttpStatusCode = 2003, + _OrthancPluginService_SendUnauthorized = 2004, + _OrthancPluginService_SendMethodNotAllowed = 2005, + _OrthancPluginService_SetCookie = 2006, + _OrthancPluginService_SetHttpHeader = 2007, + _OrthancPluginService_StartMultipartAnswer = 2008, + _OrthancPluginService_SendMultipartItem = 2009, + _OrthancPluginService_SendHttpStatus = 2010, + _OrthancPluginService_CompressAndAnswerImage = 2011, + _OrthancPluginService_SendMultipartItem2 = 2012, + _OrthancPluginService_SetHttpErrorDetails = 2013, + + /* Access to the Orthanc database and API */ + _OrthancPluginService_GetDicomForInstance = 3000, + _OrthancPluginService_RestApiGet = 3001, + _OrthancPluginService_RestApiPost = 3002, + _OrthancPluginService_RestApiDelete = 3003, + _OrthancPluginService_RestApiPut = 3004, + _OrthancPluginService_LookupPatient = 3005, + _OrthancPluginService_LookupStudy = 3006, + _OrthancPluginService_LookupSeries = 3007, + _OrthancPluginService_LookupInstance = 3008, + _OrthancPluginService_LookupStudyWithAccessionNumber = 3009, + _OrthancPluginService_RestApiGetAfterPlugins = 3010, + _OrthancPluginService_RestApiPostAfterPlugins = 3011, + _OrthancPluginService_RestApiDeleteAfterPlugins = 3012, + _OrthancPluginService_RestApiPutAfterPlugins = 3013, + _OrthancPluginService_ReconstructMainDicomTags = 3014, + _OrthancPluginService_RestApiGet2 = 3015, + + /* Access to DICOM instances */ + _OrthancPluginService_GetInstanceRemoteAet = 4000, + _OrthancPluginService_GetInstanceSize = 4001, + _OrthancPluginService_GetInstanceData = 4002, + _OrthancPluginService_GetInstanceJson = 4003, + _OrthancPluginService_GetInstanceSimplifiedJson = 4004, + _OrthancPluginService_HasInstanceMetadata = 4005, + _OrthancPluginService_GetInstanceMetadata = 4006, + _OrthancPluginService_GetInstanceOrigin = 4007, + _OrthancPluginService_GetInstanceTransferSyntaxUid = 4008, + _OrthancPluginService_HasInstancePixelData = 4009, + _OrthancPluginService_CreateDicomInstance = 4010, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_FreeDicomInstance = 4011, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceFramesCount = 4012, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceRawFrame = 4013, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceDecodedFrame = 4014, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_TranscodeDicomInstance = 4015, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_SerializeDicomInstance = 4016, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceAdvancedJson = 4017, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceDicomWebJson = 4018, /* New in Orthanc 1.7.0 */ + _OrthancPluginService_GetInstanceDicomWebXml = 4019, /* New in Orthanc 1.7.0 */ + + /* Services for plugins implementing a database back-end */ + _OrthancPluginService_RegisterDatabaseBackend = 5000, + _OrthancPluginService_DatabaseAnswer = 5001, + _OrthancPluginService_RegisterDatabaseBackendV2 = 5002, + _OrthancPluginService_StorageAreaCreate = 5003, + _OrthancPluginService_StorageAreaRead = 5004, + _OrthancPluginService_StorageAreaRemove = 5005, + + /* Primitives for handling images */ + _OrthancPluginService_GetImagePixelFormat = 6000, + _OrthancPluginService_GetImageWidth = 6001, + _OrthancPluginService_GetImageHeight = 6002, + _OrthancPluginService_GetImagePitch = 6003, + _OrthancPluginService_GetImageBuffer = 6004, + _OrthancPluginService_UncompressImage = 6005, + _OrthancPluginService_FreeImage = 6006, + _OrthancPluginService_CompressImage = 6007, + _OrthancPluginService_ConvertPixelFormat = 6008, + _OrthancPluginService_GetFontsCount = 6009, + _OrthancPluginService_GetFontInfo = 6010, + _OrthancPluginService_DrawText = 6011, + _OrthancPluginService_CreateImage = 6012, + _OrthancPluginService_CreateImageAccessor = 6013, + _OrthancPluginService_DecodeDicomImage = 6014, + + /* Primitives for handling C-Find, C-Move and worklists */ + _OrthancPluginService_WorklistAddAnswer = 7000, + _OrthancPluginService_WorklistMarkIncomplete = 7001, + _OrthancPluginService_WorklistIsMatch = 7002, + _OrthancPluginService_WorklistGetDicomQuery = 7003, + _OrthancPluginService_FindAddAnswer = 7004, + _OrthancPluginService_FindMarkIncomplete = 7005, + _OrthancPluginService_GetFindQuerySize = 7006, + _OrthancPluginService_GetFindQueryTag = 7007, + _OrthancPluginService_GetFindQueryTagName = 7008, + _OrthancPluginService_GetFindQueryValue = 7009, + _OrthancPluginService_CreateFindMatcher = 7010, + _OrthancPluginService_FreeFindMatcher = 7011, + _OrthancPluginService_FindMatcherIsMatch = 7012, + + /* Primitives for accessing Orthanc Peers (new in 1.4.2) */ + _OrthancPluginService_GetPeers = 8000, + _OrthancPluginService_FreePeers = 8001, + _OrthancPluginService_GetPeersCount = 8003, + _OrthancPluginService_GetPeerName = 8004, + _OrthancPluginService_GetPeerUrl = 8005, + _OrthancPluginService_CallPeerApi = 8006, + _OrthancPluginService_GetPeerUserProperty = 8007, + + /* Primitives for handling jobs (new in 1.4.2) */ + _OrthancPluginService_CreateJob = 9000, + _OrthancPluginService_FreeJob = 9001, + _OrthancPluginService_SubmitJob = 9002, + _OrthancPluginService_RegisterJobsUnserializer = 9003, + + _OrthancPluginService_INTERNAL = 0x7fffffff + } _OrthancPluginService; + + + typedef enum + { + _OrthancPluginProperty_Description = 1, + _OrthancPluginProperty_RootUri = 2, + _OrthancPluginProperty_OrthancExplorer = 3, + + _OrthancPluginProperty_INTERNAL = 0x7fffffff + } _OrthancPluginProperty; + + + + /** + * The memory layout of the pixels of an image. + * @ingroup Images + **/ + typedef enum + { + /** + * @brief Graylevel 8bpp image. + * + * The image is graylevel. Each pixel is unsigned and stored in + * one byte. + **/ + OrthancPluginPixelFormat_Grayscale8 = 1, + + /** + * @brief Graylevel, unsigned 16bpp image. + * + * The image is graylevel. Each pixel is unsigned and stored in + * two bytes. + **/ + OrthancPluginPixelFormat_Grayscale16 = 2, + + /** + * @brief Graylevel, signed 16bpp image. + * + * The image is graylevel. Each pixel is signed and stored in two + * bytes. + **/ + OrthancPluginPixelFormat_SignedGrayscale16 = 3, + + /** + * @brief Color image in RGB24 format. + * + * This format describes a color image. The pixels are stored in 3 + * consecutive bytes. The memory layout is RGB. + **/ + OrthancPluginPixelFormat_RGB24 = 4, + + /** + * @brief Color image in RGBA32 format. + * + * This format describes a color image. The pixels are stored in 4 + * consecutive bytes. The memory layout is RGBA. + **/ + OrthancPluginPixelFormat_RGBA32 = 5, + + OrthancPluginPixelFormat_Unknown = 6, /*!< Unknown pixel format */ + + /** + * @brief Color image in RGB48 format. + * + * This format describes a color image. The pixels are stored in 6 + * consecutive bytes. The memory layout is RRGGBB. + **/ + OrthancPluginPixelFormat_RGB48 = 7, + + /** + * @brief Graylevel, unsigned 32bpp image. + * + * The image is graylevel. Each pixel is unsigned and stored in + * four bytes. + **/ + OrthancPluginPixelFormat_Grayscale32 = 8, + + /** + * @brief Graylevel, floating-point 32bpp image. + * + * The image is graylevel. Each pixel is floating-point and stored + * in four bytes. + **/ + OrthancPluginPixelFormat_Float32 = 9, + + /** + * @brief Color image in BGRA32 format. + * + * This format describes a color image. The pixels are stored in 4 + * consecutive bytes. The memory layout is BGRA. + **/ + OrthancPluginPixelFormat_BGRA32 = 10, + + /** + * @brief Graylevel, unsigned 64bpp image. + * + * The image is graylevel. Each pixel is unsigned and stored in + * eight bytes. + **/ + OrthancPluginPixelFormat_Grayscale64 = 11, + + _OrthancPluginPixelFormat_INTERNAL = 0x7fffffff + } OrthancPluginPixelFormat; + + + + /** + * The content types that are supported by Orthanc plugins. + **/ + typedef enum + { + OrthancPluginContentType_Unknown = 0, /*!< Unknown content type */ + OrthancPluginContentType_Dicom = 1, /*!< DICOM */ + OrthancPluginContentType_DicomAsJson = 2, /*!< JSON summary of a DICOM file */ + + _OrthancPluginContentType_INTERNAL = 0x7fffffff + } OrthancPluginContentType; + + + + /** + * The supported types of DICOM resources. + **/ + typedef enum + { + OrthancPluginResourceType_Patient = 0, /*!< Patient */ + OrthancPluginResourceType_Study = 1, /*!< Study */ + OrthancPluginResourceType_Series = 2, /*!< Series */ + OrthancPluginResourceType_Instance = 3, /*!< Instance */ + OrthancPluginResourceType_None = 4, /*!< Unavailable resource type */ + + _OrthancPluginResourceType_INTERNAL = 0x7fffffff + } OrthancPluginResourceType; + + + + /** + * The supported types of changes that can be signaled to the change callback. + * @ingroup Callbacks + **/ + typedef enum + { + OrthancPluginChangeType_CompletedSeries = 0, /*!< Series is now complete */ + OrthancPluginChangeType_Deleted = 1, /*!< Deleted resource */ + OrthancPluginChangeType_NewChildInstance = 2, /*!< A new instance was added to this resource */ + OrthancPluginChangeType_NewInstance = 3, /*!< New instance received */ + OrthancPluginChangeType_NewPatient = 4, /*!< New patient created */ + OrthancPluginChangeType_NewSeries = 5, /*!< New series created */ + OrthancPluginChangeType_NewStudy = 6, /*!< New study created */ + OrthancPluginChangeType_StablePatient = 7, /*!< Timeout: No new instance in this patient */ + OrthancPluginChangeType_StableSeries = 8, /*!< Timeout: No new instance in this series */ + OrthancPluginChangeType_StableStudy = 9, /*!< Timeout: No new instance in this study */ + OrthancPluginChangeType_OrthancStarted = 10, /*!< Orthanc has started */ + OrthancPluginChangeType_OrthancStopped = 11, /*!< Orthanc is stopping */ + OrthancPluginChangeType_UpdatedAttachment = 12, /*!< Some user-defined attachment has changed for this resource */ + OrthancPluginChangeType_UpdatedMetadata = 13, /*!< Some user-defined metadata has changed for this resource */ + OrthancPluginChangeType_UpdatedPeers = 14, /*!< The list of Orthanc peers has changed */ + OrthancPluginChangeType_UpdatedModalities = 15, /*!< The list of DICOM modalities has changed */ + OrthancPluginChangeType_JobSubmitted = 16, /*!< New Job submitted */ + OrthancPluginChangeType_JobSuccess = 17, /*!< A Job has completed successfully */ + OrthancPluginChangeType_JobFailure = 18, /*!< A Job has failed */ + + _OrthancPluginChangeType_INTERNAL = 0x7fffffff + } OrthancPluginChangeType; + + + /** + * The compression algorithms that are supported by the Orthanc core. + * @ingroup Images + **/ + typedef enum + { + OrthancPluginCompressionType_Zlib = 0, /*!< Standard zlib compression */ + OrthancPluginCompressionType_ZlibWithSize = 1, /*!< zlib, prefixed with uncompressed size (uint64_t) */ + OrthancPluginCompressionType_Gzip = 2, /*!< Standard gzip compression */ + OrthancPluginCompressionType_GzipWithSize = 3, /*!< gzip, prefixed with uncompressed size (uint64_t) */ + + _OrthancPluginCompressionType_INTERNAL = 0x7fffffff + } OrthancPluginCompressionType; + + + /** + * The image formats that are supported by the Orthanc core. + * @ingroup Images + **/ + typedef enum + { + OrthancPluginImageFormat_Png = 0, /*!< Image compressed using PNG */ + OrthancPluginImageFormat_Jpeg = 1, /*!< Image compressed using JPEG */ + OrthancPluginImageFormat_Dicom = 2, /*!< Image compressed using DICOM */ + + _OrthancPluginImageFormat_INTERNAL = 0x7fffffff + } OrthancPluginImageFormat; + + + /** + * The value representations present in the DICOM standard (version 2013). + * @ingroup Toolbox + **/ + typedef enum + { + OrthancPluginValueRepresentation_AE = 1, /*!< Application Entity */ + OrthancPluginValueRepresentation_AS = 2, /*!< Age String */ + OrthancPluginValueRepresentation_AT = 3, /*!< Attribute Tag */ + OrthancPluginValueRepresentation_CS = 4, /*!< Code String */ + OrthancPluginValueRepresentation_DA = 5, /*!< Date */ + OrthancPluginValueRepresentation_DS = 6, /*!< Decimal String */ + OrthancPluginValueRepresentation_DT = 7, /*!< Date Time */ + OrthancPluginValueRepresentation_FD = 8, /*!< Floating Point Double */ + OrthancPluginValueRepresentation_FL = 9, /*!< Floating Point Single */ + OrthancPluginValueRepresentation_IS = 10, /*!< Integer String */ + OrthancPluginValueRepresentation_LO = 11, /*!< Long String */ + OrthancPluginValueRepresentation_LT = 12, /*!< Long Text */ + OrthancPluginValueRepresentation_OB = 13, /*!< Other Byte String */ + OrthancPluginValueRepresentation_OF = 14, /*!< Other Float String */ + OrthancPluginValueRepresentation_OW = 15, /*!< Other Word String */ + OrthancPluginValueRepresentation_PN = 16, /*!< Person Name */ + OrthancPluginValueRepresentation_SH = 17, /*!< Short String */ + OrthancPluginValueRepresentation_SL = 18, /*!< Signed Long */ + OrthancPluginValueRepresentation_SQ = 19, /*!< Sequence of Items */ + OrthancPluginValueRepresentation_SS = 20, /*!< Signed Short */ + OrthancPluginValueRepresentation_ST = 21, /*!< Short Text */ + OrthancPluginValueRepresentation_TM = 22, /*!< Time */ + OrthancPluginValueRepresentation_UI = 23, /*!< Unique Identifier (UID) */ + OrthancPluginValueRepresentation_UL = 24, /*!< Unsigned Long */ + OrthancPluginValueRepresentation_UN = 25, /*!< Unknown */ + OrthancPluginValueRepresentation_US = 26, /*!< Unsigned Short */ + OrthancPluginValueRepresentation_UT = 27, /*!< Unlimited Text */ + + _OrthancPluginValueRepresentation_INTERNAL = 0x7fffffff + } OrthancPluginValueRepresentation; + + + /** + * The possible output formats for a DICOM-to-JSON conversion. + * @ingroup Toolbox + * @see OrthancPluginDicomToJson() + **/ + typedef enum + { + OrthancPluginDicomToJsonFormat_Full = 1, /*!< Full output, with most details */ + OrthancPluginDicomToJsonFormat_Short = 2, /*!< Tags output as hexadecimal numbers */ + OrthancPluginDicomToJsonFormat_Human = 3, /*!< Human-readable JSON */ + + _OrthancPluginDicomToJsonFormat_INTERNAL = 0x7fffffff + } OrthancPluginDicomToJsonFormat; + + + /** + * Flags to customize a DICOM-to-JSON conversion. By default, binary + * tags are formatted using Data URI scheme. + * @ingroup Toolbox + **/ + typedef enum + { + OrthancPluginDicomToJsonFlags_None = 0, + OrthancPluginDicomToJsonFlags_IncludeBinary = (1 << 0), /*!< Include the binary tags */ + OrthancPluginDicomToJsonFlags_IncludePrivateTags = (1 << 1), /*!< Include the private tags */ + OrthancPluginDicomToJsonFlags_IncludeUnknownTags = (1 << 2), /*!< Include the tags unknown by the dictionary */ + OrthancPluginDicomToJsonFlags_IncludePixelData = (1 << 3), /*!< Include the pixel data */ + OrthancPluginDicomToJsonFlags_ConvertBinaryToAscii = (1 << 4), /*!< Output binary tags as-is, dropping non-ASCII */ + OrthancPluginDicomToJsonFlags_ConvertBinaryToNull = (1 << 5), /*!< Signal binary tags as null values */ + + _OrthancPluginDicomToJsonFlags_INTERNAL = 0x7fffffff + } OrthancPluginDicomToJsonFlags; + + + /** + * Flags to the creation of a DICOM file. + * @ingroup Toolbox + * @see OrthancPluginCreateDicom() + **/ + typedef enum + { + OrthancPluginCreateDicomFlags_None = 0, + OrthancPluginCreateDicomFlags_DecodeDataUriScheme = (1 << 0), /*!< Decode fields encoded using data URI scheme */ + OrthancPluginCreateDicomFlags_GenerateIdentifiers = (1 << 1), /*!< Automatically generate DICOM identifiers */ + + _OrthancPluginCreateDicomFlags_INTERNAL = 0x7fffffff + } OrthancPluginCreateDicomFlags; + + + /** + * The constraints on the DICOM identifiers that must be supported + * by the database plugins. + * @deprecated Plugins using OrthancPluginConstraintType will be faster + **/ + typedef enum + { + OrthancPluginIdentifierConstraint_Equal = 1, /*!< Equal */ + OrthancPluginIdentifierConstraint_SmallerOrEqual = 2, /*!< Less or equal */ + OrthancPluginIdentifierConstraint_GreaterOrEqual = 3, /*!< More or equal */ + OrthancPluginIdentifierConstraint_Wildcard = 4, /*!< Case-sensitive wildcard matching (with * and ?) */ + + _OrthancPluginIdentifierConstraint_INTERNAL = 0x7fffffff + } OrthancPluginIdentifierConstraint; + + + /** + * The constraints on the tags (main DICOM tags and identifier tags) + * that must be supported by the database plugins. + **/ + typedef enum + { + OrthancPluginConstraintType_Equal = 1, /*!< Equal */ + OrthancPluginConstraintType_SmallerOrEqual = 2, /*!< Less or equal */ + OrthancPluginConstraintType_GreaterOrEqual = 3, /*!< More or equal */ + OrthancPluginConstraintType_Wildcard = 4, /*!< Wildcard matching */ + OrthancPluginConstraintType_List = 5, /*!< List of values */ + + _OrthancPluginConstraintType_INTERNAL = 0x7fffffff + } OrthancPluginConstraintType; + + + /** + * The origin of a DICOM instance that has been received by Orthanc. + **/ + typedef enum + { + OrthancPluginInstanceOrigin_Unknown = 1, /*!< Unknown origin */ + OrthancPluginInstanceOrigin_DicomProtocol = 2, /*!< Instance received through DICOM protocol */ + OrthancPluginInstanceOrigin_RestApi = 3, /*!< Instance received through REST API of Orthanc */ + OrthancPluginInstanceOrigin_Plugin = 4, /*!< Instance added to Orthanc by a plugin */ + OrthancPluginInstanceOrigin_Lua = 5, /*!< Instance added to Orthanc by a Lua script */ + + _OrthancPluginInstanceOrigin_INTERNAL = 0x7fffffff + } OrthancPluginInstanceOrigin; + + + /** + * The possible status for one single step of a job. + **/ + typedef enum + { + OrthancPluginJobStepStatus_Success = 1, /*!< The job has successfully executed all its steps */ + OrthancPluginJobStepStatus_Failure = 2, /*!< The job has failed while executing this step */ + OrthancPluginJobStepStatus_Continue = 3 /*!< The job has still data to process after this step */ + } OrthancPluginJobStepStatus; + + + /** + * Explains why the job should stop and release the resources it has + * allocated. This is especially important to disambiguate between + * the "paused" condition and the "final" conditions (success, + * failure, or canceled). + **/ + typedef enum + { + OrthancPluginJobStopReason_Success = 1, /*!< The job has succeeded */ + OrthancPluginJobStopReason_Paused = 2, /*!< The job was paused, and will be resumed later */ + OrthancPluginJobStopReason_Failure = 3, /*!< The job has failed, and might be resubmitted later */ + OrthancPluginJobStopReason_Canceled = 4 /*!< The job was canceled, and might be resubmitted later */ + } OrthancPluginJobStopReason; + + + /** + * The available types of metrics. + **/ + typedef enum + { + OrthancPluginMetricsType_Default = 0, /*!< Default metrics */ + + /** + * This metrics represents a time duration. Orthanc will keep the + * maximum value of the metrics over a sliding window of ten + * seconds, which is useful if the metrics is sampled frequently. + **/ + OrthancPluginMetricsType_Timer = 1 + } OrthancPluginMetricsType; + + + /** + * The available modes to export a binary DICOM tag into a DICOMweb + * JSON or XML document. + **/ + typedef enum + { + OrthancPluginDicomWebBinaryMode_Ignore = 0, /*!< Don't include binary tags */ + OrthancPluginDicomWebBinaryMode_InlineBinary = 1, /*!< Inline encoding using Base64 */ + OrthancPluginDicomWebBinaryMode_BulkDataUri = 2 /*!< Use a bulk data URI field */ + } OrthancPluginDicomWebBinaryMode; + + + /** + * The available values for the Failure Reason (0008,1197) during + * storage commitment. + * http://dicom.nema.org/medical/dicom/2019e/output/chtml/part03/sect_C.14.html#sect_C.14.1.1 + **/ + typedef enum + { + OrthancPluginStorageCommitmentFailureReason_Success = 0, + /*!< Success: The DICOM instance is properly stored in the SCP */ + + OrthancPluginStorageCommitmentFailureReason_ProcessingFailure = 1, + /*!< 0110H: A general failure in processing the operation was encountered */ + + OrthancPluginStorageCommitmentFailureReason_NoSuchObjectInstance = 2, + /*!< 0112H: One or more of the elements in the Referenced SOP + Instance Sequence was not available */ + + OrthancPluginStorageCommitmentFailureReason_ResourceLimitation = 3, + /*!< 0213H: The SCP does not currently have enough resources to + store the requested SOP Instance(s) */ + + OrthancPluginStorageCommitmentFailureReason_ReferencedSOPClassNotSupported = 4, + /*!< 0122H: Storage Commitment has been requested for a SOP + Instance with a SOP Class that is not supported by the SCP */ + + OrthancPluginStorageCommitmentFailureReason_ClassInstanceConflict = 5, + /*!< 0119H: The SOP Class of an element in the Referenced SOP + Instance Sequence did not correspond to the SOP class registered + for this SOP Instance at the SCP */ + + OrthancPluginStorageCommitmentFailureReason_DuplicateTransactionUID = 6 + /*!< 0131H: The Transaction UID of the Storage Commitment Request + is already in use */ + } OrthancPluginStorageCommitmentFailureReason; + + + + /** + * @brief A memory buffer allocated by the core system of Orthanc. + * + * A memory buffer allocated by the core system of Orthanc. When the + * content of the buffer is not useful anymore, it must be free by a + * call to ::OrthancPluginFreeMemoryBuffer(). + **/ + typedef struct + { + /** + * @brief The content of the buffer. + **/ + void* data; + + /** + * @brief The number of bytes in the buffer. + **/ + uint32_t size; + } OrthancPluginMemoryBuffer; + + + + + /** + * @brief Opaque structure that represents the HTTP connection to the client application. + * @ingroup Callback + **/ + typedef struct _OrthancPluginRestOutput_t OrthancPluginRestOutput; + + + + /** + * @brief Opaque structure that represents a DICOM instance that is managed by the Orthanc core. + * @ingroup DicomInstance + **/ + typedef struct _OrthancPluginDicomInstance_t OrthancPluginDicomInstance; + + + + /** + * @brief Opaque structure that represents an image that is uncompressed in memory. + * @ingroup Images + **/ + typedef struct _OrthancPluginImage_t OrthancPluginImage; + + + + /** + * @brief Opaque structure that represents the storage area that is actually used by Orthanc. + * @ingroup Images + **/ + typedef struct _OrthancPluginStorageArea_t OrthancPluginStorageArea; + + + + /** + * @brief Opaque structure to an object that represents a C-Find query for worklists. + * @ingroup DicomCallbacks + **/ + typedef struct _OrthancPluginWorklistQuery_t OrthancPluginWorklistQuery; + + + + /** + * @brief Opaque structure to an object that represents the answers to a C-Find query for worklists. + * @ingroup DicomCallbacks + **/ + typedef struct _OrthancPluginWorklistAnswers_t OrthancPluginWorklistAnswers; + + + + /** + * @brief Opaque structure to an object that represents a C-Find query. + * @ingroup DicomCallbacks + **/ + typedef struct _OrthancPluginFindQuery_t OrthancPluginFindQuery; + + + + /** + * @brief Opaque structure to an object that represents the answers to a C-Find query for worklists. + * @ingroup DicomCallbacks + **/ + typedef struct _OrthancPluginFindAnswers_t OrthancPluginFindAnswers; + + + + /** + * @brief Opaque structure to an object that can be used to check whether a DICOM instance matches a C-Find query. + * @ingroup Toolbox + **/ + typedef struct _OrthancPluginFindMatcher_t OrthancPluginFindMatcher; + + + + /** + * @brief Opaque structure to the set of remote Orthanc Peers that are known to the local Orthanc server. + * @ingroup Toolbox + **/ + typedef struct _OrthancPluginPeers_t OrthancPluginPeers; + + + + /** + * @brief Opaque structure to a job to be executed by Orthanc. + * @ingroup Toolbox + **/ + typedef struct _OrthancPluginJob_t OrthancPluginJob; + + + + /** + * @brief Opaque structure that represents a node in a JSON or XML + * document used in DICOMweb. + * @ingroup Toolbox + **/ + typedef struct _OrthancPluginDicomWebNode_t OrthancPluginDicomWebNode; + + + + /** + * @brief Signature of a callback function that answers to a REST request. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginRestCallback) ( + OrthancPluginRestOutput* output, + const char* url, + const OrthancPluginHttpRequest* request); + + + + /** + * @brief Signature of a callback function that is triggered when Orthanc stores a new DICOM instance. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginOnStoredInstanceCallback) ( + const OrthancPluginDicomInstance* instance, + const char* instanceId); + + + + /** + * @brief Signature of a callback function that is triggered when a change happens to some DICOM resource. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginOnChangeCallback) ( + OrthancPluginChangeType changeType, + OrthancPluginResourceType resourceType, + const char* resourceId); + + + + /** + * @brief Signature of a callback function to decode a DICOM instance as an image. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginDecodeImageCallback) ( + OrthancPluginImage** target, + const void* dicom, + const uint32_t size, + uint32_t frameIndex); + + + + /** + * @brief Signature of a function to free dynamic memory. + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginFree) (void* buffer); + + + + /** + * @brief Signature of a function to set the content of a node + * encoding a binary DICOM tag, into a JSON or XML document + * generated for DICOMweb. + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginDicomWebSetBinaryNode) ( + OrthancPluginDicomWebNode* node, + OrthancPluginDicomWebBinaryMode mode, + const char* bulkDataUri); + + + + /** + * @brief Callback for writing to the storage area. + * + * Signature of a callback function that is triggered when Orthanc writes a file to the storage area. + * + * @param uuid The UUID of the file. + * @param content The content of the file. + * @param size The size of the file. + * @param type The content type corresponding to this file. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageCreate) ( + const char* uuid, + const void* content, + int64_t size, + OrthancPluginContentType type); + + + + /** + * @brief Callback for reading from the storage area. + * + * Signature of a callback function that is triggered when Orthanc reads a file from the storage area. + * + * @param content The content of the file (output). + * @param size The size of the file (output). + * @param uuid The UUID of the file of interest. + * @param type The content type corresponding to this file. + * @return 0 if success, other value if error. + * @ingroup Callbacks + * + * @warning The "content" buffer *must* have been allocated using + * the "malloc()" function of your C standard library (i.e. nor + * "new[]", neither a pointer to a buffer). The "free()" function of + * your C standard library will automatically be invoked on the + * "content" pointer. + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageRead) ( + void** content, + int64_t* size, + const char* uuid, + OrthancPluginContentType type); + + + + /** + * @brief Callback for removing a file from the storage area. + * + * Signature of a callback function that is triggered when Orthanc deletes a file from the storage area. + * + * @param uuid The UUID of the file to be removed. + * @param type The content type corresponding to this file. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageRemove) ( + const char* uuid, + OrthancPluginContentType type); + + + + /** + * @brief Callback to handle the C-Find SCP requests for worklists. + * + * Signature of a callback function that is triggered when Orthanc + * receives a C-Find SCP request against modality worklists. + * + * @param answers The target structure where answers must be stored. + * @param query The worklist query. + * @param issuerAet The Application Entity Title (AET) of the modality from which the request originates. + * @param calledAet The Application Entity Title (AET) of the modality that is called by the request. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginWorklistCallback) ( + OrthancPluginWorklistAnswers* answers, + const OrthancPluginWorklistQuery* query, + const char* issuerAet, + const char* calledAet); + + + + /** + * @brief Callback to filter incoming HTTP requests received by Orthanc. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives an HTTP/REST request, and that answers whether + * this request should be allowed. If the callback returns "0" + * ("false"), the server answers with HTTP status code 403 + * (Forbidden). + * + * @param method The HTTP method used by the request. + * @param uri The URI of interest. + * @param ip The IP address of the HTTP client. + * @param headersCount The number of HTTP headers. + * @param headersKeys The keys of the HTTP headers (always converted to low-case). + * @param headersValues The values of the HTTP headers. + * @return 0 if forbidden access, 1 if allowed access, -1 if error. + * @ingroup Callback + * @deprecated Please instead use OrthancPluginIncomingHttpRequestFilter2() + **/ + typedef int32_t (*OrthancPluginIncomingHttpRequestFilter) ( + OrthancPluginHttpMethod method, + const char* uri, + const char* ip, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues); + + + + /** + * @brief Callback to filter incoming HTTP requests received by Orthanc. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives an HTTP/REST request, and that answers whether + * this request should be allowed. If the callback returns "0" + * ("false"), the server answers with HTTP status code 403 + * (Forbidden). + * + * @param method The HTTP method used by the request. + * @param uri The URI of interest. + * @param ip The IP address of the HTTP client. + * @param headersCount The number of HTTP headers. + * @param headersKeys The keys of the HTTP headers (always converted to low-case). + * @param headersValues The values of the HTTP headers. + * @param getArgumentsCount The number of GET arguments (only for the GET HTTP method). + * @param getArgumentsKeys The keys of the GET arguments (only for the GET HTTP method). + * @param getArgumentsValues The values of the GET arguments (only for the GET HTTP method). + * @return 0 if forbidden access, 1 if allowed access, -1 if error. + * @ingroup Callback + **/ + typedef int32_t (*OrthancPluginIncomingHttpRequestFilter2) ( + OrthancPluginHttpMethod method, + const char* uri, + const char* ip, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues, + uint32_t getArgumentsCount, + const char* const* getArgumentsKeys, + const char* const* getArgumentsValues); + + + + /** + * @brief Callback to handle incoming C-Find SCP requests. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives a C-Find SCP request not concerning modality + * worklists. + * + * @param answers The target structure where answers must be stored. + * @param query The worklist query. + * @param issuerAet The Application Entity Title (AET) of the modality from which the request originates. + * @param calledAet The Application Entity Title (AET) of the modality that is called by the request. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginFindCallback) ( + OrthancPluginFindAnswers* answers, + const OrthancPluginFindQuery* query, + const char* issuerAet, + const char* calledAet); + + + + /** + * @brief Callback to handle incoming C-Move SCP requests. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives a C-Move SCP request. The callback receives the + * type of the resource of interest (study, series, instance...) + * together with the DICOM tags containing its identifiers. In turn, + * the plugin must create a driver object that will be responsible + * for driving the successive move suboperations. + * + * @param resourceType The type of the resource of interest. Note + * that this might be set to ResourceType_None if the + * QueryRetrieveLevel (0008,0052) tag was not provided by the + * issuer (i.e. the originator modality). + * @param patientId Content of the PatientID (0x0010, 0x0020) tag of the resource of interest. Might be NULL. + * @param accessionNumber Content of the AccessionNumber (0x0008, 0x0050) tag. Might be NULL. + * @param studyInstanceUid Content of the StudyInstanceUID (0x0020, 0x000d) tag. Might be NULL. + * @param seriesInstanceUid Content of the SeriesInstanceUID (0x0020, 0x000e) tag. Might be NULL. + * @param sopInstanceUid Content of the SOPInstanceUID (0x0008, 0x0018) tag. Might be NULL. + * @param originatorAet The Application Entity Title (AET) of the + * modality from which the request originates. + * @param sourceAet The Application Entity Title (AET) of the + * modality that should send its DICOM files to another modality. + * @param targetAet The Application Entity Title (AET) of the + * modality that should receive the DICOM files. + * @param originatorId The Message ID issued by the originator modality, + * as found in tag (0000,0110) of the DICOM query emitted by the issuer. + * + * @return The NULL value if the plugin cannot deal with this query, + * or a pointer to the driver object that is responsible for + * handling the successive move suboperations. + * + * @note If targetAet equals sourceAet, this is actually a query/retrieve operation. + * @ingroup DicomCallbacks + **/ + typedef void* (*OrthancPluginMoveCallback) ( + OrthancPluginResourceType resourceType, + const char* patientId, + const char* accessionNumber, + const char* studyInstanceUid, + const char* seriesInstanceUid, + const char* sopInstanceUid, + const char* originatorAet, + const char* sourceAet, + const char* targetAet, + uint16_t originatorId); + + + /** + * @brief Callback to read the size of a C-Move driver. + * + * Signature of a callback function that returns the number of + * C-Move suboperations that are to be achieved by the given C-Move + * driver. This driver is the return value of a previous call to the + * OrthancPluginMoveCallback() callback. + * + * @param moveDriver The C-Move driver of interest. + * @return The number of suboperations. + * @ingroup DicomCallbacks + **/ + typedef uint32_t (*OrthancPluginGetMoveSize) (void* moveDriver); + + + /** + * @brief Callback to apply one C-Move suboperation. + * + * Signature of a callback function that applies the next C-Move + * suboperation that os to be achieved by the given C-Move + * driver. This driver is the return value of a previous call to the + * OrthancPluginMoveCallback() callback. + * + * @param moveDriver The C-Move driver of interest. + * @return 0 if success, or the error code if failure. + * @ingroup DicomCallbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginApplyMove) (void* moveDriver); + + + /** + * @brief Callback to free one C-Move driver. + * + * Signature of a callback function that releases the resources + * allocated by the given C-Move driver. This driver is the return + * value of a previous call to the OrthancPluginMoveCallback() + * callback. + * + * @param moveDriver The C-Move driver of interest. + * @ingroup DicomCallbacks + **/ + typedef void (*OrthancPluginFreeMove) (void* moveDriver); + + + /** + * @brief Callback to finalize one custom job. + * + * Signature of a callback function that releases all the resources + * allocated by the given job. This job is the argument provided to + * OrthancPluginCreateJob(). + * + * @param job The job of interest. + * @ingroup Toolbox + **/ + typedef void (*OrthancPluginJobFinalize) (void* job); + + + /** + * @brief Callback to check the progress of one custom job. + * + * Signature of a callback function that returns the progress of the + * job. + * + * @param job The job of interest. + * @return The progress, as a floating-point number ranging from 0 to 1. + * @ingroup Toolbox + **/ + typedef float (*OrthancPluginJobGetProgress) (void* job); + + + /** + * @brief Callback to retrieve the content of one custom job. + * + * Signature of a callback function that returns human-readable + * statistics about the job. This statistics must be formatted as a + * JSON object. This information is notably displayed in the "Jobs" + * tab of "Orthanc Explorer". + * + * @param job The job of interest. + * @return The statistics, as a JSON object encoded as a string. + * @ingroup Toolbox + **/ + typedef const char* (*OrthancPluginJobGetContent) (void* job); + + + /** + * @brief Callback to serialize one custom job. + * + * Signature of a callback function that returns a serialized + * version of the job, formatted as a JSON object. This + * serialization is stored in the Orthanc database, and is used to + * reload the job on the restart of Orthanc. The "unserialization" + * callback (with OrthancPluginJobsUnserializer signature) will + * receive this serialized object. + * + * @param job The job of interest. + * @return The serialized job, as a JSON object encoded as a string. + * @see OrthancPluginRegisterJobsUnserializer() + * @ingroup Toolbox + **/ + typedef const char* (*OrthancPluginJobGetSerialized) (void* job); + + + /** + * @brief Callback to execute one step of a custom job. + * + * Signature of a callback function that executes one step in the + * job. The jobs engine of Orthanc will make successive calls to + * this method, as long as it returns + * OrthancPluginJobStepStatus_Continue. + * + * @param job The job of interest. + * @return The status of execution. + * @ingroup Toolbox + **/ + typedef OrthancPluginJobStepStatus (*OrthancPluginJobStep) (void* job); + + + /** + * @brief Callback executed once one custom job leaves the "running" state. + * + * Signature of a callback function that is invoked once a job + * leaves the "running" state. This can happen if the previous call + * to OrthancPluginJobStep has failed/succeeded, if the host Orthanc + * server is being stopped, or if the user manually tags the job as + * paused/canceled. This callback allows the plugin to free + * resources allocated for running this custom job (e.g. to stop + * threads, or to remove temporary files). + * + * Note that handling pauses might involves a specific treatment + * (such a stopping threads, but keeping temporary files on the + * disk). This "paused" situation can be checked by looking at the + * "reason" parameter. + * + * @param job The job of interest. + * @param reason The reason for leaving the "running" state. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginJobStop) (void* job, + OrthancPluginJobStopReason reason); + + + /** + * @brief Callback executed once one stopped custom job is started again. + * + * Signature of a callback function that is invoked once a job + * leaves the "failure/canceled" state, to be started again. This + * function will typically reset the progress to zero. Note that + * before being actually executed, the job would first be tagged as + * "pending" in the Orthanc jobs engine. + * + * @param job The job of interest. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginJobReset) (void* job); + + + /** + * @brief Callback executed to unserialize a custom job. + * + * Signature of a callback function that unserializes a job that was + * saved in the Orthanc database. + * + * @param jobType The type of the job, as provided to OrthancPluginCreateJob(). + * @param serialized The serialization of the job, as provided by OrthancPluginJobGetSerialized. + * @return The unserialized job (as created by OrthancPluginCreateJob()), or NULL + * if this unserializer cannot handle this job type. + * @see OrthancPluginRegisterJobsUnserializer() + * @ingroup Callbacks + **/ + typedef OrthancPluginJob* (*OrthancPluginJobsUnserializer) (const char* jobType, + const char* serialized); + + + + /** + * @brief Callback executed to update the metrics of the plugin. + * + * Signature of a callback function that is called by Orthanc + * whenever a monitoring tool (such as Prometheus) asks the current + * values of the metrics. This callback gives the plugin a chance to + * update its metrics, by calling OrthancPluginSetMetricsValue(). + * This is typically useful for metrics that are expensive to + * acquire. + * + * @see OrthancPluginRegisterRefreshMetrics() + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginRefreshMetricsCallback) (); + + + + /** + * @brief Callback executed to encode a binary tag in DICOMweb. + * + * Signature of a callback function that is called by Orthanc + * whenever a DICOM tag that contains a binary value must be written + * to a JSON or XML node, while a DICOMweb document is being + * generated. The value representation (VR) of the DICOM tag can be + * OB, OD, OF, OL, OW, or UN. + * + * @see OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml() + * @param node The node being generated, as provided by Orthanc. + * @param setter The setter to be used to encode the content of the node. If + * the setter is not called, the binary tag is not written to the output document. + * @param levelDepth The depth of the node in the DICOM hierarchy of sequences. + * This parameter gives the number of elements in the "levelTagGroup", + * "levelTagElement", and "levelIndex" arrays. + * @param levelTagGroup The group of the parent DICOM tags in the hierarchy. + * @param levelTagElement The element of the parent DICOM tags in the hierarchy. + * @param levelIndex The index of the node in the parent sequences of the hierarchy. + * @param tagGroup The group of the DICOM tag of interest. + * @param tagElement The element of the DICOM tag of interest. + * @param vr The value representation of the binary DICOM node. + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginDicomWebBinaryCallback) ( + OrthancPluginDicomWebNode* node, + OrthancPluginDicomWebSetBinaryNode setter, + uint32_t levelDepth, + const uint16_t* levelTagGroup, + const uint16_t* levelTagElement, + const uint32_t* levelIndex, + uint16_t tagGroup, + uint16_t tagElement, + OrthancPluginValueRepresentation vr); + + + + /** + * @brief Callback executed to encode a binary tag in DICOMweb. + * + * Signature of a callback function that is called by Orthanc + * whenever a DICOM tag that contains a binary value must be written + * to a JSON or XML node, while a DICOMweb document is being + * generated. The value representation (VR) of the DICOM tag can be + * OB, OD, OF, OL, OW, or UN. + * + * @see OrthancPluginEncodeDicomWebJson() and OrthancPluginEncodeDicomWebXml() + * @param node The node being generated, as provided by Orthanc. + * @param setter The setter to be used to encode the content of the node. If + * the setter is not called, the binary tag is not written to the output document. + * @param levelDepth The depth of the node in the DICOM hierarchy of sequences. + * This parameter gives the number of elements in the "levelTagGroup", + * "levelTagElement", and "levelIndex" arrays. + * @param levelTagGroup The group of the parent DICOM tags in the hierarchy. + * @param levelTagElement The element of the parent DICOM tags in the hierarchy. + * @param levelIndex The index of the node in the parent sequences of the hierarchy. + * @param tagGroup The group of the DICOM tag of interest. + * @param tagElement The element of the DICOM tag of interest. + * @param vr The value representation of the binary DICOM node. + * @param payload The user payload. + * @ingroup Callbacks + **/ + typedef void (*OrthancPluginDicomWebBinaryCallback2) ( + OrthancPluginDicomWebNode* node, + OrthancPluginDicomWebSetBinaryNode setter, + uint32_t levelDepth, + const uint16_t* levelTagGroup, + const uint16_t* levelTagElement, + const uint32_t* levelIndex, + uint16_t tagGroup, + uint16_t tagElement, + OrthancPluginValueRepresentation vr, + void* payload); + + + + /** + * @brief Data structure that contains information about the Orthanc core. + **/ + typedef struct _OrthancPluginContext_t + { + void* pluginsManager; + const char* orthancVersion; + OrthancPluginFree Free; + OrthancPluginErrorCode (*InvokeService) (struct _OrthancPluginContext_t* context, + _OrthancPluginService service, + const void* params); + } OrthancPluginContext; + + + + /** + * @brief An entry in the dictionary of DICOM tags. + **/ + typedef struct + { + uint16_t group; /*!< The group of the tag */ + uint16_t element; /*!< The element of the tag */ + OrthancPluginValueRepresentation vr; /*!< The value representation of the tag */ + uint32_t minMultiplicity; /*!< The minimum multiplicity of the tag */ + uint32_t maxMultiplicity; /*!< The maximum multiplicity of the tag (0 means arbitrary) */ + } OrthancPluginDictionaryEntry; + + + + /** + * @brief Free a string. + * + * Free a string that was allocated by the core system of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param str The string to be freed. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeString( + OrthancPluginContext* context, + char* str) + { + if (str != NULL) + { + context->Free(str); + } + } + + + /** + * @brief Check that the version of the hosting Orthanc is above a given version. + * + * This function checks whether the version of the Orthanc server + * running this plugin, is above the given version. Contrarily to + * OrthancPluginCheckVersion(), it is up to the developer of the + * plugin to make sure that all the Orthanc SDK services called by + * the plugin are actually implemented in the given version of + * Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param expectedMajor Expected major version. + * @param expectedMinor Expected minor version. + * @param expectedRevision Expected revision. + * @return 1 if and only if the versions are compatible. If the + * result is 0, the initialization of the plugin should fail. + * @see OrthancPluginCheckVersion + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE int OrthancPluginCheckVersionAdvanced( + OrthancPluginContext* context, + int expectedMajor, + int expectedMinor, + int expectedRevision) + { + int major, minor, revision; + + if (sizeof(int32_t) != sizeof(OrthancPluginErrorCode) || + sizeof(int32_t) != sizeof(OrthancPluginHttpMethod) || + sizeof(int32_t) != sizeof(_OrthancPluginService) || + sizeof(int32_t) != sizeof(_OrthancPluginProperty) || + sizeof(int32_t) != sizeof(OrthancPluginPixelFormat) || + sizeof(int32_t) != sizeof(OrthancPluginContentType) || + sizeof(int32_t) != sizeof(OrthancPluginResourceType) || + sizeof(int32_t) != sizeof(OrthancPluginChangeType) || + sizeof(int32_t) != sizeof(OrthancPluginCompressionType) || + sizeof(int32_t) != sizeof(OrthancPluginImageFormat) || + sizeof(int32_t) != sizeof(OrthancPluginValueRepresentation) || + sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFormat) || + sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFlags) || + sizeof(int32_t) != sizeof(OrthancPluginCreateDicomFlags) || + sizeof(int32_t) != sizeof(OrthancPluginIdentifierConstraint) || + sizeof(int32_t) != sizeof(OrthancPluginInstanceOrigin) || + sizeof(int32_t) != sizeof(OrthancPluginJobStepStatus) || + sizeof(int32_t) != sizeof(OrthancPluginConstraintType) || + sizeof(int32_t) != sizeof(OrthancPluginMetricsType) || + sizeof(int32_t) != sizeof(OrthancPluginDicomWebBinaryMode) || + sizeof(int32_t) != sizeof(OrthancPluginStorageCommitmentFailureReason)) + { + /* Mismatch in the size of the enumerations */ + return 0; + } + + /* Assume compatibility with the mainline */ + if (!strcmp(context->orthancVersion, "mainline")) + { + return 1; + } + + /* Parse the version of the Orthanc core */ + if ( +#ifdef _MSC_VER + sscanf_s +#else + sscanf +#endif + (context->orthancVersion, "%4d.%4d.%4d", &major, &minor, &revision) != 3) + { + return 0; + } + + /* Check the major number of the version */ + + if (major > expectedMajor) + { + return 1; + } + + if (major < expectedMajor) + { + return 0; + } + + /* Check the minor number of the version */ + + if (minor > expectedMinor) + { + return 1; + } + + if (minor < expectedMinor) + { + return 0; + } + + /* Check the revision number of the version */ + + if (revision >= expectedRevision) + { + return 1; + } + else + { + return 0; + } + } + + + /** + * @brief Check the compatibility of the plugin wrt. the version of its hosting Orthanc. + * + * This function checks whether the version of the Orthanc server + * running this plugin, is above the version of the current Orthanc + * SDK header. This guarantees that the plugin is compatible with + * the hosting Orthanc (i.e. it will not call unavailable services). + * The result of this function should always be checked in the + * OrthancPluginInitialize() entry point of the plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return 1 if and only if the versions are compatible. If the + * result is 0, the initialization of the plugin should fail. + * @see OrthancPluginCheckVersionAdvanced + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE int OrthancPluginCheckVersion( + OrthancPluginContext* context) + { + return OrthancPluginCheckVersionAdvanced( + context, + ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, + ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, + ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); + } + + + /** + * @brief Free a memory buffer. + * + * Free a memory buffer that was allocated by the core system of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The memory buffer to release. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeMemoryBuffer( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* buffer) + { + context->Free(buffer->data); + } + + + /** + * @brief Log an error. + * + * Log an error message using the Orthanc logging system. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param message The message to be logged. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginLogError( + OrthancPluginContext* context, + const char* message) + { + context->InvokeService(context, _OrthancPluginService_LogError, message); + } + + + /** + * @brief Log a warning. + * + * Log a warning message using the Orthanc logging system. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param message The message to be logged. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginLogWarning( + OrthancPluginContext* context, + const char* message) + { + context->InvokeService(context, _OrthancPluginService_LogWarning, message); + } + + + /** + * @brief Log an information. + * + * Log an information message using the Orthanc logging system. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param message The message to be logged. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginLogInfo( + OrthancPluginContext* context, + const char* message) + { + context->InvokeService(context, _OrthancPluginService_LogInfo, message); + } + + + + typedef struct + { + const char* pathRegularExpression; + OrthancPluginRestCallback callback; + } _OrthancPluginRestCallback; + + /** + * @brief Register a REST callback. + * + * This function registers a REST callback against a regular + * expression for a URI. This function must be called during the + * initialization of the plugin, i.e. inside the + * OrthancPluginInitialize() public function. + * + * Each REST callback is guaranteed to run in mutual exclusion. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param pathRegularExpression Regular expression for the URI. May contain groups. + * @param callback The callback function to handle the REST call. + * @see OrthancPluginRegisterRestCallbackNoLock() + * + * @note + * The regular expression is case sensitive and must follow the + * [Perl syntax](https://www.boost.org/doc/libs/1_67_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html). + * + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallback( + OrthancPluginContext* context, + const char* pathRegularExpression, + OrthancPluginRestCallback callback) + { + _OrthancPluginRestCallback params; + params.pathRegularExpression = pathRegularExpression; + params.callback = callback; + context->InvokeService(context, _OrthancPluginService_RegisterRestCallback, ¶ms); + } + + + + /** + * @brief Register a REST callback, without locking. + * + * This function registers a REST callback against a regular + * expression for a URI. This function must be called during the + * initialization of the plugin, i.e. inside the + * OrthancPluginInitialize() public function. + * + * Contrarily to OrthancPluginRegisterRestCallback(), the callback + * will NOT be invoked in mutual exclusion. This can be useful for + * high-performance plugins that must handle concurrent requests + * (Orthanc uses a pool of threads, one thread being assigned to + * each incoming HTTP request). Of course, if using this function, + * it is up to the plugin to implement the required locking + * mechanisms. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param pathRegularExpression Regular expression for the URI. May contain groups. + * @param callback The callback function to handle the REST call. + * @see OrthancPluginRegisterRestCallback() + * + * @note + * The regular expression is case sensitive and must follow the + * [Perl syntax](https://www.boost.org/doc/libs/1_67_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html). + * + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRestCallbackNoLock( + OrthancPluginContext* context, + const char* pathRegularExpression, + OrthancPluginRestCallback callback) + { + _OrthancPluginRestCallback params; + params.pathRegularExpression = pathRegularExpression; + params.callback = callback; + context->InvokeService(context, _OrthancPluginService_RegisterRestCallbackNoLock, ¶ms); + } + + + + typedef struct + { + OrthancPluginOnStoredInstanceCallback callback; + } _OrthancPluginOnStoredInstanceCallback; + + /** + * @brief Register a callback for received instances. + * + * This function registers a callback function that is called + * whenever a new DICOM instance is stored into the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback function. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterOnStoredInstanceCallback( + OrthancPluginContext* context, + OrthancPluginOnStoredInstanceCallback callback) + { + _OrthancPluginOnStoredInstanceCallback params; + params.callback = callback; + + context->InvokeService(context, _OrthancPluginService_RegisterOnStoredInstanceCallback, ¶ms); + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + const void* answer; + uint32_t answerSize; + const char* mimeType; + } _OrthancPluginAnswerBuffer; + + /** + * @brief Answer to a REST request. + * + * This function answers to a REST request with the content of a memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param answer Pointer to the memory buffer containing the answer. + * @param answerSize Number of bytes of the answer. + * @param mimeType The MIME type of the answer. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginAnswerBuffer( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const void* answer, + uint32_t answerSize, + const char* mimeType) + { + _OrthancPluginAnswerBuffer params; + params.output = output; + params.answer = answer; + params.answerSize = answerSize; + params.mimeType = mimeType; + context->InvokeService(context, _OrthancPluginService_AnswerBuffer, ¶ms); + } + + + typedef struct + { + OrthancPluginRestOutput* output; + OrthancPluginPixelFormat format; + uint32_t width; + uint32_t height; + uint32_t pitch; + const void* buffer; + } _OrthancPluginCompressAndAnswerPngImage; + + typedef struct + { + OrthancPluginRestOutput* output; + OrthancPluginImageFormat imageFormat; + OrthancPluginPixelFormat pixelFormat; + uint32_t width; + uint32_t height; + uint32_t pitch; + const void* buffer; + uint8_t quality; + } _OrthancPluginCompressAndAnswerImage; + + + /** + * @brief Answer to a REST request with a PNG image. + * + * This function answers to a REST request with a PNG image. The + * parameters of this function describe a memory buffer that + * contains an uncompressed image. The image will be automatically compressed + * as a PNG image by the core system of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param format The memory layout of the uncompressed image. + * @param width The width of the image. + * @param height The height of the image. + * @param pitch The pitch of the image (i.e. the number of bytes + * between 2 successive lines of the image in the memory buffer). + * @param buffer The memory buffer containing the uncompressed image. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerPngImage( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height, + uint32_t pitch, + const void* buffer) + { + _OrthancPluginCompressAndAnswerImage params; + params.output = output; + params.imageFormat = OrthancPluginImageFormat_Png; + params.pixelFormat = format; + params.width = width; + params.height = height; + params.pitch = pitch; + params.buffer = buffer; + params.quality = 0; /* No quality for PNG */ + context->InvokeService(context, _OrthancPluginService_CompressAndAnswerImage, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* instanceId; + } _OrthancPluginGetDicomForInstance; + + /** + * @brief Retrieve a DICOM instance using its Orthanc identifier. + * + * Retrieve a DICOM instance using its Orthanc identifier. The DICOM + * file is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param instanceId The Orthanc identifier of the DICOM instance of interest. + * @return 0 if success, or the error code if failure. + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetDicomForInstance( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* instanceId) + { + _OrthancPluginGetDicomForInstance params; + params.target = target; + params.instanceId = instanceId; + return context->InvokeService(context, _OrthancPluginService_GetDicomForInstance, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* uri; + } _OrthancPluginRestApiGet; + + /** + * @brief Make a GET call to the built-in Orthanc REST API. + * + * Make a GET call to the built-in Orthanc REST API. The result to + * the query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiGetAfterPlugins + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGet( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri) + { + _OrthancPluginRestApiGet params; + params.target = target; + params.uri = uri; + return context->InvokeService(context, _OrthancPluginService_RestApiGet, ¶ms); + } + + + + /** + * @brief Make a GET call to the REST API, as tainted by the plugins. + * + * Make a GET call to the Orthanc REST API, after all the plugins + * are applied. In other words, if some plugin overrides or adds the + * called URI to the built-in Orthanc REST API, this call will + * return the result provided by this plugin. The result to the + * query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiGet + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGetAfterPlugins( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri) + { + _OrthancPluginRestApiGet params; + params.target = target; + params.uri = uri; + return context->InvokeService(context, _OrthancPluginService_RestApiGetAfterPlugins, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* uri; + const void* body; + uint32_t bodySize; + } _OrthancPluginRestApiPostPut; + + /** + * @brief Make a POST call to the built-in Orthanc REST API. + * + * Make a POST call to the built-in Orthanc REST API. The result to + * the query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @param body The body of the POST request. + * @param bodySize The size of the body. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiPostAfterPlugins + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPost( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri, + const void* body, + uint32_t bodySize) + { + _OrthancPluginRestApiPostPut params; + params.target = target; + params.uri = uri; + params.body = body; + params.bodySize = bodySize; + return context->InvokeService(context, _OrthancPluginService_RestApiPost, ¶ms); + } + + + /** + * @brief Make a POST call to the REST API, as tainted by the plugins. + * + * Make a POST call to the Orthanc REST API, after all the plugins + * are applied. In other words, if some plugin overrides or adds the + * called URI to the built-in Orthanc REST API, this call will + * return the result provided by this plugin. The result to the + * query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @param body The body of the POST request. + * @param bodySize The size of the body. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiPost + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPostAfterPlugins( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri, + const void* body, + uint32_t bodySize) + { + _OrthancPluginRestApiPostPut params; + params.target = target; + params.uri = uri; + params.body = body; + params.bodySize = bodySize; + return context->InvokeService(context, _OrthancPluginService_RestApiPostAfterPlugins, ¶ms); + } + + + + /** + * @brief Make a DELETE call to the built-in Orthanc REST API. + * + * Make a DELETE call to the built-in Orthanc REST API. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param uri The URI to delete in the built-in Orthanc API. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiDeleteAfterPlugins + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiDelete( + OrthancPluginContext* context, + const char* uri) + { + return context->InvokeService(context, _OrthancPluginService_RestApiDelete, uri); + } + + + /** + * @brief Make a DELETE call to the REST API, as tainted by the plugins. + * + * Make a DELETE call to the Orthanc REST API, after all the plugins + * are applied. In other words, if some plugin overrides or adds the + * called URI to the built-in Orthanc REST API, this call will + * return the result provided by this plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param uri The URI to delete in the built-in Orthanc API. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiDelete + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiDeleteAfterPlugins( + OrthancPluginContext* context, + const char* uri) + { + return context->InvokeService(context, _OrthancPluginService_RestApiDeleteAfterPlugins, uri); + } + + + + /** + * @brief Make a PUT call to the built-in Orthanc REST API. + * + * Make a PUT call to the built-in Orthanc REST API. The result to + * the query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @param body The body of the PUT request. + * @param bodySize The size of the body. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiPutAfterPlugins + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPut( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri, + const void* body, + uint32_t bodySize) + { + _OrthancPluginRestApiPostPut params; + params.target = target; + params.uri = uri; + params.body = body; + params.bodySize = bodySize; + return context->InvokeService(context, _OrthancPluginService_RestApiPut, ¶ms); + } + + + + /** + * @brief Make a PUT call to the REST API, as tainted by the plugins. + * + * Make a PUT call to the Orthanc REST API, after all the plugins + * are applied. In other words, if some plugin overrides or adds the + * called URI to the built-in Orthanc REST API, this call will + * return the result provided by this plugin. The result to the + * query is stored into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @param body The body of the PUT request. + * @param bodySize The size of the body. + * @return 0 if success, or the error code if failure. + * @note If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. + * @see OrthancPluginRestApiPut + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiPutAfterPlugins( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri, + const void* body, + uint32_t bodySize) + { + _OrthancPluginRestApiPostPut params; + params.target = target; + params.uri = uri; + params.body = body; + params.bodySize = bodySize; + return context->InvokeService(context, _OrthancPluginService_RestApiPutAfterPlugins, ¶ms); + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + const char* argument; + } _OrthancPluginOutputPlusArgument; + + /** + * @brief Redirect a REST request. + * + * This function answers to a REST request by redirecting the user + * to another URI using HTTP status 301. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param redirection Where to redirect. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRedirect( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* redirection) + { + _OrthancPluginOutputPlusArgument params; + params.output = output; + params.argument = redirection; + context->InvokeService(context, _OrthancPluginService_Redirect, ¶ms); + } + + + + typedef struct + { + char** result; + const char* argument; + } _OrthancPluginRetrieveDynamicString; + + /** + * @brief Look for a patient. + * + * Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020). + * This function uses the database index to run as fast as possible (it does not loop + * over all the stored patients). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param patientID The Patient ID of interest. + * @return The NULL value if the patient is non-existent, or a string containing the + * Orthanc ID of the patient. This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupPatient( + OrthancPluginContext* context, + const char* patientID) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = patientID; + + if (context->InvokeService(context, _OrthancPluginService_LookupPatient, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Look for a study. + * + * Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d). + * This function uses the database index to run as fast as possible (it does not loop + * over all the stored studies). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param studyUID The Study Instance UID of interest. + * @return The NULL value if the study is non-existent, or a string containing the + * Orthanc ID of the study. This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudy( + OrthancPluginContext* context, + const char* studyUID) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = studyUID; + + if (context->InvokeService(context, _OrthancPluginService_LookupStudy, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Look for a study, using the accession number. + * + * Look for a study stored in Orthanc, using its Accession Number tag (0x0008, 0x0050). + * This function uses the database index to run as fast as possible (it does not loop + * over all the stored studies). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param accessionNumber The Accession Number of interest. + * @return The NULL value if the study is non-existent, or a string containing the + * Orthanc ID of the study. This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudyWithAccessionNumber( + OrthancPluginContext* context, + const char* accessionNumber) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = accessionNumber; + + if (context->InvokeService(context, _OrthancPluginService_LookupStudyWithAccessionNumber, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Look for a series. + * + * Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e). + * This function uses the database index to run as fast as possible (it does not loop + * over all the stored series). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param seriesUID The Series Instance UID of interest. + * @return The NULL value if the series is non-existent, or a string containing the + * Orthanc ID of the series. This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupSeries( + OrthancPluginContext* context, + const char* seriesUID) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = seriesUID; + + if (context->InvokeService(context, _OrthancPluginService_LookupSeries, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Look for an instance. + * + * Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018). + * This function uses the database index to run as fast as possible (it does not loop + * over all the stored instances). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param sopInstanceUID The SOP Instance UID of interest. + * @return The NULL value if the instance is non-existent, or a string containing the + * Orthanc ID of the instance. This string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupInstance( + OrthancPluginContext* context, + const char* sopInstanceUID) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = sopInstanceUID; + + if (context->InvokeService(context, _OrthancPluginService_LookupInstance, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + uint16_t status; + } _OrthancPluginSendHttpStatusCode; + + /** + * @brief Send a HTTP status code. + * + * This function answers to a REST request by sending a HTTP status + * code (such as "400 - Bad Request"). Note that: + * - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). + * - Redirections (status 301) must use ::OrthancPluginRedirect(). + * - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). + * - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param status The HTTP status code to be sent. + * @ingroup REST + * @see OrthancPluginSendHttpStatus() + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSendHttpStatusCode( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + uint16_t status) + { + _OrthancPluginSendHttpStatusCode params; + params.output = output; + params.status = status; + context->InvokeService(context, _OrthancPluginService_SendHttpStatusCode, ¶ms); + } + + + /** + * @brief Signal that a REST request is not authorized. + * + * This function answers to a REST request by signaling that it is + * not authorized. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param realm The realm for the authorization process. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSendUnauthorized( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* realm) + { + _OrthancPluginOutputPlusArgument params; + params.output = output; + params.argument = realm; + context->InvokeService(context, _OrthancPluginService_SendUnauthorized, ¶ms); + } + + + /** + * @brief Signal that this URI does not support this HTTP method. + * + * This function answers to a REST request by signaling that the + * queried URI does not support this method. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param allowedMethods The allowed methods for this URI (e.g. "GET,POST" after a PUT or a POST request). + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSendMethodNotAllowed( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* allowedMethods) + { + _OrthancPluginOutputPlusArgument params; + params.output = output; + params.argument = allowedMethods; + context->InvokeService(context, _OrthancPluginService_SendMethodNotAllowed, ¶ms); + } + + + typedef struct + { + OrthancPluginRestOutput* output; + const char* key; + const char* value; + } _OrthancPluginSetHttpHeader; + + /** + * @brief Set a cookie. + * + * This function sets a cookie in the HTTP client. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param cookie The cookie to be set. + * @param value The value of the cookie. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetCookie( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* cookie, + const char* value) + { + _OrthancPluginSetHttpHeader params; + params.output = output; + params.key = cookie; + params.value = value; + context->InvokeService(context, _OrthancPluginService_SetCookie, ¶ms); + } + + + /** + * @brief Set some HTTP header. + * + * This function sets a HTTP header in the HTTP answer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param key The HTTP header to be set. + * @param value The value of the HTTP header. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetHttpHeader( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* key, + const char* value) + { + _OrthancPluginSetHttpHeader params; + params.output = output; + params.key = key; + params.value = value; + context->InvokeService(context, _OrthancPluginService_SetHttpHeader, ¶ms); + } + + + typedef struct + { + char** resultStringToFree; + const char** resultString; + int64_t* resultInt64; + const char* key; + const OrthancPluginDicomInstance* instance; + OrthancPluginInstanceOrigin* resultOrigin; /* New in Orthanc 0.9.5 SDK */ + } _OrthancPluginAccessDicomInstance; + + + /** + * @brief Get the AET of a DICOM instance. + * + * This function returns the Application Entity Title (AET) of the + * DICOM modality from which a DICOM instance originates. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The AET if success, NULL if error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceRemoteAet( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + const char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultString = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceRemoteAet, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the size of a DICOM file. + * + * This function returns the number of bytes of the given DICOM instance. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The size of the file, -1 in case of error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE int64_t OrthancPluginGetInstanceSize( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + int64_t size; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultInt64 = &size; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceSize, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return -1; + } + else + { + return size; + } + } + + + /** + * @brief Get the data of a DICOM file. + * + * This function returns a pointer to the content of the given DICOM instance. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The pointer to the DICOM data, NULL in case of error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE const void* OrthancPluginGetInstanceData( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + const char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultString = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceData, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the DICOM tag hierarchy as a JSON file. + * + * This function returns a pointer to a newly created string + * containing a JSON file. This JSON file encodes the tag hierarchy + * of the given DICOM instance. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The NULL value in case of error, or a string containing the JSON file. + * This string must be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceJson( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultStringToFree = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the DICOM tag hierarchy as a JSON file (with simplification). + * + * This function returns a pointer to a newly created string + * containing a JSON file. This JSON file encodes the tag hierarchy + * of the given DICOM instance. In contrast with + * ::OrthancPluginGetInstanceJson(), the returned JSON file is in + * its simplified version. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The NULL value in case of error, or a string containing the JSON file. + * This string must be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceSimplifiedJson( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultStringToFree = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceSimplifiedJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Check whether a DICOM instance is associated with some metadata. + * + * This function checks whether the DICOM instance of interest is + * associated with some metadata. As of Orthanc 0.8.1, in the + * callbacks registered by + * ::OrthancPluginRegisterOnStoredInstanceCallback(), the only + * possibly available metadata are "ReceptionDate", "RemoteAET" and + * "IndexInSeries". + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @param metadata The metadata of interest. + * @return 1 if the metadata is present, 0 if it is absent, -1 in case of error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE int OrthancPluginHasInstanceMetadata( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + const char* metadata) + { + int64_t result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultInt64 = &result; + params.instance = instance; + params.key = metadata; + + if (context->InvokeService(context, _OrthancPluginService_HasInstanceMetadata, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return -1; + } + else + { + return (result != 0); + } + } + + + /** + * @brief Get the value of some metadata associated with a given DICOM instance. + * + * This functions returns the value of some metadata that is associated with the DICOM instance of interest. + * Before calling this function, the existence of the metadata must have been checked with + * ::OrthancPluginHasInstanceMetadata(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @param metadata The metadata of interest. + * @return The metadata value if success, NULL if error. Please note that the + * returned string belongs to the instance object and must NOT be + * deallocated. Please make a copy of the string if you wish to access + * it later. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetInstanceMetadata( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + const char* metadata) + { + const char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultString = &result; + params.instance = instance; + params.key = metadata; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceMetadata, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginStorageCreate create; + OrthancPluginStorageRead read; + OrthancPluginStorageRemove remove; + OrthancPluginFree free; + } _OrthancPluginRegisterStorageArea; + + /** + * @brief Register a custom storage area. + * + * This function registers a custom storage area, to replace the + * built-in way Orthanc stores its files on the filesystem. This + * function must be called during the initialization of the plugin, + * i.e. inside the OrthancPluginInitialize() public function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param create The callback function to store a file on the custom storage area. + * @param read The callback function to read a file from the custom storage area. + * @param remove The callback function to remove a file from the custom storage area. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterStorageArea( + OrthancPluginContext* context, + OrthancPluginStorageCreate create, + OrthancPluginStorageRead read, + OrthancPluginStorageRemove remove) + { + _OrthancPluginRegisterStorageArea params; + params.create = create; + params.read = read; + params.remove = remove; + +#ifdef __cplusplus + params.free = ::free; +#else + params.free = free; +#endif + + context->InvokeService(context, _OrthancPluginService_RegisterStorageArea, ¶ms); + } + + + + /** + * @brief Return the path to the Orthanc executable. + * + * This function returns the path to the Orthanc executable. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL in the case of an error, or a newly allocated string + * containing the path. This string must be freed by + * OrthancPluginFreeString(). + **/ + ORTHANC_PLUGIN_INLINE char *OrthancPluginGetOrthancPath(OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetOrthancPath, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Return the directory containing the Orthanc. + * + * This function returns the path to the directory containing the Orthanc executable. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL in the case of an error, or a newly allocated string + * containing the path. This string must be freed by + * OrthancPluginFreeString(). + **/ + ORTHANC_PLUGIN_INLINE char *OrthancPluginGetOrthancDirectory(OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetOrthancDirectory, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Return the path to the configuration file(s). + * + * This function returns the path to the configuration file(s) that + * was specified when starting Orthanc. Since version 0.9.1, this + * path can refer to a folder that stores a set of configuration + * files. This function is deprecated in favor of + * OrthancPluginGetConfiguration(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL in the case of an error, or a newly allocated string + * containing the path. This string must be freed by + * OrthancPluginFreeString(). + * @see OrthancPluginGetConfiguration() + **/ + ORTHANC_PLUGIN_INLINE char *OrthancPluginGetConfigurationPath(OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetConfigurationPath, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginOnChangeCallback callback; + } _OrthancPluginOnChangeCallback; + + /** + * @brief Register a callback to monitor changes. + * + * This function registers a callback function that is called + * whenever a change happens to some DICOM resource. + * + * @warning If your change callback has to call the REST API of + * Orthanc, you should make these calls in a separate thread (with + * the events passing through a message queue). Otherwise, this + * could result in deadlocks in the presence of other plugins or Lua + * scripts. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback function. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterOnChangeCallback( + OrthancPluginContext* context, + OrthancPluginOnChangeCallback callback) + { + _OrthancPluginOnChangeCallback params; + params.callback = callback; + + context->InvokeService(context, _OrthancPluginService_RegisterOnChangeCallback, ¶ms); + } + + + + typedef struct + { + const char* plugin; + _OrthancPluginProperty property; + const char* value; + } _OrthancPluginSetPluginProperty; + + + /** + * @brief Set the URI where the plugin provides its Web interface. + * + * For plugins that come with a Web interface, this function + * declares the entry path where to find this interface. This + * information is notably used in the "Plugins" page of Orthanc + * Explorer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param uri The root URI for this plugin. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetRootUri( + OrthancPluginContext* context, + const char* uri) + { + _OrthancPluginSetPluginProperty params; + params.plugin = OrthancPluginGetName(); + params.property = _OrthancPluginProperty_RootUri; + params.value = uri; + + context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); + } + + + /** + * @brief Set a description for this plugin. + * + * Set a description for this plugin. It is displayed in the + * "Plugins" page of Orthanc Explorer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param description The description. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetDescription( + OrthancPluginContext* context, + const char* description) + { + _OrthancPluginSetPluginProperty params; + params.plugin = OrthancPluginGetName(); + params.property = _OrthancPluginProperty_Description; + params.value = description; + + context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); + } + + + /** + * @brief Extend the JavaScript code of Orthanc Explorer. + * + * Add JavaScript code to customize the default behavior of Orthanc + * Explorer. This can for instance be used to add new buttons. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param javascript The custom JavaScript code. + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginExtendOrthancExplorer( + OrthancPluginContext* context, + const char* javascript) + { + _OrthancPluginSetPluginProperty params; + params.plugin = OrthancPluginGetName(); + params.property = _OrthancPluginProperty_OrthancExplorer; + params.value = javascript; + + context->InvokeService(context, _OrthancPluginService_SetPluginProperty, ¶ms); + } + + + typedef struct + { + char** result; + int32_t property; + const char* value; + } _OrthancPluginGlobalProperty; + + + /** + * @brief Get the value of a global property. + * + * Get the value of a global property that is stored in the Orthanc database. Global + * properties whose index is below 1024 are reserved by Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param property The global property of interest. + * @param defaultValue The value to return, if the global property is unset. + * @return The value of the global property, or NULL in the case of an error. This + * string must be freed by OrthancPluginFreeString(). + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetGlobalProperty( + OrthancPluginContext* context, + int32_t property, + const char* defaultValue) + { + char* result; + + _OrthancPluginGlobalProperty params; + params.result = &result; + params.property = property; + params.value = defaultValue; + + if (context->InvokeService(context, _OrthancPluginService_GetGlobalProperty, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Set the value of a global property. + * + * Set the value of a global property into the Orthanc + * database. Setting a global property can be used by plugins to + * save their internal parameters. Plugins are only allowed to set + * properties whose index are above or equal to 1024 (properties + * below 1024 are read-only and reserved by Orthanc). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param property The global property of interest. + * @param value The value to be set in the global property. + * @return 0 if success, or the error code if failure. + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSetGlobalProperty( + OrthancPluginContext* context, + int32_t property, + const char* value) + { + _OrthancPluginGlobalProperty params; + params.result = NULL; + params.property = property; + params.value = value; + + return context->InvokeService(context, _OrthancPluginService_SetGlobalProperty, ¶ms); + } + + + + typedef struct + { + int32_t *resultInt32; + uint32_t *resultUint32; + int64_t *resultInt64; + uint64_t *resultUint64; + } _OrthancPluginReturnSingleValue; + + /** + * @brief Get the number of command-line arguments. + * + * Retrieve the number of command-line arguments that were used to launch Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return The number of arguments. + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetCommandLineArgumentsCount( + OrthancPluginContext* context) + { + uint32_t count = 0; + + _OrthancPluginReturnSingleValue params; + memset(¶ms, 0, sizeof(params)); + params.resultUint32 = &count; + + if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgumentsCount, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return count; + } + } + + + + /** + * @brief Get the value of a command-line argument. + * + * Get the value of one of the command-line arguments that were used + * to launch Orthanc. The number of available arguments can be + * retrieved by OrthancPluginGetCommandLineArgumentsCount(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param argument The index of the argument. + * @return The value of the argument, or NULL in the case of an error. This + * string must be freed by OrthancPluginFreeString(). + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetCommandLineArgument( + OrthancPluginContext* context, + uint32_t argument) + { + char* result; + + _OrthancPluginGlobalProperty params; + params.result = &result; + params.property = (int32_t) argument; + params.value = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgument, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the expected version of the database schema. + * + * Retrieve the expected version of the database schema. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return The version. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetExpectedDatabaseVersion( + OrthancPluginContext* context) + { + uint32_t count = 0; + + _OrthancPluginReturnSingleValue params; + memset(¶ms, 0, sizeof(params)); + params.resultUint32 = &count; + + if (context->InvokeService(context, _OrthancPluginService_GetExpectedDatabaseVersion, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return count; + } + } + + + + /** + * @brief Return the content of the configuration file(s). + * + * This function returns the content of the configuration that is + * used by Orthanc, formatted as a JSON string. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL in the case of an error, or a newly allocated string + * containing the configuration. This string must be freed by + * OrthancPluginFreeString(). + **/ + ORTHANC_PLUGIN_INLINE char *OrthancPluginGetConfiguration(OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetConfiguration, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + const char* subType; + const char* contentType; + } _OrthancPluginStartMultipartAnswer; + + /** + * @brief Start an HTTP multipart answer. + * + * Initiates a HTTP multipart answer, as the result of a REST request. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param subType The sub-type of the multipart answer ("mixed" or "related"). + * @param contentType The MIME type of the items in the multipart answer. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginSendMultipartItem(), OrthancPluginSendMultipartItem2() + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStartMultipartAnswer( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* subType, + const char* contentType) + { + _OrthancPluginStartMultipartAnswer params; + params.output = output; + params.subType = subType; + params.contentType = contentType; + return context->InvokeService(context, _OrthancPluginService_StartMultipartAnswer, ¶ms); + } + + + /** + * @brief Send an item as a part of some HTTP multipart answer. + * + * This function sends an item as a part of some HTTP multipart + * answer that was initiated by OrthancPluginStartMultipartAnswer(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param answer Pointer to the memory buffer containing the item. + * @param answerSize Number of bytes of the item. + * @return 0 if success, or the error code if failure (this notably happens + * if the connection is closed by the client). + * @see OrthancPluginSendMultipartItem2() + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSendMultipartItem( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const void* answer, + uint32_t answerSize) + { + _OrthancPluginAnswerBuffer params; + params.output = output; + params.answer = answer; + params.answerSize = answerSize; + params.mimeType = NULL; + return context->InvokeService(context, _OrthancPluginService_SendMultipartItem, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const void* source; + uint32_t size; + OrthancPluginCompressionType compression; + uint8_t uncompress; + } _OrthancPluginBufferCompression; + + + /** + * @brief Compress or decompress a buffer. + * + * This function compresses or decompresses a buffer, using the + * version of the zlib library that is used by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param source The source buffer. + * @param size The size in bytes of the source buffer. + * @param compression The compression algorithm. + * @param uncompress If set to "0", the buffer must be compressed. + * If set to "1", the buffer must be uncompressed. + * @return 0 if success, or the error code if failure. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginBufferCompression( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const void* source, + uint32_t size, + OrthancPluginCompressionType compression, + uint8_t uncompress) + { + _OrthancPluginBufferCompression params; + params.target = target; + params.source = source; + params.size = size; + params.compression = compression; + params.uncompress = uncompress; + + return context->InvokeService(context, _OrthancPluginService_BufferCompression, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* path; + } _OrthancPluginReadFile; + + /** + * @brief Read a file. + * + * Read the content of a file on the filesystem, and returns it into + * a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param path The path of the file to be read. + * @return 0 if success, or the error code if failure. + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginReadFile( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* path) + { + _OrthancPluginReadFile params; + params.target = target; + params.path = path; + return context->InvokeService(context, _OrthancPluginService_ReadFile, ¶ms); + } + + + + typedef struct + { + const char* path; + const void* data; + uint32_t size; + } _OrthancPluginWriteFile; + + /** + * @brief Write a file. + * + * Write the content of a memory buffer to the filesystem. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param path The path of the file to be written. + * @param data The content of the memory buffer. + * @param size The size of the memory buffer. + * @return 0 if success, or the error code if failure. + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWriteFile( + OrthancPluginContext* context, + const char* path, + const void* data, + uint32_t size) + { + _OrthancPluginWriteFile params; + params.path = path; + params.data = data; + params.size = size; + return context->InvokeService(context, _OrthancPluginService_WriteFile, ¶ms); + } + + + + typedef struct + { + const char** target; + OrthancPluginErrorCode error; + } _OrthancPluginGetErrorDescription; + + /** + * @brief Get the description of a given error code. + * + * This function returns the description of a given error code. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param error The error code of interest. + * @return The error description. This is a statically-allocated + * string, do not free it. + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetErrorDescription( + OrthancPluginContext* context, + OrthancPluginErrorCode error) + { + const char* result = NULL; + + _OrthancPluginGetErrorDescription params; + params.target = &result; + params.error = error; + + if (context->InvokeService(context, _OrthancPluginService_GetErrorDescription, ¶ms) != OrthancPluginErrorCode_Success || + result == NULL) + { + return "Unknown error code"; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + uint16_t status; + const char* body; + uint32_t bodySize; + } _OrthancPluginSendHttpStatus; + + /** + * @brief Send a HTTP status, with a custom body. + * + * This function answers to a HTTP request by sending a HTTP status + * code (such as "400 - Bad Request"), together with a body + * describing the error. The body will only be returned if the + * configuration option "HttpDescribeErrors" of Orthanc is set to "true". + * + * Note that: + * - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). + * - Redirections (status 301) must use ::OrthancPluginRedirect(). + * - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). + * - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param status The HTTP status code to be sent. + * @param body The body of the answer. + * @param bodySize The size of the body. + * @see OrthancPluginSendHttpStatusCode() + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSendHttpStatus( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + uint16_t status, + const char* body, + uint32_t bodySize) + { + _OrthancPluginSendHttpStatus params; + params.output = output; + params.status = status; + params.body = body; + params.bodySize = bodySize; + context->InvokeService(context, _OrthancPluginService_SendHttpStatus, ¶ms); + } + + + + typedef struct + { + const OrthancPluginImage* image; + uint32_t* resultUint32; + OrthancPluginPixelFormat* resultPixelFormat; + void** resultBuffer; + } _OrthancPluginGetImageInfo; + + + /** + * @brief Return the pixel format of an image. + * + * This function returns the type of memory layout for the pixels of the given image. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image of interest. + * @return The pixel format. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginPixelFormat OrthancPluginGetImagePixelFormat( + OrthancPluginContext* context, + const OrthancPluginImage* image) + { + OrthancPluginPixelFormat target; + + _OrthancPluginGetImageInfo params; + memset(¶ms, 0, sizeof(params)); + params.image = image; + params.resultPixelFormat = ⌖ + + if (context->InvokeService(context, _OrthancPluginService_GetImagePixelFormat, ¶ms) != OrthancPluginErrorCode_Success) + { + return OrthancPluginPixelFormat_Unknown; + } + else + { + return (OrthancPluginPixelFormat) target; + } + } + + + + /** + * @brief Return the width of an image. + * + * This function returns the width of the given image. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image of interest. + * @return The width. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImageWidth( + OrthancPluginContext* context, + const OrthancPluginImage* image) + { + uint32_t width; + + _OrthancPluginGetImageInfo params; + memset(¶ms, 0, sizeof(params)); + params.image = image; + params.resultUint32 = &width; + + if (context->InvokeService(context, _OrthancPluginService_GetImageWidth, ¶ms) != OrthancPluginErrorCode_Success) + { + return 0; + } + else + { + return width; + } + } + + + + /** + * @brief Return the height of an image. + * + * This function returns the height of the given image. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image of interest. + * @return The height. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImageHeight( + OrthancPluginContext* context, + const OrthancPluginImage* image) + { + uint32_t height; + + _OrthancPluginGetImageInfo params; + memset(¶ms, 0, sizeof(params)); + params.image = image; + params.resultUint32 = &height; + + if (context->InvokeService(context, _OrthancPluginService_GetImageHeight, ¶ms) != OrthancPluginErrorCode_Success) + { + return 0; + } + else + { + return height; + } + } + + + + /** + * @brief Return the pitch of an image. + * + * This function returns the pitch of the given image. The pitch is + * defined as the number of bytes between 2 successive lines of the + * image in the memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image of interest. + * @return The pitch. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetImagePitch( + OrthancPluginContext* context, + const OrthancPluginImage* image) + { + uint32_t pitch; + + _OrthancPluginGetImageInfo params; + memset(¶ms, 0, sizeof(params)); + params.image = image; + params.resultUint32 = &pitch; + + if (context->InvokeService(context, _OrthancPluginService_GetImagePitch, ¶ms) != OrthancPluginErrorCode_Success) + { + return 0; + } + else + { + return pitch; + } + } + + + + /** + * @brief Return a pointer to the content of an image. + * + * This function returns a pointer to the memory buffer that + * contains the pixels of the image. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image of interest. + * @return The pointer. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE void* OrthancPluginGetImageBuffer( + OrthancPluginContext* context, + const OrthancPluginImage* image) + { + void* target = NULL; + + _OrthancPluginGetImageInfo params; + memset(¶ms, 0, sizeof(params)); + params.resultBuffer = ⌖ + params.image = image; + + if (context->InvokeService(context, _OrthancPluginService_GetImageBuffer, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + typedef struct + { + OrthancPluginImage** target; + const void* data; + uint32_t size; + OrthancPluginImageFormat format; + } _OrthancPluginUncompressImage; + + + /** + * @brief Decode a compressed image. + * + * This function decodes a compressed image from a memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param data Pointer to a memory buffer containing the compressed image. + * @param size Size of the memory buffer containing the compressed image. + * @param format The file format of the compressed image. + * @return The uncompressed image. It must be freed with OrthancPluginFreeImage(). + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage *OrthancPluginUncompressImage( + OrthancPluginContext* context, + const void* data, + uint32_t size, + OrthancPluginImageFormat format) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginUncompressImage params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.data = data; + params.size = size; + params.format = format; + + if (context->InvokeService(context, _OrthancPluginService_UncompressImage, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + + + typedef struct + { + OrthancPluginImage* image; + } _OrthancPluginFreeImage; + + /** + * @brief Free an image. + * + * This function frees an image that was decoded with OrthancPluginUncompressImage(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeImage( + OrthancPluginContext* context, + OrthancPluginImage* image) + { + _OrthancPluginFreeImage params; + params.image = image; + + context->InvokeService(context, _OrthancPluginService_FreeImage, ¶ms); + } + + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + OrthancPluginImageFormat imageFormat; + OrthancPluginPixelFormat pixelFormat; + uint32_t width; + uint32_t height; + uint32_t pitch; + const void* buffer; + uint8_t quality; + } _OrthancPluginCompressImage; + + + /** + * @brief Encode a PNG image. + * + * This function compresses the given memory buffer containing an + * image using the PNG specification, and stores the result of the + * compression into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param format The memory layout of the uncompressed image. + * @param width The width of the image. + * @param height The height of the image. + * @param pitch The pitch of the image (i.e. the number of bytes + * between 2 successive lines of the image in the memory buffer). + * @param buffer The memory buffer containing the uncompressed image. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginCompressAndAnswerPngImage() + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCompressPngImage( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height, + uint32_t pitch, + const void* buffer) + { + _OrthancPluginCompressImage params; + memset(¶ms, 0, sizeof(params)); + params.target = target; + params.imageFormat = OrthancPluginImageFormat_Png; + params.pixelFormat = format; + params.width = width; + params.height = height; + params.pitch = pitch; + params.buffer = buffer; + params.quality = 0; /* Unused for PNG */ + + return context->InvokeService(context, _OrthancPluginService_CompressImage, ¶ms); + } + + + /** + * @brief Encode a JPEG image. + * + * This function compresses the given memory buffer containing an + * image using the JPEG specification, and stores the result of the + * compression into a newly allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param format The memory layout of the uncompressed image. + * @param width The width of the image. + * @param height The height of the image. + * @param pitch The pitch of the image (i.e. the number of bytes + * between 2 successive lines of the image in the memory buffer). + * @param buffer The memory buffer containing the uncompressed image. + * @param quality The quality of the JPEG encoding, between 1 (worst + * quality, best compression) and 100 (best quality, worst + * compression). + * @return 0 if success, or the error code if failure. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCompressJpegImage( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height, + uint32_t pitch, + const void* buffer, + uint8_t quality) + { + _OrthancPluginCompressImage params; + memset(¶ms, 0, sizeof(params)); + params.target = target; + params.imageFormat = OrthancPluginImageFormat_Jpeg; + params.pixelFormat = format; + params.width = width; + params.height = height; + params.pitch = pitch; + params.buffer = buffer; + params.quality = quality; + + return context->InvokeService(context, _OrthancPluginService_CompressImage, ¶ms); + } + + + + /** + * @brief Answer to a REST request with a JPEG image. + * + * This function answers to a REST request with a JPEG image. The + * parameters of this function describe a memory buffer that + * contains an uncompressed image. The image will be automatically compressed + * as a JPEG image by the core system of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param format The memory layout of the uncompressed image. + * @param width The width of the image. + * @param height The height of the image. + * @param pitch The pitch of the image (i.e. the number of bytes + * between 2 successive lines of the image in the memory buffer). + * @param buffer The memory buffer containing the uncompressed image. + * @param quality The quality of the JPEG encoding, between 1 (worst + * quality, best compression) and 100 (best quality, worst + * compression). + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginCompressAndAnswerJpegImage( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height, + uint32_t pitch, + const void* buffer, + uint8_t quality) + { + _OrthancPluginCompressAndAnswerImage params; + params.output = output; + params.imageFormat = OrthancPluginImageFormat_Jpeg; + params.pixelFormat = format; + params.width = width; + params.height = height; + params.pitch = pitch; + params.buffer = buffer; + params.quality = quality; + context->InvokeService(context, _OrthancPluginService_CompressAndAnswerImage, ¶ms); + } + + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + OrthancPluginHttpMethod method; + const char* url; + const char* username; + const char* password; + const void* body; + uint32_t bodySize; + } _OrthancPluginCallHttpClient; + + + /** + * @brief Issue a HTTP GET call. + * + * Make a HTTP GET call to the given URL. The result to the query is + * stored into a newly allocated memory buffer. Favor + * OrthancPluginRestApiGet() if calling the built-in REST API of the + * Orthanc instance that hosts this plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param url The URL of interest. + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpGet( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* url, + const char* username, + const char* password) + { + _OrthancPluginCallHttpClient params; + memset(¶ms, 0, sizeof(params)); + + params.target = target; + params.method = OrthancPluginHttpMethod_Get; + params.url = url; + params.username = username; + params.password = password; + + return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); + } + + + /** + * @brief Issue a HTTP POST call. + * + * Make a HTTP POST call to the given URL. The result to the query + * is stored into a newly allocated memory buffer. Favor + * OrthancPluginRestApiPost() if calling the built-in REST API of + * the Orthanc instance that hosts this plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param url The URL of interest. + * @param body The content of the body of the request. + * @param bodySize The size of the body of the request. + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpPost( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* url, + const void* body, + uint32_t bodySize, + const char* username, + const char* password) + { + _OrthancPluginCallHttpClient params; + memset(¶ms, 0, sizeof(params)); + + params.target = target; + params.method = OrthancPluginHttpMethod_Post; + params.url = url; + params.body = body; + params.bodySize = bodySize; + params.username = username; + params.password = password; + + return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); + } + + + /** + * @brief Issue a HTTP PUT call. + * + * Make a HTTP PUT call to the given URL. The result to the query is + * stored into a newly allocated memory buffer. Favor + * OrthancPluginRestApiPut() if calling the built-in REST API of the + * Orthanc instance that hosts this plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param url The URL of interest. + * @param body The content of the body of the request. + * @param bodySize The size of the body of the request. + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpPut( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* url, + const void* body, + uint32_t bodySize, + const char* username, + const char* password) + { + _OrthancPluginCallHttpClient params; + memset(¶ms, 0, sizeof(params)); + + params.target = target; + params.method = OrthancPluginHttpMethod_Put; + params.url = url; + params.body = body; + params.bodySize = bodySize; + params.username = username; + params.password = password; + + return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); + } + + + /** + * @brief Issue a HTTP DELETE call. + * + * Make a HTTP DELETE call to the given URL. Favor + * OrthancPluginRestApiDelete() if calling the built-in REST API of + * the Orthanc instance that hosts this plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param url The URL of interest. + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpDelete( + OrthancPluginContext* context, + const char* url, + const char* username, + const char* password) + { + _OrthancPluginCallHttpClient params; + memset(¶ms, 0, sizeof(params)); + + params.method = OrthancPluginHttpMethod_Delete; + params.url = url; + params.username = username; + params.password = password; + + return context->InvokeService(context, _OrthancPluginService_CallHttpClient, ¶ms); + } + + + + typedef struct + { + OrthancPluginImage** target; + const OrthancPluginImage* source; + OrthancPluginPixelFormat targetFormat; + } _OrthancPluginConvertPixelFormat; + + + /** + * @brief Change the pixel format of an image. + * + * This function creates a new image, changing the memory layout of the pixels. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param source The source image. + * @param targetFormat The target pixel format. + * @return The resulting image. It must be freed with OrthancPluginFreeImage(). + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage *OrthancPluginConvertPixelFormat( + OrthancPluginContext* context, + const OrthancPluginImage* source, + OrthancPluginPixelFormat targetFormat) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginConvertPixelFormat params; + params.target = ⌖ + params.source = source; + params.targetFormat = targetFormat; + + if (context->InvokeService(context, _OrthancPluginService_ConvertPixelFormat, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + + /** + * @brief Return the number of available fonts. + * + * This function returns the number of fonts that are built in the + * Orthanc core. These fonts can be used to draw texts on images + * through OrthancPluginDrawText(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return The number of fonts. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFontsCount( + OrthancPluginContext* context) + { + uint32_t count = 0; + + _OrthancPluginReturnSingleValue params; + memset(¶ms, 0, sizeof(params)); + params.resultUint32 = &count; + + if (context->InvokeService(context, _OrthancPluginService_GetFontsCount, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return count; + } + } + + + + + typedef struct + { + uint32_t fontIndex; /* in */ + const char** name; /* out */ + uint32_t* size; /* out */ + } _OrthancPluginGetFontInfo; + + /** + * @brief Return the name of a font. + * + * This function returns the name of a font that is built in the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount(). + * @return The font name. This is a statically-allocated string, do not free it. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetFontName( + OrthancPluginContext* context, + uint32_t fontIndex) + { + const char* result = NULL; + + _OrthancPluginGetFontInfo params; + memset(¶ms, 0, sizeof(params)); + params.name = &result; + params.fontIndex = fontIndex; + + if (context->InvokeService(context, _OrthancPluginService_GetFontInfo, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Return the size of a font. + * + * This function returns the size of a font that is built in the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount(). + * @return The font size. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFontSize( + OrthancPluginContext* context, + uint32_t fontIndex) + { + uint32_t result; + + _OrthancPluginGetFontInfo params; + memset(¶ms, 0, sizeof(params)); + params.size = &result; + params.fontIndex = fontIndex; + + if (context->InvokeService(context, _OrthancPluginService_GetFontInfo, ¶ms) != OrthancPluginErrorCode_Success) + { + return 0; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginImage* image; + uint32_t fontIndex; + const char* utf8Text; + int32_t x; + int32_t y; + uint8_t r; + uint8_t g; + uint8_t b; + } _OrthancPluginDrawText; + + + /** + * @brief Draw text on an image. + * + * This function draws some text on some image. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param image The image upon which to draw the text. + * @param fontIndex The index of the font. This value must be less than OrthancPluginGetFontsCount(). + * @param utf8Text The text to be drawn, encoded as an UTF-8 zero-terminated string. + * @param x The X position of the text over the image. + * @param y The Y position of the text over the image. + * @param r The value of the red color channel of the text. + * @param g The value of the green color channel of the text. + * @param b The value of the blue color channel of the text. + * @return 0 if success, other value if error. + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginDrawText( + OrthancPluginContext* context, + OrthancPluginImage* image, + uint32_t fontIndex, + const char* utf8Text, + int32_t x, + int32_t y, + uint8_t r, + uint8_t g, + uint8_t b) + { + _OrthancPluginDrawText params; + memset(¶ms, 0, sizeof(params)); + params.image = image; + params.fontIndex = fontIndex; + params.utf8Text = utf8Text; + params.x = x; + params.y = y; + params.r = r; + params.g = g; + params.b = b; + + return context->InvokeService(context, _OrthancPluginService_DrawText, ¶ms); + } + + + + typedef struct + { + OrthancPluginStorageArea* storageArea; + const char* uuid; + const void* content; + uint64_t size; + OrthancPluginContentType type; + } _OrthancPluginStorageAreaCreate; + + + /** + * @brief Create a file inside the storage area. + * + * This function creates a new file inside the storage area that is + * currently used by Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param storageArea The storage area. + * @param uuid The identifier of the file to be created. + * @param content The content to store in the newly created file. + * @param size The size of the content. + * @param type The type of the file content. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaCreate( + OrthancPluginContext* context, + OrthancPluginStorageArea* storageArea, + const char* uuid, + const void* content, + uint64_t size, + OrthancPluginContentType type) + { + _OrthancPluginStorageAreaCreate params; + params.storageArea = storageArea; + params.uuid = uuid; + params.content = content; + params.size = size; + params.type = type; + + return context->InvokeService(context, _OrthancPluginService_StorageAreaCreate, ¶ms); + } + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + OrthancPluginStorageArea* storageArea; + const char* uuid; + OrthancPluginContentType type; + } _OrthancPluginStorageAreaRead; + + + /** + * @brief Read a file from the storage area. + * + * This function reads the content of a given file from the storage + * area that is currently used by Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param storageArea The storage area. + * @param uuid The identifier of the file to be read. + * @param type The type of the file content. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaRead( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + OrthancPluginStorageArea* storageArea, + const char* uuid, + OrthancPluginContentType type) + { + _OrthancPluginStorageAreaRead params; + params.target = target; + params.storageArea = storageArea; + params.uuid = uuid; + params.type = type; + + return context->InvokeService(context, _OrthancPluginService_StorageAreaRead, ¶ms); + } + + + typedef struct + { + OrthancPluginStorageArea* storageArea; + const char* uuid; + OrthancPluginContentType type; + } _OrthancPluginStorageAreaRemove; + + /** + * @brief Remove a file from the storage area. + * + * This function removes a given file from the storage area that is + * currently used by Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param storageArea The storage area. + * @param uuid The identifier of the file to be removed. + * @param type The type of the file content. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginStorageAreaRemove( + OrthancPluginContext* context, + OrthancPluginStorageArea* storageArea, + const char* uuid, + OrthancPluginContentType type) + { + _OrthancPluginStorageAreaRemove params; + params.storageArea = storageArea; + params.uuid = uuid; + params.type = type; + + return context->InvokeService(context, _OrthancPluginService_StorageAreaRemove, ¶ms); + } + + + + typedef struct + { + OrthancPluginErrorCode* target; + int32_t code; + uint16_t httpStatus; + const char* message; + } _OrthancPluginRegisterErrorCode; + + /** + * @brief Declare a custom error code for this plugin. + * + * This function declares a custom error code that can be generated + * by this plugin. This declaration is used to enrich the body of + * the HTTP answer in the case of an error, and to set the proper + * HTTP status code. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param code The error code that is internal to this plugin. + * @param httpStatus The HTTP status corresponding to this error. + * @param message The description of the error. + * @return The error code that has been assigned inside the Orthanc core. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterErrorCode( + OrthancPluginContext* context, + int32_t code, + uint16_t httpStatus, + const char* message) + { + OrthancPluginErrorCode target; + + _OrthancPluginRegisterErrorCode params; + params.target = ⌖ + params.code = code; + params.httpStatus = httpStatus; + params.message = message; + + if (context->InvokeService(context, _OrthancPluginService_RegisterErrorCode, ¶ms) == OrthancPluginErrorCode_Success) + { + return target; + } + else + { + /* There was an error while assigned the error. Use a generic code. */ + return OrthancPluginErrorCode_Plugin; + } + } + + + + typedef struct + { + uint16_t group; + uint16_t element; + OrthancPluginValueRepresentation vr; + const char* name; + uint32_t minMultiplicity; + uint32_t maxMultiplicity; + } _OrthancPluginRegisterDictionaryTag; + + /** + * @brief Register a new tag into the DICOM dictionary. + * + * This function declares a new public tag in the dictionary of + * DICOM tags that are known to Orthanc. This function should be + * used in the OrthancPluginInitialize() callback. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param group The group of the tag. + * @param element The element of the tag. + * @param vr The value representation of the tag. + * @param name The nickname of the tag. + * @param minMultiplicity The minimum multiplicity of the tag (must be above 0). + * @param maxMultiplicity The maximum multiplicity of the tag. A value of 0 means + * an arbitrary multiplicity ("n"). + * @return 0 if success, other value if error. + * @see OrthancPluginRegisterPrivateDictionaryTag() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDictionaryTag( + OrthancPluginContext* context, + uint16_t group, + uint16_t element, + OrthancPluginValueRepresentation vr, + const char* name, + uint32_t minMultiplicity, + uint32_t maxMultiplicity) + { + _OrthancPluginRegisterDictionaryTag params; + params.group = group; + params.element = element; + params.vr = vr; + params.name = name; + params.minMultiplicity = minMultiplicity; + params.maxMultiplicity = maxMultiplicity; + + return context->InvokeService(context, _OrthancPluginService_RegisterDictionaryTag, ¶ms); + } + + + + typedef struct + { + uint16_t group; + uint16_t element; + OrthancPluginValueRepresentation vr; + const char* name; + uint32_t minMultiplicity; + uint32_t maxMultiplicity; + const char* privateCreator; + } _OrthancPluginRegisterPrivateDictionaryTag; + + /** + * @brief Register a new private tag into the DICOM dictionary. + * + * This function declares a new private tag in the dictionary of + * DICOM tags that are known to Orthanc. This function should be + * used in the OrthancPluginInitialize() callback. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param group The group of the tag. + * @param element The element of the tag. + * @param vr The value representation of the tag. + * @param name The nickname of the tag. + * @param minMultiplicity The minimum multiplicity of the tag (must be above 0). + * @param maxMultiplicity The maximum multiplicity of the tag. A value of 0 means + * an arbitrary multiplicity ("n"). + * @param privateCreator The private creator of this private tag. + * @return 0 if success, other value if error. + * @see OrthancPluginRegisterDictionaryTag() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterPrivateDictionaryTag( + OrthancPluginContext* context, + uint16_t group, + uint16_t element, + OrthancPluginValueRepresentation vr, + const char* name, + uint32_t minMultiplicity, + uint32_t maxMultiplicity, + const char* privateCreator) + { + _OrthancPluginRegisterPrivateDictionaryTag params; + params.group = group; + params.element = element; + params.vr = vr; + params.name = name; + params.minMultiplicity = minMultiplicity; + params.maxMultiplicity = maxMultiplicity; + params.privateCreator = privateCreator; + + return context->InvokeService(context, _OrthancPluginService_RegisterPrivateDictionaryTag, ¶ms); + } + + + + typedef struct + { + OrthancPluginStorageArea* storageArea; + OrthancPluginResourceType level; + } _OrthancPluginReconstructMainDicomTags; + + /** + * @brief Reconstruct the main DICOM tags. + * + * This function requests the Orthanc core to reconstruct the main + * DICOM tags of all the resources of the given type. This function + * can only be used as a part of the upgrade of a custom database + * back-end. A database transaction will be automatically setup. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param storageArea The storage area. + * @param level The type of the resources of interest. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginReconstructMainDicomTags( + OrthancPluginContext* context, + OrthancPluginStorageArea* storageArea, + OrthancPluginResourceType level) + { + _OrthancPluginReconstructMainDicomTags params; + params.level = level; + params.storageArea = storageArea; + + return context->InvokeService(context, _OrthancPluginService_ReconstructMainDicomTags, ¶ms); + } + + + typedef struct + { + char** result; + const char* instanceId; + const void* buffer; + uint32_t size; + OrthancPluginDicomToJsonFormat format; + OrthancPluginDicomToJsonFlags flags; + uint32_t maxStringLength; + } _OrthancPluginDicomToJson; + + + /** + * @brief Format a DICOM memory buffer as a JSON string. + * + * This function takes as input a memory buffer containing a DICOM + * file, and outputs a JSON string representing the tags of this + * DICOM file. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The memory buffer containing the DICOM file. + * @param size The size of the memory buffer. + * @param format The output format. + * @param flags Flags governing the output. + * @param maxStringLength The maximum length of a field. Too long fields will + * be output as "null". The 0 value means no maximum length. + * @return The NULL value if the case of an error, or the JSON + * string. This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + * @see OrthancPluginDicomInstanceToJson + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginDicomBufferToJson( + OrthancPluginContext* context, + const void* buffer, + uint32_t size, + OrthancPluginDicomToJsonFormat format, + OrthancPluginDicomToJsonFlags flags, + uint32_t maxStringLength) + { + char* result; + + _OrthancPluginDicomToJson params; + memset(¶ms, 0, sizeof(params)); + params.result = &result; + params.buffer = buffer; + params.size = size; + params.format = format; + params.flags = flags; + params.maxStringLength = maxStringLength; + + if (context->InvokeService(context, _OrthancPluginService_DicomBufferToJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Format a DICOM instance as a JSON string. + * + * This function formats a DICOM instance that is stored in Orthanc, + * and outputs a JSON string representing the tags of this DICOM + * instance. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instanceId The Orthanc identifier of the instance. + * @param format The output format. + * @param flags Flags governing the output. + * @param maxStringLength The maximum length of a field. Too long fields will + * be output as "null". The 0 value means no maximum length. + * @return The NULL value if the case of an error, or the JSON + * string. This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + * @see OrthancPluginDicomInstanceToJson + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginDicomInstanceToJson( + OrthancPluginContext* context, + const char* instanceId, + OrthancPluginDicomToJsonFormat format, + OrthancPluginDicomToJsonFlags flags, + uint32_t maxStringLength) + { + char* result; + + _OrthancPluginDicomToJson params; + memset(¶ms, 0, sizeof(params)); + params.result = &result; + params.instanceId = instanceId; + params.format = format; + params.flags = flags; + params.maxStringLength = maxStringLength; + + if (context->InvokeService(context, _OrthancPluginService_DicomInstanceToJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* uri; + uint32_t headersCount; + const char* const* headersKeys; + const char* const* headersValues; + int32_t afterPlugins; + } _OrthancPluginRestApiGet2; + + /** + * @brief Make a GET call to the Orthanc REST API, with custom HTTP headers. + * + * Make a GET call to the Orthanc REST API with extended + * parameters. The result to the query is stored into a newly + * allocated memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param uri The URI in the built-in Orthanc API. + * @param headersCount The number of HTTP headers. + * @param headersKeys Array containing the keys of the HTTP headers (can be NULL if no header). + * @param headersValues Array containing the values of the HTTP headers (can be NULL if no header). + * @param afterPlugins If 0, the built-in API of Orthanc is used. + * If 1, the API is tainted by the plugins. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginRestApiGet, OrthancPluginRestApiGetAfterPlugins + * @ingroup Orthanc + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGet2( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* uri, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues, + int32_t afterPlugins) + { + _OrthancPluginRestApiGet2 params; + params.target = target; + params.uri = uri; + params.headersCount = headersCount; + params.headersKeys = headersKeys; + params.headersValues = headersValues; + params.afterPlugins = afterPlugins; + + return context->InvokeService(context, _OrthancPluginService_RestApiGet2, ¶ms); + } + + + + typedef struct + { + OrthancPluginWorklistCallback callback; + } _OrthancPluginWorklistCallback; + + /** + * @brief Register a callback to handle modality worklists requests. + * + * This function registers a callback to handle C-Find SCP requests + * on modality worklists. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterWorklistCallback( + OrthancPluginContext* context, + OrthancPluginWorklistCallback callback) + { + _OrthancPluginWorklistCallback params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterWorklistCallback, ¶ms); + } + + + + typedef struct + { + OrthancPluginWorklistAnswers* answers; + const OrthancPluginWorklistQuery* query; + const void* dicom; + uint32_t size; + } _OrthancPluginWorklistAnswersOperation; + + /** + * @brief Add one answer to some modality worklist request. + * + * This function adds one worklist (encoded as a DICOM file) to the + * set of answers corresponding to some C-Find SCP request against + * modality worklists. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answers The set of answers. + * @param query The worklist query, as received by the callback. + * @param dicom The worklist to answer, encoded as a DICOM file. + * @param size The size of the DICOM file. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + * @see OrthancPluginCreateDicom() + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistAddAnswer( + OrthancPluginContext* context, + OrthancPluginWorklistAnswers* answers, + const OrthancPluginWorklistQuery* query, + const void* dicom, + uint32_t size) + { + _OrthancPluginWorklistAnswersOperation params; + params.answers = answers; + params.query = query; + params.dicom = dicom; + params.size = size; + + return context->InvokeService(context, _OrthancPluginService_WorklistAddAnswer, ¶ms); + } + + + /** + * @brief Mark the set of worklist answers as incomplete. + * + * This function marks as incomplete the set of answers + * corresponding to some C-Find SCP request against modality + * worklists. This must be used if canceling the handling of a + * request when too many answers are to be returned. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answers The set of answers. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistMarkIncomplete( + OrthancPluginContext* context, + OrthancPluginWorklistAnswers* answers) + { + _OrthancPluginWorklistAnswersOperation params; + params.answers = answers; + params.query = NULL; + params.dicom = NULL; + params.size = 0; + + return context->InvokeService(context, _OrthancPluginService_WorklistMarkIncomplete, ¶ms); + } + + + typedef struct + { + const OrthancPluginWorklistQuery* query; + const void* dicom; + uint32_t size; + int32_t* isMatch; + OrthancPluginMemoryBuffer* target; + } _OrthancPluginWorklistQueryOperation; + + /** + * @brief Test whether a worklist matches the query. + * + * This function checks whether one worklist (encoded as a DICOM + * file) matches the C-Find SCP query against modality + * worklists. This function must be called before adding the + * worklist as an answer through OrthancPluginWorklistAddAnswer(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param query The worklist query, as received by the callback. + * @param dicom The worklist to answer, encoded as a DICOM file. + * @param size The size of the DICOM file. + * @return 1 if the worklist matches the query, 0 otherwise. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE int32_t OrthancPluginWorklistIsMatch( + OrthancPluginContext* context, + const OrthancPluginWorklistQuery* query, + const void* dicom, + uint32_t size) + { + int32_t isMatch = 0; + + _OrthancPluginWorklistQueryOperation params; + params.query = query; + params.dicom = dicom; + params.size = size; + params.isMatch = &isMatch; + params.target = NULL; + + if (context->InvokeService(context, _OrthancPluginService_WorklistIsMatch, ¶ms) == OrthancPluginErrorCode_Success) + { + return isMatch; + } + else + { + /* Error: Assume non-match */ + return 0; + } + } + + + /** + * @brief Retrieve the worklist query as a DICOM file. + * + * This function retrieves the DICOM file that underlies a C-Find + * SCP query against modality worklists. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target Memory buffer where to store the DICOM file. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param query The worklist query, as received by the callback. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistGetDicomQuery( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const OrthancPluginWorklistQuery* query) + { + _OrthancPluginWorklistQueryOperation params; + params.query = query; + params.dicom = NULL; + params.size = 0; + params.isMatch = NULL; + params.target = target; + + return context->InvokeService(context, _OrthancPluginService_WorklistGetDicomQuery, ¶ms); + } + + + /** + * @brief Get the origin of a DICOM file. + * + * This function returns the origin of a DICOM instance that has been received by Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The origin of the instance. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginInstanceOrigin OrthancPluginGetInstanceOrigin( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + OrthancPluginInstanceOrigin origin; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultOrigin = &origin; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceOrigin, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return OrthancPluginInstanceOrigin_Unknown; + } + else + { + return origin; + } + } + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + const char* json; + const OrthancPluginImage* pixelData; + OrthancPluginCreateDicomFlags flags; + } _OrthancPluginCreateDicom; + + /** + * @brief Create a DICOM instance from a JSON string and an image. + * + * This function takes as input a string containing a JSON file + * describing the content of a DICOM instance. As an output, it + * writes the corresponding DICOM instance to a newly allocated + * memory buffer. Additionally, an image to be encoded within the + * DICOM instance can also be provided. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param json The input JSON file. + * @param pixelData The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme. + * @param flags Flags governing the output. + * @return 0 if success, other value if error. + * @ingroup Toolbox + * @see OrthancPluginDicomBufferToJson + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateDicom( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const char* json, + const OrthancPluginImage* pixelData, + OrthancPluginCreateDicomFlags flags) + { + _OrthancPluginCreateDicom params; + params.target = target; + params.json = json; + params.pixelData = pixelData; + params.flags = flags; + + return context->InvokeService(context, _OrthancPluginService_CreateDicom, ¶ms); + } + + + typedef struct + { + OrthancPluginDecodeImageCallback callback; + } _OrthancPluginDecodeImageCallback; + + /** + * @brief Register a callback to handle the decoding of DICOM images. + * + * This function registers a custom callback to decode DICOM images, + * extending the built-in decoder of Orthanc that uses + * DCMTK. Starting with Orthanc 1.7.0, the exact behavior is + * affected by the configuration option + * "BuiltinDecoderTranscoderOrder" of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDecodeImageCallback( + OrthancPluginContext* context, + OrthancPluginDecodeImageCallback callback) + { + _OrthancPluginDecodeImageCallback params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterDecodeImageCallback, ¶ms); + } + + + + typedef struct + { + OrthancPluginImage** target; + OrthancPluginPixelFormat format; + uint32_t width; + uint32_t height; + uint32_t pitch; + void* buffer; + const void* constBuffer; + uint32_t bufferSize; + uint32_t frameIndex; + } _OrthancPluginCreateImage; + + + /** + * @brief Create an image. + * + * This function creates an image of given size and format. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param format The format of the pixels. + * @param width The width of the image. + * @param height The height of the image. + * @return The newly allocated image. It must be freed with OrthancPluginFreeImage(). + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginCreateImage( + OrthancPluginContext* context, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginCreateImage params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.format = format; + params.width = width; + params.height = height; + + if (context->InvokeService(context, _OrthancPluginService_CreateImage, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Create an image pointing to a memory buffer. + * + * This function creates an image whose content points to a memory + * buffer managed by the plugin. Note that the buffer is directly + * accessed, no memory is allocated and no data is copied. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param format The format of the pixels. + * @param width The width of the image. + * @param height The height of the image. + * @param pitch The pitch of the image (i.e. the number of bytes + * between 2 successive lines of the image in the memory buffer). + * @param buffer The memory buffer. + * @return The newly allocated image. It must be freed with OrthancPluginFreeImage(). + * @ingroup Images + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginCreateImageAccessor( + OrthancPluginContext* context, + OrthancPluginPixelFormat format, + uint32_t width, + uint32_t height, + uint32_t pitch, + void* buffer) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginCreateImage params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.format = format; + params.width = width; + params.height = height; + params.pitch = pitch; + params.buffer = buffer; + + if (context->InvokeService(context, _OrthancPluginService_CreateImageAccessor, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + + /** + * @brief Decode one frame from a DICOM instance. + * + * This function decodes one frame of a DICOM image that is stored + * in a memory buffer. This function will give the same result as + * OrthancPluginUncompressImage() for single-frame DICOM images. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer Pointer to a memory buffer containing the DICOM image. + * @param bufferSize Size of the memory buffer containing the DICOM image. + * @param frameIndex The index of the frame of interest in a multi-frame image. + * @return The uncompressed image. It must be freed with OrthancPluginFreeImage(). + * @ingroup Images + * @see OrthancPluginGetInstanceDecodedFrame() + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginDecodeDicomImage( + OrthancPluginContext* context, + const void* buffer, + uint32_t bufferSize, + uint32_t frameIndex) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginCreateImage params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.constBuffer = buffer; + params.bufferSize = bufferSize; + params.frameIndex = frameIndex; + + if (context->InvokeService(context, _OrthancPluginService_DecodeDicomImage, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + + typedef struct + { + char** result; + const void* buffer; + uint32_t size; + } _OrthancPluginComputeHash; + + /** + * @brief Compute an MD5 hash. + * + * This functions computes the MD5 cryptographic hash of the given memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The source memory buffer. + * @param size The size in bytes of the source buffer. + * @return The NULL value in case of error, or a string containing the cryptographic hash. + * This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginComputeMd5( + OrthancPluginContext* context, + const void* buffer, + uint32_t size) + { + char* result; + + _OrthancPluginComputeHash params; + params.result = &result; + params.buffer = buffer; + params.size = size; + + if (context->InvokeService(context, _OrthancPluginService_ComputeMd5, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Compute a SHA-1 hash. + * + * This functions computes the SHA-1 cryptographic hash of the given memory buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The source memory buffer. + * @param size The size in bytes of the source buffer. + * @return The NULL value in case of error, or a string containing the cryptographic hash. + * This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginComputeSha1( + OrthancPluginContext* context, + const void* buffer, + uint32_t size) + { + char* result; + + _OrthancPluginComputeHash params; + params.result = &result; + params.buffer = buffer; + params.size = size; + + if (context->InvokeService(context, _OrthancPluginService_ComputeSha1, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + OrthancPluginDictionaryEntry* target; + const char* name; + } _OrthancPluginLookupDictionary; + + /** + * @brief Get information about the given DICOM tag. + * + * This functions makes a lookup in the dictionary of DICOM tags + * that are known to Orthanc, and returns information about this + * tag. The tag can be specified using its human-readable name + * (e.g. "PatientName") or a set of two hexadecimal numbers + * (e.g. "0010-0020"). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target Where to store the information about the tag. + * @param name The name of the DICOM tag. + * @return 0 if success, other value if error. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginLookupDictionary( + OrthancPluginContext* context, + OrthancPluginDictionaryEntry* target, + const char* name) + { + _OrthancPluginLookupDictionary params; + params.target = target; + params.name = name; + return context->InvokeService(context, _OrthancPluginService_LookupDictionary, ¶ms); + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + const void* answer; + uint32_t answerSize; + uint32_t headersCount; + const char* const* headersKeys; + const char* const* headersValues; + } _OrthancPluginSendMultipartItem2; + + /** + * @brief Send an item as a part of some HTTP multipart answer, with custom headers. + * + * This function sends an item as a part of some HTTP multipart + * answer that was initiated by OrthancPluginStartMultipartAnswer(). In addition to + * OrthancPluginSendMultipartItem(), this function will set HTTP header associated + * with the item. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param answer Pointer to the memory buffer containing the item. + * @param answerSize Number of bytes of the item. + * @param headersCount The number of HTTP headers. + * @param headersKeys Array containing the keys of the HTTP headers. + * @param headersValues Array containing the values of the HTTP headers. + * @return 0 if success, or the error code if failure (this notably happens + * if the connection is closed by the client). + * @see OrthancPluginSendMultipartItem() + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSendMultipartItem2( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const void* answer, + uint32_t answerSize, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues) + { + _OrthancPluginSendMultipartItem2 params; + params.output = output; + params.answer = answer; + params.answerSize = answerSize; + params.headersCount = headersCount; + params.headersKeys = headersKeys; + params.headersValues = headersValues; + + return context->InvokeService(context, _OrthancPluginService_SendMultipartItem2, ¶ms); + } + + + typedef struct + { + OrthancPluginIncomingHttpRequestFilter callback; + } _OrthancPluginIncomingHttpRequestFilter; + + /** + * @brief Register a callback to filter incoming HTTP requests. + * + * This function registers a custom callback to filter incoming HTTP/REST + * requests received by the HTTP server of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + * @deprecated Please instead use OrthancPluginRegisterIncomingHttpRequestFilter2() + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingHttpRequestFilter( + OrthancPluginContext* context, + OrthancPluginIncomingHttpRequestFilter callback) + { + _OrthancPluginIncomingHttpRequestFilter params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterIncomingHttpRequestFilter, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* answerBody; + OrthancPluginMemoryBuffer* answerHeaders; + uint16_t* httpStatus; + OrthancPluginHttpMethod method; + const char* url; + uint32_t headersCount; + const char* const* headersKeys; + const char* const* headersValues; + const void* body; + uint32_t bodySize; + const char* username; + const char* password; + uint32_t timeout; + const char* certificateFile; + const char* certificateKeyFile; + const char* certificateKeyPassword; + uint8_t pkcs11; + } _OrthancPluginCallHttpClient2; + + + + /** + * @brief Issue a HTTP call with full flexibility. + * + * Make a HTTP call to the given URL. The result to the query is + * stored into a newly allocated memory buffer. The HTTP request + * will be done accordingly to the global configuration of Orthanc + * (in particular, the options "HttpProxy", "HttpTimeout", + * "HttpsVerifyPeers", "HttpsCACertificates", and "Pkcs11" will be + * taken into account). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answerBody The target memory buffer (out argument). + * It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param answerHeaders The target memory buffer for the HTTP headers in the answers (out argument). + * The answer headers are formatted as a JSON object (associative array). + * The buffer must be freed with OrthancPluginFreeMemoryBuffer(). + * This argument can be set to NULL if the plugin has no interest in the HTTP headers. + * @param httpStatus The HTTP status after the execution of the request (out argument). + * @param method HTTP method to be used. + * @param url The URL of interest. + * @param headersCount The number of HTTP headers. + * @param headersKeys Array containing the keys of the HTTP headers (can be NULL if no header). + * @param headersValues Array containing the values of the HTTP headers (can be NULL if no header). + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @param body The HTTP body for a POST or PUT request. + * @param bodySize The size of the body. + * @param timeout Timeout in seconds (0 for default timeout). + * @param certificateFile Path to the client certificate for HTTPS, in PEM format + * (can be NULL if no client certificate or if not using HTTPS). + * @param certificateKeyFile Path to the key of the client certificate for HTTPS, in PEM format + * (can be NULL if no client certificate or if not using HTTPS). + * @param certificateKeyPassword Password to unlock the key of the client certificate + * (can be NULL if no client certificate or if not using HTTPS). + * @param pkcs11 Enable PKCS#11 client authentication for hardware security modules and smart cards. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginCallPeerApi() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginHttpClient( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* answerBody, + OrthancPluginMemoryBuffer* answerHeaders, + uint16_t* httpStatus, + OrthancPluginHttpMethod method, + const char* url, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues, + const void* body, + uint32_t bodySize, + const char* username, + const char* password, + uint32_t timeout, + const char* certificateFile, + const char* certificateKeyFile, + const char* certificateKeyPassword, + uint8_t pkcs11) + { + _OrthancPluginCallHttpClient2 params; + memset(¶ms, 0, sizeof(params)); + + params.answerBody = answerBody; + params.answerHeaders = answerHeaders; + params.httpStatus = httpStatus; + params.method = method; + params.url = url; + params.headersCount = headersCount; + params.headersKeys = headersKeys; + params.headersValues = headersValues; + params.body = body; + params.bodySize = bodySize; + params.username = username; + params.password = password; + params.timeout = timeout; + params.certificateFile = certificateFile; + params.certificateKeyFile = certificateKeyFile; + params.certificateKeyPassword = certificateKeyPassword; + params.pkcs11 = pkcs11; + + return context->InvokeService(context, _OrthancPluginService_CallHttpClient2, ¶ms); + } + + + /** + * @brief Generate an UUID. + * + * Generate a random GUID/UUID (globally unique identifier). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL in the case of an error, or a newly allocated string + * containing the UUID. This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGenerateUuid( + OrthancPluginContext* context) + { + char* result; + + _OrthancPluginRetrieveDynamicString params; + params.result = &result; + params.argument = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GenerateUuid, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + + typedef struct + { + OrthancPluginFindCallback callback; + } _OrthancPluginFindCallback; + + /** + * @brief Register a callback to handle C-Find requests. + * + * This function registers a callback to handle C-Find SCP requests + * that are not related to modality worklists. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterFindCallback( + OrthancPluginContext* context, + OrthancPluginFindCallback callback) + { + _OrthancPluginFindCallback params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterFindCallback, ¶ms); + } + + + typedef struct + { + OrthancPluginFindAnswers *answers; + const OrthancPluginFindQuery *query; + const void *dicom; + uint32_t size; + uint32_t index; + uint32_t *resultUint32; + uint16_t *resultGroup; + uint16_t *resultElement; + char **resultString; + } _OrthancPluginFindOperation; + + /** + * @brief Add one answer to some C-Find request. + * + * This function adds one answer (encoded as a DICOM file) to the + * set of answers corresponding to some C-Find SCP request that is + * not related to modality worklists. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answers The set of answers. + * @param dicom The answer to be added, encoded as a DICOM file. + * @param size The size of the DICOM file. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + * @see OrthancPluginCreateDicom() + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginFindAddAnswer( + OrthancPluginContext* context, + OrthancPluginFindAnswers* answers, + const void* dicom, + uint32_t size) + { + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.answers = answers; + params.dicom = dicom; + params.size = size; + + return context->InvokeService(context, _OrthancPluginService_FindAddAnswer, ¶ms); + } + + + /** + * @brief Mark the set of C-Find answers as incomplete. + * + * This function marks as incomplete the set of answers + * corresponding to some C-Find SCP request that is not related to + * modality worklists. This must be used if canceling the handling + * of a request when too many answers are to be returned. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answers The set of answers. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginFindMarkIncomplete( + OrthancPluginContext* context, + OrthancPluginFindAnswers* answers) + { + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.answers = answers; + + return context->InvokeService(context, _OrthancPluginService_FindMarkIncomplete, ¶ms); + } + + + + /** + * @brief Get the number of tags in a C-Find query. + * + * This function returns the number of tags that are contained in + * the given C-Find query. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param query The C-Find query. + * @return The number of tags. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetFindQuerySize( + OrthancPluginContext* context, + const OrthancPluginFindQuery* query) + { + uint32_t count = 0; + + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.query = query; + params.resultUint32 = &count; + + if (context->InvokeService(context, _OrthancPluginService_GetFindQuerySize, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return count; + } + } + + + /** + * @brief Get one tag in a C-Find query. + * + * This function returns the group and the element of one DICOM tag + * in the given C-Find query. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param group The group of the tag (output). + * @param element The element of the tag (output). + * @param query The C-Find query. + * @param index The index of the tag of interest. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetFindQueryTag( + OrthancPluginContext* context, + uint16_t* group, + uint16_t* element, + const OrthancPluginFindQuery* query, + uint32_t index) + { + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.query = query; + params.index = index; + params.resultGroup = group; + params.resultElement = element; + + return context->InvokeService(context, _OrthancPluginService_GetFindQueryTag, ¶ms); + } + + + /** + * @brief Get the symbolic name of one tag in a C-Find query. + * + * This function returns the symbolic name of one DICOM tag in the + * given C-Find query. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param query The C-Find query. + * @param index The index of the tag of interest. + * @return The NULL value in case of error, or a string containing the name of the tag. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetFindQueryTagName( + OrthancPluginContext* context, + const OrthancPluginFindQuery* query, + uint32_t index) + { + char* result; + + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.query = query; + params.index = index; + params.resultString = &result; + + if (context->InvokeService(context, _OrthancPluginService_GetFindQueryTagName, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Get the value associated with one tag in a C-Find query. + * + * This function returns the value associated with one tag in the + * given C-Find query. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param query The C-Find query. + * @param index The index of the tag of interest. + * @return The NULL value in case of error, or a string containing the value of the tag. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetFindQueryValue( + OrthancPluginContext* context, + const OrthancPluginFindQuery* query, + uint32_t index) + { + char* result; + + _OrthancPluginFindOperation params; + memset(¶ms, 0, sizeof(params)); + params.query = query; + params.index = index; + params.resultString = &result; + + if (context->InvokeService(context, _OrthancPluginService_GetFindQueryValue, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + + typedef struct + { + OrthancPluginMoveCallback callback; + OrthancPluginGetMoveSize getMoveSize; + OrthancPluginApplyMove applyMove; + OrthancPluginFreeMove freeMove; + } _OrthancPluginMoveCallback; + + /** + * @brief Register a callback to handle C-Move requests. + * + * This function registers a callback to handle C-Move SCP requests. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The main callback. + * @param getMoveSize Callback to read the number of C-Move suboperations. + * @param applyMove Callback to apply one C-Move suboperation. + * @param freeMove Callback to free the C-Move driver. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterMoveCallback( + OrthancPluginContext* context, + OrthancPluginMoveCallback callback, + OrthancPluginGetMoveSize getMoveSize, + OrthancPluginApplyMove applyMove, + OrthancPluginFreeMove freeMove) + { + _OrthancPluginMoveCallback params; + params.callback = callback; + params.getMoveSize = getMoveSize; + params.applyMove = applyMove; + params.freeMove = freeMove; + + return context->InvokeService(context, _OrthancPluginService_RegisterMoveCallback, ¶ms); + } + + + + typedef struct + { + OrthancPluginFindMatcher** target; + const void* query; + uint32_t size; + } _OrthancPluginCreateFindMatcher; + + + /** + * @brief Create a C-Find matcher. + * + * This function creates a "matcher" object that can be used to + * check whether a DICOM instance matches a C-Find query. The C-Find + * query must be expressed as a DICOM buffer. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param query The C-Find DICOM query. + * @param size The size of the DICOM query. + * @return The newly allocated matcher. It must be freed with OrthancPluginFreeFindMatcher(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginFindMatcher* OrthancPluginCreateFindMatcher( + OrthancPluginContext* context, + const void* query, + uint32_t size) + { + OrthancPluginFindMatcher* target = NULL; + + _OrthancPluginCreateFindMatcher params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.query = query; + params.size = size; + + if (context->InvokeService(context, _OrthancPluginService_CreateFindMatcher, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + typedef struct + { + OrthancPluginFindMatcher* matcher; + } _OrthancPluginFreeFindMatcher; + + /** + * @brief Free a C-Find matcher. + * + * This function frees a matcher that was created using OrthancPluginCreateFindMatcher(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param matcher The matcher of interest. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeFindMatcher( + OrthancPluginContext* context, + OrthancPluginFindMatcher* matcher) + { + _OrthancPluginFreeFindMatcher params; + params.matcher = matcher; + + context->InvokeService(context, _OrthancPluginService_FreeFindMatcher, ¶ms); + } + + + typedef struct + { + const OrthancPluginFindMatcher* matcher; + const void* dicom; + uint32_t size; + int32_t* isMatch; + } _OrthancPluginFindMatcherIsMatch; + + /** + * @brief Test whether a DICOM instance matches a C-Find query. + * + * This function checks whether one DICOM instance matches C-Find + * matcher that was previously allocated using + * OrthancPluginCreateFindMatcher(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param matcher The matcher of interest. + * @param dicom The DICOM instance to be matched. + * @param size The size of the DICOM instance. + * @return 1 if the DICOM instance matches the query, 0 otherwise. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE int32_t OrthancPluginFindMatcherIsMatch( + OrthancPluginContext* context, + const OrthancPluginFindMatcher* matcher, + const void* dicom, + uint32_t size) + { + int32_t isMatch = 0; + + _OrthancPluginFindMatcherIsMatch params; + params.matcher = matcher; + params.dicom = dicom; + params.size = size; + params.isMatch = &isMatch; + + if (context->InvokeService(context, _OrthancPluginService_FindMatcherIsMatch, ¶ms) == OrthancPluginErrorCode_Success) + { + return isMatch; + } + else + { + /* Error: Assume non-match */ + return 0; + } + } + + + typedef struct + { + OrthancPluginIncomingHttpRequestFilter2 callback; + } _OrthancPluginIncomingHttpRequestFilter2; + + /** + * @brief Register a callback to filter incoming HTTP requests. + * + * This function registers a custom callback to filter incoming HTTP/REST + * requests received by the HTTP server of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingHttpRequestFilter2( + OrthancPluginContext* context, + OrthancPluginIncomingHttpRequestFilter2 callback) + { + _OrthancPluginIncomingHttpRequestFilter2 params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterIncomingHttpRequestFilter2, ¶ms); + } + + + + typedef struct + { + OrthancPluginPeers** peers; + } _OrthancPluginGetPeers; + + /** + * @brief Return the list of available Orthanc peers. + * + * This function returns the parameters of the Orthanc peers that are known to + * the Orthanc server hosting the plugin. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @return NULL if error, or a newly allocated opaque data structure containing the peers. + * This structure must be freed with OrthancPluginFreePeers(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginPeers* OrthancPluginGetPeers( + OrthancPluginContext* context) + { + OrthancPluginPeers* peers = NULL; + + _OrthancPluginGetPeers params; + memset(¶ms, 0, sizeof(params)); + params.peers = &peers; + + if (context->InvokeService(context, _OrthancPluginService_GetPeers, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return peers; + } + } + + + typedef struct + { + OrthancPluginPeers* peers; + } _OrthancPluginFreePeers; + + /** + * @brief Free the list of available Orthanc peers. + * + * This function frees the data structure returned by OrthancPluginGetPeers(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param peers The data structure describing the Orthanc peers. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreePeers( + OrthancPluginContext* context, + OrthancPluginPeers* peers) + { + _OrthancPluginFreePeers params; + params.peers = peers; + + context->InvokeService(context, _OrthancPluginService_FreePeers, ¶ms); + } + + + typedef struct + { + uint32_t* target; + const OrthancPluginPeers* peers; + } _OrthancPluginGetPeersCount; + + /** + * @brief Get the number of Orthanc peers. + * + * This function returns the number of Orthanc peers. + * + * This function is thread-safe: Several threads sharing the same + * OrthancPluginPeers object can simultaneously call this function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param peers The data structure describing the Orthanc peers. + * @result The number of peers. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetPeersCount( + OrthancPluginContext* context, + const OrthancPluginPeers* peers) + { + uint32_t target = 0; + + _OrthancPluginGetPeersCount params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.peers = peers; + + if (context->InvokeService(context, _OrthancPluginService_GetPeersCount, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return target; + } + } + + + typedef struct + { + const char** target; + const OrthancPluginPeers* peers; + uint32_t peerIndex; + const char* userProperty; + } _OrthancPluginGetPeerProperty; + + /** + * @brief Get the symbolic name of an Orthanc peer. + * + * This function returns the symbolic name of the Orthanc peer, + * which corresponds to the key of the "OrthancPeers" configuration + * option of Orthanc. + * + * This function is thread-safe: Several threads sharing the same + * OrthancPluginPeers object can simultaneously call this function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param peers The data structure describing the Orthanc peers. + * @param peerIndex The index of the peer of interest. + * This value must be lower than OrthancPluginGetPeersCount(). + * @result The symbolic name, or NULL in the case of an error. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetPeerName( + OrthancPluginContext* context, + const OrthancPluginPeers* peers, + uint32_t peerIndex) + { + const char* target = NULL; + + _OrthancPluginGetPeerProperty params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.peers = peers; + params.peerIndex = peerIndex; + params.userProperty = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetPeerName, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Get the base URL of an Orthanc peer. + * + * This function returns the base URL to the REST API of some Orthanc peer. + * + * This function is thread-safe: Several threads sharing the same + * OrthancPluginPeers object can simultaneously call this function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param peers The data structure describing the Orthanc peers. + * @param peerIndex The index of the peer of interest. + * This value must be lower than OrthancPluginGetPeersCount(). + * @result The URL, or NULL in the case of an error. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetPeerUrl( + OrthancPluginContext* context, + const OrthancPluginPeers* peers, + uint32_t peerIndex) + { + const char* target = NULL; + + _OrthancPluginGetPeerProperty params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.peers = peers; + params.peerIndex = peerIndex; + params.userProperty = NULL; + + if (context->InvokeService(context, _OrthancPluginService_GetPeerUrl, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + + /** + * @brief Get some user-defined property of an Orthanc peer. + * + * This function returns some user-defined property of some Orthanc + * peer. An user-defined property is a property that is associated + * with the peer in the Orthanc configuration file, but that is not + * recognized by the Orthanc core. + * + * This function is thread-safe: Several threads sharing the same + * OrthancPluginPeers object can simultaneously call this function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param peers The data structure describing the Orthanc peers. + * @param peerIndex The index of the peer of interest. + * This value must be lower than OrthancPluginGetPeersCount(). + * @param userProperty The user property of interest. + * @result The value of the user property, or NULL if it is not defined. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginGetPeerUserProperty( + OrthancPluginContext* context, + const OrthancPluginPeers* peers, + uint32_t peerIndex, + const char* userProperty) + { + const char* target = NULL; + + _OrthancPluginGetPeerProperty params; + memset(¶ms, 0, sizeof(params)); + params.target = ⌖ + params.peers = peers; + params.peerIndex = peerIndex; + params.userProperty = userProperty; + + if (context->InvokeService(context, _OrthancPluginService_GetPeerUserProperty, ¶ms) != OrthancPluginErrorCode_Success) + { + /* No such user property */ + return NULL; + } + else + { + return target; + } + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* answerBody; + OrthancPluginMemoryBuffer* answerHeaders; + uint16_t* httpStatus; + const OrthancPluginPeers* peers; + uint32_t peerIndex; + OrthancPluginHttpMethod method; + const char* uri; + uint32_t additionalHeadersCount; + const char* const* additionalHeadersKeys; + const char* const* additionalHeadersValues; + const void* body; + uint32_t bodySize; + uint32_t timeout; + } _OrthancPluginCallPeerApi; + + /** + * @brief Call the REST API of an Orthanc peer. + * + * Make a REST call to the given URI in the REST API of a remote + * Orthanc peer. The result to the query is stored into a newly + * allocated memory buffer. The HTTP request will be done according + * to the "OrthancPeers" configuration option of Orthanc. + * + * This function is thread-safe: Several threads sharing the same + * OrthancPluginPeers object can simultaneously call this function. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answerBody The target memory buffer (out argument). + * It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param answerHeaders The target memory buffer for the HTTP headers in the answers (out argument). + * The answer headers are formatted as a JSON object (associative array). + * The buffer must be freed with OrthancPluginFreeMemoryBuffer(). + * This argument can be set to NULL if the plugin has no interest in the HTTP headers. + * @param httpStatus The HTTP status after the execution of the request (out argument). + * @param peers The data structure describing the Orthanc peers. + * @param peerIndex The index of the peer of interest. + * This value must be lower than OrthancPluginGetPeersCount(). + * @param method HTTP method to be used. + * @param uri The URI of interest in the REST API. + * @param additionalHeadersCount The number of HTTP headers to be added to the + * HTTP headers provided in the global configuration of Orthanc. + * @param additionalHeadersKeys Array containing the keys of the HTTP headers (can be NULL if no header). + * @param additionalHeadersValues Array containing the values of the HTTP headers (can be NULL if no header). + * @param body The HTTP body for a POST or PUT request. + * @param bodySize The size of the body. + * @param timeout Timeout in seconds (0 for default timeout). + * @return 0 if success, or the error code if failure. + * @see OrthancPluginHttpClient() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCallPeerApi( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* answerBody, + OrthancPluginMemoryBuffer* answerHeaders, + uint16_t* httpStatus, + const OrthancPluginPeers* peers, + uint32_t peerIndex, + OrthancPluginHttpMethod method, + const char* uri, + uint32_t additionalHeadersCount, + const char* const* additionalHeadersKeys, + const char* const* additionalHeadersValues, + const void* body, + uint32_t bodySize, + uint32_t timeout) + { + _OrthancPluginCallPeerApi params; + memset(¶ms, 0, sizeof(params)); + + params.answerBody = answerBody; + params.answerHeaders = answerHeaders; + params.httpStatus = httpStatus; + params.peers = peers; + params.peerIndex = peerIndex; + params.method = method; + params.uri = uri; + params.additionalHeadersCount = additionalHeadersCount; + params.additionalHeadersKeys = additionalHeadersKeys; + params.additionalHeadersValues = additionalHeadersValues; + params.body = body; + params.bodySize = bodySize; + params.timeout = timeout; + + return context->InvokeService(context, _OrthancPluginService_CallPeerApi, ¶ms); + } + + + + + + typedef struct + { + OrthancPluginJob** target; + void *job; + OrthancPluginJobFinalize finalize; + const char *type; + OrthancPluginJobGetProgress getProgress; + OrthancPluginJobGetContent getContent; + OrthancPluginJobGetSerialized getSerialized; + OrthancPluginJobStep step; + OrthancPluginJobStop stop; + OrthancPluginJobReset reset; + } _OrthancPluginCreateJob; + + /** + * @brief Create a custom job. + * + * This function creates a custom job to be run by the jobs engine + * of Orthanc. + * + * Orthanc starts one dedicated thread per custom job that is + * running. It is guaranteed that all the callbacks will only be + * called from this single dedicated thread, in mutual exclusion: As + * a consequence, it is *not* mandatory to protect the various + * callbacks by mutexes. + * + * The custom job can nonetheless launch its own processing threads + * on the first call to the "step()" callback, and stop them once + * the "stop()" callback is called. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param job The job to be executed. + * @param finalize The finalization callback. + * @param type The type of the job, provided to the job unserializer. + * See OrthancPluginRegisterJobsUnserializer(). + * @param getProgress The progress callback. + * @param getContent The content callback. + * @param getSerialized The serialization callback. + * @param step The callback to execute the individual steps of the job. + * @param stop The callback that is invoked once the job leaves the "running" state. + * @param reset The callback that is invoked if a stopped job is started again. + * @return The newly allocated job. It must be freed with OrthancPluginFreeJob(), + * as long as it is not submitted with OrthancPluginSubmitJob(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginJob *OrthancPluginCreateJob( + OrthancPluginContext *context, + void *job, + OrthancPluginJobFinalize finalize, + const char *type, + OrthancPluginJobGetProgress getProgress, + OrthancPluginJobGetContent getContent, + OrthancPluginJobGetSerialized getSerialized, + OrthancPluginJobStep step, + OrthancPluginJobStop stop, + OrthancPluginJobReset reset) + { + OrthancPluginJob* target = NULL; + + _OrthancPluginCreateJob params; + memset(¶ms, 0, sizeof(params)); + + params.target = ⌖ + params.job = job; + params.finalize = finalize; + params.type = type; + params.getProgress = getProgress; + params.getContent = getContent; + params.getSerialized = getSerialized; + params.step = step; + params.stop = stop; + params.reset = reset; + + if (context->InvokeService(context, _OrthancPluginService_CreateJob, ¶ms) != OrthancPluginErrorCode_Success || + target == NULL) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + typedef struct + { + OrthancPluginJob* job; + } _OrthancPluginFreeJob; + + /** + * @brief Free a custom job. + * + * This function frees an image that was created with OrthancPluginCreateJob(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param job The job. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeJob( + OrthancPluginContext* context, + OrthancPluginJob* job) + { + _OrthancPluginFreeJob params; + params.job = job; + + context->InvokeService(context, _OrthancPluginService_FreeJob, ¶ms); + } + + + + typedef struct + { + char** resultId; + OrthancPluginJob *job; + int priority; + } _OrthancPluginSubmitJob; + + /** + * @brief Submit a new job to the jobs engine of Orthanc. + * + * This function adds the given job to the pending jobs of + * Orthanc. Orthanc will take take of freeing it by invoking the + * finalization callback provided to OrthancPluginCreateJob(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param job The job, as received by OrthancPluginCreateJob(). + * @param priority The priority of the job. + * @return ID of the newly-submitted job. This string must be freed by OrthancPluginFreeString(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char *OrthancPluginSubmitJob( + OrthancPluginContext *context, + OrthancPluginJob *job, + int priority) + { + char* resultId = NULL; + + _OrthancPluginSubmitJob params; + memset(¶ms, 0, sizeof(params)); + + params.resultId = &resultId; + params.job = job; + params.priority = priority; + + if (context->InvokeService(context, _OrthancPluginService_SubmitJob, ¶ms) != OrthancPluginErrorCode_Success || + resultId == NULL) + { + /* Error */ + return NULL; + } + else + { + return resultId; + } + } + + + + typedef struct + { + OrthancPluginJobsUnserializer unserializer; + } _OrthancPluginJobsUnserializer; + + /** + * @brief Register an unserializer for custom jobs. + * + * This function registers an unserializer that decodes custom jobs + * from a JSON string. This callback is invoked when the jobs engine + * of Orthanc is started (on Orthanc initialization), for each job + * that is stored in the Orthanc database. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param unserializer The job unserializer. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterJobsUnserializer( + OrthancPluginContext* context, + OrthancPluginJobsUnserializer unserializer) + { + _OrthancPluginJobsUnserializer params; + params.unserializer = unserializer; + + context->InvokeService(context, _OrthancPluginService_RegisterJobsUnserializer, ¶ms); + } + + + + typedef struct + { + OrthancPluginRestOutput* output; + const char* details; + uint8_t log; + } _OrthancPluginSetHttpErrorDetails; + + /** + * @brief Provide a detailed description for an HTTP error. + * + * This function sets the detailed description associated with an + * HTTP error. This description will be displayed in the "Details" + * field of the JSON body of the HTTP answer. It is only taken into + * consideration if the REST callback returns an error code that is + * different from "OrthancPluginErrorCode_Success", and if the + * "HttpDescribeErrors" configuration option of Orthanc is set to + * "true". + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param output The HTTP connection to the client application. + * @param details The details of the error message. + * @param log Whether to also write the detailed error to the Orthanc logs. + * @ingroup REST + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetHttpErrorDetails( + OrthancPluginContext* context, + OrthancPluginRestOutput* output, + const char* details, + uint8_t log) + { + _OrthancPluginSetHttpErrorDetails params; + params.output = output; + params.details = details; + params.log = log; + context->InvokeService(context, _OrthancPluginService_SetHttpErrorDetails, ¶ms); + } + + + + typedef struct + { + const char** result; + const char* argument; + } _OrthancPluginRetrieveStaticString; + + /** + * @brief Detect the MIME type of a file. + * + * This function returns the MIME type of a file by inspecting its extension. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param path Path to the file. + * @return The MIME type. This is a statically-allocated + * string, do not free it. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginAutodetectMimeType( + OrthancPluginContext* context, + const char* path) + { + const char* result = NULL; + + _OrthancPluginRetrieveStaticString params; + params.result = &result; + params.argument = path; + + if (context->InvokeService(context, _OrthancPluginService_AutodetectMimeType, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + typedef struct + { + const char* name; + float value; + OrthancPluginMetricsType type; + } _OrthancPluginSetMetricsValue; + + /** + * @brief Set the value of a metrics. + * + * This function sets the value of a metrics to monitor the behavior + * of the plugin through tools such as Prometheus. The values of all + * the metrics are stored within the Orthanc context. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param name The name of the metrics to be set. + * @param value The value of the metrics. + * @param type The type of the metrics. This parameter is only taken into consideration + * the first time this metrics is set. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginSetMetricsValue( + OrthancPluginContext* context, + const char* name, + float value, + OrthancPluginMetricsType type) + { + _OrthancPluginSetMetricsValue params; + params.name = name; + params.value = value; + params.type = type; + context->InvokeService(context, _OrthancPluginService_SetMetricsValue, ¶ms); + } + + + + typedef struct + { + OrthancPluginRefreshMetricsCallback callback; + } _OrthancPluginRegisterRefreshMetricsCallback; + + /** + * @brief Register a callback to refresh the metrics. + * + * This function registers a callback to refresh the metrics. The + * callback must make calls to OrthancPluginSetMetricsValue(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback function to handle the refresh. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterRefreshMetricsCallback( + OrthancPluginContext* context, + OrthancPluginRefreshMetricsCallback callback) + { + _OrthancPluginRegisterRefreshMetricsCallback params; + params.callback = callback; + context->InvokeService(context, _OrthancPluginService_RegisterRefreshMetricsCallback, ¶ms); + } + + + + + typedef struct + { + char** target; + const void* dicom; + uint32_t dicomSize; + OrthancPluginDicomWebBinaryCallback callback; + } _OrthancPluginEncodeDicomWeb; + + /** + * @brief Convert a DICOM instance to DICOMweb JSON. + * + * This function converts a memory buffer containing a DICOM instance, + * into its DICOMweb JSON representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param dicom Pointer to the DICOM instance. + * @param dicomSize Size of the DICOM instance. + * @param callback Callback to set the value of the binary tags. + * @see OrthancPluginCreateDicom() + * @return The NULL value in case of error, or the JSON document. This string must + * be freed by OrthancPluginFreeString(). + * @deprecated OrthancPluginEncodeDicomWebJson2() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebJson( + OrthancPluginContext* context, + const void* dicom, + uint32_t dicomSize, + OrthancPluginDicomWebBinaryCallback callback) + { + char* target = NULL; + + _OrthancPluginEncodeDicomWeb params; + params.target = ⌖ + params.dicom = dicom; + params.dicomSize = dicomSize; + params.callback = callback; + + if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Convert a DICOM instance to DICOMweb XML. + * + * This function converts a memory buffer containing a DICOM instance, + * into its DICOMweb XML representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param dicom Pointer to the DICOM instance. + * @param dicomSize Size of the DICOM instance. + * @param callback Callback to set the value of the binary tags. + * @return The NULL value in case of error, or the XML document. This string must + * be freed by OrthancPluginFreeString(). + * @see OrthancPluginCreateDicom() + * @deprecated OrthancPluginEncodeDicomWebXml2() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebXml( + OrthancPluginContext* context, + const void* dicom, + uint32_t dicomSize, + OrthancPluginDicomWebBinaryCallback callback) + { + char* target = NULL; + + _OrthancPluginEncodeDicomWeb params; + params.target = ⌖ + params.dicom = dicom; + params.dicomSize = dicomSize; + params.callback = callback; + + if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebXml, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + + typedef struct + { + char** target; + const void* dicom; + uint32_t dicomSize; + OrthancPluginDicomWebBinaryCallback2 callback; + void* payload; + } _OrthancPluginEncodeDicomWeb2; + + /** + * @brief Convert a DICOM instance to DICOMweb JSON. + * + * This function converts a memory buffer containing a DICOM instance, + * into its DICOMweb JSON representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param dicom Pointer to the DICOM instance. + * @param dicomSize Size of the DICOM instance. + * @param callback Callback to set the value of the binary tags. + * @param payload User payload. + * @return The NULL value in case of error, or the JSON document. This string must + * be freed by OrthancPluginFreeString(). + * @see OrthancPluginCreateDicom() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebJson2( + OrthancPluginContext* context, + const void* dicom, + uint32_t dicomSize, + OrthancPluginDicomWebBinaryCallback2 callback, + void* payload) + { + char* target = NULL; + + _OrthancPluginEncodeDicomWeb2 params; + params.target = ⌖ + params.dicom = dicom; + params.dicomSize = dicomSize; + params.callback = callback; + params.payload = payload; + + if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebJson2, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Convert a DICOM instance to DICOMweb XML. + * + * This function converts a memory buffer containing a DICOM instance, + * into its DICOMweb XML representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param dicom Pointer to the DICOM instance. + * @param dicomSize Size of the DICOM instance. + * @param callback Callback to set the value of the binary tags. + * @param payload User payload. + * @return The NULL value in case of error, or the XML document. This string must + * be freed by OrthancPluginFreeString(). + * @see OrthancPluginCreateDicom() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginEncodeDicomWebXml2( + OrthancPluginContext* context, + const void* dicom, + uint32_t dicomSize, + OrthancPluginDicomWebBinaryCallback2 callback, + void* payload) + { + char* target = NULL; + + _OrthancPluginEncodeDicomWeb2 params; + params.target = ⌖ + params.dicom = dicom; + params.dicomSize = dicomSize; + params.callback = callback; + params.payload = payload; + + if (context->InvokeService(context, _OrthancPluginService_EncodeDicomWebXml2, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + + /** + * @brief Callback executed when a HTTP header is received during a chunked transfer. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, as soon as it + * receives one HTTP header from the answer of the remote HTTP + * server. + * + * @see OrthancPluginChunkedHttpClient() + * @param answer The user payload, as provided by the calling plugin. + * @param key The key of the HTTP header. + * @param value The value of the HTTP header. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginChunkedClientAnswerAddHeader) ( + void* answer, + const char* key, + const char* value); + + + /** + * @brief Callback executed when an answer chunk is received during a chunked transfer. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, as soon as it + * receives one data chunk from the answer of the remote HTTP + * server. + * + * @see OrthancPluginChunkedHttpClient() + * @param answer The user payload, as provided by the calling plugin. + * @param data The content of the data chunk. + * @param size The size of the data chunk. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginChunkedClientAnswerAddChunk) ( + void* answer, + const void* data, + uint32_t size); + + + /** + * @brief Callback to know whether the request body is entirely read during a chunked transfer + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, while reading + * the body of a POST or PUT request. The plugin must answer "1" as + * soon as the body is entirely read: The "request" data structure + * must act as an iterator. + * + * @see OrthancPluginChunkedHttpClient() + * @param request The user payload, as provided by the calling plugin. + * @return "1" if the body is over, or "0" if there is still data to be read. + * @ingroup Toolbox + **/ + typedef uint8_t (*OrthancPluginChunkedClientRequestIsDone) (void* request); + + + /** + * @brief Callback to advance in the request body during a chunked transfer + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, while reading + * the body of a POST or PUT request. This function asks the plugin + * to advance to the next chunk of data of the request body: The + * "request" data structure must act as an iterator. + * + * @see OrthancPluginChunkedHttpClient() + * @param request The user payload, as provided by the calling plugin. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + typedef OrthancPluginErrorCode (*OrthancPluginChunkedClientRequestNext) (void* request); + + + /** + * @brief Callback to read the current chunk of the request body during a chunked transfer + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, while reading + * the body of a POST or PUT request. The plugin must provide the + * content of the current chunk of data of the request body. + * + * @see OrthancPluginChunkedHttpClient() + * @param request The user payload, as provided by the calling plugin. + * @return The content of the current request chunk. + * @ingroup Toolbox + **/ + typedef const void* (*OrthancPluginChunkedClientRequestGetChunkData) (void* request); + + + /** + * @brief Callback to read the size of the current request chunk during a chunked transfer + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP client during a chunked HTTP transfer, while reading + * the body of a POST or PUT request. The plugin must provide the + * size of the current chunk of data of the request body. + * + * @see OrthancPluginChunkedHttpClient() + * @param request The user payload, as provided by the calling plugin. + * @return The size of the current request chunk. + * @ingroup Toolbox + **/ + typedef uint32_t (*OrthancPluginChunkedClientRequestGetChunkSize) (void* request); + + + typedef struct + { + void* answer; + OrthancPluginChunkedClientAnswerAddChunk answerAddChunk; + OrthancPluginChunkedClientAnswerAddHeader answerAddHeader; + uint16_t* httpStatus; + OrthancPluginHttpMethod method; + const char* url; + uint32_t headersCount; + const char* const* headersKeys; + const char* const* headersValues; + void* request; + OrthancPluginChunkedClientRequestIsDone requestIsDone; + OrthancPluginChunkedClientRequestGetChunkData requestChunkData; + OrthancPluginChunkedClientRequestGetChunkSize requestChunkSize; + OrthancPluginChunkedClientRequestNext requestNext; + const char* username; + const char* password; + uint32_t timeout; + const char* certificateFile; + const char* certificateKeyFile; + const char* certificateKeyPassword; + uint8_t pkcs11; + } _OrthancPluginChunkedHttpClient; + + + /** + * @brief Issue a HTTP call, using chunked HTTP transfers. + * + * Make a HTTP call to the given URL using chunked HTTP + * transfers. The request body is provided as an iterator over data + * chunks. The answer is provided as a sequence of function calls + * with the individual HTTP headers and answer chunks. + * + * Contrarily to OrthancPluginHttpClient() that entirely stores the + * request body and the answer body in memory buffers, this function + * uses chunked HTTP transfers. This results in a lower memory + * consumption. Pay attention to the fact that Orthanc servers with + * version <= 1.5.6 do not support chunked transfers: You must use + * OrthancPluginHttpClient() if contacting such older servers. + * + * The HTTP request will be done accordingly to the global + * configuration of Orthanc (in particular, the options "HttpProxy", + * "HttpTimeout", "HttpsVerifyPeers", "HttpsCACertificates", and + * "Pkcs11" will be taken into account). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param answer The user payload for the answer body. It will be provided to the callbacks for the answer. + * @param answerAddChunk Callback function to report a data chunk from the answer body. + * @param answerAddHeader Callback function to report an HTTP header sent by the remote server. + * @param httpStatus The HTTP status after the execution of the request (out argument). + * @param method HTTP method to be used. + * @param url The URL of interest. + * @param headersCount The number of HTTP headers. + * @param headersKeys Array containing the keys of the HTTP headers (can be NULL if no header). + * @param headersValues Array containing the values of the HTTP headers (can be NULL if no header). + * @param request The user payload containing the request body, and acting as an iterator. + * It will be provided to the callbacks for the request. + * @param requestIsDone Callback function to tell whether the request body is entirely read. + * @param requestChunkData Callback function to get the content of the current data chunk of the request body. + * @param requestChunkSize Callback function to get the size of the current data chunk of the request body. + * @param requestNext Callback function to advance to the next data chunk of the request body. + * @param username The username (can be NULL if no password protection). + * @param password The password (can be NULL if no password protection). + * @param timeout Timeout in seconds (0 for default timeout). + * @param certificateFile Path to the client certificate for HTTPS, in PEM format + * (can be NULL if no client certificate or if not using HTTPS). + * @param certificateKeyFile Path to the key of the client certificate for HTTPS, in PEM format + * (can be NULL if no client certificate or if not using HTTPS). + * @param certificateKeyPassword Password to unlock the key of the client certificate + * (can be NULL if no client certificate or if not using HTTPS). + * @param pkcs11 Enable PKCS#11 client authentication for hardware security modules and smart cards. + * @return 0 if success, or the error code if failure. + * @see OrthancPluginHttpClient() + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginChunkedHttpClient( + OrthancPluginContext* context, + void* answer, + OrthancPluginChunkedClientAnswerAddChunk answerAddChunk, + OrthancPluginChunkedClientAnswerAddHeader answerAddHeader, + uint16_t* httpStatus, + OrthancPluginHttpMethod method, + const char* url, + uint32_t headersCount, + const char* const* headersKeys, + const char* const* headersValues, + void* request, + OrthancPluginChunkedClientRequestIsDone requestIsDone, + OrthancPluginChunkedClientRequestGetChunkData requestChunkData, + OrthancPluginChunkedClientRequestGetChunkSize requestChunkSize, + OrthancPluginChunkedClientRequestNext requestNext, + const char* username, + const char* password, + uint32_t timeout, + const char* certificateFile, + const char* certificateKeyFile, + const char* certificateKeyPassword, + uint8_t pkcs11) + { + _OrthancPluginChunkedHttpClient params; + memset(¶ms, 0, sizeof(params)); + + /* In common with OrthancPluginHttpClient() */ + params.httpStatus = httpStatus; + params.method = method; + params.url = url; + params.headersCount = headersCount; + params.headersKeys = headersKeys; + params.headersValues = headersValues; + params.username = username; + params.password = password; + params.timeout = timeout; + params.certificateFile = certificateFile; + params.certificateKeyFile = certificateKeyFile; + params.certificateKeyPassword = certificateKeyPassword; + params.pkcs11 = pkcs11; + + /* For chunked body/answer */ + params.answer = answer; + params.answerAddChunk = answerAddChunk; + params.answerAddHeader = answerAddHeader; + params.request = request; + params.requestIsDone = requestIsDone; + params.requestChunkData = requestChunkData; + params.requestChunkSize = requestChunkSize; + params.requestNext = requestNext; + + return context->InvokeService(context, _OrthancPluginService_ChunkedHttpClient, ¶ms); + } + + + + /** + * @brief Opaque structure that reads the content of a HTTP request body during a chunked HTTP transfer. + * @ingroup Callback + **/ + typedef struct _OrthancPluginServerChunkedRequestReader_t OrthancPluginServerChunkedRequestReader; + + + + /** + * @brief Callback to create a reader to handle incoming chunked HTTP transfers. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP server that supports chunked HTTP transfers. This + * callback is only invoked if the HTTP method is POST or PUT. The + * callback must create an user-specific "reader" object that will + * be fed with the body of the incoming body. + * + * @see OrthancPluginRegisterChunkedRestCallback() + * @param reader Memory location that must be filled with the newly-created reader. + * @param url The URI that is accessed. + * @param request The body of the HTTP request. Note that "body" and "bodySize" are not used. + * @return 0 if success, or the error code if failure. + **/ + typedef OrthancPluginErrorCode (*OrthancPluginServerChunkedRequestReaderFactory) ( + OrthancPluginServerChunkedRequestReader** reader, + const char* url, + const OrthancPluginHttpRequest* request); + + + /** + * @brief Callback invoked whenever a new data chunk is available during a chunked transfer. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP server that supports chunked HTTP transfers. This callback + * is invoked as soon as a new data chunk is available for the request body. + * + * @see OrthancPluginRegisterChunkedRestCallback() + * @param reader The user payload, as created by the OrthancPluginServerChunkedRequestReaderFactory() callback. + * @param data The content of the data chunk. + * @param size The size of the data chunk. + * @return 0 if success, or the error code if failure. + **/ + typedef OrthancPluginErrorCode (*OrthancPluginServerChunkedRequestReaderAddChunk) ( + OrthancPluginServerChunkedRequestReader* reader, + const void* data, + uint32_t size); + + + /** + * @brief Callback invoked whenever the request body is entirely received. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP server that supports chunked HTTP transfers. This + * callback is invoked as soon as the full body of the HTTP request + * is available. The plugin can then send its answer thanks to the + * provided "output" object. + * + * @see OrthancPluginRegisterChunkedRestCallback() + * @param reader The user payload, as created by the OrthancPluginServerChunkedRequestReaderFactory() callback. + * @param output The HTTP connection to the client application. + * @return 0 if success, or the error code if failure. + **/ + typedef OrthancPluginErrorCode (*OrthancPluginServerChunkedRequestReaderExecute) ( + OrthancPluginServerChunkedRequestReader* reader, + OrthancPluginRestOutput* output); + + + /** + * @brief Callback invoked to release the resources associated with an incoming HTTP chunked transfer. + * + * Signature of a callback function that is called by Orthanc acting + * as a HTTP server that supports chunked HTTP transfers. This + * callback is invoked to release all the resources allocated by the + * given reader. Note that this function might be invoked even if + * the entire body was not read, to deal with client error or + * disconnection. + * + * @see OrthancPluginRegisterChunkedRestCallback() + * @param reader The user payload, as created by the OrthancPluginServerChunkedRequestReaderFactory() callback. + **/ + typedef void (*OrthancPluginServerChunkedRequestReaderFinalize) ( + OrthancPluginServerChunkedRequestReader* reader); + + typedef struct + { + const char* pathRegularExpression; + OrthancPluginRestCallback getHandler; + OrthancPluginServerChunkedRequestReaderFactory postHandler; + OrthancPluginRestCallback deleteHandler; + OrthancPluginServerChunkedRequestReaderFactory putHandler; + OrthancPluginServerChunkedRequestReaderAddChunk addChunk; + OrthancPluginServerChunkedRequestReaderExecute execute; + OrthancPluginServerChunkedRequestReaderFinalize finalize; + } _OrthancPluginChunkedRestCallback; + + + /** + * @brief Register a REST callback to handle chunked HTTP transfers. + * + * This function registers a REST callback against a regular + * expression for a URI. This function must be called during the + * initialization of the plugin, i.e. inside the + * OrthancPluginInitialize() public function. + * + * Contrarily to OrthancPluginRegisterRestCallback(), the callbacks + * will NOT be invoked in mutual exclusion, so it is up to the + * plugin to implement the required locking mechanisms. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param pathRegularExpression Regular expression for the URI. May contain groups. + * @param getHandler The callback function to handle REST calls using the GET HTTP method. + * @param postHandler The callback function to handle REST calls using the GET POST method. + * @param deleteHandler The callback function to handle REST calls using the GET DELETE method. + * @param putHandler The callback function to handle REST calls using the GET PUT method. + * @param addChunk The callback invoked when a new chunk is available for the request body of a POST or PUT call. + * @param execute The callback invoked once the entire body of a POST or PUT call is read. + * @param finalize The callback invoked to release the resources associated with a POST or PUT call. + * @see OrthancPluginRegisterRestCallbackNoLock() + * + * @note + * The regular expression is case sensitive and must follow the + * [Perl syntax](https://www.boost.org/doc/libs/1_67_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html). + * + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginRegisterChunkedRestCallback( + OrthancPluginContext* context, + const char* pathRegularExpression, + OrthancPluginRestCallback getHandler, + OrthancPluginServerChunkedRequestReaderFactory postHandler, + OrthancPluginRestCallback deleteHandler, + OrthancPluginServerChunkedRequestReaderFactory putHandler, + OrthancPluginServerChunkedRequestReaderAddChunk addChunk, + OrthancPluginServerChunkedRequestReaderExecute execute, + OrthancPluginServerChunkedRequestReaderFinalize finalize) + { + _OrthancPluginChunkedRestCallback params; + params.pathRegularExpression = pathRegularExpression; + params.getHandler = getHandler; + params.postHandler = postHandler; + params.deleteHandler = deleteHandler; + params.putHandler = putHandler; + params.addChunk = addChunk; + params.execute = execute; + params.finalize = finalize; + + context->InvokeService(context, _OrthancPluginService_RegisterChunkedRestCallback, ¶ms); + } + + + + + + typedef struct + { + char** result; + uint16_t group; + uint16_t element; + const char* privateCreator; + } _OrthancPluginGetTagName; + + /** + * @brief Returns the symbolic name of a DICOM tag. + * + * This function makes a lookup to the dictionary of DICOM tags that + * are known to Orthanc, and returns the symbolic name of a DICOM tag. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param group The group of the tag. + * @param element The element of the tag. + * @param privateCreator For private tags, the name of the private creator (can be NULL). + * @return NULL in the case of an error, or a newly allocated string + * containing the path. This string must be freed by + * OrthancPluginFreeString(). + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetTagName( + OrthancPluginContext* context, + uint16_t group, + uint16_t element, + const char* privateCreator) + { + char* result; + + _OrthancPluginGetTagName params; + params.result = &result; + params.group = group; + params.element = element; + params.privateCreator = privateCreator; + + if (context->InvokeService(context, _OrthancPluginService_GetTagName, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + + /** + * @brief Callback executed by the storage commitment SCP. + * + * Signature of a factory function that creates an object to handle + * one incoming storage commitment request. + * + * @remark The factory receives the list of the SOP class/instance + * UIDs of interest to the remote storage commitment SCU. This gives + * the factory the possibility to start some prefetch process + * upfront in the background, before the handler object is actually + * queried about the status of these DICOM instances. + * + * @param handler Output variable where the factory puts the handler object it created. + * @param jobId ID of the Orthanc job that is responsible for handling + * the storage commitment request. This job will successively look for the + * status of all the individual queried DICOM instances. + * @param transactionUid UID of the storage commitment transaction + * provided by the storage commitment SCU. It contains the value of the + * (0008,1195) DICOM tag. + * @param sopClassUids Array of the SOP class UIDs (0008,0016) that are queried by the SCU. + * @param sopInstanceUids Array of the SOP instance UIDs (0008,0018) that are queried by the SCU. + * @param countInstances Number of DICOM instances that are queried. This is the size + * of the `sopClassUids` and `sopInstanceUids` arrays. + * @param remoteAet The AET of the storage commitment SCU. + * @param calledAet The AET used by the SCU to contact the storage commitment SCP (i.e. Orthanc). + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageCommitmentFactory) ( + void** handler /* out */, + const char* jobId, + const char* transactionUid, + const char* const* sopClassUids, + const char* const* sopInstanceUids, + uint32_t countInstances, + const char* remoteAet, + const char* calledAet); + + + /** + * @brief Callback to free one storage commitment SCP handler. + * + * Signature of a callback function that releases the resources + * allocated by the factory of the storage commitment SCP. The + * handler is the return value of a previous call to the + * OrthancPluginStorageCommitmentFactory() callback. + * + * @param handler The handler object to be destructed. + * @ingroup DicomCallbacks + **/ + typedef void (*OrthancPluginStorageCommitmentDestructor) (void* handler); + + + /** + * @brief Callback to get the status of one DICOM instance in the + * storage commitment SCP. + * + * Signature of a callback function that is successively invoked for + * each DICOM instance that is queried by the remote storage + * commitment SCU. The function must be tought of as a method of + * the handler object that was created by a previous call to the + * OrthancPluginStorageCommitmentFactory() callback. After each call + * to this method, the progress of the associated Orthanc job is + * updated. + * + * @param target Output variable where to put the status for the queried instance. + * @param handler The handler object associated with this storage commitment request. + * @param sopClassUid The SOP class UID (0008,0016) of interest. + * @param sopInstanceUid The SOP instance UID (0008,0018) of interest. + * @ingroup DicomCallbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginStorageCommitmentLookup) ( + OrthancPluginStorageCommitmentFailureReason* target, + void* handler, + const char* sopClassUid, + const char* sopInstanceUid); + + + typedef struct + { + OrthancPluginStorageCommitmentFactory factory; + OrthancPluginStorageCommitmentDestructor destructor; + OrthancPluginStorageCommitmentLookup lookup; + } _OrthancPluginRegisterStorageCommitmentScpCallback; + + /** + * @brief Register a callback to handle incoming requests to the storage commitment SCP. + * + * This function registers a callback to handle storage commitment SCP requests. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param factory Factory function that creates the handler object + * for incoming storage commitment requests. + * @param destructor Destructor function to destroy the handler object. + * @param lookup Callback method to get the status of one DICOM instance. + * @return 0 if success, other value if error. + * @ingroup DicomCallbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterStorageCommitmentScpCallback( + OrthancPluginContext* context, + OrthancPluginStorageCommitmentFactory factory, + OrthancPluginStorageCommitmentDestructor destructor, + OrthancPluginStorageCommitmentLookup lookup) + { + _OrthancPluginRegisterStorageCommitmentScpCallback params; + params.factory = factory; + params.destructor = destructor; + params.lookup = lookup; + return context->InvokeService(context, _OrthancPluginService_RegisterStorageCommitmentScpCallback, ¶ms); + } + + + + /** + * @brief Callback to filter incoming DICOM instances received by Orthanc. + * + * Signature of a callback function that is triggered whenever + * Orthanc receives a new DICOM instance (e.g. through REST API or + * DICOM protocol), and that answers whether this DICOM instance + * should be accepted or discarded by Orthanc. + * + * Note that the metadata information is not available + * (i.e. GetInstanceMetadata() should not be used on "instance"). + * + * @param instance The received DICOM instance. + * @return 0 to discard the instance, 1 to store the instance, -1 if error. + * @ingroup Callback + **/ + typedef int32_t (*OrthancPluginIncomingDicomInstanceFilter) ( + const OrthancPluginDicomInstance* instance); + + + typedef struct + { + OrthancPluginIncomingDicomInstanceFilter callback; + } _OrthancPluginIncomingDicomInstanceFilter; + + /** + * @brief Register a callback to filter incoming DICOM instance. + * + * This function registers a custom callback to filter incoming + * DICOM instances received by Orthanc (either through the REST API + * or through the DICOM protocol). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterIncomingDicomInstanceFilter( + OrthancPluginContext* context, + OrthancPluginIncomingDicomInstanceFilter callback) + { + _OrthancPluginIncomingDicomInstanceFilter params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterIncomingDicomInstanceFilter, ¶ms); + } + + + /** + * @brief Get the transfer syntax of a DICOM file. + * + * This function returns a pointer to a newly created string that + * contains the transfer syntax UID of the DICOM instance. The empty + * string might be returned if this information is unknown. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The NULL value in case of error, or a string containing the + * transfer syntax UID. This string must be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceTransferSyntaxUid( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + char* result; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultStringToFree = &result; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceTransferSyntaxUid, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Check whether the DICOM file has pixel data. + * + * This function returns a Boolean value indicating whether the + * DICOM instance contains the pixel data (7FE0,0010) tag. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return "1" if the DICOM instance contains pixel data, or "0" if + * the tag is missing, or "-1" in the case of an error. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE int32_t OrthancPluginHasInstancePixelData( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + int64_t hasPixelData; + + _OrthancPluginAccessDicomInstance params; + memset(¶ms, 0, sizeof(params)); + params.resultInt64 = &hasPixelData; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_HasInstancePixelData, ¶ms) != OrthancPluginErrorCode_Success || + hasPixelData < 0 || + hasPixelData > 1) + { + /* Error */ + return -1; + } + else + { + return (hasPixelData != 0); + } + } + + + + + + + typedef struct + { + OrthancPluginDicomInstance** target; + const void* buffer; + uint32_t size; + const char* transferSyntax; + } _OrthancPluginCreateDicomInstance; + + /** + * @brief Parse a DICOM instance. + * + * This function parses a memory buffer that contains a DICOM + * file. The function returns a new pointer to a data structure that + * is managed by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The memory buffer containing the DICOM instance. + * @param size The size of the memory buffer. + * @return The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginDicomInstance* OrthancPluginCreateDicomInstance( + OrthancPluginContext* context, + const void* buffer, + uint32_t size) + { + OrthancPluginDicomInstance* target = NULL; + + _OrthancPluginCreateDicomInstance params; + params.target = ⌖ + params.buffer = buffer; + params.size = size; + + if (context->InvokeService(context, _OrthancPluginService_CreateDicomInstance, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + typedef struct + { + OrthancPluginDicomInstance* dicom; + } _OrthancPluginFreeDicomInstance; + + /** + * @brief Free a DICOM instance. + * + * This function frees a DICOM instance that was parsed using + * OrthancPluginCreateDicomInstance(). + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param dicom The DICOM instance. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE void OrthancPluginFreeDicomInstance( + OrthancPluginContext* context, + OrthancPluginDicomInstance* dicom) + { + _OrthancPluginFreeDicomInstance params; + params.dicom = dicom; + + context->InvokeService(context, _OrthancPluginService_FreeDicomInstance, ¶ms); + } + + + typedef struct + { + uint32_t* targetUint32; + OrthancPluginMemoryBuffer* targetBuffer; + OrthancPluginImage** targetImage; + char** targetStringToFree; + const OrthancPluginDicomInstance* instance; + uint32_t frameIndex; + OrthancPluginDicomToJsonFormat format; + OrthancPluginDicomToJsonFlags flags; + uint32_t maxStringLength; + OrthancPluginDicomWebBinaryCallback2 dicomWebCallback; + void* dicomWebPayload; + } _OrthancPluginAccessDicomInstance2; + + /** + * @brief Get the number of frames in a DICOM instance. + * + * This function returns the number of frames that are part of a + * DICOM image managed by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @return The number of frames (will be zero in the case of an error). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE uint32_t OrthancPluginGetInstanceFramesCount( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance) + { + uint32_t count; + + _OrthancPluginAccessDicomInstance2 params; + memset(¶ms, 0, sizeof(params)); + params.targetUint32 = &count; + params.instance = instance; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceFramesCount, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return 0; + } + else + { + return count; + } + } + + + /** + * @brief Get the raw content of a frame in a DICOM instance. + * + * This function returns a memory buffer containing the raw content + * of a frame in a DICOM instance that is managed by the Orthanc + * core. This is notably useful for compressed transfer syntaxes, as + * it gives access to the embedded files (such as JPEG, JPEG-LS or + * JPEG2k). The Orthanc core transparently reassembles the fragments + * to extract the raw frame. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param instance The instance of interest. + * @param frameIndex The index of the frame of interest. + * @return 0 if success, or the error code if failure. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetInstanceRawFrame( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const OrthancPluginDicomInstance* instance, + uint32_t frameIndex) + { + _OrthancPluginAccessDicomInstance2 params; + memset(¶ms, 0, sizeof(params)); + params.targetBuffer = target; + params.instance = instance; + params.frameIndex = frameIndex; + + return context->InvokeService(context, _OrthancPluginService_GetInstanceRawFrame, ¶ms); + } + + + /** + * @brief Decode one frame from a DICOM instance. + * + * This function decodes one frame of a DICOM image that is managed + * by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The instance of interest. + * @param frameIndex The index of the frame of interest. + * @return The uncompressed image. It must be freed with OrthancPluginFreeImage(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginGetInstanceDecodedFrame( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + uint32_t frameIndex) + { + OrthancPluginImage* target = NULL; + + _OrthancPluginAccessDicomInstance2 params; + memset(¶ms, 0, sizeof(params)); + params.targetImage = ⌖ + params.instance = instance; + params.frameIndex = frameIndex; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceDecodedFrame, ¶ms) != OrthancPluginErrorCode_Success) + { + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Parse and transcode a DICOM instance. + * + * This function parses a memory buffer that contains a DICOM file, + * then transcodes it to the given transfer syntax. The function + * returns a new pointer to a data structure that is managed by the + * Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param buffer The memory buffer containing the DICOM instance. + * @param size The size of the memory buffer. + * @param transferSyntax The transfer syntax UID for the transcoding. + * @return The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginDicomInstance* OrthancPluginTranscodeDicomInstance( + OrthancPluginContext* context, + const void* buffer, + uint32_t size, + const char* transferSyntax) + { + OrthancPluginDicomInstance* target = NULL; + + _OrthancPluginCreateDicomInstance params; + params.target = ⌖ + params.buffer = buffer; + params.size = size; + params.transferSyntax = transferSyntax; + + if (context->InvokeService(context, _OrthancPluginService_TranscodeDicomInstance, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + /** + * @brief Writes a DICOM instance to a memory buffer. + * + * This function returns a memory buffer containing the + * serialization of a DICOM instance that is managed by the Orthanc + * core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param instance The instance of interest. + * @return 0 if success, or the error code if failure. + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginSerializeDicomInstance( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + const OrthancPluginDicomInstance* instance) + { + _OrthancPluginAccessDicomInstance2 params; + memset(¶ms, 0, sizeof(params)); + params.targetBuffer = target; + params.instance = instance; + + return context->InvokeService(context, _OrthancPluginService_SerializeDicomInstance, ¶ms); + } + + + /** + * @brief Format a DICOM memory buffer as a JSON string. + * + * This function takes as DICOM instance managed by the Orthanc + * core, and outputs a JSON string representing the tags of this + * DICOM file. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The DICOM instance of interest. + * @param format The output format. + * @param flags Flags governing the output. + * @param maxStringLength The maximum length of a field. Too long fields will + * be output as "null". The 0 value means no maximum length. + * @return The NULL value if the case of an error, or the JSON + * string. This string must be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + * @see OrthancPluginDicomBufferToJson + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceAdvancedJson( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + OrthancPluginDicomToJsonFormat format, + OrthancPluginDicomToJsonFlags flags, + uint32_t maxStringLength) + { + char* result = NULL; + + _OrthancPluginAccessDicomInstance2 params; + memset(¶ms, 0, sizeof(params)); + params.targetStringToFree = &result; + params.instance = instance; + params.format = format; + params.flags = flags; + params.maxStringLength = maxStringLength; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceAdvancedJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + + /** + * @brief Convert a DICOM instance to DICOMweb JSON. + * + * This function converts a DICOM instance that is managed by the + * Orthanc core, into its DICOMweb JSON representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The DICOM instance of interest. + * @param callback Callback to set the value of the binary tags. + * @param payload User payload. + * @return The NULL value in case of error, or the JSON document. This string must + * be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceDicomWebJson( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + OrthancPluginDicomWebBinaryCallback2 callback, + void* payload) + { + char* target = NULL; + + _OrthancPluginAccessDicomInstance2 params; + params.targetStringToFree = ⌖ + params.instance = instance; + params.dicomWebCallback = callback; + params.dicomWebPayload = payload; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceDicomWebJson, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + /** + * @brief Convert a DICOM instance to DICOMweb XML. + * + * This function converts a DICOM instance that is managed by the + * Orthanc core, into its DICOMweb XML representation. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param instance The DICOM instance of interest. + * @param callback Callback to set the value of the binary tags. + * @param payload User payload. + * @return The NULL value in case of error, or the XML document. This string must + * be freed by OrthancPluginFreeString(). + * @ingroup DicomInstance + **/ + ORTHANC_PLUGIN_INLINE char* OrthancPluginGetInstanceDicomWebXml( + OrthancPluginContext* context, + const OrthancPluginDicomInstance* instance, + OrthancPluginDicomWebBinaryCallback2 callback, + void* payload) + { + char* target = NULL; + + _OrthancPluginAccessDicomInstance2 params; + params.targetStringToFree = ⌖ + params.instance = instance; + params.dicomWebCallback = callback; + params.dicomWebPayload = payload; + + if (context->InvokeService(context, _OrthancPluginService_GetInstanceDicomWebXml, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return target; + } + } + + + + /** + * @brief Signature of a callback function to transcode a DICOM instance. + * @param transcoded Target memory buffer. It must be allocated by the + * plugin using OrthancPluginCreateMemoryBuffer(). + * @param buffer Memory buffer containing the source DICOM instance. + * @param size Size of the source memory buffer. + * @param allowedSyntaxes A C array of possible transfer syntaxes UIDs for the + * result of the transcoding. The plugin must choose by itself the + * transfer syntax that will be used for the resulting DICOM image. + * @param countSyntaxes The number of transfer syntaxes that are contained + * in the "allowedSyntaxes" array. + * @param allowNewSopInstanceUid Whether the transcoding plugin can select + * a transfer syntax that will change the SOP instance UID (or, in other + * terms, whether the plugin can transcode using lossy compression). + * @return 0 if success (i.e. image successfully transcoded and stored into + * "transcoded"), or the error code if failure. + * @ingroup Callbacks + **/ + typedef OrthancPluginErrorCode (*OrthancPluginTranscoderCallback) ( + OrthancPluginMemoryBuffer* transcoded /* out */, + const void* buffer, + uint64_t size, + const char* const* allowedSyntaxes, + uint32_t countSyntaxes, + uint8_t allowNewSopInstanceUid); + + + typedef struct + { + OrthancPluginTranscoderCallback callback; + } _OrthancPluginTranscoderCallback; + + /** + * @brief Register a callback to handle the transcoding of DICOM images. + * + * This function registers a custom callback to transcode DICOM + * images, extending the built-in transcoder of Orthanc that uses + * DCMTK. The exact behavior is affected by the configuration option + * "BuiltinDecoderTranscoderOrder" of Orthanc. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param callback The callback. + * @return 0 if success, other value if error. + * @ingroup Callbacks + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterTranscoderCallback( + OrthancPluginContext* context, + OrthancPluginTranscoderCallback callback) + { + _OrthancPluginTranscoderCallback params; + params.callback = callback; + + return context->InvokeService(context, _OrthancPluginService_RegisterTranscoderCallback, ¶ms); + } + + + + typedef struct + { + OrthancPluginMemoryBuffer* target; + uint32_t size; + } _OrthancPluginCreateMemoryBuffer; + + /** + * @brief Create a memory buffer. + * + * This function creates a memory buffer that is managed by the + * Orthanc core. The main use case of this function is for plugins + * that act as DICOM transcoders. + * + * Your plugin should never call "free()" on the resulting memory + * buffer, as the C library that is used by the plugin is in general + * not the same as the one used by the Orthanc core. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). + * @param size Size of the memory buffer to be created. + * @return 0 if success, or the error code if failure. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateMemoryBuffer( + OrthancPluginContext* context, + OrthancPluginMemoryBuffer* target, + uint32_t size) + { + _OrthancPluginCreateMemoryBuffer params; + params.target = target; + params.size = size; + + return context->InvokeService(context, _OrthancPluginService_CreateMemoryBuffer, ¶ms); + } + + +#ifdef __cplusplus +} +#endif + + +/** @} */ + diff -r 6a7e91d753ae -r 67c833e5dee6 Resources/SyncOrthancFolder.py --- a/Resources/SyncOrthancFolder.py Wed Jan 22 16:18:14 2025 +0100 +++ b/Resources/SyncOrthancFolder.py Wed Aug 13 12:02:04 2025 +0200 @@ -37,14 +37,8 @@ import urllib.request TARGET = os.path.join(os.path.dirname(__file__), 'Orthanc') -ORTHANC_JAVA_VERSION = 'default' -ORTHANC_CORE_REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc/raw-file' -ORTHANC_JAVA_REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc-java/raw-file' - -with open(os.path.join(os.path.dirname(__file__), '..', 'OrthancSDKVersion.cmake'), 'r') as f: - m = re.match('^set\(ORTHANC_SDK_VERSION "([0-9.]+)"\)$', f.read(), re.MULTILINE) - assert(m != None) - PLUGIN_SDK_VERSION = m.group(1) +REPOSITORY = 'https://orthanc.uclouvain.be/hg/orthanc/raw-file' +PLUGIN_SDK_VERSIONS = [ '1.7.2', '1.10.0', '1.12.6', '1.12.9' ] FILES = [ @@ -58,6 +52,7 @@ ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain32.cmake', 'Toolchains'), ('OrthancFramework/Resources/Toolchains/MinGW-W64-Toolchain64.cmake', 'Toolchains'), ('OrthancFramework/Resources/Toolchains/MinGWToolchain.cmake', 'Toolchains'), + ('OrthancServer/Plugins/Include/orthanc/OrthancPluginCodeModel.json', '.'), ('OrthancServer/Plugins/Samples/Common/ExportedSymbolsPlugins.list', 'Plugins'), ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp', 'Plugins'), ('OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h', 'Plugins'), @@ -66,12 +61,15 @@ ('OrthancServer/Plugins/Samples/Common/VersionScriptPlugins.map', 'Plugins'), ] +SDK = [ + 'orthanc/OrthancCPlugin.h', +] + def Download(x): - repository = x[0] - branch = x[1] - source = x[2] - target = os.path.join(TARGET, x[3]) + branch = x[0] + source = x[1] + target = os.path.join(TARGET, x[2]) print(target) try: @@ -79,7 +77,7 @@ except: pass - url = '%s/%s/%s' % (repository, branch, source) + url = '%s/%s/%s' % (REPOSITORY, branch, source) with open(target, 'wb') as f: try: @@ -93,34 +91,18 @@ for f in FILES: commands.append([ - ORTHANC_CORE_REPOSITORY, 'default', f[0], os.path.join(f[1], os.path.basename(f[0])) ]) - -commands.append([ - ORTHANC_JAVA_REPOSITORY, - ORTHANC_JAVA_VERSION, - 'Resources/Orthanc/Sdk-%s/orthanc/OrthancCPlugin.h' % PLUGIN_SDK_VERSION, - 'Sdk-%s/orthanc/OrthancCPlugin.h' % PLUGIN_SDK_VERSION, -]) - - -for f in [ - ('ClassDocumentation.json', 'CodeGeneration/ClassDocumentation.json'), - ('ClassDocumentation.json.license', 'CodeGeneration/ClassDocumentation.json.license'), - ('CodeModel.json', 'Resources/CodeModel-%s.json' % PLUGIN_SDK_VERSION), - ('CodeModel.json.license', 'Resources/CodeModel-%s.json.license' % PLUGIN_SDK_VERSION), - ]: - commands.append([ - ORTHANC_JAVA_REPOSITORY, - ORTHANC_JAVA_VERSION, - f[1], - 'Sdk-%s/%s' % (PLUGIN_SDK_VERSION, f[0]), - ]) - +for f in SDK: + for version in PLUGIN_SDK_VERSIONS: + commands.append([ + 'Orthanc-%s' % version, + 'OrthancServer/Plugins/Include/%s' % f, + 'Sdk-%s/%s' % (version, f) + ]) pool = multiprocessing.Pool(10) # simultaneous downloads diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/orthanc.pyi --- a/Sources/Autogenerated/orthanc.pyi Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3121 +0,0 @@ -# SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain -# SPDX-License-Identifier: AGPL-3.0-or-later - -## -## Python plugin for Orthanc -## Copyright (C) 2020-2023 Osimis S.A., Belgium -## Copyright (C) 2024-2025 Orthanc Team SRL, Belgium -## Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium -## -## This program is free software: you can redistribute it and/or -## modify it under the terms of the GNU Affero General Public License -## as published by the Free Software Foundation, either version 3 of -## the License, or (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## Affero General Public License for more details. -## -## You should have received a copy of the GNU Affero General Public License -## along with this program. If not, see . -## - - -# WARNING: Auto-generated file. Do not modify it by hand. - - -import typing - - - -class ChangeType(): - """ - The supported types of changes that can be signaled to the change callback. - """ - - """ - Series is now complete - """ - COMPLETED_SERIES: int = 0, - - """ - Deleted resource - """ - DELETED: int = 1, - - """ - A new instance was added to this resource - """ - NEW_CHILD_INSTANCE: int = 2, - - """ - New instance received - """ - NEW_INSTANCE: int = 3, - - """ - New patient created - """ - NEW_PATIENT: int = 4, - - """ - New series created - """ - NEW_SERIES: int = 5, - - """ - New study created - """ - NEW_STUDY: int = 6, - - """ - Timeout: No new instance in this patient - """ - STABLE_PATIENT: int = 7, - - """ - Timeout: No new instance in this series - """ - STABLE_SERIES: int = 8, - - """ - Timeout: No new instance in this study - """ - STABLE_STUDY: int = 9, - - """ - Orthanc has started - """ - ORTHANC_STARTED: int = 10, - - """ - Orthanc is stopping - """ - ORTHANC_STOPPED: int = 11, - - """ - Some user-defined attachment has changed for this resource - """ - UPDATED_ATTACHMENT: int = 12, - - """ - Some user-defined metadata has changed for this resource - """ - UPDATED_METADATA: int = 13, - - """ - The list of Orthanc peers has changed - """ - UPDATED_PEERS: int = 14, - - """ - The list of DICOM modalities has changed - """ - UPDATED_MODALITIES: int = 15, - - """ - New Job submitted - """ - JOB_SUBMITTED: int = 16, - - """ - A Job has completed successfully - """ - JOB_SUCCESS: int = 17, - - """ - A Job has failed - """ - JOB_FAILURE: int = 18, - -class CompressionType(): - """ - The compression algorithms that are supported by the Orthanc core. - """ - - """ - Standard zlib compression - """ - ZLIB: int = 0, - - """ - zlib, prefixed with uncompressed size (uint64_t) - """ - ZLIB_WITH_SIZE: int = 1, - - """ - Standard gzip compression - """ - GZIP: int = 2, - - """ - gzip, prefixed with uncompressed size (uint64_t) - """ - GZIP_WITH_SIZE: int = 3, - -class ConstraintType(): - """ - The constraints on the tags (main DICOM tags and identifier tags) that must be supported by the database plugins. - """ - - """ - Equal - """ - EQUAL: int = 1, - - """ - Less or equal - """ - SMALLER_OR_EQUAL: int = 2, - - """ - More or equal - """ - GREATER_OR_EQUAL: int = 3, - - """ - Wildcard matching - """ - WILDCARD: int = 4, - - """ - List of values - """ - LIST: int = 5, - -class ContentType(): - """ - The content types that are supported by Orthanc plugins. - """ - - """ - Unknown content type - """ - UNKNOWN: int = 0, - - """ - DICOM - """ - DICOM: int = 1, - - """ - JSON summary of a DICOM file - """ - DICOM_AS_JSON: int = 2, - - """ - DICOM Header till pixel data - """ - DICOM_UNTIL_PIXEL_DATA: int = 3, - -class CreateDicomFlags(): - """ - Flags to the creation of a DICOM file. - """ - - """ - Default mode - """ - NONE: int = 0, - - """ - Decode fields encoded using data URI scheme - """ - DECODE_DATA_URI_SCHEME: int = 1, - - """ - Automatically generate DICOM identifiers - """ - GENERATE_IDENTIFIERS: int = 2, - -class DicomToJsonFlags(): - """ - Flags to customize a DICOM-to-JSON conversion. By default, binary tags are formatted using Data URI scheme. - """ - - """ - Default formatting - """ - NONE: int = 0, - - """ - Include the binary tags - """ - INCLUDE_BINARY: int = 1, - - """ - Include the private tags - """ - INCLUDE_PRIVATE_TAGS: int = 2, - - """ - Include the tags unknown by the dictionary - """ - INCLUDE_UNKNOWN_TAGS: int = 4, - - """ - Include the pixel data - """ - INCLUDE_PIXEL_DATA: int = 8, - - """ - Output binary tags as-is, dropping non-ASCII - """ - CONVERT_BINARY_TO_ASCII: int = 16, - - """ - Signal binary tags as null values - """ - CONVERT_BINARY_TO_NULL: int = 32, - - """ - Stop processing after pixel data (new in 1.9.1) - """ - STOP_AFTER_PIXEL_DATA: int = 64, - - """ - Skip tags whose element is zero (new in 1.9.1) - """ - SKIP_GROUP_LENGTHS: int = 128, - -class DicomToJsonFormat(): - """ - The possible output formats for a DICOM-to-JSON conversion. - """ - - """ - Full output, with most details - """ - FULL: int = 1, - - """ - Tags output as hexadecimal numbers - """ - SHORT: int = 2, - - """ - Human-readable JSON - """ - HUMAN: int = 3, - -class DicomWebBinaryMode(): - """ - The available modes to export a binary DICOM tag into a DICOMweb JSON or XML document. - """ - - """ - Don't include binary tags - """ - IGNORE: int = 0, - - """ - Inline encoding using Base64 - """ - INLINE_BINARY: int = 1, - - """ - Use a bulk data URI field - """ - BULK_DATA_URI: int = 2, - -class ErrorCode(): - """ - The various error codes that can be returned by the Orthanc core. - """ - - """ - Internal error - """ - INTERNAL_ERROR: int = -1, - - """ - Success - """ - SUCCESS: int = 0, - - """ - Error encountered within the plugin engine - """ - PLUGIN: int = 1, - - """ - Not implemented yet - """ - NOT_IMPLEMENTED: int = 2, - - """ - Parameter out of range - """ - PARAMETER_OUT_OF_RANGE: int = 3, - - """ - The server hosting Orthanc is running out of memory - """ - NOT_ENOUGH_MEMORY: int = 4, - - """ - Bad type for a parameter - """ - BAD_PARAMETER_TYPE: int = 5, - - """ - Bad sequence of calls - """ - BAD_SEQUENCE_OF_CALLS: int = 6, - - """ - Accessing an inexistent item - """ - INEXISTENT_ITEM: int = 7, - - """ - Bad request - """ - BAD_REQUEST: int = 8, - - """ - Error in the network protocol - """ - NETWORK_PROTOCOL: int = 9, - - """ - Error while calling a system command - """ - SYSTEM_COMMAND: int = 10, - - """ - Error with the database engine - """ - DATABASE: int = 11, - - """ - Badly formatted URI - """ - URI_SYNTAX: int = 12, - - """ - Inexistent file - """ - INEXISTENT_FILE: int = 13, - - """ - Cannot write to file - """ - CANNOT_WRITE_FILE: int = 14, - - """ - Bad file format - """ - BAD_FILE_FORMAT: int = 15, - - """ - Timeout - """ - TIMEOUT: int = 16, - - """ - Unknown resource - """ - UNKNOWN_RESOURCE: int = 17, - - """ - Incompatible version of the database - """ - INCOMPATIBLE_DATABASE_VERSION: int = 18, - - """ - The file storage is full - """ - FULL_STORAGE: int = 19, - - """ - Corrupted file (e.g. inconsistent MD5 hash) - """ - CORRUPTED_FILE: int = 20, - - """ - Inexistent tag - """ - INEXISTENT_TAG: int = 21, - - """ - Cannot modify a read-only data structure - """ - READ_ONLY: int = 22, - - """ - Incompatible format of the images - """ - INCOMPATIBLE_IMAGE_FORMAT: int = 23, - - """ - Incompatible size of the images - """ - INCOMPATIBLE_IMAGE_SIZE: int = 24, - - """ - Error while using a shared library (plugin) - """ - SHARED_LIBRARY: int = 25, - - """ - Plugin invoking an unknown service - """ - UNKNOWN_PLUGIN_SERVICE: int = 26, - - """ - Unknown DICOM tag - """ - UNKNOWN_DICOM_TAG: int = 27, - - """ - Cannot parse a JSON document - """ - BAD_JSON: int = 28, - - """ - Bad credentials were provided to an HTTP request - """ - UNAUTHORIZED: int = 29, - - """ - Badly formatted font file - """ - BAD_FONT: int = 30, - - """ - The plugin implementing a custom database back-end does not fulfill the proper interface - """ - DATABASE_PLUGIN: int = 31, - - """ - Error in the plugin implementing a custom storage area - """ - STORAGE_AREA_PLUGIN: int = 32, - - """ - The request is empty - """ - EMPTY_REQUEST: int = 33, - - """ - Cannot send a response which is acceptable according to the Accept HTTP header - """ - NOT_ACCEPTABLE: int = 34, - - """ - Cannot handle a NULL pointer - """ - NULL_POINTER: int = 35, - - """ - The database is currently not available (probably a transient situation) - """ - DATABASE_UNAVAILABLE: int = 36, - - """ - This job was canceled - """ - CANCELED_JOB: int = 37, - - """ - Geometry error encountered in Stone - """ - BAD_GEOMETRY: int = 38, - - """ - Cannot initialize SSL encryption, check out your certificates - """ - SSL_INITIALIZATION: int = 39, - - """ - Calling a function that has been removed from the Orthanc Framework - """ - DISCONTINUED_ABI: int = 40, - - """ - Incorrect range request - """ - BAD_RANGE: int = 41, - - """ - Database could not serialize access due to concurrent update, the transaction should be retried - """ - DATABASE_CANNOT_SERIALIZE: int = 42, - - """ - A bad revision number was provided, which might indicate conflict between multiple writers - """ - REVISION: int = 43, - - """ - SQLite: The database is not opened - """ - SQLITE_NOT_OPENED: int = 1000, - - """ - SQLite: Connection is already open - """ - SQLITE_ALREADY_OPENED: int = 1001, - - """ - SQLite: Unable to open the database - """ - SQLITE_CANNOT_OPEN: int = 1002, - - """ - SQLite: This cached statement is already being referred to - """ - SQLITE_STATEMENT_ALREADY_USED: int = 1003, - - """ - SQLite: Cannot execute a command - """ - SQLITE_EXECUTE: int = 1004, - - """ - SQLite: Rolling back a nonexistent transaction (have you called Begin()?) - """ - SQLITE_ROLLBACK_WITHOUT_TRANSACTION: int = 1005, - - """ - SQLite: Committing a nonexistent transaction - """ - SQLITE_COMMIT_WITHOUT_TRANSACTION: int = 1006, - - """ - SQLite: Unable to register a function - """ - SQLITE_REGISTER_FUNCTION: int = 1007, - - """ - SQLite: Unable to flush the database - """ - SQLITE_FLUSH: int = 1008, - - """ - SQLite: Cannot run a cached statement - """ - SQLITE_CANNOT_RUN: int = 1009, - - """ - SQLite: Cannot step over a cached statement - """ - SQLITE_CANNOT_STEP: int = 1010, - - """ - SQLite: Bing a value while out of range (serious error) - """ - SQLITE_BIND_OUT_OF_RANGE: int = 1011, - - """ - SQLite: Cannot prepare a cached statement - """ - SQLITE_PREPARE_STATEMENT: int = 1012, - - """ - SQLite: Beginning the same transaction twice - """ - SQLITE_TRANSACTION_ALREADY_STARTED: int = 1013, - - """ - SQLite: Failure when committing the transaction - """ - SQLITE_TRANSACTION_COMMIT: int = 1014, - - """ - SQLite: Cannot start a transaction - """ - SQLITE_TRANSACTION_BEGIN: int = 1015, - - """ - The directory to be created is already occupied by a regular file - """ - DIRECTORY_OVER_FILE: int = 2000, - - """ - Unable to create a subdirectory or a file in the file storage - """ - FILE_STORAGE_CANNOT_WRITE: int = 2001, - - """ - The specified path does not point to a directory - """ - DIRECTORY_EXPECTED: int = 2002, - - """ - The TCP port of the HTTP server is privileged or already in use - """ - HTTP_PORT_IN_USE: int = 2003, - - """ - The TCP port of the DICOM server is privileged or already in use - """ - DICOM_PORT_IN_USE: int = 2004, - - """ - This HTTP status is not allowed in a REST API - """ - BAD_HTTP_STATUS_IN_REST: int = 2005, - - """ - The specified path does not point to a regular file - """ - REGULAR_FILE_EXPECTED: int = 2006, - - """ - Unable to get the path to the executable - """ - PATH_TO_EXECUTABLE: int = 2007, - - """ - Cannot create a directory - """ - MAKE_DIRECTORY: int = 2008, - - """ - An application entity title (AET) cannot be empty or be longer than 16 characters - """ - BAD_APPLICATION_ENTITY_TITLE: int = 2009, - - """ - No request handler factory for DICOM C-FIND SCP - """ - NO_CFIND_HANDLER: int = 2010, - - """ - No request handler factory for DICOM C-MOVE SCP - """ - NO_CMOVE_HANDLER: int = 2011, - - """ - No request handler factory for DICOM C-STORE SCP - """ - NO_CSTORE_HANDLER: int = 2012, - - """ - No application entity filter - """ - NO_APPLICATION_ENTITY_FILTER: int = 2013, - - """ - DicomUserConnection: Unable to find the SOP class and instance - """ - NO_SOP_CLASS_OR_INSTANCE: int = 2014, - - """ - DicomUserConnection: No acceptable presentation context for modality - """ - NO_PRESENTATION_CONTEXT: int = 2015, - - """ - DicomUserConnection: The C-FIND command is not supported by the remote SCP - """ - DICOM_FIND_UNAVAILABLE: int = 2016, - - """ - DicomUserConnection: The C-MOVE command is not supported by the remote SCP - """ - DICOM_MOVE_UNAVAILABLE: int = 2017, - - """ - Cannot store an instance - """ - CANNOT_STORE_INSTANCE: int = 2018, - - """ - Only string values are supported when creating DICOM instances - """ - CREATE_DICOM_NOT_STRING: int = 2019, - - """ - Trying to override a value inherited from a parent module - """ - CREATE_DICOM_OVERRIDE_TAG: int = 2020, - - """ - Use \"Content\" to inject an image into a new DICOM instance - """ - CREATE_DICOM_USE_CONTENT: int = 2021, - - """ - No payload is present for one instance in the series - """ - CREATE_DICOM_NO_PAYLOAD: int = 2022, - - """ - The payload of the DICOM instance must be specified according to Data URI scheme - """ - CREATE_DICOM_USE_DATA_URI_SCHEME: int = 2023, - - """ - Trying to attach a new DICOM instance to an inexistent resource - """ - CREATE_DICOM_BAD_PARENT: int = 2024, - - """ - Trying to attach a new DICOM instance to an instance (must be a series, study or patient) - """ - CREATE_DICOM_PARENT_IS_INSTANCE: int = 2025, - - """ - Unable to get the encoding of the parent resource - """ - CREATE_DICOM_PARENT_ENCODING: int = 2026, - - """ - Unknown modality - """ - UNKNOWN_MODALITY: int = 2027, - - """ - Bad ordering of filters in a job - """ - BAD_JOB_ORDERING: int = 2028, - - """ - Cannot convert the given JSON object to a Lua table - """ - JSON_TO_LUA_TABLE: int = 2029, - - """ - Cannot create the Lua context - """ - CANNOT_CREATE_LUA: int = 2030, - - """ - Cannot execute a Lua command - """ - CANNOT_EXECUTE_LUA: int = 2031, - - """ - Arguments cannot be pushed after the Lua function is executed - """ - LUA_ALREADY_EXECUTED: int = 2032, - - """ - The Lua function does not give the expected number of outputs - """ - LUA_BAD_OUTPUT: int = 2033, - - """ - The Lua function is not a predicate (only true/false outputs allowed) - """ - NOT_LUA_PREDICATE: int = 2034, - - """ - The Lua function does not return a string - """ - LUA_RETURNS_NO_STRING: int = 2035, - - """ - Another plugin has already registered a custom storage area - """ - STORAGE_AREA_ALREADY_REGISTERED: int = 2036, - - """ - Another plugin has already registered a custom database back-end - """ - DATABASE_BACKEND_ALREADY_REGISTERED: int = 2037, - - """ - Plugin trying to call the database during its initialization - """ - DATABASE_NOT_INITIALIZED: int = 2038, - - """ - Orthanc has been built without SSL support - """ - SSL_DISABLED: int = 2039, - - """ - Unable to order the slices of the series - """ - CANNOT_ORDER_SLICES: int = 2040, - - """ - No request handler factory for DICOM C-Find Modality SCP - """ - NO_WORKLIST_HANDLER: int = 2041, - - """ - Cannot override the value of a tag that already exists - """ - ALREADY_EXISTING_TAG: int = 2042, - - """ - No request handler factory for DICOM N-ACTION SCP (storage commitment) - """ - NO_STORAGE_COMMITMENT_HANDLER: int = 2043, - - """ - No request handler factory for DICOM C-GET SCP - """ - NO_CGET_HANDLER: int = 2044, - - """ - Unsupported media type - """ - UNSUPPORTED_MEDIA_TYPE: int = 3000, - -class HttpMethod(): - """ - The various HTTP methods for a REST call. - """ - - """ - GET request - """ - GET: int = 1, - - """ - POST request - """ - POST: int = 2, - - """ - PUT request - """ - PUT: int = 3, - - """ - DELETE request - """ - DELETE: int = 4, - -class IdentifierConstraint(): - """ - The constraints on the DICOM identifiers that must be supported by the database plugins. - """ - - """ - Equal - """ - EQUAL: int = 1, - - """ - Less or equal - """ - SMALLER_OR_EQUAL: int = 2, - - """ - More or equal - """ - GREATER_OR_EQUAL: int = 3, - - """ - Case-sensitive wildcard matching (with * and ?) - """ - WILDCARD: int = 4, - -class ImageFormat(): - """ - The image formats that are supported by the Orthanc core. - """ - - """ - Image compressed using PNG - """ - PNG: int = 0, - - """ - Image compressed using JPEG - """ - JPEG: int = 1, - - """ - Image compressed using DICOM - """ - DICOM: int = 2, - -class InstanceOrigin(): - """ - The origin of a DICOM instance that has been received by Orthanc. - """ - - """ - Unknown origin - """ - UNKNOWN: int = 1, - - """ - Instance received through DICOM protocol - """ - DICOM_PROTOCOL: int = 2, - - """ - Instance received through REST API of Orthanc - """ - REST_API: int = 3, - - """ - Instance added to Orthanc by a plugin - """ - PLUGIN: int = 4, - - """ - Instance added to Orthanc by a Lua script - """ - LUA: int = 5, - - """ - Instance received through WebDAV (new in 1.8.0) - """ - WEB_DAV: int = 6, - -class JobStepStatus(): - """ - The possible status for one single step of a job. - """ - - """ - The job has successfully executed all its steps - """ - SUCCESS: int = 1, - - """ - The job has failed while executing this step - """ - FAILURE: int = 2, - - """ - The job has still data to process after this step - """ - CONTINUE: int = 3, - -class JobStopReason(): - """ - Explains why the job should stop and release the resources it has allocated. This is especially important to disambiguate between the "paused" condition and the "final" conditions (success, failure, or canceled). - """ - - """ - The job has succeeded - """ - SUCCESS: int = 1, - - """ - The job was paused, and will be resumed later - """ - PAUSED: int = 2, - - """ - The job has failed, and might be resubmitted later - """ - FAILURE: int = 3, - - """ - The job was canceled, and might be resubmitted later - """ - CANCELED: int = 4, - -class MetricsType(): - """ - The available types of metrics. - """ - - """ - Default metrics - """ - DEFAULT: int = 0, - - """ - This metrics represents a time duration. Orthanc will keep the maximum value of the metrics over a sliding window of ten seconds, which is useful if the metrics is sampled frequently. - """ - TIMER: int = 1, - -class PixelFormat(): - """ - The memory layout of the pixels of an image. - """ - - """ - Graylevel 8bpp image. The image is graylevel. Each pixel is unsigned and stored in one byte. - """ - GRAYSCALE8: int = 1, - - """ - Graylevel, unsigned 16bpp image. The image is graylevel. Each pixel is unsigned and stored in two bytes. - """ - GRAYSCALE16: int = 2, - - """ - Graylevel, signed 16bpp image. The image is graylevel. Each pixel is signed and stored in two bytes. - """ - SIGNED_GRAYSCALE16: int = 3, - - """ - Color image in RGB24 format. This format describes a color image. The pixels are stored in 3 consecutive bytes. The memory layout is RGB. - """ - RGB24: int = 4, - - """ - Color image in RGBA32 format. This format describes a color image. The pixels are stored in 4 consecutive bytes. The memory layout is RGBA. - """ - RGBA32: int = 5, - - """ - Unknown pixel format - """ - UNKNOWN: int = 6, - - """ - Color image in RGB48 format. This format describes a color image. The pixels are stored in 6 consecutive bytes. The memory layout is RRGGBB. - """ - RGB48: int = 7, - - """ - Graylevel, unsigned 32bpp image. The image is graylevel. Each pixel is unsigned and stored in four bytes. - """ - GRAYSCALE32: int = 8, - - """ - Graylevel, floating-point 32bpp image. The image is graylevel. Each pixel is floating-point and stored in four bytes. - """ - FLOAT32: int = 9, - - """ - Color image in BGRA32 format. This format describes a color image. The pixels are stored in 4 consecutive bytes. The memory layout is BGRA. - """ - BGRA32: int = 10, - - """ - Graylevel, unsigned 64bpp image. The image is graylevel. Each pixel is unsigned and stored in eight bytes. - """ - GRAYSCALE64: int = 11, - -class ReceivedInstanceAction(): - """ - The action to be taken after ReceivedInstanceCallback is triggered - """ - - """ - Keep the instance as is - """ - KEEP_AS_IS: int = 1, - - """ - Modify the instance - """ - MODIFY: int = 2, - - """ - Discard the instance - """ - DISCARD: int = 3, - -class ResourceType(): - """ - The supported types of DICOM resources. - """ - - """ - Patient - """ - PATIENT: int = 0, - - """ - Study - """ - STUDY: int = 1, - - """ - Series - """ - SERIES: int = 2, - - """ - Instance - """ - INSTANCE: int = 3, - - """ - Unavailable resource type - """ - NONE: int = 4, - -class StorageCommitmentFailureReason(): - """ - The available values for the Failure Reason (0008,1197) during storage commitment. http://dicom.nema.org/medical/dicom/2019e/output/chtml/part03/sect_C.14.html#sect_C.14.1.1 - """ - - """ - Success: The DICOM instance is properly stored in the SCP - """ - SUCCESS: int = 0, - - """ - 0110H: A general failure in processing the operation was encountered - """ - PROCESSING_FAILURE: int = 1, - - """ - 0112H: One or more of the elements in the Referenced SOP Instance Sequence was not available - """ - NO_SUCH_OBJECT_INSTANCE: int = 2, - - """ - 0213H: The SCP does not currently have enough resources to store the requested SOP Instance(s) - """ - RESOURCE_LIMITATION: int = 3, - - """ - 0122H: Storage Commitment has been requested for a SOP Instance with a SOP Class that is not supported by the SCP - """ - REFERENCED_SOPCLASS_NOT_SUPPORTED: int = 4, - - """ - 0119H: The SOP Class of an element in the Referenced SOP Instance Sequence did not correspond to the SOP class registered for this SOP Instance at the SCP - """ - CLASS_INSTANCE_CONFLICT: int = 5, - - """ - 0131H: The Transaction UID of the Storage Commitment Request is already in use - """ - DUPLICATE_TRANSACTION_UID: int = 6, - -class ValueRepresentation(): - """ - The value representations present in the DICOM standard (version 2013). - """ - - """ - Application Entity - """ - AE: int = 1, - - """ - Age String - """ - AS: int = 2, - - """ - Attribute Tag - """ - AT: int = 3, - - """ - Code String - """ - CS: int = 4, - - """ - Date - """ - DA: int = 5, - - """ - Decimal String - """ - DS: int = 6, - - """ - Date Time - """ - DT: int = 7, - - """ - Floating Point Double - """ - FD: int = 8, - - """ - Floating Point Single - """ - FL: int = 9, - - """ - Integer String - """ - IS: int = 10, - - """ - Long String - """ - LO: int = 11, - - """ - Long Text - """ - LT: int = 12, - - """ - Other Byte String - """ - OB: int = 13, - - """ - Other Float String - """ - OF: int = 14, - - """ - Other Word String - """ - OW: int = 15, - - """ - Person Name - """ - PN: int = 16, - - """ - Short String - """ - SH: int = 17, - - """ - Signed Long - """ - SL: int = 18, - - """ - Sequence of Items - """ - SQ: int = 19, - - """ - Signed Short - """ - SS: int = 20, - - """ - Short Text - """ - ST: int = 21, - - """ - Time - """ - TM: int = 22, - - """ - Unique Identifier (UID) - """ - UI: int = 23, - - """ - Unsigned Long - """ - UL: int = 24, - - """ - Unknown - """ - UN: int = 25, - - """ - Unsigned Short - """ - US: int = 26, - - """ - Unlimited Text - """ - UT: int = 27, - - - -# This function returns the MIME type of a file by inspecting its extension -def AutodetectMimeType(path: str) -> str: - """ - This function returns the MIME type of a file by inspecting its extension. - - Args: - path (str): Path to the file. - - Returns: - str: The MIME type. This is a statically-allocated string, do not free it. - """ - ... - -# This function compresses or decompresses a buffer, using the version of the zlib library that is used by the Orthanc core -def BufferCompression(source: bytes, compression: CompressionType, uncompress: int) -> bytes: - """ - This function compresses or decompresses a buffer, using the version of the zlib library that is used by the Orthanc core. - - Args: - source (bytes): The source buffer. - compression (CompressionType): The compression algorithm. - uncompress (int): If set to "0", the buffer must be compressed. If set to "1", the buffer must be uncompressed. - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - -# This function checks whether the version of the Orthanc server running this plugin, is above the version of the current Orthanc SDK header -def CheckVersion() -> int: - """ - This function checks whether the version of the Orthanc server running this plugin, is above the version of the current Orthanc SDK header. This guarantees that the plugin is compatible with the hosting Orthanc (i.e. it will not call unavailable services). The result of this function should always be checked in the OrthancPluginInitialize() entry point of the plugin. - - Returns: - int: 1 if and only if the versions are compatible. If the result is 0, the initialization of the plugin should fail. - """ - ... - -# This function checks whether the version of the Orthanc server running this plugin, is above the given version -def CheckVersionAdvanced(expected_major: int, expected_minor: int, expected_revision: int) -> int: - """ - This function checks whether the version of the Orthanc server running this plugin, is above the given version. Contrarily to OrthancPluginCheckVersion(), it is up to the developer of the plugin to make sure that all the Orthanc SDK services called by the plugin are actually implemented in the given version of Orthanc. - - Args: - expected_major (int): Expected major version. - expected_minor (int): Expected minor version. - expected_revision (int): Expected revision. - - Returns: - int: 1 if and only if the versions are compatible. If the result is 0, the initialization of the plugin should fail. - """ - ... - -# This function compresses the given memory buffer containing an image using the JPEG specification, and stores the result of the compression into a newly allocated memory buffer -def CompressJpegImage(format: PixelFormat, width: int, height: int, pitch: int, buffer: bytes, quality: int) -> bytes: - """ - This function compresses the given memory buffer containing an image using the JPEG specification, and stores the result of the compression into a newly allocated memory buffer. - - Args: - format (PixelFormat): The memory layout of the uncompressed image. - width (int): The width of the image. - height (int): The height of the image. - pitch (int): The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer). - buffer (bytes): The memory buffer containing the uncompressed image. - quality (int): The quality of the JPEG encoding, between 1 (worst quality, best compression) and 100 (best quality, worst compression). - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - -# This function compresses the given memory buffer containing an image using the PNG specification, and stores the result of the compression into a newly allocated memory buffer -def CompressPngImage(format: PixelFormat, width: int, height: int, pitch: int, buffer: bytes) -> bytes: - """ - This function compresses the given memory buffer containing an image using the PNG specification, and stores the result of the compression into a newly allocated memory buffer. - - Args: - format (PixelFormat): The memory layout of the uncompressed image. - width (int): The width of the image. - height (int): The height of the image. - pitch (int): The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer). - buffer (bytes): The memory buffer containing the uncompressed image. - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - -# This functions computes the MD5 cryptographic hash of the given memory buffer -def ComputeMd5(buffer: bytes) -> str: - """ - This functions computes the MD5 cryptographic hash of the given memory buffer. - - Args: - buffer (bytes): The source memory buffer. - - Returns: - str: The NULL value in case of error, or a string containing the cryptographic hash. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# This functions computes the SHA-1 cryptographic hash of the given memory buffer -def ComputeSha1(buffer: bytes) -> str: - """ - This functions computes the SHA-1 cryptographic hash of the given memory buffer. - - Args: - buffer (bytes): The source memory buffer. - - Returns: - str: The NULL value in case of error, or a string containing the cryptographic hash. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# This function takes as input a string containing a JSON file describing the content of a DICOM instance -def CreateDicom(json: str, pixel_data: Image, flags: CreateDicomFlags) -> bytes: - """ - This function takes as input a string containing a JSON file describing the content of a DICOM instance. As an output, it writes the corresponding DICOM instance to a newly allocated memory buffer. Additionally, an image to be encoded within the DICOM instance can also be provided. - Private tags will be associated with the private creator whose value is specified in the "DefaultPrivateCreator" configuration option of Orthanc. The function OrthancPluginCreateDicom2() can be used if another private creator must be used to create this instance. - - Args: - json (str): The input JSON file. - pixel_data (Image): The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme. - flags (CreateDicomFlags): Flags governing the output. - - Returns: - bytes: 0 if success, other value if error. - """ - ... - -# This function takes as input a string containing a JSON file describing the content of a DICOM instance -def CreateDicom2(json: str, pixel_data: Image, flags: CreateDicomFlags, private_creator: str) -> bytes: - """ - This function takes as input a string containing a JSON file describing the content of a DICOM instance. As an output, it writes the corresponding DICOM instance to a newly allocated memory buffer. Additionally, an image to be encoded within the DICOM instance can also be provided. - Contrarily to the function OrthancPluginCreateDicom(), this function can be explicitly provided with a private creator. - - Args: - json (str): The input JSON file. - pixel_data (Image): The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme. - flags (CreateDicomFlags): Flags governing the output. - private_creator (str): The private creator to be used for the private DICOM tags. Check out the global configuration option "Dictionary" of Orthanc. - - Returns: - bytes: 0 if success, other value if error. - """ - ... - -# This function parses a memory buffer that contains a DICOM file -def CreateDicomInstance(buffer: bytes) -> DicomInstance: - """ - This function parses a memory buffer that contains a DICOM file. The function returns a new pointer to a data structure that is managed by the Orthanc core. - - Args: - buffer (bytes): The memory buffer containing the DICOM instance. - - Returns: - DicomInstance: The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance(). - """ - ... - -# This function creates a "matcher" object that can be used to check whether a DICOM instance matches a C-Find query -def CreateFindMatcher(query: bytes) -> FindMatcher: - """ - This function creates a "matcher" object that can be used to check whether a DICOM instance matches a C-Find query. The C-Find query must be expressed as a DICOM buffer. - - Args: - query (bytes): The C-Find DICOM query. - - Returns: - FindMatcher: The newly allocated matcher. It must be freed with OrthancPluginFreeFindMatcher(). - """ - ... - -# This function creates an image of given size and format -def CreateImage(format: PixelFormat, width: int, height: int) -> Image: - """ - This function creates an image of given size and format. - - Args: - format (PixelFormat): The format of the pixels. - width (int): The width of the image. - height (int): The height of the image. - - Returns: - Image: The newly allocated image. It must be freed with OrthancPluginFreeImage(). - """ - ... - -# This function decodes one frame of a DICOM image that is stored in a memory buffer -def DecodeDicomImage(buffer: bytes, frame_index: int) -> Image: - """ - This function decodes one frame of a DICOM image that is stored in a memory buffer. This function will give the same result as OrthancPluginUncompressImage() for single-frame DICOM images. - - Args: - buffer (bytes): Pointer to a memory buffer containing the DICOM image. - frame_index (int): The index of the frame of interest in a multi-frame image. - - Returns: - Image: The uncompressed image. It must be freed with OrthancPluginFreeImage(). - """ - ... - -# This function takes as input a memory buffer containing a DICOM file, and outputs a JSON string representing the tags of this DICOM file -def DicomBufferToJson(buffer: bytes, format: DicomToJsonFormat, flags: DicomToJsonFlags, max_string_length: int) -> str: - """ - This function takes as input a memory buffer containing a DICOM file, and outputs a JSON string representing the tags of this DICOM file. - - Args: - buffer (bytes): The memory buffer containing the DICOM file. - format (DicomToJsonFormat): The output format. - flags (DicomToJsonFlags): Flags governing the output. - max_string_length (int): The maximum length of a field. Too long fields will be output as "null". The 0 value means no maximum length. - - Returns: - str: The NULL value if the case of an error, or the JSON string. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# This function formats a DICOM instance that is stored in Orthanc, and outputs a JSON string representing the tags of this DICOM instance -def DicomInstanceToJson(instance_id: str, format: DicomToJsonFormat, flags: DicomToJsonFlags, max_string_length: int) -> str: - """ - This function formats a DICOM instance that is stored in Orthanc, and outputs a JSON string representing the tags of this DICOM instance. - - Args: - instance_id (str): The Orthanc identifier of the instance. - format (DicomToJsonFormat): The output format. - flags (DicomToJsonFlags): Flags governing the output. - max_string_length (int): The maximum length of a field. Too long fields will be output as "null". The 0 value means no maximum length. - - Returns: - str: The NULL value if the case of an error, or the JSON string. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# Add JavaScript code to customize the default behavior of Orthanc Explorer -def ExtendOrthancExplorer(javascript: str) -> None: - """ - Add JavaScript code to customize the default behavior of Orthanc Explorer. This can for instance be used to add new buttons. - - Args: - javascript (str): The custom JavaScript code. - """ - ... - -# This function generates a token that can be set in the HTTP header "Authorization" so as to grant full access to the REST API of Orthanc using an external HTTP client -def GenerateRestApiAuthorizationToken() -> str: - """ - This function generates a token that can be set in the HTTP header "Authorization" so as to grant full access to the REST API of Orthanc using an external HTTP client. Using this function avoids the need of adding a separate user in the "RegisteredUsers" configuration of Orthanc, which eases deployments. - This feature is notably useful in multiprocess scenarios, where a subprocess created by a plugin has no access to the "OrthancPluginContext", and thus cannot call "OrthancPluginRestApi[Get|Post|Put|Delete]()". - This situation is frequently encountered in Python plugins, where the "multiprocessing" package can be used to bypass the Global Interpreter Lock (GIL) and thus to improve performance and concurrency. - - Returns: - str: The authorization token, or NULL value in the case of an error. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# Generate a random GUID/UUID (globally unique identifier) -def GenerateUuid() -> str: - """ - Generate a random GUID/UUID (globally unique identifier). - - Returns: - str: NULL in the case of an error, or a newly allocated string containing the UUID. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# Get the value of one of the command-line arguments that were used to launch Orthanc -def GetCommandLineArgument(argument: int) -> str: - """ - Get the value of one of the command-line arguments that were used to launch Orthanc. The number of available arguments can be retrieved by OrthancPluginGetCommandLineArgumentsCount(). - - Args: - argument (int): The index of the argument. - - Returns: - str: The value of the argument, or NULL in the case of an error. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# Retrieve the number of command-line arguments that were used to launch Orthanc -def GetCommandLineArgumentsCount() -> int: - """ - Retrieve the number of command-line arguments that were used to launch Orthanc. - - Returns: - int: The number of arguments. - """ - ... - -# This function returns the content of the configuration that is used by Orthanc, formatted as a JSON string -def GetConfiguration() -> str: - """ - This function returns the content of the configuration that is used by Orthanc, formatted as a JSON string. - - Returns: - str: NULL in the case of an error, or a newly allocated string containing the configuration. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# This function returns the path to the configuration file(s) that was specified when starting Orthanc -def GetConfigurationPath() -> str: - """ - This function returns the path to the configuration file(s) that was specified when starting Orthanc. Since version 0.9.1, this path can refer to a folder that stores a set of configuration files. This function is deprecated in favor of OrthancPluginGetConfiguration(). - - Returns: - str: NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# Retrieve a DICOM instance using its Orthanc identifier -def GetDicomForInstance(instance_id: str) -> bytes: - """ - Retrieve a DICOM instance using its Orthanc identifier. The DICOM file is stored into a newly allocated memory buffer. - - Args: - instance_id (str): The Orthanc identifier of the DICOM instance of interest. - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - -# This function returns the description of a given error code -def GetErrorDescription(error: ErrorCode) -> str: - """ - This function returns the description of a given error code. - - Args: - error (ErrorCode): The error code of interest. - - Returns: - str: The error description. This is a statically-allocated string, do not free it. - """ - ... - -# Retrieve the expected version of the database schema -def GetExpectedDatabaseVersion() -> int: - """ - Retrieve the expected version of the database schema. - - Returns: - int: The version. - """ - ... - -# This function returns the name of a font that is built in the Orthanc core -def GetFontName(font_index: int) -> str: - """ - This function returns the name of a font that is built in the Orthanc core. - - Args: - font_index (int): The index of the font. This value must be less than OrthancPluginGetFontsCount(). - - Returns: - str: The font name. This is a statically-allocated string, do not free it. - """ - ... - -# This function returns the size of a font that is built in the Orthanc core -def GetFontSize(font_index: int) -> int: - """ - This function returns the size of a font that is built in the Orthanc core. - - Args: - font_index (int): The index of the font. This value must be less than OrthancPluginGetFontsCount(). - - Returns: - int: The font size. - """ - ... - -# This function returns the number of fonts that are built in the Orthanc core -def GetFontsCount() -> int: - """ - This function returns the number of fonts that are built in the Orthanc core. These fonts can be used to draw texts on images through OrthancPluginDrawText(). - - Returns: - int: The number of fonts. - """ - ... - -# Get the value of a global property that is stored in the Orthanc database -def GetGlobalProperty(property: int, default_value: str) -> str: - """ - Get the value of a global property that is stored in the Orthanc database. Global properties whose index is below 1024 are reserved by Orthanc. - - Args: - property (int): The global property of interest. - default_value (str): The value to return, if the global property is unset. - - Returns: - str: The value of the global property, or NULL in the case of an error. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# This function returns the path to the directory containing the Orthanc executable -def GetOrthancDirectory() -> str: - """ - This function returns the path to the directory containing the Orthanc executable. - - Returns: - str: NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# This function returns the path to the Orthanc executable -def GetOrthancPath() -> str: - """ - This function returns the path to the Orthanc executable. - - Returns: - str: NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# This function returns the parameters of the Orthanc peers that are known to the Orthanc server hosting the plugin -def GetPeers() -> Peers: - """ - This function returns the parameters of the Orthanc peers that are known to the Orthanc server hosting the plugin. - - Returns: - Peers: NULL if error, or a newly allocated opaque data structure containing the peers. This structure must be freed with OrthancPluginFreePeers(). - """ - ... - -# This function makes a lookup to the dictionary of DICOM tags that are known to Orthanc, and returns the symbolic name of a DICOM tag -def GetTagName(group: int, element: int, private_creator: str) -> str: - """ - This function makes a lookup to the dictionary of DICOM tags that are known to Orthanc, and returns the symbolic name of a DICOM tag. - - Args: - group (int): The group of the tag. - element (int): The element of the tag. - private_creator (str): For private tags, the name of the private creator (can be NULL). - - Returns: - str: NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# Make a HTTP DELETE call to the given URL -def HttpDelete(url: str, username: str, password: str) -> None: - """ - Make a HTTP DELETE call to the given URL. Favor OrthancPluginRestApiDelete() if calling the built-in REST API of the Orthanc instance that hosts this plugin. - - Args: - url (str): The URL of interest. - username (str): The username (can be "NULL" if no password protection). - password (str): The password (can be "NULL" if no password protection). - """ - ... - -# Make a HTTP GET call to the given URL -def HttpGet(url: str, username: str, password: str) -> bytes: - """ - Make a HTTP GET call to the given URL. The result to the query is stored into a newly allocated memory buffer. Favor OrthancPluginRestApiGet() if calling the built-in REST API of the Orthanc instance that hosts this plugin. - - Args: - url (str): The URL of interest. - username (str): The username (can be "NULL" if no password protection). - password (str): The password (can be "NULL" if no password protection). - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - -# Make a HTTP POST call to the given URL -def HttpPost(url: str, body: bytes, username: str, password: str) -> bytes: - """ - Make a HTTP POST call to the given URL. The result to the query is stored into a newly allocated memory buffer. Favor OrthancPluginRestApiPost() if calling the built-in REST API of the Orthanc instance that hosts this plugin. - - Args: - url (str): The URL of interest. - body (bytes): The content of the body of the request. - username (str): The username (can be "NULL" if no password protection). - password (str): The password (can be "NULL" if no password protection). - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - -# Make a HTTP PUT call to the given URL -def HttpPut(url: str, body: bytes, username: str, password: str) -> bytes: - """ - Make a HTTP PUT call to the given URL. The result to the query is stored into a newly allocated memory buffer. Favor OrthancPluginRestApiPut() if calling the built-in REST API of the Orthanc instance that hosts this plugin. - - Args: - url (str): The URL of interest. - body (bytes): The content of the body of the request. - username (str): The username (can be "NULL" if no password protection). - password (str): The password (can be "NULL" if no password protection). - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - -# Log an error message using the Orthanc logging system -def LogError(message: str) -> None: - """ - Log an error message using the Orthanc logging system. - - Args: - message (str): The message to be logged. - """ - ... - -# Log an information message using the Orthanc logging system -def LogInfo(message: str) -> None: - """ - Log an information message using the Orthanc logging system. - - Args: - message (str): The message to be logged. - """ - ... - -# Log a warning message using the Orthanc logging system -def LogWarning(message: str) -> None: - """ - Log a warning message using the Orthanc logging system. - - Args: - message (str): The message to be logged. - """ - ... - -# Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018) -def LookupInstance(sop_instance_u_i_d: str) -> str: - """ - Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018). This function uses the database index to run as fast as possible (it does not loop over all the stored instances). - - Args: - sop_instance_u_i_d (str): The SOP Instance UID of interest. - - Returns: - str: The NULL value if the instance is non-existent, or a string containing the Orthanc ID of the instance. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020) -def LookupPatient(patient_i_d: str) -> str: - """ - Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020). This function uses the database index to run as fast as possible (it does not loop over all the stored patients). - - Args: - patient_i_d (str): The Patient ID of interest. - - Returns: - str: The NULL value if the patient is non-existent, or a string containing the Orthanc ID of the patient. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e) -def LookupSeries(series_u_i_d: str) -> str: - """ - Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e). This function uses the database index to run as fast as possible (it does not loop over all the stored series). - - Args: - series_u_i_d (str): The Series Instance UID of interest. - - Returns: - str: The NULL value if the series is non-existent, or a string containing the Orthanc ID of the series. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d) -def LookupStudy(study_u_i_d: str) -> str: - """ - Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d). This function uses the database index to run as fast as possible (it does not loop over all the stored studies). - - Args: - study_u_i_d (str): The Study Instance UID of interest. - - Returns: - str: The NULL value if the study is non-existent, or a string containing the Orthanc ID of the study. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# Look for a study stored in Orthanc, using its Accession Number tag (0x0008, 0x0050) -def LookupStudyWithAccessionNumber(accession_number: str) -> str: - """ - Look for a study stored in Orthanc, using its Accession Number tag (0x0008, 0x0050). This function uses the database index to run as fast as possible (it does not loop over all the stored studies). - - Args: - accession_number (str): The Accession Number of interest. - - Returns: - str: The NULL value if the study is non-existent, or a string containing the Orthanc ID of the study. This string must be freed by OrthancPluginFreeString(). - """ - ... - -# Read the content of a file on the filesystem, and returns it into a newly allocated memory buffer -def ReadFile(path: str) -> bytes: - """ - Read the content of a file on the filesystem, and returns it into a newly allocated memory buffer. - - Args: - path (str): The path of the file to be read. - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - -# This function declares a new public tag in the dictionary of DICOM tags that are known to Orthanc -def RegisterDictionaryTag(group: int, element: int, vr: ValueRepresentation, name: str, min_multiplicity: int, max_multiplicity: int) -> None: - """ - This function declares a new public tag in the dictionary of DICOM tags that are known to Orthanc. This function should be used in the OrthancPluginInitialize() callback. - - Args: - group (int): The group of the tag. - element (int): The element of the tag. - vr (ValueRepresentation): The value representation of the tag. - name (str): The nickname of the tag. - min_multiplicity (int): The minimum multiplicity of the tag (must be above 0). - max_multiplicity (int): The maximum multiplicity of the tag. A value of 0 means an arbitrary multiplicity (""n""). - """ - ... - -# This function declares a custom error code that can be generated by this plugin -def RegisterErrorCode(code: int, http_status: int, message: str) -> None: - """ - This function declares a custom error code that can be generated by this plugin. This declaration is used to enrich the body of the HTTP answer in the case of an error, and to set the proper HTTP status code. - - Args: - code (int): The error code that is internal to this plugin. - http_status (int): The HTTP status corresponding to this error. - message (str): The description of the error. - """ - ... - -# This function declares a new private tag in the dictionary of DICOM tags that are known to Orthanc -def RegisterPrivateDictionaryTag(group: int, element: int, vr: ValueRepresentation, name: str, min_multiplicity: int, max_multiplicity: int, private_creator: str) -> None: - """ - This function declares a new private tag in the dictionary of DICOM tags that are known to Orthanc. This function should be used in the OrthancPluginInitialize() callback. - - Args: - group (int): The group of the tag. - element (int): The element of the tag. - vr (ValueRepresentation): The value representation of the tag. - name (str): The nickname of the tag. - min_multiplicity (int): The minimum multiplicity of the tag (must be above 0). - max_multiplicity (int): The maximum multiplicity of the tag. A value of 0 means an arbitrary multiplicity (""n""). - private_creator (str): The private creator of this private tag. - """ - ... - -# Make a DELETE call to the built-in Orthanc REST API -def RestApiDelete(uri: str) -> None: - """ - Make a DELETE call to the built-in Orthanc REST API. - Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. - - Args: - uri (str): The URI to delete in the built-in Orthanc API. - """ - ... - -# Make a DELETE call to the Orthanc REST API, after all the plugins are applied -def RestApiDeleteAfterPlugins(uri: str) -> None: - """ - Make a DELETE call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. - Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. - - Args: - uri (str): The URI to delete in the built-in Orthanc API. - """ - ... - -# Make a GET call to the built-in Orthanc REST API -def RestApiGet(uri: str) -> bytes: - """ - Make a GET call to the built-in Orthanc REST API. The result to the query is stored into a newly allocated memory buffer. - Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. - - Args: - uri (str): The URI in the built-in Orthanc API. - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - -# Make a GET call to the Orthanc REST API, after all the plugins are applied -def RestApiGetAfterPlugins(uri: str) -> bytes: - """ - Make a GET call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. The result to the query is stored into a newly allocated memory buffer. - Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. - - Args: - uri (str): The URI in the built-in Orthanc API. - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - -# Make a POST call to the built-in Orthanc REST API -def RestApiPost(uri: str, body: bytes) -> bytes: - """ - Make a POST call to the built-in Orthanc REST API. The result to the query is stored into a newly allocated memory buffer. - Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. - - Args: - uri (str): The URI in the built-in Orthanc API. - body (bytes): The body of the POST request. - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - -# Make a POST call to the Orthanc REST API, after all the plugins are applied -def RestApiPostAfterPlugins(uri: str, body: bytes) -> bytes: - """ - Make a POST call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. The result to the query is stored into a newly allocated memory buffer. - Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. - - Args: - uri (str): The URI in the built-in Orthanc API. - body (bytes): The body of the POST request. - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - -# Make a PUT call to the built-in Orthanc REST API -def RestApiPut(uri: str, body: bytes) -> bytes: - """ - Make a PUT call to the built-in Orthanc REST API. The result to the query is stored into a newly allocated memory buffer. - Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. - - Args: - uri (str): The URI in the built-in Orthanc API. - body (bytes): The body of the PUT request. - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - -# Make a PUT call to the Orthanc REST API, after all the plugins are applied -def RestApiPutAfterPlugins(uri: str, body: bytes) -> bytes: - """ - Make a PUT call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. The result to the query is stored into a newly allocated memory buffer. - Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. - - Args: - uri (str): The URI in the built-in Orthanc API. - body (bytes): The body of the PUT request. - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - -# Set a description for this plugin -def SetDescription(description: str) -> None: - """ - Set a description for this plugin. It is displayed in the "Plugins" page of Orthanc Explorer. - - Args: - description (str): The description. - """ - ... - -# Set the value of a global property into the Orthanc database -def SetGlobalProperty(property: int, value: str) -> None: - """ - Set the value of a global property into the Orthanc database. Setting a global property can be used by plugins to save their internal parameters. Plugins are only allowed to set properties whose index are above or equal to 1024 (properties below 1024 are read-only and reserved by Orthanc). - - Args: - property (int): The global property of interest. - value (str): The value to be set in the global property. - """ - ... - -# This function sets the value of a metrics to monitor the behavior of the plugin through tools such as Prometheus -def SetMetricsValue(name: str, value: float, type: MetricsType) -> None: - """ - This function sets the value of a metrics to monitor the behavior of the plugin through tools such as Prometheus. The values of all the metrics are stored within the Orthanc context. - - Args: - name (str): The name of the metrics to be set. - value (float): The value of the metrics. - type (MetricsType): The type of the metrics. This parameter is only taken into consideration the first time this metrics is set. - """ - ... - -# For plugins that come with a Web interface, this function declares the entry path where to find this interface -def SetRootUri(uri: str) -> None: - """ - For plugins that come with a Web interface, this function declares the entry path where to find this interface. This information is notably used in the "Plugins" page of Orthanc Explorer. - - Args: - uri (str): The root URI for this plugin. - """ - ... - -# This function parses a memory buffer that contains a DICOM file, then transcodes it to the given transfer syntax -def TranscodeDicomInstance(buffer: bytes, transfer_syntax: str) -> DicomInstance: - """ - This function parses a memory buffer that contains a DICOM file, then transcodes it to the given transfer syntax. The function returns a new pointer to a data structure that is managed by the Orthanc core. - - Args: - buffer (bytes): The memory buffer containing the DICOM instance. - transfer_syntax (str): The transfer syntax UID for the transcoding. - - Returns: - DicomInstance: The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance(). - """ - ... - -# This function decodes a compressed image from a memory buffer -def UncompressImage(data: bytes, format: ImageFormat) -> Image: - """ - This function decodes a compressed image from a memory buffer. - - Args: - data (bytes): Pointer to a memory buffer containing the compressed image. - format (ImageFormat): The file format of the compressed image. - - Returns: - Image: The uncompressed image. It must be freed with OrthancPluginFreeImage(). - """ - ... - -# Write the content of a memory buffer to the filesystem -def WriteFile(path: str, data: bytes) -> None: - """ - Write the content of a memory buffer to the filesystem. - - Args: - path (str): The path of the file to be written. - data (bytes): The content of the memory buffer. - """ - ... - -# This function creates an image of given size and format, and initializes its pixel data from a memory buffer -def CreateImageFromBuffer(format: PixelFormat, width: int, height: int, pitch: int, buffer: bytes) -> Image: - """ - This function creates an image of given size and format, and initializes its pixel data from a memory buffer. - - Args: - format (PixelFormat): The format of the pixels. - width (int): The width of the image. - height (int): The height of the image. - pitch (int): The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer). - buffer (bytes): The memory buffer. - - Returns: - Image: The newly allocated image. - """ - ... - -# Get information about the given DICOM tag -def LookupDictionary(name: str) -> dict: - """ - Get information about the given DICOM tag. - - Args: - name (str): The name of the DICOM tag. - - Returns: - dict: Dictionary containing the requested information. - """ - ... - -class FindCallback(typing.Protocol): - def __call__(self, answers: FindAnswers, query: FindQuery, issuer_aet: str, called_aet: str) -> None: - ... - -# Register a callback to handle C-Find requests -def RegisterFindCallback(callback: FindCallback) -> None: - """ - Register a callback to handle C-Find requests. - - Args: - callback (FindCallback): The callback function. - """ - ... - -class IncomingCStoreInstanceFilter(typing.Protocol): - def __call__(self, received_dicom: DicomInstance) -> int: - ... - -# Register a callback to filter incoming DICOM instances received by Orthanc through C-STORE -def RegisterIncomingCStoreInstanceFilter(callback: IncomingCStoreInstanceFilter) -> None: - """ - Register a callback to filter incoming DICOM instances received by Orthanc through C-STORE. - - Args: - callback (IncomingCStoreInstanceFilter): The callback function. - """ - ... - -class IncomingHttpRequestFilter(typing.Protocol): - def __call__(self, uri: str, method: HttpMethod, ip: str, headers: dict, get: dict) -> bool: - ... - -# Callback to filter incoming HTTP requests received by Orthanc -def RegisterIncomingHttpRequestFilter(callback: IncomingHttpRequestFilter) -> None: - """ - Callback to filter incoming HTTP requests received by Orthanc. - - Args: - callback (IncomingHttpRequestFilter): The callback function. - """ - ... - -class MoveCallback(typing.Protocol): - def __call__(self, Level: str, PatientID: str, AccessionNumber: str, StudyInstanceUID: str, SeriesInstanceUID: str, SOPInstanceUID: str, OriginatorAET: str, SourceAET: str, TargetAET: str, OriginatorID: int) -> None: - ... - -# Register a callback to handle C-Move requests (simple version, with 1 suboperation) -def RegisterMoveCallback(callback: MoveCallback) -> None: - """ - Register a callback to handle C-Move requests (simple version, with 1 suboperation). - - Args: - callback (MoveCallback): The callback function. - """ - ... - -class MoveCallback2(typing.Protocol): - def __call__(self, Level: str, PatientID: str, AccessionNumber: str, StudyInstanceUID: str, SeriesInstanceUID: str, SOPInstanceUID: str, OriginatorAET: str, SourceAET: str, TargetAET: str, OriginatorID: int) -> object: - ... - -class GetMoveSizeCallback(typing.Protocol): - def __call__(self, driver: object) -> int: - ... - -class ApplyMoveCallback(typing.Protocol): - def __call__(self, driver: object) -> None: - ... - -class FreeMoveCallback(typing.Protocol): - def __call__(self, driver: object) -> None: - ... - -# Register a callback to handle C-Move requests (full version, with multiple suboperations) -def RegisterMoveCallback2(callback: MoveCallback2, get_move_size: GetMoveSizeCallback, apply_move: ApplyMoveCallback, free_move: FreeMoveCallback) -> None: - """ - Register a callback to handle C-Move requests (full version, with multiple suboperations). - - Args: - callback (MoveCallback2): Main callback that creates the C-Move driver. - get_move_size (GetMoveSizeCallback): Callback to read the number of C-Move suboperations. - apply_move (ApplyMoveCallback): Callback to apply one C-Move suboperation. - free_move (FreeMoveCallback): Callback to free the C-Move driver. - """ - ... - -class OnChangeCallback(typing.Protocol): - def __call__(self, change_type: ChangeType, resource_type: ResourceType, resource_id: str) -> None: - ... - -# Register a callback to monitor changes -def RegisterOnChangeCallback(callback: OnChangeCallback) -> None: - """ - Register a callback to monitor changes. - - Args: - callback (OnChangeCallback): The callback function. - """ - ... - -class OnStoredInstanceCallback(typing.Protocol): - def __call__(self, instance: DicomInstance, instance_id: str) -> None: - ... - -# Register a callback for received DICOM instances -def RegisterOnStoredInstanceCallback(callback: OnStoredInstanceCallback) -> None: - """ - Register a callback for received DICOM instances. - - Args: - callback (OnStoredInstanceCallback): The callback function. - """ - ... - -class ReceivedInstanceCallback(typing.Protocol): - def __call__(self, received_dicom: bytes, origin: InstanceOrigin) -> tuple[ReceivedInstanceAction, bytes]: - ... - -# Register a callback to keep/discard/modify a DICOM instance received by Orthanc from any source (C-STORE or REST API) -def RegisterReceivedInstanceCallback(callback: ReceivedInstanceCallback) -> None: - """ - Register a callback to keep/discard/modify a DICOM instance received by Orthanc from any source (C-STORE or REST API). - - Args: - callback (ReceivedInstanceCallback): The callback function. - """ - ... - -class RestCallback(typing.Protocol): - def __call__(self, output: RestOutput, url: str, method: HttpMethod, groups: dict, get: dict, headers: dict, body: bytes=None) -> None: - ... - -# Register a REST callback -def RegisterRestCallback(path_regular_expression: str, callback: RestCallback) -> None: - """ - Register a REST callback. - - Args: - path_regular_expression (str): Regular expression for the URI. May contain groups. - callback (RestCallback): The callback function to handle the REST call. - """ - ... - -class StorageCreateCallback(typing.Protocol): - def __call__(self, uuid: str, content_type: ContentType, data: bytes) -> None: - ... - -class StorageReadCallback(typing.Protocol): - def __call__(self, uuid: str, content_type: ContentType) -> bytes: - ... - -class StorageRemoveCallback(typing.Protocol): - def __call__(self, uuid: str, content_type: ContentType) -> None: - ... - -# Register a custom storage area -def RegisterStorageArea(create: StorageCreateCallback, read: StorageReadCallback, remove: StorageRemoveCallback) -> None: - """ - Register a custom storage area. - - Args: - create (StorageCreateCallback): The callback function to store a file on the custom storage area. - read (StorageReadCallback): The callback function to read a file from the custom storage area. - remove (StorageRemoveCallback): The callback function to remove a file from the custom storage area. - """ - ... - -class StorageCommitmentScpCallback(typing.Protocol): - def __call__(self, job_id: str, transaction_uid: str, sop_class_uids: list[str], sop_instance_uids: list[str], remote_aet: str, called_aet: str) -> object: - ... - -class StorageCommitmentLookup(typing.Protocol): - def __call__(self, sop_class_uid: str, sop_instance_uid: str, driver: object) -> StorageCommitmentFailureReason: - ... - -# Register a callback to handle incoming requests to the storage commitment SCP -def RegisterStorageCommitmentScpCallback(callback: StorageCommitmentScpCallback, lookup: StorageCommitmentLookup) -> None: - """ - Register a callback to handle incoming requests to the storage commitment SCP. - - Args: - callback (StorageCommitmentScpCallback): Main callback that creates the a driver to handle an incoming storage commitment request. - lookup (StorageCommitmentLookup): Callback function to get the status of one DICOM instance. - """ - ... - -class WorklistCallback(typing.Protocol): - def __call__(self, answers: WorklistAnswers, query: WorklistQuery, issuer_aet: str, called_aet: str) -> None: - ... - -# Register a callback to handle modality worklists requests -def RegisterWorklistCallback(callback: WorklistCallback) -> None: - """ - Register a callback to handle modality worklists requests. - - Args: - callback (WorklistCallback): The callback function. - """ - ... - - -class DicomInstance: - """ - DICOM instance managed by the Orthanc core - """ - ... - - - # This function returns the Application Entity Title (AET) of the DICOM modality from which a DICOM instance originates - def GetInstanceRemoteAet(self) -> str: - """ - This function returns the Application Entity Title (AET) of the DICOM modality from which a DICOM instance originates. - - Returns: - str: The AET if success, NULL if error. - """ - ... - - # This function returns the number of bytes of the given DICOM instance - def GetInstanceSize(self) -> int: - """ - This function returns the number of bytes of the given DICOM instance. - - Returns: - int: The size of the file, -1 in case of error. - """ - ... - - # This function returns a pointer to a newly created string containing a JSON file - def GetInstanceJson(self) -> str: - """ - This function returns a pointer to a newly created string containing a JSON file. This JSON file encodes the tag hierarchy of the given DICOM instance. - - Returns: - str: The NULL value in case of error, or a string containing the JSON file. This string must be freed by OrthancPluginFreeString(). - """ - ... - - # This function returns a pointer to a newly created string containing a JSON file - def GetInstanceSimplifiedJson(self) -> str: - """ - This function returns a pointer to a newly created string containing a JSON file. This JSON file encodes the tag hierarchy of the given DICOM instance. In contrast with ::OrthancPluginGetInstanceJson(), the returned JSON file is in its simplified version. - - Returns: - str: The NULL value in case of error, or a string containing the JSON file. This string must be freed by OrthancPluginFreeString(). - """ - ... - - # This function checks whether the DICOM instance of interest is associated with some metadata - def HasInstanceMetadata(self, metadata: str) -> int: - """ - This function checks whether the DICOM instance of interest is associated with some metadata. As of Orthanc 0.8.1, in the callbacks registered by ::OrthancPluginRegisterOnStoredInstanceCallback(), the only possibly available metadata are "ReceptionDate", "RemoteAET" and "IndexInSeries". - - Args: - metadata (str): The metadata of interest. - - Returns: - int: 1 if the metadata is present, 0 if it is absent, -1 in case of error. - """ - ... - - # This functions returns the value of some metadata that is associated with the DICOM instance of interest - def GetInstanceMetadata(self, metadata: str) -> str: - """ - This functions returns the value of some metadata that is associated with the DICOM instance of interest. Before calling this function, the existence of the metadata must have been checked with ::OrthancPluginHasInstanceMetadata(). - - Args: - metadata (str): The metadata of interest. - - Returns: - str: The metadata value if success, NULL if error. Please note that the returned string belongs to the instance object and must NOT be deallocated. Please make a copy of the string if you wish to access it later. - """ - ... - - # This function returns the origin of a DICOM instance that has been received by Orthanc - def GetInstanceOrigin(self) -> InstanceOrigin: - """ - This function returns the origin of a DICOM instance that has been received by Orthanc. - - Returns: - InstanceOrigin: The origin of the instance. - """ - ... - - # This function returns a pointer to a newly created string that contains the transfer syntax UID of the DICOM instance - def GetInstanceTransferSyntaxUid(self) -> str: - """ - This function returns a pointer to a newly created string that contains the transfer syntax UID of the DICOM instance. The empty string might be returned if this information is unknown. - - Returns: - str: The NULL value in case of error, or a string containing the transfer syntax UID. This string must be freed by OrthancPluginFreeString(). - """ - ... - - # This function returns a Boolean value indicating whether the DICOM instance contains the pixel data (7FE0,0010) tag - def HasInstancePixelData(self) -> int: - """ - This function returns a Boolean value indicating whether the DICOM instance contains the pixel data (7FE0,0010) tag. - - Returns: - int: "1" if the DICOM instance contains pixel data, or "0" if the tag is missing, or "-1" in the case of an error. - """ - ... - - # This function returns the number of frames that are part of a DICOM image managed by the Orthanc core - def GetInstanceFramesCount(self) -> int: - """ - This function returns the number of frames that are part of a DICOM image managed by the Orthanc core. - - Returns: - int: The number of frames (will be zero in the case of an error). - """ - ... - - # This function returns a memory buffer containing the raw content of a frame in a DICOM instance that is managed by the Orthanc core - def GetInstanceRawFrame(self, frame_index: int) -> bytes: - """ - This function returns a memory buffer containing the raw content of a frame in a DICOM instance that is managed by the Orthanc core. This is notably useful for compressed transfer syntaxes, as it gives access to the embedded files (such as JPEG, JPEG-LS or JPEG2k). The Orthanc core transparently reassembles the fragments to extract the raw frame. - - Args: - frame_index (int): The index of the frame of interest. - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - - # This function decodes one frame of a DICOM image that is managed by the Orthanc core - def GetInstanceDecodedFrame(self, frame_index: int) -> Image: - """ - This function decodes one frame of a DICOM image that is managed by the Orthanc core. - - Args: - frame_index (int): The index of the frame of interest. - - Returns: - Image: The uncompressed image. It must be freed with OrthancPluginFreeImage(). - """ - ... - - # This function returns a memory buffer containing the serialization of a DICOM instance that is managed by the Orthanc core - def SerializeDicomInstance(self) -> bytes: - """ - This function returns a memory buffer containing the serialization of a DICOM instance that is managed by the Orthanc core. - - Returns: - bytes: 0 if success, or the error code if failure. - """ - ... - - # This function takes as DICOM instance managed by the Orthanc core, and outputs a JSON string representing the tags of this DICOM file - def GetInstanceAdvancedJson(self, format: DicomToJsonFormat, flags: DicomToJsonFlags, max_string_length: int) -> str: - """ - This function takes as DICOM instance managed by the Orthanc core, and outputs a JSON string representing the tags of this DICOM file. - - Args: - format (DicomToJsonFormat): The output format. - flags (DicomToJsonFlags): Flags governing the output. - max_string_length (int): The maximum length of a field. Too long fields will be output as "null". The 0 value means no maximum length. - - Returns: - str: The NULL value if the case of an error, or the JSON string. This string must be freed by OrthancPluginFreeString(). - """ - ... - - - # Get the content of the DICOM instance - def GetInstanceData(self) -> bytes: - """ - Get the content of the DICOM instance. - - Returns: - bytes: The DICOM data. - """ - ... -class DicomWebNode: - """ - Node visited by DICOMweb conversion - """ - ... - - -class FindAnswers: - """ - Answers to a DICOM C-FIND query - """ - ... - - - # This function adds one answer (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request that is not related to modality worklists - def FindAddAnswer(self, dicom: bytes) -> None: - """ - This function adds one answer (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request that is not related to modality worklists. - - Args: - dicom (bytes): The answer to be added, encoded as a DICOM file. - """ - ... - - # This function marks as incomplete the set of answers corresponding to some C-Find SCP request that is not related to modality worklists - def FindMarkIncomplete(self) -> None: - """ - This function marks as incomplete the set of answers corresponding to some C-Find SCP request that is not related to modality worklists. This must be used if canceling the handling of a request when too many answers are to be returned. - """ - ... - -class FindMatcher: - """ - Matcher for DICOM C-FIND query - """ - ... - - - # This function checks whether one DICOM instance matches C-Find matcher that was previously allocated using OrthancPluginCreateFindMatcher() - def FindMatcherIsMatch(self, dicom: bytes) -> int: - """ - This function checks whether one DICOM instance matches C-Find matcher that was previously allocated using OrthancPluginCreateFindMatcher(). - - Args: - dicom (bytes): The DICOM instance to be matched. - - Returns: - int: 1 if the DICOM instance matches the query, 0 otherwise. - """ - ... - -class FindQuery: - """ - DICOM C-FIND query - """ - ... - - - # This function returns the number of tags that are contained in the given C-Find query - def GetFindQuerySize(self) -> int: - """ - This function returns the number of tags that are contained in the given C-Find query. - - Returns: - int: The number of tags. - """ - ... - - # This function returns the symbolic name of one DICOM tag in the given C-Find query - def GetFindQueryTagName(self, index: int) -> str: - """ - This function returns the symbolic name of one DICOM tag in the given C-Find query. - - Args: - index (int): The index of the tag of interest. - - Returns: - str: 0 if success, other value if error. - """ - ... - - # This function returns the value associated with one tag in the given C-Find query - def GetFindQueryValue(self, index: int) -> str: - """ - This function returns the value associated with one tag in the given C-Find query. - - Args: - index (int): The index of the tag of interest. - - Returns: - str: 0 if success, other value if error. - """ - ... - - - # This function returns the element of one DICOM tag in the given C-Find query - def GetFindQueryTagElement(self, index: int) -> int: - """ - This function returns the element of one DICOM tag in the given C-Find query. - - Args: - index (int): The index of the tag of interest. - - Returns: - int: The value of the element. - """ - ... - - # This function returns the group of one DICOM tag in the given C-Find query - def GetFindQueryTagGroup(self, index: int) -> int: - """ - This function returns the group of one DICOM tag in the given C-Find query. - - Args: - index (int): The index of the tag of interest. - - Returns: - int: The value of the group. - """ - ... -class Image: - """ - 2D image managed by the Orthanc core - """ - ... - - - # This function returns the type of memory layout for the pixels of the given image - def GetImagePixelFormat(self) -> PixelFormat: - """ - This function returns the type of memory layout for the pixels of the given image. - - Returns: - PixelFormat: The pixel format. - """ - ... - - # This function returns the width of the given image - def GetImageWidth(self) -> int: - """ - This function returns the width of the given image. - - Returns: - int: The width. - """ - ... - - # This function returns the height of the given image - def GetImageHeight(self) -> int: - """ - This function returns the height of the given image. - - Returns: - int: The height. - """ - ... - - # This function returns the pitch of the given image - def GetImagePitch(self) -> int: - """ - This function returns the pitch of the given image. The pitch is defined as the number of bytes between 2 successive lines of the image in the memory buffer. - - Returns: - int: The pitch. - """ - ... - - # This function creates a new image, changing the memory layout of the pixels - def ConvertPixelFormat(self, target_format: PixelFormat) -> Image: - """ - This function creates a new image, changing the memory layout of the pixels. - - Args: - target_format (PixelFormat): The target pixel format. - - Returns: - Image: The resulting image. It must be freed with OrthancPluginFreeImage(). - """ - ... - - # This function draws some text on some image - def DrawText(self, font_index: int, utf8_text: str, x: int, y: int, r: int, g: int, b: int) -> None: - """ - This function draws some text on some image. - - Args: - font_index (int): The index of the font. This value must be less than OrthancPluginGetFontsCount(). - utf8_text (str): The text to be drawn, encoded as an UTF-8 zero-terminated string. - x (int): The X position of the text over the image. - y (int): The Y position of the text over the image. - r (int): The value of the red color channel of the text. - g (int): The value of the green color channel of the text. - b (int): The value of the blue color channel of the text. - """ - ... - - - # This function returns a pointer to the memory buffer that contains the pixels of the image - def GetImageBuffer(self) -> bytes: - """ - This function returns a pointer to the memory buffer that contains the pixels of the image. - - Returns: - bytes: The pixel data. - """ - ... -class Job: - """ - Orthanc job - """ - ... - - - # This function adds the given job to the pending jobs of Orthanc - def SubmitJob(self, priority: int) -> str: - """ - This function adds the given job to the pending jobs of Orthanc. Orthanc will take take of freeing it by invoking the finalization callback provided to OrthancPluginCreateJob(). - - Args: - priority (int): The priority of the job. - - Returns: - str: ID of the newly-submitted job. This string must be freed by OrthancPluginFreeString(). - """ - ... - -class Peers: - """ - Orthanc peer - """ - ... - - - # This function returns the number of Orthanc peers - def GetPeersCount(self) -> int: - """ - This function returns the number of Orthanc peers. - This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function. - - Returns: - int: The number of peers. - """ - ... - - # This function returns the symbolic name of the Orthanc peer, which corresponds to the key of the "OrthancPeers" configuration option of Orthanc - def GetPeerName(self, peer_index: int) -> str: - """ - This function returns the symbolic name of the Orthanc peer, which corresponds to the key of the "OrthancPeers" configuration option of Orthanc. - This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function. - - Args: - peer_index (int): The index of the peer of interest. This value must be lower than OrthancPluginGetPeersCount(). - - Returns: - str: The symbolic name, or NULL in the case of an error. - """ - ... - - # This function returns the base URL to the REST API of some Orthanc peer - def GetPeerUrl(self, peer_index: int) -> str: - """ - This function returns the base URL to the REST API of some Orthanc peer. - This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function. - - Args: - peer_index (int): The index of the peer of interest. This value must be lower than OrthancPluginGetPeersCount(). - - Returns: - str: The URL, or NULL in the case of an error. - """ - ... - - # This function returns some user-defined property of some Orthanc peer - def GetPeerUserProperty(self, peer_index: int, user_property: str) -> str: - """ - This function returns some user-defined property of some Orthanc peer. An user-defined property is a property that is associated with the peer in the Orthanc configuration file, but that is not recognized by the Orthanc core. - This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function. - - Args: - peer_index (int): The index of the peer of interest. This value must be lower than OrthancPluginGetPeersCount(). - user_property (str): The user property of interest. - - Returns: - str: The value of the user property, or NULL if it is not defined. - """ - ... - -class RestOutput: - """ - Output for a call to the REST API of Orthanc - """ - ... - - - # This function answers to a REST request with the content of a memory buffer - def AnswerBuffer(self, answer: bytes, mime_type: str) -> None: - """ - This function answers to a REST request with the content of a memory buffer. - - Args: - answer (bytes): Pointer to the memory buffer containing the answer. - mime_type (str): The MIME type of the answer. - """ - ... - - # This function answers to a REST request with a PNG image - def CompressAndAnswerPngImage(self, format: PixelFormat, width: int, height: int, pitch: int, buffer: bytes) -> None: - """ - This function answers to a REST request with a PNG image. The parameters of this function describe a memory buffer that contains an uncompressed image. The image will be automatically compressed as a PNG image by the core system of Orthanc. - - Args: - format (PixelFormat): The memory layout of the uncompressed image. - width (int): The width of the image. - height (int): The height of the image. - pitch (int): The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer). - buffer (bytes): The memory buffer containing the uncompressed image. - """ - ... - - # This function answers to a REST request by redirecting the user to another URI using HTTP status 301 - def Redirect(self, redirection: str) -> None: - """ - This function answers to a REST request by redirecting the user to another URI using HTTP status 301. - - Args: - redirection (str): Where to redirect. - """ - ... - - # This function answers to a REST request by sending a HTTP status code (such as "400 - Bad Request") - def SendHttpStatusCode(self, status: int) -> None: - """ - This function answers to a REST request by sending a HTTP status code (such as "400 - Bad Request"). Note that: - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). - Redirections (status 301) must use ::OrthancPluginRedirect(). - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed(). - - Args: - status (int): The HTTP status code to be sent. - """ - ... - - # This function answers to a REST request by signaling that it is not authorized - def SendUnauthorized(self, realm: str) -> None: - """ - This function answers to a REST request by signaling that it is not authorized. - - Args: - realm (str): The realm for the authorization process. - """ - ... - - # This function answers to a REST request by signaling that the queried URI does not support this method - def SendMethodNotAllowed(self, allowed_methods: str) -> None: - """ - This function answers to a REST request by signaling that the queried URI does not support this method. - - Args: - allowed_methods (str): The allowed methods for this URI (e.g. "GET,POST" after a PUT or a POST request). - """ - ... - - # This function sets a cookie in the HTTP client - def SetCookie(self, cookie: str, value: str) -> None: - """ - This function sets a cookie in the HTTP client. - - Args: - cookie (str): The cookie to be set. - value (str): The value of the cookie. - """ - ... - - # This function sets a HTTP header in the HTTP answer - def SetHttpHeader(self, key: str, value: str) -> None: - """ - This function sets a HTTP header in the HTTP answer. - - Args: - key (str): The HTTP header to be set. - value (str): The value of the HTTP header. - """ - ... - - # Initiates a HTTP multipart answer, as the result of a REST request - def StartMultipartAnswer(self, sub_type: str, content_type: str) -> None: - """ - Initiates a HTTP multipart answer, as the result of a REST request. - - Args: - sub_type (str): The sub-type of the multipart answer ("mixed" or "related"). - content_type (str): The MIME type of the items in the multipart answer. - """ - ... - - # This function sends an item as a part of some HTTP multipart answer that was initiated by OrthancPluginStartMultipartAnswer() - def SendMultipartItem(self, answer: bytes) -> None: - """ - This function sends an item as a part of some HTTP multipart answer that was initiated by OrthancPluginStartMultipartAnswer(). - - Args: - answer (bytes): Pointer to the memory buffer containing the item. - """ - ... - - # This function answers to a HTTP request by sending a HTTP status code (such as "400 - Bad Request"), together with a body describing the error - def SendHttpStatus(self, status: int, body: bytes) -> None: - """ - This function answers to a HTTP request by sending a HTTP status code (such as "400 - Bad Request"), together with a body describing the error. The body will only be returned if the configuration option "HttpDescribeErrors" of Orthanc is set to "true". - Note that: - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). - Redirections (status 301) must use ::OrthancPluginRedirect(). - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed(). - - Args: - status (int): The HTTP status code to be sent. - body (bytes): The body of the answer. - """ - ... - - # This function answers to a REST request with a JPEG image - def CompressAndAnswerJpegImage(self, format: PixelFormat, width: int, height: int, pitch: int, buffer: bytes, quality: int) -> None: - """ - This function answers to a REST request with a JPEG image. The parameters of this function describe a memory buffer that contains an uncompressed image. The image will be automatically compressed as a JPEG image by the core system of Orthanc. - - Args: - format (PixelFormat): The memory layout of the uncompressed image. - width (int): The width of the image. - height (int): The height of the image. - pitch (int): The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer). - buffer (bytes): The memory buffer containing the uncompressed image. - quality (int): The quality of the JPEG encoding, between 1 (worst quality, best compression) and 100 (best quality, worst compression). - """ - ... - - # This function sets the detailed description associated with an HTTP error - def SetHttpErrorDetails(self, details: str, log: int) -> None: - """ - This function sets the detailed description associated with an HTTP error. This description will be displayed in the "Details" field of the JSON body of the HTTP answer. It is only taken into consideration if the REST callback returns an error code that is different from "OrthancPluginErrorCode_Success", and if the "HttpDescribeErrors" configuration option of Orthanc is set to "true". - - Args: - details (str): The details of the error message. - log (int): Whether to also write the detailed error to the Orthanc logs. - """ - ... - -class ServerChunkedRequestReader: - """ - Read for a chunked HTTP request - """ - ... - - -class StorageArea: - """ - Storage area plugin - """ - ... - - - # This function creates a new file inside the storage area that is currently used by Orthanc - def StorageAreaCreate(self, uuid: str, content: bytes, size: int, type: ContentType) -> None: - """ - This function creates a new file inside the storage area that is currently used by Orthanc. - - Args: - uuid (str): The identifier of the file to be created. - content (bytes): The content to store in the newly created file. - size (int): The size of the content. - type (ContentType): The type of the file content. - """ - ... - - # This function reads the content of a given file from the storage area that is currently used by Orthanc - def StorageAreaRead(self, uuid: str, type: ContentType) -> bytes: - """ - This function reads the content of a given file from the storage area that is currently used by Orthanc. - - Args: - uuid (str): The identifier of the file to be read. - type (ContentType): The type of the file content. - - Returns: - bytes: 0 if success, other value if error. - """ - ... - - # This function removes a given file from the storage area that is currently used by Orthanc - def StorageAreaRemove(self, uuid: str, type: ContentType) -> None: - """ - This function removes a given file from the storage area that is currently used by Orthanc. - - Args: - uuid (str): The identifier of the file to be removed. - type (ContentType): The type of the file content. - """ - ... - - # This function requests the Orthanc core to reconstruct the main DICOM tags of all the resources of the given type - def ReconstructMainDicomTags(self, level: ResourceType) -> None: - """ - This function requests the Orthanc core to reconstruct the main DICOM tags of all the resources of the given type. This function can only be used as a part of the upgrade of a custom database back-end. A database transaction will be automatically setup. - - Args: - level (ResourceType): The type of the resources of interest. - """ - ... - -class WorklistAnswers: - """ - Answers to a DICOM C-FIND worklist query - """ - ... - - - # This function adds one worklist (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request against modality worklists - def WorklistAddAnswer(self, query: WorklistQuery, dicom: bytes) -> None: - """ - This function adds one worklist (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request against modality worklists. - - Args: - query (WorklistQuery): The worklist query, as received by the callback. - dicom (bytes): The worklist to answer, encoded as a DICOM file. - """ - ... - - # This function marks as incomplete the set of answers corresponding to some C-Find SCP request against modality worklists - def WorklistMarkIncomplete(self) -> None: - """ - This function marks as incomplete the set of answers corresponding to some C-Find SCP request against modality worklists. This must be used if canceling the handling of a request when too many answers are to be returned. - """ - ... - -class WorklistQuery: - """ - DICOM C-FIND worklist query - """ - ... - - - # This function checks whether one worklist (encoded as a DICOM file) matches the C-Find SCP query against modality worklists - def WorklistIsMatch(self, dicom: bytes) -> int: - """ - This function checks whether one worklist (encoded as a DICOM file) matches the C-Find SCP query against modality worklists. This function must be called before adding the worklist as an answer through OrthancPluginWorklistAddAnswer(). - - Args: - dicom (bytes): The worklist to answer, encoded as a DICOM file. - - Returns: - int: 1 if the worklist matches the query, 0 otherwise. - """ - ... - - # This function retrieves the DICOM file that underlies a C-Find SCP query against modality worklists - def WorklistGetDicomQuery(self) -> bytes: - """ - This function retrieves the DICOM file that underlies a C-Find SCP query against modality worklists. - - Returns: - bytes: 0 if success, other value if error. - """ - ... - diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk.cpp --- a/Sources/Autogenerated/sdk.cpp Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -#include "sdk.h" - -#include "../PythonLock.h" -#include "../PythonThreadsAllower.h" - -#include "../../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" - -#include "./sdk_OrthancPluginChangeType.impl.h" -#include "./sdk_OrthancPluginCompressionType.impl.h" -#include "./sdk_OrthancPluginConstraintType.impl.h" -#include "./sdk_OrthancPluginContentType.impl.h" -#include "./sdk_OrthancPluginCreateDicomFlags.impl.h" -#include "./sdk_OrthancPluginDicomToJsonFlags.impl.h" -#include "./sdk_OrthancPluginDicomToJsonFormat.impl.h" -#include "./sdk_OrthancPluginDicomWebBinaryMode.impl.h" -#include "./sdk_OrthancPluginErrorCode.impl.h" -#include "./sdk_OrthancPluginHttpMethod.impl.h" -#include "./sdk_OrthancPluginIdentifierConstraint.impl.h" -#include "./sdk_OrthancPluginImageFormat.impl.h" -#include "./sdk_OrthancPluginInstanceOrigin.impl.h" -#include "./sdk_OrthancPluginJobStepStatus.impl.h" -#include "./sdk_OrthancPluginJobStopReason.impl.h" -#include "./sdk_OrthancPluginMetricsType.impl.h" -#include "./sdk_OrthancPluginPixelFormat.impl.h" -#include "./sdk_OrthancPluginReceivedInstanceAction.impl.h" -#include "./sdk_OrthancPluginResourceType.impl.h" -#include "./sdk_OrthancPluginStorageCommitmentFailureReason.impl.h" -#include "./sdk_OrthancPluginValueRepresentation.impl.h" - -#include "./sdk_OrthancPluginDicomInstance.impl.h" -#include "./sdk_OrthancPluginDicomWebNode.impl.h" -#include "./sdk_OrthancPluginFindAnswers.impl.h" -#include "./sdk_OrthancPluginFindMatcher.impl.h" -#include "./sdk_OrthancPluginFindQuery.impl.h" -#include "./sdk_OrthancPluginImage.impl.h" -#include "./sdk_OrthancPluginJob.impl.h" -#include "./sdk_OrthancPluginPeers.impl.h" -#include "./sdk_OrthancPluginRestOutput.impl.h" -#include "./sdk_OrthancPluginServerChunkedRequestReader.impl.h" -#include "./sdk_OrthancPluginStorageArea.impl.h" -#include "./sdk_OrthancPluginWorklistAnswers.impl.h" -#include "./sdk_OrthancPluginWorklistQuery.impl.h" - -#include "./sdk_GlobalFunctions.impl.h" - -#include "./sdk_OrthancPluginDicomInstance.methods.h" -#include "./sdk_OrthancPluginDicomWebNode.methods.h" -#include "./sdk_OrthancPluginFindAnswers.methods.h" -#include "./sdk_OrthancPluginFindMatcher.methods.h" -#include "./sdk_OrthancPluginFindQuery.methods.h" -#include "./sdk_OrthancPluginImage.methods.h" -#include "./sdk_OrthancPluginJob.methods.h" -#include "./sdk_OrthancPluginPeers.methods.h" -#include "./sdk_OrthancPluginRestOutput.methods.h" -#include "./sdk_OrthancPluginServerChunkedRequestReader.methods.h" -#include "./sdk_OrthancPluginStorageArea.methods.h" -#include "./sdk_OrthancPluginWorklistAnswers.methods.h" -#include "./sdk_OrthancPluginWorklistQuery.methods.h" - -void RegisterOrthancSdk(PyObject* module) -{ - RegisterOrthancPluginChangeTypeEnumeration(module); - RegisterOrthancPluginCompressionTypeEnumeration(module); - RegisterOrthancPluginConstraintTypeEnumeration(module); - RegisterOrthancPluginContentTypeEnumeration(module); - RegisterOrthancPluginCreateDicomFlagsEnumeration(module); - RegisterOrthancPluginDicomToJsonFlagsEnumeration(module); - RegisterOrthancPluginDicomToJsonFormatEnumeration(module); - RegisterOrthancPluginDicomWebBinaryModeEnumeration(module); - RegisterOrthancPluginErrorCodeEnumeration(module); - RegisterOrthancPluginHttpMethodEnumeration(module); - RegisterOrthancPluginIdentifierConstraintEnumeration(module); - RegisterOrthancPluginImageFormatEnumeration(module); - RegisterOrthancPluginInstanceOriginEnumeration(module); - RegisterOrthancPluginJobStepStatusEnumeration(module); - RegisterOrthancPluginJobStopReasonEnumeration(module); - RegisterOrthancPluginMetricsTypeEnumeration(module); - RegisterOrthancPluginPixelFormatEnumeration(module); - RegisterOrthancPluginReceivedInstanceActionEnumeration(module); - RegisterOrthancPluginResourceTypeEnumeration(module); - RegisterOrthancPluginStorageCommitmentFailureReasonEnumeration(module); - RegisterOrthancPluginValueRepresentationEnumeration(module); - - RegisterOrthancPluginDicomInstanceClass(module); - RegisterOrthancPluginDicomWebNodeClass(module); - RegisterOrthancPluginFindAnswersClass(module); - RegisterOrthancPluginFindMatcherClass(module); - RegisterOrthancPluginFindQueryClass(module); - RegisterOrthancPluginImageClass(module); - RegisterOrthancPluginJobClass(module); - RegisterOrthancPluginPeersClass(module); - RegisterOrthancPluginRestOutputClass(module); - RegisterOrthancPluginServerChunkedRequestReaderClass(module); - RegisterOrthancPluginStorageAreaClass(module); - RegisterOrthancPluginWorklistAnswersClass(module); - RegisterOrthancPluginWorklistQueryClass(module); -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk.h --- a/Sources/Autogenerated/sdk.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,169 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -#pragma once - -#include "../PythonHeaderWrapper.h" - -void RegisterOrthancSdk(PyObject* module); -PyMethodDef* GetOrthancSdkFunctions(); - -PyTypeObject* GetOrthancPluginDicomInstanceType(); -PyTypeObject* GetOrthancPluginDicomWebNodeType(); -PyTypeObject* GetOrthancPluginFindAnswersType(); -PyTypeObject* GetOrthancPluginFindMatcherType(); -PyTypeObject* GetOrthancPluginFindQueryType(); -PyTypeObject* GetOrthancPluginImageType(); -PyTypeObject* GetOrthancPluginJobType(); -PyTypeObject* GetOrthancPluginPeersType(); -PyTypeObject* GetOrthancPluginRestOutputType(); -PyTypeObject* GetOrthancPluginServerChunkedRequestReaderType(); -PyTypeObject* GetOrthancPluginStorageAreaType(); -PyTypeObject* GetOrthancPluginWorklistAnswersType(); -PyTypeObject* GetOrthancPluginWorklistQueryType(); - -#include - -typedef struct -{ - PyObject_HEAD - - /* Type-specific fields go here. */ - OrthancPluginDicomInstance* object_; - bool borrowed_; -} sdk_OrthancPluginDicomInstance_Object; - -typedef struct -{ - PyObject_HEAD - - /* Type-specific fields go here. */ - OrthancPluginDicomWebNode* object_; - bool borrowed_; -} sdk_OrthancPluginDicomWebNode_Object; - -typedef struct -{ - PyObject_HEAD - - /* Type-specific fields go here. */ - OrthancPluginFindAnswers* object_; - bool borrowed_; -} sdk_OrthancPluginFindAnswers_Object; - -typedef struct -{ - PyObject_HEAD - - /* Type-specific fields go here. */ - OrthancPluginFindMatcher* object_; - bool borrowed_; -} sdk_OrthancPluginFindMatcher_Object; - -typedef struct -{ - PyObject_HEAD - - /* Type-specific fields go here. */ - OrthancPluginFindQuery* object_; - bool borrowed_; -} sdk_OrthancPluginFindQuery_Object; - -typedef struct -{ - PyObject_HEAD - - /* Type-specific fields go here. */ - OrthancPluginImage* object_; - bool borrowed_; -} sdk_OrthancPluginImage_Object; - -typedef struct -{ - PyObject_HEAD - - /* Type-specific fields go here. */ - OrthancPluginJob* object_; - bool borrowed_; -} sdk_OrthancPluginJob_Object; - -typedef struct -{ - PyObject_HEAD - - /* Type-specific fields go here. */ - OrthancPluginPeers* object_; - bool borrowed_; -} sdk_OrthancPluginPeers_Object; - -typedef struct -{ - PyObject_HEAD - - /* Type-specific fields go here. */ - OrthancPluginRestOutput* object_; - bool borrowed_; -} sdk_OrthancPluginRestOutput_Object; - -typedef struct -{ - PyObject_HEAD - - /* Type-specific fields go here. */ - OrthancPluginServerChunkedRequestReader* object_; - bool borrowed_; -} sdk_OrthancPluginServerChunkedRequestReader_Object; - -typedef struct -{ - PyObject_HEAD - - /* Type-specific fields go here. */ - OrthancPluginStorageArea* object_; - bool borrowed_; -} sdk_OrthancPluginStorageArea_Object; - -typedef struct -{ - PyObject_HEAD - - /* Type-specific fields go here. */ - OrthancPluginWorklistAnswers* object_; - bool borrowed_; -} sdk_OrthancPluginWorklistAnswers_Object; - -typedef struct -{ - PyObject_HEAD - - /* Type-specific fields go here. */ - OrthancPluginWorklistQuery* object_; - bool borrowed_; -} sdk_OrthancPluginWorklistQuery_Object; - diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_GlobalFunctions.impl.h --- a/Sources/Autogenerated/sdk_GlobalFunctions.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2073 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Forward declaration of the custom global functions -extern PyObject *CreateImageFromBuffer(PyObject* module, PyObject *args); -extern PyObject *LookupDictionary(PyObject* module, PyObject *args); -extern PyObject *RegisterFindCallback(PyObject* module, PyObject *args); -extern PyObject *RegisterIncomingCStoreInstanceFilter(PyObject* module, PyObject *args); -extern PyObject *RegisterIncomingHttpRequestFilter(PyObject* module, PyObject *args); -extern PyObject *RegisterMoveCallback(PyObject* module, PyObject *args); -extern PyObject *RegisterMoveCallback2(PyObject* module, PyObject *args); -extern PyObject *RegisterOnChangeCallback(PyObject* module, PyObject *args); -extern PyObject *RegisterOnStoredInstanceCallback(PyObject* module, PyObject *args); -extern PyObject *RegisterReceivedInstanceCallback(PyObject* module, PyObject *args); -extern PyObject *RegisterRestCallback(PyObject* module, PyObject *args); -extern PyObject *RegisterStorageArea(PyObject* module, PyObject *args); -extern PyObject *RegisterStorageCommitmentScpCallback(PyObject* module, PyObject *args); -extern PyObject *RegisterWorklistCallback(PyObject* module, PyObject *args); -// End of forward declarations - - -static PyObject* sdk_OrthancPluginAutodetectMimeType(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginAutodetectMimeType()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - const char* s; - { - PythonThreadsAllower allower; - s = OrthancPluginAutodetectMimeType(OrthancPlugins::GetGlobalContext(), arg0); - } - - if (s == NULL) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - return PyUnicode_FromString(s); - } -} - -static PyObject* sdk_OrthancPluginBufferCompression(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginBufferCompression()"); - - Py_buffer arg0; - long int arg2 = 0; - unsigned char arg3 = 0; - - if (!PyArg_ParseTuple(args, "s*lb", &arg0, &arg2, &arg3)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (3 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginBufferCompression(OrthancPlugins::GetGlobalContext(), *buffer, arg0.buf, arg0.len, static_cast(arg2), arg3); - } - PyBuffer_Release(&arg0); - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginCheckVersion(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginCheckVersion()"); - - - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginCheckVersion(OrthancPlugins::GetGlobalContext()); - } - - return PyLong_FromLong(value); -} - -static PyObject* sdk_OrthancPluginCheckVersionAdvanced(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginCheckVersionAdvanced()"); - - long int arg0 = 0; - long int arg1 = 0; - long int arg2 = 0; - - if (!PyArg_ParseTuple(args, "lll", &arg0, &arg1, &arg2)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (3 arguments expected)"); - return NULL; - } - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginCheckVersionAdvanced(OrthancPlugins::GetGlobalContext(), arg0, arg1, arg2); - } - - return PyLong_FromLong(value); -} - -static PyObject* sdk_OrthancPluginCompressJpegImage(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginCompressJpegImage()"); - - long int arg0 = 0; - unsigned long arg1 = 0; - unsigned long arg2 = 0; - unsigned long arg3 = 0; - Py_buffer arg4; - unsigned char arg5 = 0; - - if (!PyArg_ParseTuple(args, "lkkks*b", &arg0, &arg1, &arg2, &arg3, &arg4, &arg5)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (6 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginCompressJpegImage(OrthancPlugins::GetGlobalContext(), *buffer, static_cast(arg0), arg1, arg2, arg3, arg4.buf, arg5); - } - PyBuffer_Release(&arg4); - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginCompressPngImage(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginCompressPngImage()"); - - long int arg0 = 0; - unsigned long arg1 = 0; - unsigned long arg2 = 0; - unsigned long arg3 = 0; - Py_buffer arg4; - - if (!PyArg_ParseTuple(args, "lkkks*", &arg0, &arg1, &arg2, &arg3, &arg4)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (5 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginCompressPngImage(OrthancPlugins::GetGlobalContext(), *buffer, static_cast(arg0), arg1, arg2, arg3, arg4.buf); - } - PyBuffer_Release(&arg4); - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginComputeMd5(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginComputeMd5()"); - - Py_buffer arg0; - - if (!PyArg_ParseTuple(args, "s*", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginComputeMd5(OrthancPlugins::GetGlobalContext(), arg0.buf, arg0.len)); - } - PyBuffer_Release(&arg0); - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginComputeSha1(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginComputeSha1()"); - - Py_buffer arg0; - - if (!PyArg_ParseTuple(args, "s*", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginComputeSha1(OrthancPlugins::GetGlobalContext(), arg0.buf, arg0.len)); - } - PyBuffer_Release(&arg0); - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginCreateDicom(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginCreateDicom()"); - - const char* arg0 = NULL; - PyObject* arg1 = NULL; - long int arg2 = 0; - - if (!PyArg_ParseTuple(args, "sOl", &arg0, &arg1, &arg2)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (3 arguments expected)"); - return NULL; - } - - if (arg1 != Py_None && Py_TYPE(arg1) != GetOrthancPluginImageType()) - { - PyErr_SetString(PyExc_TypeError, "Invalid orthanc.OrthancPluginImage object"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginCreateDicom(OrthancPlugins::GetGlobalContext(), *buffer, arg0, arg1 == Py_None ? NULL : reinterpret_cast(arg1)->object_, static_cast(arg2)); - } - - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginCreateDicom2(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginCreateDicom2()"); - - const char* arg0 = NULL; - PyObject* arg1 = NULL; - long int arg2 = 0; - const char* arg3 = NULL; - - if (!PyArg_ParseTuple(args, "sOls", &arg0, &arg1, &arg2, &arg3)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (4 arguments expected)"); - return NULL; - } - - if (arg1 != Py_None && Py_TYPE(arg1) != GetOrthancPluginImageType()) - { - PyErr_SetString(PyExc_TypeError, "Invalid orthanc.OrthancPluginImage object"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginCreateDicom2(OrthancPlugins::GetGlobalContext(), *buffer, arg0, arg1 == Py_None ? NULL : reinterpret_cast(arg1)->object_, static_cast(arg2), arg3); - } - - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginCreateDicomInstance(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginCreateDicomInstance()"); - - Py_buffer arg0; - - if (!PyArg_ParseTuple(args, "s*", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - // This is the case of a constructor - OrthancPluginDicomInstance* obj; - { - PythonThreadsAllower allower; - obj = OrthancPluginCreateDicomInstance(OrthancPlugins::GetGlobalContext(), arg0.buf, arg0.len); - } - PyBuffer_Release(&arg0); - if (obj == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - PyObject *argList = Py_BuildValue("Lb", obj, false /* not borrowed */); - PyObject *python = PyObject_CallObject((PyObject *) &sdk_OrthancPluginDicomInstance_Type, argList); - Py_DECREF(argList); - return python; - } -} - -static PyObject* sdk_OrthancPluginCreateFindMatcher(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginCreateFindMatcher()"); - - Py_buffer arg0; - - if (!PyArg_ParseTuple(args, "s*", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - // This is the case of a constructor - OrthancPluginFindMatcher* obj; - { - PythonThreadsAllower allower; - obj = OrthancPluginCreateFindMatcher(OrthancPlugins::GetGlobalContext(), arg0.buf, arg0.len); - } - PyBuffer_Release(&arg0); - if (obj == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - PyObject *argList = Py_BuildValue("Lb", obj, false /* not borrowed */); - PyObject *python = PyObject_CallObject((PyObject *) &sdk_OrthancPluginFindMatcher_Type, argList); - Py_DECREF(argList); - return python; - } -} - -static PyObject* sdk_OrthancPluginCreateImage(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginCreateImage()"); - - long int arg0 = 0; - unsigned long arg1 = 0; - unsigned long arg2 = 0; - - if (!PyArg_ParseTuple(args, "lkk", &arg0, &arg1, &arg2)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (3 arguments expected)"); - return NULL; - } - - // This is the case of a constructor - OrthancPluginImage* obj; - { - PythonThreadsAllower allower; - obj = OrthancPluginCreateImage(OrthancPlugins::GetGlobalContext(), static_cast(arg0), arg1, arg2); - } - - if (obj == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - PyObject *argList = Py_BuildValue("Lb", obj, false /* not borrowed */); - PyObject *python = PyObject_CallObject((PyObject *) &sdk_OrthancPluginImage_Type, argList); - Py_DECREF(argList); - return python; - } -} - -static PyObject* sdk_OrthancPluginDecodeDicomImage(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginDecodeDicomImage()"); - - Py_buffer arg0; - unsigned long arg2 = 0; - - if (!PyArg_ParseTuple(args, "s*k", &arg0, &arg2)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - // This is the case of a constructor - OrthancPluginImage* obj; - { - PythonThreadsAllower allower; - obj = OrthancPluginDecodeDicomImage(OrthancPlugins::GetGlobalContext(), arg0.buf, arg0.len, arg2); - } - PyBuffer_Release(&arg0); - if (obj == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - PyObject *argList = Py_BuildValue("Lb", obj, false /* not borrowed */); - PyObject *python = PyObject_CallObject((PyObject *) &sdk_OrthancPluginImage_Type, argList); - Py_DECREF(argList); - return python; - } -} - -static PyObject* sdk_OrthancPluginDicomBufferToJson(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginDicomBufferToJson()"); - - Py_buffer arg0; - long int arg2 = 0; - long int arg3 = 0; - unsigned long arg4 = 0; - - if (!PyArg_ParseTuple(args, "s*llk", &arg0, &arg2, &arg3, &arg4)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (4 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginDicomBufferToJson(OrthancPlugins::GetGlobalContext(), arg0.buf, arg0.len, static_cast(arg2), static_cast(arg3), arg4)); - } - PyBuffer_Release(&arg0); - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginDicomInstanceToJson(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginDicomInstanceToJson()"); - - const char* arg0 = NULL; - long int arg1 = 0; - long int arg2 = 0; - unsigned long arg3 = 0; - - if (!PyArg_ParseTuple(args, "sllk", &arg0, &arg1, &arg2, &arg3)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (4 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginDicomInstanceToJson(OrthancPlugins::GetGlobalContext(), arg0, static_cast(arg1), static_cast(arg2), arg3)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginExtendOrthancExplorer(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginExtendOrthancExplorer()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginExtendOrthancExplorer(OrthancPlugins::GetGlobalContext(), arg0); - } - - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject* sdk_OrthancPluginGenerateRestApiAuthorizationToken(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGenerateRestApiAuthorizationToken()"); - - - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginGenerateRestApiAuthorizationToken(OrthancPlugins::GetGlobalContext())); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginGenerateUuid(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGenerateUuid()"); - - - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginGenerateUuid(OrthancPlugins::GetGlobalContext())); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginGetCommandLineArgument(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGetCommandLineArgument()"); - - unsigned long arg0 = 0; - - if (!PyArg_ParseTuple(args, "k", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginGetCommandLineArgument(OrthancPlugins::GetGlobalContext(), arg0)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginGetCommandLineArgumentsCount(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGetCommandLineArgumentsCount()"); - - - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginGetCommandLineArgumentsCount(OrthancPlugins::GetGlobalContext()); - } - - return PyLong_FromLong(value); -} - -static PyObject* sdk_OrthancPluginGetConfiguration(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGetConfiguration()"); - - - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginGetConfiguration(OrthancPlugins::GetGlobalContext())); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginGetConfigurationPath(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGetConfigurationPath()"); - - - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginGetConfigurationPath(OrthancPlugins::GetGlobalContext())); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginGetDicomForInstance(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGetDicomForInstance()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginGetDicomForInstance(OrthancPlugins::GetGlobalContext(), *buffer, arg0); - } - - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginGetErrorDescription(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGetErrorDescription()"); - - long int arg0 = 0; - - if (!PyArg_ParseTuple(args, "l", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - const char* s; - { - PythonThreadsAllower allower; - s = OrthancPluginGetErrorDescription(OrthancPlugins::GetGlobalContext(), static_cast(arg0)); - } - - if (s == NULL) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - return PyUnicode_FromString(s); - } -} - -static PyObject* sdk_OrthancPluginGetExpectedDatabaseVersion(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGetExpectedDatabaseVersion()"); - - - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginGetExpectedDatabaseVersion(OrthancPlugins::GetGlobalContext()); - } - - return PyLong_FromLong(value); -} - -static PyObject* sdk_OrthancPluginGetFontName(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGetFontName()"); - - unsigned long arg0 = 0; - - if (!PyArg_ParseTuple(args, "k", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - const char* s; - { - PythonThreadsAllower allower; - s = OrthancPluginGetFontName(OrthancPlugins::GetGlobalContext(), arg0); - } - - if (s == NULL) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - return PyUnicode_FromString(s); - } -} - -static PyObject* sdk_OrthancPluginGetFontSize(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGetFontSize()"); - - unsigned long arg0 = 0; - - if (!PyArg_ParseTuple(args, "k", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginGetFontSize(OrthancPlugins::GetGlobalContext(), arg0); - } - - return PyLong_FromLong(value); -} - -static PyObject* sdk_OrthancPluginGetFontsCount(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGetFontsCount()"); - - - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginGetFontsCount(OrthancPlugins::GetGlobalContext()); - } - - return PyLong_FromLong(value); -} - -static PyObject* sdk_OrthancPluginGetGlobalProperty(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGetGlobalProperty()"); - - long int arg0 = 0; - const char* arg1 = NULL; - - if (!PyArg_ParseTuple(args, "ls", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginGetGlobalProperty(OrthancPlugins::GetGlobalContext(), arg0, arg1)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginGetOrthancDirectory(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGetOrthancDirectory()"); - - - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginGetOrthancDirectory(OrthancPlugins::GetGlobalContext())); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginGetOrthancPath(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGetOrthancPath()"); - - - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginGetOrthancPath(OrthancPlugins::GetGlobalContext())); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginGetPeers(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGetPeers()"); - - - - // This is the case of a constructor - OrthancPluginPeers* obj; - { - PythonThreadsAllower allower; - obj = OrthancPluginGetPeers(OrthancPlugins::GetGlobalContext()); - } - - if (obj == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - PyObject *argList = Py_BuildValue("Lb", obj, false /* not borrowed */); - PyObject *python = PyObject_CallObject((PyObject *) &sdk_OrthancPluginPeers_Type, argList); - Py_DECREF(argList); - return python; - } -} - -static PyObject* sdk_OrthancPluginGetTagName(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginGetTagName()"); - - unsigned short arg0 = 0; - unsigned short arg1 = 0; - const char* arg2 = NULL; - - if (!PyArg_ParseTuple(args, "HHs", &arg0, &arg1, &arg2)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (3 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginGetTagName(OrthancPlugins::GetGlobalContext(), arg0, arg1, arg2)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginHttpDelete(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginHttpDelete()"); - - const char* arg0 = NULL; - const char* arg1 = NULL; - const char* arg2 = NULL; - - if (!PyArg_ParseTuple(args, "sss", &arg0, &arg1, &arg2)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (3 arguments expected)"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginHttpDelete(OrthancPlugins::GetGlobalContext(), arg0, arg1, arg2); - } - - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginHttpGet(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginHttpGet()"); - - const char* arg0 = NULL; - const char* arg1 = NULL; - const char* arg2 = NULL; - - if (!PyArg_ParseTuple(args, "sss", &arg0, &arg1, &arg2)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (3 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginHttpGet(OrthancPlugins::GetGlobalContext(), *buffer, arg0, arg1, arg2); - } - - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginHttpPost(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginHttpPost()"); - - const char* arg0 = NULL; - Py_buffer arg1; - const char* arg3 = NULL; - const char* arg4 = NULL; - - if (!PyArg_ParseTuple(args, "ss*ss", &arg0, &arg1, &arg3, &arg4)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (4 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginHttpPost(OrthancPlugins::GetGlobalContext(), *buffer, arg0, arg1.buf, arg1.len, arg3, arg4); - } - PyBuffer_Release(&arg1); - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginHttpPut(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginHttpPut()"); - - const char* arg0 = NULL; - Py_buffer arg1; - const char* arg3 = NULL; - const char* arg4 = NULL; - - if (!PyArg_ParseTuple(args, "ss*ss", &arg0, &arg1, &arg3, &arg4)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (4 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginHttpPut(OrthancPlugins::GetGlobalContext(), *buffer, arg0, arg1.buf, arg1.len, arg3, arg4); - } - PyBuffer_Release(&arg1); - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginLogError(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginLogError()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginLogError(OrthancPlugins::GetGlobalContext(), arg0); - } - - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject* sdk_OrthancPluginLogInfo(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginLogInfo()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginLogInfo(OrthancPlugins::GetGlobalContext(), arg0); - } - - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject* sdk_OrthancPluginLogWarning(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginLogWarning()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginLogWarning(OrthancPlugins::GetGlobalContext(), arg0); - } - - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject* sdk_OrthancPluginLookupInstance(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginLookupInstance()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginLookupInstance(OrthancPlugins::GetGlobalContext(), arg0)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginLookupPatient(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginLookupPatient()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginLookupPatient(OrthancPlugins::GetGlobalContext(), arg0)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginLookupSeries(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginLookupSeries()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginLookupSeries(OrthancPlugins::GetGlobalContext(), arg0)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginLookupStudy(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginLookupStudy()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginLookupStudy(OrthancPlugins::GetGlobalContext(), arg0)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginLookupStudyWithAccessionNumber(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginLookupStudyWithAccessionNumber()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginLookupStudyWithAccessionNumber(OrthancPlugins::GetGlobalContext(), arg0)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject* sdk_OrthancPluginReadFile(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginReadFile()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginReadFile(OrthancPlugins::GetGlobalContext(), *buffer, arg0); - } - - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginRegisterDictionaryTag(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginRegisterDictionaryTag()"); - - unsigned short arg0 = 0; - unsigned short arg1 = 0; - long int arg2 = 0; - const char* arg3 = NULL; - unsigned long arg4 = 0; - unsigned long arg5 = 0; - - if (!PyArg_ParseTuple(args, "HHlskk", &arg0, &arg1, &arg2, &arg3, &arg4, &arg5)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (6 arguments expected)"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginRegisterDictionaryTag(OrthancPlugins::GetGlobalContext(), arg0, arg1, static_cast(arg2), arg3, arg4, arg5); - } - - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginRegisterErrorCode(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginRegisterErrorCode()"); - - long int arg0 = 0; - unsigned short arg1 = 0; - const char* arg2 = NULL; - - if (!PyArg_ParseTuple(args, "lHs", &arg0, &arg1, &arg2)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (3 arguments expected)"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginRegisterErrorCode(OrthancPlugins::GetGlobalContext(), arg0, arg1, arg2); - } - - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginRegisterPrivateDictionaryTag(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginRegisterPrivateDictionaryTag()"); - - unsigned short arg0 = 0; - unsigned short arg1 = 0; - long int arg2 = 0; - const char* arg3 = NULL; - unsigned long arg4 = 0; - unsigned long arg5 = 0; - const char* arg6 = NULL; - - if (!PyArg_ParseTuple(args, "HHlskks", &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (7 arguments expected)"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginRegisterPrivateDictionaryTag(OrthancPlugins::GetGlobalContext(), arg0, arg1, static_cast(arg2), arg3, arg4, arg5, arg6); - } - - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginRestApiDelete(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginRestApiDelete()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginRestApiDelete(OrthancPlugins::GetGlobalContext(), arg0); - } - - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginRestApiDeleteAfterPlugins(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginRestApiDeleteAfterPlugins()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginRestApiDeleteAfterPlugins(OrthancPlugins::GetGlobalContext(), arg0); - } - - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginRestApiGet(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginRestApiGet()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginRestApiGet(OrthancPlugins::GetGlobalContext(), *buffer, arg0); - } - - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginRestApiGetAfterPlugins(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginRestApiGetAfterPlugins()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginRestApiGetAfterPlugins(OrthancPlugins::GetGlobalContext(), *buffer, arg0); - } - - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginRestApiPost(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginRestApiPost()"); - - const char* arg0 = NULL; - Py_buffer arg1; - - if (!PyArg_ParseTuple(args, "ss*", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginRestApiPost(OrthancPlugins::GetGlobalContext(), *buffer, arg0, arg1.buf, arg1.len); - } - PyBuffer_Release(&arg1); - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginRestApiPostAfterPlugins(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginRestApiPostAfterPlugins()"); - - const char* arg0 = NULL; - Py_buffer arg1; - - if (!PyArg_ParseTuple(args, "ss*", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginRestApiPostAfterPlugins(OrthancPlugins::GetGlobalContext(), *buffer, arg0, arg1.buf, arg1.len); - } - PyBuffer_Release(&arg1); - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginRestApiPut(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginRestApiPut()"); - - const char* arg0 = NULL; - Py_buffer arg1; - - if (!PyArg_ParseTuple(args, "ss*", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginRestApiPut(OrthancPlugins::GetGlobalContext(), *buffer, arg0, arg1.buf, arg1.len); - } - PyBuffer_Release(&arg1); - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginRestApiPutAfterPlugins(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginRestApiPutAfterPlugins()"); - - const char* arg0 = NULL; - Py_buffer arg1; - - if (!PyArg_ParseTuple(args, "ss*", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginRestApiPutAfterPlugins(OrthancPlugins::GetGlobalContext(), *buffer, arg0, arg1.buf, arg1.len); - } - PyBuffer_Release(&arg1); - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginSetDescription(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginSetDescription()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginSetDescription(OrthancPlugins::GetGlobalContext(), arg0); - } - - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject* sdk_OrthancPluginSetGlobalProperty(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginSetGlobalProperty()"); - - long int arg0 = 0; - const char* arg1 = NULL; - - if (!PyArg_ParseTuple(args, "ls", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginSetGlobalProperty(OrthancPlugins::GetGlobalContext(), arg0, arg1); - } - - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject* sdk_OrthancPluginSetMetricsValue(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginSetMetricsValue()"); - - const char* arg0 = NULL; - float arg1 = 0; - long int arg2 = 0; - - if (!PyArg_ParseTuple(args, "sfl", &arg0, &arg1, &arg2)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (3 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginSetMetricsValue(OrthancPlugins::GetGlobalContext(), arg0, arg1, static_cast(arg2)); - } - - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject* sdk_OrthancPluginSetRootUri(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginSetRootUri()"); - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginSetRootUri(OrthancPlugins::GetGlobalContext(), arg0); - } - - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject* sdk_OrthancPluginTranscodeDicomInstance(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginTranscodeDicomInstance()"); - - Py_buffer arg0; - const char* arg2 = NULL; - - if (!PyArg_ParseTuple(args, "s*s", &arg0, &arg2)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - // This is the case of a constructor - OrthancPluginDicomInstance* obj; - { - PythonThreadsAllower allower; - obj = OrthancPluginTranscodeDicomInstance(OrthancPlugins::GetGlobalContext(), arg0.buf, arg0.len, arg2); - } - PyBuffer_Release(&arg0); - if (obj == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - PyObject *argList = Py_BuildValue("Lb", obj, false /* not borrowed */); - PyObject *python = PyObject_CallObject((PyObject *) &sdk_OrthancPluginDicomInstance_Type, argList); - Py_DECREF(argList); - return python; - } -} - -static PyObject* sdk_OrthancPluginUncompressImage(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginUncompressImage()"); - - Py_buffer arg0; - long int arg2 = 0; - - if (!PyArg_ParseTuple(args, "s*l", &arg0, &arg2)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - // This is the case of a constructor - OrthancPluginImage* obj; - { - PythonThreadsAllower allower; - obj = OrthancPluginUncompressImage(OrthancPlugins::GetGlobalContext(), arg0.buf, arg0.len, static_cast(arg2)); - } - PyBuffer_Release(&arg0); - if (obj == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - PyObject *argList = Py_BuildValue("Lb", obj, false /* not borrowed */); - PyObject *python = PyObject_CallObject((PyObject *) &sdk_OrthancPluginImage_Type, argList); - Py_DECREF(argList); - return python; - } -} - -static PyObject* sdk_OrthancPluginWriteFile(PyObject* module, PyObject* args) -{ - PythonLock::LogCall("Calling Python global function: OrthancPluginWriteFile()"); - - const char* arg0 = NULL; - Py_buffer arg1; - - if (!PyArg_ParseTuple(args, "ss*", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginWriteFile(OrthancPlugins::GetGlobalContext(), arg0, arg1.buf, arg1.len); - } - PyBuffer_Release(&arg1); - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - - -static PyMethodDef ORTHANC_SDK_FUNCTIONS[] = -{ - { "AutodetectMimeType", sdk_OrthancPluginAutodetectMimeType, METH_VARARGS, - "Generated from C function OrthancPluginAutodetectMimeType()" }, - { "BufferCompression", sdk_OrthancPluginBufferCompression, METH_VARARGS, - "Generated from C function OrthancPluginBufferCompression()" }, - { "CheckVersion", sdk_OrthancPluginCheckVersion, METH_VARARGS, - "Generated from C function OrthancPluginCheckVersion()" }, - { "CheckVersionAdvanced", sdk_OrthancPluginCheckVersionAdvanced, METH_VARARGS, - "Generated from C function OrthancPluginCheckVersionAdvanced()" }, - { "CompressJpegImage", sdk_OrthancPluginCompressJpegImage, METH_VARARGS, - "Generated from C function OrthancPluginCompressJpegImage()" }, - { "CompressPngImage", sdk_OrthancPluginCompressPngImage, METH_VARARGS, - "Generated from C function OrthancPluginCompressPngImage()" }, - { "ComputeMd5", sdk_OrthancPluginComputeMd5, METH_VARARGS, - "Generated from C function OrthancPluginComputeMd5()" }, - { "ComputeSha1", sdk_OrthancPluginComputeSha1, METH_VARARGS, - "Generated from C function OrthancPluginComputeSha1()" }, - { "CreateDicom", sdk_OrthancPluginCreateDicom, METH_VARARGS, - "Generated from C function OrthancPluginCreateDicom()" }, - { "CreateDicom2", sdk_OrthancPluginCreateDicom2, METH_VARARGS, - "Generated from C function OrthancPluginCreateDicom2()" }, - { "CreateDicomInstance", sdk_OrthancPluginCreateDicomInstance, METH_VARARGS, - "Generated from C function OrthancPluginCreateDicomInstance()" }, - { "CreateFindMatcher", sdk_OrthancPluginCreateFindMatcher, METH_VARARGS, - "Generated from C function OrthancPluginCreateFindMatcher()" }, - { "CreateImage", sdk_OrthancPluginCreateImage, METH_VARARGS, - "Generated from C function OrthancPluginCreateImage()" }, - { "DecodeDicomImage", sdk_OrthancPluginDecodeDicomImage, METH_VARARGS, - "Generated from C function OrthancPluginDecodeDicomImage()" }, - { "DicomBufferToJson", sdk_OrthancPluginDicomBufferToJson, METH_VARARGS, - "Generated from C function OrthancPluginDicomBufferToJson()" }, - { "DicomInstanceToJson", sdk_OrthancPluginDicomInstanceToJson, METH_VARARGS, - "Generated from C function OrthancPluginDicomInstanceToJson()" }, - { "ExtendOrthancExplorer", sdk_OrthancPluginExtendOrthancExplorer, METH_VARARGS, - "Generated from C function OrthancPluginExtendOrthancExplorer()" }, - { "GenerateRestApiAuthorizationToken", sdk_OrthancPluginGenerateRestApiAuthorizationToken, METH_VARARGS, - "Generated from C function OrthancPluginGenerateRestApiAuthorizationToken()" }, - { "GenerateUuid", sdk_OrthancPluginGenerateUuid, METH_VARARGS, - "Generated from C function OrthancPluginGenerateUuid()" }, - { "GetCommandLineArgument", sdk_OrthancPluginGetCommandLineArgument, METH_VARARGS, - "Generated from C function OrthancPluginGetCommandLineArgument()" }, - { "GetCommandLineArgumentsCount", sdk_OrthancPluginGetCommandLineArgumentsCount, METH_VARARGS, - "Generated from C function OrthancPluginGetCommandLineArgumentsCount()" }, - { "GetConfiguration", sdk_OrthancPluginGetConfiguration, METH_VARARGS, - "Generated from C function OrthancPluginGetConfiguration()" }, - { "GetConfigurationPath", sdk_OrthancPluginGetConfigurationPath, METH_VARARGS, - "Generated from C function OrthancPluginGetConfigurationPath()" }, - { "GetDicomForInstance", sdk_OrthancPluginGetDicomForInstance, METH_VARARGS, - "Generated from C function OrthancPluginGetDicomForInstance()" }, - { "GetErrorDescription", sdk_OrthancPluginGetErrorDescription, METH_VARARGS, - "Generated from C function OrthancPluginGetErrorDescription()" }, - { "GetExpectedDatabaseVersion", sdk_OrthancPluginGetExpectedDatabaseVersion, METH_VARARGS, - "Generated from C function OrthancPluginGetExpectedDatabaseVersion()" }, - { "GetFontName", sdk_OrthancPluginGetFontName, METH_VARARGS, - "Generated from C function OrthancPluginGetFontName()" }, - { "GetFontSize", sdk_OrthancPluginGetFontSize, METH_VARARGS, - "Generated from C function OrthancPluginGetFontSize()" }, - { "GetFontsCount", sdk_OrthancPluginGetFontsCount, METH_VARARGS, - "Generated from C function OrthancPluginGetFontsCount()" }, - { "GetGlobalProperty", sdk_OrthancPluginGetGlobalProperty, METH_VARARGS, - "Generated from C function OrthancPluginGetGlobalProperty()" }, - { "GetOrthancDirectory", sdk_OrthancPluginGetOrthancDirectory, METH_VARARGS, - "Generated from C function OrthancPluginGetOrthancDirectory()" }, - { "GetOrthancPath", sdk_OrthancPluginGetOrthancPath, METH_VARARGS, - "Generated from C function OrthancPluginGetOrthancPath()" }, - { "GetPeers", sdk_OrthancPluginGetPeers, METH_VARARGS, - "Generated from C function OrthancPluginGetPeers()" }, - { "GetTagName", sdk_OrthancPluginGetTagName, METH_VARARGS, - "Generated from C function OrthancPluginGetTagName()" }, - { "HttpDelete", sdk_OrthancPluginHttpDelete, METH_VARARGS, - "Generated from C function OrthancPluginHttpDelete()" }, - { "HttpGet", sdk_OrthancPluginHttpGet, METH_VARARGS, - "Generated from C function OrthancPluginHttpGet()" }, - { "HttpPost", sdk_OrthancPluginHttpPost, METH_VARARGS, - "Generated from C function OrthancPluginHttpPost()" }, - { "HttpPut", sdk_OrthancPluginHttpPut, METH_VARARGS, - "Generated from C function OrthancPluginHttpPut()" }, - { "LogError", sdk_OrthancPluginLogError, METH_VARARGS, - "Generated from C function OrthancPluginLogError()" }, - { "LogInfo", sdk_OrthancPluginLogInfo, METH_VARARGS, - "Generated from C function OrthancPluginLogInfo()" }, - { "LogWarning", sdk_OrthancPluginLogWarning, METH_VARARGS, - "Generated from C function OrthancPluginLogWarning()" }, - { "LookupInstance", sdk_OrthancPluginLookupInstance, METH_VARARGS, - "Generated from C function OrthancPluginLookupInstance()" }, - { "LookupPatient", sdk_OrthancPluginLookupPatient, METH_VARARGS, - "Generated from C function OrthancPluginLookupPatient()" }, - { "LookupSeries", sdk_OrthancPluginLookupSeries, METH_VARARGS, - "Generated from C function OrthancPluginLookupSeries()" }, - { "LookupStudy", sdk_OrthancPluginLookupStudy, METH_VARARGS, - "Generated from C function OrthancPluginLookupStudy()" }, - { "LookupStudyWithAccessionNumber", sdk_OrthancPluginLookupStudyWithAccessionNumber, METH_VARARGS, - "Generated from C function OrthancPluginLookupStudyWithAccessionNumber()" }, - { "ReadFile", sdk_OrthancPluginReadFile, METH_VARARGS, - "Generated from C function OrthancPluginReadFile()" }, - { "RegisterDictionaryTag", sdk_OrthancPluginRegisterDictionaryTag, METH_VARARGS, - "Generated from C function OrthancPluginRegisterDictionaryTag()" }, - { "RegisterErrorCode", sdk_OrthancPluginRegisterErrorCode, METH_VARARGS, - "Generated from C function OrthancPluginRegisterErrorCode()" }, - { "RegisterPrivateDictionaryTag", sdk_OrthancPluginRegisterPrivateDictionaryTag, METH_VARARGS, - "Generated from C function OrthancPluginRegisterPrivateDictionaryTag()" }, - { "RestApiDelete", sdk_OrthancPluginRestApiDelete, METH_VARARGS, - "Generated from C function OrthancPluginRestApiDelete()" }, - { "RestApiDeleteAfterPlugins", sdk_OrthancPluginRestApiDeleteAfterPlugins, METH_VARARGS, - "Generated from C function OrthancPluginRestApiDeleteAfterPlugins()" }, - { "RestApiGet", sdk_OrthancPluginRestApiGet, METH_VARARGS, - "Generated from C function OrthancPluginRestApiGet()" }, - { "RestApiGetAfterPlugins", sdk_OrthancPluginRestApiGetAfterPlugins, METH_VARARGS, - "Generated from C function OrthancPluginRestApiGetAfterPlugins()" }, - { "RestApiPost", sdk_OrthancPluginRestApiPost, METH_VARARGS, - "Generated from C function OrthancPluginRestApiPost()" }, - { "RestApiPostAfterPlugins", sdk_OrthancPluginRestApiPostAfterPlugins, METH_VARARGS, - "Generated from C function OrthancPluginRestApiPostAfterPlugins()" }, - { "RestApiPut", sdk_OrthancPluginRestApiPut, METH_VARARGS, - "Generated from C function OrthancPluginRestApiPut()" }, - { "RestApiPutAfterPlugins", sdk_OrthancPluginRestApiPutAfterPlugins, METH_VARARGS, - "Generated from C function OrthancPluginRestApiPutAfterPlugins()" }, - { "SetDescription", sdk_OrthancPluginSetDescription, METH_VARARGS, - "Generated from C function OrthancPluginSetDescription()" }, - { "SetGlobalProperty", sdk_OrthancPluginSetGlobalProperty, METH_VARARGS, - "Generated from C function OrthancPluginSetGlobalProperty()" }, - { "SetMetricsValue", sdk_OrthancPluginSetMetricsValue, METH_VARARGS, - "Generated from C function OrthancPluginSetMetricsValue()" }, - { "SetRootUri", sdk_OrthancPluginSetRootUri, METH_VARARGS, - "Generated from C function OrthancPluginSetRootUri()" }, - { "TranscodeDicomInstance", sdk_OrthancPluginTranscodeDicomInstance, METH_VARARGS, - "Generated from C function OrthancPluginTranscodeDicomInstance()" }, - { "UncompressImage", sdk_OrthancPluginUncompressImage, METH_VARARGS, - "Generated from C function OrthancPluginUncompressImage()" }, - { "WriteFile", sdk_OrthancPluginWriteFile, METH_VARARGS, - "Generated from C function OrthancPluginWriteFile()" }, - { "CreateImageFromBuffer", CreateImageFromBuffer, METH_VARARGS, - "Implemented in C++ function CreateImageFromBuffer()" }, - { "LookupDictionary", LookupDictionary, METH_VARARGS, - "Implemented in C++ function LookupDictionary()" }, - { "RegisterFindCallback", RegisterFindCallback, METH_VARARGS, - "Implemented in C++ function RegisterFindCallback()" }, - { "RegisterIncomingCStoreInstanceFilter", RegisterIncomingCStoreInstanceFilter, METH_VARARGS, - "Implemented in C++ function RegisterIncomingCStoreInstanceFilter()" }, - { "RegisterIncomingHttpRequestFilter", RegisterIncomingHttpRequestFilter, METH_VARARGS, - "Implemented in C++ function RegisterIncomingHttpRequestFilter()" }, - { "RegisterMoveCallback", RegisterMoveCallback, METH_VARARGS, - "Implemented in C++ function RegisterMoveCallback()" }, - { "RegisterMoveCallback2", RegisterMoveCallback2, METH_VARARGS, - "Implemented in C++ function RegisterMoveCallback2()" }, - { "RegisterOnChangeCallback", RegisterOnChangeCallback, METH_VARARGS, - "Implemented in C++ function RegisterOnChangeCallback()" }, - { "RegisterOnStoredInstanceCallback", RegisterOnStoredInstanceCallback, METH_VARARGS, - "Implemented in C++ function RegisterOnStoredInstanceCallback()" }, - { "RegisterReceivedInstanceCallback", RegisterReceivedInstanceCallback, METH_VARARGS, - "Implemented in C++ function RegisterReceivedInstanceCallback()" }, - { "RegisterRestCallback", RegisterRestCallback, METH_VARARGS, - "Implemented in C++ function RegisterRestCallback()" }, - { "RegisterStorageArea", RegisterStorageArea, METH_VARARGS, - "Implemented in C++ function RegisterStorageArea()" }, - { "RegisterStorageCommitmentScpCallback", RegisterStorageCommitmentScpCallback, METH_VARARGS, - "Implemented in C++ function RegisterStorageCommitmentScpCallback()" }, - { "RegisterWorklistCallback", RegisterWorklistCallback, METH_VARARGS, - "Implemented in C++ function RegisterWorklistCallback()" }, - { NULL, NULL } -}; - - -PyMethodDef* GetOrthancSdkFunctions() -{ - return ORTHANC_SDK_FUNCTIONS; -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginChangeType.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginChangeType.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,198 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginChangeType_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginChangeType_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.ChangeType", /* tp_name */ - sizeof(sdk_OrthancPluginChangeType_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginChangeTypeEnumeration(PyObject* module) -{ - sdk_OrthancPluginChangeType_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginChangeType_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginChangeType_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginChangeType"; - - sdk_OrthancPluginChangeType_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginChangeType_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginChangeType"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(0); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "COMPLETED_SERIES", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "DELETED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "NEW_CHILD_INSTANCE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "NEW_INSTANCE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(4); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "NEW_PATIENT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(5); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "NEW_SERIES", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(6); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "NEW_STUDY", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(7); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "STABLE_PATIENT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(8); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "STABLE_SERIES", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(9); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "STABLE_STUDY", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(10); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "ORTHANC_STARTED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(11); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "ORTHANC_STOPPED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(12); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "UPDATED_ATTACHMENT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(13); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "UPDATED_METADATA", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(14); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "UPDATED_PEERS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(15); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "UPDATED_MODALITIES", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(16); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "JOB_SUBMITTED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(17); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "JOB_SUCCESS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(18); - PyDict_SetItemString(sdk_OrthancPluginChangeType_Type.tp_dict, "JOB_FAILURE", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginChangeType_Type); - if (PyModule_AddObject(module, "ChangeType", (PyObject *)&sdk_OrthancPluginChangeType_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginChangeType"); - Py_DECREF(&sdk_OrthancPluginChangeType_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginCompressionType.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginCompressionType.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginCompressionType_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginCompressionType_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.CompressionType", /* tp_name */ - sizeof(sdk_OrthancPluginCompressionType_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginCompressionTypeEnumeration(PyObject* module) -{ - sdk_OrthancPluginCompressionType_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginCompressionType_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginCompressionType_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginCompressionType"; - - sdk_OrthancPluginCompressionType_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginCompressionType_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginCompressionType"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(0); - PyDict_SetItemString(sdk_OrthancPluginCompressionType_Type.tp_dict, "ZLIB", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginCompressionType_Type.tp_dict, "ZLIB_WITH_SIZE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginCompressionType_Type.tp_dict, "GZIP", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginCompressionType_Type.tp_dict, "GZIP_WITH_SIZE", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginCompressionType_Type); - if (PyModule_AddObject(module, "CompressionType", (PyObject *)&sdk_OrthancPluginCompressionType_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginCompressionType"); - Py_DECREF(&sdk_OrthancPluginCompressionType_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginConstraintType.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginConstraintType.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginConstraintType_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginConstraintType_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.ConstraintType", /* tp_name */ - sizeof(sdk_OrthancPluginConstraintType_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginConstraintTypeEnumeration(PyObject* module) -{ - sdk_OrthancPluginConstraintType_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginConstraintType_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginConstraintType_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginConstraintType"; - - sdk_OrthancPluginConstraintType_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginConstraintType_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginConstraintType"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginConstraintType_Type.tp_dict, "EQUAL", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginConstraintType_Type.tp_dict, "SMALLER_OR_EQUAL", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginConstraintType_Type.tp_dict, "GREATER_OR_EQUAL", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(4); - PyDict_SetItemString(sdk_OrthancPluginConstraintType_Type.tp_dict, "WILDCARD", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(5); - PyDict_SetItemString(sdk_OrthancPluginConstraintType_Type.tp_dict, "LIST", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginConstraintType_Type); - if (PyModule_AddObject(module, "ConstraintType", (PyObject *)&sdk_OrthancPluginConstraintType_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginConstraintType"); - Py_DECREF(&sdk_OrthancPluginConstraintType_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginContentType.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginContentType.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginContentType_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginContentType_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.ContentType", /* tp_name */ - sizeof(sdk_OrthancPluginContentType_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginContentTypeEnumeration(PyObject* module) -{ - sdk_OrthancPluginContentType_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginContentType_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginContentType_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginContentType"; - - sdk_OrthancPluginContentType_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginContentType_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginContentType"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(0); - PyDict_SetItemString(sdk_OrthancPluginContentType_Type.tp_dict, "UNKNOWN", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginContentType_Type.tp_dict, "DICOM", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginContentType_Type.tp_dict, "DICOM_AS_JSON", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginContentType_Type.tp_dict, "DICOM_UNTIL_PIXEL_DATA", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginContentType_Type); - if (PyModule_AddObject(module, "ContentType", (PyObject *)&sdk_OrthancPluginContentType_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginContentType"); - Py_DECREF(&sdk_OrthancPluginContentType_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginCreateDicomFlags.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginCreateDicomFlags.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginCreateDicomFlags_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginCreateDicomFlags_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.CreateDicomFlags", /* tp_name */ - sizeof(sdk_OrthancPluginCreateDicomFlags_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginCreateDicomFlagsEnumeration(PyObject* module) -{ - sdk_OrthancPluginCreateDicomFlags_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginCreateDicomFlags_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginCreateDicomFlags_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginCreateDicomFlags"; - - sdk_OrthancPluginCreateDicomFlags_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginCreateDicomFlags_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginCreateDicomFlags"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(0); - PyDict_SetItemString(sdk_OrthancPluginCreateDicomFlags_Type.tp_dict, "NONE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginCreateDicomFlags_Type.tp_dict, "DECODE_DATA_URI_SCHEME", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginCreateDicomFlags_Type.tp_dict, "GENERATE_IDENTIFIERS", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginCreateDicomFlags_Type); - if (PyModule_AddObject(module, "CreateDicomFlags", (PyObject *)&sdk_OrthancPluginCreateDicomFlags_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginCreateDicomFlags"); - Py_DECREF(&sdk_OrthancPluginCreateDicomFlags_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginDicomInstance.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginDicomInstance.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,207 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Forward declaration of the autogenerated methods -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceRemoteAet( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceSize( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceJson( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceSimplifiedJson( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginHasInstanceMetadata( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceMetadata( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceOrigin( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceTransferSyntaxUid( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginHasInstancePixelData( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceFramesCount( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceRawFrame( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceDecodedFrame( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginSerializeDicomInstance( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceAdvancedJson( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args); -// End of forward declarations - - -// Forward declaration of the custom methods -extern PyObject *GetInstanceData(sdk_OrthancPluginDicomInstance_Object* self, PyObject *args); -// End of forward declarations - - -static PyMethodDef sdk_OrthancPluginDicomInstance_Methods[] = { - { "GetInstanceRemoteAet", - (PyCFunction) sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceRemoteAet, METH_VARARGS, - "Generated from C function OrthancPluginGetInstanceRemoteAet()" }, - { "GetInstanceSize", - (PyCFunction) sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceSize, METH_VARARGS, - "Generated from C function OrthancPluginGetInstanceSize()" }, - { "GetInstanceJson", - (PyCFunction) sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceJson, METH_VARARGS, - "Generated from C function OrthancPluginGetInstanceJson()" }, - { "GetInstanceSimplifiedJson", - (PyCFunction) sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceSimplifiedJson, METH_VARARGS, - "Generated from C function OrthancPluginGetInstanceSimplifiedJson()" }, - { "HasInstanceMetadata", - (PyCFunction) sdk_OrthancPluginDicomInstance_OrthancPluginHasInstanceMetadata, METH_VARARGS, - "Generated from C function OrthancPluginHasInstanceMetadata()" }, - { "GetInstanceMetadata", - (PyCFunction) sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceMetadata, METH_VARARGS, - "Generated from C function OrthancPluginGetInstanceMetadata()" }, - { "GetInstanceOrigin", - (PyCFunction) sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceOrigin, METH_VARARGS, - "Generated from C function OrthancPluginGetInstanceOrigin()" }, - { "GetInstanceTransferSyntaxUid", - (PyCFunction) sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceTransferSyntaxUid, METH_VARARGS, - "Generated from C function OrthancPluginGetInstanceTransferSyntaxUid()" }, - { "HasInstancePixelData", - (PyCFunction) sdk_OrthancPluginDicomInstance_OrthancPluginHasInstancePixelData, METH_VARARGS, - "Generated from C function OrthancPluginHasInstancePixelData()" }, - { "GetInstanceFramesCount", - (PyCFunction) sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceFramesCount, METH_VARARGS, - "Generated from C function OrthancPluginGetInstanceFramesCount()" }, - { "GetInstanceRawFrame", - (PyCFunction) sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceRawFrame, METH_VARARGS, - "Generated from C function OrthancPluginGetInstanceRawFrame()" }, - { "GetInstanceDecodedFrame", - (PyCFunction) sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceDecodedFrame, METH_VARARGS, - "Generated from C function OrthancPluginGetInstanceDecodedFrame()" }, - { "SerializeDicomInstance", - (PyCFunction) sdk_OrthancPluginDicomInstance_OrthancPluginSerializeDicomInstance, METH_VARARGS, - "Generated from C function OrthancPluginSerializeDicomInstance()" }, - { "GetInstanceAdvancedJson", - (PyCFunction) sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceAdvancedJson, METH_VARARGS, - "Generated from C function OrthancPluginGetInstanceAdvancedJson()" }, - { "GetInstanceData", - (PyCFunction) GetInstanceData, METH_VARARGS, - "Implemented in C++ function GetInstanceData()" }, - { NULL } /* Sentinel */ -}; - - -static int sdk_OrthancPluginDicomInstance_Constructor( - sdk_OrthancPluginDicomInstance_Object *self, PyObject *args, PyObject *kwds) -{ - PythonLock::LogCall("Creating Python object of class OrthancPluginDicomInstance"); - - self->object_ = NULL; - self->borrowed_ = false; - - long long object = 0; - unsigned char borrowed = false; - - if (PyArg_ParseTuple(args, "Lb", &object, &borrowed)) - { - self->object_ = reinterpret_cast(static_cast(object)); - self->borrowed_ = borrowed; - return 0; - } - else - { - PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor"); - return -1; - } -} - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginDicomInstance_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.DicomInstance", /* tp_name */ - sizeof(sdk_OrthancPluginDicomInstance_Object), /* tp_basicsize */ -}; - - -static void sdk_OrthancPluginDicomInstance_Destructor(PyObject *self) -{ - PythonLock::LogCall("Destroying Python object of class OrthancPluginDicomInstance"); - - sdk_OrthancPluginDicomInstance_Object& tmp = *((sdk_OrthancPluginDicomInstance_Object*) self); - - if (tmp.object_ != NULL && - !tmp.borrowed_) - { - OrthancPluginFreeDicomInstance(OrthancPlugins::GetGlobalContext(), tmp.object_); - tmp.object_ = NULL; - } - - Py_TYPE(self)->tp_free((PyObject *)self); -} - - -static void RegisterOrthancPluginDicomInstanceClass(PyObject* module) -{ - sdk_OrthancPluginDicomInstance_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginDicomInstance_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginDicomInstance_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginDicomInstance"; - sdk_OrthancPluginDicomInstance_Type.tp_methods = sdk_OrthancPluginDicomInstance_Methods; - sdk_OrthancPluginDicomInstance_Type.tp_init = (initproc) sdk_OrthancPluginDicomInstance_Constructor; - - /** - * "tp_dealloc is called when the reference count of the object goes - * down to zero. This is where you destroy the object and its - * members. It should then free the memory occupied by the object by - * calling tp_free." - * https://stackoverflow.com/a/24863227/881731 - **/ - sdk_OrthancPluginDicomInstance_Type.tp_dealloc = sdk_OrthancPluginDicomInstance_Destructor; - - if (PyType_Ready(&sdk_OrthancPluginDicomInstance_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginDicomInstance"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - Py_INCREF(&sdk_OrthancPluginDicomInstance_Type); - if (PyModule_AddObject(module, "DicomInstance", (PyObject *)&sdk_OrthancPluginDicomInstance_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginDicomInstance"); - Py_DECREF(&sdk_OrthancPluginDicomInstance_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} - - -PyTypeObject* GetOrthancPluginDicomInstanceType() -{ - return &sdk_OrthancPluginDicomInstance_Type; -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginDicomInstance.methods.h --- a/Sources/Autogenerated/sdk_OrthancPluginDicomInstance.methods.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,448 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Actual implementation of the methods -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceRemoteAet( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetInstanceRemoteAet() on object of class OrthancPluginDicomInstance"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - const char* s; - { - PythonThreadsAllower allower; - s = OrthancPluginGetInstanceRemoteAet(OrthancPlugins::GetGlobalContext(), self->object_); - } - - if (s == NULL) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - return PyUnicode_FromString(s); - } -} - -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceSize( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetInstanceSize() on object of class OrthancPluginDicomInstance"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginGetInstanceSize(OrthancPlugins::GetGlobalContext(), self->object_); - } - - return PyLong_FromLong(value); -} - -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceJson( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetInstanceJson() on object of class OrthancPluginDicomInstance"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginGetInstanceJson(OrthancPlugins::GetGlobalContext(), self->object_)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceSimplifiedJson( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetInstanceSimplifiedJson() on object of class OrthancPluginDicomInstance"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginGetInstanceSimplifiedJson(OrthancPlugins::GetGlobalContext(), self->object_)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginHasInstanceMetadata( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginHasInstanceMetadata() on object of class OrthancPluginDicomInstance"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginHasInstanceMetadata(OrthancPlugins::GetGlobalContext(), self->object_, arg0); - } - - return PyLong_FromLong(value); -} - -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceMetadata( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetInstanceMetadata() on object of class OrthancPluginDicomInstance"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - const char* s; - { - PythonThreadsAllower allower; - s = OrthancPluginGetInstanceMetadata(OrthancPlugins::GetGlobalContext(), self->object_, arg0); - } - - if (s == NULL) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - return PyUnicode_FromString(s); - } -} - -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceOrigin( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetInstanceOrigin() on object of class OrthancPluginDicomInstance"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - OrthancPluginInstanceOrigin value; - { - PythonThreadsAllower allower; - value = OrthancPluginGetInstanceOrigin(OrthancPlugins::GetGlobalContext(), self->object_); - } - - return PyLong_FromLong(value); -} - -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceTransferSyntaxUid( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetInstanceTransferSyntaxUid() on object of class OrthancPluginDicomInstance"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginGetInstanceTransferSyntaxUid(OrthancPlugins::GetGlobalContext(), self->object_)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginHasInstancePixelData( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginHasInstancePixelData() on object of class OrthancPluginDicomInstance"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginHasInstancePixelData(OrthancPlugins::GetGlobalContext(), self->object_); - } - - return PyLong_FromLong(value); -} - -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceFramesCount( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetInstanceFramesCount() on object of class OrthancPluginDicomInstance"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginGetInstanceFramesCount(OrthancPlugins::GetGlobalContext(), self->object_); - } - - return PyLong_FromLong(value); -} - -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceRawFrame( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetInstanceRawFrame() on object of class OrthancPluginDicomInstance"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - unsigned long arg0 = 0; - - if (!PyArg_ParseTuple(args, "k", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginGetInstanceRawFrame(OrthancPlugins::GetGlobalContext(), *buffer, self->object_, arg0); - } - - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceDecodedFrame( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetInstanceDecodedFrame() on object of class OrthancPluginDicomInstance"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - unsigned long arg0 = 0; - - if (!PyArg_ParseTuple(args, "k", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - // This is the case of a constructor - OrthancPluginImage* obj; - { - PythonThreadsAllower allower; - obj = OrthancPluginGetInstanceDecodedFrame(OrthancPlugins::GetGlobalContext(), self->object_, arg0); - } - - if (obj == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - PyObject *argList = Py_BuildValue("Lb", obj, false /* not borrowed */); - PyObject *python = PyObject_CallObject((PyObject *) &sdk_OrthancPluginImage_Type, argList); - Py_DECREF(argList); - return python; - } -} - -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginSerializeDicomInstance( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginSerializeDicomInstance() on object of class OrthancPluginDicomInstance"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginSerializeDicomInstance(OrthancPlugins::GetGlobalContext(), *buffer, self->object_); - } - - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject *sdk_OrthancPluginDicomInstance_OrthancPluginGetInstanceAdvancedJson( - sdk_OrthancPluginDicomInstance_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetInstanceAdvancedJson() on object of class OrthancPluginDicomInstance"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - long int arg0 = 0; - long int arg1 = 0; - unsigned long arg2 = 0; - - if (!PyArg_ParseTuple(args, "llk", &arg0, &arg1, &arg2)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (3 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginGetInstanceAdvancedJson(OrthancPlugins::GetGlobalContext(), self->object_, static_cast(arg0), static_cast(arg1), arg2)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginDicomToJsonFlags.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginDicomToJsonFlags.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,138 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginDicomToJsonFlags_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginDicomToJsonFlags_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.DicomToJsonFlags", /* tp_name */ - sizeof(sdk_OrthancPluginDicomToJsonFlags_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginDicomToJsonFlagsEnumeration(PyObject* module) -{ - sdk_OrthancPluginDicomToJsonFlags_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginDicomToJsonFlags_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginDicomToJsonFlags_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginDicomToJsonFlags"; - - sdk_OrthancPluginDicomToJsonFlags_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginDicomToJsonFlags_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginDicomToJsonFlags"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(0); - PyDict_SetItemString(sdk_OrthancPluginDicomToJsonFlags_Type.tp_dict, "NONE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginDicomToJsonFlags_Type.tp_dict, "INCLUDE_BINARY", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginDicomToJsonFlags_Type.tp_dict, "INCLUDE_PRIVATE_TAGS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(4); - PyDict_SetItemString(sdk_OrthancPluginDicomToJsonFlags_Type.tp_dict, "INCLUDE_UNKNOWN_TAGS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(8); - PyDict_SetItemString(sdk_OrthancPluginDicomToJsonFlags_Type.tp_dict, "INCLUDE_PIXEL_DATA", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(16); - PyDict_SetItemString(sdk_OrthancPluginDicomToJsonFlags_Type.tp_dict, "CONVERT_BINARY_TO_ASCII", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(32); - PyDict_SetItemString(sdk_OrthancPluginDicomToJsonFlags_Type.tp_dict, "CONVERT_BINARY_TO_NULL", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(64); - PyDict_SetItemString(sdk_OrthancPluginDicomToJsonFlags_Type.tp_dict, "STOP_AFTER_PIXEL_DATA", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(128); - PyDict_SetItemString(sdk_OrthancPluginDicomToJsonFlags_Type.tp_dict, "SKIP_GROUP_LENGTHS", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginDicomToJsonFlags_Type); - if (PyModule_AddObject(module, "DicomToJsonFlags", (PyObject *)&sdk_OrthancPluginDicomToJsonFlags_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginDicomToJsonFlags"); - Py_DECREF(&sdk_OrthancPluginDicomToJsonFlags_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginDicomToJsonFormat.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginDicomToJsonFormat.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginDicomToJsonFormat_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginDicomToJsonFormat_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.DicomToJsonFormat", /* tp_name */ - sizeof(sdk_OrthancPluginDicomToJsonFormat_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginDicomToJsonFormatEnumeration(PyObject* module) -{ - sdk_OrthancPluginDicomToJsonFormat_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginDicomToJsonFormat_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginDicomToJsonFormat_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginDicomToJsonFormat"; - - sdk_OrthancPluginDicomToJsonFormat_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginDicomToJsonFormat_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginDicomToJsonFormat"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginDicomToJsonFormat_Type.tp_dict, "FULL", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginDicomToJsonFormat_Type.tp_dict, "SHORT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginDicomToJsonFormat_Type.tp_dict, "HUMAN", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginDicomToJsonFormat_Type); - if (PyModule_AddObject(module, "DicomToJsonFormat", (PyObject *)&sdk_OrthancPluginDicomToJsonFormat_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginDicomToJsonFormat"); - Py_DECREF(&sdk_OrthancPluginDicomToJsonFormat_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginDicomWebBinaryMode.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginDicomWebBinaryMode.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginDicomWebBinaryMode_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginDicomWebBinaryMode_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.DicomWebBinaryMode", /* tp_name */ - sizeof(sdk_OrthancPluginDicomWebBinaryMode_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginDicomWebBinaryModeEnumeration(PyObject* module) -{ - sdk_OrthancPluginDicomWebBinaryMode_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginDicomWebBinaryMode_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginDicomWebBinaryMode_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginDicomWebBinaryMode"; - - sdk_OrthancPluginDicomWebBinaryMode_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginDicomWebBinaryMode_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginDicomWebBinaryMode"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(0); - PyDict_SetItemString(sdk_OrthancPluginDicomWebBinaryMode_Type.tp_dict, "IGNORE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginDicomWebBinaryMode_Type.tp_dict, "INLINE_BINARY", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginDicomWebBinaryMode_Type.tp_dict, "BULK_DATA_URI", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginDicomWebBinaryMode_Type); - if (PyModule_AddObject(module, "DicomWebBinaryMode", (PyObject *)&sdk_OrthancPluginDicomWebBinaryMode_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginDicomWebBinaryMode"); - Py_DECREF(&sdk_OrthancPluginDicomWebBinaryMode_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginDicomWebNode.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginDicomWebNode.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Forward declaration of the autogenerated methods -// End of forward declarations - - -// Forward declaration of the custom methods -// End of forward declarations - - -static PyMethodDef sdk_OrthancPluginDicomWebNode_Methods[] = { - { NULL } /* Sentinel */ -}; - - -static int sdk_OrthancPluginDicomWebNode_Constructor( - sdk_OrthancPluginDicomWebNode_Object *self, PyObject *args, PyObject *kwds) -{ - PythonLock::LogCall("Creating Python object of class OrthancPluginDicomWebNode"); - - self->object_ = NULL; - self->borrowed_ = false; - - long long object = 0; - unsigned char borrowed = false; - - if (PyArg_ParseTuple(args, "Lb", &object, &borrowed)) - { - self->object_ = reinterpret_cast(static_cast(object)); - self->borrowed_ = borrowed; - return 0; - } - else - { - PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor"); - return -1; - } -} - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginDicomWebNode_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.DicomWebNode", /* tp_name */ - sizeof(sdk_OrthancPluginDicomWebNode_Object), /* tp_basicsize */ -}; - - - - -static void RegisterOrthancPluginDicomWebNodeClass(PyObject* module) -{ - sdk_OrthancPluginDicomWebNode_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginDicomWebNode_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginDicomWebNode_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginDicomWebNode"; - sdk_OrthancPluginDicomWebNode_Type.tp_methods = sdk_OrthancPluginDicomWebNode_Methods; - sdk_OrthancPluginDicomWebNode_Type.tp_init = (initproc) sdk_OrthancPluginDicomWebNode_Constructor; - - - if (PyType_Ready(&sdk_OrthancPluginDicomWebNode_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginDicomWebNode"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - Py_INCREF(&sdk_OrthancPluginDicomWebNode_Type); - if (PyModule_AddObject(module, "DicomWebNode", (PyObject *)&sdk_OrthancPluginDicomWebNode_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginDicomWebNode"); - Py_DECREF(&sdk_OrthancPluginDicomWebNode_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} - - -PyTypeObject* GetOrthancPluginDicomWebNodeType() -{ - return &sdk_OrthancPluginDicomWebNode_Type; -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginDicomWebNode.methods.h --- a/Sources/Autogenerated/sdk_OrthancPluginDicomWebNode.methods.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Actual implementation of the methods diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginErrorCode.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginErrorCode.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,726 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginErrorCode_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginErrorCode_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.ErrorCode", /* tp_name */ - sizeof(sdk_OrthancPluginErrorCode_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginErrorCodeEnumeration(PyObject* module) -{ - sdk_OrthancPluginErrorCode_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginErrorCode_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginErrorCode_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginErrorCode"; - - sdk_OrthancPluginErrorCode_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginErrorCode_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginErrorCode"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(-1); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "INTERNAL_ERROR", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(0); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SUCCESS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "PLUGIN", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "NOT_IMPLEMENTED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "PARAMETER_OUT_OF_RANGE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(4); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "NOT_ENOUGH_MEMORY", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(5); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "BAD_PARAMETER_TYPE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(6); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "BAD_SEQUENCE_OF_CALLS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(7); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "INEXISTENT_ITEM", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(8); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "BAD_REQUEST", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(9); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "NETWORK_PROTOCOL", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(10); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SYSTEM_COMMAND", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(11); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "DATABASE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(12); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "URI_SYNTAX", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(13); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "INEXISTENT_FILE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(14); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "CANNOT_WRITE_FILE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(15); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "BAD_FILE_FORMAT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(16); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "TIMEOUT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(17); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "UNKNOWN_RESOURCE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(18); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "INCOMPATIBLE_DATABASE_VERSION", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(19); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "FULL_STORAGE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(20); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "CORRUPTED_FILE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(21); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "INEXISTENT_TAG", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(22); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "READ_ONLY", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(23); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "INCOMPATIBLE_IMAGE_FORMAT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(24); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "INCOMPATIBLE_IMAGE_SIZE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(25); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SHARED_LIBRARY", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(26); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "UNKNOWN_PLUGIN_SERVICE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(27); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "UNKNOWN_DICOM_TAG", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(28); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "BAD_JSON", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(29); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "UNAUTHORIZED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(30); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "BAD_FONT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(31); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "DATABASE_PLUGIN", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(32); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "STORAGE_AREA_PLUGIN", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(33); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "EMPTY_REQUEST", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(34); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "NOT_ACCEPTABLE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(35); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "NULL_POINTER", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(36); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "DATABASE_UNAVAILABLE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(37); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "CANCELED_JOB", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(38); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "BAD_GEOMETRY", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(39); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SSL_INITIALIZATION", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(40); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "DISCONTINUED_ABI", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(41); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "BAD_RANGE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(42); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "DATABASE_CANNOT_SERIALIZE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(43); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "REVISION", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1000); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_NOT_OPENED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1001); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_ALREADY_OPENED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1002); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_CANNOT_OPEN", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1003); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_STATEMENT_ALREADY_USED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1004); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_EXECUTE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1005); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_ROLLBACK_WITHOUT_TRANSACTION", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1006); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_COMMIT_WITHOUT_TRANSACTION", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1007); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_REGISTER_FUNCTION", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1008); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_FLUSH", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1009); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_CANNOT_RUN", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1010); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_CANNOT_STEP", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1011); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_BIND_OUT_OF_RANGE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1012); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_PREPARE_STATEMENT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1013); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_TRANSACTION_ALREADY_STARTED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1014); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_TRANSACTION_COMMIT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1015); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SQLITE_TRANSACTION_BEGIN", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2000); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "DIRECTORY_OVER_FILE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2001); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "FILE_STORAGE_CANNOT_WRITE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2002); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "DIRECTORY_EXPECTED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2003); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "HTTP_PORT_IN_USE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2004); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "DICOM_PORT_IN_USE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2005); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "BAD_HTTP_STATUS_IN_REST", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2006); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "REGULAR_FILE_EXPECTED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2007); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "PATH_TO_EXECUTABLE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2008); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "MAKE_DIRECTORY", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2009); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "BAD_APPLICATION_ENTITY_TITLE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2010); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "NO_CFIND_HANDLER", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2011); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "NO_CMOVE_HANDLER", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2012); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "NO_CSTORE_HANDLER", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2013); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "NO_APPLICATION_ENTITY_FILTER", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2014); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "NO_SOP_CLASS_OR_INSTANCE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2015); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "NO_PRESENTATION_CONTEXT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2016); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "DICOM_FIND_UNAVAILABLE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2017); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "DICOM_MOVE_UNAVAILABLE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2018); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "CANNOT_STORE_INSTANCE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2019); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "CREATE_DICOM_NOT_STRING", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2020); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "CREATE_DICOM_OVERRIDE_TAG", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2021); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "CREATE_DICOM_USE_CONTENT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2022); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "CREATE_DICOM_NO_PAYLOAD", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2023); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "CREATE_DICOM_USE_DATA_URI_SCHEME", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2024); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "CREATE_DICOM_BAD_PARENT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2025); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "CREATE_DICOM_PARENT_IS_INSTANCE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2026); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "CREATE_DICOM_PARENT_ENCODING", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2027); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "UNKNOWN_MODALITY", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2028); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "BAD_JOB_ORDERING", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2029); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "JSON_TO_LUA_TABLE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2030); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "CANNOT_CREATE_LUA", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2031); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "CANNOT_EXECUTE_LUA", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2032); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "LUA_ALREADY_EXECUTED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2033); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "LUA_BAD_OUTPUT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2034); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "NOT_LUA_PREDICATE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2035); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "LUA_RETURNS_NO_STRING", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2036); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "STORAGE_AREA_ALREADY_REGISTERED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2037); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "DATABASE_BACKEND_ALREADY_REGISTERED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2038); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "DATABASE_NOT_INITIALIZED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2039); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "SSL_DISABLED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2040); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "CANNOT_ORDER_SLICES", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2041); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "NO_WORKLIST_HANDLER", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2042); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "ALREADY_EXISTING_TAG", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2043); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "NO_STORAGE_COMMITMENT_HANDLER", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2044); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "NO_CGET_HANDLER", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3000); - PyDict_SetItemString(sdk_OrthancPluginErrorCode_Type.tp_dict, "UNSUPPORTED_MEDIA_TYPE", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginErrorCode_Type); - if (PyModule_AddObject(module, "ErrorCode", (PyObject *)&sdk_OrthancPluginErrorCode_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginErrorCode"); - Py_DECREF(&sdk_OrthancPluginErrorCode_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginFindAnswers.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginFindAnswers.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Forward declaration of the autogenerated methods -static PyObject *sdk_OrthancPluginFindAnswers_OrthancPluginFindAddAnswer( - sdk_OrthancPluginFindAnswers_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginFindAnswers_OrthancPluginFindMarkIncomplete( - sdk_OrthancPluginFindAnswers_Object* self, PyObject *args); -// End of forward declarations - - -// Forward declaration of the custom methods -// End of forward declarations - - -static PyMethodDef sdk_OrthancPluginFindAnswers_Methods[] = { - { "FindAddAnswer", - (PyCFunction) sdk_OrthancPluginFindAnswers_OrthancPluginFindAddAnswer, METH_VARARGS, - "Generated from C function OrthancPluginFindAddAnswer()" }, - { "FindMarkIncomplete", - (PyCFunction) sdk_OrthancPluginFindAnswers_OrthancPluginFindMarkIncomplete, METH_VARARGS, - "Generated from C function OrthancPluginFindMarkIncomplete()" }, - { NULL } /* Sentinel */ -}; - - -static int sdk_OrthancPluginFindAnswers_Constructor( - sdk_OrthancPluginFindAnswers_Object *self, PyObject *args, PyObject *kwds) -{ - PythonLock::LogCall("Creating Python object of class OrthancPluginFindAnswers"); - - self->object_ = NULL; - self->borrowed_ = false; - - long long object = 0; - unsigned char borrowed = false; - - if (PyArg_ParseTuple(args, "Lb", &object, &borrowed)) - { - self->object_ = reinterpret_cast(static_cast(object)); - self->borrowed_ = borrowed; - return 0; - } - else - { - PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor"); - return -1; - } -} - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginFindAnswers_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.FindAnswers", /* tp_name */ - sizeof(sdk_OrthancPluginFindAnswers_Object), /* tp_basicsize */ -}; - - - - -static void RegisterOrthancPluginFindAnswersClass(PyObject* module) -{ - sdk_OrthancPluginFindAnswers_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginFindAnswers_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginFindAnswers_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginFindAnswers"; - sdk_OrthancPluginFindAnswers_Type.tp_methods = sdk_OrthancPluginFindAnswers_Methods; - sdk_OrthancPluginFindAnswers_Type.tp_init = (initproc) sdk_OrthancPluginFindAnswers_Constructor; - - - if (PyType_Ready(&sdk_OrthancPluginFindAnswers_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginFindAnswers"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - Py_INCREF(&sdk_OrthancPluginFindAnswers_Type); - if (PyModule_AddObject(module, "FindAnswers", (PyObject *)&sdk_OrthancPluginFindAnswers_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginFindAnswers"); - Py_DECREF(&sdk_OrthancPluginFindAnswers_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} - - -PyTypeObject* GetOrthancPluginFindAnswersType() -{ - return &sdk_OrthancPluginFindAnswers_Type; -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginFindAnswers.methods.h --- a/Sources/Autogenerated/sdk_OrthancPluginFindAnswers.methods.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Actual implementation of the methods -static PyObject *sdk_OrthancPluginFindAnswers_OrthancPluginFindAddAnswer( - sdk_OrthancPluginFindAnswers_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginFindAddAnswer() on object of class OrthancPluginFindAnswers"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - Py_buffer arg0; - - if (!PyArg_ParseTuple(args, "s*", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginFindAddAnswer(OrthancPlugins::GetGlobalContext(), self->object_, arg0.buf, arg0.len); - } - PyBuffer_Release(&arg0); - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject *sdk_OrthancPluginFindAnswers_OrthancPluginFindMarkIncomplete( - sdk_OrthancPluginFindAnswers_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginFindMarkIncomplete() on object of class OrthancPluginFindAnswers"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginFindMarkIncomplete(OrthancPlugins::GetGlobalContext(), self->object_); - } - - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginFindMatcher.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginFindMatcher.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,138 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Forward declaration of the autogenerated methods -static PyObject *sdk_OrthancPluginFindMatcher_OrthancPluginFindMatcherIsMatch( - sdk_OrthancPluginFindMatcher_Object* self, PyObject *args); -// End of forward declarations - - -// Forward declaration of the custom methods -// End of forward declarations - - -static PyMethodDef sdk_OrthancPluginFindMatcher_Methods[] = { - { "FindMatcherIsMatch", - (PyCFunction) sdk_OrthancPluginFindMatcher_OrthancPluginFindMatcherIsMatch, METH_VARARGS, - "Generated from C function OrthancPluginFindMatcherIsMatch()" }, - { NULL } /* Sentinel */ -}; - - -static int sdk_OrthancPluginFindMatcher_Constructor( - sdk_OrthancPluginFindMatcher_Object *self, PyObject *args, PyObject *kwds) -{ - PythonLock::LogCall("Creating Python object of class OrthancPluginFindMatcher"); - - self->object_ = NULL; - self->borrowed_ = false; - - long long object = 0; - unsigned char borrowed = false; - - if (PyArg_ParseTuple(args, "Lb", &object, &borrowed)) - { - self->object_ = reinterpret_cast(static_cast(object)); - self->borrowed_ = borrowed; - return 0; - } - else - { - PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor"); - return -1; - } -} - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginFindMatcher_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.FindMatcher", /* tp_name */ - sizeof(sdk_OrthancPluginFindMatcher_Object), /* tp_basicsize */ -}; - - -static void sdk_OrthancPluginFindMatcher_Destructor(PyObject *self) -{ - PythonLock::LogCall("Destroying Python object of class OrthancPluginFindMatcher"); - - sdk_OrthancPluginFindMatcher_Object& tmp = *((sdk_OrthancPluginFindMatcher_Object*) self); - - if (tmp.object_ != NULL && - !tmp.borrowed_) - { - OrthancPluginFreeFindMatcher(OrthancPlugins::GetGlobalContext(), tmp.object_); - tmp.object_ = NULL; - } - - Py_TYPE(self)->tp_free((PyObject *)self); -} - - -static void RegisterOrthancPluginFindMatcherClass(PyObject* module) -{ - sdk_OrthancPluginFindMatcher_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginFindMatcher_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginFindMatcher_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginFindMatcher"; - sdk_OrthancPluginFindMatcher_Type.tp_methods = sdk_OrthancPluginFindMatcher_Methods; - sdk_OrthancPluginFindMatcher_Type.tp_init = (initproc) sdk_OrthancPluginFindMatcher_Constructor; - - /** - * "tp_dealloc is called when the reference count of the object goes - * down to zero. This is where you destroy the object and its - * members. It should then free the memory occupied by the object by - * calling tp_free." - * https://stackoverflow.com/a/24863227/881731 - **/ - sdk_OrthancPluginFindMatcher_Type.tp_dealloc = sdk_OrthancPluginFindMatcher_Destructor; - - if (PyType_Ready(&sdk_OrthancPluginFindMatcher_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginFindMatcher"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - Py_INCREF(&sdk_OrthancPluginFindMatcher_Type); - if (PyModule_AddObject(module, "FindMatcher", (PyObject *)&sdk_OrthancPluginFindMatcher_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginFindMatcher"); - Py_DECREF(&sdk_OrthancPluginFindMatcher_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} - - -PyTypeObject* GetOrthancPluginFindMatcherType() -{ - return &sdk_OrthancPluginFindMatcher_Type; -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginFindMatcher.methods.h --- a/Sources/Autogenerated/sdk_OrthancPluginFindMatcher.methods.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Actual implementation of the methods -static PyObject *sdk_OrthancPluginFindMatcher_OrthancPluginFindMatcherIsMatch( - sdk_OrthancPluginFindMatcher_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginFindMatcherIsMatch() on object of class OrthancPluginFindMatcher"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - Py_buffer arg0; - - if (!PyArg_ParseTuple(args, "s*", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginFindMatcherIsMatch(OrthancPlugins::GetGlobalContext(), self->object_, arg0.buf, arg0.len); - } - PyBuffer_Release(&arg0); - return PyLong_FromLong(value); -} - diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginFindQuery.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginFindQuery.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Forward declaration of the autogenerated methods -static PyObject *sdk_OrthancPluginFindQuery_OrthancPluginGetFindQuerySize( - sdk_OrthancPluginFindQuery_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginFindQuery_OrthancPluginGetFindQueryTagName( - sdk_OrthancPluginFindQuery_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginFindQuery_OrthancPluginGetFindQueryValue( - sdk_OrthancPluginFindQuery_Object* self, PyObject *args); -// End of forward declarations - - -// Forward declaration of the custom methods -extern PyObject *GetFindQueryTagElement(sdk_OrthancPluginFindQuery_Object* self, PyObject *args); -extern PyObject *GetFindQueryTagGroup(sdk_OrthancPluginFindQuery_Object* self, PyObject *args); -// End of forward declarations - - -static PyMethodDef sdk_OrthancPluginFindQuery_Methods[] = { - { "GetFindQuerySize", - (PyCFunction) sdk_OrthancPluginFindQuery_OrthancPluginGetFindQuerySize, METH_VARARGS, - "Generated from C function OrthancPluginGetFindQuerySize()" }, - { "GetFindQueryTagName", - (PyCFunction) sdk_OrthancPluginFindQuery_OrthancPluginGetFindQueryTagName, METH_VARARGS, - "Generated from C function OrthancPluginGetFindQueryTagName()" }, - { "GetFindQueryValue", - (PyCFunction) sdk_OrthancPluginFindQuery_OrthancPluginGetFindQueryValue, METH_VARARGS, - "Generated from C function OrthancPluginGetFindQueryValue()" }, - { "GetFindQueryTagElement", - (PyCFunction) GetFindQueryTagElement, METH_VARARGS, - "Implemented in C++ function GetFindQueryTagElement()" }, - { "GetFindQueryTagGroup", - (PyCFunction) GetFindQueryTagGroup, METH_VARARGS, - "Implemented in C++ function GetFindQueryTagGroup()" }, - { NULL } /* Sentinel */ -}; - - -static int sdk_OrthancPluginFindQuery_Constructor( - sdk_OrthancPluginFindQuery_Object *self, PyObject *args, PyObject *kwds) -{ - PythonLock::LogCall("Creating Python object of class OrthancPluginFindQuery"); - - self->object_ = NULL; - self->borrowed_ = false; - - long long object = 0; - unsigned char borrowed = false; - - if (PyArg_ParseTuple(args, "Lb", &object, &borrowed)) - { - self->object_ = reinterpret_cast(static_cast(object)); - self->borrowed_ = borrowed; - return 0; - } - else - { - PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor"); - return -1; - } -} - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginFindQuery_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.FindQuery", /* tp_name */ - sizeof(sdk_OrthancPluginFindQuery_Object), /* tp_basicsize */ -}; - - - - -static void RegisterOrthancPluginFindQueryClass(PyObject* module) -{ - sdk_OrthancPluginFindQuery_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginFindQuery_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginFindQuery_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginFindQuery"; - sdk_OrthancPluginFindQuery_Type.tp_methods = sdk_OrthancPluginFindQuery_Methods; - sdk_OrthancPluginFindQuery_Type.tp_init = (initproc) sdk_OrthancPluginFindQuery_Constructor; - - - if (PyType_Ready(&sdk_OrthancPluginFindQuery_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginFindQuery"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - Py_INCREF(&sdk_OrthancPluginFindQuery_Type); - if (PyModule_AddObject(module, "FindQuery", (PyObject *)&sdk_OrthancPluginFindQuery_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginFindQuery"); - Py_DECREF(&sdk_OrthancPluginFindQuery_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} - - -PyTypeObject* GetOrthancPluginFindQueryType() -{ - return &sdk_OrthancPluginFindQuery_Type; -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginFindQuery.methods.h --- a/Sources/Autogenerated/sdk_OrthancPluginFindQuery.methods.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,124 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Actual implementation of the methods -static PyObject *sdk_OrthancPluginFindQuery_OrthancPluginGetFindQuerySize( - sdk_OrthancPluginFindQuery_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetFindQuerySize() on object of class OrthancPluginFindQuery"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginGetFindQuerySize(OrthancPlugins::GetGlobalContext(), self->object_); - } - - return PyLong_FromLong(value); -} - -static PyObject *sdk_OrthancPluginFindQuery_OrthancPluginGetFindQueryTagName( - sdk_OrthancPluginFindQuery_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetFindQueryTagName() on object of class OrthancPluginFindQuery"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - unsigned long arg0 = 0; - - if (!PyArg_ParseTuple(args, "k", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginGetFindQueryTagName(OrthancPlugins::GetGlobalContext(), self->object_, arg0)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - -static PyObject *sdk_OrthancPluginFindQuery_OrthancPluginGetFindQueryValue( - sdk_OrthancPluginFindQuery_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetFindQueryValue() on object of class OrthancPluginFindQuery"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - unsigned long arg0 = 0; - - if (!PyArg_ParseTuple(args, "k", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginGetFindQueryValue(OrthancPlugins::GetGlobalContext(), self->object_, arg0)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginHttpMethod.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginHttpMethod.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginHttpMethod_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginHttpMethod_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.HttpMethod", /* tp_name */ - sizeof(sdk_OrthancPluginHttpMethod_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginHttpMethodEnumeration(PyObject* module) -{ - sdk_OrthancPluginHttpMethod_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginHttpMethod_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginHttpMethod_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginHttpMethod"; - - sdk_OrthancPluginHttpMethod_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginHttpMethod_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginHttpMethod"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginHttpMethod_Type.tp_dict, "GET", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginHttpMethod_Type.tp_dict, "POST", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginHttpMethod_Type.tp_dict, "PUT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(4); - PyDict_SetItemString(sdk_OrthancPluginHttpMethod_Type.tp_dict, "DELETE", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginHttpMethod_Type); - if (PyModule_AddObject(module, "HttpMethod", (PyObject *)&sdk_OrthancPluginHttpMethod_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginHttpMethod"); - Py_DECREF(&sdk_OrthancPluginHttpMethod_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginIdentifierConstraint.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginIdentifierConstraint.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginIdentifierConstraint_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginIdentifierConstraint_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.IdentifierConstraint", /* tp_name */ - sizeof(sdk_OrthancPluginIdentifierConstraint_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginIdentifierConstraintEnumeration(PyObject* module) -{ - sdk_OrthancPluginIdentifierConstraint_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginIdentifierConstraint_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginIdentifierConstraint_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginIdentifierConstraint"; - - sdk_OrthancPluginIdentifierConstraint_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginIdentifierConstraint_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginIdentifierConstraint"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginIdentifierConstraint_Type.tp_dict, "EQUAL", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginIdentifierConstraint_Type.tp_dict, "SMALLER_OR_EQUAL", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginIdentifierConstraint_Type.tp_dict, "GREATER_OR_EQUAL", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(4); - PyDict_SetItemString(sdk_OrthancPluginIdentifierConstraint_Type.tp_dict, "WILDCARD", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginIdentifierConstraint_Type); - if (PyModule_AddObject(module, "IdentifierConstraint", (PyObject *)&sdk_OrthancPluginIdentifierConstraint_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginIdentifierConstraint"); - Py_DECREF(&sdk_OrthancPluginIdentifierConstraint_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginImage.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginImage.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Forward declaration of the autogenerated methods -static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImagePixelFormat( - sdk_OrthancPluginImage_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImageWidth( - sdk_OrthancPluginImage_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImageHeight( - sdk_OrthancPluginImage_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImagePitch( - sdk_OrthancPluginImage_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginImage_OrthancPluginConvertPixelFormat( - sdk_OrthancPluginImage_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginImage_OrthancPluginDrawText( - sdk_OrthancPluginImage_Object* self, PyObject *args); -// End of forward declarations - - -// Forward declaration of the custom methods -extern PyObject *GetImageBuffer(sdk_OrthancPluginImage_Object* self, PyObject *args); -// End of forward declarations - - -static PyMethodDef sdk_OrthancPluginImage_Methods[] = { - { "GetImagePixelFormat", - (PyCFunction) sdk_OrthancPluginImage_OrthancPluginGetImagePixelFormat, METH_VARARGS, - "Generated from C function OrthancPluginGetImagePixelFormat()" }, - { "GetImageWidth", - (PyCFunction) sdk_OrthancPluginImage_OrthancPluginGetImageWidth, METH_VARARGS, - "Generated from C function OrthancPluginGetImageWidth()" }, - { "GetImageHeight", - (PyCFunction) sdk_OrthancPluginImage_OrthancPluginGetImageHeight, METH_VARARGS, - "Generated from C function OrthancPluginGetImageHeight()" }, - { "GetImagePitch", - (PyCFunction) sdk_OrthancPluginImage_OrthancPluginGetImagePitch, METH_VARARGS, - "Generated from C function OrthancPluginGetImagePitch()" }, - { "ConvertPixelFormat", - (PyCFunction) sdk_OrthancPluginImage_OrthancPluginConvertPixelFormat, METH_VARARGS, - "Generated from C function OrthancPluginConvertPixelFormat()" }, - { "DrawText", - (PyCFunction) sdk_OrthancPluginImage_OrthancPluginDrawText, METH_VARARGS, - "Generated from C function OrthancPluginDrawText()" }, - { "GetImageBuffer", - (PyCFunction) GetImageBuffer, METH_VARARGS, - "Implemented in C++ function GetImageBuffer()" }, - { NULL } /* Sentinel */ -}; - - -static int sdk_OrthancPluginImage_Constructor( - sdk_OrthancPluginImage_Object *self, PyObject *args, PyObject *kwds) -{ - PythonLock::LogCall("Creating Python object of class OrthancPluginImage"); - - self->object_ = NULL; - self->borrowed_ = false; - - long long object = 0; - unsigned char borrowed = false; - - if (PyArg_ParseTuple(args, "Lb", &object, &borrowed)) - { - self->object_ = reinterpret_cast(static_cast(object)); - self->borrowed_ = borrowed; - return 0; - } - else - { - PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor"); - return -1; - } -} - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginImage_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.Image", /* tp_name */ - sizeof(sdk_OrthancPluginImage_Object), /* tp_basicsize */ -}; - - -static void sdk_OrthancPluginImage_Destructor(PyObject *self) -{ - PythonLock::LogCall("Destroying Python object of class OrthancPluginImage"); - - sdk_OrthancPluginImage_Object& tmp = *((sdk_OrthancPluginImage_Object*) self); - - if (tmp.object_ != NULL && - !tmp.borrowed_) - { - OrthancPluginFreeImage(OrthancPlugins::GetGlobalContext(), tmp.object_); - tmp.object_ = NULL; - } - - Py_TYPE(self)->tp_free((PyObject *)self); -} - - -static void RegisterOrthancPluginImageClass(PyObject* module) -{ - sdk_OrthancPluginImage_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginImage_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginImage_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginImage"; - sdk_OrthancPluginImage_Type.tp_methods = sdk_OrthancPluginImage_Methods; - sdk_OrthancPluginImage_Type.tp_init = (initproc) sdk_OrthancPluginImage_Constructor; - - /** - * "tp_dealloc is called when the reference count of the object goes - * down to zero. This is where you destroy the object and its - * members. It should then free the memory occupied by the object by - * calling tp_free." - * https://stackoverflow.com/a/24863227/881731 - **/ - sdk_OrthancPluginImage_Type.tp_dealloc = sdk_OrthancPluginImage_Destructor; - - if (PyType_Ready(&sdk_OrthancPluginImage_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginImage"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - Py_INCREF(&sdk_OrthancPluginImage_Type); - if (PyModule_AddObject(module, "Image", (PyObject *)&sdk_OrthancPluginImage_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginImage"); - Py_DECREF(&sdk_OrthancPluginImage_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} - - -PyTypeObject* GetOrthancPluginImageType() -{ - return &sdk_OrthancPluginImage_Type; -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginImage.methods.h --- a/Sources/Autogenerated/sdk_OrthancPluginImage.methods.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,202 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Actual implementation of the methods -static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImagePixelFormat( - sdk_OrthancPluginImage_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetImagePixelFormat() on object of class OrthancPluginImage"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - OrthancPluginPixelFormat value; - { - PythonThreadsAllower allower; - value = OrthancPluginGetImagePixelFormat(OrthancPlugins::GetGlobalContext(), self->object_); - } - - return PyLong_FromLong(value); -} - -static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImageWidth( - sdk_OrthancPluginImage_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetImageWidth() on object of class OrthancPluginImage"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginGetImageWidth(OrthancPlugins::GetGlobalContext(), self->object_); - } - - return PyLong_FromLong(value); -} - -static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImageHeight( - sdk_OrthancPluginImage_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetImageHeight() on object of class OrthancPluginImage"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginGetImageHeight(OrthancPlugins::GetGlobalContext(), self->object_); - } - - return PyLong_FromLong(value); -} - -static PyObject *sdk_OrthancPluginImage_OrthancPluginGetImagePitch( - sdk_OrthancPluginImage_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetImagePitch() on object of class OrthancPluginImage"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginGetImagePitch(OrthancPlugins::GetGlobalContext(), self->object_); - } - - return PyLong_FromLong(value); -} - -static PyObject *sdk_OrthancPluginImage_OrthancPluginConvertPixelFormat( - sdk_OrthancPluginImage_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginConvertPixelFormat() on object of class OrthancPluginImage"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - long int arg0 = 0; - - if (!PyArg_ParseTuple(args, "l", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - // This is the case of a constructor - OrthancPluginImage* obj; - { - PythonThreadsAllower allower; - obj = OrthancPluginConvertPixelFormat(OrthancPlugins::GetGlobalContext(), self->object_, static_cast(arg0)); - } - - if (obj == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - PyObject *argList = Py_BuildValue("Lb", obj, false /* not borrowed */); - PyObject *python = PyObject_CallObject((PyObject *) &sdk_OrthancPluginImage_Type, argList); - Py_DECREF(argList); - return python; - } -} - -static PyObject *sdk_OrthancPluginImage_OrthancPluginDrawText( - sdk_OrthancPluginImage_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginDrawText() on object of class OrthancPluginImage"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - unsigned long arg0 = 0; - const char* arg1 = NULL; - long int arg2 = 0; - long int arg3 = 0; - unsigned char arg4 = 0; - unsigned char arg5 = 0; - unsigned char arg6 = 0; - - if (!PyArg_ParseTuple(args, "ksllbbb", &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (7 arguments expected)"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginDrawText(OrthancPlugins::GetGlobalContext(), self->object_, arg0, arg1, arg2, arg3, arg4, arg5, arg6); - } - - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginImageFormat.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginImageFormat.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginImageFormat_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginImageFormat_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.ImageFormat", /* tp_name */ - sizeof(sdk_OrthancPluginImageFormat_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginImageFormatEnumeration(PyObject* module) -{ - sdk_OrthancPluginImageFormat_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginImageFormat_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginImageFormat_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginImageFormat"; - - sdk_OrthancPluginImageFormat_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginImageFormat_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginImageFormat"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(0); - PyDict_SetItemString(sdk_OrthancPluginImageFormat_Type.tp_dict, "PNG", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginImageFormat_Type.tp_dict, "JPEG", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginImageFormat_Type.tp_dict, "DICOM", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginImageFormat_Type); - if (PyModule_AddObject(module, "ImageFormat", (PyObject *)&sdk_OrthancPluginImageFormat_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginImageFormat"); - Py_DECREF(&sdk_OrthancPluginImageFormat_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginInstanceOrigin.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginInstanceOrigin.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginInstanceOrigin_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginInstanceOrigin_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.InstanceOrigin", /* tp_name */ - sizeof(sdk_OrthancPluginInstanceOrigin_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginInstanceOriginEnumeration(PyObject* module) -{ - sdk_OrthancPluginInstanceOrigin_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginInstanceOrigin_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginInstanceOrigin_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginInstanceOrigin"; - - sdk_OrthancPluginInstanceOrigin_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginInstanceOrigin_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginInstanceOrigin"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginInstanceOrigin_Type.tp_dict, "UNKNOWN", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginInstanceOrigin_Type.tp_dict, "DICOM_PROTOCOL", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginInstanceOrigin_Type.tp_dict, "REST_API", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(4); - PyDict_SetItemString(sdk_OrthancPluginInstanceOrigin_Type.tp_dict, "PLUGIN", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(5); - PyDict_SetItemString(sdk_OrthancPluginInstanceOrigin_Type.tp_dict, "LUA", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(6); - PyDict_SetItemString(sdk_OrthancPluginInstanceOrigin_Type.tp_dict, "WEB_DAV", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginInstanceOrigin_Type); - if (PyModule_AddObject(module, "InstanceOrigin", (PyObject *)&sdk_OrthancPluginInstanceOrigin_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginInstanceOrigin"); - Py_DECREF(&sdk_OrthancPluginInstanceOrigin_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginJob.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginJob.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,138 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Forward declaration of the autogenerated methods -static PyObject *sdk_OrthancPluginJob_OrthancPluginSubmitJob( - sdk_OrthancPluginJob_Object* self, PyObject *args); -// End of forward declarations - - -// Forward declaration of the custom methods -// End of forward declarations - - -static PyMethodDef sdk_OrthancPluginJob_Methods[] = { - { "SubmitJob", - (PyCFunction) sdk_OrthancPluginJob_OrthancPluginSubmitJob, METH_VARARGS, - "Generated from C function OrthancPluginSubmitJob()" }, - { NULL } /* Sentinel */ -}; - - -static int sdk_OrthancPluginJob_Constructor( - sdk_OrthancPluginJob_Object *self, PyObject *args, PyObject *kwds) -{ - PythonLock::LogCall("Creating Python object of class OrthancPluginJob"); - - self->object_ = NULL; - self->borrowed_ = false; - - long long object = 0; - unsigned char borrowed = false; - - if (PyArg_ParseTuple(args, "Lb", &object, &borrowed)) - { - self->object_ = reinterpret_cast(static_cast(object)); - self->borrowed_ = borrowed; - return 0; - } - else - { - PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor"); - return -1; - } -} - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginJob_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.Job", /* tp_name */ - sizeof(sdk_OrthancPluginJob_Object), /* tp_basicsize */ -}; - - -static void sdk_OrthancPluginJob_Destructor(PyObject *self) -{ - PythonLock::LogCall("Destroying Python object of class OrthancPluginJob"); - - sdk_OrthancPluginJob_Object& tmp = *((sdk_OrthancPluginJob_Object*) self); - - if (tmp.object_ != NULL && - !tmp.borrowed_) - { - OrthancPluginFreeJob(OrthancPlugins::GetGlobalContext(), tmp.object_); - tmp.object_ = NULL; - } - - Py_TYPE(self)->tp_free((PyObject *)self); -} - - -static void RegisterOrthancPluginJobClass(PyObject* module) -{ - sdk_OrthancPluginJob_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginJob_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginJob_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginJob"; - sdk_OrthancPluginJob_Type.tp_methods = sdk_OrthancPluginJob_Methods; - sdk_OrthancPluginJob_Type.tp_init = (initproc) sdk_OrthancPluginJob_Constructor; - - /** - * "tp_dealloc is called when the reference count of the object goes - * down to zero. This is where you destroy the object and its - * members. It should then free the memory occupied by the object by - * calling tp_free." - * https://stackoverflow.com/a/24863227/881731 - **/ - sdk_OrthancPluginJob_Type.tp_dealloc = sdk_OrthancPluginJob_Destructor; - - if (PyType_Ready(&sdk_OrthancPluginJob_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginJob"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - Py_INCREF(&sdk_OrthancPluginJob_Type); - if (PyModule_AddObject(module, "Job", (PyObject *)&sdk_OrthancPluginJob_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginJob"); - Py_DECREF(&sdk_OrthancPluginJob_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} - - -PyTypeObject* GetOrthancPluginJobType() -{ - return &sdk_OrthancPluginJob_Type; -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginJob.methods.h --- a/Sources/Autogenerated/sdk_OrthancPluginJob.methods.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Actual implementation of the methods -static PyObject *sdk_OrthancPluginJob_OrthancPluginSubmitJob( - sdk_OrthancPluginJob_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginSubmitJob() on object of class OrthancPluginJob"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - long int arg0 = 0; - - if (!PyArg_ParseTuple(args, "l", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPlugins::OrthancString s; - { - PythonThreadsAllower allower; - s.Assign(OrthancPluginSubmitJob(OrthancPlugins::GetGlobalContext(), self->object_, arg0)); - } - - if (s.GetContent() == NULL) - { - PythonLock::RaiseException(OrthancPluginErrorCode_InternalError); - return NULL; - } - else - { - return PyUnicode_FromString(s.GetContent()); - } -} - diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginJobStepStatus.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginJobStepStatus.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginJobStepStatus_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginJobStepStatus_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.JobStepStatus", /* tp_name */ - sizeof(sdk_OrthancPluginJobStepStatus_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginJobStepStatusEnumeration(PyObject* module) -{ - sdk_OrthancPluginJobStepStatus_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginJobStepStatus_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginJobStepStatus_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginJobStepStatus"; - - sdk_OrthancPluginJobStepStatus_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginJobStepStatus_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginJobStepStatus"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginJobStepStatus_Type.tp_dict, "SUCCESS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginJobStepStatus_Type.tp_dict, "FAILURE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginJobStepStatus_Type.tp_dict, "CONTINUE", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginJobStepStatus_Type); - if (PyModule_AddObject(module, "JobStepStatus", (PyObject *)&sdk_OrthancPluginJobStepStatus_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginJobStepStatus"); - Py_DECREF(&sdk_OrthancPluginJobStepStatus_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginJobStopReason.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginJobStopReason.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginJobStopReason_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginJobStopReason_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.JobStopReason", /* tp_name */ - sizeof(sdk_OrthancPluginJobStopReason_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginJobStopReasonEnumeration(PyObject* module) -{ - sdk_OrthancPluginJobStopReason_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginJobStopReason_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginJobStopReason_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginJobStopReason"; - - sdk_OrthancPluginJobStopReason_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginJobStopReason_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginJobStopReason"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginJobStopReason_Type.tp_dict, "SUCCESS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginJobStopReason_Type.tp_dict, "PAUSED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginJobStopReason_Type.tp_dict, "FAILURE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(4); - PyDict_SetItemString(sdk_OrthancPluginJobStopReason_Type.tp_dict, "CANCELED", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginJobStopReason_Type); - if (PyModule_AddObject(module, "JobStopReason", (PyObject *)&sdk_OrthancPluginJobStopReason_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginJobStopReason"); - Py_DECREF(&sdk_OrthancPluginJobStopReason_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginLoadDicomInstanceMode.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginLoadDicomInstanceMode.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginLoadDicomInstanceMode_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginLoadDicomInstanceMode_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.LoadDicomInstanceMode", /* tp_name */ - sizeof(sdk_OrthancPluginLoadDicomInstanceMode_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginLoadDicomInstanceModeEnumeration(PyObject* module) -{ - sdk_OrthancPluginLoadDicomInstanceMode_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginLoadDicomInstanceMode_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginLoadDicomInstanceMode_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginLoadDicomInstanceMode"; - - sdk_OrthancPluginLoadDicomInstanceMode_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginLoadDicomInstanceMode_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginLoadDicomInstanceMode"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginLoadDicomInstanceMode_Type.tp_dict, "WHOLE_DICOM", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginLoadDicomInstanceMode_Type.tp_dict, "UNTIL_PIXEL_DATA", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginLoadDicomInstanceMode_Type.tp_dict, "EMPTY_PIXEL_DATA", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginLoadDicomInstanceMode_Type); - if (PyModule_AddObject(module, "LoadDicomInstanceMode", (PyObject *)&sdk_OrthancPluginLoadDicomInstanceMode_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginLoadDicomInstanceMode"); - Py_DECREF(&sdk_OrthancPluginLoadDicomInstanceMode_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginLogCategory.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginLogCategory.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginLogCategory_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginLogCategory_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.LogCategory", /* tp_name */ - sizeof(sdk_OrthancPluginLogCategory_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginLogCategoryEnumeration(PyObject* module) -{ - sdk_OrthancPluginLogCategory_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginLogCategory_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginLogCategory_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginLogCategory"; - - sdk_OrthancPluginLogCategory_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginLogCategory_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginLogCategory"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginLogCategory_Type.tp_dict, "GENERIC", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginLogCategory_Type.tp_dict, "PLUGINS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(4); - PyDict_SetItemString(sdk_OrthancPluginLogCategory_Type.tp_dict, "HTTP", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(8); - PyDict_SetItemString(sdk_OrthancPluginLogCategory_Type.tp_dict, "SQLITE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(16); - PyDict_SetItemString(sdk_OrthancPluginLogCategory_Type.tp_dict, "DICOM", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(32); - PyDict_SetItemString(sdk_OrthancPluginLogCategory_Type.tp_dict, "JOBS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(64); - PyDict_SetItemString(sdk_OrthancPluginLogCategory_Type.tp_dict, "LUA", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginLogCategory_Type); - if (PyModule_AddObject(module, "LogCategory", (PyObject *)&sdk_OrthancPluginLogCategory_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginLogCategory"); - Py_DECREF(&sdk_OrthancPluginLogCategory_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginLogLevel.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginLogLevel.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginLogLevel_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginLogLevel_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.LogLevel", /* tp_name */ - sizeof(sdk_OrthancPluginLogLevel_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginLogLevelEnumeration(PyObject* module) -{ - sdk_OrthancPluginLogLevel_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginLogLevel_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginLogLevel_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginLogLevel"; - - sdk_OrthancPluginLogLevel_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginLogLevel_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginLogLevel"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(0); - PyDict_SetItemString(sdk_OrthancPluginLogLevel_Type.tp_dict, "ERROR", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginLogLevel_Type.tp_dict, "WARNING", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginLogLevel_Type.tp_dict, "INFO", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginLogLevel_Type.tp_dict, "TRACE", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginLogLevel_Type); - if (PyModule_AddObject(module, "LogLevel", (PyObject *)&sdk_OrthancPluginLogLevel_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginLogLevel"); - Py_DECREF(&sdk_OrthancPluginLogLevel_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginMetricsType.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginMetricsType.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,96 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginMetricsType_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginMetricsType_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.MetricsType", /* tp_name */ - sizeof(sdk_OrthancPluginMetricsType_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginMetricsTypeEnumeration(PyObject* module) -{ - sdk_OrthancPluginMetricsType_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginMetricsType_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginMetricsType_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginMetricsType"; - - sdk_OrthancPluginMetricsType_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginMetricsType_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginMetricsType"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(0); - PyDict_SetItemString(sdk_OrthancPluginMetricsType_Type.tp_dict, "DEFAULT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginMetricsType_Type.tp_dict, "TIMER", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginMetricsType_Type); - if (PyModule_AddObject(module, "MetricsType", (PyObject *)&sdk_OrthancPluginMetricsType_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginMetricsType"); - Py_DECREF(&sdk_OrthancPluginMetricsType_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginPeers.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginPeers.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,153 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Forward declaration of the autogenerated methods -static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeersCount( - sdk_OrthancPluginPeers_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeerName( - sdk_OrthancPluginPeers_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeerUrl( - sdk_OrthancPluginPeers_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeerUserProperty( - sdk_OrthancPluginPeers_Object* self, PyObject *args); -// End of forward declarations - - -// Forward declaration of the custom methods -// End of forward declarations - - -static PyMethodDef sdk_OrthancPluginPeers_Methods[] = { - { "GetPeersCount", - (PyCFunction) sdk_OrthancPluginPeers_OrthancPluginGetPeersCount, METH_VARARGS, - "Generated from C function OrthancPluginGetPeersCount()" }, - { "GetPeerName", - (PyCFunction) sdk_OrthancPluginPeers_OrthancPluginGetPeerName, METH_VARARGS, - "Generated from C function OrthancPluginGetPeerName()" }, - { "GetPeerUrl", - (PyCFunction) sdk_OrthancPluginPeers_OrthancPluginGetPeerUrl, METH_VARARGS, - "Generated from C function OrthancPluginGetPeerUrl()" }, - { "GetPeerUserProperty", - (PyCFunction) sdk_OrthancPluginPeers_OrthancPluginGetPeerUserProperty, METH_VARARGS, - "Generated from C function OrthancPluginGetPeerUserProperty()" }, - { NULL } /* Sentinel */ -}; - - -static int sdk_OrthancPluginPeers_Constructor( - sdk_OrthancPluginPeers_Object *self, PyObject *args, PyObject *kwds) -{ - PythonLock::LogCall("Creating Python object of class OrthancPluginPeers"); - - self->object_ = NULL; - self->borrowed_ = false; - - long long object = 0; - unsigned char borrowed = false; - - if (PyArg_ParseTuple(args, "Lb", &object, &borrowed)) - { - self->object_ = reinterpret_cast(static_cast(object)); - self->borrowed_ = borrowed; - return 0; - } - else - { - PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor"); - return -1; - } -} - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginPeers_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.Peers", /* tp_name */ - sizeof(sdk_OrthancPluginPeers_Object), /* tp_basicsize */ -}; - - -static void sdk_OrthancPluginPeers_Destructor(PyObject *self) -{ - PythonLock::LogCall("Destroying Python object of class OrthancPluginPeers"); - - sdk_OrthancPluginPeers_Object& tmp = *((sdk_OrthancPluginPeers_Object*) self); - - if (tmp.object_ != NULL && - !tmp.borrowed_) - { - OrthancPluginFreePeers(OrthancPlugins::GetGlobalContext(), tmp.object_); - tmp.object_ = NULL; - } - - Py_TYPE(self)->tp_free((PyObject *)self); -} - - -static void RegisterOrthancPluginPeersClass(PyObject* module) -{ - sdk_OrthancPluginPeers_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginPeers_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginPeers_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginPeers"; - sdk_OrthancPluginPeers_Type.tp_methods = sdk_OrthancPluginPeers_Methods; - sdk_OrthancPluginPeers_Type.tp_init = (initproc) sdk_OrthancPluginPeers_Constructor; - - /** - * "tp_dealloc is called when the reference count of the object goes - * down to zero. This is where you destroy the object and its - * members. It should then free the memory occupied by the object by - * calling tp_free." - * https://stackoverflow.com/a/24863227/881731 - **/ - sdk_OrthancPluginPeers_Type.tp_dealloc = sdk_OrthancPluginPeers_Destructor; - - if (PyType_Ready(&sdk_OrthancPluginPeers_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginPeers"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - Py_INCREF(&sdk_OrthancPluginPeers_Type); - if (PyModule_AddObject(module, "Peers", (PyObject *)&sdk_OrthancPluginPeers_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginPeers"); - Py_DECREF(&sdk_OrthancPluginPeers_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} - - -PyTypeObject* GetOrthancPluginPeersType() -{ - return &sdk_OrthancPluginPeers_Type; -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginPeers.methods.h --- a/Sources/Autogenerated/sdk_OrthancPluginPeers.methods.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,161 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Actual implementation of the methods -static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeersCount( - sdk_OrthancPluginPeers_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetPeersCount() on object of class OrthancPluginPeers"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginGetPeersCount(OrthancPlugins::GetGlobalContext(), self->object_); - } - - return PyLong_FromLong(value); -} - -static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeerName( - sdk_OrthancPluginPeers_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetPeerName() on object of class OrthancPluginPeers"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - unsigned long arg0 = 0; - - if (!PyArg_ParseTuple(args, "k", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - const char* s; - { - PythonThreadsAllower allower; - s = OrthancPluginGetPeerName(OrthancPlugins::GetGlobalContext(), self->object_, arg0); - } - - if (s == NULL) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - return PyUnicode_FromString(s); - } -} - -static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeerUrl( - sdk_OrthancPluginPeers_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetPeerUrl() on object of class OrthancPluginPeers"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - unsigned long arg0 = 0; - - if (!PyArg_ParseTuple(args, "k", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - const char* s; - { - PythonThreadsAllower allower; - s = OrthancPluginGetPeerUrl(OrthancPlugins::GetGlobalContext(), self->object_, arg0); - } - - if (s == NULL) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - return PyUnicode_FromString(s); - } -} - -static PyObject *sdk_OrthancPluginPeers_OrthancPluginGetPeerUserProperty( - sdk_OrthancPluginPeers_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginGetPeerUserProperty() on object of class OrthancPluginPeers"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - unsigned long arg0 = 0; - const char* arg1 = NULL; - - if (!PyArg_ParseTuple(args, "ks", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - const char* s; - { - PythonThreadsAllower allower; - s = OrthancPluginGetPeerUserProperty(OrthancPlugins::GetGlobalContext(), self->object_, arg0, arg1); - } - - if (s == NULL) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - return PyUnicode_FromString(s); - } -} - diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginPixelFormat.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginPixelFormat.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,150 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginPixelFormat_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginPixelFormat_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.PixelFormat", /* tp_name */ - sizeof(sdk_OrthancPluginPixelFormat_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginPixelFormatEnumeration(PyObject* module) -{ - sdk_OrthancPluginPixelFormat_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginPixelFormat_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginPixelFormat_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginPixelFormat"; - - sdk_OrthancPluginPixelFormat_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginPixelFormat_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginPixelFormat"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginPixelFormat_Type.tp_dict, "GRAYSCALE8", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginPixelFormat_Type.tp_dict, "GRAYSCALE16", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginPixelFormat_Type.tp_dict, "SIGNED_GRAYSCALE16", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(4); - PyDict_SetItemString(sdk_OrthancPluginPixelFormat_Type.tp_dict, "RGB24", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(5); - PyDict_SetItemString(sdk_OrthancPluginPixelFormat_Type.tp_dict, "RGBA32", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(6); - PyDict_SetItemString(sdk_OrthancPluginPixelFormat_Type.tp_dict, "UNKNOWN", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(7); - PyDict_SetItemString(sdk_OrthancPluginPixelFormat_Type.tp_dict, "RGB48", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(8); - PyDict_SetItemString(sdk_OrthancPluginPixelFormat_Type.tp_dict, "GRAYSCALE32", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(9); - PyDict_SetItemString(sdk_OrthancPluginPixelFormat_Type.tp_dict, "FLOAT32", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(10); - PyDict_SetItemString(sdk_OrthancPluginPixelFormat_Type.tp_dict, "BGRA32", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(11); - PyDict_SetItemString(sdk_OrthancPluginPixelFormat_Type.tp_dict, "GRAYSCALE64", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginPixelFormat_Type); - if (PyModule_AddObject(module, "PixelFormat", (PyObject *)&sdk_OrthancPluginPixelFormat_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginPixelFormat"); - Py_DECREF(&sdk_OrthancPluginPixelFormat_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginReceivedInstanceAction.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginReceivedInstanceAction.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginReceivedInstanceAction_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginReceivedInstanceAction_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.ReceivedInstanceAction", /* tp_name */ - sizeof(sdk_OrthancPluginReceivedInstanceAction_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginReceivedInstanceActionEnumeration(PyObject* module) -{ - sdk_OrthancPluginReceivedInstanceAction_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginReceivedInstanceAction_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginReceivedInstanceAction_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginReceivedInstanceAction"; - - sdk_OrthancPluginReceivedInstanceAction_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginReceivedInstanceAction_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginReceivedInstanceAction"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginReceivedInstanceAction_Type.tp_dict, "KEEP_AS_IS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginReceivedInstanceAction_Type.tp_dict, "MODIFY", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginReceivedInstanceAction_Type.tp_dict, "DISCARD", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginReceivedInstanceAction_Type); - if (PyModule_AddObject(module, "ReceivedInstanceAction", (PyObject *)&sdk_OrthancPluginReceivedInstanceAction_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginReceivedInstanceAction"); - Py_DECREF(&sdk_OrthancPluginReceivedInstanceAction_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginResourceType.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginResourceType.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginResourceType_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginResourceType_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.ResourceType", /* tp_name */ - sizeof(sdk_OrthancPluginResourceType_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginResourceTypeEnumeration(PyObject* module) -{ - sdk_OrthancPluginResourceType_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginResourceType_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginResourceType_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginResourceType"; - - sdk_OrthancPluginResourceType_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginResourceType_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginResourceType"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(0); - PyDict_SetItemString(sdk_OrthancPluginResourceType_Type.tp_dict, "PATIENT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginResourceType_Type.tp_dict, "STUDY", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginResourceType_Type.tp_dict, "SERIES", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginResourceType_Type.tp_dict, "INSTANCE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(4); - PyDict_SetItemString(sdk_OrthancPluginResourceType_Type.tp_dict, "NONE", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginResourceType_Type); - if (PyModule_AddObject(module, "ResourceType", (PyObject *)&sdk_OrthancPluginResourceType_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginResourceType"); - Py_DECREF(&sdk_OrthancPluginResourceType_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginRestOutput.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginRestOutput.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,175 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Forward declaration of the autogenerated methods -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginAnswerBuffer( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginCompressAndAnswerPngImage( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginRedirect( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSendHttpStatusCode( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSendUnauthorized( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSendMethodNotAllowed( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSetCookie( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSetHttpHeader( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginStartMultipartAnswer( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSendMultipartItem( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSendHttpStatus( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginCompressAndAnswerJpegImage( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSetHttpErrorDetails( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args); -// End of forward declarations - - -// Forward declaration of the custom methods -// End of forward declarations - - -static PyMethodDef sdk_OrthancPluginRestOutput_Methods[] = { - { "AnswerBuffer", - (PyCFunction) sdk_OrthancPluginRestOutput_OrthancPluginAnswerBuffer, METH_VARARGS, - "Generated from C function OrthancPluginAnswerBuffer()" }, - { "CompressAndAnswerPngImage", - (PyCFunction) sdk_OrthancPluginRestOutput_OrthancPluginCompressAndAnswerPngImage, METH_VARARGS, - "Generated from C function OrthancPluginCompressAndAnswerPngImage()" }, - { "Redirect", - (PyCFunction) sdk_OrthancPluginRestOutput_OrthancPluginRedirect, METH_VARARGS, - "Generated from C function OrthancPluginRedirect()" }, - { "SendHttpStatusCode", - (PyCFunction) sdk_OrthancPluginRestOutput_OrthancPluginSendHttpStatusCode, METH_VARARGS, - "Generated from C function OrthancPluginSendHttpStatusCode()" }, - { "SendUnauthorized", - (PyCFunction) sdk_OrthancPluginRestOutput_OrthancPluginSendUnauthorized, METH_VARARGS, - "Generated from C function OrthancPluginSendUnauthorized()" }, - { "SendMethodNotAllowed", - (PyCFunction) sdk_OrthancPluginRestOutput_OrthancPluginSendMethodNotAllowed, METH_VARARGS, - "Generated from C function OrthancPluginSendMethodNotAllowed()" }, - { "SetCookie", - (PyCFunction) sdk_OrthancPluginRestOutput_OrthancPluginSetCookie, METH_VARARGS, - "Generated from C function OrthancPluginSetCookie()" }, - { "SetHttpHeader", - (PyCFunction) sdk_OrthancPluginRestOutput_OrthancPluginSetHttpHeader, METH_VARARGS, - "Generated from C function OrthancPluginSetHttpHeader()" }, - { "StartMultipartAnswer", - (PyCFunction) sdk_OrthancPluginRestOutput_OrthancPluginStartMultipartAnswer, METH_VARARGS, - "Generated from C function OrthancPluginStartMultipartAnswer()" }, - { "SendMultipartItem", - (PyCFunction) sdk_OrthancPluginRestOutput_OrthancPluginSendMultipartItem, METH_VARARGS, - "Generated from C function OrthancPluginSendMultipartItem()" }, - { "SendHttpStatus", - (PyCFunction) sdk_OrthancPluginRestOutput_OrthancPluginSendHttpStatus, METH_VARARGS, - "Generated from C function OrthancPluginSendHttpStatus()" }, - { "CompressAndAnswerJpegImage", - (PyCFunction) sdk_OrthancPluginRestOutput_OrthancPluginCompressAndAnswerJpegImage, METH_VARARGS, - "Generated from C function OrthancPluginCompressAndAnswerJpegImage()" }, - { "SetHttpErrorDetails", - (PyCFunction) sdk_OrthancPluginRestOutput_OrthancPluginSetHttpErrorDetails, METH_VARARGS, - "Generated from C function OrthancPluginSetHttpErrorDetails()" }, - { NULL } /* Sentinel */ -}; - - -static int sdk_OrthancPluginRestOutput_Constructor( - sdk_OrthancPluginRestOutput_Object *self, PyObject *args, PyObject *kwds) -{ - PythonLock::LogCall("Creating Python object of class OrthancPluginRestOutput"); - - self->object_ = NULL; - self->borrowed_ = false; - - long long object = 0; - unsigned char borrowed = false; - - if (PyArg_ParseTuple(args, "Lb", &object, &borrowed)) - { - self->object_ = reinterpret_cast(static_cast(object)); - self->borrowed_ = borrowed; - return 0; - } - else - { - PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor"); - return -1; - } -} - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginRestOutput_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.RestOutput", /* tp_name */ - sizeof(sdk_OrthancPluginRestOutput_Object), /* tp_basicsize */ -}; - - - - -static void RegisterOrthancPluginRestOutputClass(PyObject* module) -{ - sdk_OrthancPluginRestOutput_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginRestOutput_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginRestOutput_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginRestOutput"; - sdk_OrthancPluginRestOutput_Type.tp_methods = sdk_OrthancPluginRestOutput_Methods; - sdk_OrthancPluginRestOutput_Type.tp_init = (initproc) sdk_OrthancPluginRestOutput_Constructor; - - - if (PyType_Ready(&sdk_OrthancPluginRestOutput_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginRestOutput"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - Py_INCREF(&sdk_OrthancPluginRestOutput_Type); - if (PyModule_AddObject(module, "RestOutput", (PyObject *)&sdk_OrthancPluginRestOutput_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginRestOutput"); - Py_DECREF(&sdk_OrthancPluginRestOutput_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} - - -PyTypeObject* GetOrthancPluginRestOutputType() -{ - return &sdk_OrthancPluginRestOutput_Type; -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginRestOutput.methods.h --- a/Sources/Autogenerated/sdk_OrthancPluginRestOutput.methods.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,440 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Actual implementation of the methods -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginAnswerBuffer( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginAnswerBuffer() on object of class OrthancPluginRestOutput"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - Py_buffer arg0; - const char* arg2 = NULL; - - if (!PyArg_ParseTuple(args, "s*s", &arg0, &arg2)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginAnswerBuffer(OrthancPlugins::GetGlobalContext(), self->object_, arg0.buf, arg0.len, arg2); - } - PyBuffer_Release(&arg0); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginCompressAndAnswerPngImage( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginCompressAndAnswerPngImage() on object of class OrthancPluginRestOutput"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - long int arg0 = 0; - unsigned long arg1 = 0; - unsigned long arg2 = 0; - unsigned long arg3 = 0; - Py_buffer arg4; - - if (!PyArg_ParseTuple(args, "lkkks*", &arg0, &arg1, &arg2, &arg3, &arg4)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (5 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginCompressAndAnswerPngImage(OrthancPlugins::GetGlobalContext(), self->object_, static_cast(arg0), arg1, arg2, arg3, arg4.buf); - } - PyBuffer_Release(&arg4); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginRedirect( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginRedirect() on object of class OrthancPluginRestOutput"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginRedirect(OrthancPlugins::GetGlobalContext(), self->object_, arg0); - } - - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSendHttpStatusCode( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginSendHttpStatusCode() on object of class OrthancPluginRestOutput"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - unsigned short arg0 = 0; - - if (!PyArg_ParseTuple(args, "H", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginSendHttpStatusCode(OrthancPlugins::GetGlobalContext(), self->object_, arg0); - } - - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSendUnauthorized( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginSendUnauthorized() on object of class OrthancPluginRestOutput"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginSendUnauthorized(OrthancPlugins::GetGlobalContext(), self->object_, arg0); - } - - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSendMethodNotAllowed( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginSendMethodNotAllowed() on object of class OrthancPluginRestOutput"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - const char* arg0 = NULL; - - if (!PyArg_ParseTuple(args, "s", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginSendMethodNotAllowed(OrthancPlugins::GetGlobalContext(), self->object_, arg0); - } - - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSetCookie( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginSetCookie() on object of class OrthancPluginRestOutput"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - const char* arg0 = NULL; - const char* arg1 = NULL; - - if (!PyArg_ParseTuple(args, "ss", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginSetCookie(OrthancPlugins::GetGlobalContext(), self->object_, arg0, arg1); - } - - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSetHttpHeader( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginSetHttpHeader() on object of class OrthancPluginRestOutput"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - const char* arg0 = NULL; - const char* arg1 = NULL; - - if (!PyArg_ParseTuple(args, "ss", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginSetHttpHeader(OrthancPlugins::GetGlobalContext(), self->object_, arg0, arg1); - } - - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginStartMultipartAnswer( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginStartMultipartAnswer() on object of class OrthancPluginRestOutput"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - const char* arg0 = NULL; - const char* arg1 = NULL; - - if (!PyArg_ParseTuple(args, "ss", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginStartMultipartAnswer(OrthancPlugins::GetGlobalContext(), self->object_, arg0, arg1); - } - - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSendMultipartItem( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginSendMultipartItem() on object of class OrthancPluginRestOutput"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - Py_buffer arg0; - - if (!PyArg_ParseTuple(args, "s*", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginSendMultipartItem(OrthancPlugins::GetGlobalContext(), self->object_, arg0.buf, arg0.len); - } - PyBuffer_Release(&arg0); - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSendHttpStatus( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginSendHttpStatus() on object of class OrthancPluginRestOutput"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - unsigned short arg0 = 0; - Py_buffer arg1; - - if (!PyArg_ParseTuple(args, "Hs*", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginSendHttpStatus(OrthancPlugins::GetGlobalContext(), self->object_, arg0, arg1.buf, arg1.len); - } - PyBuffer_Release(&arg1); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginCompressAndAnswerJpegImage( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginCompressAndAnswerJpegImage() on object of class OrthancPluginRestOutput"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - long int arg0 = 0; - unsigned long arg1 = 0; - unsigned long arg2 = 0; - unsigned long arg3 = 0; - Py_buffer arg4; - unsigned char arg5 = 0; - - if (!PyArg_ParseTuple(args, "lkkks*b", &arg0, &arg1, &arg2, &arg3, &arg4, &arg5)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (6 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginCompressAndAnswerJpegImage(OrthancPlugins::GetGlobalContext(), self->object_, static_cast(arg0), arg1, arg2, arg3, arg4.buf, arg5); - } - PyBuffer_Release(&arg4); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *sdk_OrthancPluginRestOutput_OrthancPluginSetHttpErrorDetails( - sdk_OrthancPluginRestOutput_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginSetHttpErrorDetails() on object of class OrthancPluginRestOutput"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - const char* arg0 = NULL; - unsigned char arg1 = 0; - - if (!PyArg_ParseTuple(args, "sb", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - { - PythonThreadsAllower allower; - OrthancPluginSetHttpErrorDetails(OrthancPlugins::GetGlobalContext(), self->object_, arg0, arg1); - } - - - Py_INCREF(Py_None); - return Py_None; -} - diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginServerChunkedRequestReader.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginServerChunkedRequestReader.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Forward declaration of the autogenerated methods -// End of forward declarations - - -// Forward declaration of the custom methods -// End of forward declarations - - -static PyMethodDef sdk_OrthancPluginServerChunkedRequestReader_Methods[] = { - { NULL } /* Sentinel */ -}; - - -static int sdk_OrthancPluginServerChunkedRequestReader_Constructor( - sdk_OrthancPluginServerChunkedRequestReader_Object *self, PyObject *args, PyObject *kwds) -{ - PythonLock::LogCall("Creating Python object of class OrthancPluginServerChunkedRequestReader"); - - self->object_ = NULL; - self->borrowed_ = false; - - long long object = 0; - unsigned char borrowed = false; - - if (PyArg_ParseTuple(args, "Lb", &object, &borrowed)) - { - self->object_ = reinterpret_cast(static_cast(object)); - self->borrowed_ = borrowed; - return 0; - } - else - { - PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor"); - return -1; - } -} - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginServerChunkedRequestReader_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.ServerChunkedRequestReader", /* tp_name */ - sizeof(sdk_OrthancPluginServerChunkedRequestReader_Object), /* tp_basicsize */ -}; - - - - -static void RegisterOrthancPluginServerChunkedRequestReaderClass(PyObject* module) -{ - sdk_OrthancPluginServerChunkedRequestReader_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginServerChunkedRequestReader_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginServerChunkedRequestReader_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginServerChunkedRequestReader"; - sdk_OrthancPluginServerChunkedRequestReader_Type.tp_methods = sdk_OrthancPluginServerChunkedRequestReader_Methods; - sdk_OrthancPluginServerChunkedRequestReader_Type.tp_init = (initproc) sdk_OrthancPluginServerChunkedRequestReader_Constructor; - - - if (PyType_Ready(&sdk_OrthancPluginServerChunkedRequestReader_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginServerChunkedRequestReader"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - Py_INCREF(&sdk_OrthancPluginServerChunkedRequestReader_Type); - if (PyModule_AddObject(module, "ServerChunkedRequestReader", (PyObject *)&sdk_OrthancPluginServerChunkedRequestReader_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginServerChunkedRequestReader"); - Py_DECREF(&sdk_OrthancPluginServerChunkedRequestReader_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} - - -PyTypeObject* GetOrthancPluginServerChunkedRequestReaderType() -{ - return &sdk_OrthancPluginServerChunkedRequestReader_Type; -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginServerChunkedRequestReader.methods.h --- a/Sources/Autogenerated/sdk_OrthancPluginServerChunkedRequestReader.methods.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Actual implementation of the methods diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginStorageArea.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginStorageArea.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Forward declaration of the autogenerated methods -static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaCreate( - sdk_OrthancPluginStorageArea_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaRead( - sdk_OrthancPluginStorageArea_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaRemove( - sdk_OrthancPluginStorageArea_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginReconstructMainDicomTags( - sdk_OrthancPluginStorageArea_Object* self, PyObject *args); -// End of forward declarations - - -// Forward declaration of the custom methods -// End of forward declarations - - -static PyMethodDef sdk_OrthancPluginStorageArea_Methods[] = { - { "StorageAreaCreate", - (PyCFunction) sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaCreate, METH_VARARGS, - "Generated from C function OrthancPluginStorageAreaCreate()" }, - { "StorageAreaRead", - (PyCFunction) sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaRead, METH_VARARGS, - "Generated from C function OrthancPluginStorageAreaRead()" }, - { "StorageAreaRemove", - (PyCFunction) sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaRemove, METH_VARARGS, - "Generated from C function OrthancPluginStorageAreaRemove()" }, - { "ReconstructMainDicomTags", - (PyCFunction) sdk_OrthancPluginStorageArea_OrthancPluginReconstructMainDicomTags, METH_VARARGS, - "Generated from C function OrthancPluginReconstructMainDicomTags()" }, - { NULL } /* Sentinel */ -}; - - -static int sdk_OrthancPluginStorageArea_Constructor( - sdk_OrthancPluginStorageArea_Object *self, PyObject *args, PyObject *kwds) -{ - PythonLock::LogCall("Creating Python object of class OrthancPluginStorageArea"); - - self->object_ = NULL; - self->borrowed_ = false; - - long long object = 0; - unsigned char borrowed = false; - - if (PyArg_ParseTuple(args, "Lb", &object, &borrowed)) - { - self->object_ = reinterpret_cast(static_cast(object)); - self->borrowed_ = borrowed; - return 0; - } - else - { - PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor"); - return -1; - } -} - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginStorageArea_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.StorageArea", /* tp_name */ - sizeof(sdk_OrthancPluginStorageArea_Object), /* tp_basicsize */ -}; - - - - -static void RegisterOrthancPluginStorageAreaClass(PyObject* module) -{ - sdk_OrthancPluginStorageArea_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginStorageArea_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginStorageArea_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginStorageArea"; - sdk_OrthancPluginStorageArea_Type.tp_methods = sdk_OrthancPluginStorageArea_Methods; - sdk_OrthancPluginStorageArea_Type.tp_init = (initproc) sdk_OrthancPluginStorageArea_Constructor; - - - if (PyType_Ready(&sdk_OrthancPluginStorageArea_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginStorageArea"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - Py_INCREF(&sdk_OrthancPluginStorageArea_Type); - if (PyModule_AddObject(module, "StorageArea", (PyObject *)&sdk_OrthancPluginStorageArea_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginStorageArea"); - Py_DECREF(&sdk_OrthancPluginStorageArea_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} - - -PyTypeObject* GetOrthancPluginStorageAreaType() -{ - return &sdk_OrthancPluginStorageArea_Type; -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginStorageArea.methods.h --- a/Sources/Autogenerated/sdk_OrthancPluginStorageArea.methods.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,186 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Actual implementation of the methods -static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaCreate( - sdk_OrthancPluginStorageArea_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginStorageAreaCreate() on object of class OrthancPluginStorageArea"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - const char* arg0 = NULL; - Py_buffer arg1; - unsigned long long arg2 = 0; - long int arg3 = 0; - - if (!PyArg_ParseTuple(args, "ss*Kl", &arg0, &arg1, &arg2, &arg3)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (4 arguments expected)"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginStorageAreaCreate(OrthancPlugins::GetGlobalContext(), self->object_, arg0, arg1.buf, arg2, static_cast(arg3)); - } - PyBuffer_Release(&arg1); - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaRead( - sdk_OrthancPluginStorageArea_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginStorageAreaRead() on object of class OrthancPluginStorageArea"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - const char* arg0 = NULL; - long int arg1 = 0; - - if (!PyArg_ParseTuple(args, "sl", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginStorageAreaRead(OrthancPlugins::GetGlobalContext(), *buffer, self->object_, arg0, static_cast(arg1)); - } - - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginStorageAreaRemove( - sdk_OrthancPluginStorageArea_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginStorageAreaRemove() on object of class OrthancPluginStorageArea"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - const char* arg0 = NULL; - long int arg1 = 0; - - if (!PyArg_ParseTuple(args, "sl", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginStorageAreaRemove(OrthancPlugins::GetGlobalContext(), self->object_, arg0, static_cast(arg1)); - } - - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject *sdk_OrthancPluginStorageArea_OrthancPluginReconstructMainDicomTags( - sdk_OrthancPluginStorageArea_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginReconstructMainDicomTags() on object of class OrthancPluginStorageArea"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - long int arg0 = 0; - - if (!PyArg_ParseTuple(args, "l", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginReconstructMainDicomTags(OrthancPlugins::GetGlobalContext(), self->object_, static_cast(arg0)); - } - - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginStorageCommitmentFailureReason.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginStorageCommitmentFailureReason.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginStorageCommitmentFailureReason_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginStorageCommitmentFailureReason_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.StorageCommitmentFailureReason", /* tp_name */ - sizeof(sdk_OrthancPluginStorageCommitmentFailureReason_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginStorageCommitmentFailureReasonEnumeration(PyObject* module) -{ - sdk_OrthancPluginStorageCommitmentFailureReason_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginStorageCommitmentFailureReason_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginStorageCommitmentFailureReason_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginStorageCommitmentFailureReason"; - - sdk_OrthancPluginStorageCommitmentFailureReason_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginStorageCommitmentFailureReason_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginStorageCommitmentFailureReason"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(0); - PyDict_SetItemString(sdk_OrthancPluginStorageCommitmentFailureReason_Type.tp_dict, "SUCCESS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginStorageCommitmentFailureReason_Type.tp_dict, "PROCESSING_FAILURE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginStorageCommitmentFailureReason_Type.tp_dict, "NO_SUCH_OBJECT_INSTANCE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginStorageCommitmentFailureReason_Type.tp_dict, "RESOURCE_LIMITATION", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(4); - PyDict_SetItemString(sdk_OrthancPluginStorageCommitmentFailureReason_Type.tp_dict, "REFERENCED_SOPCLASS_NOT_SUPPORTED", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(5); - PyDict_SetItemString(sdk_OrthancPluginStorageCommitmentFailureReason_Type.tp_dict, "CLASS_INSTANCE_CONFLICT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(6); - PyDict_SetItemString(sdk_OrthancPluginStorageCommitmentFailureReason_Type.tp_dict, "DUPLICATE_TRANSACTION_UID", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginStorageCommitmentFailureReason_Type); - if (PyModule_AddObject(module, "StorageCommitmentFailureReason", (PyObject *)&sdk_OrthancPluginStorageCommitmentFailureReason_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginStorageCommitmentFailureReason"); - Py_DECREF(&sdk_OrthancPluginStorageCommitmentFailureReason_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginValueRepresentation.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginValueRepresentation.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,246 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -typedef struct -{ - PyObject_HEAD -} sdk_OrthancPluginValueRepresentation_Object; - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginValueRepresentation_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.ValueRepresentation", /* tp_name */ - sizeof(sdk_OrthancPluginValueRepresentation_Object), /* tp_basicsize */ -}; - - -void RegisterOrthancPluginValueRepresentationEnumeration(PyObject* module) -{ - sdk_OrthancPluginValueRepresentation_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginValueRepresentation_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginValueRepresentation_Type.tp_doc = "Generated from C enumeration OrthancPluginOrthancPluginValueRepresentation"; - - sdk_OrthancPluginValueRepresentation_Type.tp_dict = PyDict_New(); - - if (PyType_Ready(&sdk_OrthancPluginValueRepresentation_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginValueRepresentation"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - /** - * Declare constants here (static members = class attributes) - * https://stackoverflow.com/a/8017906/881731 - * - * "Static and class methods can be defined in tp_methods by adding - * METH_STATIC or METH_CLASS to the ml_flags field of the - * PyMethodDef structure. This is equivalent to @staticmethod and - * @classmethod decorators." - * - * "Class attributes can be added by setting the tp_dict to a - * dictionary with these attributes before calling PyType_Ready() - * (in your module initialization function)." - **/ - - { - PyObject* tmp = PyLong_FromLong(1); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "AE", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(2); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "AS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(3); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "AT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(4); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "CS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(5); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "DA", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(6); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "DS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(7); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "DT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(8); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "FD", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(9); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "FL", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(10); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "IS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(11); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "LO", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(12); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "LT", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(13); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "OB", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(14); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "OF", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(15); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "OW", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(16); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "PN", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(17); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "SH", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(18); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "SL", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(19); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "SQ", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(20); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "SS", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(21); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "ST", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(22); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "TM", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(23); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "UI", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(24); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "UL", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(25); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "UN", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(26); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "US", tmp); - Py_DECREF(tmp); - } - - { - PyObject* tmp = PyLong_FromLong(27); - PyDict_SetItemString(sdk_OrthancPluginValueRepresentation_Type.tp_dict, "UT", tmp); - Py_DECREF(tmp); - } - - - Py_INCREF(&sdk_OrthancPluginValueRepresentation_Type); - if (PyModule_AddObject(module, "ValueRepresentation", (PyObject *)&sdk_OrthancPluginValueRepresentation_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python enumeration: OrthancPluginValueRepresentation"); - Py_DECREF(&sdk_OrthancPluginValueRepresentation_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginWebDavCollection.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginWebDavCollection.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Forward declaration of the autogenerated methods -// End of forward declarations - - -// Forward declaration of the custom methods -// End of forward declarations - - -static PyMethodDef sdk_OrthancPluginWebDavCollection_Methods[] = { - { NULL } /* Sentinel */ -}; - - -static int sdk_OrthancPluginWebDavCollection_Constructor( - sdk_OrthancPluginWebDavCollection_Object *self, PyObject *args, PyObject *kwds) -{ - PythonLock::LogCall("Creating Python object of class OrthancPluginWebDavCollection"); - - self->object_ = NULL; - self->borrowed_ = false; - - long long object = 0; - unsigned char borrowed = false; - - if (PyArg_ParseTuple(args, "Lb", &object, &borrowed)) - { - self->object_ = reinterpret_cast(static_cast(object)); - self->borrowed_ = borrowed; - return 0; - } - else - { - PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor"); - return -1; - } -} - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginWebDavCollection_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.WebDavCollection", /* tp_name */ - sizeof(sdk_OrthancPluginWebDavCollection_Object), /* tp_basicsize */ -}; - - - - -static void RegisterOrthancPluginWebDavCollectionClass(PyObject* module) -{ - sdk_OrthancPluginWebDavCollection_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginWebDavCollection_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginWebDavCollection_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginWebDavCollection"; - sdk_OrthancPluginWebDavCollection_Type.tp_methods = sdk_OrthancPluginWebDavCollection_Methods; - sdk_OrthancPluginWebDavCollection_Type.tp_init = (initproc) sdk_OrthancPluginWebDavCollection_Constructor; - - - if (PyType_Ready(&sdk_OrthancPluginWebDavCollection_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginWebDavCollection"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - Py_INCREF(&sdk_OrthancPluginWebDavCollection_Type); - if (PyModule_AddObject(module, "WebDavCollection", (PyObject *)&sdk_OrthancPluginWebDavCollection_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginWebDavCollection"); - Py_DECREF(&sdk_OrthancPluginWebDavCollection_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} - - -PyTypeObject* GetOrthancPluginWebDavCollectionType() -{ - return &sdk_OrthancPluginWebDavCollection_Type; -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginWebDavCollection.methods.h --- a/Sources/Autogenerated/sdk_OrthancPluginWebDavCollection.methods.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Actual implementation of the methods diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginWorklistAnswers.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginWorklistAnswers.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Forward declaration of the autogenerated methods -static PyObject *sdk_OrthancPluginWorklistAnswers_OrthancPluginWorklistAddAnswer( - sdk_OrthancPluginWorklistAnswers_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginWorklistAnswers_OrthancPluginWorklistMarkIncomplete( - sdk_OrthancPluginWorklistAnswers_Object* self, PyObject *args); -// End of forward declarations - - -// Forward declaration of the custom methods -// End of forward declarations - - -static PyMethodDef sdk_OrthancPluginWorklistAnswers_Methods[] = { - { "WorklistAddAnswer", - (PyCFunction) sdk_OrthancPluginWorklistAnswers_OrthancPluginWorklistAddAnswer, METH_VARARGS, - "Generated from C function OrthancPluginWorklistAddAnswer()" }, - { "WorklistMarkIncomplete", - (PyCFunction) sdk_OrthancPluginWorklistAnswers_OrthancPluginWorklistMarkIncomplete, METH_VARARGS, - "Generated from C function OrthancPluginWorklistMarkIncomplete()" }, - { NULL } /* Sentinel */ -}; - - -static int sdk_OrthancPluginWorklistAnswers_Constructor( - sdk_OrthancPluginWorklistAnswers_Object *self, PyObject *args, PyObject *kwds) -{ - PythonLock::LogCall("Creating Python object of class OrthancPluginWorklistAnswers"); - - self->object_ = NULL; - self->borrowed_ = false; - - long long object = 0; - unsigned char borrowed = false; - - if (PyArg_ParseTuple(args, "Lb", &object, &borrowed)) - { - self->object_ = reinterpret_cast(static_cast(object)); - self->borrowed_ = borrowed; - return 0; - } - else - { - PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor"); - return -1; - } -} - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginWorklistAnswers_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.WorklistAnswers", /* tp_name */ - sizeof(sdk_OrthancPluginWorklistAnswers_Object), /* tp_basicsize */ -}; - - - - -static void RegisterOrthancPluginWorklistAnswersClass(PyObject* module) -{ - sdk_OrthancPluginWorklistAnswers_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginWorklistAnswers_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginWorklistAnswers_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginWorklistAnswers"; - sdk_OrthancPluginWorklistAnswers_Type.tp_methods = sdk_OrthancPluginWorklistAnswers_Methods; - sdk_OrthancPluginWorklistAnswers_Type.tp_init = (initproc) sdk_OrthancPluginWorklistAnswers_Constructor; - - - if (PyType_Ready(&sdk_OrthancPluginWorklistAnswers_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginWorklistAnswers"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - Py_INCREF(&sdk_OrthancPluginWorklistAnswers_Type); - if (PyModule_AddObject(module, "WorklistAnswers", (PyObject *)&sdk_OrthancPluginWorklistAnswers_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginWorklistAnswers"); - Py_DECREF(&sdk_OrthancPluginWorklistAnswers_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} - - -PyTypeObject* GetOrthancPluginWorklistAnswersType() -{ - return &sdk_OrthancPluginWorklistAnswers_Type; -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginWorklistAnswers.methods.h --- a/Sources/Autogenerated/sdk_OrthancPluginWorklistAnswers.methods.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Actual implementation of the methods -static PyObject *sdk_OrthancPluginWorklistAnswers_OrthancPluginWorklistAddAnswer( - sdk_OrthancPluginWorklistAnswers_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginWorklistAddAnswer() on object of class OrthancPluginWorklistAnswers"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - PyObject* arg0 = NULL; - Py_buffer arg1; - - if (!PyArg_ParseTuple(args, "Os*", &arg0, &arg1)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (2 arguments expected)"); - return NULL; - } - - if (arg0 != Py_None && Py_TYPE(arg0) != GetOrthancPluginWorklistQueryType()) - { - PyErr_SetString(PyExc_TypeError, "Invalid orthanc.OrthancPluginWorklistQuery object"); - return NULL; - } - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginWorklistAddAnswer(OrthancPlugins::GetGlobalContext(), self->object_, arg0 == Py_None ? NULL : reinterpret_cast(arg0)->object_, arg1.buf, arg1.len); - } - PyBuffer_Release(&arg1); - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - -static PyObject *sdk_OrthancPluginWorklistAnswers_OrthancPluginWorklistMarkIncomplete( - sdk_OrthancPluginWorklistAnswers_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginWorklistMarkIncomplete() on object of class OrthancPluginWorklistAnswers"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginWorklistMarkIncomplete(OrthancPlugins::GetGlobalContext(), self->object_); - } - - - if (code == OrthancPluginErrorCode_Success) - { - Py_INCREF(Py_None); - return Py_None; - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginWorklistQuery.impl.h --- a/Sources/Autogenerated/sdk_OrthancPluginWorklistQuery.impl.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Forward declaration of the autogenerated methods -static PyObject *sdk_OrthancPluginWorklistQuery_OrthancPluginWorklistIsMatch( - sdk_OrthancPluginWorklistQuery_Object* self, PyObject *args); -static PyObject *sdk_OrthancPluginWorklistQuery_OrthancPluginWorklistGetDicomQuery( - sdk_OrthancPluginWorklistQuery_Object* self, PyObject *args); -// End of forward declarations - - -// Forward declaration of the custom methods -// End of forward declarations - - -static PyMethodDef sdk_OrthancPluginWorklistQuery_Methods[] = { - { "WorklistIsMatch", - (PyCFunction) sdk_OrthancPluginWorklistQuery_OrthancPluginWorklistIsMatch, METH_VARARGS, - "Generated from C function OrthancPluginWorklistIsMatch()" }, - { "WorklistGetDicomQuery", - (PyCFunction) sdk_OrthancPluginWorklistQuery_OrthancPluginWorklistGetDicomQuery, METH_VARARGS, - "Generated from C function OrthancPluginWorklistGetDicomQuery()" }, - { NULL } /* Sentinel */ -}; - - -static int sdk_OrthancPluginWorklistQuery_Constructor( - sdk_OrthancPluginWorklistQuery_Object *self, PyObject *args, PyObject *kwds) -{ - PythonLock::LogCall("Creating Python object of class OrthancPluginWorklistQuery"); - - self->object_ = NULL; - self->borrowed_ = false; - - long long object = 0; - unsigned char borrowed = false; - - if (PyArg_ParseTuple(args, "Lb", &object, &borrowed)) - { - self->object_ = reinterpret_cast(static_cast(object)); - self->borrowed_ = borrowed; - return 0; - } - else - { - PyErr_SetString(PyExc_ValueError, "Expected a pair (pointer, borrowed) in the constructor"); - return -1; - } -} - - -/** - * Static global structure => the fields that are beyond the last - * initialized field are set to zero. - * https://stackoverflow.com/a/11152199/881731 - **/ -static PyTypeObject sdk_OrthancPluginWorklistQuery_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "orthanc.WorklistQuery", /* tp_name */ - sizeof(sdk_OrthancPluginWorklistQuery_Object), /* tp_basicsize */ -}; - - - - -static void RegisterOrthancPluginWorklistQueryClass(PyObject* module) -{ - sdk_OrthancPluginWorklistQuery_Type.tp_new = PyType_GenericNew; - sdk_OrthancPluginWorklistQuery_Type.tp_flags = Py_TPFLAGS_DEFAULT; - sdk_OrthancPluginWorklistQuery_Type.tp_doc = "Generated from Orthanc C class: OrthancPluginWorklistQuery"; - sdk_OrthancPluginWorklistQuery_Type.tp_methods = sdk_OrthancPluginWorklistQuery_Methods; - sdk_OrthancPluginWorklistQuery_Type.tp_init = (initproc) sdk_OrthancPluginWorklistQuery_Constructor; - - - if (PyType_Ready(&sdk_OrthancPluginWorklistQuery_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginWorklistQuery"); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } - - Py_INCREF(&sdk_OrthancPluginWorklistQuery_Type); - if (PyModule_AddObject(module, "WorklistQuery", (PyObject *)&sdk_OrthancPluginWorklistQuery_Type) < 0) - { - ORTHANC_PLUGINS_LOG_ERROR("Cannot register Python class: OrthancPluginWorklistQuery"); - Py_DECREF(&sdk_OrthancPluginWorklistQuery_Type); - ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); - } -} - - -PyTypeObject* GetOrthancPluginWorklistQueryType() -{ - return &sdk_OrthancPluginWorklistQuery_Type; -} diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Autogenerated/sdk_OrthancPluginWorklistQuery.methods.h --- a/Sources/Autogenerated/sdk_OrthancPluginWorklistQuery.methods.h Wed Jan 22 16:18:14 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2025 Orthanc Team SRL, 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -/** - * Python plugin for Orthanc - * Copyright (C) 2020-2023 Osimis S.A., Belgium - * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium - * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - **/ - - -// WARNING: Auto-generated file. Do not modify it by hand. - - -// Actual implementation of the methods -static PyObject *sdk_OrthancPluginWorklistQuery_OrthancPluginWorklistIsMatch( - sdk_OrthancPluginWorklistQuery_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginWorklistIsMatch() on object of class OrthancPluginWorklistQuery"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - Py_buffer arg0; - - if (!PyArg_ParseTuple(args, "s*", &arg0)) - { - PyErr_SetString(PyExc_TypeError, "Bad types for the arguments (1 arguments expected)"); - return NULL; - } - - long value; - { - PythonThreadsAllower allower; - value = OrthancPluginWorklistIsMatch(OrthancPlugins::GetGlobalContext(), self->object_, arg0.buf, arg0.len); - } - PyBuffer_Release(&arg0); - return PyLong_FromLong(value); -} - -static PyObject *sdk_OrthancPluginWorklistQuery_OrthancPluginWorklistGetDicomQuery( - sdk_OrthancPluginWorklistQuery_Object* self, PyObject *args) -{ - PythonLock::LogCall("Calling method OrthancPluginWorklistGetDicomQuery() on object of class OrthancPluginWorklistQuery"); - - if (self->object_ == NULL) - { - PyErr_SetString(PyExc_ValueError, "Invalid object"); - return NULL; - } - - - - OrthancPlugins::MemoryBuffer buffer; - OrthancPluginErrorCode code; - { - PythonThreadsAllower allower; - code = OrthancPluginWorklistGetDicomQuery(OrthancPlugins::GetGlobalContext(), *buffer, self->object_); - } - - if (code == OrthancPluginErrorCode_Success) - { - return PyBytes_FromStringAndSize(buffer.GetData(), buffer.GetSize()); - } - else - { - PythonLock::RaiseException(code); - return NULL; - } -} - diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/DicomScpCallbacks.cpp --- a/Sources/DicomScpCallbacks.cpp Wed Jan 22 16:18:14 2025 +0100 +++ b/Sources/DicomScpCallbacks.cpp Wed Aug 13 12:02:04 2025 +0200 @@ -29,10 +29,11 @@ #include "PythonHeaderWrapper.h" #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" -#include "Autogenerated/sdk.h" #include "ICallbackRegistration.h" #include "PythonString.h" +#include + static PyObject* findScpCallback_ = NULL; static PyObject* moveScpCallback_ = NULL; diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/IncomingHttpRequestFilter.cpp --- a/Sources/IncomingHttpRequestFilter.cpp Wed Jan 22 16:18:14 2025 +0100 +++ b/Sources/IncomingHttpRequestFilter.cpp Wed Aug 13 12:02:04 2025 +0200 @@ -29,10 +29,10 @@ #include "PythonHeaderWrapper.h" #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" -#include "Autogenerated/sdk.h" #include "ICallbackRegistration.h" #include "PythonString.h" +#include static PyObject* incomingHttpRequestFilter_ = NULL; diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/IncomingInstanceFilter.cpp --- a/Sources/IncomingInstanceFilter.cpp Wed Jan 22 16:18:14 2025 +0100 +++ b/Sources/IncomingInstanceFilter.cpp Wed Aug 13 12:02:04 2025 +0200 @@ -29,10 +29,11 @@ #include "PythonHeaderWrapper.h" #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" -#include "Autogenerated/sdk.h" #include "ICallbackRegistration.h" #include "PythonString.h" +#include + #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 10, 0) diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/OnStoredInstanceCallback.cpp --- a/Sources/OnStoredInstanceCallback.cpp Wed Jan 22 16:18:14 2025 +0100 +++ b/Sources/OnStoredInstanceCallback.cpp Wed Aug 13 12:02:04 2025 +0200 @@ -29,10 +29,11 @@ #include "PythonHeaderWrapper.h" #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" -#include "Autogenerated/sdk.h" #include "ICallbackRegistration.h" #include "PythonString.h" +#include + static PyObject* storedInstanceCallback_ = NULL; diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/Plugin.cpp --- a/Sources/Plugin.cpp Wed Jan 22 16:18:14 2025 +0100 +++ b/Sources/Plugin.cpp Wed Aug 13 12:02:04 2025 +0200 @@ -44,9 +44,9 @@ #include "PythonThreadsAllower.h" #include "RestCallbacks.h" -#include "Autogenerated/sdk.h" +#include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" -#include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" +#include #include #include @@ -143,7 +143,7 @@ } else { - OrthancPluginDicomInstance* instance = reinterpret_cast(self)->object_; + OrthancPluginDicomInstance* instance = self->object_; const void* data; size_t size; @@ -185,7 +185,7 @@ } else { - OrthancPluginImage* image = reinterpret_cast(self)->object_; + OrthancPluginImage* image = self->object_; const void* buffer; size_t size; @@ -287,6 +287,213 @@ } +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 8) +PyObject* GetKeyValue(PyObject* module, PyObject* args) +{ + // The GIL is locked at this point (no need to create "PythonLock") + + const char* storeId = NULL; + const char* key = NULL; + + if (!PyArg_ParseTuple(args, "ss", &storeId, &key)) + { + PyErr_SetString(PyExc_TypeError, "Bad arguments"); + return NULL; + } + else + { + uint8_t found = 0; + OrthancPlugins::MemoryBuffer buffer; + OrthancPluginErrorCode code; + + { + PythonThreadsAllower allower; + code = OrthancPluginGetKeyValue(OrthancPlugins::GetGlobalContext(), &found, *buffer, storeId, key); + } + + if (code == OrthancPluginErrorCode_Success) + { + if (found) + { + return PyBytes_FromStringAndSize(reinterpret_cast(buffer.GetData()), buffer.GetSize()); + } + else + { + return Py_None; + } + } + else + { + PyErr_SetString(PyExc_TypeError, OrthancPluginGetErrorDescription(OrthancPlugins::GetGlobalContext(), code)); + return NULL; + } + } +} +#endif + + +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 8) +PyObject* DequeueValue(PyObject* module, PyObject* args) +{ + // The GIL is locked at this point (no need to create "PythonLock") + + const char* queueId = NULL; + unsigned long origin = 0; + + if (!PyArg_ParseTuple(args, "sl", &queueId, &origin)) + { + PyErr_SetString(PyExc_TypeError, "Bad arguments"); + return NULL; + } + else + { + uint8_t found = 0; + OrthancPlugins::MemoryBuffer buffer; + OrthancPluginErrorCode code; + + { + PythonThreadsAllower allower; + code = OrthancPluginDequeueValue(OrthancPlugins::GetGlobalContext(), &found, *buffer, queueId, + static_cast(origin)); + } + + if (code == OrthancPluginErrorCode_Success) + { + if (found) + { + return PyBytes_FromStringAndSize(reinterpret_cast(buffer.GetData()), buffer.GetSize()); + } + else + { + return Py_None; + } + } + else + { + PyErr_SetString(PyExc_TypeError, OrthancPluginGetErrorDescription(OrthancPlugins::GetGlobalContext(), code)); + return NULL; + } + } +} +#endif + + +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 8) +PyObject* GetQueueSize(PyObject* module, PyObject* args) +{ + // The GIL is locked at this point (no need to create "PythonLock") + + const char* queueId = NULL; + + if (!PyArg_ParseTuple(args, "s", &queueId)) + { + PyErr_SetString(PyExc_TypeError, "Bad arguments"); + return NULL; + } + else + { + uint64_t size = 0; + OrthancPluginErrorCode code; + + { + PythonThreadsAllower allower; + code = OrthancPluginGetQueueSize(OrthancPlugins::GetGlobalContext(), queueId, &size); + } + + if (code == OrthancPluginErrorCode_Success) + { + return PyLong_FromLong(size); + } + else + { + PyErr_SetString(PyExc_TypeError, OrthancPluginGetErrorDescription(OrthancPlugins::GetGlobalContext(), code)); + return NULL; + } + } +} +#endif + + +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 8) +PyObject* KeysValuesIteratorNext(sdk_OrthancPluginKeysValuesIterator_Object* self, PyObject *args) +{ + // The GIL is locked at this point (no need to create "PythonLock") + + if (self->object_ == NULL) + { + PyErr_SetString(PyExc_ValueError, "Invalid object"); + return NULL; + } + else + { + uint8_t done; + OrthancPluginErrorCode code; + + { + PythonThreadsAllower allower; + code = OrthancPluginKeysValuesIteratorNext(OrthancPlugins::GetGlobalContext(), &done, self->object_); + } + + if (code == OrthancPluginErrorCode_Success) + { + return PyBool_FromLong(done ? 1 : 0); + } + else + { + PyErr_SetString(PyExc_TypeError, OrthancPluginGetErrorDescription(OrthancPlugins::GetGlobalContext(), code)); + return NULL; + } + } +} +#endif + + +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 9) +PyObject* SetStableStatus(PyObject* module, PyObject* args) +{ + const char* resourceId = NULL; + long int stableStatus = 0; + + if (!PyArg_ParseTuple(args, "sl", &resourceId, &stableStatus)) + { + PyErr_SetString(PyExc_TypeError, "Please provide a string containing the resourceId and a integer with 0 for stable and 1 for unstable"); + return NULL; + } + else + { + OrthancPluginErrorCode code; + uint8_t statusHasChanged; + + { + PythonThreadsAllower allower; + code = OrthancPluginSetStableStatus(OrthancPlugins::GetGlobalContext(), &statusHasChanged, resourceId, static_cast(stableStatus)); + } + + if (code == OrthancPluginErrorCode_Success) + { + /** + * "PyGILState_Ensure()" can be invoked several times from the + * same thread, so no problem in creating a PythonLock even if + * the GIL is already locked. + **/ + PythonLock lock; + + PythonObject tuple(lock, PyTuple_New(2)); + PyTuple_SetItem(tuple.GetPyObject(), 0, PyLong_FromUnsignedLong(static_cast(code))); + PyTuple_SetItem(tuple.GetPyObject(), 1, PyLong_FromLong(static_cast(statusHasChanged))); + + return tuple.Release(); + } + else + { + std::string message = "Failed to change stable status of resource: " + std::string(resourceId); + PyErr_SetString(PyExc_TypeError, message.c_str()); + return NULL; + } + } +} +#endif + static bool pythonEnabled_ = false; static std::string userScriptName_; @@ -371,6 +578,11 @@ OrthancPlugins::SetDescription(PLUGIN_NAME, "Run Python scripts as Orthanc plugins"); + ORTHANC_PLUGINS_LOG_WARNING("Version of the Orthanc SDK in use by the Python plugin: " + + boost::lexical_cast(ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER) + "." + + boost::lexical_cast(ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER) + "." + + boost::lexical_cast(ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER)); + try { /** diff -r 6a7e91d753ae -r 67c833e5dee6 Sources/RestCallbacks.cpp --- a/Sources/RestCallbacks.cpp Wed Jan 22 16:18:14 2025 +0100 +++ b/Sources/RestCallbacks.cpp Wed Aug 13 12:02:04 2025 +0200 @@ -29,10 +29,11 @@ #include "PythonHeaderWrapper.h" #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" -#include "Autogenerated/sdk.h" #include "PythonBytes.h" #include "PythonString.h" +#include + #include #include