Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

decompile.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include "decompile.h"

Include dependency graph for decompile.c:

Include dependency graph

Go to the source code of this file.

Defines

#define INDENT_SIZE   4
#define STRING_BLOCK_SIZE   256

Functions

P_WBXML_NODE NewNode (P_WBXML_INFO buffer, WBXML_NODE_TYPE type)
void FreeNode (P_WBXML_NODE node)
void AddDTDNode (P_WBXML_INFO buffer, const WBXML_DTD_TYPE dtdnum, const WBXML_MB_U_INT32 index)
void AddStringTableNode (P_WBXML_INFO buffer, const P_WBXML_STRING_TABLE strings)
void AddCodepageTagNode (P_WBXML_INFO buffer, WBXML_TAG tag)
void AddCodepageLiteralTagNode (P_WBXML_INFO buffer, WBXML_MB_U_INT32 index)
void AddAttrStartNode (P_WBXML_INFO buffer, WBXML_TAG tag)
void AddAttrStartLiteralNode (P_WBXML_INFO buffer, WBXML_MB_U_INT32 index)
void AddAttrValueNode (P_WBXML_INFO buffer, WBXML_TAG tag)
void AddAttrEndNode (P_WBXML_INFO buffer)
void AddStringNode (P_WBXML_INFO buffer, char *string)
void AddVariableStringNode (P_WBXML_INFO buffer, char *string, WBXML_VARIABLE_TYPE type)
void AddVariableIndexNode (P_WBXML_INFO buffer, char *string, WBXML_VARIABLE_TYPE type)
void Message (char *msg)
void ParseError (WBXML_PARSE_ERROR error)
void ParseWarning (WBXML_PARSE_WARNING warning)
WBXML_LENGTH BytesLeft (P_WBXML_INFO buffer)
BOOL IsTag (P_WBXML_INFO buffer, WBXML_TAG tag)
BOOL IsCodepageTag (P_WBXML_INFO buffer, CP_TAG_TYPE type)
BOOL Is_attrValue (P_WBXML_INFO buffer)
BOOL Is_extension (P_WBXML_INFO buffer)
BOOL Is_string (P_WBXML_INFO buffer)
BOOL Is_switchPage (P_WBXML_INFO buffer)
BOOL Is_inline (P_WBXML_INFO buffer)
BOOL Is_tableref (P_WBXML_INFO buffer)
BOOL Is_entity (P_WBXML_INFO buffer)
BOOL Is_pi (P_WBXML_INFO buffer)
BOOL Is_opaque (P_WBXML_INFO buffer)
BOOL Is_zero (P_WBXML_INFO buffer)
void Read_u_int8 (P_WBXML_INFO buffer, P_WBXML_U_INT8 result)
void Read_mb_u_int32 (P_WBXML_INFO buffer, P_WBXML_MB_U_INT32 result)
void Read_bytes (P_WBXML_INFO buffer, WBXML_LENGTH length, P_WBXML_BYTES result)
void ReadFixedTag (P_WBXML_INFO buffer, WBXML_TAG tag)
WBXML_TAG ReadCodepageTag (P_WBXML_INFO buffer, CP_TAG_TYPE type)
long mb_u_int32_to_long (P_WBXML_MB_U_INT32 value)
void OutputEncodedString (const unsigned char *str)
void Read_start (P_WBXML_INFO buffer)
void Read_strtbl (P_WBXML_INFO buffer)
void Read_body (P_WBXML_INFO buffer)
void Read_element (P_WBXML_INFO buffer)
void Read_content (P_WBXML_INFO buffer)
WBXML_TAG Read_stag (P_WBXML_INFO buffer)
void Read_attribute (P_WBXML_INFO buffer)
void Read_attrStart (P_WBXML_INFO buffer)
void Read_attrValue (P_WBXML_INFO buffer)
void Read_extension (P_WBXML_INFO buffer)
void Read_string (P_WBXML_INFO buffer)
void Read_switchPage (P_WBXML_INFO buffer)
void Read_inline (P_WBXML_INFO buffer)
void Read_tableref (P_WBXML_INFO buffer)
void Read_entity (P_WBXML_INFO buffer)
void Read_entcode (P_WBXML_INFO buffer)
void Read_pi (P_WBXML_INFO buffer)
void Read_opaque (P_WBXML_INFO buffer)
void Read_version (P_WBXML_INFO buffer)
void Read_publicid (P_WBXML_INFO buffer)
void Read_charset (P_WBXML_INFO buffer)
void Read_termstr_rtn (P_WBXML_INFO buffer, char **result)
void Read_termstr (P_WBXML_INFO buffer)
void Read_index (P_WBXML_INFO buffer, P_WBXML_MB_U_INT32 result)
void Read_length (P_WBXML_INFO buffer, P_WBXML_MB_U_INT32 result)
void Read_zero (P_WBXML_INFO buffer)
void Read_pageindex (P_WBXML_INFO buffer, P_WBXML_U_INT8 result)
void Init (P_WBXML_INFO buffer)
size_t BufferLength (P_WBXML_INFO buffer)
void Free (P_WBXML_INFO buffer)
long FileSize (FILE *file)
void ReadBinary (P_WBXML_INFO buffer, FILE *file)
const char * DTDTypeName (long dtdnum)
const char * CodepageTagName (WBXML_CODEPAGE page, WBXML_TAG tag)
const char * CodepageAttrstartName (WBXML_CODEPAGE page, WBXML_TAG tag, char **value)
void CodepageAttrvalueName (WBXML_CODEPAGE page, WBXML_TAG tag, char **value)
const char * GetStringTableString (P_WBXML_NODE node, long index)
void DumpNode (P_WBXML_NODE node, int indent, BOOL *inattrs, BOOL hascontent, char **value)
void DumpNodes (P_WBXML_INFO buffer)
int main (int argc, char **argv)

Variables

const WBXML_MB_U_INT32 ZERO_WBXML_MB_U_INT32 = {0,0,0,0}
long dtd_id
DTD_TYPE_LIST DTDTypeList []
CODEPAGE_TAG_NAME_LIST CodepageTagNames []
CODEPAGE_ATTRSTART_NAME_LIST CodepageAttrstartNames []
CODEPAGE_ATTRVALUE_NAME_LIST CodepageAttrvalueNames []


Define Documentation

#define INDENT_SIZE   4
 

Definition at line 75 of file decompile.c.

#define STRING_BLOCK_SIZE   256
 


Function Documentation

void AddAttrEndNode P_WBXML_INFO  buffer  )  [static]
 

Definition at line 458 of file decompile.c.

References tagWBXML_NODE::m_data, NewNode(), NODE_ATTREND, P_WBXML_INFO, and P_WBXML_NODE.

Referenced by Read_element().

00459 {
00460     P_WBXML_NODE newnode = NewNode(buffer, NODE_ATTREND);
00461     newnode->m_data = NULL;
00462 }

Here is the call graph for this function:

void AddAttrStartLiteralNode P_WBXML_INFO  buffer,
WBXML_MB_U_INT32  index
[static]
 

Definition at line 444 of file decompile.c.

References tagWBXML_NODE::m_data, malloc, NewNode(), NODE_ATTRSTART_LITERAL, P_WBXML_INFO, P_WBXML_MB_U_INT32, P_WBXML_NODE, and WBXML_MB_U_INT32.

Referenced by Read_attrStart().

00445 {
00446     P_WBXML_NODE newnode = NewNode(buffer, NODE_ATTRSTART_LITERAL);
00447     newnode->m_data = malloc(sizeof(WBXML_MB_U_INT32));
00448     memcpy( ((P_WBXML_MB_U_INT32)newnode->m_data), &index, sizeof(WBXML_MB_U_INT32) );
00449 }

Here is the call graph for this function:

void AddAttrStartNode P_WBXML_INFO  buffer,
WBXML_TAG  tag
[static]
 

Definition at line 437 of file decompile.c.

References tagWBXML_NODE::m_data, malloc, NewNode(), NODE_ATTRSTART, P_WBXML_INFO, P_WBXML_NODE, and WBXML_TAG.

Referenced by Read_attrStart().

00438 {
00439     P_WBXML_NODE newnode = NewNode(buffer, NODE_ATTRSTART);
00440     newnode->m_data = malloc(sizeof(WBXML_TAG));
00441     *((P_WBXML_TAG)newnode->m_data) = tag;
00442 }

Here is the call graph for this function:

void AddAttrValueNode P_WBXML_INFO  buffer,
WBXML_TAG  tag
[static]
 

Definition at line 451 of file decompile.c.

References tagWBXML_NODE::m_data, malloc, NewNode(), NODE_ATTRVALUE, P_WBXML_INFO, P_WBXML_NODE, and WBXML_TAG.

Referenced by Read_attrValue().

00452 {
00453     P_WBXML_NODE newnode = NewNode(buffer, NODE_ATTRVALUE);
00454     newnode->m_data = malloc(sizeof(WBXML_TAG));
00455     *((P_WBXML_TAG)newnode->m_data) = tag;
00456 }

Here is the call graph for this function:

void AddCodepageLiteralTagNode P_WBXML_INFO  buffer,
WBXML_MB_U_INT32  index
[static]
 

Definition at line 430 of file decompile.c.

References tagWBXML_NODE::m_data, malloc, NewNode(), NODE_CODEPAGE_LITERAL_TAG, P_WBXML_INFO, P_WBXML_MB_U_INT32, P_WBXML_NODE, and WBXML_MB_U_INT32.

Referenced by Read_stag().

00431 {
00432     P_WBXML_NODE newnode = NewNode(buffer, NODE_CODEPAGE_LITERAL_TAG);
00433     newnode->m_data = malloc(sizeof(WBXML_MB_U_INT32));
00434     memcpy( ((P_WBXML_MB_U_INT32)newnode->m_data), &index, sizeof(WBXML_MB_U_INT32) );
00435 }

Here is the call graph for this function:

void AddCodepageTagNode P_WBXML_INFO  buffer,
WBXML_TAG  tag
[static]
 

Definition at line 423 of file decompile.c.

References tagWBXML_NODE::m_data, malloc, NewNode(), NODE_CODEPAGE_TAG, P_WBXML_INFO, P_WBXML_NODE, and WBXML_TAG.

Referenced by Read_stag().

00424 {
00425     P_WBXML_NODE newnode = NewNode(buffer, NODE_CODEPAGE_TAG);
00426     newnode->m_data = malloc(sizeof(WBXML_TAG));
00427     *((P_WBXML_TAG)newnode->m_data) = tag;
00428 }

Here is the call graph for this function:

