1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
/**
* 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-2016 Aleksey Sanin <aleksey@aleksey.com>. All Rights Reserved.
*/
#ifndef __XMLSEC_H__
#define __XMLSEC_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <libxml/tree.h>
#include <xmlsec/version.h>
#include <xmlsec/exports.h>
#include <xmlsec/strings.h>
/***********************************************************************
*
* Basic types to make ports to exotic platforms easier
*
***********************************************************************/
/**
* xmlSecPtr:
*
* Void pointer.
*/
typedef void* xmlSecPtr;
/**
* xmlSecSize:
*
* Size of something. Should be typedef instead of define
* but it will break ABI (todo).
*/
#ifdef XMLSEC_NO_SIZE_T
#define xmlSecSize unsigned int
#else /* XMLSEC_NO_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
/***********************************************************************
*
* 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;
#ifndef XMLSEC_NO_XMLDSIG
typedef struct _xmlSecDSigCtx xmlSecDSigCtx, *xmlSecDSigCtxPtr;
#endif /* XMLSEC_NO_XMLDSIG */
#ifndef XMLSEC_NO_XMLENC
typedef struct _xmlSecEncCtx xmlSecEncCtx, *xmlSecEncCtxPtr;
#endif /* XMLSEC_NO_XMLENC */
XMLSEC_EXPORT int xmlSecInit (void);
XMLSEC_EXPORT int xmlSecShutdown (void);
XMLSEC_EXPORT const xmlChar * xmlSecGetDefaultCrypto (void);
/**
* XMLSEC_CRYPTO:
*
* Macro. Deprecated. Defined for backward compatibility only. Do not use
* in your code and use xmlSecGetDefaultCrypto() function instead.
*
* Returns the default crypto engine.
*/
#define XMLSEC_CRYPTO (xmlSecGetDefaultCrypto())
/***********************************************************************
*
* Version checking
*
***********************************************************************/
/**
* xmlSecCheckVersionExact:
*
* 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() \
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() \
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.
*
* The xmlsec library version mode.
*/
typedef enum {
xmlSecCheckVersionExactMatch = 0,
xmlSecCheckVersionABICompatible
} xmlSecCheckVersionMode;
XMLSEC_EXPORT int xmlSecCheckVersionExt (int major,
int minor,
int subminor,
xmlSecCheckVersionMode mode);
/**
* ATTRIBUTE_UNUSED:
*
* Macro used to signal to GCC unused function parameters
*/
#ifdef __GNUC__
#ifdef HAVE_ANSIDECL_H
#include <ansidecl.h>
#endif
#ifndef ATTRIBUTE_UNUSED
#define ATTRIBUTE_UNUSED
#endif
#else
#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 */
#endif /* __XMLSEC_H__ */
|