Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
decompile.h
Go to the documentation of this file.
1 /* ====================================================================
2  * The Kannel Software License, Version 1.0
3  *
4  * Copyright (c) 2001-2016 Kannel Group
5  * Copyright (c) 1998-2001 WapIT Ltd.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Kannel Group (http://www.kannel.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Kannel" and "Kannel Group" must not be used to
28  * endorse or promote products derived from this software without
29  * prior written permission. For written permission, please
30  * contact org@kannel.org.
31  *
32  * 5. Products derived from this software may not be called "Kannel",
33  * nor may "Kannel" appear in their name, without prior written
34  * permission of the Kannel Group.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS
40  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
41  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
42  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
43  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
44  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
45  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
46  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47  * ====================================================================
48  *
49  * This software consists of voluntary contributions made by many
50  * individuals on behalf of the Kannel Group. For more information on
51  * the Kannel Group, please see <http://www.kannel.org/>.
52  *
53  * Portions of this software are based upon software originally written at
54  * WapIT Ltd., Helsinki, Finland for the Kannel project.
55  */
56 
57 /*
58  * decompile.h - Declarations and types used by decompile.c
59  *
60  * Author: Chris Wulff, Vanteon (cwulff@vanteon.com)
61  *
62  */
63 
64 #ifndef DECOMPILE_H_INCLUDED
65 #define DECOMPILE_H_INCLUDED
66 
67 
68 /* Global Tags */
69 #define TAG_SWITCH_PAGE 0x00
70 #define TAG_END 0x01
71 #define TAG_ENTITY 0x02
72 #define TAG_STR_I 0x03
73 #define TAG_LITERAL 0x04
74 #define TAG_EXT_I_0 0x40
75 #define TAG_EXT_I_1 0x41
76 #define TAG_EXT_I_2 0x42
77 #define TAG_PI 0x43
78 #define TAG_LITERAL_C 0x44
79 #define TAG_EXT_T_0 0x80
80 #define TAG_EXT_T_1 0x81
81 #define TAG_EXT_T_2 0x82
82 #define TAG_STR_T 0x83
83 #define TAG_LITERAL_A 0x84
84 #define TAG_EXT_0 0xc0
85 #define TAG_EXT_1 0xc1
86 #define TAG_EXT_2 0xc2
87 #define TAG_OPAQUE 0xc3
88 #define TAG_LITERAL_AC 0xc4
89 
90 /* Codepage tag masks */
91 #define CODEPAGE_TAG_MASK ((WBXML_TAG) 0x3f)
92 #define CODEPAGE_TAG_HAS_CONTENT ((WBXML_TAG) 0x40)
93 #define CODEPAGE_TAG_HAS_ATTRS ((WBXML_TAG) 0x80)
94 
95 /* Sizes */
96 #define SWITCHPAGE_SIZE 2
97 
98 /* Codepage Tag Types */
99 typedef enum tagCP_TYPES
100 {
104 
105 } CP_TAG_TYPE;
106 
107 /* Datatypes */
108 typedef int BOOL;
109 #define FALSE 0
110 #define TRUE 1
111 
112 typedef unsigned char WBXML;
113 typedef WBXML* P_WBXML;
114 typedef P_WBXML* PP_WBXML;
115 
116 typedef unsigned char WBXML_TAG;
118 
119 typedef unsigned char WBXML_CODEPAGE;
120 
121 typedef unsigned long WBXML_LENGTH;
122 
123 typedef enum
124 {
136 
138 
139 typedef struct tagWBXML_NODE
140 {
141  void* m_prev; /* (P_WBXML_NODE) the previous sibling */
142  void* m_next; /* (P_WBXML_NODE) the next sibling */
143  void* m_child; /* (P_WBXML_NODE) the first child */
144  void* m_parent; /* (P_WBXML_NODE) the parent */
145  WBXML_NODE_TYPE m_type; /* type of this node */
146  WBXML_CODEPAGE m_page; /* the codepage for this node */
147  void* m_data; /* type specific node data */
148 
149 } WBXML_NODE;
150 
152 
153 typedef enum
154 {
158 
160 
161 typedef unsigned char WBXML_U_INT8;
163 
164 #define MAX_MB_U_INT32_BYTES 4
165 
166 typedef unsigned char WBXML_MB_U_INT32[MAX_MB_U_INT32_BYTES];
168 
170 
173 
174 typedef unsigned char* WBXML_BYTES;
176 
178 
179 typedef struct tagDTD_NODE_DATA
180 {
181  WBXML_DTD_TYPE m_dtdnum; /* DTD number */
182  WBXML_MB_U_INT32 m_index; /* DTD string table index (for DTD# 0) */
183 
184 } DTD_NODE_DATA;
185 
186 typedef struct tagWBXML_INFO
187 {
188  P_WBXML m_start; /* Beginning of the binary buffer */
189  P_WBXML m_curpos; /* Current binary buffer position */
190  WBXML_LENGTH m_length; /* Length of the binary data */
191  P_WBXML_NODE m_tree; /* WBXML parse tree */
192  P_WBXML_NODE m_curnode; /* current parse tree node */
193  WBXML_CODEPAGE m_curpage; /* the current codepage */
194 
195 } WBXML_INFO;
196 
198 
199 typedef struct tagWBXML_STRING_TABLE
200 {
203 
205 
207 
209 {
216 
218 
220 {
224 
226 
227 typedef struct tagDTD_TYPE_LIST
228 {
229  long m_id;
230  char* m_name;
231 
232 } DTD_TYPE_LIST;
233 
235 {
236  long m_dtd_id;
237  char* m_name;
240 
242 
244 
246 {
247  long m_dtd_id;
248  char* m_name;
252 
254 
256 
258 {
259  long m_dtd_id;
260  char* m_name;
263 
265 
267 
268 /* Flow Control Prototypes */
269 
270 void Message(char* msg);
271 
274 
276 
277 BOOL IsTag(P_WBXML_INFO buffer, WBXML_TAG tag);
279 
282 BOOL Is_string (P_WBXML_INFO buffer);
284 BOOL Is_inline (P_WBXML_INFO buffer);
285 BOOL Is_tableref (P_WBXML_INFO buffer);
286 BOOL Is_entity (P_WBXML_INFO buffer);
287 BOOL Is_pi (P_WBXML_INFO buffer);
288 BOOL Is_opaque (P_WBXML_INFO buffer);
289 BOOL Is_zero (P_WBXML_INFO buffer);
290 
291 /* Basic Type Decoder Prototypes */
292 
293 void Read_u_int8 (P_WBXML_INFO buffer, P_WBXML_U_INT8 result);
294 void Read_mb_u_int32 (P_WBXML_INFO buffer, P_WBXML_MB_U_INT32 result);
295 void Read_bytes (P_WBXML_INFO buffer, WBXML_LENGTH length, P_WBXML_BYTES result);
296 void ReadFixedTag (P_WBXML_INFO buffer, WBXML_TAG tag);
298 
299 /* Basic Type Conversion Prototypes */
300 
302 
303 /* Document Structure Decoder Prototypes */
304 
305 void Read_start (P_WBXML_INFO buffer);
306 void Read_strtbl (P_WBXML_INFO buffer);
307 void Read_body (P_WBXML_INFO buffer);
308 void Read_element (P_WBXML_INFO buffer);
309 void Read_content (P_WBXML_INFO buffer);
311 void Read_attribute (P_WBXML_INFO buffer);
312 void Read_attrStart (P_WBXML_INFO buffer);
313 void Read_attrValue (P_WBXML_INFO buffer);
314 void Read_extension (P_WBXML_INFO buffer);
315 void Read_string (P_WBXML_INFO buffer);
316 void Read_switchPage (P_WBXML_INFO buffer);
317 void Read_inline (P_WBXML_INFO buffer);
318 void Read_tableref (P_WBXML_INFO buffer);
319 void Read_entity (P_WBXML_INFO buffer);
320 void Read_entcode (P_WBXML_INFO buffer);
321 void Read_pi (P_WBXML_INFO buffer);
322 void Read_opaque (P_WBXML_INFO buffer);
323 void Read_version (P_WBXML_INFO buffer);
324 void Read_publicid (P_WBXML_INFO buffer);
325 void Read_charset (P_WBXML_INFO buffer);
326 void Read_termstr (P_WBXML_INFO buffer);
327 void Read_termstr_rtn(P_WBXML_INFO buffer, char** result);
328 void Read_index (P_WBXML_INFO buffer, P_WBXML_MB_U_INT32 result);
329 void Read_length (P_WBXML_INFO buffer, P_WBXML_MB_U_INT32 result);
330 void Read_zero (P_WBXML_INFO buffer);
331 void Read_pageindex (P_WBXML_INFO buffer, P_WBXML_U_INT8 result);
332 
333 #endif /* _DECOMPILE_H_INCLUDED_ */
const WBXML_MB_U_INT32 ZERO_WBXML_MB_U_INT32
Definition: decompile.c:72
void Read_attrValue(P_WBXML_INFO buffer)
Definition: decompile.c:1109
WBXML_MB_U_INT32 m_length
Definition: decompile.h:201
void error(int err, const char *fmt,...)
Definition: log.c:612
void * m_next
Definition: decompile.h:142
CODEPAGE_TAG_NAME_LIST * P_CODEPAGE_TAG_NAME_LIST
Definition: decompile.h:243
void Read_bytes(P_WBXML_INFO buffer, WBXML_LENGTH length, P_WBXML_BYTES result)
Definition: decompile.c:765
BOOL Is_extension(P_WBXML_INFO buffer)
Definition: decompile.c:627
WBXML_MB_U_INT32 * P_WBXML_MB_U_INT32
Definition: decompile.h:167
void Read_content(P_WBXML_INFO buffer)
Definition: decompile.c:1011
CODEPAGE_ATTRSTART_NAME_LIST * P_CODEPAGE_ATTRSTART_NAME_LIST
Definition: decompile.h:255
P_WBXML m_curpos
Definition: decompile.h:189
WBXML_TAG Read_stag(P_WBXML_INFO buffer)
Definition: decompile.c:1040
unsigned char WBXML
Definition: decompile.h:112
unsigned long WBXML_LENGTH
Definition: decompile.h:121
enum tagWBXML_PARSE_ERROR WBXML_PARSE_ERROR
P_WBXML * PP_WBXML
Definition: decompile.h:114
unsigned char WBXML_CODEPAGE
Definition: decompile.h:119
unsigned char WBXML_TAG
Definition: decompile.h:116
WBXML_NODE * P_WBXML_NODE
Definition: decompile.h:151
WBXML_CODEPAGE m_page
Definition: decompile.h:238
void Read_body(P_WBXML_INFO buffer)
Definition: decompile.c:953
void Read_extension(P_WBXML_INFO buffer)
Definition: decompile.c:1146
void Message(char *msg)
Definition: decompile.c:485
BOOL Is_pi(P_WBXML_INFO buffer)
Definition: decompile.c:680
long mb_u_int32_to_long(P_WBXML_MB_U_INT32 value)
Definition: decompile.c:873
WBXML_INFO * P_WBXML_INFO
Definition: decompile.h:197
struct tagDTD_NODE_DATA DTD_NODE_DATA
struct tagCODEPAGE_TAG_NAME_LIST CODEPAGE_TAG_NAME_LIST
enum tagCP_TYPES CP_TAG_TYPE
P_WBXML_NODE m_tree
Definition: decompile.h:191
WBXML_BYTES * P_WBXML_BYTES
Definition: decompile.h:175
unsigned char WBXML_MB_U_INT32[MAX_MB_U_INT32_BYTES]
Definition: decompile.h:166
WBXML_VARIABLE_TYPE
Definition: decompile.h:153
WBXML_CODEPAGE m_page
Definition: decompile.h:146
int type
Definition: smsc_cimd2.c:215
WBXML_U_INT8 * P_WBXML_U_INT8
Definition: decompile.h:162
WBXML_LENGTH BytesLeft(P_WBXML_INFO buffer)
Definition: decompile.c:548
void Read_element(P_WBXML_INFO buffer)
Definition: decompile.c:968
void Read_start(P_WBXML_INFO buffer)
Definition: decompile.c:935
struct tagWBXML_INFO WBXML_INFO
void ReadFixedTag(P_WBXML_INFO buffer, WBXML_TAG tag)
Definition: decompile.c:786
void Read_u_int8(P_WBXML_INFO buffer, P_WBXML_U_INT8 result)
Definition: decompile.c:718
struct tagCODEPAGE_ATTRSTART_NAME_LIST CODEPAGE_ATTRSTART_NAME_LIST
WBXML_STRING_TABLE * P_WBXML_STRING_TABLE
Definition: decompile.h:206
void ParseError(WBXML_PARSE_ERROR error)
Definition: decompile.c:490
void Read_pageindex(P_WBXML_INFO buffer, P_WBXML_U_INT8 result)
Definition: decompile.c:1420
void Read_index(P_WBXML_INFO buffer, P_WBXML_MB_U_INT32 result)
Definition: decompile.c:1398
void Read_tableref(P_WBXML_INFO buffer)
Definition: decompile.c:1264
void Read_publicid(P_WBXML_INFO buffer)
Definition: decompile.c:1314
void Read_entity(P_WBXML_INFO buffer)
Definition: decompile.c:1272
void Read_opaque(P_WBXML_INFO buffer)
Definition: decompile.c:1297
void Read_attrStart(P_WBXML_INFO buffer)
Definition: decompile.c:1077
WBXML_CODEPAGE m_curpage
Definition: decompile.h:193
void Read_string(P_WBXML_INFO buffer)
Definition: decompile.c:1231
void ParseWarning(WBXML_PARSE_WARNING warning)
Definition: decompile.c:526
WBXML_MB_U_INT32 m_index
Definition: decompile.h:182
BOOL Is_entity(P_WBXML_INFO buffer)
Definition: decompile.c:675
void Read_termstr(P_WBXML_INFO buffer)
Definition: decompile.c:1387
struct tagWBXML_STRING_TABLE WBXML_STRING_TABLE
void * m_prev
Definition: decompile.h:141
WBXML_MB_U_INT32 WBXML_STRING_INDEX
Definition: decompile.h:171
WBXML_LENGTH m_length
Definition: decompile.h:190
unsigned char WBXML_U_INT8
Definition: decompile.h:161
void Read_pi(P_WBXML_INFO buffer)
Definition: decompile.c:1284
void Read_mb_u_int32(P_WBXML_INFO buffer, P_WBXML_MB_U_INT32 result)
Definition: decompile.c:738
P_WBXML_NODE m_curnode
Definition: decompile.h:192
#define MAX_MB_U_INT32_BYTES
Definition: decompile.h:164
struct tagDTD_TYPE_LIST DTD_TYPE_LIST
void warning(int err, const char *fmt,...)
Definition: log.c:624
WBXML * P_WBXML
Definition: decompile.h:113
WBXML_MB_U_INT32 WBXML_DTD_TYPE
Definition: decompile.h:177
CODEPAGE_ATTRVALUE_NAME_LIST * P_CODEPAGE_ATTRVALUE_NAME_LIST
Definition: decompile.h:266
enum tagWBXML_PARSE_WARNING WBXML_PARSE_WARNING
void Read_attribute(P_WBXML_INFO buffer)
Definition: decompile.c:1067
BOOL Is_zero(P_WBXML_INFO buffer)
Definition: decompile.c:690
BOOL IsCodepageTag(P_WBXML_INFO buffer, CP_TAG_TYPE type)
Definition: decompile.c:594
BOOL Is_switchPage(P_WBXML_INFO buffer)
Definition: decompile.c:660
void Read_termstr_rtn(P_WBXML_INFO buffer, char **result)
Definition: decompile.c:1341
WBXML_TAG * P_WBXML_TAG
Definition: decompile.h:117
WBXML_NODE_TYPE
Definition: decompile.h:123
tagCP_TYPES
Definition: decompile.h:99
int BOOL
Definition: decompile.h:108
unsigned char * WBXML_BYTES
Definition: decompile.h:174
BOOL Is_string(P_WBXML_INFO buffer)
Definition: decompile.c:654
P_WBXML m_start
Definition: decompile.h:188
tagWBXML_PARSE_ERROR
Definition: decompile.h:208
BOOL Is_attrValue(P_WBXML_INFO buffer)
Definition: decompile.c:612
void Read_length(P_WBXML_INFO buffer, P_WBXML_MB_U_INT32 result)
Definition: decompile.c:1403
void Read_strtbl(P_WBXML_INFO buffer)
Definition: decompile.c:944
BOOL Is_opaque(P_WBXML_INFO buffer)
Definition: decompile.c:685
void * m_child
Definition: decompile.h:143
void Read_switchPage(P_WBXML_INFO buffer)
Definition: decompile.c:1247
WBXML_NODE_TYPE m_type
Definition: decompile.h:145
void Read_entcode(P_WBXML_INFO buffer)
Definition: decompile.c:1278
void Read_charset(P_WBXML_INFO buffer)
Definition: decompile.c:1334
BOOL IsTag(P_WBXML_INFO buffer, WBXML_TAG tag)
Definition: decompile.c:570
void Read_inline(P_WBXML_INFO buffer)
Definition: decompile.c:1258
struct tagCODEPAGE_ATTRVALUE_NAME_LIST CODEPAGE_ATTRVALUE_NAME_LIST
WBXML_TAG ReadCodepageTag(P_WBXML_INFO buffer, CP_TAG_TYPE type)
Definition: decompile.c:812
void * m_data
Definition: decompile.h:147
BOOL Is_tableref(P_WBXML_INFO buffer)
Definition: decompile.c:670
BOOL Is_inline(P_WBXML_INFO buffer)
Definition: decompile.c:665
WBXML_DTD_TYPE m_dtdnum
Definition: decompile.h:181
WBXML_STRING_INDEX * P_WBXML_STRING_INDEX
Definition: decompile.h:172
void Read_zero(P_WBXML_INFO buffer)
Definition: decompile.c:1408
WBXML_BYTES m_strings
Definition: decompile.h:202
void * m_parent
Definition: decompile.h:144
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
tagWBXML_PARSE_WARNING
Definition: decompile.h:219
void Read_version(P_WBXML_INFO buffer)
Definition: decompile.c:1307
struct tagWBXML_NODE WBXML_NODE
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.