void AddDTDNode P_WBXML_INFO  buffer,
const WBXML_DTD_TYPE  dtdnum,
const WBXML_MB_U_INT32  index
[static]
 

Definition at line 407 of file decompile.c.

References dtd_id, DTD_NODE_DATA, tagWBXML_NODE::m_data, malloc, NewNode(), NODE_DTD_TYPE, P_WBXML_INFO, P_WBXML_NODE, and WBXML_MB_U_INT32.

Referenced by Read_publicid().

00408 {
00409     P_WBXML_NODE newnode = NewNode(buffer, NODE_DTD_TYPE);
00410     newnode->m_data = malloc(sizeof(DTD_NODE_DATA));
00411     memcpy( &( ((DTD_NODE_DATA*)newnode->m_data)->m_dtdnum ), &(dtdnum[0]), sizeof(WBXML_MB_U_INT32) );
00412     memcpy( &( ((DTD_NODE_DATA*)newnode->m_data)->m_index ), &(index[0]), sizeof(WBXML_MB_U_INT32) );
00413     dtd_id = (long) dtdnum[0];
00414 }

Here is the call graph for this function:

void AddStringNode P_WBXML_INFO  buffer,
char *  string
[static]
 

Definition at line 464 of file decompile.c.

References tagWBXML_NODE::m_data, NewNode(), NODE_STRING, P_WBXML_INFO, P_WBXML_NODE, and string.

Referenced by Read_termstr().

00465 {
00466     P_WBXML_NODE newnode = NewNode(buffer, NODE_STRING);
00467     newnode->m_data = strdup(string);
00468 }

Here is the call graph for this function:

void AddStringTableNode P_WBXML_INFO  buffer,
const P_WBXML_STRING_TABLE  strings
[static]
 

Definition at line 416 of file decompile.c.

References tagWBXML_NODE::m_data, malloc, NewNode(), NODE_STRING_TABLE, P_WBXML_INFO, P_WBXML_NODE, P_WBXML_STRING_TABLE, and WBXML_STRING_TABLE.

Referenced by Read_strtbl().

00417 {
00418     P_WBXML_NODE newnode = NewNode(buffer, NODE_STRING_TABLE);
00419     newnode->m_data = malloc(sizeof(WBXML_STRING_TABLE));
00420     memcpy( newnode->m_data, strings, sizeof(WBXML_STRING_TABLE) );
00421 }

Here is the call graph for this function:

void AddVariableIndexNode P_WBXML_INFO  buffer,
char *  string,
WBXML_VARIABLE_TYPE  type
[static]
 

Definition at line 475 of file decompile.c.

References P_WBXML_INFO.

Referenced by Read_extension().

00476 {
00477     /* TODO: add this node */
00478 }

void AddVariableStringNode P_WBXML_INFO  buffer,
char *  string,
WBXML_VARIABLE_TYPE  type
[static]
 

Definition at line 470 of file decompile.c.

References P_WBXML_INFO.

Referenced by Read_extension().

00471 {
00472     /* TODO: add this node */
00473 }

size_t BufferLength P_WBXML_INFO  buffer  )  [static]
 

Definition at line 1435 of file decompile.c.

References tagWBXML_INFO::m_curpos, tagWBXML_INFO::m_start, and P_WBXML_INFO.

Referenced by ReadBinary().

01436 {
01437     size_t ret;
01438 
01439     while (buffer->m_curpos != '\0')
01440         buffer->m_curpos++;
01441 
01442     ret = buffer->m_curpos - buffer->m_start;
01443     buffer->m_curpos = buffer->m_start;
01444     return ret;
01445 }

WBXML_LENGTH BytesLeft P_WBXML_INFO  buffer  ) 
 

Definition at line 548 of file decompile.c.

References ERR_INTERNAL_BAD_PARAM, tagWBXML_INFO::m_curpos, tagWBXML_INFO::m_length, tagWBXML_INFO::m_start, P_WBXML_INFO, ParseError(), and WBXML_LENGTH.

Referenced by Is_zero(), IsTag(), Read_bytes(), Read_mb_u_int32(), Read_termstr_rtn(), Read_u_int8(), ReadCodepageTag(), and ReadFixedTag().

00549 {
00550   if (buffer)
00551   {
00552     WBXML_LENGTH bytesRead = (buffer->m_curpos - buffer->m_start);
00553     if (bytesRead >= buffer->m_length)
00554     {
00555       return 0;
00556     }
00557     else
00558     {
00559       return (buffer->m_length - bytesRead);
00560     }
00561   }
00562   else
00563   {
00564     ParseError(ERR_INTERNAL_BAD_PARAM);
00565   }
00566 
00567   return 0;
00568 }

Here is the call graph for this function:

const char* CodepageAttrstartName WBXML_CODEPAGE  page,
WBXML_TAG  tag,
char **  value
[static]
 

Definition at line 1563 of file decompile.c.

References CodepageAttrstartNames, ERR_INTERNAL_BAD_PARAM, tagCODEPAGE_ATTRSTART_NAME_LIST::m_dtd_id, tagCODEPAGE_ATTRSTART_NAME_LIST::m_name, tagCODEPAGE_ATTRSTART_NAME_LIST::m_page, tagCODEPAGE_ATTRSTART_NAME_LIST::m_tag, tagCODEPAGE_ATTRSTART_NAME_LIST::m_valueprefix, and ParseError().

Referenced by DumpNode().

01564 {
01565     int i = 0;
01566 
01567     /* Check Parameters */
01568     if (!value)
01569     {
01570         ParseError(ERR_INTERNAL_BAD_PARAM);
01571     }
01572 
01573     /* Search the tag list for a match */
01574     while (CodepageAttrstartNames[i].m_name)
01575     {
01576         if ((CodepageAttrstartNames[i].m_dtd_id == dtd_id) &&
01577             (CodepageAttrstartNames[i].m_page == page) &&
01578             (CodepageAttrstartNames[i].m_tag == tag))
01579         {
01580             break;
01581         }
01582 
01583         i++;
01584     }
01585 
01586     /* Duplicate the value because it may be concatenated to */
01587     if (CodepageAttrstartNames[i].m_valueprefix)
01588     {
01589         *value = strdup(CodepageAttrstartNames[i].m_valueprefix);
01590     }
01591     else
01592     {
01593         *value = NULL;
01594     }
01595 
01596     /* Return the tag name */
01597     return CodepageAttrstartNames[i].m_name;
01598 }

Here is the call graph for this function:

void CodepageAttrvalueName WBXML_CODEPAGE  page,
WBXML_TAG  tag,
char **  value
[static]
 

Definition at line 1600 of file decompile.c.

References CodepageAttrvalueNames, ERR_INTERNAL_BAD_PARAM, tagCODEPAGE_ATTRVALUE_NAME_LIST::m_dtd_id, tagCODEPAGE_ATTRVALUE_NAME_LIST::m_name, tagCODEPAGE_ATTRVALUE_NAME_LIST::m_page, tagCODEPAGE_ATTRVALUE_NAME_LIST::m_tag, ParseError(), and realloc.

Referenced by DumpNode().

01601 {
01602     int i = 0;
01603 
01604     /* Check Parameters */
01605     if (!value)
01606     {
01607         ParseError(ERR_INTERNAL_BAD_PARAM);
01608     }
01609 
01610     /* Search the tag list for a match */
01611     while (CodepageAttrvalueNames[i].m_name)
01612     {
01613         if ((CodepageAttrvalueNames[i].m_dtd_id == dtd_id) &&
01614             (CodepageAttrvalueNames[i].m_page == page) &&
01615             (CodepageAttrvalueNames[i].m_tag == tag))
01616         {
01617             break;
01618         }
01619 
01620         i++;
01621     }
01622 
01623     /* concatenate the value */
01624     if (CodepageAttrvalueNames[i].m_name)
01625     {
01626         if (*value)
01627         {
01628             *value = realloc(*value, strlen(*value) + strlen(CodepageAttrvalueNames[i].m_name) + 1);
01629             strcat(*value, CodepageAttrvalueNames[i].m_name);
01630         }
01631         else
01632         {
01633             *value = strdup(CodepageAttrvalueNames[i].m_name);
01634         }
01635     }
01636 }

Here is the call graph for this function:

const char* CodepageTagName WBXML_CODEPAGE  page,
WBXML_TAG  tag
[static]
 

Definition at line 1540 of file decompile.c.

References CodepageTagNames, tagCODEPAGE_TAG_NAME_LIST::m_dtd_id, tagCODEPAGE_TAG_NAME_LIST::m_name, tagCODEPAGE_TAG_NAME_LIST::m_page, and tagCODEPAGE_TAG_NAME_LIST::m_tag.

Referenced by DumpNode().

01541 {
01542     int i = 0;
01543 
01544     /* Strip flags off of the tag */
01545     tag = (WBXML_TAG) (tag & CODEPAGE_TAG_MASK);
01546 
01547     /* Search the tag list for a match */
01548     while (CodepageTagNames[i].m_name)
01549     {
01550         if ((CodepageTagNames[i].m_dtd_id == dtd_id) &&
01551             (CodepageTagNames[i].m_page == page) &&
01552             (CodepageTagNames[i].m_tag == tag))
01553         {
01554             break;
01555         }
01556 
01557         i++;
01558     }
01559 
01560     return CodepageTagNames[i].m_name;
01561 }

const char* DTDTypeName long  dtdnum  )  [static]
 

Definition at line 1522 of file decompile.c.

References DTDTypeList, tagDTD_TYPE_LIST::m_id, and tagDTD_TYPE_LIST::m_name.

Referenced by DumpNode().

01523 {
01524     int i = 0;
01525 
01526     /* Search the DTD list for a match */
01527     while (DTDTypeList[i].m_name)
01528     {
01529         if (DTDTypeList[i].m_id == dtdnum)
01530         {
01531             break;
01532         }
01533 
01534         i++;
01535     }
01536 
01537     return DTDTypeList[i].m_name;
01538 }

void DumpNode P_WBXML_NODE  node,
int  indent,
BOOL inattrs,
BOOL  hascontent,
char **  value
[static]
 

Definition at line 1676 of file decompile.c.

