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