]> rtime.felk.cvut.cz Git - frescor/frsh.git/blob - fres/contract/fres_container_internal.h
Added handling of unknown contract blocks
[frescor/frsh.git] / fres / contract / fres_container_internal.h
1 /**
2  * @file   fres_container_internal.h
3  * @author Michal Sojka <sojkam1@fel.cvut.cz>
4  * 
5  * @brief  Internal interface to fres_container.
6  *
7  * This header should only be included by files in frsh/cm library.
8  * 
9  */
10 #ifndef FRES_CONTAINER_INTERNAL_H
11 #define FRES_CONTAINER_INTERNAL_H
12
13 #include <fres_contract_idl.h>
14
15 /** State of the block in container. */
16 enum fres_block_state {
17         /** There is no such block in the container. */
18         FRES_BLOCK_EMPTY,
19         /** The container contains the block in the deserialized
20          * form. */
21         FRES_BLOCK_DATA,
22         /** The container contains the block in the serialized form
23          * (sequence of octets).*/
24         FRES_BLOCK_STREAM
25 };
26
27 #define FRES_BLOCK_FLAG_ENDIAN_m 0x0001
28 #define FRES_BLOCK_LITTLE_ENDIAN 0x0001
29
30 /**< Unserialized (unknown) contracts blocks */
31 typedef struct fres_block_stream {
32         void *data; /**< Serialized data */
33         CORBA_unsigned_short flags; /**< Flags: bit 1 - little endian */
34         size_t length;              /**< Length of the stream */
35 } fres_block_stream_t;
36
37 struct fres_block {
38         enum fres_block_state state;
39         union {
40                 /** Pointer to data according to param_type
41                  * (state == FRES_BLOCK_DATA) */
42                 void *data;
43                 
44                 /** Unserialized (unknown) data
45                  * (state == FRES_BLOCK_STREAM) */
46                 fres_block_stream_t stream;
47         } u;
48 };
49
50 struct fres_container {
51         struct fres_block blocks[FRES_NUM_BLOCKS];
52 };
53
54 #define FRES_BLOCK_TYPE_VALID(type)     \
55         ((type) < FRES_NUM_BLOCKS &&    \
56          (type) >= 0)
57
58
59 #endif