References BOOL, CodepageAttrstartName(), CodepageAttrvalueName(), CodepageTagName(), DTD_NODE_DATA, DTDTypeName(), free, GetStringTableString(), tagWBXML_NODE::m_child, tagWBXML_NODE::m_data, tagWBXML_NODE::m_next, tagWBXML_NODE::m_page, tagWBXML_NODE::m_prev, tagWBXML_NODE::m_type, mb_u_int32_to_long(), NODE_ATTREND, NODE_ATTRSTART, NODE_ATTRSTART_LITERAL, NODE_ATTRVALUE, NODE_CODEPAGE_LITERAL_TAG, NODE_CODEPAGE_TAG, NODE_DTD_TYPE, NODE_STRING, NODE_VARIABLE_INDEX, NODE_VARIABLE_STRING, OutputEncodedString(), P_WBXML_MB_U_INT32, P_WBXML_NODE, P_WBXML_TAG, realloc, and WBXML_TAG.

Referenced by DumpNodes().

01677 {
01678     P_WBXML_NODE curnode = node->m_child;
01679 
01680     WBXML_TAG nodetype = 0;
01681     long dtdnum = 0;
01682 
01683     BOOL bAttributesFollow = FALSE;
01684     BOOL bHasContent = FALSE;
01685 
01686     int i;
01687 
01688     if (!(*inattrs))
01689     {
01690         for (i=0; i<indent; i++)
01691         {
01692             printf(" ");
01693         }
01694     }
01695     else
01696     {
01697         if ((node->m_type != NODE_ATTRVALUE) && (*value))
01698         {
01699             printf("=\"");
01700             OutputEncodedString((unsigned char*) *value);
01701             printf("\"");
01702             free(*value);
01703             *value = NULL;
01704         }
01705     }
01706 
01707     switch (node->m_type)
01708     {
01709         case NODE_DTD_TYPE:
01710             printf("<?xml version=\"1.0\"?>\n<!DOCTYPE wml PUBLIC ");
01711 
01712             dtdnum = mb_u_int32_to_long( &((DTD_NODE_DATA*)node->m_data)->m_dtdnum );
01713             if ( dtdnum == 0)
01714             {
01715                 printf("\"%s\">\n\n", GetStringTableString(node, mb_u_int32_to_long(&((DTD_NODE_DATA*)node->m_data)->m_index)) );
01716             }
01717             else
01718             {
01719                 printf("\"%s\">\n\n", DTDTypeName(dtdnum) );
01720             }
01721             break;
01722 
01723         case NODE_CODEPAGE_TAG:
01724             nodetype = *((P_WBXML_TAG)node->m_data);
01725             if ((nodetype & CODEPAGE_TAG_MASK) == nodetype)
01726             {
01727                 printf("<%s/>\n", CodepageTagName(node->m_page, nodetype));
01728             }
01729             else
01730             {
01731                 if ((nodetype & CODEPAGE_TAG_HAS_CONTENT) == CODEPAGE_TAG_HAS_CONTENT)
01732                 {
01733                     bHasContent = TRUE;
01734                 }
01735 
01736                 if ((nodetype & CODEPAGE_TAG_HAS_ATTRS) == CODEPAGE_TAG_HAS_ATTRS)
01737                 {
01738                     printf("<%s", CodepageTagName(node->m_page, nodetype));
01739                     bAttributesFollow = TRUE;
01740                 }
01741                 else
01742                 {
01743                     printf("<%s>\n", CodepageTagName(node->m_page, nodetype));
01744                 }
01745             }
01746             break;
01747 
01748         case NODE_CODEPAGE_LITERAL_TAG:
01749             printf("<%s>\n", GetStringTableString(node, mb_u_int32_to_long(((P_WBXML_MB_U_INT32)node->m_data))) );
01750             break;
01751 
01752         case NODE_ATTRSTART:
01753             printf(" %s", CodepageAttrstartName(node->m_page, *((P_WBXML_TAG)node->m_data), value) );
01754             break;
01755 
01756         case NODE_ATTRSTART_LITERAL:
01757             printf(" %s", GetStringTableString(node, mb_u_int32_to_long(((P_WBXML_MB_U_INT32)node->m_data))) );
01758             break;
01759 
01760         case NODE_ATTRVALUE:
01761             CodepageAttrvalueName(node->m_page, *((P_WBXML_TAG)node->m_data), value);
01762             break;
01763 
01764         case NODE_ATTREND:
01765             if (!hascontent)
01766             {
01767                 printf("/");
01768             }
01769             printf(">\n");
01770             *inattrs = FALSE;
01771             break;
01772 
01773         case NODE_STRING:
01774             if (*inattrs)
01775             {
01776                 /* concatenate the value */
01777                 if (*value)
01778                 {
01779                     if (node->m_data)
01780                     {
01781                         *value = realloc(*value, strlen(*value) + strlen((char*) node->m_data) + 1);
01782                         strcat(*value, (char*) node->m_data);
01783                     }
01784                 }
01785                 else
01786                 {
01787                     if (node->m_data)
01788                     {
01789                         *value = strdup((char*) node->m_data);
01790                     }
01791                 }
01792             }
01793             else
01794             {
01795                 OutputEncodedString((unsigned char*) node->m_data);
01796                 printf("\n");
01797             }
01798             break;
01799 
01800         case NODE_VARIABLE_STRING:
01801             /* TODO: output variable string */
01802             break;
01803 
01804         case NODE_VARIABLE_INDEX:
01805             /* TODO: output variable string */
01806             break;
01807 
01808         default:
01809             break;
01810     }
01811 
01812     indent += INDENT_SIZE;
01813 
01814     if (curnode)
01815     {
01816         while (curnode->m_next) curnode = curnode->m_next;
01817 
01818         while (curnode)
01819         {
01820             DumpNode(curnode, indent, &bAttributesFollow, bHasContent, value);
01821             curnode = curnode->m_prev;
01822         }
01823     }
01824 
01825     indent -= INDENT_SIZE;
01826 
01827     /* Output the element end if we have one */
01828     if ((nodetype & CODEPAGE_TAG_HAS_CONTENT) == CODEPAGE_TAG_HAS_CONTENT)
01829     {
01830         for (i=0; i<indent; i++)
01831         {
01832             printf(" ");
01833         }
01834 
01835         switch (node->m_type)
01836         {
01837             case NODE_CODEPAGE_TAG:
01838                 printf("</%s>\n", CodepageTagName(node->m_page, *((P_WBXML_TAG)node->m_data)) );
01839                 break;
01840 
01841             case NODE_CODEPAGE_LITERAL_TAG:
01842                 printf("</%s>\n", GetStringTableString(node, mb_u_int32_to_long(((P_WBXML_MB_U_INT32)node->m_data))) );
01843                 break;
01844 
01845             default:
01846                 break;
01847         }
01848     }
01849 }

Here is the call graph for this function:

void DumpNodes P_WBXML_INFO  buffer  )  [static]
 

Definition at line 1851 of file decompile.c.

References BOOL, DumpNode(), FALSE, tagWBXML_NODE::m_next, tagWBXML_NODE::m_prev, tagWBXML_INFO::m_tree, P_WBXML_INFO, and P_WBXML_NODE.

Referenced by main().

01852 {
01853     P_WBXML_NODE curnode = buffer->m_tree;
01854     BOOL bAttrsFollow = FALSE;
01855     char* value = NULL;
01856 
01857     if (curnode)
01858     {
01859         while (curnode->m_next) curnode = curnode->m_next;
01860 
01861         while (curnode)
01862         {
01863             DumpNode(curnode, 0, &bAttrsFollow, FALSE, &value);
01864             curnode = curnode->m_prev;
01865         }
01866     }
01867 }

Here is the call graph for this function:

long FileSize FILE *  file  )  [static]
 

Definition at line 1462 of file decompile.c.

References file.

Referenced by ReadBinary().

01463 {
01464     long curpos = ftell(file);
01465     long endpos;
01466     fseek(file, 0, SEEK_END);
01467     endpos = ftell(file);
01468     fseek(file, curpos, SEEK_SET);
01469 
01470     return endpos;
01471 }

void Free P_WBXML_INFO  buffer  )  [static]
 

Definition at line 1447 of file decompile.c.

References free, FreeNode(), tagWBXML_INFO::m_curpos, tagWBXML_INFO::m_length, tagWBXML_INFO::m_start, tagWBXML_INFO::m_tree, and P_WBXML_INFO.

Referenced by main().

01448 {
01449     if (buffer->m_start)
01450     {
01451         free(buffer->m_start);
01452         buffer->m_start = NULL;
01453     }
01454 
01455     buffer->m_curpos = NULL;
01456     buffer->m_length = 0;
01457 
01458     FreeNode(buffer->m_tree);
01459     buffer->m_tree = NULL;
01460 }

Here is the call graph for this function:

void FreeNode P_WBXML_NODE  node  )  [static]
 

Definition at line 389 of file decompile.c.

References free, tagWBXML_NODE::m_child, tagWBXML_NODE::m_next, and P_WBXML_NODE.

Referenced by Free().

00390 {
00391     if (node)
00392     {
00393         if (node->m_child)
00394         {
00395             FreeNode(node->m_child);
00396         }
00397 
00398         if (node->m_next)
00399         {
00400             FreeNode(node->m_next);
00401         }
00402 
00403         free(node);
00404     }
00405 }

const char* GetStringTableString P_WBXML_NODE  node,
long  index
[static]
 

Definition at line 1638 of file decompile.c.

References tagWBXML_NODE::m_data, tagWBXML_NODE::m_next, tagWBXML_NODE::m_parent, tagWBXML_NODE::m_prev, tagWBXML_NODE::m_type, mb_u_int32_to_long(), P_WBXML_NODE, and P_WBXML_STRING_TABLE.

Referenced by DumpNode().

01639 {
01640     /* Find the string table node */
01641 
01642     P_WBXML_NODE pStringsNode = node;
01643 
01644     while (pStringsNode->m_parent)
01645     {
01646         pStringsNode = pStringsNode->m_parent;
01647     }
01648 
01649     while (pStringsNode->m_next)
01650     {
01651         pStringsNode = pStringsNode->m_next;
01652     }
01653 
01654     while (pStringsNode->m_prev && pStringsNode->m_type != NODE_STRING_TABLE)
01655     {
01656         pStringsNode = pStringsNode->m_prev;
01657     }
01658 
01659     if (pStringsNode->m_type != NODE_STRING_TABLE)
01660     {
01661         return "!!NO STRING TABLE!!";
01662     }
01663 
01664     /* Find the indexed string */
01665 
01666     if ((index >= 0) && (index < mb_u_int32_to_long(&((P_WBXML_STRING_TABLE)pStringsNode->m_data)->m_length)))
01667     {
01668         return (const char*) &(((P_WBXML_STRING_TABLE)pStringsNode->m_data)->m_strings[index]);
01669     }
01670     else
01671     {
01672         return "!!STRING TABLE INDEX TOO LARGE!!";
01673     }
01674 }

