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
5 #ifndef _XER_ENCODER_H_
\r
6 #define _XER_ENCODER_H_
\r
8 #include <asn_application.h>
\r
14 struct asn_TYPE_descriptor_s; /* Forward declaration */
\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
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
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
35 * The variant of the above function which dumps the BASIC-XER (XER_F_BASIC)
\r
36 * output into the chosen file pointer.
\r
38 * 0: The structure is printed.
\r
39 * -1: Problem printing the structure.
\r
40 * WARNING: No sensible errno value is returned.
\r
42 int xer_fprint(FILE *stream, const struct asn_TYPE_descriptor_s *td,
\r
43 const void *struct_ptr);
\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
52 * (opt_debug_stream) - If specified, prints ongoing details.
\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
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
68 * Type of the generic XER encoder.
\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
83 #endif /* _XER_ENCODER_H_ */
\r