143a21f0dd50c8ec157dc2bb8113b36dbabf28c9
[ric-app/kpimon.git] / asn1c_defs / all-defs / xer_decoder.h
1 /*-\r
2  * Copyright (c) 2004-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 _XER_DECODER_H_\r
6 #define _XER_DECODER_H_\r
7 \r
8 #include <asn_application.h>\r
9 \r
10 #ifdef __cplusplus\r
11 extern "C" {\r
12 #endif\r
13 \r
14 struct asn_TYPE_descriptor_s;   /* Forward declaration */\r
15 \r
16 /*\r
17  * The XER decoder of any ASN.1 type. May be invoked by the application.\r
18  * Decodes CANONICAL-XER and BASIC-XER.\r
19  */\r
20 asn_dec_rval_t xer_decode(\r
21     const struct asn_codec_ctx_s *opt_codec_ctx,\r
22     const struct asn_TYPE_descriptor_s *type_descriptor,\r
23     void **struct_ptr,  /* Pointer to a target structure's pointer */\r
24     const void *buffer, /* Data to be decoded */\r
25     size_t size         /* Size of data buffer */\r
26 );\r
27 \r
28 /*\r
29  * Type of the type-specific XER decoder function.\r
30  */\r
31 typedef asn_dec_rval_t(xer_type_decoder_f)(\r
32     const asn_codec_ctx_t *opt_codec_ctx,\r
33     const struct asn_TYPE_descriptor_s *type_descriptor, void **struct_ptr,\r
34     const char *opt_mname, /* Member name */\r
35     const void *buf_ptr, size_t size);\r
36 \r
37 /*******************************\r
38  * INTERNALLY USEFUL FUNCTIONS *\r
39  *******************************/\r
40 \r
41 /*\r
42  * Generalized function for decoding the primitive values.\r
43  * Used by more specialized functions, such as OCTET_STRING_decode_xer_utf8\r
44  * and others. This function should not be used by applications, as its API\r
45  * is subject to changes.\r
46  */\r
47 asn_dec_rval_t xer_decode_general(\r
48     const asn_codec_ctx_t *opt_codec_ctx,\r
49     asn_struct_ctx_t *ctx, /* Type decoder context */\r
50     void *struct_key,      /* Treated as opaque pointer */\r
51     const char *xml_tag,   /* Expected XML tag name */\r
52     const void *buf_ptr, size_t size,\r
53     int (*opt_unexpected_tag_decoder)(void *struct_key, const void *chunk_buf,\r
54                                       size_t chunk_size),\r
55     ssize_t (*body_receiver)(void *struct_key, const void *chunk_buf,\r
56                              size_t chunk_size, int have_more));\r
57 \r
58 \r
59 /*\r
60  * Fetch the next XER (XML) token from the stream.\r
61  * The function returns the number of bytes occupied by the chunk type,\r
62  * returned in the _ch_type. The _ch_type is only set (and valid) when\r
63  * the return value is >= 0.\r
64  */\r
65   typedef enum pxer_chunk_type {\r
66         PXER_WMORE,     /* Chunk type is not clear, more data expected. */\r
67         PXER_TAG,           /* Complete XER tag */\r
68         PXER_TEXT,          /* Plain text between XER tags */\r
69         PXER_COMMENT    /* A comment, may be part of */\r
70   } pxer_chunk_type_e;\r
71 ssize_t xer_next_token(int *stateContext,\r
72         const void *buffer, size_t size, pxer_chunk_type_e *_ch_type);\r
73 \r
74 /*\r
75  * This function checks the buffer against the tag name is expected to occur.\r
76  */\r
77   typedef enum xer_check_tag {\r
78         XCT_BROKEN      = 0,    /* The tag is broken */\r
79         XCT_OPENING     = 1,    /* This is the <opening> tag */\r
80         XCT_CLOSING     = 2,    /* This is the </closing> tag */\r
81         XCT_BOTH        = 3,    /* This is the <modified/> tag */\r
82         XCT__UNK__MASK  = 4,    /* Mask of everything unexpected */\r
83         XCT_UNKNOWN_OP  = 5,    /* Unexpected <opening> tag */\r
84         XCT_UNKNOWN_CL  = 6,    /* Unexpected </closing> tag */\r
85         XCT_UNKNOWN_BO  = 7     /* Unexpected <modified/> tag */\r
86   } xer_check_tag_e;\r
87 xer_check_tag_e xer_check_tag(const void *buf_ptr, int size,\r
88                 const char *need_tag);\r
89 \r
90 /*\r
91  * Get the number of bytes consisting entirely of XER whitespace characters.\r
92  * RETURN VALUES:\r
93  * >=0: Number of whitespace characters in the string.\r
94  */\r
95 size_t xer_whitespace_span(const void *chunk_buf, size_t chunk_size);\r
96 \r
97 /*\r
98  * Skip the series of anticipated extensions.\r
99  */\r
100 int xer_skip_unknown(xer_check_tag_e tcv, ber_tlv_len_t *depth);\r
101 \r
102 #ifdef __cplusplus\r
103 }\r
104 #endif\r
105 \r
106 #endif  /* _XER_DECODER_H_ */\r