Here is the call graph for this function:

void Init P_WBXML_INFO  buffer  )  [static]
 

Definition at line 1425 of file decompile.c.

References tagWBXML_INFO::m_curnode, tagWBXML_INFO::m_curpage, tagWBXML_INFO::m_curpos, tagWBXML_INFO::m_length, tagWBXML_INFO::m_start, tagWBXML_INFO::m_tree, and P_WBXML_INFO.

Referenced by main().

01426 {
01427     buffer->m_start = NULL;
01428     buffer->m_curpos = NULL;
01429     buffer->m_length = 0;
01430     buffer->m_tree = NULL;
01431     buffer->m_curnode = NULL;
01432     buffer->m_curpage = 0;
01433 }

BOOL Is_attrValue P_WBXML_INFO  buffer  ) 
 

Definition at line 612 of file decompile.c.

References BOOL, CP_TAG_ATTRVALUE, Is_entity(), Is_extension(), Is_opaque(), Is_pi(), Is_string(), Is_switchPage(), IsCodepageTag(), tagWBXML_INFO::m_curpos, P_WBXML_INFO, and WBXML_INFO.

Referenced by Read_attribute(), and Read_pi().

00613 {
00614     WBXML_INFO tmpbuffer;
00615     memcpy(&tmpbuffer, buffer, sizeof(WBXML_INFO));
00616     tmpbuffer.m_curpos += SWITCHPAGE_SIZE;
00617 
00618     return ((Is_switchPage(buffer) && IsCodepageTag(&tmpbuffer, CP_TAG_ATTRVALUE)) ||
00619             IsCodepageTag(buffer, CP_TAG_ATTRVALUE) ||
00620             Is_string(buffer) ||
00621             Is_extension(buffer) ||
00622             Is_entity(buffer) ||
00623             Is_pi(buffer) ||
00624             Is_opaque(buffer));
00625 }

Here is the call graph for this function:

BOOL Is_entity P_WBXML_INFO  buffer  ) 
 

Definition at line 675 of file decompile.c.

References BOOL, IsTag(), P_WBXML_INFO, and TAG_ENTITY.

Referenced by Is_attrValue(), Read_attrValue(), and Read_content().

00676 {
00677     return IsTag(buffer, TAG_ENTITY);
00678 }

Here is the call graph for this function:

BOOL Is_extension P_WBXML_INFO  buffer  ) 
 

Definition at line 627 of file decompile.c.

References BOOL, Is_switchPage(), IsTag(), tagWBXML_INFO::m_curpos, P_WBXML_INFO, TAG_EXT_0, TAG_EXT_1, TAG_EXT_2, TAG_EXT_I_0, TAG_EXT_I_1, TAG_EXT_I_2, TAG_EXT_T_0, TAG_EXT_T_1, TAG_EXT_T_2, and WBXML_INFO.

Referenced by Is_attrValue(), Read_attrValue(), and Read_content().

00628 {
00629     WBXML_INFO tmpbuffer;
00630     memcpy(&tmpbuffer, buffer, sizeof(WBXML_INFO));
00631     tmpbuffer.m_curpos += SWITCHPAGE_SIZE;
00632 
00633     return ((Is_switchPage(buffer) &&
00634              (IsTag(&tmpbuffer, TAG_EXT_0) ||
00635               IsTag(&tmpbuffer, TAG_EXT_1) ||
00636               IsTag(&tmpbuffer, TAG_EXT_2) ||
00637               IsTag(&tmpbuffer, TAG_EXT_T_0) ||
00638               IsTag(&tmpbuffer, TAG_EXT_T_1) ||
00639               IsTag(&tmpbuffer, TAG_EXT_T_2) ||
00640               IsTag(&tmpbuffer, TAG_EXT_I_0) ||
00641               IsTag(&tmpbuffer, TAG_EXT_I_1) ||
00642               IsTag(&tmpbuffer, TAG_EXT_I_2))) ||
00643             (IsTag(buffer, TAG_EXT_0) ||
00644              IsTag(buffer, TAG_EXT_1) ||
00645              IsTag(buffer, TAG_EXT_2) ||
00646              IsTag(buffer, TAG_EXT_T_0) ||
00647              IsTag(buffer, TAG_EXT_T_1) ||
00648              IsTag(buffer, TAG_EXT_T_2) ||
00649              IsTag(buffer, TAG_EXT_I_0) ||
00650              IsTag(buffer, TAG_EXT_I_1) ||
00651              IsTag(buffer, TAG_EXT_I_2)));
00652 }

Here is the call graph for this function:

BOOL Is_inline P_WBXML_INFO  buffer  ) 
 

Definition at line 665 of file decompile.c.

References BOOL, IsTag(), P_WBXML_INFO, and TAG_STR_I.

Referenced by Is_string(), and Read_string().

00666 {
00667     return IsTag(buffer, TAG_STR_I);
00668 }

Here is the call graph for this function:

BOOL Is_opaque P_WBXML_INFO  buffer  ) 
 

Definition at line 685 of file decompile.c.

References BOOL, IsTag(), P_WBXML_INFO, and TAG_OPAQUE.

Referenced by Is_attrValue(), Read_attrValue(), and Read_content().

00686 {
00687     return IsTag(buffer, TAG_OPAQUE);
00688 }

Here is the call graph for this function:

BOOL Is_pi P_WBXML_INFO  buffer  ) 
 

Definition at line 680 of file decompile.c.

References BOOL, IsTag(), P_WBXML_INFO, and TAG_PI.

Referenced by Is_attrValue(), Read_body(), and Read_content().

00681 {
00682     return IsTag(buffer, TAG_PI);
00683 }

Here is the call graph for this function:

BOOL Is_string P_WBXML_INFO  buffer  ) 
 

Definition at line 654 of file decompile.c.

References BOOL, Is_inline(), Is_tableref(), and P_WBXML_INFO.

Referenced by Is_attrValue(), Read_attrValue(), and Read_content().

00655 {
00656     return (Is_inline(buffer) ||
00657             Is_tableref(buffer));
00658 }

Here is the call graph for this function:

BOOL Is_switchPage P_WBXML_INFO  buffer  ) 
 

Definition at line 660 of file decompile.c.

References BOOL, IsTag(), P_WBXML_INFO, and TAG_SWITCH_PAGE.

Referenced by Is_attrValue(), Is_extension(), Read_attrStart(), Read_attrValue(), Read_element(), and Read_extension().

00661 {
00662     return IsTag(buffer, TAG_SWITCH_PAGE);
00663 }

Here is the call graph for this function:

BOOL Is_tableref P_WBXML_INFO  buffer  ) 
 

Definition at line 670 of file decompile.c.

References BOOL, IsTag(), P_WBXML_INFO, and TAG_STR_T.

Referenced by Is_string(), and Read_string().

00671 {
00672     return IsTag(buffer, TAG_STR_T);
00673 }

Here is the call graph for this function:

BOOL Is_zero P_WBXML_INFO  buffer  ) 
 

Definition at line 690 of file decompile.c.

References BOOL, BytesLeft(), ERR_END_OF_DATA, ERR_INTERNAL_BAD_PARAM, tagWBXML_INFO::m_curpos, P_WBXML_INFO, ParseError(), and result.

Referenced by Read_publicid().

00691 {
00692   BOOL result = FALSE;
00693 
00694   if (buffer) 
00695   {
00696     if (BytesLeft(buffer) >= 1) 
00697     {
00698       result = ((*buffer->m_curpos) == 0);
00699     }
00700     else
00701     {
00702       ParseError(ERR_END_OF_DATA);
00703     }
00704   }
00705   else
00706   {
00707     ParseError(ERR_INTERNAL_BAD_PARAM);
00708   }
00709 
00710   return result;
00711 }

Here is the call graph for this function:

BOOL IsCodepageTag P_WBXML_INFO  buffer,
CP_TAG_TYPE  type
 

Definition at line 594 of file decompile.c.

References BOOL, CP_TAG_ATTRSTART, CP_TAG_ATTRVALUE, CP_TAG_TAG, tagWBXML_INFO::m_curpos, P_WBXML_INFO, result, and WBXML_U_INT8.

Referenced by Is_attrValue(), Read_attrStart(), Read_attrValue(), and Read_stag().

00595 {
00596     WBXML_U_INT8 result = *(buffer->m_curpos);
00597 
00598     /* NOTE THAT THESE ARE NOT UNIQUE! */
00599     switch (type)
00600     {
00601         case CP_TAG_TAG:
00602             return TRUE;
00603         case CP_TAG_ATTRSTART:
00604             return ((result & 0x80) != 0x80);
00605         case CP_TAG_ATTRVALUE:
00606             return ((result & 0x80) == 0x80);
00607         default:
00608             return FALSE;
00609     }
00610 }

BOOL IsTag P_WBXML_INFO  buffer,
WBXML_TAG  tag
 

Definition at line 570 of file decompile.c.

References BOOL, BytesLeft(), ERR_INTERNAL_BAD_PARAM, tagWBXML_INFO::m_curpos, P_WBXML_INFO, ParseError(), result, and WBXML_TAG.

Referenced by Is_entity(), Is_extension(), Is_inline(), Is_opaque(), Is_pi(), Is_switchPage(), Is_tableref(), Read_attrStart(), Read_element(), Read_extension(), and Read_stag().

00571 {
00572   BOOL result = FALSE;
00573 
00574   if (buffer)
00575   {
00576     if (BytesLeft(buffer) >= sizeof(WBXML_TAG))
00577     {
00578       result = ((*((WBXML_TAG*) buffer->m_curpos)) == tag);
00579     }
00580     else
00581     {
00582         /* No more data, so nope, not this tag */
00583       result = FALSE;
00584     }
00585   }
00586   else
00587   {
00588     ParseError(ERR_INTERNAL_BAD_PARAM);
00589   }
00590 
00591   return result;
00592 }

Here is the call graph for this function:

int main int  argc,
char **  argv
 

Definition at line 1869 of file decompile.c.

References DumpNodes(), ERR_FILE_NOT_FOUND, file, Free(), Init(), ParseError(), Read_start(), ReadBinary(), and WBXML_INFO.

01870 {
01871     WBXML_INFO buffer;
01872     FILE* file;
01873 
01874     if (argc < 2)
01875     {
01876         file = stdin;
01877     }
01878     else
01879     {
01880             file = fopen(argv[1], "r");
01881         if (!file)
01882         {
01883             ParseError(ERR_FILE_NOT_FOUND);
01884         }
01885     }
01886 
01887     Init(&buffer);
01888     ReadBinary(&buffer, file);
01889     Read_start(&buffer);
01890     DumpNodes(&buffer);
01891     Free(&buffer);
01892 
01893     return 0;
01894 }

