4 /* tidy-int.h -- internal library declarations
6 (c) 1998-2007 (W3C) MIT, ERCIM, Keio University
7 See tidy.h for the copyright notice.
20 #define MAX(a,b) (((a) > (b))?(a):(b))
23 #define MIN(a,b) (((a) < (b))?(a):(b))
27 * Issue #166 - repeated <main> element
28 * Change the previous on/off uint flag badForm
29 * to a BIT flag to support other than <form>
30 * errors. This could be extended more...
32 #define flg_BadForm 0x00000001
33 #define flg_BadMain 0x00000002
37 /* The Document Tree (and backing store buffer) */
38 Node root; /* This MUST remain the first declared
39 variable in this structure */
42 /* Config + Markup Declarations */
43 TidyConfigImpl config;
45 TidyAttribImpl attribs;
47 #if SUPPORT_ACCESSIBILITY_CHECKS
48 /* Accessibility Checks state */
49 TidyAccessImpl access;
52 /* The Pretty Print buffer */
59 TidyReportFilter mssgFilt;
60 TidyReportFilter2 mssgFilt2;
61 TidyOptCallback pOptCallback;
63 /* Parse + Repair Results */
72 uint badAccess; /* for accessibility errors */
73 uint badLayout; /* for bad style errors */
74 uint badChars; /* for bad char encodings */
75 uint badForm; /* bit field, for badly placed form tags, or other format errors */
77 /* Memory allocator */
78 TidyAllocator* allocator;
85 #ifdef TIDY_STORE_ORIGINAL_TEXT
89 #if PRESERVE_FILE_TIMES
90 struct utimbuf filetimes;
96 /* Twizzle internal/external types */
98 TidyDocImpl* tidyDocToImpl( TidyDoc tdoc );
99 TidyDoc tidyImplToDoc( TidyDocImpl* impl );
101 Node* tidyNodeToImpl( TidyNode tnod );
102 TidyNode tidyImplToNode( Node* node );
104 AttVal* tidyAttrToImpl( TidyAttr tattr );
105 TidyAttr tidyImplToAttr( AttVal* attval );
107 const TidyOptionImpl* tidyOptionToImpl( TidyOption topt );
108 TidyOption tidyImplToOption( const TidyOptionImpl* option );
111 #define tidyDocToImpl( tdoc ) ((TidyDocImpl*)(tdoc))
112 #define tidyImplToDoc( doc ) ((TidyDoc)(doc))
114 #define tidyNodeToImpl( tnod ) ((Node*)(tnod))
115 #define tidyImplToNode( node ) ((TidyNode)(node))
117 #define tidyAttrToImpl( tattr ) ((AttVal*)(tattr))
118 #define tidyImplToAttr( attval ) ((TidyAttr)(attval))
120 #define tidyOptionToImpl( topt ) ((const TidyOptionImpl*)(topt))
121 #define tidyImplToOption( option ) ((TidyOption)(option))
125 /** Wrappers for easy memory allocation using the document's allocator */
126 #define TidyDocAlloc(doc, size) TidyAlloc((doc)->allocator, size)
127 #define TidyDocRealloc(doc, block, size) TidyRealloc((doc)->allocator, block, size)
128 #define TidyDocFree(doc, block) TidyFree((doc)->allocator, block)
129 #define TidyDocPanic(doc, msg) TidyPanic((doc)->allocator, msg)
131 int TY_(DocParseStream)( TidyDocImpl* impl, StreamIn* in );
134 [i_a] generic node tree traversal code; used in several spots.
136 Define your own callback, which returns one of the NodeTraversalSignal values
137 to instruct the tree traversal routine TraverseNodeTree() what to do.
139 Pass custom data to/from the callback using the 'propagate' reference.
143 ContinueTraversal, /* visit siblings and children */
144 SkipChildren, /* visit siblings of this node; ignore its children */
145 SkipSiblings, /* ignore subsequent siblings of this node; ignore their children; traverse */
146 SkipChildrenAndSiblings, /* visit siblings of this node; ignore its children */
147 VisitParent, /* REVERSE traversal: visit the parent of the current node */
148 ExitTraversal /* terminate traversal on the spot */
149 } NodeTraversalSignal;
151 typedef NodeTraversalSignal NodeTraversalCallBack(TidyDocImpl* doc, Node* node, void *propagate);
153 NodeTraversalSignal TY_(TraverseNodeTree)(TidyDocImpl* doc, Node* node, NodeTraversalCallBack *cb, void *propagate);
155 #endif /* __TIDY_INT_H__ */