summaryrefslogtreecommitdiff
path: root/include/xmlsec/xmlsec.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/xmlsec/xmlsec.h')
-rw-r--r--include/xmlsec/xmlsec.h129
1 files changed, 97 insertions, 32 deletions
diff --git a/include/xmlsec/xmlsec.h b/include/xmlsec/xmlsec.h
index f7c4a20d..ad44918b 100644
--- a/include/xmlsec/xmlsec.h
+++ b/include/xmlsec/xmlsec.h
@@ -1,19 +1,19 @@
-/**
+/**
* XML Security Library (http://www.aleksey.com/xmlsec).
*
* General functions and forward declarations.
*
* This is free software; see Copyright file in the source
* distribution for preciese wording.
- *
+ *
* Copyright (C) 2002-2003 Aleksey Sanin <aleksey@aleksey.com>
*/
#ifndef __XMLSEC_H__
-#define __XMLSEC_H__
+#define __XMLSEC_H__
#ifdef __cplusplus
extern "C" {
-#endif /* __cplusplus */
+#endif /* __cplusplus */
#include <libxml/tree.h>
@@ -31,7 +31,7 @@ extern "C" {
*
* Void pointer.
*/
-typedef void* xmlSecPtr;
+typedef void* xmlSecPtr;
/**
* xmlSecSize:
@@ -40,47 +40,55 @@ typedef void* xmlSecPtr;
* but it will break ABI (todo).
*/
#ifdef XMLSEC_NO_SIZE_T
-#define xmlSecSize unsigned int
+#define xmlSecSize unsigned int
#else /* XMLSEC_NO_SIZE_T */
-#define xmlSecSize size_t
+#define xmlSecSize size_t
#endif /* XMLSEC_NO_SIZE_T */
/**
+ * XMLSEC_SIZE_BAD_CAST:
+ * @val: the value to cast
+ *
+ * Bad cast to xmlSecSize
+ */
+#define XMLSEC_SIZE_BAD_CAST(val) ((xmlSecSize)(val))
+
+/**
* xmlSecByte:
*
* One byte. Should be typedef instead of define
* but it will break ABI (todo).
*/
-#define xmlSecByte unsigned char
+#define xmlSecByte unsigned char
/***********************************************************************
*
* Forward declarations
*
***********************************************************************/
-typedef struct _xmlSecKeyData xmlSecKeyData, *xmlSecKeyDataPtr;
-typedef struct _xmlSecKeyDataStore xmlSecKeyDataStore, *xmlSecKeyDataStorePtr;
-typedef struct _xmlSecKeyInfoCtx xmlSecKeyInfoCtx, *xmlSecKeyInfoCtxPtr;
-typedef struct _xmlSecKey xmlSecKey, *xmlSecKeyPtr;
-typedef struct _xmlSecKeyStore xmlSecKeyStore, *xmlSecKeyStorePtr;
-typedef struct _xmlSecKeysMngr xmlSecKeysMngr, *xmlSecKeysMngrPtr;
-typedef struct _xmlSecTransform xmlSecTransform, *xmlSecTransformPtr;
-typedef struct _xmlSecTransformCtx xmlSecTransformCtx, *xmlSecTransformCtxPtr;
+typedef struct _xmlSecKeyData xmlSecKeyData, *xmlSecKeyDataPtr;
+typedef struct _xmlSecKeyDataStore xmlSecKeyDataStore, *xmlSecKeyDataStorePtr;
+typedef struct _xmlSecKeyInfoCtx xmlSecKeyInfoCtx, *xmlSecKeyInfoCtxPtr;
+typedef struct _xmlSecKey xmlSecKey, *xmlSecKeyPtr;
+typedef struct _xmlSecKeyStore xmlSecKeyStore, *xmlSecKeyStorePtr;
+typedef struct _xmlSecKeysMngr xmlSecKeysMngr, *xmlSecKeysMngrPtr;
+typedef struct _xmlSecTransform xmlSecTransform, *xmlSecTransformPtr;
+typedef struct _xmlSecTransformCtx xmlSecTransformCtx, *xmlSecTransformCtxPtr;
#ifndef XMLSEC_NO_XMLDSIG
-typedef struct _xmlSecDSigCtx xmlSecDSigCtx, *xmlSecDSigCtxPtr;
+typedef struct _xmlSecDSigCtx xmlSecDSigCtx, *xmlSecDSigCtxPtr;
#endif /* XMLSEC_NO_XMLDSIG */
#ifndef XMLSEC_NO_XMLENC
-typedef struct _xmlSecEncCtx xmlSecEncCtx, *xmlSecEncCtxPtr;
+typedef struct _xmlSecEncCtx xmlSecEncCtx, *xmlSecEncCtxPtr;
#endif /* XMLSEC_NO_XMLENC */
#ifndef XMLSEC_NO_XKMS
-typedef struct _xmlSecXkmsServerCtx xmlSecXkmsServerCtx, *xmlSecXkmsServerCtxPtr;
+typedef struct _xmlSecXkmsServerCtx xmlSecXkmsServerCtx, *xmlSecXkmsServerCtxPtr;
#endif /* XMLSEC_NO_XKMS */
-XMLSEC_EXPORT int xmlSecInit (void);
-XMLSEC_EXPORT int xmlSecShutdown (void);
+XMLSEC_EXPORT int xmlSecInit (void);
+XMLSEC_EXPORT int xmlSecShutdown (void);
@@ -89,30 +97,30 @@ XMLSEC_EXPORT int xmlSecShutdown (void);
* Version checking
*
***********************************************************************/
-/**
+/**
* xmlSecCheckVersionExact:
*
- * Macro. Returns 1 if the loaded xmlsec 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 or a negative
* value if an error occurs.
*/
-#define xmlSecCheckVersionExact() \
+#define xmlSecCheckVersionExact() \
xmlSecCheckVersionExt(XMLSEC_VERSION_MAJOR, XMLSEC_VERSION_MINOR, XMLSEC_VERSION_SUBMINOR, xmlSecCheckVersionExactMatch)
-/**
+/**
* xmlSecCheckVersion:
*
* Macro. Returns 1 if the loaded xmlsec library version ABI compatible with
* the one used to compile the caller, 0 if it does not or a negative
* value if an error occurs.
*/
-#define xmlSecCheckVersion() \
+#define xmlSecCheckVersion() \
xmlSecCheckVersionExt(XMLSEC_VERSION_MAJOR, XMLSEC_VERSION_MINOR, XMLSEC_VERSION_SUBMINOR, xmlSecCheckVersionABICompatible)
/**
* xmlSecCheckVersionMode:
- * @xmlSecCheckVersionExactMatch: the version should match exactly.
- * @xmlSecCheckVersionABICompatible: the version should be ABI compatible.
+ * @xmlSecCheckVersionExactMatch: the version should match exactly.
+ * @xmlSecCheckVersionABICompatible: the version should be ABI compatible.
*
* The xmlsec library version mode.
*/
@@ -121,10 +129,10 @@ typedef enum {
xmlSecCheckVersionABICompatible
} xmlSecCheckVersionMode;
-XMLSEC_EXPORT int xmlSecCheckVersionExt (int major,
- int minor,
- int subminor,
- xmlSecCheckVersionMode mode);
+XMLSEC_EXPORT int xmlSecCheckVersionExt (int major,
+ int minor,
+ int subminor,
+ xmlSecCheckVersionMode mode);
/**
* ATTRIBUTE_UNUSED:
@@ -142,6 +150,63 @@ XMLSEC_EXPORT int xmlSecCheckVersionExt (int major,
#define ATTRIBUTE_UNUSED
#endif
+/***********************************************************************
+ *
+ * Helpers to convert from void* to function pointer, this silence
+ * gcc warning
+ *
+ * warning: ISO C forbids conversion of object pointer to function
+ * pointer type
+ *
+ * The workaround is to declare a union that does the conversion. This is
+ * guaranteed (ISO/IEC 9899:1990 "C89"/"C90") to match exactly.
+ *
+ ***********************************************************************/
+
+/**
+ * XMLSEC_PTR_TO_FUNC_IMPL:
+ * @func_type: the function type.
+ *
+ * Macro declares helper functions to convert between "void *" pointer and
+ * function pointer.
+ */
+#define XMLSEC_PTR_TO_FUNC_IMPL(func_type) \
+ union xmlSecPtrToFuncUnion_ ##func_type { \
+ void *ptr; \
+ func_type * func; \
+ } ; \
+ static func_type * xmlSecPtrToFunc_ ##func_type(void * ptr) { \
+ union xmlSecPtrToFuncUnion_ ##func_type x; \
+ x.ptr = ptr; \
+ return (x.func); \
+ } \
+ static void * xmlSecFuncToPtr_ ##func_type(func_type * func) { \
+ union xmlSecPtrToFuncUnion_ ##func_type x; \
+ x.func = func; \
+ return (x.ptr); \
+ }
+
+/**
+ * XMLSEC_PTR_TO_FUNC:
+ * @func_type: the function type.
+ * @ptr: the "void*" pointer to be converted.
+ *
+ * Macro converts from "void*" pointer to "func_type" function pointer.
+ */
+#define XMLSEC_PTR_TO_FUNC(func_type, ptr) \
+ xmlSecPtrToFunc_ ##func_type((ptr))
+
+/**
+ * XMLSEC_FUNC_TO_PTR:
+ * @func_type: the function type.
+ * @func: the "func_type" function pointer to be converted.
+ *
+ * Macro converts from "func_type" function pointer to "void*" pointer.
+ */
+#define XMLSEC_FUNC_TO_PTR(func_type, func) \
+ xmlSecFuncToPtr_ ##func_type((func))
+
+
#ifdef __cplusplus
}
#endif /* __cplusplus */