Here is the call graph for this function:

long mb_u_int32_to_long P_WBXML_MB_U_INT32  value  ) 
 

Definition at line 873 of file decompile.c.

References ERR_INTERNAL_BAD_PARAM, ParseError(), and result.

Referenced by DumpNode(), GetStringTableString(), Read_opaque(), and Read_strtbl().

00874 {
00875   long result = 0;
00876 
00877   if (value)
00878   {
00879     int i;
00880     for (i = 0; i < MAX_MB_U_INT32_BYTES; i++)
00881     {
00882       result <<= 7;
00883       result |= ((*value)[i] & 0x7f);
00884 
00885       if ( !( (*value)[i] & 0x80 ) )
00886         break;
00887     }
00888   }
00889   else
00890   {
00891     ParseError(ERR_INTERNAL_BAD_PARAM);
00892   }
00893 
00894   return result;
00895 }

Here is the call graph for this function:

void Message char *  msg  ) 
 

Definition at line 485 of file decompile.c.

Referenced by ParseError(), and ParseWarning().

00486 {
00487   printf("%s\n", msg);
00488 }

P_WBXML_NODE NewNode P_WBXML_INFO  buffer,
WBXML_NODE_TYPE  type
[static]
 

Definition at line 320 of file decompile.c.

References ERR_INTERNAL_BAD_PARAM, ERR_NOT_ENOUGH_MEMORY, tagWBXML_NODE::m_child, tagWBXML_INFO::m_curnode, tagWBXML_INFO::m_curpage, tagWBXML_NODE::m_data, tagWBXML_NODE::m_next, tagWBXML_NODE::m_page, tagWBXML_NODE::m_parent, tagWBXML_NODE::m_prev, tagWBXML_INFO::m_tree, tagWBXML_NODE::m_type, malloc, P_WBXML_INFO, P_WBXML_NODE, ParseError(), and WBXML_NODE.

Referenced by AddAttrEndNode(), AddAttrStartLiteralNode(), AddAttrStartNode(), AddAttrValueNode(), AddCodepageLiteralTagNode(), AddCodepageTagNode(), AddDTDNode(), AddStringNode(), and AddStringTableNode().

00321 {
00322     if (buffer)
00323     {
00324         P_WBXML_NODE newnode = malloc(sizeof(WBXML_NODE));
00325 
00326         if (newnode)
00327         {
00328             newnode->m_prev = NULL;
00329             newnode->m_child = NULL;
00330 
00331             if (buffer->m_curnode)
00332             {
00333                 /* Insert this node as the first child of the current node */
00334                 newnode->m_parent = buffer->m_curnode;
00335                 newnode->m_next = buffer->m_curnode->m_child;
00336 
00337                 if (buffer->m_curnode->m_child)
00338                 {
00339                     ((P_WBXML_NODE)buffer->m_curnode->m_child)->m_prev = newnode;
00340                 }
00341 
00342                 buffer->m_curnode->m_child = newnode;
00343             }
00344             else
00345             {
00346                 /* Insert this node at the top of the tree */
00347                 newnode->m_parent = NULL;
00348                 newnode->m_next = buffer->m_tree;
00349                 
00350                 if (buffer->m_tree)
00351                 {
00352                     buffer->m_tree->m_prev = newnode;
00353                 }
00354 
00355                 buffer->m_tree = newnode;
00356             }
00357 
00358             newnode->m_page = buffer->m_curpage;
00359             newnode->m_type = type;
00360             newnode->m_data = NULL;
00361         }
00362         else
00363         {
00364             ParseError(ERR_NOT_ENOUGH_MEMORY);
00365         }
00366 
00367         return newnode;
00368     }
00369     else
00370     {
00371         ParseError(ERR_INTERNAL_BAD_PARAM);
00372     }
00373 
00374     return NULL;
00375 }

Here is the call graph for this function:

void OutputEncodedString const unsigned char *  str  )  [static]
 

Definition at line 897 of file decompile.c.

Referenced by DumpNode().

00898 {
00899     /* Work our way down the string looking for illegal chars */
00900     while (*str != 0)
00901     {
00902         if ((*str < 0x20) || (*str > 0x7F))
00903         {
00904             /* Out of range... encode */
00905             printf("&#x%02x;", *str);
00906         }
00907         else
00908         {
00909             switch (*str)
00910             {
00911                 case '<':
00912                 case '>':
00913                 case '&':
00914                 case '\'':
00915                 case '\"':
00916                     /* Special symbol... encode */
00917                     printf("&#x%2x", *str);
00918                     break;
00919 
00920                 default:
00921                     printf("%c", *str);
00922                     break;
00923             }
00924         }
00925 
00926         str++;
00927     }
00928 }

void ParseError WBXML_PARSE_ERROR  error  ) 
 

Definition at line 490 of file decompile.c.

References ERR_END_OF_DATA, ERR_FILE_NOT_FOUND, ERR_FILE_NOT_READ, ERR_INTERNAL_BAD_PARAM, ERR_NOT_ENOUGH_MEMORY, ERR_TAG_NOT_FOUND, error(), and Message().

Referenced by BytesLeft(), CodepageAttrstartName(), CodepageAttrvalueName(), Is_zero(), IsTag(), main(), mb_u_int32_to_long(), NewNode(), Read_attrStart(), Read_attrValue(), Read_bytes(), Read_extension(), Read_mb_u_int32(), Read_stag(), Read_string(), Read_termstr_rtn(), Read_u_int8(), Read_zero(), ReadBinary(), ReadCodepageTag(), and ReadFixedTag().

00491 {
00492   switch (error)
00493   {
00494     case ERR_END_OF_DATA:
00495       Message("Input stream is incomplete (EOF).");
00496       break;
00497 
00498     case ERR_INTERNAL_BAD_PARAM:
00499       Message("Internal error: Bad parameter.");
00500       break;
00501 
00502     case ERR_TAG_NOT_FOUND:
00503       Message("Tag not found.");
00504       break;
00505         
00506     case ERR_FILE_NOT_FOUND:
00507       Message("File not found.");
00508       break;
00509 
00510     case ERR_FILE_NOT_READ:
00511       Message("File read error.");
00512       break;
00513 
00514     case ERR_NOT_ENOUGH_MEMORY:
00515       Message("Not enough memory");
00516       break;
00517 
00518     default:
00519       Message("Unknown error.");
00520       break;
00521   }
00522 
00523   exit(error);
00524 }

Here is the call graph for this function:

void ParseWarning WBXML_PARSE_WARNING  warning  ) 
 

Definition at line 526 of file decompile.c.

References Message(), WARN_FUTURE_EXPANSION_EXT_0, WARN_FUTURE_EXPANSION_EXT_1, and WARN_FUTURE_EXPANSION_EXT_2.

Referenced by Read_extension().

00527 {
00528   switch (warning)
00529   {
00530     case WARN_FUTURE_EXPANSION_EXT_0:
00531       Message("Token EXT_0 encountered. This token is reserved for future expansion.");
00532       break;
00533 
00534     case WARN_FUTURE_EXPANSION_EXT_1:
00535       Message("Token EXT_1 encountered. This token is reserved for future expansion.");
00536       break;
00537 
00538     case WARN_FUTURE_EXPANSION_EXT_2:
00539       Message("Token EXT_2 encountered. This token is reserved for future expansion.");
00540       break;
00541 
00542     default:
00543       Message("Unknown warning.");
00544       break;
00545   }
00546 }

Here is the call graph for this function:

void Read_attribute P_WBXML_INFO  buffer  ) 
 

Definition at line 1067 of file decompile.c.

References Is_attrValue(), P_WBXML_INFO, Read_attrStart(), and Read_attrValue().

Referenced by Read_element().

01068 {
01069     Read_attrStart(buffer);
01070 
01071     while (Is_attrValue(buffer))
01072     {
01073         Read_attrValue(buffer);
01074     }
01075 }

Here is the call graph for this function:

void Read_attrStart P_WBXML_INFO  buffer  ) 
 

Definition at line 1077 of file decompile.c.

References AddAttrStartLiteralNode(), AddAttrStartNode(), CP_TAG_ATTRSTART, ERR_TAG_NOT_FOUND, Is_switchPage(), IsCodepageTag(), IsTag(), P_WBXML_INFO, ParseError(), Read_index(), Read_switchPage(), ReadCodepageTag(), ReadFixedTag(), TAG_LITERAL, WBXML_MB_U_INT32, and WBXML_TAG.

Referenced by Read_attribute(), and Read_pi().

01078 {
01079   if (Is_switchPage(buffer))
01080   {
01081     WBXML_TAG tag;
01082     Read_switchPage(buffer);
01083     tag = ReadCodepageTag(buffer, CP_TAG_ATTRSTART);
01084 
01085     AddAttrStartNode(buffer, tag);
01086   }
01087   else if (IsCodepageTag(buffer, CP_TAG_ATTRSTART))
01088   {
01089     WBXML_TAG tag;
01090     tag = ReadCodepageTag(buffer, CP_TAG_ATTRSTART);
01091 
01092     AddAttrStartNode(buffer, tag);
01093   }
01094   else if (IsTag(buffer, TAG_LITERAL))
01095   {
01096     WBXML_MB_U_INT32 index;
01097 
01098     ReadFixedTag(buffer, TAG_LITERAL);
01099     Read_index(buffer, &index);
01100 
01101     AddAttrStartLiteralNode(buffer, index);
01102   }
01103   else
01104   {
01105     ParseError(ERR_TAG_NOT_FOUND);
01106   }
01107 }

Here is the call graph for this function:

void Read_attrValue P_WBXML_INFO  buffer  ) 
 

Definition at line 1109 of file decompile.c.

References AddAttrValueNode(), CP_TAG_ATTRVALUE, ERR_TAG_NOT_FOUND, Is_entity(), Is_extension(), Is_opaque(), Is_string(), Is_switchPage(), IsCodepageTag(), P_WBXML_INFO, ParseError(), Read_entity(), Read_extension(), Read_opaque(), Read_string(), Read_switchPage(), ReadCodepageTag(), and WBXML_TAG.

Referenced by Read_attribute(), and Read_pi().

