OSDN Git Service

フォルダ名変更
[wordring-tm/wordring-tm.git] / third-party / tidy-html5-master / src / tidy-int.h
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
35 struct _TidyDocImpl
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 */
43     TidyConfigImpl      config;
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 */
53     TidyPrintImpl       pprint;
54
55     /* I/O */
56     StreamIn*           docIn;
57     StreamOut*          docOut;
58     StreamOut*          errout;
59     TidyReportFilter    mssgFilt;
60     TidyReportFilter2   mssgFilt2;
61     TidyOptCallback     pOptCallback;
62
63     /* Parse + Repair Results */
64     uint                optionErrors;
65     uint                errors;
66     uint                warnings;
67     uint                accessErrors;
68     uint                infoMessages;
69     uint                docErrors;
70     int                 parseStatus;
71
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 */
76
77     /* Memory allocator */
78     TidyAllocator*      allocator;
79
80     /* Miscellaneous */
81     void*               appData;
82     uint                nClassId;
83     Bool                inputHadBOM;
84
85 #ifdef TIDY_STORE_ORIGINAL_TEXT
86     Bool                storeText;
87 #endif
88
89 #if PRESERVE_FILE_TIMES
90     struct utimbuf      filetimes;
91 #endif
92     tmbstr              givenDoctype;
93 };
94
95
96 /* Twizzle internal/external types */
97 #ifdef NEVER
98 TidyDocImpl* tidyDocToImpl( TidyDoc tdoc );
99 TidyDoc      tidyImplToDoc( TidyDocImpl* impl );
100
101 Node*        tidyNodeToImpl( TidyNode tnod );
102 TidyNode     tidyImplToNode( Node* node );
103
104 AttVal*      tidyAttrToImpl( TidyAttr tattr );
105 TidyAttr     tidyImplToAttr( AttVal* attval );
106
107 const TidyOptionImpl* tidyOptionToImpl( TidyOption topt );
108 TidyOption   tidyImplToOption( const TidyOptionImpl* option );
109 #else
110
111 #define tidyDocToImpl( tdoc )       ((TidyDocImpl*)(tdoc))
112 #define tidyImplToDoc( doc )        ((TidyDoc)(doc))
113
114 #define tidyNodeToImpl( tnod )      ((Node*)(tnod))
115 #define tidyImplToNode( node )      ((TidyNode)(node))
116
117 #define tidyAttrToImpl( tattr )     ((AttVal*)(tattr))
118 #define tidyImplToAttr( attval )    ((TidyAttr)(attval))
119
120 #define tidyOptionToImpl( topt )    ((const TidyOptionImpl*)(topt))
121 #define tidyImplToOption( option )  ((TidyOption)(option))
122
123 #endif
124
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)
130
131 int          TY_(DocParseStream)( TidyDocImpl* impl, StreamIn* in );
132
133 /*
134    [i_a] generic node tree traversal code; used in several spots.
135
136    Define your own callback, which returns one of the NodeTraversalSignal values
137    to instruct the tree traversal routine TraverseNodeTree() what to do.
138
139    Pass custom data to/from the callback using the 'propagate' reference.
140  */
141 typedef enum
142 {
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;
150
151 typedef NodeTraversalSignal NodeTraversalCallBack(TidyDocImpl* doc, Node* node, void *propagate);
152
153 NodeTraversalSignal TY_(TraverseNodeTree)(TidyDocImpl* doc, Node* node, NodeTraversalCallBack *cb, void *propagate);
154
155 #endif /* __TIDY_INT_H__ */