Skip to content

API XMLSec Core Helpers

Aleksey Sanin edited this page Oct 12, 2026 · 6 revisions

XML Security Init/Shutdown

API Group: xmlsec_core_helpers

Library initialization, shutdown, configuration, and other helper functions and macros.

Utility functions. Various utility functions.

Macros

XMLSEC_SIZE_T_FMT

Defined as: "%zu"

Source: include/xmlsec/xmlsec.h

The printf format specifier for size_t.

The only reason we need this is that MinGW doesn't recognize "%zu" despite the fact that MSVC runtime supports it for 10+ years.


XMLSEC_SIZE_MIN

Defined as: ((xmlSecSize)0)

Source: include/xmlsec/xmlsec.h

The minimum value of xmlSecSize (0).


XMLSEC_SIZE_MAX

Defined as: SIZE_MAX

Source: include/xmlsec/xmlsec.h

The maximum value of xmlSecSize.


XMLSEC_SIZE_FMT

Defined as: XMLSEC_SIZE_T_FMT

Source: include/xmlsec/xmlsec.h

The printf format specifier for xmlSecSize.


xmlSecCheckVersionExact

Defined as: xmlSecCheckVersionExt(XMLSEC_VERSION_MAJOR, XMLSEC_VERSION_MINOR, XMLSEC_VERSION_SUBMINOR, xmlSecCheckVersionExactMatch)

Source: include/xmlsec/xmlsec.h

Checks if the loaded library version exactly matches.

Macro. Returns 1 if the loaded xmlsec library version exactly matches the one used to compile the caller, 0 if it does not.


xmlSecCheckVersion

Defined as: xmlSecCheckVersionExt(XMLSEC_VERSION_MAJOR, XMLSEC_VERSION_MINOR, XMLSEC_VERSION_SUBMINOR, xmlSecCheckVersionABICompatible)

Source: include/xmlsec/xmlsec.h

Checks if the loaded library version is ABI compatible.

Macro. Returns 1 if the loaded xmlsec library version is ABI compatible with the one used to compile the caller, 0 if it does not.


Typedefs

xmlSecPtr

typedef void* xmlSecPtr;

Source: include/xmlsec/xmlsec.h

Marks a function as deprecated.

Void pointer.


xmlSecSize

typedef size_t xmlSecSize;

Source: include/xmlsec/xmlsec.h

Size of something.


xmlSecByte

typedef unsigned char xmlSecByte;

Source: include/xmlsec/xmlsec.h

One byte.


Enumerations

xmlSecCheckVersionMode

Source: include/xmlsec/xmlsec.h

The xmlsec library version mode.

Value Initializer Description
xmlSecCheckVersionExactMatch 0 the version should match exactly.
xmlSecCheckVersionABICompatible `` the version should be ABI compatible.

Functions

xmlSecInit

int xmlSecInit(void);

Source: include/xmlsec/xmlsec.h

Initializes XML Security Library.

Initializes XML Security Library. The dependent libraries (LibXML and LibXSLT) must be initialized before calling this function.

Note: The application SHOULD NOT initialize the XML Security Library more than once per process. Re-initialization is not supported: a second call re-runs the sub-initialization routines, which re-initialize the global lists (IO callbacks, key data, transforms) and orphan the first-generation data (the dynamically allocated xmlSecIOCallbacks structs are never freed), resulting in a bounded one-time memory leak.

Note: in case of failure the library is left partially initialized and this state is not recoverable.

Returns: 0 on success or a negative value otherwise.


xmlSecShutdown

int xmlSecShutdown(void);

Source: include/xmlsec/xmlsec.h

Cleans up the XML Security Library.

Cleans up the XML Security Library.

Note: Once this function has been called it might be impossible to reinitialize the library correctly.

Returns: 0 on success or a negative value otherwise.


xmlSecGetDefaultCrypto

const xmlChar * xmlSecGetDefaultCrypto(void);

Source: include/xmlsec/xmlsec.h

Gets the default crypto engine for the XML Security Library.

Gets the default crypto engine ("openssl", "nss", etc.) for the XML Security Library.

Returns: the default crypto engine ("openssl", "nss", etc.).


xmlSecSetExternalEntityLoader

void xmlSecSetExternalEntityLoader(xmlExternalEntityLoader entityLoader);

Source: include/xmlsec/xmlsec.h

Wrapper for xmlSetExternalEntityLoader.

Parameters:

  • entityLoader — the new entity resolver function, or NULL to restore the loader that was in effect when the library was initialized

xmlSecStrlen

xmlSecSize xmlSecStrlen(const xmlChar *str);

Source: include/xmlsec/xmlsec.h

Calculates the length of the string.

Parameters:

  • str — the string.

Returns: the length of the string.


xmlSecCheckVersionExt

int xmlSecCheckVersionExt(int major, int minor, int subminor, xmlSecCheckVersionMode mode);

Source: include/xmlsec/xmlsec.h

Checks if the loaded version of xmlsec library could be used.

Parameters:

  • major — the major version number.
  • minor — the minor version number.
  • subminor — the subminor version number.
  • mode — the version check mode.

Returns: 1 if the loaded xmlsec library version is OK to use, 0 if it is not.


Clone this wiki locally