01110 {
01111   if (Is_switchPage(buffer))
01112   {
01113     WBXML_TAG tag;
01114     Read_switchPage(buffer);
01115     tag = ReadCodepageTag(buffer, CP_TAG_ATTRVALUE);
01116     AddAttrValueNode(buffer, tag);
01117   }
01118   else if (IsCodepageTag(buffer, CP_TAG_ATTRVALUE))
01119   {
01120     WBXML_TAG tag;
01121     tag = ReadCodepageTag(buffer, CP_TAG_ATTRVALUE);
01122     AddAttrValueNode(buffer, tag);
01123   }
01124   else if (Is_string(buffer))
01125   {
01126     Read_string(buffer);
01127   }
01128   else if (Is_extension(buffer))
01129   {
01130     Read_extension(buffer);
01131   }
01132   else if (Is_entity(buffer))
01133   {
01134     Read_entity(buffer);
01135   }
01136   else if (Is_opaque(buffer))
01137   {
01138     Read_opaque(buffer);
01139   }
01140   else
01141   {
01142     ParseError(ERR_TAG_NOT_FOUND);
01143   }
01144 }

Here is the call graph for this function:

void Read_body P_WBXML_INFO  buffer  ) 
 

Definition at line 953 of file decompile.c.

References Is_pi(), P_WBXML_INFO, Read_element(), and Read_pi().

Referenced by Read_start().

00954 {
00955   while (Is_pi(buffer))
00956   {
00957     Read_pi(buffer);
00958   }
00959 
00960   Read_element(buffer);
00961 
00962   while (Is_pi(buffer))
00963   {
00964     Read_pi(buffer);
00965   }
00966 }

Here is the call graph for this function:

void Read_bytes P_WBXML_INFO  buffer,
WBXML_LENGTH  length,
P_WBXML_BYTES  result
 

Definition at line 765 of file decompile.c.

References BytesLeft(), ERR_END_OF_DATA, ERR_INTERNAL_BAD_PARAM, tagWBXML_INFO::m_curpos, malloc, P_WBXML_INFO, ParseError(), and result.

Referenced by Read_opaque(), and Read_strtbl().

00766 {
00767   if (buffer && result)
00768   {
00769     if (BytesLeft(buffer) >= length) 
00770     {
00771       *result = (WBXML_BYTES) malloc(length*sizeof(unsigned char));
00772       memcpy(*result, buffer->m_curpos, length);
00773       buffer->m_curpos += length;
00774     }
00775     else
00776     {
00777       ParseError(ERR_END_OF_DATA);
00778     }
00779   }
00780   else
00781   {
00782     ParseError(ERR_INTERNAL_BAD_PARAM);
00783   }
00784 }

Here is the call graph for this function:

void Read_charset P_WBXML_INFO  buffer  ) 
 

Definition at line 1334 of file decompile.c.

References P_WBXML_INFO, Read_mb_u_int32(), result, and WBXML_MB_U_INT32.

Referenced by Read_start().

01335 {
01336   WBXML_MB_U_INT32 result;
01337 
01338   Read_mb_u_int32(buffer, &result);
01339 }

Here is the call graph for this function:

void Read_content P_WBXML_INFO  buffer  ) 
 

Definition at line 1011 of file decompile.c.

References Is_entity(), Is_extension(), Is_opaque(), Is_pi(), Is_string(), P_WBXML_INFO, Read_element(), Read_entity(), Read_extension(), Read_opaque(), Read_pi(), and Read_string().

Referenced by Read_element().

01012 {
01013     if (Is_string(buffer))
01014     {
01015         Read_string(buffer);
01016     }
01017     else if (Is_extension(buffer))
01018     {
01019         Read_extension(buffer);
01020     }
01021     else if (Is_entity(buffer))
01022     {
01023         Read_entity(buffer);
01024     }
01025     else if (Is_pi(buffer))
01026     {
01027         Read_pi(buffer);
01028     }
01029     else if (Is_opaque(buffer))
01030     {
01031         Read_opaque(buffer);
01032     }
01033     else
01034     {
01035         /* Assume it is an element */
01036         Read_element(buffer);
01037     }
01038 }

Here is the call graph for this function:

void Read_element P_WBXML_INFO  buffer  ) 
 

Definition at line 968 of file decompile.c.

References AddAttrEndNode(), Is_switchPage(), IsTag(), tagWBXML_NODE::m_child, tagWBXML_INFO::m_curnode, tagWBXML_NODE::m_parent, tagWBXML_INFO::m_tree, P_WBXML_INFO, Read_attribute(), Read_content(), Read_stag(), Read_switchPage(), ReadFixedTag(), TAG_END, and WBXML_TAG.

Referenced by Read_body(), and Read_content().

00969 {
00970   WBXML_TAG stagvalue = 0;
00971 
00972   if (Is_switchPage(buffer))
00973   {
00974     Read_switchPage(buffer);
00975   }
00976 
00977   stagvalue = Read_stag(buffer);
00978 
00979   /* move the current node down to this one in the tree */
00980   if (buffer->m_curnode)
00981       buffer->m_curnode = buffer->m_curnode->m_child;
00982   else buffer->m_curnode = buffer->m_tree;
00983 
00984   if ((stagvalue & CODEPAGE_TAG_HAS_ATTRS) == CODEPAGE_TAG_HAS_ATTRS)
00985   {
00986     do
00987     {
00988       Read_attribute(buffer);
00989 
00990     } while (!IsTag(buffer, TAG_END));
00991 
00992     ReadFixedTag(buffer, TAG_END);
00993 
00994     AddAttrEndNode(buffer);
00995   }
00996 
00997   if ((stagvalue & CODEPAGE_TAG_HAS_CONTENT) == CODEPAGE_TAG_HAS_CONTENT)
00998   {
00999     while (!IsTag(buffer, TAG_END))
01000     {
01001       Read_content(buffer);
01002     }
01003 
01004     ReadFixedTag(buffer, TAG_END);
01005   }
01006 
01007   /* move the current node back up one */
01008   buffer->m_curnode = buffer->m_curnode->m_parent;
01009 }

Here is the call graph for this function:

void Read_entcode P_WBXML_INFO  buffer  ) 
 

Definition at line 1278 of file decompile.c.

References P_WBXML_INFO, Read_mb_u_int32(), result, and WBXML_MB_U_INT32.

Referenced by Read_entity().

01279 {
01280     WBXML_MB_U_INT32 result;
01281     Read_mb_u_int32(buffer, &result);
01282 }

Here is the call graph for this function:

void Read_entity P_WBXML_INFO  buffer  ) 
 

Definition at line 1272 of file decompile.c.

References P_WBXML_INFO, Read_entcode(), ReadFixedTag(), and TAG_ENTITY.

Referenced by Read_attrValue(), and Read_content().

01273 {
01274     ReadFixedTag(buffer, TAG_ENTITY);
01275     Read_entcode(buffer);
01276 }

Here is the call graph for this function:

void Read_extension P_WBXML_INFO  buffer  ) 
 

Definition at line 1146 of file decompile.c.

References AddVariableIndexNode(), AddVariableStringNode(), ERR_TAG_NOT_FOUND, Is_switchPage(), IsTag(), P_WBXML_INFO, ParseError(), ParseWarning(), Read_index(), Read_switchPage(), Read_termstr_rtn(), ReadFixedTag(), TAG_EXT_0, TAG_EXT_1, TAG_EXT_2, TAG_EXT_I_0, TAG_EXT_I_1, TAG_EXT_I_2, TAG_EXT_T_0, TAG_EXT_T_1, TAG_EXT_T_2, VAR_ESCAPED, VAR_UNCHANGED, VAR_UNESCAPED, WARN_FUTURE_EXPANSION_EXT_0, WARN_FUTURE_EXPANSION_EXT_1, WARN_FUTURE_EXPANSION_EXT_2, and WBXML_MB_U_INT32.

Referenced by Read_attrValue(), and Read_content().

01147 {
01148     if (Is_switchPage(buffer))
01149     {
01150         Read_switchPage(buffer);
01151     }
01152 
01153     if (IsTag(buffer, TAG_EXT_I_0))
01154     {
01155         char* str = NULL;
01156 
01157         ReadFixedTag(buffer, TAG_EXT_I_0);
01158         Read_termstr_rtn(buffer, &str);
01159 
01160         AddVariableStringNode(buffer, str, VAR_ESCAPED); 
01161     }
01162     else if (IsTag(buffer, TAG_EXT_I_1))
01163     {
01164         char* str = NULL;
01165 
01166         ReadFixedTag(buffer, TAG_EXT_I_1);
01167         Read_termstr_rtn(buffer, &str);
01168 
01169         AddVariableStringNode(buffer, str, VAR_UNESCAPED); 
01170     }
01171     else if (IsTag(buffer, TAG_EXT_I_2))
01172     {
01173         char* str = NULL;
01174 
01175         ReadFixedTag(buffer, TAG_EXT_I_2);
01176         Read_termstr_rtn(buffer, &str);
01177 
01178         AddVariableStringNode(buffer, str, VAR_UNCHANGED); 
01179     }
01180     else if (IsTag(buffer, TAG_EXT_T_0))
01181     {
01182         WBXML_MB_U_INT32 index;
01183 
01184         ReadFixedTag(buffer, TAG_EXT_T_0);
01185         Read_index(buffer, &index);
01186 
01187         AddVariableIndexNode(buffer, index, VAR_ESCAPED);
01188     }
01189     else if (IsTag(buffer, TAG_EXT_T_1))
01190     {
01191         WBXML_MB_U_INT32 index;
01192 
01193         ReadFixedTag(buffer, TAG_EXT_T_1);
01194         Read_index(buffer, &index);
01195 
01196         AddVariableIndexNode(buffer, index, VAR_UNESCAPED);
01197     }
01198     else if (IsTag(buffer, TAG_EXT_T_2))
01199     {
01200         WBXML_MB_U_INT32 index;
01201 
01202         ReadFixedTag(buffer, TAG_EXT_T_2);
01203         Read_index(buffer, &index);
01204 
01205         AddVariableIndexNode(buffer, index, VAR_UNCHANGED);
01206     }
01207     else if (IsTag(buffer, TAG_EXT_0))
01208     {
01209         ReadFixedTag(buffer, TAG_EXT_0);
01210 
01211         ParseWarning(WARN_FUTURE_EXPANSION_EXT_0);
01212     }
01213     else if (IsTag(buffer, TAG_EXT_1))
01214     {
01215         ReadFixedTag(buffer, TAG_EXT_1);
01216 
01217         ParseWarning(WARN_FUTURE_EXPANSION_EXT_1);
01218     }
01219     else if (IsTag(buffer, TAG_EXT_2))
01220     {
01221         ReadFixedTag(buffer, TAG_EXT_2);
01222 
01223         ParseWarning(WARN_FUTURE_EXPANSION_EXT_2);
01224     }
01225     else
01226     {
01227         ParseError(ERR_TAG_NOT_FOUND);
01228     }
01229 }

