df702f5c491f715fc0aa1a3b79e2dda7c8283eda
[ric-plt/resource-status-manager.git] / RSM / 3rdparty / asn1codec / e2ap_engine / xer_encoder.h
1
2 /*-
3  * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
4  * Redistribution and modifications are permitted subject to BSD license.
5  */
6 #ifndef _XER_ENCODER_H_
7 #define _XER_ENCODER_H_
8
9 #include <asn_application.h>
10
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14
15 struct asn_TYPE_descriptor_s;   /* Forward declaration */
16
17 /* Flags used by the xer_encode() and (*xer_type_encoder_f), defined below */
18 enum xer_encoder_flags_e {
19         /* Mode of encoding */
20         XER_F_BASIC     = 0x01, /* BASIC-XER (pretty-printing) */
21         XER_F_CANONICAL = 0x02  /* Canonical XER (strict rules) */
22 };
23
24 /*
25  * The XER encoder of any type. May be invoked by the application.
26  * Produces CANONICAL-XER and BASIC-XER depending on the (xer_flags).
27  */
28 asn_enc_rval_t xer_encode(const struct asn_TYPE_descriptor_s *type_descriptor,
29                           const void *struct_ptr, /* Structure to be encoded */
30                           enum xer_encoder_flags_e xer_flags,
31                           asn_app_consume_bytes_f *consume_bytes_cb,
32                           void *app_key /* Arbitrary callback argument */
33 );
34
35 /*
36  * The variant of the above function which dumps the BASIC-XER (XER_F_BASIC)
37  * output into the chosen file pointer.
38  * RETURN VALUES:
39  *       0: The structure is printed.
40  *      -1: Problem printing the structure.
41  * WARNING: No sensible errno value is returned.
42  */
43 int xer_fprint(FILE *stream, const struct asn_TYPE_descriptor_s *td,
44                const void *struct_ptr);
45
46 /*
47  * A helper function that uses XER encoding/decoding to verify that:
48  * - Both structures encode into the same BASIC XER.
49  * - Both resulting XER byte streams can be decoded back.
50  * - Both decoded structures encode into the same BASIC XER (round-trip).
51  * All of this verifies equivalence between structures and a round-trip.
52  * ARGUMENTS:
53  *  (opt_debug_stream)  - If specified, prints ongoing details.
54  */
55 enum xer_equivalence_e {
56     XEQ_SUCCESS,          /* The only completely positive return value */
57     XEQ_FAILURE,          /* General failure */
58     XEQ_ENCODE1_FAILED,   /* First sructure XER encoding failed */
59     XEQ_ENCODE2_FAILED,   /* Second structure XER encoding failed */
60     XEQ_DIFFERENT,        /* Structures encoded into different XER */
61     XEQ_DECODE_FAILED,    /* Decode of the XER data failed */
62     XEQ_ROUND_TRIP_FAILED /* Bad round-trip */
63 };
64 enum xer_equivalence_e xer_equivalent(
65     const struct asn_TYPE_descriptor_s *type_descriptor, const void *struct1,
66     const void *struct2, FILE *opt_debug_stream);
67
68 /*
69  * Type of the generic XER encoder.
70  */
71 typedef asn_enc_rval_t(xer_type_encoder_f)(
72     const struct asn_TYPE_descriptor_s *type_descriptor,
73     const void *struct_ptr, /* Structure to be encoded */
74     int ilevel,             /* Level of indentation */
75     enum xer_encoder_flags_e xer_flags,
76     asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
77     void *app_key                              /* Arbitrary callback argument */
78 );
79
80 #ifdef __cplusplus
81 }
82 #endif
83
84 #endif  /* _XER_ENCODER_H_ */