SIM-115: update simulator to use latest E2SM KPM version 3
[sim/e2-interface.git] / e2sim / asn1c / BOOLEAN.c
1 /*-
2  * Copyright (c) 2003, 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
3  * Redistribution and modifications are permitted subject to BSD license.
4  */
5 #include <asn_internal.h>
6 #include <BOOLEAN.h>
7
8 /*
9  * BOOLEAN basic type description.
10  */
11 static const ber_tlv_tag_t asn_DEF_BOOLEAN_tags[] = {
12     (ASN_TAG_CLASS_UNIVERSAL | (1 << 2))
13 };
14 asn_TYPE_operation_t asn_OP_BOOLEAN = {
15     BOOLEAN_free,
16 #if !defined(ASN_DISABLE_PRINT_SUPPORT)
17     BOOLEAN_print,
18 #else
19     0,
20 #endif  /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
21     BOOLEAN_compare,
22 #if !defined(ASN_DISABLE_BER_SUPPORT)
23     BOOLEAN_decode_ber,
24     BOOLEAN_encode_der,
25 #else
26     0,
27     0,
28 #endif  /* !defined(ASN_DISABLE_BER_SUPPORT) */
29 #if !defined(ASN_DISABLE_XER_SUPPORT)
30     BOOLEAN_decode_xer,
31     BOOLEAN_encode_xer,
32 #else
33     0,
34     0,
35 #endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
36 #if !defined(ASN_DISABLE_JER_SUPPORT)
37     BOOLEAN_encode_jer,
38 #else
39     0,
40 #endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
41 #if !defined(ASN_DISABLE_OER_SUPPORT)
42     BOOLEAN_decode_oer,
43     BOOLEAN_encode_oer,
44 #else
45     0,
46     0,
47 #endif  /* !defined(ASN_DISABLE_OER_SUPPORT) */
48 #if !defined(ASN_DISABLE_UPER_SUPPORT)
49     BOOLEAN_decode_uper,  /* Unaligned PER decoder */
50     BOOLEAN_encode_uper,  /* Unaligned PER encoder */
51 #else
52     0,
53     0,
54 #endif  /* !defined(ASN_DISABLE_UPER_SUPPORT) */
55 #if !defined(ASN_DISABLE_APER_SUPPORT)
56     BOOLEAN_decode_aper,  /* Aligned PER decoder */
57     BOOLEAN_encode_aper,  /* Aligned PER encoder */
58 #else
59     0,
60     0,
61 #endif  /* !defined(ASN_DISABLE_APER_SUPPORT) */
62 #if !defined(ASN_DISABLE_RFILL_SUPPORT)
63     BOOLEAN_random_fill,
64 #else
65     0,
66 #endif  /* !defined(ASN_DISABLE_RFILL_SUPPORT) */
67     0  /* Use generic outmost tag fetcher */
68 };
69 asn_TYPE_descriptor_t asn_DEF_BOOLEAN = {
70     "BOOLEAN",
71     "BOOLEAN",
72     &asn_OP_BOOLEAN,
73     asn_DEF_BOOLEAN_tags,
74     sizeof(asn_DEF_BOOLEAN_tags) / sizeof(asn_DEF_BOOLEAN_tags[0]),
75     asn_DEF_BOOLEAN_tags,  /* Same as above */
76     sizeof(asn_DEF_BOOLEAN_tags) / sizeof(asn_DEF_BOOLEAN_tags[0]),
77     {
78 #if !defined(ASN_DISABLE_OER_SUPPORT)
79         0,
80 #endif  /* !defined(ASN_DISABLE_OER_SUPPORT) */
81 #if !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT)
82         0,
83 #endif  /* !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT) */
84         asn_generic_no_constraint
85     },
86     0, 0,  /* No members */
87     0  /* No specifics */
88 };
89
90 void
91 BOOLEAN_free(const asn_TYPE_descriptor_t *td, void *ptr,
92              enum asn_struct_free_method method) {
93     if(td && ptr) {
94         switch(method) {
95         case ASFM_FREE_EVERYTHING:
96             FREEMEM(ptr);
97             break;
98         case ASFM_FREE_UNDERLYING:
99             break;
100         case ASFM_FREE_UNDERLYING_AND_RESET:
101             memset(ptr, 0, sizeof(BOOLEAN_t));
102             break;
103         }
104     }
105 }
106
107 int
108 BOOLEAN_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
109                 const void *bptr) {
110     const BOOLEAN_t *a = aptr;
111     const BOOLEAN_t *b = bptr;
112
113     (void)td;
114
115     if(a && b) {
116         if(!*a == !*b) {    /* TRUE can be encoded by any non-zero byte. */
117             return 0;
118         } else if(!*a) {
119             return -1;
120         } else {
121             return 1;
122         }
123     } else if(!a) {
124         return -1;
125     } else {
126         return 1;
127     }
128 }