Updated INFO.yaml file
[ric-app/kpimon.git] / asn1c_defs / all-defs / asn_codecs.h
1 /*\r
2  * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.\r
3  * Redistribution and modifications are permitted subject to BSD license.\r
4  */\r
5 #ifndef ASN_CODECS_H\r
6 #define ASN_CODECS_H\r
7 \r
8 #ifdef __cplusplus\r
9 extern "C" {\r
10 #endif\r
11 \r
12 struct asn_TYPE_descriptor_s;   /* Forward declaration */\r
13 \r
14 /*\r
15  * This structure defines a set of parameters that may be passed\r
16  * to every ASN.1 encoder or decoder function.\r
17  * WARNING: if max_stack_size member is set, and you are calling the\r
18  *   function pointers of the asn_TYPE_descriptor_t directly,\r
19  *   this structure must be ALLOCATED ON THE STACK!\r
20  *   If you can't always satisfy this requirement, use ber_decode(),\r
21  *   xer_decode() and uper_decode() functions instead.\r
22  */\r
23 typedef struct asn_codec_ctx_s {\r
24         /*\r
25          * Limit the decoder routines to use no (much) more stack than a given\r
26          * number of bytes. Most of decoders are stack-based, and this\r
27          * would protect against stack overflows if the number of nested\r
28          * encodings is high.\r
29          * The OCTET STRING, BIT STRING and ANY BER decoders are heap-based,\r
30          * and are safe from this kind of overflow.\r
31          * A value from getrlimit(RLIMIT_STACK) may be used to initialize\r
32          * this variable. Be careful in multithreaded environments, as the\r
33          * stack size is rather limited.\r
34          */\r
35         size_t  max_stack_size; /* 0 disables stack bounds checking */\r
36 } asn_codec_ctx_t;\r
37 \r
38 /*\r
39  * Type of the return value of the encoding functions (der_encode, xer_encode).\r
40  */\r
41 typedef struct asn_enc_rval_s {\r
42         /*\r
43          * Number of bytes encoded.\r
44          * -1 indicates failure to encode the structure.\r
45          * In this case, the members below this one are meaningful.\r
46          */\r
47         ssize_t encoded;\r
48 \r
49         /*\r
50          * Members meaningful when (encoded == -1), for post mortem analysis.\r
51          */\r
52 \r
53         /* Type which cannot be encoded */\r
54         const struct asn_TYPE_descriptor_s *failed_type;\r
55 \r
56         /* Pointer to the structure of that type */\r
57         const void *structure_ptr;\r
58 } asn_enc_rval_t;\r
59 #define ASN__ENCODE_FAILED do {                                 \\r
60         asn_enc_rval_t tmp_error;                               \\r
61         tmp_error.encoded = -1;                                 \\r
62         tmp_error.failed_type = td;                             \\r
63         tmp_error.structure_ptr = sptr;                         \\r
64         ASN_DEBUG("Failed to encode element %s", td ? td->name : "");   \\r
65         return tmp_error;                                       \\r
66 } while(0)\r
67 #define ASN__ENCODED_OK(rval) do {                              \\r
68         rval.structure_ptr = 0;                                 \\r
69         rval.failed_type = 0;                                   \\r
70         return rval;                                            \\r
71 } while(0)\r
72 \r
73 /*\r
74  * Type of the return value of the decoding functions (ber_decode, xer_decode)\r
75  * \r
76  * Please note that the number of consumed bytes is ALWAYS meaningful,\r
77  * even if code==RC_FAIL. This is to indicate the number of successfully\r
78  * decoded bytes, hence providing a possibility to fail with more diagnostics\r
79  * (i.e., print the offending remainder of the buffer).\r
80  */\r
81 enum asn_dec_rval_code_e {\r
82         RC_OK,          /* Decoded successfully */\r
83         RC_WMORE,       /* More data expected, call again */\r
84         RC_FAIL         /* Failure to decode data */\r
85 };\r
86 typedef struct asn_dec_rval_s {\r
87         enum asn_dec_rval_code_e code;  /* Result code */\r
88         size_t consumed;                /* Number of bytes consumed */\r
89 } asn_dec_rval_t;\r
90 #define ASN__DECODE_FAILED do {                                 \\r
91         asn_dec_rval_t tmp_error;                               \\r
92         tmp_error.code = RC_FAIL;                               \\r
93         tmp_error.consumed = 0;                                 \\r
94         ASN_DEBUG("Failed to decode element %s", td ? td->name : "");   \\r
95         return tmp_error;                                       \\r
96 } while(0)\r
97 #define ASN__DECODE_STARVED do {                                \\r
98         asn_dec_rval_t tmp_error;                               \\r
99         tmp_error.code = RC_WMORE;                              \\r
100         tmp_error.consumed = 0;                                 \\r
101         return tmp_error;                                       \\r
102 } while(0)\r
103 \r
104 #ifdef __cplusplus\r
105 }\r
106 #endif\r
107 \r
108 #endif  /* ASN_CODECS_H */\r