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 | 21b41ac | 2005-07-24 09:03:44 +0000 | [diff] [blame] | 10 | #ifdef __cplusplus |
| 11 | extern "C" { |
| 12 | #endif |
| 13 | |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 14 | struct asn_TYPE_descriptor_s; /* Forward declaration */ |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 15 | |
| 16 | /* Flags used by the xer_encode() and (*xer_type_encoder_f), defined below */ |
| 17 | enum xer_encoder_flags_e { |
| 18 | /* Mode of encoding */ |
| 19 | XER_F_BASIC = 0x01, /* BASIC-XER (pretty-printing) */ |
Lev Walkin | 34ae9e3 | 2006-03-17 02:40:30 +0000 | [diff] [blame] | 20 | XER_F_CANONICAL = 0x02 /* Canonical XER (strict rules) */ |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 21 | }; |
| 22 | |
| 23 | /* |
| 24 | * The XER encoder of any type. May be invoked by the application. |
| 25 | */ |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 26 | 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] | 27 | void *struct_ptr, /* Structure to be encoded */ |
| 28 | enum xer_encoder_flags_e xer_flags, |
| 29 | asn_app_consume_bytes_f *consume_bytes_cb, |
| 30 | void *app_key /* Arbitrary callback argument */ |
| 31 | ); |
| 32 | |
| 33 | /* |
| 34 | * The variant of the above function which dumps the BASIC-XER (XER_F_BASIC) |
| 35 | * output into the chosen file pointer. |
| 36 | * RETURN VALUES: |
| 37 | * 0: The structure is printed. |
| 38 | * -1: Problem printing the structure. |
| 39 | * WARNING: No sensible errno value is returned. |
| 40 | */ |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 41 | 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] | 42 | |
| 43 | /* |
| 44 | * Type of the generic XER encoder. |
| 45 | */ |
| 46 | typedef asn_enc_rval_t (xer_type_encoder_f)( |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 47 | struct asn_TYPE_descriptor_s *type_descriptor, |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 48 | void *struct_ptr, /* Structure to be encoded */ |
| 49 | int ilevel, /* Level of indentation */ |
| 50 | enum xer_encoder_flags_e xer_flags, |
| 51 | asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */ |
| 52 | void *app_key /* Arbitrary callback argument */ |
| 53 | ); |
| 54 | |
Lev Walkin | 21b41ac | 2005-07-24 09:03:44 +0000 | [diff] [blame] | 55 | #ifdef __cplusplus |
| 56 | } |
| 57 | #endif |
| 58 | |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 59 | #endif /* _XER_ENCODER_H_ */ |