📄 wbxmldef.h
字号:
/*
* Copyright (C) Ericsson Mobile Communications AB, 2000.
* Licensed to AU-System AB.
* All rights reserved.
*
* This software is covered by the license agreement between
* the end user and AU-System AB, and may be used and copied
* only in accordance with the terms of the said agreement.
*
* Neither Ericsson Mobile Communications AB nor AU-System AB
* assumes any responsibility or liability for any errors or inaccuracies in
* this software, or any consequential, incidental or indirect damage arising
* out of the use of the Generic WAP Client software.
*/
/*========================================================================
FILE: wbxmldef.h
General WBXML-decoder. Definition file.
Rev history:
990302 JPR Created
990319 JPR Modified
990326 JPR IANA-codes moved to CmmnRsrc.h
990414 JPR Corrections
990511 JPR Additions in tWBXMLDECODESTR
990915 JPR Updated to support channel decoding
991112 JPR Updated to support PUSH content types
991126 JPR Redesign of Element Handling, Text Handling,
and Error Handling (Consult separate document).
Updates for WAP 1.2 are also included. Application
specific parts removed
991207 JPR Small changes
991208 JPR ViewId removed
991222 JPR iDTD in tWBXMLDECODESTR changed to iVersion
000104 JPR xml:space def. added, DTD_CreateElementFunc mod.
000113 JPR OPAQUE changed to XMLOPAQUE
000131 JPR Generic Content Element added (tCONTENTELEMENT)
000925 JPR WBXML version 1.3 added
010119 NKE Replaced DTD_AddContentFunc with DTD_ValidContentFunc
for the new decoder in wbxmldec.c.
010125 NKE Changed definition of DTD_AppSpecParseModFunc.
=========================================================================*/
#ifndef CWAPWBXMLDEF_H
#define CWAPWBXMLDEF_H
#include "cmmnrsrc.h"
/*========================================================================
Definitions
=========================================================================*/
#define WBXML_VERSION_NUMBER_1_1 ((BYTE) 0x01) /* WBXML 1.1 */
#define WBXML_VERSION_NUMBER_1_2 ((BYTE) 0x02) /* WBXML 1.2 */
#define WBXML_VERSION_NUMBER_1_3 ((BYTE) 0x03) /* WBXML 1.3 */
#define Type_Literal 4 /* Literal tag */
#define WBXML_TIMESLOT 300 /* Length of each decode session */
/* xml:space definitions; only 'preserve' or 'default' allowed */
#define XML_SPACE_PRESERVE 0
#define XML_SPACE_DEFAULT 1
#define isXMLWhiteSpace(c) ((c==(WCHAR)'\x20')||(c==(WCHAR)'\x9')||(c==(WCHAR)'\xD')||(c==(WCHAR)'\xA'))
#define B_isXMLWhiteSpace(c) ((c=='\x20')||(c=='\x9')||(c=='\xD')||(c=='\xA'))
typedef struct tWBXMLDECODESTR *pDECSTR;
/*========================================================================
Global Element definitions
=========================================================================*/
/* Global Element types */
#define Type_ContentElement (UINT16) 0x01 /* Super element + content */
#define Type_Entity (UINT16) 0x02 /* The Element is an Entity */
#define Type_Inline_Text (UINT16) 0x03 /* Inline string */
#define Type_Token_Value (UINT16) 0x51 /* Token Value, used only with connectivity doc, used in provisioning and E2E sec */
#define Type_Ext_0 (UINT16) 0x40 /* The Element is a EXT_0 */
#define Type_Ext_1 (UINT16) 0x41 /* The Element is a EXT_1 */
#define Type_Ext_2 (UINT16) 0x42 /* The Element is a EXT_2 */
#define Type_Table_Text (UINT16) 0x83 /* String table reference */
#define Type_Opaque (UINT16) 0xC3 /* OPAQUE data */
/* Super Element
The type attribute determines the type of the element in the actual
DTD. Elements with a global type have the same meaning in all DTD:s.
The values are set to the same values as the global tokens in the
WBXML specification to avoid collision with application specific types
(defined in e.g. the WML specification).
All elements MUST have iType (UINT16) as its first attribute and
pNextElement (struct tELEMENTTYPE*) as its second.
*/
typedef struct tELEMENTTYPE
{
UINT16 iType;
struct tELEMENTTYPE* pNextElement;
} ELEMENTTYPE, *pELEMENTTYPE;
/* Super Element with content
This element is used when content is to be stored. All elements with
content MUST be conformant with this element. The content is stored
with a call to the function XML_AddContent. Content is retrieved with
a call to the function XML_GetContent.
*/
typedef struct tCONTENTELEMENT
{
UINT16 iType;
struct tELEMENTTYPE* pNextElement;
pELEMENTTYPE pContent;
} CONTENTELEMENT, *pCONTENTELEMENT;
/* Inline Text Element.
Used for internal representation of inline strings. The data is
stored in the pwchTextData attribute.
*/
typedef struct tI_TEXTELEMENT
{
UINT16 iType;
struct tELEMENTTYPE *pNextElement;
WCHAR* pwchTextData;
} I_TEXTELEMENT, *pI_TEXTELEMENT;
/* String table reference Text Element.
Used for internal representation of strings. A reference to the
string table is stored in the iTable attribute.
*/
typedef struct tT_TEXTELEMENT
{
UINT16 iType;
struct tELEMENTTYPE *pNextElement;
UINT32 iTableRef;
} T_TEXTELEMENT, *pT_TEXTELEMENT;
/* Token Element.
Used for internal representation of Token values. The data is
stored in the iTokenData attribute.
*/
typedef struct t_TOKENELEMENT
{
UINT16 iType;
struct tELEMENTTYPE *pNextElement;
UINT16 iTokenData;
} TOKENELEMENT, *pTOKENELEMENT;
/* Ext Element.
Used for internal representation of extensions (Type_Ext_0,
Type_Ext_1, and Type_Ext_2). The name of the extension is stored
in the pwchName attribute.
*/
typedef struct tEXT_ELEMENT
{
UINT16 iType;
struct tELEMENTTYPE *pNextElement;
WCHAR* pwchName;
} EXT_ELEMENT, *pEXT_ELEMENT;
/* Entity Element.
Used for internal representation of Entities. The entity is stored
in the iEntity attribute.
*/
typedef struct tENTITY
{
UINT16 iType;
struct tELEMENTTYPE *pNextElement;
UINT32 iEntity;
} ENTITY, *pENTITY;
/* Opaque Element.
Used for internal representation of Opaque data. The data is stored
in the pbData attribute and the length is stored in the iLength
attribute.
*/
typedef struct tXMLOPAQUE
{
UINT16 iType;
struct tELEMENTTYPE *pNextElement;
UINT32 iLength;
BYTE* pbData;
} XMLOPAQUE, *pXMLOPAQUE;
/*========================================================================
Definitions for the Document Type Specific function pointers that
are needed by the WBXML-decoder for each supported DTD.
=========================================================================*/
/*========================================================================
DTD_CreateElementFunc
==========================================================================
A function of this type is used for creating an element.
Creates an element of the specified type and sets the default values.
The returned element is of the type tELEMENTTYPE, but can be casted
to the correct type (stored in the element, consult the definitions in
the file WBXMLDef.h) if the attributes are required.
It is the caller's responsibility to deallocate the memory (with a
call to the function XML_DeleteElement).
Input: pWBXMLDECODESTR (not NULL), Type of element to be created
Output: Pointer to a struct of the type tELEMENTTYPE or NULL.
==========================================================================*/
typedef
pELEMENTTYPE DTD_CreateElementFunc (pDECSTR pDecStr, UINT16 iType);
/*========================================================================
DTD_DeleteElementFunc
==========================================================================
A function of this type is used for deleting an element and all its
content.
Deletes an element and all its content and frees the memory. The in-
parameter ppElement is set to point to NULL after the element has been
deleted.
Input: pWBXMLDECODESTR (not NULL), ELEMENTTYPE**
Output: -
==========================================================================*/
typedef
void DTD_DeleteElementFunc (pDECSTR pDecStr, pELEMENTTYPE* ppElement);
/*========================================================================
DTD_ValidContentFunc
==========================================================================
A function of this type is used for checking if an element may take
content.
The function returns TRUE if the content is legal in the element,
FALSE otherwise. The function SHOULD consider the Version
attribute in the Decode Struct when the decision is made. If the
function returns FALSE, the calling function will set the Illegal
Content Warning in the Decode Struct.
Input: pWBXMLDECODESTR (not NULL) and an element.
Output: TRUE/FALSE
==========================================================================*/
typedef
BOOL DTD_ValidContentFunc (pDECSTR pDecStr, pELEMENTTYPE pElement);
/*========================================================================
DTD_GetContentFunc
==========================================================================
A function of this type is used to retrieve the first content from an
element.
If no content is present or if the pElement is NULL, NULL is returned.
NOTE! The returned data is not a copy and therefore MUST NOT be
deallocated. The data is deallocated when the structure is deleted.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -