Version:
~ [ 1.0 ] ~
1 #ifndef __CONFIG_H__
2 #define __CONFIG_H__
3
4 /* config.h -- read config file and manage config properties
5
6 (c) 1998-2005 (W3C) MIT, ERCIM, Keio University
7 See tidy.h for the copyright notice.
8
9 CVS Info :
10
11 $Author: arnaud02 $
12 $Date: 2005/03/31 13:10:34 $
13 $Revision: 1.10 $
14
15 config files associate a property name with a value.
16
17 // comments can start at the beginning of a line
18 # comments can start at the beginning of a line
19 name: short values fit onto one line
20 name: a really long value that
21 continues on the next line
22
23 property names are case insensitive and should be less than
24 60 characters in length and must start at the begining of
25 the line, as whitespace at the start of a line signifies a
26 line continuation.
27
28 */
29
30 #include "forward.h"
31 #include "tidy.h"
32 #include "streamio.h"
33
34 struct _tidy_option;
35 typedef struct _tidy_option TidyOptionImpl;
36
37 typedef Bool (ParseProperty)( TidyDocImpl* doc, const TidyOptionImpl* opt );
38
39 struct _tidy_option
40 {
41 TidyOptionId id;
42 TidyConfigCategory category; /* put 'em in groups */
43 ctmbstr name; /* property name */
44 TidyOptionType type; /* string, int or bool */
45 ulong dflt; /* factory default */
46 ParseProperty* parser; /* parsing method, read-only if NULL */
47 const ctmbstr* pickList; /* pick list */
48 };
49
50
51 typedef struct _tidy_config
52 {
53 ulong value[ N_TIDY_OPTIONS + 1 ]; /* current config values */
54 ulong snapshot[ N_TIDY_OPTIONS + 1 ]; /* Snapshot of values to be restored later */
55
56 /* track what tags user has defined to eliminate unnecessary searches */
57 uint defined_tags;
58
59 uint c; /* current char in input stream */
60 StreamIn* cfgIn; /* current input source */
61
62 } TidyConfigImpl;
63
64
65 typedef struct {
66 TidyOptionId opt; /**< Identifier. */
67 ctmbstr doc; /**< HTML text */
68 TidyOptionId const *links; /**< Cross references.
69 Last element must be 'TidyUnknownOption'. */
70 } TidyOptionDoc;
71
72
73 const TidyOptionImpl* lookupOption( ctmbstr optnam );
74 const TidyOptionImpl* getOption( TidyOptionId optId );
75
76 TidyIterator getOptionList( TidyDocImpl* doc );
77 const TidyOptionImpl* getNextOption( TidyDocImpl* doc, TidyIterator* iter );
78
79 TidyIterator getOptionPickList( const TidyOptionImpl* option );
80 ctmbstr getNextOptionPick( const TidyOptionImpl* option, TidyIterator* iter );
81
82 const TidyOptionDoc* tidyOptGetDocDesc( TidyOptionId optId );
83
84 void InitConfig( TidyDocImpl* doc );
85 void FreeConfig( TidyDocImpl* doc );
86
87 Bool SetOptionValue( TidyDocImpl* doc, TidyOptionId optId, ctmbstr val );
88 Bool SetOptionInt( TidyDocImpl* doc, TidyOptionId optId, ulong val );
89 Bool SetOptionBool( TidyDocImpl* doc, TidyOptionId optId, Bool val );
90
91 Bool ResetOptionToDefault( TidyDocImpl* doc, TidyOptionId optId );
92 void ResetConfigToDefault( TidyDocImpl* doc );
93 void TakeConfigSnapshot( TidyDocImpl* doc );
94 void ResetConfigToSnapshot( TidyDocImpl* doc );
95
96 void CopyConfig( TidyDocImpl* docTo, TidyDocImpl* docFrom );
97
98 /*
99 Todd Lewis contributed this code for expanding
100 ~/foo or ~your/foo according to $HOME and your
101 user name. This will only work on Unix systems.
102 */
103 ctmbstr ExpandTilde(ctmbstr filename);
104
105 int ParseConfigFile( TidyDocImpl* doc, ctmbstr cfgfil );
106 int ParseConfigFileEnc( TidyDocImpl* doc,
107 ctmbstr cfgfil, ctmbstr charenc );
108
109 int SaveConfigFile( TidyDocImpl* doc, ctmbstr cfgfil );
110 int SaveConfigSink( TidyDocImpl* doc, TidyOutputSink* sink );
111
112 /* returns false if unknown option, missing parameter, or
113 option doesn't use parameter
114 */
115 Bool ParseConfigOption( TidyDocImpl* doc, ctmbstr optnam, ctmbstr optVal );
116 Bool ParseConfigValue( TidyDocImpl* doc, TidyOptionId optId, ctmbstr optVal );
117
118 /* ensure that char encodings are self consistent */
119 Bool AdjustCharEncoding( TidyDocImpl* doc, int encoding );
120
121 /* ensure that config is self consistent */
122 void AdjustConfig( TidyDocImpl* doc );
123
124 Bool ConfigDiffThanDefault( TidyDocImpl* doc );
125 Bool ConfigDiffThanSnapshot( TidyDocImpl* doc );
126
127 int CharEncodingId( ctmbstr charenc );
128 ctmbstr CharEncodingName( int encoding );
129 ctmbstr CharEncodingOptName( int encoding );
130
131 void SetEmacsFilename( TidyDocImpl* doc, ctmbstr filename );
132
133
134 #ifdef _DEBUG
135
136 /* Debug lookup functions will be type-safe and assert option type match */
137 ulong _cfgGet( TidyDocImpl* doc, TidyOptionId optId );
138 Bool _cfgGetBool( TidyDocImpl* doc, TidyOptionId optId );
139 TidyTriState _cfgGetAutoBool( TidyDocImpl* doc, TidyOptionId optId );
140 ctmbstr _cfgGetString( TidyDocImpl* doc, TidyOptionId optId );
141
142 #define cfg(doc, id) _cfgGet( (doc), (id) )
143 #define cfgBool(doc, id) _cfgGetBool( (doc), (id) )
144 #define cfgAutoBool(doc, id) _cfgGetAutoBool( (doc), (id) )
145 #define cfgStr(doc, id) _cfgGetString( (doc), (id) )
146
147 #else
148
149 /* Release build macros for speed */
150 #define cfg(doc, id) ((doc)->config.value[ (id) ])
151 #define cfgBool(doc, id) ((Bool) cfg(doc, id))
152 #define cfgAutoBool(doc, id) ((TidyTriState) cfg(doc, id))
153 #define cfgStr(doc, id) ((ctmbstr) cfg(doc, id))
154
155 #endif /* _DEBUG */
156
157
158
159 /* parser for integer values */
160 ParseProperty ParseInt;
161
162 /* parser for 't'/'f', 'true'/'false', 'y'/'n', 'yes'/'no' or '1'/'' */
163 ParseProperty ParseBool;
164
165 /* parser for 't'/'f', 'true'/'false', 'y'/'n', 'yes'/'no', '1'/''
166 or 'auto' */
167 ParseProperty ParseAutoBool;
168
169 /* a string excluding whitespace */
170 ParseProperty ParseName;
171
172 /* a CSS1 selector - CSS class naming for -clean option */
173 ParseProperty ParseCSS1Selector;
174
175 /* a string including whitespace */
176 ParseProperty ParseString;
177
178 /* a space or comma separated list of tag names */
179 ParseProperty ParseTagNames;
180
181 /* RAW, ASCII, LATIN0, LATIN1, UTF8, ISO2022, MACROMAN,
182 WIN1252, IBM858, UTF16LE, UTF16BE, UTF16, BIG5, SHIFTJIS
183 */
184 ParseProperty ParseCharEnc;
185 ParseProperty ParseNewline;
186
187 /* omit | auto | strict | loose | <fpi> */
188 ParseProperty ParseDocType;
189
190 /* keep-first or keep-last? */
191 ParseProperty ParseRepeatAttr;
192
193 #endif /* __CONFIG_H__ */
194
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.