HTML Tidy  5.4.0
The HTACG Tidy HTML Project
tidy-int.h
Go to the documentation of this file.
1 #ifndef __TIDY_INT_H__
2 #define __TIDY_INT_H__
3 
4 /* tidy-int.h -- internal library declarations
5 
6  (c) 1998-2007 (W3C) MIT, ERCIM, Keio University
7  See tidy.h for the copyright notice.
8 
9 */
10 
11 #include "tidy.h"
12 #include "config.h"
13 #include "lexer.h"
14 #include "tags.h"
15 #include "attrs.h"
16 #include "pprint.h"
17 #include "access.h"
18 
19 #ifndef MAX
20 #define MAX(a,b) (((a) > (b))?(a):(b))
21 #endif
22 #ifndef MIN
23 #define MIN(a,b) (((a) < (b))?(a):(b))
24 #endif
25 
26 /*\
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...
31 \*/
32 #define flg_BadForm 0x00000001
33 #define flg_BadMain 0x00000002
34 
36 {
37  /* The Document Tree (and backing store buffer) */
38  Node root; /* This MUST remain the first declared
39  variable in this structure */
40  Lexer* lexer;
41 
42  /* Config + Markup Declarations */
44  TidyTagImpl tags;
45  TidyAttribImpl attribs;
46 
47 #if SUPPORT_ACCESSIBILITY_CHECKS
48  /* Accessibility Checks state */
49  TidyAccessImpl access;
50 #endif
51 
52  /* The Pretty Print buffer */
54 
55  /* I/O */
56  StreamIn* docIn;
57  StreamOut* docOut;
58  StreamOut* errout;
64 
65  /* Parse + Repair Results */
73 
74  uint badAccess; /* for accessibility errors */
75  uint badLayout; /* for bad style errors */
76  uint badChars; /* for bad char encodings */
77  uint badForm; /* bit field, for badly placed form tags, or other format errors */
78 
79  Bool HTML5Mode; /* current mode is html5 */
80 
81  /* Memory allocator */
82  TidyAllocator* allocator;
83 
84  /* Miscellaneous */
85  void* appData;
88 
89 #ifdef TIDY_STORE_ORIGINAL_TEXT
90  Bool storeText;
91 #endif
92 
93 #if PRESERVE_FILE_TIMES
94  struct utimbuf filetimes;
95 #endif
97 };
98 
99 
100 /* Twizzle internal/external types */
101 #ifdef NEVER
102 TidyDocImpl* tidyDocToImpl( TidyDoc tdoc );
103 TidyDoc tidyImplToDoc( TidyDocImpl* impl );
104 
105 Node* tidyNodeToImpl( TidyNode tnod );
106 TidyNode tidyImplToNode( Node* node );
107 
108 AttVal* tidyAttrToImpl( TidyAttr tattr );
109 TidyAttr tidyImplToAttr( AttVal* attval );
110 
111 const TidyOptionImpl* tidyOptionToImpl( TidyOption topt );
112 TidyOption tidyImplToOption( const TidyOptionImpl* option );
113 #else
114 
115 #define tidyDocToImpl( tdoc ) ((TidyDocImpl*)(tdoc))
116 #define tidyImplToDoc( doc ) ((TidyDoc)(doc))
117 
118 #define tidyNodeToImpl( tnod ) ((Node*)(tnod))
119 #define tidyImplToNode( node ) ((TidyNode)(node))
120 
121 #define tidyAttrToImpl( tattr ) ((AttVal*)(tattr))
122 #define tidyImplToAttr( attval ) ((TidyAttr)(attval))
123 
124 #define tidyOptionToImpl( topt ) ((const TidyOptionImpl*)(topt))
125 #define tidyImplToOption( option ) ((TidyOption)(option))
126 
127 #endif
128 
129 /** Wrappers for easy memory allocation using the document's allocator */
130 #define TidyDocAlloc(doc, size) TidyAlloc((doc)->allocator, size)
131 #define TidyDocRealloc(doc, block, size) TidyRealloc((doc)->allocator, block, size)
132 #define TidyDocFree(doc, block) TidyFree((doc)->allocator, block)
133 #define TidyDocPanic(doc, msg) TidyPanic((doc)->allocator, msg)
134 
135 int TY_(DocParseStream)( TidyDocImpl* impl, StreamIn* in );
136 
137 /*
138  [i_a] generic node tree traversal code; used in several spots.
139 
140  Define your own callback, which returns one of the NodeTraversalSignal values
141  to instruct the tree traversal routine TraverseNodeTree() what to do.
142 
143  Pass custom data to/from the callback using the 'propagate' reference.
144  */
145 typedef enum
146 {
147  ContinueTraversal, /* visit siblings and children */
148  SkipChildren, /* visit siblings of this node; ignore its children */
149  SkipSiblings, /* ignore subsequent siblings of this node; ignore their children; traverse */
150  SkipChildrenAndSiblings, /* visit siblings of this node; ignore its children */
151  VisitParent, /* REVERSE traversal: visit the parent of the current node */
152  ExitTraversal /* terminate traversal on the spot */
154 
155 typedef NodeTraversalSignal NodeTraversalCallBack(TidyDocImpl* doc, Node* node, void *propagate);
156 
157 NodeTraversalSignal TY_(TraverseNodeTree)(TidyDocImpl* doc, Node* node, NodeTraversalCallBack *cb, void *propagate);
158 
159 #endif /* __TIDY_INT_H__ */
uint docErrors
Definition: tidy-int.h:71
uint badForm
Definition: tidy-int.h:77
Definition: tidy-int.h:150
Bool(TIDY_CALL * TidyReportFilter2)(TidyDoc tdoc, TidyReportLevel lvl, uint line, uint col, ctmbstr mssg, va_list args)
Definition: tidy.h:645
TidyReportFilter mssgFilt
Definition: tidy-int.h:59
TidyReportFilter2 mssgFilt2
Definition: tidy-int.h:60
Definition: tidy-int.h:149
TidyPPProgress progressCallback
Definition: tidy-int.h:63
Bool(TIDY_CALL * TidyReportFilter)(TidyDoc tdoc, TidyReportLevel lvl, uint line, uint col, ctmbstr mssg)
Callback to filter messages by diagnostic level: info, warning, etc.
Definition: tidy.h:642
TidyConfigImpl config
Definition: tidy-int.h:43
Definition: tidy-int.h:152
uint infoMessages
Definition: tidy-int.h:70
#define tidyImplToNode(node)
Definition: tidy-int.h:119
void * appData
Definition: tidy-int.h:85
uint badAccess
Definition: tidy-int.h:74
StreamOut * errout
Definition: tidy-int.h:58
#define tidyAttrToImpl(tattr)
Definition: tidy-int.h:121
Definition: tidy-int.h:35
Bool inputHadBOM
Definition: tidy-int.h:87
Definition: config.h:51
TidyPrintImpl pprint
Definition: tidy-int.h:53
tmbstr givenDoctype
Definition: tidy-int.h:96
NodeTraversalSignal NodeTraversalCallBack(TidyDocImpl *doc, Node *node, void *propagate)
Definition: tidy-int.h:155
StreamIn * docIn
Definition: tidy-int.h:56
#define tidyNodeToImpl(tnod)
Definition: tidy-int.h:118
Bool
Definition: tidyplatform.h:593
#define tidyImplToOption(option)
Definition: tidy-int.h:125
StreamOut * docOut
Definition: tidy-int.h:57
#define tidyImplToDoc(doc)
Definition: tidy-int.h:116
Defines HTML Tidy API implemented by tidy library.
uint badChars
Definition: tidy-int.h:76
uint errors
Definition: tidy-int.h:67
TidyOptCallback pOptCallback
Definition: tidy-int.h:62
Node root
Definition: tidy-int.h:38
#define tidyImplToAttr(attval)
Definition: tidy-int.h:122
Opaque node datatype.
tmbchar * tmbstr
Definition: tidyplatform.h:555
#define tidyOptionToImpl(topt)
Definition: tidy-int.h:124
Definition: tidy-int.h:151
unsigned int uint
Definition: tidyplatform.h:525
int parseStatus
Definition: tidy-int.h:72
Bool(TIDY_CALL * TidyReportFilter3)(TidyDoc tdoc, TidyReportLevel lvl, uint line, uint col, ctmbstr code, va_list args)
Definition: tidy.h:648
uint accessErrors
Definition: tidy-int.h:69
Definition: tidy-int.h:148
Bool(TIDY_CALL * TidyOptCallback)(ctmbstr option, ctmbstr value)
Applications using TidyLib may want to augment command-line and configuration file options...
Definition: tidy.h:421
Definition: tidy-int.h:147
TidyTagImpl tags
Definition: tidy-int.h:44
Opaque document datatype.
TidyAccessImpl access
Definition: tidy-int.h:49
TidyReportFilter3 mssgFilt3
Definition: tidy-int.h:61
#define TY_(str)
Definition: forward.h:23
#define tidyDocToImpl(tdoc)
Definition: tidy-int.h:115
Opaque option datatype.
Opaque attribute datatype.
Lexer * lexer
Definition: tidy-int.h:40
TidyAllocator * allocator
Definition: tidy-int.h:82
void(TIDY_CALL * TidyPPProgress)(TidyDoc tdoc, uint line, uint col, uint destLine)
Callback to track the progress of the pretting printing process.
Definition: tidy.h:675
TidyAttribImpl attribs
Definition: tidy-int.h:45
NodeTraversalSignal
Definition: tidy-int.h:145
uint badLayout
Definition: tidy-int.h:75
uint nClassId
Definition: tidy-int.h:86
uint optionErrors
Definition: tidy-int.h:66
Definition: pprint.h:48
Bool HTML5Mode
Definition: tidy-int.h:79
uint warnings
Definition: tidy-int.h:68