Here is the call graph for this function:

void Read_index P_WBXML_INFO  buffer,
P_WBXML_MB_U_INT32  result
 

Definition at line 1398 of file decompile.c.

References P_WBXML_INFO, Read_mb_u_int32(), and result.

Referenced by Read_attrStart(), Read_extension(), Read_publicid(), Read_stag(), and Read_tableref().

01399 {
01400   Read_mb_u_int32(buffer, result);
01401 }

Here is the call graph for this function:

void Read_inline P_WBXML_INFO  buffer  ) 
 

Definition at line 1258 of file decompile.c.

References P_WBXML_INFO, Read_termstr(), ReadFixedTag(), and TAG_STR_I.

Referenced by Read_string().

01259 {
01260     ReadFixedTag(buffer, TAG_STR_I);
01261     Read_termstr(buffer);
01262 }

Here is the call graph for this function:

void Read_length P_WBXML_INFO  buffer,
P_WBXML_MB_U_INT32  result
 

Definition at line 1403 of file decompile.c.

References P_WBXML_INFO, Read_mb_u_int32(), and result.

Referenced by Read_opaque().

01404 {
01405   Read_mb_u_int32(buffer, result);
01406 }

Here is the call graph for this function:

void Read_mb_u_int32 P_WBXML_INFO  buffer,
P_WBXML_MB_U_INT32  result
 

Definition at line 738 of file decompile.c.

References BytesLeft(), ERR_END_OF_DATA, ERR_INTERNAL_BAD_PARAM, tagWBXML_INFO::m_curpos, P_WBXML_INFO, and ParseError().

Referenced by Read_charset(), Read_entcode(), Read_index(), Read_length(), Read_publicid(), and Read_strtbl().

00739 {
00740   if (buffer && result)
00741   {
00742     int i;
00743     for (i = 0; i < MAX_MB_U_INT32_BYTES; i++)
00744     {
00745       if (BytesLeft(buffer) >= 1)
00746       {
00747         (*result)[i] = *(buffer->m_curpos);
00748         (buffer->m_curpos)++;
00749 
00750         if ( !( (*result)[i] & 0x80 ) )
00751           break;
00752       }
00753       else
00754       {
00755         ParseError(ERR_END_OF_DATA);
00756       }
00757     }
00758   }
00759   else
00760   {
00761     ParseError(ERR_INTERNAL_BAD_PARAM);
00762   }
00763 }

Here is the call graph for this function:

void Read_opaque P_WBXML_INFO  buffer  ) 
 

Definition at line 1297 of file decompile.c.

References data, mb_u_int32_to_long(), P_WBXML_INFO, Read_bytes(), Read_length(), ReadFixedTag(), TAG_OPAQUE, WBXML_BYTES, and WBXML_MB_U_INT32.

Referenced by Read_attrValue(), and Read_content().

01298 {
01299   WBXML_MB_U_INT32 length;
01300   WBXML_BYTES      data;
01301 
01302   ReadFixedTag(buffer, TAG_OPAQUE);
01303   Read_length(buffer, &length);
01304   Read_bytes(buffer, mb_u_int32_to_long(&length), &data);
01305 }

Here is the call graph for this function:

void Read_pageindex P_WBXML_INFO  buffer,
P_WBXML_U_INT8  result
 

Definition at line 1420 of file decompile.c.

References P_WBXML_INFO, Read_u_int8(), and result.

Referenced by Read_switchPage().

01421 {
01422   Read_u_int8(buffer, result);
01423 }

Here is the call graph for this function:

void Read_pi P_WBXML_INFO  buffer  ) 
 

Definition at line 1284 of file decompile.c.

References Is_attrValue(), P_WBXML_INFO, Read_attrStart(), Read_attrValue(), ReadFixedTag(), TAG_END, and TAG_PI.

Referenced by Read_body(), and Read_content().

01285 {
01286   ReadFixedTag(buffer, TAG_PI);
01287   Read_attrStart(buffer);
01288   
01289   while (Is_attrValue(buffer))
01290   {
01291     Read_attrValue(buffer);
01292   }
01293 
01294   ReadFixedTag(buffer, TAG_END);
01295 }

Here is the call graph for this function:

void Read_publicid P_WBXML_INFO  buffer  ) 
 

Definition at line 1314 of file decompile.c.

References AddDTDNode(), Is_zero(), P_WBXML_INFO, Read_index(), Read_mb_u_int32(), result, WBXML_MB_U_INT32, and ZERO_WBXML_MB_U_INT32.

Referenced by Read_start().

01315 {
01316   if (Is_zero(buffer))
01317   {
01318     WBXML_MB_U_INT32 index;
01319 
01320     Read_index(buffer, &index);
01321 
01322     AddDTDNode(buffer, ZERO_WBXML_MB_U_INT32, index);
01323   }
01324   else
01325   {
01326     WBXML_MB_U_INT32 result;
01327 
01328     Read_mb_u_int32(buffer, &result);
01329 
01330     AddDTDNode(buffer, result, ZERO_WBXML_MB_U_INT32);
01331   }
01332 }

Here is the call graph for this function:

WBXML_TAG Read_stag P_WBXML_INFO  buffer  ) 
 

Definition at line 1040 of file decompile.c.

References AddCodepageLiteralTagNode(), AddCodepageTagNode(), CP_TAG_TAG, ERR_TAG_NOT_FOUND, IsCodepageTag(), IsTag(), P_WBXML_INFO, ParseError(), Read_index(), ReadCodepageTag(), ReadFixedTag(), TAG_LITERAL, WBXML_MB_U_INT32, and WBXML_TAG.

Referenced by Read_element().

01041 {
01042     if (IsCodepageTag(buffer, CP_TAG_TAG))
01043     {
01044         WBXML_TAG tag = ReadCodepageTag(buffer, CP_TAG_TAG);
01045 
01046         AddCodepageTagNode(buffer, tag);
01047 
01048         return tag;
01049     }
01050     else if (IsTag(buffer, TAG_LITERAL))
01051     {
01052         WBXML_MB_U_INT32 index;
01053 
01054         ReadFixedTag(buffer, TAG_LITERAL);
01055         Read_index(buffer, &index);
01056 
01057         AddCodepageLiteralTagNode(buffer, index);
01058     }
01059     else
01060     {
01061         ParseError(ERR_TAG_NOT_FOUND);
01062     }
01063 
01064     return 0;
01065 }

Here is the call graph for this function:

void Read_start P_WBXML_INFO  buffer  ) 
 

Definition at line 935 of file decompile.c.

References P_WBXML_INFO, Read_body(), Read_charset(), Read_publicid(), Read_strtbl(), and Read_version().

Referenced by main().

00936 {
00937   Read_version(buffer);
00938   Read_publicid(buffer);
00939   Read_charset(buffer);
00940   Read_strtbl(buffer);
00941   Read_body(buffer);
00942 }

Here is the call graph for this function:

void Read_string P_WBXML_INFO  buffer  ) 
 

Definition at line 1231 of file decompile.c.

References ERR_TAG_NOT_FOUND, Is_inline(), Is_tableref(), P_WBXML_INFO, ParseError(), Read_inline(), and Read_tableref().

Referenced by Read_attrValue(), and Read_content().

01232 {
01233     if (Is_inline(buffer))
01234     {
01235         Read_inline(buffer);
01236     }
01237     else if (Is_tableref(buffer))
01238     {
01239         Read_tableref(buffer);
01240     }
01241     else
01242     {
01243         ParseError(ERR_TAG_NOT_FOUND);
01244     }
01245 }

Here is the call graph for this function:

void Read_strtbl P_WBXML_INFO  buffer  ) 
 

Definition at line 944 of file decompile.c.

References AddStringTableNode(), tagWBXML_STRING_TABLE::m_length, tagWBXML_STRING_TABLE::m_strings, mb_u_int32_to_long(), P_WBXML_INFO, Read_bytes(), Read_mb_u_int32(), result, and WBXML_STRING_TABLE.

Referenced by Read_start().

00945 {
00946   WBXML_STRING_TABLE result;
00947   Read_mb_u_int32(buffer, &(result.m_length));
00948   Read_bytes(buffer, mb_u_int32_to_long(&(result.m_length)), &(result.m_strings));
00949 
00950   AddStringTableNode(buffer, &result);
00951 }

Here is the call graph for this function:

void Read_switchPage P_WBXML_INFO  buffer  ) 
 

Definition at line 1247 of file decompile.c.

References tagWBXML_INFO::m_curpage, P_WBXML_INFO, Read_pageindex(), ReadFixedTag(), TAG_SWITCH_PAGE, and WBXML_U_INT8.

Referenced by Read_attrStart(), Read_attrValue(), Read_element(), and Read_extension().

01248 {
01249   WBXML_U_INT8 pageindex;
01250 
01251   ReadFixedTag(buffer, TAG_SWITCH_PAGE);
01252   Read_pageindex(buffer, &pageindex);
01253 
01254   /* Use the new codepage */
01255   buffer->m_curpage = pageindex;
01256 }

Here is the call graph for this function:

void Read_tableref P_WBXML_INFO  buffer  ) 
 

Definition at line 1264 of file decompile.c.

References P_WBXML_INFO, Read_index(), ReadFixedTag(), TAG_STR_T, and WBXML_MB_U_INT32.

Referenced by Read_string().

01265 {
01266   WBXML_MB_U_INT32 index;
01267 
01268   ReadFixedTag(buffer, TAG_STR_T);
01269   Read_index(buffer, &index);
01270 }

Here is the call graph for this function:

void Read_termstr P_WBXML_INFO  buffer  ) 
 

Definition at line 1387 of file decompile.c.

References AddStringNode(), free, P_WBXML_INFO, and Read_termstr_rtn().

Referenced by Read_inline().

01388 {
01389     char* strbuf = NULL;
01390 
01391     Read_termstr_rtn(buffer, &strbuf);
01392 
01393     AddStringNode(buffer, strbuf);
01394 
01395     free(strbuf);
01396 }

Here is the call graph for this function:

void Read_termstr_rtn P_WBXML_INFO  buffer,
char **  result
 

Definition at line 1341 of file decompile.c.

References BOOL, BytesLeft(), ERR_INTERNAL_BAD_PARAM, free, tagWBXML_INFO::m_curpos, malloc, P_WBXML_INFO, ParseError(), realloc, and result.

Referenced by Read_extension(), and Read_termstr().

