libmongocrypt
Loading...
Searching...
No Matches
mongo_crypt-v1.h
1
5// clang-format off
6
7#ifndef MONGO_CRYPT_SUPPORT_H
8#define MONGO_CRYPT_SUPPORT_H
9
10#include <stddef.h>
11#include <stdint.h>
12
13#pragma push_macro("MONGO_API_CALL")
14#undef MONGO_API_CALL
15
16#pragma push_macro("MONGO_API_IMPORT")
17#undef MONGO_API_IMPORT
18
19#pragma push_macro("MONGO_API_EXPORT")
20#undef MONGO_API_EXPORT
21
22#pragma push_macro("MONGO_CRYPT_SUPPORT_API")
23#undef MONGO_CRYPT_SUPPORT_API
24
25#if defined(_WIN32)
26#define MONGO_API_CALL __cdecl
27#define MONGO_API_IMPORT __declspec(dllimport)
28#define MONGO_API_EXPORT __declspec(dllexport)
29#else
30#define MONGO_API_CALL
31#define MONGO_API_IMPORT __attribute__((visibility("default")))
32#define MONGO_API_EXPORT __attribute__((used, visibility("default")))
33#endif
34
35#if defined(MONGO_CRYPT_SUPPORT_STATIC)
36#define MONGO_CRYPT_API
37#else
38#if defined(MONGO_CRYPT_SUPPORT_COMPILING)
39#define MONGO_CRYPT_API MONGO_API_EXPORT
40#else
41#define MONGO_CRYPT_API MONGO_API_IMPORT
42#endif
43#endif
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
71typedef struct mongo_crypt_v1_status mongo_crypt_v1_status;
72
80MONGO_CRYPT_API mongo_crypt_v1_status* MONGO_API_CALL mongo_crypt_v1_status_create(void);
81
99MONGO_CRYPT_API void MONGO_API_CALL mongo_crypt_v1_status_destroy(mongo_crypt_v1_status* status);
100
109typedef enum {
110 MONGO_CRYPT_V1_ERROR_IN_REPORTING_ERROR = -2,
111 MONGO_CRYPT_V1_ERROR_UNKNOWN = -1,
112
113 MONGO_CRYPT_V1_SUCCESS = 0,
114
115 MONGO_CRYPT_V1_ERROR_ENOMEM = 1,
116 MONGO_CRYPT_V1_ERROR_EXCEPTION = 2,
117 MONGO_CRYPT_V1_ERROR_LIBRARY_ALREADY_INITIALIZED = 3,
118 MONGO_CRYPT_V1_ERROR_LIBRARY_NOT_INITIALIZED = 4,
119 MONGO_CRYPT_V1_ERROR_INVALID_LIB_HANDLE = 5,
120 MONGO_CRYPT_V1_ERROR_REENTRANCY_NOT_ALLOWED = 6,
121} mongo_crypt_v1_error;
122
135MONGO_CRYPT_API int MONGO_API_CALL
136mongo_crypt_v1_status_get_error(const mongo_crypt_v1_status* status);
137
152MONGO_CRYPT_API const char* MONGO_API_CALL
153mongo_crypt_v1_status_get_explanation(const mongo_crypt_v1_status* status);
154
166MONGO_CRYPT_API int MONGO_API_CALL
167mongo_crypt_v1_status_get_code(const mongo_crypt_v1_status* status);
168
182typedef struct mongo_crypt_v1_lib mongo_crypt_v1_lib;
183
190MONGO_CRYPT_API mongo_crypt_v1_lib* MONGO_API_CALL
191mongo_crypt_v1_lib_create(mongo_crypt_v1_status* status);
192
208MONGO_CRYPT_API int MONGO_API_CALL mongo_crypt_v1_lib_destroy(mongo_crypt_v1_lib* lib,
209 mongo_crypt_v1_status* status);
210
211
223MONGO_CRYPT_API uint64_t MONGO_API_CALL mongo_crypt_v1_get_version(void);
224
232MONGO_CRYPT_API const char* MONGO_API_CALL mongo_crypt_v1_get_version_str(void);
233
234
245typedef struct mongo_crypt_v1_query_analyzer mongo_crypt_v1_query_analyzer;
246
254MONGO_CRYPT_API mongo_crypt_v1_query_analyzer* MONGO_API_CALL
255mongo_crypt_v1_query_analyzer_create(mongo_crypt_v1_lib* lib, mongo_crypt_v1_status* status);
256
266MONGO_CRYPT_API void MONGO_API_CALL
267mongo_crypt_v1_query_analyzer_destroy(mongo_crypt_v1_query_analyzer* analyzer);
268
269
287MONGO_CRYPT_API uint8_t* MONGO_API_CALL
288mongo_crypt_v1_analyze_query(mongo_crypt_v1_query_analyzer* analyzer,
289 const uint8_t* documentBSON,
290 const char* ns_str,
291 uint32_t ns_len,
292 uint32_t* bson_len,
293 mongo_crypt_v1_status* status);
294
302MONGO_CRYPT_API void MONGO_API_CALL mongo_crypt_v1_bson_free(uint8_t* bson);
303
304#ifdef __cplusplus
305} // extern "C"
306#endif
307
308#undef MONGO_CRYPT_SUPPORT_API
309#pragma pop_macro("MONGO_CRYPT_SUPPORT_API")
310
311#undef MONGO_API_EXPORT
312#pragma push_macro("MONGO_API_EXPORT")
313
314#undef MONGO_API_IMPORT
315#pragma push_macro("MONGO_API_IMPORT")
316
317#undef MONGO_API_CALL
318#pragma pop_macro("MONGO_API_CALL")
319
320#endif // MONGO_CRYPT_SUPPORT_H