1 /*
2  * XML Security Library (http://www.aleksey.com/xmlsec).
3  *
4  * General functions and forward declarations.
5  *
6  * This is free software; see Copyright file in the source
7  * distribution for preciese wording.
8  *
9  * Copyright (C) 2002-2016 Aleksey Sanin <aleksey@aleksey.com>. All Rights Reserved.
10  */
11 #ifndef __XMLSEC_H__
12 #define __XMLSEC_H__
13 
14 #include <libxml/tree.h>
15 
16 #include <xmlsec/version.h>
17 #include <xmlsec/exports.h>
18 #include <xmlsec/strings.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif /* __cplusplus */
23 
24 /***********************************************************************
25  *
26  * Basic types to make ports to exotic platforms easier
27  *
28  ***********************************************************************/
29 /**
30  * xmlSecPtr:
31  *
32  * Void pointer.
33  */
34 typedef void*                                   xmlSecPtr;
35 
36 /**
37  * xmlSecSize:
38  *
39  * Size of something. Should be typedef instead of define
40  * but it will break ABI (todo).
41  */
42 #ifdef XMLSEC_NO_SIZE_T
43 #define xmlSecSize                              unsigned int
44 #else  /* XMLSEC_NO_SIZE_T */
45 #define xmlSecSize                              size_t
46 #endif /* XMLSEC_NO_SIZE_T */
47 
48 /**
49  * XMLSEC_SIZE_BAD_CAST:
50  * @val:        the value to cast
51  *
52  * Bad cast to xmlSecSize
53  */
54 #define XMLSEC_SIZE_BAD_CAST(val)               ((xmlSecSize)(val))
55 
56 /**
57  * xmlSecByte:
58  *
59  * One byte. Should be typedef instead of define
60  * but it will break ABI (todo).
61  */
62 #define xmlSecByte                              unsigned char
63 
64 /***********************************************************************
65  *
66  * Forward declarations
67  *
68  ***********************************************************************/
69 typedef struct _xmlSecKeyData                   xmlSecKeyData, *xmlSecKeyDataPtr;
70 typedef struct _xmlSecKeyDataStore              xmlSecKeyDataStore, *xmlSecKeyDataStorePtr;
71 typedef struct _xmlSecKeyInfoCtx                xmlSecKeyInfoCtx, *xmlSecKeyInfoCtxPtr;
72 typedef struct _xmlSecKey                       xmlSecKey, *xmlSecKeyPtr;
73 typedef struct _xmlSecKeyStore                  xmlSecKeyStore, *xmlSecKeyStorePtr;
74 typedef struct _xmlSecKeysMngr                  xmlSecKeysMngr, *xmlSecKeysMngrPtr;
75 typedef struct _xmlSecTransform                 xmlSecTransform, *xmlSecTransformPtr;
76 typedef struct _xmlSecTransformCtx              xmlSecTransformCtx, *xmlSecTransformCtxPtr;
77 
78 #ifndef XMLSEC_NO_XMLDSIG
79 typedef struct _xmlSecDSigCtx                   xmlSecDSigCtx, *xmlSecDSigCtxPtr;
80 #endif /* XMLSEC_NO_XMLDSIG */
81 
82 #ifndef XMLSEC_NO_XMLENC
83 typedef struct _xmlSecEncCtx                    xmlSecEncCtx, *xmlSecEncCtxPtr;
84 #endif /* XMLSEC_NO_XMLENC */
85 
86 XMLSEC_EXPORT int                               xmlSecInit              (void);
87 XMLSEC_EXPORT int                               xmlSecShutdown          (void);
88 XMLSEC_EXPORT const xmlChar *                   xmlSecGetDefaultCrypto  (void);
89 XMLSEC_EXPORT void                              xmlSecSetExternalEntityLoader (xmlExternalEntityLoader);
90 
91 /**
92  * XMLSEC_CRYPTO:
93  *
94  * Macro. Deprecated. Defined for backward compatibility only. Do not use
95  * in your code and use xmlSecGetDefaultCrypto() function instead.
96  *
97  * Returns the default crypto engine.
98  */
99 #define XMLSEC_CRYPTO                          (xmlSecGetDefaultCrypto())
100 
101 /*
102  * XMLSEC_DEPRECATED function definition
103  */
104 #if !defined(IN_XMLSEC)
105 #ifdef __GNUC__
106 #define XMLSEC_DEPRECATED __attribute__((deprecated))
107 #elif defined(_MSC_VER)
108 #define XMLSEC_DEPRECATED __declspec(deprecated)
109 #else /* defined(_MSC_VER) */
110 #pragma message("WARNING: You need to implement XMLSEC_DEPRECATED for this compiler")
111 #define XMLSEC_DEPRECATED
112 #endif /* defined(_MSC_VER) */
113 #else  /* !defined(IN_XMLSEC) */
114 #define XMLSEC_DEPRECATED
115 #endif /* !defined(IN_XMLSEC) */
116 
117 /***********************************************************************
118  *
119  * Version checking
120  *
121  ***********************************************************************/
122 /**
123  * xmlSecCheckVersionExact:
124  *
125  * Macro. Returns 1 if the loaded xmlsec library version exactly matches
126  * the one used to compile the caller, 0 if it does not or a negative
127  * value if an error occurs.
128  */
129 #define xmlSecCheckVersionExact()       \
130     xmlSecCheckVersionExt(XMLSEC_VERSION_MAJOR, XMLSEC_VERSION_MINOR, XMLSEC_VERSION_SUBMINOR, xmlSecCheckVersionExactMatch)
131 
132 /**
133  * xmlSecCheckVersion:
134  *
135  * Macro. Returns 1 if the loaded xmlsec library version ABI compatible with
136  * the one used to compile the caller, 0 if it does not or a negative
137  * value if an error occurs.
138  */
139 #define xmlSecCheckVersion()    \
140     xmlSecCheckVersionExt(XMLSEC_VERSION_MAJOR, XMLSEC_VERSION_MINOR, XMLSEC_VERSION_SUBMINOR, xmlSecCheckVersionABICompatible)
141 
142 /**
143  * xmlSecCheckVersionMode:
144  * @xmlSecCheckVersionExactMatch:       the version should match exactly.
145  * @xmlSecCheckVersionABICompatible:    the version should be ABI compatible.
146  *
147  * The xmlsec library version mode.
148  */
149 typedef enum {
150     xmlSecCheckVersionExactMatch = 0,
151     xmlSecCheckVersionABICompatible
152 } xmlSecCheckVersionMode;
153 
154 XMLSEC_EXPORT int       xmlSecCheckVersionExt   (int major,
155                                                  int minor,
156                                                  int subminor,
157                                                  xmlSecCheckVersionMode mode);
158 
159 #ifdef __cplusplus
160 }
161 #endif /* __cplusplus */
162 
163 #endif /* __XMLSEC_H__ */
164 
165 
166