HTML Tidy  5.7.28
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 #include "message.h"
19 
20 #ifndef MAX
21 #define MAX(a,b) (((a) > (b))?(a):(b))
22 #endif
23 #ifndef MIN
24 #define MIN(a,b) (((a) < (b))?(a):(b))
25 #endif
26 
27 /*\
28  * Issue #166 - repeated <main> element
29  * Change the previous on/off uint flag badForm
30  * to a BIT flag to support other than <form>
31  * errors. This could be extended more...
32 \*/
33 #define flg_BadForm 0x00000001
34 #define flg_BadMain 0x00000002
35 
37 {
38  /* The Document Tree (and backing store buffer) */
39  Node root; /* This MUST remain the first declared
40  variable in this structure */
41  Lexer* lexer;
42 
43  /* Config + Markup Declarations */
46  TidyAttribImpl attribs;
47  TidyAccessImpl access;
49 
50  /* The Pretty Print buffer */
52 
53  /* I/O */
54  StreamIn* docIn;
55  StreamOut* docOut;
56  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  uint footnotes; /* bit field, for other footnotes, until formalized */
79 
80  Bool HTML5Mode; /* current mode is html5 */
81  Bool xmlDetected; /* true if XML was used/detected */
82 
83  /* Memory allocator */
84  TidyAllocator* allocator;
85 
86  /* Miscellaneous */
87  void* appData;
90 
91 #if PRESERVE_FILE_TIMES
92  struct utimbuf filetimes;
93 #endif
95 };
96 
97 /** The basic struct for communicating a message within LibTidy. All of the
98 ** relevant information pertaining to a message can be retrieved with the
99 ** accessor functions and one of these records.
100 */
102 {
103  TidyDocImpl *tidyDoc; /* document instance this message is attributed to */
104  Node *tidyNode; /* the node reporting the message, if applicable */
105  uint code; /* the message code */
106  int line; /* the line message applies to */
107  int column; /* the column the message applies to */
108  TidyReportLevel level; /* the severity level of the message */
109  Bool allowMessage; /* indicates whether or not a filter rejected a message */
110  Bool muted; /* indicates whether or not a configuration mutes this message */
111 
112  int argcount; /* the number of arguments */
113  struct printfArg* arguments; /* the arguments' values and types */
114 
115  ctmbstr messageKey; /* the message code as a key string */
116 
117  ctmbstr messageFormatDefault; /* the built-in format string */
118  ctmbstr messageFormat; /* the localized format string */
119 
120  tmbstr messageDefault; /* the message, formatted, default language */
121  tmbstr message; /* the message, formatted, localized */
122 
123  tmbstr messagePosDefault; /* the position part, default language */
124  tmbstr messagePos; /* the position part, localized */
125 
126  ctmbstr messagePrefixDefault; /* the prefix part, default language */
127  ctmbstr messagePrefix; /* the prefix part, localized */
128 
129  tmbstr messageOutputDefault; /* the complete string Tidy would output */
130  tmbstr messageOutput; /* the complete string, localized */
131 };
132 
133 
134 #define tidyDocToImpl( tdoc ) ((TidyDocImpl*)(tdoc))
135 #define tidyImplToDoc( doc ) ((TidyDoc)(doc))
136 
137 #define tidyMessageToImpl( tmessage ) ((TidyMessageImpl*)(tmessage))
138 #define tidyImplToMessage( message ) ((TidyMessage)(message))
139 
140 #define tidyNodeToImpl( tnod ) ((Node*)(tnod))
141 #define tidyImplToNode( node ) ((TidyNode)(node))
142 
143 #define tidyAttrToImpl( tattr ) ((AttVal*)(tattr))
144 #define tidyImplToAttr( attval ) ((TidyAttr)(attval))
145 
146 #define tidyOptionToImpl( topt ) ((const TidyOptionImpl*)(topt))
147 #define tidyImplToOption( option ) ((TidyOption)(option))
148 
149 
150 /** Wrappers for easy memory allocation using the document's allocator */
151 #define TidyDocAlloc(doc, size) TidyAlloc((doc)->allocator, size)
152 #define TidyDocRealloc(doc, block, size) TidyRealloc((doc)->allocator, block, size)
153 #define TidyDocFree(doc, block) TidyFree((doc)->allocator, block)
154 #define TidyDocPanic(doc, msg) TidyPanic((doc)->allocator, msg)
155 
156 int TY_(DocParseStream)( TidyDocImpl* impl, StreamIn* in );
157 
158 /*
159  [i_a] generic node tree traversal code; used in several spots.
160 
161  Define your own callback, which returns one of the NodeTraversalSignal values
162  to instruct the tree traversal routine TraverseNodeTree() what to do.
163 
164  Pass custom data to/from the callback using the 'propagate' reference.
165  */
166 typedef enum
167 {
168  ContinueTraversal, /* visit siblings and children */
169  SkipChildren, /* visit siblings of this node; ignore its children */
170  SkipSiblings, /* ignore subsequent siblings of this node; ignore their children; traverse */
171  SkipChildrenAndSiblings, /* visit siblings of this node; ignore its children */
172  VisitParent, /* REVERSE traversal: visit the parent of the current node */
173  ExitTraversal /* terminate traversal on the spot */
175 
176 typedef NodeTraversalSignal NodeTraversalCallBack(TidyDocImpl* doc, Node* node, void *propagate);
177 
178 NodeTraversalSignal TY_(TraverseNodeTree)(TidyDocImpl* doc, Node* node, NodeTraversalCallBack *cb, void *propagate);
179 
180 #endif /* __TIDY_INT_H__ */
_TidyDocImpl::root
Node root
Definition: tidy-int.h:39
tmbstr
tmbchar * tmbstr
Definition: tidyplatform.h:608
_TidyDocImpl
Definition: tidy-int.h:37
uint
unsigned int uint
Definition: tidyplatform.h:569
_TidyMessageImpl::tidyDoc
TidyDocImpl * tidyDoc
Definition: tidy-int.h:103
TidyTagImpl
This structure consists of the lists of all tags known to Tidy.
Definition: tags.h:110
_TidyDocImpl::lexer
Lexer * lexer
Definition: tidy-int.h:41
attrs.h
_TidyMessageImpl::messagePosDefault
tmbstr messagePosDefault
Definition: tidy-int.h:123
NodeTraversalSignal
NodeTraversalSignal
Definition: tidy-int.h:167
_TidyMessageImpl::messageDefault
tmbstr messageDefault
Definition: tidy-int.h:120
_TidyMessageImpl::level
TidyReportLevel level
Definition: tidy-int.h:108
_TidyMessageImpl::column
int column
Definition: tidy-int.h:107
VisitParent
@ VisitParent
Definition: tidy-int.h:172
_TidyMessageImpl::messagePos
tmbstr messagePos
Definition: tidy-int.h:124
_TidyDocImpl::givenDoctype
tmbstr givenDoctype
Definition: tidy-int.h:94
TidyReportLevel
TidyReportLevel
Message severity level, used throughout LibTidy to indicate the severity or status of a message.
Definition: tidyenum.h:1380
_TidyDocImpl::reportFilter
TidyReportFilter reportFilter
Definition: tidy-int.h:57
tags.h
_TidyDocImpl::HTML5Mode
Bool HTML5Mode
Definition: tidy-int.h:80
TidyReportFilter
Bool(TIDY_CALL * TidyReportFilter)(TidyDoc tdoc, TidyReportLevel lvl, uint line, uint col, ctmbstr mssg)
This typedef represents the required signature for your provided callback function should you wish to...
Definition: tidy.h:1221
_TidyDocImpl::accessErrors
uint accessErrors
Definition: tidy-int.h:69
_TidyMessageImpl::tidyNode
Node * tidyNode
Definition: tidy-int.h:104
_TidyDocImpl::parseStatus
int parseStatus
Definition: tidy-int.h:72
SkipChildren
@ SkipChildren
Definition: tidy-int.h:169
_TidyMessageImpl::messageOutputDefault
tmbstr messageOutputDefault
Definition: tidy-int.h:129
ExitTraversal
@ ExitTraversal
Definition: tidy-int.h:173
_TidyMessageImpl::messageFormatDefault
ctmbstr messageFormatDefault
Definition: tidy-int.h:117
_TidyMessageImpl::argcount
int argcount
Definition: tidy-int.h:112
_TidyMessageImpl::message
tmbstr message
Definition: tidy-int.h:121
_TidyDocImpl::access
TidyAccessImpl access
Definition: tidy-int.h:47
_TidyMessageImpl::messageOutput
tmbstr messageOutput
Definition: tidy-int.h:130
TidyMessageCallback
Bool(TIDY_CALL * TidyMessageCallback)(TidyMessage tmessage)
This typedef represents the required signature for your provided callback function should you wish to...
Definition: tidy.h:1286
_TidyDocImpl::footnotes
uint footnotes
Definition: tidy-int.h:78
_TidyMessageImpl::messageFormat
ctmbstr messageFormat
Definition: tidy-int.h:118
_TidyMessageImpl::code
uint code
Definition: tidy-int.h:105
_TidyDocImpl::allocator
TidyAllocator * allocator
Definition: tidy-int.h:84
TidyConfigChangeCallback
void(TIDY_CALL * TidyConfigChangeCallback)(TidyDoc tdoc, TidyOption option)
This typedef represents the required signature for your provided callback function should you wish to...
Definition: tidy.h:616
_TidyDocImpl::nClassId
uint nClassId
Definition: tidy-int.h:88
message.h
_TidyDocImpl::warnings
uint warnings
Definition: tidy-int.h:68
_TidyDocImpl::badLayout
uint badLayout
Definition: tidy-int.h:75
_TidyMessageImpl::messagePrefixDefault
ctmbstr messagePrefixDefault
Definition: tidy-int.h:126
_TidyDocImpl::reportCallback
TidyReportCallback reportCallback
Definition: tidy-int.h:58
_TidyMessageImpl::arguments
struct printfArg * arguments
Definition: tidy-int.h:113
_TidyDocImpl::docErrors
uint docErrors
Definition: tidy-int.h:71
TidyConfigCallback
Bool(TIDY_CALL * TidyConfigCallback)(TidyDoc tdoc, ctmbstr option, ctmbstr value)
This typedef represents the required signature for your provided callback function should you wish to...
Definition: tidy.h:597
_TidyDocImpl::xmlDetected
Bool xmlDetected
Definition: tidy-int.h:81
_TidyMessageImpl::allowMessage
Bool allowMessage
Definition: tidy-int.h:109
TidyOptCallback
Bool(TIDY_CALL * TidyOptCallback)(ctmbstr option, ctmbstr value)
This typedef represents the required signature for your provided callback function should you wish to...
Definition: tidy.h:573
SkipSiblings
@ SkipSiblings
Definition: tidy-int.h:170
TidyPrintImpl
Definition: pprint.h:49
_TidyDocImpl::docIn
StreamIn * docIn
Definition: tidy-int.h:54
_TidyDocImpl::infoMessages
uint infoMessages
Definition: tidy-int.h:70
TidyMutedMessages
Maintains a list of messages not to display.
Definition: message.h:194
_TidyDocImpl::progressCallback
TidyPPProgress progressCallback
Definition: tidy-int.h:63
_TidyDocImpl::messageCallback
TidyMessageCallback messageCallback
Definition: tidy-int.h:59
lexer.h
_TidyDocImpl::errout
StreamOut * errout
Definition: tidy-int.h:56
_TidyDocImpl::pConfigChangeCallback
TidyConfigChangeCallback pConfigChangeCallback
Definition: tidy-int.h:62
_TidyDocImpl::badAccess
uint badAccess
Definition: tidy-int.h:74
_TidyDocImpl::attribs
TidyAttribImpl attribs
Definition: tidy-int.h:46
_TidyDocImpl::errors
uint errors
Definition: tidy-int.h:67
pprint.h
_TidyDocImpl::muted
TidyMutedMessages muted
Definition: tidy-int.h:48
_TidyDocImpl::optionErrors
uint optionErrors
Definition: tidy-int.h:66
_TidyDocImpl::pOptCallback
TidyOptCallback pOptCallback
Definition: tidy-int.h:60
_TidyDocImpl::inputHadBOM
Bool inputHadBOM
Definition: tidy-int.h:89
_TidyMessageImpl::muted
Bool muted
Definition: tidy-int.h:110
_TidyMessageImpl::messagePrefix
ctmbstr messagePrefix
Definition: tidy-int.h:127
Bool
Bool
Definition: tidyplatform.h:647
access.h
TidyReportCallback
Bool(TIDY_CALL * TidyReportCallback)(TidyDoc tdoc, TidyReportLevel lvl, uint line, uint col, ctmbstr code, va_list args)
This typedef represents the required signature for your provided callback function should you wish to...
Definition: tidy.h:1260
config.h
TY_
#define TY_(str)
Definition: forward.h:23
ContinueTraversal
@ ContinueTraversal
Definition: tidy-int.h:168
tidy.h
_TidyDocImpl::badForm
uint badForm
Definition: tidy-int.h:77
_TidyMessageImpl
The basic struct for communicating a message within LibTidy.
Definition: tidy-int.h:102
SkipChildrenAndSiblings
@ SkipChildrenAndSiblings
Definition: tidy-int.h:171
TidyConfigImpl
This type is used to define a structure for keeping track of the values for each option.
Definition: config.h:122
_TidyDocImpl::pprint
TidyPrintImpl pprint
Definition: tidy-int.h:51
_TidyDocImpl::tags
TidyTagImpl tags
Definition: tidy-int.h:45
_TidyMessageImpl::line
int line
Definition: tidy-int.h:106
_TidyDocImpl::badChars
uint badChars
Definition: tidy-int.h:76
NodeTraversalCallBack
NodeTraversalSignal NodeTraversalCallBack(TidyDocImpl *doc, Node *node, void *propagate)
Definition: tidy-int.h:176
_TidyDocImpl::pConfigCallback
TidyConfigCallback pConfigCallback
Definition: tidy-int.h:61
_TidyDocImpl::docOut
StreamOut * docOut
Definition: tidy-int.h:55
_TidyMessageImpl::messageKey
ctmbstr messageKey
Definition: tidy-int.h:115
_TidyDocImpl::appData
void * appData
Definition: tidy-int.h:87
TidyPPProgress
void(TIDY_CALL * TidyPPProgress)(TidyDoc tdoc, uint line, uint col, uint destLine)
This typedef represents the required signature for your provided callback function should you wish to...
Definition: tidy.h:1532
_TidyDocImpl::config
TidyConfigImpl config
Definition: tidy-int.h:44
ctmbstr
const tmbchar * ctmbstr
Definition: tidyplatform.h:609