Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1 | /*- |
Lev Walkin | 59b176e | 2005-11-26 11:25:14 +0000 | [diff] [blame] | 2 | * Copyright (c) 2003, 2004, 2005 Lev Walkin <vlm@lionet.info>. |
| 3 | * All rights reserved. |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 4 | * Redistribution and modifications are permitted subject to BSD license. |
| 5 | */ |
| 6 | #ifndef _CONSTR_CHOICE_H_ |
| 7 | #define _CONSTR_CHOICE_H_ |
| 8 | |
Lev Walkin | 11c3e17 | 2004-09-24 21:00:50 +0000 | [diff] [blame] | 9 | #include <asn_application.h> |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 10 | |
Lev Walkin | 21b41ac | 2005-07-24 09:03:44 +0000 | [diff] [blame] | 11 | #ifdef __cplusplus |
| 12 | extern "C" { |
| 13 | #endif |
| 14 | |
Wim Lewis | fb6344e | 2014-07-28 12:16:01 -0700 | [diff] [blame] | 15 | typedef const struct asn_CHOICE_specifics_s { |
Bi-Ruei, Chiu | 1f87ac0 | 2017-08-20 01:25:45 +0800 | [diff] [blame] | 16 | /* |
| 17 | * Target structure description. |
| 18 | */ |
| 19 | unsigned struct_size; /* Size of the target structure. */ |
| 20 | unsigned ctx_offset; /* Offset of the asn_codec_ctx_t member */ |
| 21 | unsigned pres_offset; /* Identifier of the present member */ |
| 22 | unsigned pres_size; /* Size of the identifier (enum) */ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 23 | |
Bi-Ruei, Chiu | 1f87ac0 | 2017-08-20 01:25:45 +0800 | [diff] [blame] | 24 | /* |
| 25 | * Tags to members mapping table. |
| 26 | */ |
| 27 | const asn_TYPE_tag2member_t *tag2el; |
| 28 | unsigned tag2el_count; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 29 | |
Bi-Ruei, Chiu | 1f87ac0 | 2017-08-20 01:25:45 +0800 | [diff] [blame] | 30 | /* Canonical ordering of CHOICE elements, for PER */ |
| 31 | const unsigned *canonical_order; |
Lev Walkin | 59b176e | 2005-11-26 11:25:14 +0000 | [diff] [blame] | 32 | |
Bi-Ruei, Chiu | 1f87ac0 | 2017-08-20 01:25:45 +0800 | [diff] [blame] | 33 | /* |
| 34 | * Extensions-related stuff. |
| 35 | */ |
| 36 | signed ext_start; /* First member of extensions, or -1 */ |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 37 | } asn_CHOICE_specifics_t; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 38 | |
| 39 | /* |
| 40 | * A set specialized functions dealing with the CHOICE type. |
| 41 | */ |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 42 | asn_struct_free_f CHOICE_free; |
| 43 | asn_struct_print_f CHOICE_print; |
Lev Walkin | cd2f48e | 2017-08-10 02:14:59 -0700 | [diff] [blame] | 44 | asn_struct_compare_f CHOICE_compare; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 45 | asn_constr_check_f CHOICE_constraint; |
| 46 | ber_type_decoder_f CHOICE_decode_ber; |
| 47 | der_type_encoder_f CHOICE_encode_der; |
Lev Walkin | 8d01b4c | 2004-10-23 14:57:50 +0000 | [diff] [blame] | 48 | xer_type_decoder_f CHOICE_decode_xer; |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 49 | xer_type_encoder_f CHOICE_encode_xer; |
Lev Walkin | 9a1736d | 2017-08-27 23:46:34 -0700 | [diff] [blame] | 50 | oer_type_decoder_f CHOICE_decode_oer; |
| 51 | oer_type_encoder_f CHOICE_encode_oer; |
Lev Walkin | 59b176e | 2005-11-26 11:25:14 +0000 | [diff] [blame] | 52 | per_type_decoder_f CHOICE_decode_uper; |
Lev Walkin | 523de9e | 2006-08-18 01:34:18 +0000 | [diff] [blame] | 53 | per_type_encoder_f CHOICE_encode_uper; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 54 | asn_outmost_tag_f CHOICE_outmost_tag; |
Lev Walkin | a5972be | 2017-09-29 23:15:58 -0700 | [diff] [blame] | 55 | asn_random_fill_f CHOICE_random_fill; |
Bi-Ruei, Chiu | 1f87ac0 | 2017-08-20 01:25:45 +0800 | [diff] [blame] | 56 | extern asn_TYPE_operation_t asn_OP_CHOICE; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 57 | |
Lev Walkin | f6853ce | 2017-08-11 00:50:27 -0700 | [diff] [blame] | 58 | /* |
| 59 | * Return the 1-based choice variant presence index. |
| 60 | * Returns 0 in case of error. |
| 61 | */ |
| 62 | unsigned CHOICE_variant_get_presence(const asn_TYPE_descriptor_t *td, |
| 63 | const void *structure_ptr); |
| 64 | |
| 65 | /* |
| 66 | * Sets or resets the 1-based choice variant presence index. |
| 67 | * In case a previous index is not zero, the currently selected structure |
| 68 | * member is freed and zeroed-out first. |
| 69 | * Returns 0 on success and -1 on error. |
| 70 | */ |
| 71 | int CHOICE_variant_set_presence(const asn_TYPE_descriptor_t *td, |
| 72 | void *structure_ptr, unsigned present); |
| 73 | |
Lev Walkin | 21b41ac | 2005-07-24 09:03:44 +0000 | [diff] [blame] | 74 | #ifdef __cplusplus |
| 75 | } |
| 76 | #endif |
| 77 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 78 | #endif /* _CONSTR_CHOICE_H_ */ |