struct
tArrayCtrl
{
#ifdef DMALLOC
char
sSig [6] ;
char
* sFile ;
int
nLine ;
#endif
int
nFill ;
int
nMax ;
int
nAdd ;
int
nElementSize ;
} ;
typedef
void
tArray ;
typedef
unsigned
char
tUInt8 ;
typedef
signed
char
tSInt8 ;
typedef
unsigned
short
tUInt16 ;
typedef
signed
short
tSInt16 ;
typedef
unsigned
long
tUInt32 ;
typedef
signed
long
tSInt32 ;
typedef
tSInt32 tIndex ;
typedef
tSInt16 tIndexShort ;
typedef
tIndex tStringIndex ;
typedef
tUInt8 tNodeType ;
typedef
tIndex tNode ;
typedef
tIndex tAttr ;
typedef
tUInt16 tRepeatLevel ;
struct
tNodeData
{
tNodeType nType ;
tUInt8 bFlags ;
tIndexShort xDomTree ;
tIndex xNdx ;
tStringIndex nText ;
tNode xChilds ;
tUInt16 numAttr ;
tUInt16 nLinenumber ;
tNode xPrev ;
tNode xNext ;
tNode xParent ;
tRepeatLevel nRepeatLevel ;
} ;
typedef
struct
tNodeData tNodeData ;
struct
tAttrData
{
tNodeType nType ;
tUInt8 bFlags ;
tUInt16 nNodeOffset ;
tIndex xNdx ;
tIndex xName ;
tIndex xValue ;
} ;
typedef
struct
tAttrData tAttrData ;
struct
tDomNode
{
tIndex xDomTree ;
tNode xNode ;
SV * pDomNodeSV ;
} ;
typedef
struct
tDomNode tDomNode ;
enum
tNodeTypeValues
{
ntypTag = 1,
ntypStartTag = 1 + 0x20,
ntypStartEndTag = 1 + 0x80,
ntypEndTag = 1 + 0x40,
ntypEndStartTag = 1 + 0x60,
ntypAttr = 2,
ntypAttrValue = 2 + 0x20,
ntypText = 3,
ntypTextHTML = 3 + 0x20,
ntypCDATA = 4,
ntypEntityRef = 5,
ntypEntity = 6,
ntypProcessingInstr = 7,
ntypComment = 8,
ntypDocument = 9,
ntypDocumentType = 10,
ntypDocumentFraq = 11,
ntypNotation = 12
} ;
#define ntypMask 0x1f
enum
tNodeFlags
{
nflgDeleted = 0,
nflgOK = 1,
nflgEscUrl = 2,
nflgEscChar = 4,
nflgIgnore = 16,
nflgNewLevelNext = 32,
nflgNewLevelPrev = 64,
nflgStopOutput = 8,
nflgEscUTF8 = 128
} ;
enum
tAttrFlags
{
aflgDeleted = 0,
aflgOK = 1,
aflgAttrValue = 2,
aflgAttrChilds = 4,
aflgSingleQuote = 8
} ;
struct
tDomTreeOrder
{
tNode xFromNode ;
tNode xToNode ;
} ;
typedef
struct
tDomTreeOrder tDomTreeOrder ;
struct
tDomTreeCheckpoint
{
tNode xNode ;
} ;
typedef
struct
tDomTreeCheckpoint tDomTreeCheckpoint ;
struct
tDomTreeCheckpointStatus
{
tRepeatLevel nRepeatLevel ;
tIndex nCompileCheckpoint ;
tNode xJumpFromNode ;
tNode xJumpToNode ;
} ;
typedef
struct
tDomTreeCheckpointStatus tDomTreeCheckpointStatus ;
struct
tRepeatLevelLookupItem
{
tNodeData * pNode ;
struct
tRepeatLevelLookupItem * pNext ;
} ;
typedef
struct
tRepeatLevelLookupItem tRepeatLevelLookupItem ;
struct
tRepeatLevelLookup
{
tNode xNullNode ;
tRepeatLevel numItems ;
tRepeatLevel nMask ;
tRepeatLevelLookupItem items[1] ;
} ;
typedef
struct
tRepeatLevelLookup tRepeatLevelLookup ;
struct
tLookupItem
{
void
* pLookup ;
tRepeatLevelLookup * pLookupLevel ;
} ;
typedef
struct
tLookupItem tLookupItem ;
struct
tDomTree
{
tLookupItem * pLookup ;
tDomTreeCheckpoint * pCheckpoints ;
tDomTreeCheckpointStatus * pCheckpointStatus ;
tIndexShort xNdx ;
tIndexShort xSourceNdx ;
tNode xDocument ;
tNode xLastNode ;
tNode xCurrNode ;
tIndex xFilename ;
SV * pSV ;
SV * pDomTreeSV ;
tUInt16 nLastLinenumber ;
AV * pDependsOn ;
} ;
typedef
struct
tDomTree tDomTree ;
extern
tDomTree * pDomTrees ;
extern
HE * * pStringTableArray ;
extern
tIndex xNoName ;
extern
tIndex xDomTreeAttr ;
extern
tIndex xDocument ;
extern
tIndex xDocumentFraq ;
extern
tIndex xOrderIndexAttr ;
struct
tApp ;
tStringIndex String2NdxInc (
struct
tApp * a,
const
char
* sText,
int
nLen,
int
bInc) ;
tStringIndex String2UniqueNdx (
struct
tApp * a,
const
char
* sText,
int
nLen) ;
void
NdxStringFree (
struct
tApp * a,
tStringIndex nNdx) ;
#define SV2String(pSV,l) (SvOK (pSV)?SvPV (pSV, l):(l=0,((char *)NULL)))
#define String2NdxNoInc(a,sText,nLen) String2NdxInc(a,sText,nLen,0)
#define String2Ndx(a,sText,nLen) String2NdxInc(a,sText,nLen,1)
#define Ndx2String(nNdx) (HeKEY (pStringTableArray[nNdx]))
#define Ndx2StringLen(nNdx,sVal,nLen) { HE * pHE = pStringTableArray[nNdx] ; nLen=HeKLEN(pHE) ; sVal = HeKEY (pHE) ; }
#define NdxStringRefcntInc(a,nNdx) (SvREFCNT_inc (HeVAL (pStringTableArray[nNdx])))
#ifdef DMALLOC
int
ArrayNew_dbg (
struct
tApp * a,
const
tArray * pArray,
int
nAdd,
int
nElementSize,
char
* sFile,
int
nLine) ;
int
ArrayNewZero_dbg (
struct
tApp * a,
const
tArray * pArray,
int
nAdd,
int
nElementSize,
char
* sFile,
int
nLine) ;
int
ArrayClone_dbg (
struct
tApp * a,
const
tArray * pOrgArray,
const
tArray * pNewArray,
char
* sFile,
int
nLine) ;
#undef ArrayNew
#define ArrayNew(app,a,n,s) ArrayNew_dbg(app,a,n,s,__FILE__,__LINE__)
#undef ArrayNewZero
#define ArrayNewZero(app,a,n,s) ArrayNewZero_dbg(app,a,n,s,__FILE__,__LINE__)
#undef ArrayClone
#define ArrayClone(app,o,n) ArrayClone_dbg(app,o,n,__FILE__,__LINE__)
#else
int
ArrayNew (
struct
tApp * a,
const
tArray * pArray,
int
nAdd,
int
nElementSize) ;
int
ArrayNewZero (
struct
tApp * a,
const
tArray * pArray,
int
nAdd,
int
nElementSize) ;
int
ArrayClone (
struct
tApp * a,
const
tArray * pOrgArray,
const
tArray * pNewArray) ;
#endif
int
ArrayFree (
struct
tApp * a,
const
tArray * pArray) ;
int
ArraySet (
struct
tApp * a,
const
tArray * pArray,
int
numElements) ;
int
ArraySetSize (
struct
tApp * a,
const
tArray * pArray,
int
numElements) ;
int
ArrayGetSize (
struct
tApp * a,
const
tArray * pArray) ;
int
ArrayAdd (
struct
tApp * a,
const
tArray * pArray,
int
numElements) ;
int
ArraySub (
struct
tApp * a,
const
tArray * pArray,
int
numElements) ;
#ifdef DMALLOC
void
StringNew_dbg (
struct
tApp * a,
char
* * pArray,
int
nAdd,
char
* sFile,
int
nLine) ;
#undef StringNew
#define StringNew(app,a,n) StringNew_dbg(app,a,n,__FILE__,__LINE__)
#else
void
StringNew (
struct
tApp * a,
char
* * pArray,
int
nAdd) ;
#endif
void
StringFree (
struct
tApp * a,
char
* * pArray) ;
int
StringAdd (
struct
tApp * a,
char
* * pArray,
const
char
* sAdd,
int
nLen) ;
int
DomInit (
struct
tApp * a) ;
void
DomStats (
struct
tApp * a) ;
int
DomTree_clone (
struct
tApp * a,
tDomTree * pOrgDomTree,
tDomTree * * pNewDomTree,
int
bForceDocFraq) ;
int
DomTree_new (
struct
tApp * a,
tDomTree * * pNewLookup) ;
int
DomTree_delete (
struct
tApp * a,
tDomTree * pDomTree) ;
void
DomTree_checkpoint (
struct
tReq * r, tIndex nRunCheckpoint) ;
void
DomTree_discardAfterCheckpoint (
struct
tReq * r, tIndex nRunCheckpoint) ;
#define DomTree_SV(pSV) SvIVX(pSV)
#define DomTree_selfSV(pSV) (DomTree_self(SvIVX(pSV)))
#define SV_DomTree(xDomTree) (DomTree_self (xDomTree) -> pDomTreeSV)
#define SV_DomTree_self(pDomTree) (pDomTree -> pDomTreeSV)
#define DomTree_filename(xDomTree) (Ndx2String (DomTree_self(xDomTree) -> xFilename))
#define DomTree_selfFilename(pDomTree) (Ndx2String ((pDomTree) -> xFilename))
tNodeData * Node_selfLevelItem (
struct
tApp * a,
tDomTree * pDomTree,
tNode xNode,
tRepeatLevel nLevel) ;
tNode Node_appendChild (
struct
tApp * a,
tDomTree * pDomTree,
tNode xParent,
tRepeatLevel nRepeatLevel,
tNodeType nType,
int
bForceAttrValue,
const
char
* sText,
int
nTextLen,
int
nLevel,
int
nLinenumber,
const
char
* sLogMsg) ;
struct
tNodeData * Node_selfNthChild (
struct
tApp * a,
tDomTree * pDomTree,
struct
tNodeData * pNode,
tRepeatLevel nRepeatLevel,
int
nChildNo) ;
tNodeData * Node_selfLastChild (
struct
tApp * a,
tDomTree * pDomTree,
tNodeData * pNode,
tRepeatLevel nRepeatLevel) ;
tNodeData * Node_selfNextSibling (
struct
tApp * a,
tDomTree * pDomTree,
tNodeData * pNode,
tRepeatLevel nRepeatLevel) ;
tNode Node_nextSibling (
struct
tApp * a,
tDomTree * pDomTree,
tNode xNode,
tRepeatLevel nRepeatLevel) ;
tNodeData * Node_selfPreviousSibling (
struct
tApp * a,
tDomTree * pDomTree,
tNodeData * pNode,
tRepeatLevel nRepeatLevel) ;
tNode Node_previousSibling (
struct
tApp * a,
tDomTree * pDomTree,
tNode xNode,
tRepeatLevel nRepeatLevel) ;
#define DomTree_self(xDomTree) (&pDomTrees[xDomTree])
#define Node_self(pDomTree,xNode) ((struct tNodeData *)(pDomTree -> pLookup[xNode].pLookup))
#define Node_selfLevel(a,pDomTree,xNode,nLevel) \
(pDomTree -> pLookup[xNode].pLookup == NULL?NULL: \
(((
struct
tNodeData *)(pDomTree -> pLookup[xNode].pLookup)) -> nRepeatLevel == nLevel? \
((
struct
tNodeData *)(pDomTree -> pLookup[xNode].pLookup)): \
Node_selfLevelItem(a,pDomTree,xNode,nLevel)))
#define Node_selfNotNullLevel(a,pDomTree,xNode,nLevel) \
(pDomTree -> pLookup[xNode].pLookup == NULL?NULL: \
(((
struct
tNodeData *)(pDomTree -> pLookup[xNode].pLookup)) -> xDomTree == pDomTree -> xNdx? \
((
struct
tNodeData *)(pDomTree -> pLookup[xNode].pLookup)): \
Node_selfLevelItem(a,pDomTree,xNode,nLevel)))
#if 0
(pDomTree -> pLookup[xNode].pLookup == ? \
((((
struct
tNodeData *)(pDomTree -> pLookup[xNode].pLookup)) -> nRepeatLevel == nLevel || \
((
struct
tNodeData *)(pDomTree -> pLookup[xNode].pLookup)) -> nRepeatLevel != 0 || \
pDomTree -> pLookup[xNode].pLookupLevel == NULL)? \
((
struct
tNodeData *)(pDomTree -> pLookup[xNode].pLookup)): \
Node_selfLevelItem(a,pDomTree,xNode,nLevel)): \
NULL)
#endif
#define xNode_selfLevelNull(pDomTree,pNode) ((pDomTree) -> pLookup[(pNode)->xNdx].pLookupLevel?(pDomTree) -> pLookup[(pNode)->xNdx].pLookupLevel -> xNullNode:(pNode) -> xNdx)
#define xNode_levelNull(pDomTree,xNode) ((pDomTree) -> pLookup[(xNode)].pLookupLevel?(pDomTree) -> pLookup[(xNode)].pLookupLevel -> xNullNode:(xNode))
#define Node_parentNode(a,pDomTree,xNode,nLevel) (Node_selfLevel(a,pDomTree,xNode,nLevel)->xParent)
#define Node_selfParentNode(a,pDomTree,pNode,nLevel) (Node_selfLevel(a,pDomTree,(pNode)->xParent,nLevel))
#define xNode_selfParentNode(pDomTree,pNode) ((pNode)->xParent)
#define Node_firstChild(a,pDomTree,xNode,nLevel) (Node_selfLevel(a,pDomTree,xNode,nLevel)->xChilds)
#define Node_selfFirstChild(a,pDomTree,pNode,nLevel) (Node_selfLevel(a,pDomTree,(pNode)->xChilds,nLevel))
#define Node_selfNodeNameNdx(pNode) ((pNode) -> nText) ;
#define Node_selfNodeName(pNode) (Ndx2String ((pNode) -> nText))
#define Node_nodeName(a,pDomTree,xNode,nLevel) (Ndx2String (Node_selfLevel (a,pDomTree,xNode,nLevel) -> nText))
#define Node_selfFirstAttr(pNode) ((tAttrData *)((pNode) + 1))
tNodeData * Node_selfCloneNode (
struct
tApp * a,
tDomTree * pDomTree,
tNodeData * pNode,
tRepeatLevel nRepeatLevel,
int
bDeep) ;
tNodeData * Node_selfCondCloneNode (
struct
tApp * a,
tDomTree * pDomTree,
tNodeData * pNode,
tRepeatLevel nRepeatLevel) ;
tNodeData * Node_selfForceLevel(
struct
tApp * a,
tDomTree * pDomTree,
tNode xNode,
tRepeatLevel nRepeatLevel) ;
tNode Node_cloneNode (
struct
tApp * a,
tDomTree * pDomTree,
tNode xNode,
tRepeatLevel nRepeatLevel,
int
bDeep) ;
void
Node_toString (
register
req * r,
tDomTree * pDomTree,
tNode xNode,
tRepeatLevel nRepeatLevel) ;
struct
tNodeData * Node_selfRemoveChild (
struct
tApp * a,
tDomTree * pDomTree,
tNode xNode,
struct
tNodeData * pChild) ;
tNode Node_removeChild (
struct
tApp * a,
tDomTree * pDomTree,
tNode xNode,
tNode xChild,
tRepeatLevel nRepeatLevel) ;
tNode Node_insertBefore_CDATA (
struct
tApp * a,
const
char
* sText,
int
nTextLen,
int
nEscMode,
tDomTree * pRefNodeDomTree,
tNode xRefNode,
tRepeatLevel nRefRepeatLevel) ;
tNode Node_insertAfter (
struct
tApp * a,
tDomTree * pNewNodeDomTree,
tNode xNewNode,
tRepeatLevel nNewRepeatLevel,
tDomTree * pRefNodeDomTree,
tNode xRefNode,
tRepeatLevel nRefRepeatLevel) ;
tNode Node_insertAfter_CDATA (
struct
tApp * a,
const
char
* sText,
int
nTextLen,
int
nEscMode,
tDomTree * pRefNodeDomTree,
tNode xRefNode,
tRepeatLevel nRefRepeatLevel) ;
tNode Node_replaceChildWithNode (
struct
tApp * a,
tDomTree * pDomTree,
tNode xNode,
tRepeatLevel nRepeatLevel,
tDomTree * pOldChildDomTree,
tNode xOldChild,
tRepeatLevel nOldRepeatLevel) ;
tNode Node_replaceChildWithCDATA (
struct
tApp * a,
tDomTree * pDomTree,
tNode xOldChild,
tRepeatLevel nRepeatLevel,
const
char
* sText,
int
nTextLen,
int
nEscMode,
int
bFlags) ;
char
* Node_childsText (
struct
tApp * a,
tDomTree * pDomTree,
tNode xNode,
tRepeatLevel nRepeatLevel,
char
* * ppText,
int
bDeep) ;
tAttrData * Element_selfGetAttribut (
struct
tApp * a,
tDomTree * pDomTree,
struct
tNodeData * pNode,
const
char
* sAttrName,
int
nAttrNameLen) ;
tAttrData * Element_selfGetNthAttribut (
struct
tApp * a,
tDomTree * pDomTree,
struct
tNodeData * pNode,
int
n) ;
tAttrData * Element_selfSetAttribut (
struct
tApp * a,
tDomTree * pDomTree,
struct
tNodeData * pNode,
tRepeatLevel nRepeatLevel,
const
char
* sAttrName,
int
nAttrNameLen,
const
char
* sNewValue,
int
nNewValueLen) ;
tAttrData * Element_selfRemoveAttributPtr (
struct
tApp * a,
tDomTree * pDomTree,
struct
tNodeData * pNode,
tRepeatLevel nRepeatLevel,
tAttrData * pAttr) ;
tAttrData * Element_selfRemoveNthAttribut (
struct
tApp * a,
tDomTree * pDomTree,
struct
tNodeData * pNode,
tRepeatLevel nRepeatLevel,
int
n) ;
tAttrData * Element_selfRemoveAttribut (
struct
tApp * a,
tDomTree * pDomTree,
struct
tNodeData * pNode,
tRepeatLevel nRepeatLevel,
const
char
* sAttrName,
int
nAttrNameLen) ;
#define Attr_self(pDomTree,xAttr) ((struct tAttrData *)(pDomTree -> pLookup[xAttr].pLookup))
#define Attr_selfNode(pAttr) ((struct tNodeData * )(((tUInt8 *)pAttr) - pAttr -> nNodeOffset))
#define Attr_selfAttrNum(pAttr) (pAttr - Node_selfFirstAttr (Attr_selfNode(pAttr)))
char
* Attr_selfValue (
struct
tApp * a,
tDomTree * pDomTree,
struct
tAttrData * pAttr,
tRepeatLevel nRepeatLevel,
char
* * ppAttr) ;
#define NodeAttr_selfParentNode(pDomTree,pNode,nLevel) (pNode->nType == ntypAttr?Attr_selfNode(((tAttrData *)pNode)):(Node_self(pDomTree,(pNode)->xParent)))