1 | /* makeinfo.h -- declarations for Makeinfo. |
---|
2 | $Id: makeinfo.h,v 1.1.1.2 2003-02-28 17:45:09 amb Exp $ |
---|
3 | |
---|
4 | Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software |
---|
5 | Foundation, Inc. |
---|
6 | |
---|
7 | This program is free software; you can redistribute it and/or modify |
---|
8 | it under the terms of the GNU General Public License as published by |
---|
9 | the Free Software Foundation; either version 2, or (at your option) |
---|
10 | any later version. |
---|
11 | |
---|
12 | This program is distributed in the hope that it will be useful, |
---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | GNU General Public License for more details. |
---|
16 | |
---|
17 | You should have received a copy of the GNU General Public License |
---|
18 | along with this program; if not, write to the Free Software |
---|
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
20 | |
---|
21 | Written by Brian Fox (bfox@ai.mit.edu). */ |
---|
22 | |
---|
23 | #ifndef MAKEINFO_H |
---|
24 | #define MAKEINFO_H |
---|
25 | |
---|
26 | #ifdef COMPILING_MAKEINFO |
---|
27 | # define DECLARE(type,var,init) type var = init |
---|
28 | #else |
---|
29 | # define DECLARE(type,var,init) extern type var |
---|
30 | #endif |
---|
31 | |
---|
32 | /* Hardcoded per GNU standards, not dependent on argv[0]. */ |
---|
33 | DECLARE (char *, progname, "makeinfo"); |
---|
34 | |
---|
35 | enum reftype |
---|
36 | { |
---|
37 | menu_reference, followed_reference |
---|
38 | }; |
---|
39 | |
---|
40 | extern char *get_xref_token (); |
---|
41 | |
---|
42 | /* Nonzero means a string is in execution, as opposed to a file. */ |
---|
43 | DECLARE (int, executing_string, 0); |
---|
44 | |
---|
45 | /* Nonzero means to inhibit writing macro expansions to the output |
---|
46 | stream, because it has already been written. */ |
---|
47 | DECLARE (int, me_inhibit_expansion, 0); |
---|
48 | |
---|
49 | extern char *expansion (), *text_expansion (), *full_expansion (); |
---|
50 | |
---|
51 | /* Current output stream. */ |
---|
52 | DECLARE (FILE *, output_stream, NULL); |
---|
53 | |
---|
54 | DECLARE (char *, pretty_output_filename, NULL); |
---|
55 | |
---|
56 | /* Current output file name. */ |
---|
57 | DECLARE (char *, current_output_filename, NULL); |
---|
58 | |
---|
59 | /* Output paragraph buffer. */ |
---|
60 | DECLARE (unsigned char *, output_paragraph, NULL); |
---|
61 | |
---|
62 | /* Offset into OUTPUT_PARAGRAPH. */ |
---|
63 | DECLARE (int, output_paragraph_offset, 0); |
---|
64 | |
---|
65 | /* The output paragraph "cursor" horizontal position. */ |
---|
66 | DECLARE (int, output_column, 0); |
---|
67 | |
---|
68 | /* Position in the output file. */ |
---|
69 | DECLARE (int, output_position, 0); |
---|
70 | |
---|
71 | /* The offset into OUTPUT_PARAGRAPH where we have a meta character |
---|
72 | produced by a markup such as @code or @dfn. */ |
---|
73 | DECLARE (int, meta_char_pos, -1); |
---|
74 | |
---|
75 | /* Nonzero means output_paragraph contains text. */ |
---|
76 | DECLARE (int, paragraph_is_open, 0); |
---|
77 | |
---|
78 | /* Nonzero means that `start_paragraph' MUST be called before we pay |
---|
79 | any attention to `close_paragraph' calls. */ |
---|
80 | DECLARE (int, must_start_paragraph, 0); |
---|
81 | |
---|
82 | /* Nonzero means that we have seen "@top" once already. */ |
---|
83 | DECLARE (int, top_node_seen, 0); |
---|
84 | |
---|
85 | /* Nonzero means that we have seen a non-"@top" node already. */ |
---|
86 | DECLARE (int, non_top_node_seen, 0); |
---|
87 | |
---|
88 | /* Nonzero indicates that indentation is temporarily turned off. */ |
---|
89 | DECLARE (int, no_indent, 1); |
---|
90 | |
---|
91 | /* Nonzero indicates that filling a line also indents the new line. */ |
---|
92 | DECLARE (int, indented_fill, 0); |
---|
93 | |
---|
94 | /* Nonzero means forcing output text to be flushright. */ |
---|
95 | DECLARE (int, force_flush_right, 0); |
---|
96 | |
---|
97 | /* The amount of indentation to apply at the start of each line. */ |
---|
98 | DECLARE (int, current_indent, 0); |
---|
99 | |
---|
100 | /* The column at which long lines are broken. */ |
---|
101 | DECLARE (int, fill_column, 72); |
---|
102 | |
---|
103 | /* Nonzero means that words are not to be split, even in long lines. This |
---|
104 | gets changed for cm_w (). */ |
---|
105 | DECLARE (int, non_splitting_words, 0); |
---|
106 | |
---|
107 | /* Amount by which @example indentation increases/decreases. */ |
---|
108 | DECLARE (int, default_indentation_increment, 5); |
---|
109 | |
---|
110 | /* Nonzero means that we are currently hacking the insides of an |
---|
111 | insertion which would use a fixed width font. */ |
---|
112 | DECLARE (int, in_fixed_width_font, 0); |
---|
113 | |
---|
114 | /* Nonzero if we are currently processing a multitable command */ |
---|
115 | DECLARE (int, multitable_active, 0); |
---|
116 | |
---|
117 | /* Nonzero means that we're generating HTML. */ |
---|
118 | DECLARE (int, html, 0); |
---|
119 | |
---|
120 | /* Nonzero means that we're generating XML. */ |
---|
121 | DECLARE (int, xml, 0); |
---|
122 | |
---|
123 | /* Nonzero means that we're generating DocBook. */ |
---|
124 | DECLARE (int, docbook, 0); |
---|
125 | |
---|
126 | /* Nonzero means true 8-bit output for Info and plain text. */ |
---|
127 | DECLARE (int, enable_encoding, 0); |
---|
128 | |
---|
129 | /* Nonzero means escape characters in HTML output. */ |
---|
130 | DECLARE (int, escape_html, 1); |
---|
131 | extern char *escape_string (); /* do HTML escapes */ |
---|
132 | |
---|
133 | /* Access key number for next menu entry to be generated (1 to 9, or 10 to |
---|
134 | mean no access key) */ |
---|
135 | DECLARE (int, next_menu_item_number, 1); |
---|
136 | |
---|
137 | /* Nonzero means that the use of paragraph_start_indent is inhibited. |
---|
138 | @example uses this to line up the left columns of the example text. |
---|
139 | A negative value for this variable is incremented each time it is used. |
---|
140 | @noindent uses this to inhibit indentation for a single paragraph. */ |
---|
141 | DECLARE (int, inhibit_paragraph_indentation, 0); |
---|
142 | |
---|
143 | /* Nonzero indicates that filling will take place on long lines. */ |
---|
144 | DECLARE (int, filling_enabled, 1); |
---|
145 | |
---|
146 | /* The current node's node name. */ |
---|
147 | DECLARE (char *, current_node, NULL); |
---|
148 | |
---|
149 | /* Command name in the process of being hacked. */ |
---|
150 | DECLARE (char *, command, NULL); |
---|
151 | |
---|
152 | /* @copying ... @end copying. */ |
---|
153 | DECLARE (char *, copying_text, NULL); |
---|
154 | |
---|
155 | /* @documentdescription ... @end documentdescription. */ |
---|
156 | DECLARE (char *, document_description, NULL); |
---|
157 | |
---|
158 | /* Nonzero if the last character inserted has the syntax class of NEWLINE. */ |
---|
159 | DECLARE (int, last_char_was_newline, 1); |
---|
160 | |
---|
161 | /* The current input file state. */ |
---|
162 | DECLARE (char *, input_filename, (char *)NULL); |
---|
163 | DECLARE (char *, input_text, (char *)NULL); |
---|
164 | DECLARE (int, input_text_length, 0); |
---|
165 | DECLARE (int, input_text_offset, 0); |
---|
166 | DECLARE (int, line_number, 0); |
---|
167 | DECLARE (char *, toplevel_output_filename, NULL); |
---|
168 | #define curchar() input_text[input_text_offset] |
---|
169 | |
---|
170 | /* A colon separated list of directories to search for files included |
---|
171 | with @include. This can be controlled with the `-I' option to makeinfo. */ |
---|
172 | DECLARE (char *, include_files_path, NULL); |
---|
173 | |
---|
174 | /* The filename of the current input file. This is never freed. */ |
---|
175 | DECLARE (char *, node_filename, NULL); |
---|
176 | |
---|
177 | /* Nonzero means do not output "Node: Foo" for node separations, that |
---|
178 | is, generate plain text. (--no-headers) */ |
---|
179 | DECLARE (int, no_headers, 0); |
---|
180 | |
---|
181 | /* Nonzero means that we process @html and @rawhtml even when not |
---|
182 | generating HTML. (--ifhtml) */ |
---|
183 | DECLARE (int, process_html, 0); |
---|
184 | |
---|
185 | /* Positive means process @ifinfo (even if not generating Info); |
---|
186 | zero means don't process @ifinfo (even if we are); |
---|
187 | -1 means we don't know yet. (--ifinfo) */ |
---|
188 | DECLARE (int, process_info, -1); |
---|
189 | |
---|
190 | /* Positive means process @ifplaintext (even if not generating plain text); |
---|
191 | zero means we don't process @ifplaintext (even if we are); |
---|
192 | -1 means we don't know yet. (--ifplaintext) */ |
---|
193 | DECLARE (int, process_plaintext, -1); |
---|
194 | |
---|
195 | /* Nonzero means that we process @tex and @iftex. (--iftex) */ |
---|
196 | DECLARE (int, process_tex, 0); |
---|
197 | |
---|
198 | /* Nonzero means that we process @xml and @ifxml. (--ifxml) */ |
---|
199 | DECLARE (int, process_xml, 0); |
---|
200 | |
---|
201 | /* Maximum number of references to a single node before complaining. |
---|
202 | (--reference-limit) */ |
---|
203 | DECLARE (int, reference_warning_limit, 1000); |
---|
204 | |
---|
205 | /* Default is to check node references. (--no-validate) */ |
---|
206 | DECLARE (int, validating, 1); |
---|
207 | |
---|
208 | /* Nonzero means print information about what is going on. (--verbose) */ |
---|
209 | DECLARE (int, verbose_mode, 0); |
---|
210 | |
---|
211 | /* Nonzero means prefix each @chapter, ... with a number like 1. (--number-sections) */ |
---|
212 | DECLARE (int, number_sections, 0); |
---|
213 | |
---|
214 | /* Nonzero means split size. When zero, DEFAULT_SPLIT_SIZE is used. */ |
---|
215 | DECLARE (int, split_size, 0); |
---|
216 | |
---|
217 | /* Nonzero means expand node names and references while validating. |
---|
218 | This will avoid errors when the Texinfo document uses features |
---|
219 | like @@ and @value inconsistently in node names, but will slow |
---|
220 | the program by about 80%. You HAVE been warned. */ |
---|
221 | DECLARE (int, expensive_validation, 0); |
---|
222 | |
---|
223 | /* C's standard macros don't check to make sure that the characters being |
---|
224 | changed are within range. So I have to check explicitly. */ |
---|
225 | |
---|
226 | #define coerce_to_upper(c) ((islower(c) ? toupper(c) : (c))) |
---|
227 | #define coerce_to_lower(c) ((isupper(c) ? tolower(c) : (c))) |
---|
228 | |
---|
229 | #define control_character_bit 0x40 /* %01000000, must be off. */ |
---|
230 | #define meta_character_bit 0x080/* %10000000, must be on. */ |
---|
231 | #define CTL(c) ((c) & (~control_character_bit)) |
---|
232 | #define UNCTL(c) coerce_to_upper(((c)|control_character_bit)) |
---|
233 | #define META(c) ((c) | (meta_character_bit)) |
---|
234 | #define UNMETA(c) ((c) & (~meta_character_bit)) |
---|
235 | |
---|
236 | #define whitespace(c) ((c) == '\t' || (c) == ' ') |
---|
237 | #define sentence_ender(c) ((c) == '.' || (c) == '?' || (c) == '!') |
---|
238 | #define cr_or_whitespace(c) (whitespace(c) || (c) == '\r' || (c) == '\n') |
---|
239 | |
---|
240 | #ifndef isletter |
---|
241 | #define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z')) |
---|
242 | #endif |
---|
243 | |
---|
244 | #ifndef isupper |
---|
245 | #define isupper(c) ((c) >= 'A' && (c) <= 'Z') |
---|
246 | #endif |
---|
247 | |
---|
248 | #ifndef isdigit |
---|
249 | #define isdigit(c) ((c) >= '0' && (c) <= '9') |
---|
250 | #endif |
---|
251 | |
---|
252 | #ifndef digit_value |
---|
253 | #define digit_value(c) ((c) - '0') |
---|
254 | #endif |
---|
255 | |
---|
256 | #define HTML_SAFE "$-_.+!*'()" |
---|
257 | #define URL_SAFE_CHAR(ch) (isalnum (ch) || strchr (HTML_SAFE, ch)) |
---|
258 | |
---|
259 | #define COMMAND_PREFIX '@' |
---|
260 | |
---|
261 | #define END_VERBATIM "end verbatim" |
---|
262 | |
---|
263 | /* Stuff for splitting large files. */ |
---|
264 | #define SPLIT_SIZE_THRESHOLD 70000 /* What's good enough for Stallman... */ |
---|
265 | #define DEFAULT_SPLIT_SIZE 50000 /* Is probably good enough for me. */ |
---|
266 | DECLARE (int, splitting, 1); /* Defaults to true for now. */ |
---|
267 | |
---|
268 | #define skip_whitespace() \ |
---|
269 | while ((input_text_offset != input_text_length) && \ |
---|
270 | whitespace (curchar())) \ |
---|
271 | input_text_offset++ |
---|
272 | |
---|
273 | #define skip_whitespace_and_newlines() \ |
---|
274 | do { \ |
---|
275 | while (input_text_offset != input_text_length \ |
---|
276 | && cr_or_whitespace (curchar ())) \ |
---|
277 | { \ |
---|
278 | if (curchar () == '\n') \ |
---|
279 | line_number++; \ |
---|
280 | input_text_offset++; \ |
---|
281 | } \ |
---|
282 | } while (0) |
---|
283 | |
---|
284 | /* Return nonzero if STRING is the text at input_text + input_text_offset, |
---|
285 | else zero. */ |
---|
286 | #define looking_at(string) \ |
---|
287 | (strncmp (input_text + input_text_offset, string, strlen (string)) == 0) |
---|
288 | |
---|
289 | #endif /* not MAKEINFO_H */ |
---|