01342 {
01343 
01344 #define STRING_BLOCK_SIZE 256
01345 
01346     int buflen = STRING_BLOCK_SIZE;
01347     char* strbuf = (char*) malloc(buflen);
01348     BOOL doubled = FALSE;
01349     int i = 0;
01350 
01351     if (!result)
01352         ParseError(ERR_INTERNAL_BAD_PARAM);
01353 
01354     while ( (BytesLeft(buffer) >= 1) && (*(buffer->m_curpos) != 0) )
01355     {
01356         if (i>=buflen)
01357         {
01358             buflen += STRING_BLOCK_SIZE;
01359             strbuf = realloc(strbuf, buflen);
01360         }
01361 
01362         if (*(buffer->m_curpos) != '$' || doubled == TRUE)
01363         {
01364             strbuf[i] = *(buffer->m_curpos);
01365             buffer->m_curpos++;
01366             i++;
01367             if (doubled == TRUE)
01368                 doubled = FALSE;
01369         }
01370         else
01371         {
01372             strbuf[i] = *(buffer->m_curpos);
01373             i++;
01374             doubled = TRUE;
01375         }
01376     }
01377 
01378     strbuf[i] = 0;
01379     buffer->m_curpos++;
01380 
01381     if (*result)
01382         free(*result);
01383 
01384     *result = strbuf;
01385 }

Here is the call graph for this function:

void Read_u_int8 P_WBXML_INFO  buffer,
P_WBXML_U_INT8  result
 

Definition at line 718 of file decompile.c.

References BytesLeft(), ERR_END_OF_DATA, ERR_INTERNAL_BAD_PARAM, tagWBXML_INFO::m_curpos, P_WBXML_INFO, ParseError(), and result.

Referenced by Read_pageindex(), Read_version(), and Read_zero().

00719 {
00720   if (buffer && result)
00721   {
00722     if (BytesLeft(buffer) >= 1) 
00723     {
00724       *result = *(buffer->m_curpos);
00725       (buffer->m_curpos)++;
00726     }
00727     else
00728     {
00729       ParseError(ERR_END_OF_DATA);
00730     }
00731   }
00732   else
00733   {
00734     ParseError(ERR_INTERNAL_BAD_PARAM);
00735   }
00736 }

Here is the call graph for this function:

void Read_version P_WBXML_INFO  buffer  ) 
 

Definition at line 1307 of file decompile.c.

References P_WBXML_INFO, Read_u_int8(), result, and WBXML_U_INT8.

Referenced by Read_start().

01308 {
01309   WBXML_U_INT8 result;
01310 
01311   Read_u_int8(buffer, &result);
01312 }

Here is the call graph for this function:

void Read_zero P_WBXML_INFO  buffer  ) 
 

Definition at line 1408 of file decompile.c.

References ERR_TAG_NOT_FOUND, P_WBXML_INFO, ParseError(), Read_u_int8(), result, and WBXML_U_INT8.

01409 {
01410   WBXML_U_INT8 result;
01411 
01412   Read_u_int8(buffer, &result);
01413 
01414   if (result != (WBXML_U_INT8) 0)
01415   {
01416     ParseError(ERR_TAG_NOT_FOUND);
01417   }
01418 }

Here is the call graph for this function:

void ReadBinary P_WBXML_INFO  buffer,
FILE *  file
[static]
 

Definition at line 1473 of file decompile.c.

References BufferLength(), ERR_FILE_NOT_READ, ERR_INTERNAL_BAD_PARAM, ERR_NOT_ENOUGH_MEMORY, file, FileSize(), m, tagWBXML_INFO::m_curpos, tagWBXML_INFO::m_length, tagWBXML_INFO::m_start, malloc, P_WBXML_INFO, ParseError(), and realloc.

Referenced by main().

01474 {
01475     char buf[4096];
01476     int m = 1;
01477     long n;
01478 
01479     if (buffer && file)
01480     {
01481         if (file != stdin)
01482         {
01483             buffer->m_length = FileSize(file);
01484             buffer->m_start = (P_WBXML) malloc(buffer->m_length);
01485             buffer->m_curpos = buffer->m_start;
01486 
01487             if (!buffer->m_start)
01488             {
01489                 fclose(file);
01490                 ParseError(ERR_NOT_ENOUGH_MEMORY);
01491             }
01492 
01493             if (fread(buffer->m_start, 1, buffer->m_length, file) != buffer->m_length)
01494             {
01495                 fclose(file);
01496                 ParseError(ERR_FILE_NOT_READ);
01497             }
01498             else
01499             {
01500                 fclose(file);
01501             }
01502         }
01503         else
01504         {
01505             while ((n = fread(buf, 1, sizeof(buf), file)) > 0)
01506             {
01507                 buffer->m_start = (P_WBXML) realloc(buffer->m_start, sizeof(buf) * m);
01508                 memcpy(buffer->m_start + (sizeof(buf) * (m - 1)), buf, sizeof(buf));
01509                 m++;
01510             }
01511             buffer->m_length = BufferLength(buffer);
01512             buffer->m_curpos = buffer->m_start;
01513         }
01514                 
01515     }
01516     else
01517     {
01518         ParseError(ERR_INTERNAL_BAD_PARAM);
01519     }
01520 }

Here is the call graph for this function:

WBXML_TAG ReadCodepageTag P_WBXML_INFO  buffer,
CP_TAG_TYPE  type
 

Definition at line 812 of file decompile.c.

References BytesLeft(), CP_TAG_ATTRSTART, CP_TAG_ATTRVALUE, CP_TAG_TAG, ERR_END_OF_DATA, ERR_INTERNAL_BAD_PARAM, ERR_TAG_NOT_FOUND, tagWBXML_INFO::m_curpos, P_WBXML_INFO, ParseError(), and WBXML_TAG.

Referenced by Read_attrStart(), Read_attrValue(), and Read_stag().

00813 {
00814   WBXML_TAG tag = 0;
00815 
00816   if (buffer)
00817   {
00818     if (BytesLeft(buffer) >= sizeof(WBXML_TAG))
00819     {
00820       tag = *((WBXML_TAG*) buffer->m_curpos);
00821 
00822       switch (type)
00823       {
00824         case CP_TAG_TAG:
00825           buffer->m_curpos += sizeof(WBXML_TAG);
00826           break;
00827 
00828         case CP_TAG_ATTRSTART:
00829           if ((tag & 0x80) != 0x80)
00830           {
00831             buffer->m_curpos += sizeof(WBXML_TAG);
00832           }
00833           else
00834           {
00835               ParseError(ERR_TAG_NOT_FOUND);
00836           }
00837           break;
00838 
00839         case CP_TAG_ATTRVALUE:
00840           if ((tag & 0x80) == 0x80)
00841           {
00842             buffer->m_curpos += sizeof(WBXML_TAG);
00843           }
00844           else
00845           {
00846               ParseError(ERR_TAG_NOT_FOUND);
00847           }
00848           break;
00849 
00850         default:
00851           ParseError(ERR_TAG_NOT_FOUND);
00852           break;
00853       }
00854     }
00855     else
00856     {
00857       ParseError(ERR_END_OF_DATA);
00858     }
00859   }
00860   else
00861   {
00862     ParseError(ERR_INTERNAL_BAD_PARAM);
00863   }
00864 
00865   return tag;
00866 }

Here is the call graph for this function:

void ReadFixedTag P_WBXML_INFO  buffer,
WBXML_TAG  tag
 

Definition at line 786 of file decompile.c.

References BytesLeft(), ERR_END_OF_DATA, ERR_INTERNAL_BAD_PARAM, ERR_TAG_NOT_FOUND, tagWBXML_INFO::m_curpos, P_WBXML_INFO, ParseError(), and WBXML_TAG.

Referenced by Read_attrStart(), Read_element(), Read_entity(), Read_extension(), Read_inline(), Read_opaque(), Read_pi(), Read_stag(), Read_switchPage(), and Read_tableref().

00787 {
00788   if (buffer)
00789   {
00790     if (BytesLeft(buffer) >= sizeof(WBXML_TAG))
00791     {
00792       if ((*((WBXML_TAG*) buffer->m_curpos)) == tag)
00793       {
00794         buffer->m_curpos += sizeof(WBXML_TAG);
00795       }
00796       else
00797       {
00798         ParseError(ERR_TAG_NOT_FOUND);
00799       }
00800     }
00801     else
00802     {
00803       ParseError(ERR_END_OF_DATA);
00804     }
00805   }
00806   else
00807   {
00808     ParseError(ERR_INTERNAL_BAD_PARAM);
00809   }
00810 }

Here is the call graph for this function:


Variable Documentation

CODEPAGE_ATTRSTART_NAME_LIST CodepageAttrstartNames[]
 

Definition at line 147 of file decompile.c.

Referenced by CodepageAttrstartName().

CODEPAGE_ATTRVALUE_NAME_LIST CodepageAttrvalueNames[]
 

Definition at line 262 of file decompile.c.

Referenced by CodepageAttrvalueName().

CODEPAGE_TAG_NAME_LIST CodepageTagNames[]
 

Definition at line 101 of file decompile.c.

Referenced by CodepageTagName().

long dtd_id
 

Definition at line 73 of file decompile.c.

Referenced by AddDTDNode().

DTD_TYPE_LIST DTDTypeList[]
 

Initial value:

{
    {1, "UNKNOWN"},
    {2, "-//WAPFORUM//DTD WML 1.0//EN\"\n"
     "\"http://www.wapforum.org/DTD/wml.xml"},
    {3, "-//WAPFORUM//DTD WTA 1.0//EN"},
    {4, "-//WAPFORUM//DTD WML 1.1//EN\"\n"
     "\"http://www.wapforum.org/DTD/wml_1.1.xml"},
    {5, "-//WAPFORUM//DTD SI 1.0//EN\"\n"
     "\"http://www.wapforum.org/DTD/si.dtd"},
    {6, "-//WAPFORUM//DTD SL 1.0//EN\"\n"
     "\"http://www.wapforum.org/DTD/sl.dtd"},
    {7, "-//WAPFORUM//DTD CO 1.0//EN"},
    {8, "-//WAPFORUM//DTD CHANNEL 1.1//EN"},
    {9, "-//WAPFORUM//DTD WML 1.2//EN\"\n"
     "\"http://www.wapforum.org/DTD/wml12.dtd"},
    {0, NULL}
}

Definition at line 77 of file decompile.c.

Referenced by DTDTypeName().

const WBXML_MB_U_INT32 ZERO_WBXML_MB_U_INT32 = {0,0,0,0}
 

Definition at line 72 of file decompile.c.

Referenced by Read_publicid().

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.