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   CVS Info :
10 
11     $Author: arnaud02 $
12     $Date: 2007/02/11 09:45:52 $
13     $Revision: 1.13 $
14 
15 */
16 
17 #include "tidy.h"
18 #include "config.h"
19 #include "lexer.h"
20 #include "tags.h"
21 #include "attrs.h"
22 #include "pprint.h"
23 #include "access.h"
24 
25 #ifndef MAX
26 #define MAX(a,b) (((a) > (b))?(a):(b))
27 #endif
28 #ifndef MIN
29 #define MIN(a,b) (((a) < (b))?(a):(b))
30 #endif
31 
32 struct _TidyDocImpl
33 {
34     /* The Document Tree (and backing store buffer) */
35     Node                root;       /* This MUST remain the first declared
36                                        variable in this structure */
37     Lexer*              lexer;
38 
39     /* Config + Markup Declarations */
40     TidyConfigImpl      config;
41     TidyTagImpl         tags;
42     TidyAttribImpl      attribs;
43 
44 #if SUPPORT_ACCESSIBILITY_CHECKS
45     /* Accessibility Checks state */
46     TidyAccessImpl      access;
47 #endif
48 
49     /* The Pretty Print buffer */
50     TidyPrintImpl       pprint;
51 
52     /* I/O */
53     StreamIn*           docIn;
54     StreamOut*          docOut;
55     StreamOut*          errout;
56     TidyReportFilter    mssgFilt;
57     TidyOptCallback     pOptCallback;
58 
59     /* Parse + Repair Results */
60     uint                optionErrors;
61     uint                errors;
62     uint                warnings;
63     uint                accessErrors;
64     uint                infoMessages;
65     uint                docErrors;
66     int                 parseStatus;
67 
68     uint                badAccess;   /* for accessibility errors */
69     uint                badLayout;   /* for bad style errors */
70     uint                badChars;    /* for bad char encodings */
71     uint                badForm;     /* for badly placed form tags */
72 
73     /* Memory allocator */
74     TidyAllocator*      allocator;
75 
76     /* Miscellaneous */
77     void*               appData;
78     uint                nClassId;
79     Bool                inputHadBOM;
80 
81 #ifdef TIDY_STORE_ORIGINAL_TEXT
82     Bool                storeText;
83 #endif
84 
85 #if PRESERVE_FILE_TIMES
86     struct utimbuf      filetimes;
87 #endif
88     tmbstr              givenDoctype;
89 };
90 
91 
92 /* Twizzle internal/external types */
93 #ifdef NEVER
94 TidyDocImpl* tidyDocToImpl( TidyDoc tdoc );
95 TidyDoc      tidyImplToDoc( TidyDocImpl* impl );
96 
97 Node*        tidyNodeToImpl( TidyNode tnod );
98 TidyNode     tidyImplToNode( Node* node );
99 
100 AttVal*      tidyAttrToImpl( TidyAttr tattr );
101 TidyAttr     tidyImplToAttr( AttVal* attval );
102 
103 const TidyOptionImpl* tidyOptionToImpl( TidyOption topt );
104 TidyOption   tidyImplToOption( const TidyOptionImpl* option );
105 #else
106 
107 #define tidyDocToImpl( tdoc )       ((TidyDocImpl*)(tdoc))
108 #define tidyImplToDoc( doc )        ((TidyDoc)(doc))
109 
110 #define tidyNodeToImpl( tnod )      ((Node*)(tnod))
111 #define tidyImplToNode( node )      ((TidyNode)(node))
112 
113 #define tidyAttrToImpl( tattr )     ((AttVal*)(tattr))
114 #define tidyImplToAttr( attval )    ((TidyAttr)(attval))
115 
116 #define tidyOptionToImpl( topt )    ((const TidyOptionImpl*)(topt))
117 #define tidyImplToOption( option )  ((TidyOption)(option))
118 
119 #endif
120 
121 /** Wrappers for easy memory allocation using the document's allocator */
122 #define TidyDocAlloc(doc, size) TidyAlloc((doc)->allocator, size)
123 #define TidyDocRealloc(doc, block, size) TidyRealloc((doc)->allocator, block, size)
124 #define TidyDocFree(doc, block) TidyFree((doc)->allocator, block)
125 #define TidyDocPanic(doc, msg) TidyPanic((doc)->allocator, msg)
126 
127 int          TY_(DocParseStream)( TidyDocImpl* impl, StreamIn* in );
128 
129 #endif /* __TIDY_INT_H__ */
130