Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 1 | /*- |
| 2 | * Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved. |
| 3 | * Redistribution and modifications are permitted subject to BSD license. |
| 4 | */ |
| 5 | #ifndef _XER_ENCODER_H_ |
| 6 | #define _XER_ENCODER_H_ |
| 7 | |
Lev Walkin | 11c3e17 | 2004-09-24 21:00:50 +0000 | [diff] [blame] | 8 | #include <asn_application.h> |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 9 | |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 10 | struct asn_TYPE_descriptor_s; /* Forward declaration */ |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 11 | |
| 12 | /* Flags used by the xer_encode() and (*xer_type_encoder_f), defined below */ |
| 13 | enum xer_encoder_flags_e { |
| 14 | /* Mode of encoding */ |
| 15 | XER_F_BASIC = 0x01, /* BASIC-XER (pretty-printing) */ |
Lev Walkin | 8e8078a | 2004-09-26 13:10:40 +0000 | [diff] [blame] | 16 | XER_F_CANONICAL = 0x02 /* Canonical XER (strict rules, unreadable) */ |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 17 | }; |
| 18 | |
| 19 | /* |
| 20 | * The XER encoder of any type. May be invoked by the application. |
| 21 | */ |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 22 | asn_enc_rval_t xer_encode(struct asn_TYPE_descriptor_s *type_descriptor, |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 23 | void *struct_ptr, /* Structure to be encoded */ |
| 24 | enum xer_encoder_flags_e xer_flags, |
| 25 | asn_app_consume_bytes_f *consume_bytes_cb, |
| 26 | void *app_key /* Arbitrary callback argument */ |
| 27 | ); |
| 28 | |
| 29 | /* |
| 30 | * The variant of the above function which dumps the BASIC-XER (XER_F_BASIC) |
| 31 | * output into the chosen file pointer. |
| 32 | * RETURN VALUES: |
| 33 | * 0: The structure is printed. |
| 34 | * -1: Problem printing the structure. |
| 35 | * WARNING: No sensible errno value is returned. |
| 36 | */ |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 37 | int xer_fprint(FILE *stream, struct asn_TYPE_descriptor_s *td, void *sptr); |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 38 | |
| 39 | /* |
| 40 | * Type of the generic XER encoder. |
| 41 | */ |
| 42 | typedef asn_enc_rval_t (xer_type_encoder_f)( |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 43 | struct asn_TYPE_descriptor_s *type_descriptor, |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 44 | void *struct_ptr, /* Structure to be encoded */ |
| 45 | int ilevel, /* Level of indentation */ |
| 46 | enum xer_encoder_flags_e xer_flags, |
| 47 | asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */ |
| 48 | void *app_key /* Arbitrary callback argument */ |
| 49 | ); |
| 50 | |
| 51 | #endif /* _XER_ENCODER_H_ */ |