comparison src/gpf3/ccd/asn1_opentype.c @ 2:c41a534f33c6

src/gpf3: preened GPF goo from TCS3.2
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 25 Sep 2016 23:52:50 +0000
parents
children
comparison
equal deleted inserted replaced
1:864b8cc0cf63 2:c41a534f33c6
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul : asn1_opentype.c
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : Encoding and decoding functions for ASN1_OPEN_TYPE type
18 +-----------------------------------------------------------------------------
19 */
20
21 /*
22 * Standard definitions like UCHAR, ERROR etc.
23 */
24 #include "typedefs.h"
25 #include "header.h"
26
27 /*
28 * Prototypes of ccd (USE_DRIVER EQ undef) for prototypes only
29 * look at ccdapi.h
30 */
31 #undef USE_DRIVER
32 #include "ccdapi.h"
33
34 /*
35 * Types and functions for bit access and manipulation
36 */
37 #include "ccd_globs.h"
38 #include "bitfun.h"
39
40 /*
41 * Prototypes and constants in the common part of ccd
42 */
43 #include "ccd.h"
44
45 /*
46 * Declaration of coder/decoder tables
47 */
48 #include "ccdtable.h"
49 #include "ccddata.h"
50
51 #ifndef RUN_INT_RAM
52 /*
53 +------------------------------------------------------------------------+
54 | PROJECT : CCD (6144) MODULE : asn1_opentype |
55 | STATE : code ROUTINE : cdc_asn1_open_type_decode |
56 +------------------------------------------------------------------------+
57
58 PURPOSE : Decode PER OBJECT IDENTIFIER type
59
60 The PER encoding of an open type is preceded by a length
61 determinant (1 or 2 bytes as long as no data fragmentation is
62 necessary). The bit field of the encoded open type itself is
63 octet aligned octet string.
64 If the result of encoding the outermost value is an empty bit
65 string, the bit string must be replaced with a single octet
66 with all bits set to 0.
67 */
68 SHORT cdc_asn1_open_type_decode (const ULONG c_ref, const ULONG e_ref, T_CCD_Globs *globs)
69 {
70 U8 BER_Len;
71
72 #ifdef DEBUG_CCD
73 #ifndef CCD_SYMBOLS
74 TRACE_CCD (globs, "cdc_asn1_open_type_decode()");
75 #else
76 TRACE_CCD (globs, "cdc_asn1_open_type_decode() %s", mcomp[melem[e_ref].elemRef].name);
77 #endif
78 #endif
79
80 globs->pstructOffs = melem[e_ref].structOffs;
81
82 /* For optional elements we have already set the valid flag in the
83 * C-structure. We have done it while processing ASN1_SEQ.
84 */
85 if ( ! cdc_isPresent(e_ref, globs) ) {
86 return 1;
87 }
88
89 /*
90 * For unknown extension read the length and skip over the octets.
91 */
92 BER_Len = (U8) Read_OpenTpye_Length (globs);
93 bf_incBitpos (8 * BER_Len, globs);
94
95 return 1;
96 }
97 #endif /* !RUN_INT_RAM */
98
99 #ifndef RUN_INT_RAM
100 /*
101 +------------------------------------------------------------------------+
102 | PROJECT : CCD (6144) MODULE : asn1_opentype |
103 | STATE : code ROUTINE : cdc_asn1_open_type_encode |
104 +------------------------------------------------------------------------+
105
106 PURPOSE : PER encoding of open types
107
108 The PER encoding of an open type is preceded by a length
109 determinant (1 or 2 bytes as long as no data fragmentation is
110 necessary). The bit field of the encoded open type itself is
111 octet aligned octet string.
112 If the result of encoding the outermost value is an empty bit
113 string, the bit string must be replaced with a single octet
114 with all bits set to 0.
115 */
116 SHORT cdc_asn1_open_type_encode (const ULONG c_ref, const ULONG e_ref, T_CCD_Globs *globs)
117 {
118 #ifdef DEBUG_CCD
119 #ifndef CCD_SYMBOLS
120 TRACE_CCD (globs, "cdc_asn1_open_type_encode()");
121 #else
122 TRACE_CCD (globs, "cdc_asn1_open_type_encode() %s", mcomp[melem[e_ref].elemRef].name);
123 #endif
124 #endif
125
126 /* For optional elements we have already set the valid flag in the
127 * C-structure. We have done it while processing ASN1_SEQ.
128 */
129 if ( ! cdc_isPresent(e_ref, globs) )
130 return 1;
131 #ifdef DEBUG_CCD
132 else
133 {
134 TRACE_CCD (globs, "Please set valid flag to 0 for open type element.");
135 }
136 #endif
137 return 1;
138 }
139 #endif /* !RUN_INT_RAM */