8a5fc584834a0460ed3ba3552be896aa4b7517dd
[ric-app/kpimon.git] / asn1c_defs / all-defs / xer_encoder.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_ENCODER_H_\r
6 #define _XER_ENCODER_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 /* Flags used by the xer_encode() and (*xer_type_encoder_f), defined below */\r
17 enum xer_encoder_flags_e {\r
18         /* Mode of encoding */\r
19         XER_F_BASIC     = 0x01, /* BASIC-XER (pretty-printing) */\r
20         XER_F_CANONICAL = 0x02  /* Canonical XER (strict rules) */\r
21 };\r
22 \r
23 /*\r
24  * The XER encoder of any type. May be invoked by the application.\r
25  * Produces CANONICAL-XER and BASIC-XER depending on the (xer_flags).\r
26  */\r
27 asn_enc_rval_t xer_encode(const struct asn_TYPE_descriptor_s *type_descriptor,\r
28                           const void *struct_ptr, /* Structure to be encoded */\r
29                           enum xer_encoder_flags_e xer_flags,\r
30                           asn_app_consume_bytes_f *consume_bytes_cb,\r
31                           void *app_key /* Arbitrary callback argument */\r
32 );\r
33 \r
34 /*\r
35  * The variant of the above function which dumps the BASIC-XER (XER_F_BASIC)\r
36  * output into the chosen file pointer.\r
37  * RETURN VALUES:\r
38  *       0: The structure is printed.\r
39  *      -1: Problem printing the structure.\r
40  * WARNING: No sensible errno value is returned.\r
41  */\r
42 int xer_fprint(FILE *stream, const struct asn_TYPE_descriptor_s *td,\r
43                const void *struct_ptr);\r
44 \r
45 /*\r
46  * A helper function that uses XER encoding/decoding to verify that:\r
47  * - Both structures encode into the same BASIC XER.\r
48  * - Both resulting XER byte streams can be decoded back.\r
49  * - Both decoded structures encode into the same BASIC XER (round-trip).\r
50  * All of this verifies equivalence between structures and a round-trip.\r
51  * ARGUMENTS:\r
52  *  (opt_debug_stream)  - If specified, prints ongoing details.\r
53  */\r
54 enum xer_equivalence_e {\r
55     XEQ_SUCCESS,          /* The only completely positive return value */\r
56     XEQ_FAILURE,          /* General failure */\r
57     XEQ_ENCODE1_FAILED,   /* First sructure XER encoding failed */\r
58     XEQ_ENCODE2_FAILED,   /* Second structure XER encoding failed */\r
59     XEQ_DIFFERENT,        /* Structures encoded into different XER */\r
60     XEQ_DECODE_FAILED,    /* Decode of the XER data failed */\r
61     XEQ_ROUND_TRIP_FAILED /* Bad round-trip */\r
62 };\r
63 enum xer_equivalence_e xer_equivalent(\r
64     const struct asn_TYPE_descriptor_s *type_descriptor, const void *struct1,\r
65     const void *struct2, FILE *opt_debug_stream);\r
66 \r
67 /*\r
68  * Type of the generic XER encoder.\r
69  */\r
70 typedef asn_enc_rval_t(xer_type_encoder_f)(\r
71     const struct asn_TYPE_descriptor_s *type_descriptor,\r
72     const void *struct_ptr, /* Structure to be encoded */\r
73     int ilevel,             /* Level of indentation */\r
74     enum xer_encoder_flags_e xer_flags,\r
75     asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */\r
76     void *app_key                              /* Arbitrary callback argument */\r
77 );\r
78 \r
79 #ifdef __cplusplus\r
80 }\r
81 #endif\r
82 \r
83 #endif  /* _XER_ENCODER_H_ */\r