aboutsummaryrefslogtreecommitdiffstats
path: root/addons/ooh323c/src/eventHandler.h
blob: e5eff605bd9ea5c9f3ed27a7302ec8dffd961ed2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/*
 * Copyright (C) 2004-2005 by Objective Systems, Inc.
 *
 * This software is furnished under an open source license and may be 
 * used and copied only in accordance with the terms of this license. 
 * The text of the license may generally be found in the root 
 * directory of this installation in the COPYING file.  It 
 * can also be viewed online at the following URL:
 *
 *   http://www.obj-sys.com/open/license.html
 *
 * Any redistributions of this file including modified versions must 
 * maintain this copyright notice.
 *
 *****************************************************************************/
/**
 * @file eventHandler.h 
 * C event handler structure.  This structure holds event handler function 
 * callbacks for use by the generated code.
 */
/**
 * @defgroup EventHandler event handler
 * Event handler structures and callback function definitions.
 * @{
 */
#ifndef _EVENTHANDLER_H_
#define _EVENTHANDLER_H_

#include <stdio.h>
#include "ooasn1.h"

#ifdef __cplusplus
extern "C" {
#endif


#ifndef EXTERN
#if define (MAKE_DLL)
#define EXTERN __declspec(dllexport)
#else
#define EXTERN
#endif /* MAKE_DLL */
#endif /* EXTERN */


/**
 * This is a function pointer for a callback function which is invoked 
 * from within a decode function when an element of a SEQUENCE, SET, 
 * SEQUENCE OF, SET OF, or CHOICE construct is parsed.
 *
 * @param name         For SEQUENCE, SET, or CHOICE, this is the name of the
 *                       element as defined in the ASN.1 defination. For
 *                       SEQUENCE OF or SET OF, this is set to the name
 *                       "element".
 * @param index        For SEQUENCE, SET, or CHOICE, this is not used and is
 *                       set to the value
 *                       -1. For SEQUENCE OF or SET OF, this contains the
 *                       zero-based index of the element in the conceptual
 *                       array associated with the construct.
 * @return             - none
 */
typedef void (*StartElement) (const char* name, int index) ;


/**
 * This is a function pointer for a callback function which is invoked from 
 * within a decode function when parsing is complete on an element of a 
 * SEQUENCE, SET, SEQUENCE OF, SET OF, or CHOICE construct.
 *
 * @param name         For SEQUENCE, SET, or CHOICE, this is the name of the
 *                       element as defined in the ASN.1 defination. For
 *                       SEQUENCE OF or SET OF, this is set to the name
 *                       "element".
 * @param index        For SEQUENCE, SET, or CHOICE, this is not used and is
 *                       set to the value
 *                       -1. For SEQUENCE OF or SET OF, this contains the
 *                       zero-based index of the element in the conceptual
 *                       array associated with the construct.
 * @return             - none
 */
typedef void (*EndElement) (const char* name, int index) ;


/**
 * This is a function pointer for a callback function which is invoked from 
 * within a decode function when a value of the BOOLEAN ASN.1 type is parsed.
 *
 * @param value        Parsed value.
 * @return             - none
 */
typedef void (*BoolValue) (ASN1BOOL value);

/**
 * This is a function pointer for a callback function which is invoked from 
 * within a decode function when a value of the INTERGER ASN.1 type is parsed.
 *
 * @param value        Parsed value.
 * @return             - none
 */
typedef void (*IntValue) (ASN1INT value);

/**
 * This is a function pointer for a callback function which is invoked 
 * from within a decode function when a value of the INTEGER ASN.1 type 
 * is parsed. In this case, constraints on the integer value forced the 
 * use of unsigned integer C type to represent the value.
 *
 * @param value        Parsed value.
 * @return             - none
 */
typedef void (*UIntValue) (ASN1UINT value);

/**
 * This is a function pointer for a callback function which is invoked from 
 * within a decode function when a value of the BIT STRING ASN.1 type is 
 * parsed.
 *
 * @param numbits      - Number of bits in the parsed value. 
 * @param data         - Pointer to a byte array that contains the bit 
 *                         string data.
 * @return             - none
 */ 
typedef void (*BitStrValue) (ASN1UINT numbits, const ASN1OCTET* data);

/**
 * This is a function pointer for a callback function which is invoked from 
 * within a decode function when a value of one of the OCTET STRING ASN.1 type
 * is parsed.
 *
 * @param numocts      Number of octets in the parsed value.
 * @param data         Pointer to byte array containing the octet string
 *                       data.
 * @return             - none
 */
typedef void (*OctStrValue) (ASN1UINT numocts, const ASN1OCTET* data) ;

/**
 * This is a function pointer for a callback function which is invoked from 
 * within a decode function when a value of one of the 8-bit ASN.1 character 
 * string types is parsed.
 *
 * @param value        Null terminated character string value.
 * @return             - none
 */
typedef void (*CharStrValue) (const char* value) ;

/**
 * This is a function pointer for a callback function which is invoked from 
 * within a decode function when a value of one of the 16-bit ASN.1 character 
 * string types is parsed.
 *
 * This is used for the ASN.1 BmpString type.
 *
 * @param nchars       Number of characters in the parsed value.
 * @param data         Pointer to an array containing 16-bit values.
 *                       These are represented using unsigned short integer
 *                       values.
 * @return             - none
 */
typedef void (*CharStrValue16Bit) (ASN1UINT nchars, ASN116BITCHAR* data) ;

/**
 * This is a function pointer for a callback function which is invoked from 
 * within a decode function when a value of the NULL ASN.1 type is parsed.
 *
 * @param             - none
 * @return             - none
 */
typedef void (*NullValue) (void) ;

/**
 * This is a function pointer for a callback function which is invoked from 
 * within a decode function whn a value the OBJECT IDENTIFIER ASN.1 type is 
 * parsed.
 *
 * @param numSubIds    Number of subidentifiers in the object identifier.
 * @param pSubIds      Pointer to array containing the subidentifier values.
 * @return             -none
 */
typedef void (*OidValue) (ASN1UINT numSubIds, ASN1UINT* pSubIds) ;

/**
 * This is a function pointer for a callback function which is invoked from 
 * within a decode function when a value of the ENUMERATED ASN.1 type is 
 * parsed.
 *
 * @param value        - Parsed enumerated value
 * @return             - none
 */
typedef void (*EnumValue) (ASN1UINT value) ;

/**
 * This is a function pointer for a callback function which is invoked from 
 * within a decode function when an ASN.1 open type is parsed.
 *
 * @param numocts      Number of octets in the parsed value.
 * @param data         Pointer to byet array contain in tencoded ASN.1
 *                       value.
 * @return             - none
 */
typedef void (*OpenTypeValue) (ASN1UINT numocts, const ASN1OCTET* data) ;


/**
 * This is a basic C based event handler structure, which can be used
 * to define user-defined event handlers.
 */
typedef struct EventHandler {
   StartElement      startElement;
   EndElement        endElement;
   BoolValue         boolValue;
   IntValue          intValue;
   UIntValue         uIntValue;
   BitStrValue       bitStrValue;
   OctStrValue       octStrValue;
   CharStrValue      charStrValue;
   CharStrValue16Bit charStr16BitValue;
   NullValue         nullValue;
   OidValue          oidValue;
   EnumValue         enumValue;
   OpenTypeValue     openTypeValue;
} EventHandler;


/**
 * This function sets the event handler object within the context.  It 
 * will overwrite the definition of any handler that was set previously.
 *
 * @param pctxt       Context to which event handler has to be added.
 * @param pHandler    Pointer to the event handler structure.
 * @return            none
 */
EXTERN void setEventHandler (OOCTXT* pctxt, EventHandler* pHandler);

/**
 * This function is called to remove the event handler current defined 
 * in the context.  This is done by setting the event handler object 
 * pointer to NULL.
 *
 * @param pctxt       Context from which event handler has to be removed.
 * @return            none
 */
EXTERN void removeEventHandler (OOCTXT* pctxt);

/**
 * The following functions are invoked from within the generated 
 * code to call the various user-defined event handler methods ..
 */
EXTERN void invokeStartElement (OOCTXT* pctxt, const char* name, int index);
EXTERN void invokeEndElement (OOCTXT* pctxt, const char* name, int index);
EXTERN void invokeBoolValue (OOCTXT* pctxt, ASN1BOOL value);
EXTERN void invokeIntValue (OOCTXT* pctxt, ASN1INT value);
EXTERN void invokeUIntValue (OOCTXT* pctxt, ASN1UINT value);

EXTERN void invokeBitStrValue 
(OOCTXT* pctxt, ASN1UINT numbits, const ASN1OCTET* data);

EXTERN void invokeOctStrValue 
(OOCTXT* pctxt, ASN1UINT numocts, const ASN1OCTET* data);

EXTERN void invokeCharStrValue (OOCTXT* pctxt, const char* value);

EXTERN void invokeCharStr16BitValue 
(OOCTXT* pctxt, ASN1UINT nchars, ASN116BITCHAR* data);

EXTERN void invokeNullValue (OOCTXT* pctxt);

EXTERN void invokeOidValue 
(OOCTXT* pctxt, ASN1UINT numSubIds, ASN1UINT* pSubIds);

EXTERN void invokeEnumValue (OOCTXT* pctxt, ASN1UINT value);

EXTERN void invokeOpenTypeValue 
(OOCTXT* pctxt, ASN1UINT numocts, const ASN1OCTET* data);

/** 
 * @} 
 */

#ifdef __cplusplus
}
#endif

#endif