1 #pragma once
2 
3 #include "bej_tree.h"
4 
5 #include <stdlib.h>
6 
7 #ifdef __cplusplus
8 extern "C"
9 {
10 #endif
11 
12 #define BEJ_VERSION 0xF1F0F000
13 
14 /**
15  * @brief A struct for storing output information for the encoder.
16  */
17 struct BejEncoderOutputHandler
18 {
19     // A user provided context to be passed to the recvOutput() callback.
20     void* handlerContext;
21     // A callback function that will be invoked by the encoder whenever it
22     // has output data.
23     int (*recvOutput)(const void* data, size_t data_size, void* handlerContext);
24 };
25 
26 /**
27  * @brief Perform BEJ encoding.
28  *
29  * @param dictionaries - dictionaries used for encoding.
30  * @param majorSchemaStartingOffset - starting dictionary offset for
31  * endcoding. Use BEJ_DICTIONARY_START_AT_HEAD to encode a complete
32  * resource. Use the correct offset when encoding a subsection of a redfish
33  * resource.
34  * @param schemaClass - schema class for the resource.
35  * @param root - root node of the resource to be encoded. Root node has to
36  * be a bejSet.
37  * @param output - An intialized BejEncoderOutputHandler struct.
38  * @param stack - An initialized BejPointerStackCallback struct.
39  * @return 0 if successful.
40  */
41 int bejEncode(const struct BejDictionaries* dictionaries,
42               uint16_t majorSchemaStartingOffset,
43               enum BejSchemaClass schemaClass,
44               struct RedfishPropertyParent* root,
45               struct BejEncoderOutputHandler* output,
46               struct BejPointerStackCallback* stack);
47 
48 #ifdef __cplusplus
49 }
50 #endif
51