Initial import of binutils 2.22 on the new vendor branch
[dragonfly.git] / contrib / texinfo / makeinfo / makeinfo.h
1 /* makeinfo.h -- declarations for Makeinfo.
2    $Id: makeinfo.h,v 1.31 2008/03/26 23:57:12 karl Exp $
3
4    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5    2005, 2006, 2007, 2008 Free Software 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 3 of the License, or
10    (at your option) 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, see <http://www.gnu.org/licenses/>.
19
20    Written by Brian Fox (bfox@ai.mit.edu). */
21
22 #ifndef MAKEINFO_H
23 #define MAKEINFO_H
24
25 #ifdef COMPILING_MAKEINFO
26 #  define DECLARE(type,var,init) type var = init
27 #else
28 #  define DECLARE(type,var,init) extern type var
29 #endif
30
31 /* Hardcoded per GNU standards, not dependent on argv[0].  */
32 DECLARE (char *, progname, "makeinfo");
33 \f
34 /* Nonzero means a string is in execution, as opposed to a file. */
35 DECLARE (int, executing_string, 0);
36
37 /* Nonzero means to inhibit writing macro expansions to the output
38    stream, because it has already been written. */
39 DECLARE (int, me_inhibit_expansion, 0);
40 \f
41 /* Current output stream. */
42 DECLARE (FILE *, output_stream, NULL);
43
44 DECLARE (char *, pretty_output_filename, NULL);
45
46 /* Current output file name.  */
47 DECLARE (char *, current_output_filename, NULL);
48
49 /* Output paragraph buffer and its length. */
50 #define INITIAL_PARAGRAPH_BUFFER_LEN 5000
51 DECLARE (unsigned char *, output_paragraph, NULL);
52 DECLARE (int, paragraph_buffer_len, INITIAL_PARAGRAPH_BUFFER_LEN);
53
54 /* Offset into OUTPUT_PARAGRAPH. */
55 DECLARE (int, output_paragraph_offset, 0);
56
57 /* Position in the output file. */
58 DECLARE (int, output_position, 0);
59
60 /* Number of lines in the output.  */
61 DECLARE (int, output_line_number, 1);
62 DECLARE (int, node_line_number, 0);
63
64 /* The offset into OUTPUT_PARAGRAPH where we have a meta character
65    produced by a markup such as @code or @dfn.  */
66 DECLARE (int, meta_char_pos, -1);
67
68 /* Nonzero means output_paragraph contains text. */
69 DECLARE (int, paragraph_is_open, 0);
70
71 /* Nonzero means that `start_paragraph' MUST be called before we pay
72    any attention to `close_paragraph' calls. */
73 DECLARE (int, must_start_paragraph, 0);
74
75 /* Nonzero if we have output the topmatter of the output file.  */
76 DECLARE (int, output_head_p, 0);
77
78 /* Nonzero means that we have seen "@top" once already. */
79 DECLARE (int, top_node_seen, 0);
80
81 /* Nonzero means that we have seen a non-"@top" node already. */
82 DECLARE (int, non_top_node_seen, 0);
83
84 /* Nonzero indicates that indentation is temporarily turned off. */
85 DECLARE (int, no_indent, 1);
86
87 /* The amount of indentation to apply at the start of each line. */
88 DECLARE (int, current_indent, 0);
89
90 /* Nonzero means that we suppress the indentation of the first paragraph
91    following any section heading.  */
92 DECLARE (int, do_first_par_indent, 0);
93
94 /* Amount by which @example indentation increases/decreases. */
95 DECLARE (int, example_indentation_increment, 5);
96
97 /* Amount by which @table, @defun, etc. indentation increases/decreases.  */
98 DECLARE (int, default_indentation_increment, 5);
99
100 /* Amount by which xml indentation increases/decreases.
101    Zero means unnecessary whitespace is compressed.  */
102 DECLARE (int, xml_indentation_increment, 2);
103
104 /* Nonzero indicates that filling a line also indents the new line. */
105 DECLARE (int, indented_fill, 0);
106
107 /* Nonzero means forcing output text to be flushright. */
108 DECLARE (int, force_flush_right, 0);
109
110 /* The column at which long lines are broken. */
111 DECLARE (int, fill_column, 72);
112
113 /* Nonzero means we're doing one space after sentences (@frenchspacing).  */
114 DECLARE (int, french_spacing, 0);
115
116 /* Nonzero means that words are not to be split, even in long lines.  This
117    gets changed for cm_w (). */
118 DECLARE (int, non_splitting_words, 0);
119
120 /* Nonzero means that we are currently hacking the insides of an
121    insertion which would use a fixed width font. */
122 DECLARE (int, in_fixed_width_font, 0);
123
124 /* Nonzero if we are currently processing a multitable command */
125 DECLARE (int, multitable_active, 0);
126
127 /* Nonzero means that we're generating HTML. (--html) */
128 DECLARE (int, html, 0);
129
130 /* Nonzero means that we're generating XML. (--xml) */
131 DECLARE (int, xml, 0);
132
133 /* Nonzero means that we're generating DocBook. (--docbook) */
134 DECLARE (int, docbook, 0);
135
136 /* Nonzero means 8-bit output for Info and plain text, according to
137    @documentencoding.  (--enable-encoding) */
138 DECLARE (int, enable_encoding, 1);
139
140 /* Nonzero means escape characters in HTML output. */
141 DECLARE (int, escape_html, 1);
142
143 /* Access key number for next menu entry to be generated (1 to 9, or 10 to
144    mean no access key)  */
145 DECLARE (int, next_menu_item_number, 1);
146
147 /* Nonzero means that the use of paragraph_start_indent is inhibited.
148    @example uses this to line up the left columns of the example text.
149    A negative value for this variable is incremented each time it is used.
150    @noindent uses this to inhibit indentation for a single paragraph.  */
151 DECLARE (int, inhibit_paragraph_indentation, 0);
152
153 /* Nonzero indicates that filling will take place on long lines. */
154 DECLARE (int, filling_enabled, 1);
155
156 /* The current node's node name. */
157 DECLARE (char *, current_node, NULL);
158
159 /* Command name in the process of being hacked. */
160 DECLARE (char *, command, NULL);
161
162 /* Nonzero if we have seen an @titlepage command.  */
163 DECLARE (int, titlepage_cmd_present, 0);
164
165 /* @copying ... @end copying. */
166 DECLARE (char *, copying_text, NULL);
167
168 /* @documentdescription ... @end documentdescription. */
169 DECLARE (const char *, document_description, NULL);
170
171 /* Nonzero if the last character inserted has the syntax class of NEWLINE. */
172 DECLARE (int, last_char_was_newline, 1);
173
174 /* The current input file state. */
175 DECLARE (char *, input_filename, (char *)NULL);
176 DECLARE (char *, input_text, (char *)NULL);
177 DECLARE (int, input_text_length, 0);
178 DECLARE (int, input_text_offset, 0);
179 DECLARE (int, line_number, 0);
180 DECLARE (char *, toplevel_output_filename, NULL);
181 #define curchar() input_text[input_text_offset]
182 \f
183 /* A colon separated list of directories to search for files included
184    with @include.  This can be controlled with the `-I' option to makeinfo. */
185 DECLARE (char *, include_files_path, NULL);
186
187 /* The filename of the current input file.  This is never freed. */
188 DECLARE (char *, node_filename, NULL);
189 \f
190 /* Name of CSS file to include, if any.  (--css-include).  */
191 DECLARE (char *, css_include, NULL);
192
193 /* Name of CSS to reference, if any.  (--css-ref).  */
194 DECLARE (char *, css_ref, NULL);
195
196 /* Transliterate file names into ASCII */
197 DECLARE (int, transliterate_file_names, 0);
198
199 /* Nonzero means do not output "Node: Foo" for node separations, that
200    is, generate plain text.  (--no-headers) */
201 DECLARE (int, no_headers, 0);
202
203 /* Nonzero means that we process @docbook and @ifdocbook.  (--ifdocbook) */
204 DECLARE (int, process_docbook, 0);
205
206 /* Nonzero means that we process @html and @rawhtml even when not
207    generating HTML.  (--ifhtml) */
208 DECLARE (int, process_html, 0);
209
210 /* Positive means process @ifinfo (even if not generating Info);
211    zero means don't process @ifinfo (even if we are);
212    -1 means we don't know yet.  (--ifinfo) */
213 DECLARE (int, process_info, -1);
214
215 /* Positive means process @ifplaintext (even if not generating plain text);
216    zero means we don't process @ifplaintext (even if we are);
217    -1 means we don't know yet.  (--ifplaintext) */
218 DECLARE (int, process_plaintext, -1);
219
220 /* Nonzero means that we process @tex and @iftex.  (--iftex) */
221 DECLARE (int, process_tex, 0);
222
223 /* Nonzero means that we process @xml and @ifxml.  (--ifxml) */
224 DECLARE (int, process_xml, 0);
225
226 /* Default is to check node references.  (--no-validate) */
227 DECLARE (int, validating, 1);
228
229 /* Nonzero means print information about what is going on.  (--verbose) */
230 DECLARE (int, verbose_mode, 0);
231
232 /* Nonzero means prefix each @chapter, ... with a number like
233    1, 1.1, etc.  (--number-sections) */
234 DECLARE (int, number_sections, 1);
235
236 /* Nonzero means split size.  When zero, DEFAULT_SPLIT_SIZE is used. */
237 DECLARE (int, split_size, 0);
238
239 /* Nonzero means expand node names and references while validating.
240    This will avoid errors when the Texinfo document uses features
241    like @@ and @value inconsistently in node names, but will slow
242    the program by about 80%.  You HAVE been warned.  */
243 DECLARE (int, expensive_validation, 0);
244 \f
245 /* C's standard macros don't check to make sure that the characters being
246    changed are within range.  So I have to check explicitly. */
247
248 #define coerce_to_upper(c) ((islower(c) ? toupper(c) : (c)))
249 #define coerce_to_lower(c) ((isupper(c) ? tolower(c) : (c)))
250
251 #define whitespace(c)       ((c) == '\t' || (c) == ' ')
252 #define sentence_ender(c)   ((c) == '.'  || (c) == '?' || (c) == '!')
253 #define cr_or_whitespace(c) (whitespace(c) || (c) == '\r' || (c) == '\n')
254
255 #ifndef isletter
256 #define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
257 #endif
258
259 #ifndef isupper
260 #define isupper(c) ((c) >= 'A' && (c) <= 'Z')
261 #endif
262
263 #ifndef isdigit
264 #define isdigit(c)  ((c) >= '0' && (c) <= '9')
265 #endif
266
267 #ifndef digit_value
268 #define digit_value(c) ((c) - '0')
269 #endif
270
271 /* These characters are not really HTML-safe (with strict XHTML),
272    and also there are possible collisions.  That's the whole reason we
273    designed a new conversion scheme in the first place.  But we
274    nevertheless need to generate the old names.  See
275    `add_escaped_anchor_name' in html.c.  */
276 #define OLD_HTML_SAFE "$-_.+!*'()"
277 #define OLD_URL_SAFE_CHAR(ch) (strchr (OLD_HTML_SAFE, ch))
278
279 /* For the current/stable scheme.  */
280 #define URL_SAFE_CHAR(ch) (((unsigned char)ch)<128 && isalnum (ch))
281
282 #define COMMAND_PREFIX '@'
283
284 /* A byte value to represent a non-breaking space until flush_output (). */
285 #define NON_BREAKING_SPACE 036
286
287 #define END_VERBATIM "end verbatim"
288
289 /* Stuff for splitting large files.  The numbers for Emacs
290    texinfo-format-buffer are much smaller, but memory capacities have
291    increased so much, 50k info files seem a bit tiny these days.  */
292 #define DEFAULT_SPLIT_SIZE 300000
293 DECLARE (int, splitting, 1);    /* Defaults to true for now. */
294
295 #define skip_whitespace() \
296      while ((input_text_offset != input_text_length) && \
297              whitespace (curchar())) \
298        input_text_offset++
299
300 #define skip_whitespace_and_newlines() \
301   do { \
302    while (input_text_offset != input_text_length \
303           && cr_or_whitespace (curchar ())) \
304       { \
305          if (curchar () == '\n') \
306            line_number++; \
307          input_text_offset++; \
308       } \
309    } while (0)
310
311 /* Return nonzero if STRING is the text at input_text + input_text_offset,
312    else zero. */
313 #define looking_at(string) \
314   (strncmp (input_text + input_text_offset, string, strlen (string)) == 0)
315
316 /* Any list with a member named `next'.  */
317 typedef struct generic_list {
318   struct generic_list *next;
319 } GENERIC_LIST;
320
321 /* Use `gdt' instead of `_' to translate strings that end up in the
322    output document.  */
323 extern char *getdocumenttext (const char *msgid);
324 #define gdt(s) getdocumenttext(s)
325
326 /* Reverse the order of a list.  */
327 extern GENERIC_LIST * reverse_list (GENERIC_LIST *list);
328
329 /* Possibly return Local Variables trailer for Info output.  */
330 extern char *info_trailer (void),
331   *expansion (char *str, int implicit_code),
332   *text_expansion (char *str),
333   *maybe_escaped_expansion (char *str, int implicit_code, int do_escape_html),
334   *full_expansion (char *str, int implicit_code);
335
336 extern void free_and_clear (char **pointer),
337   add_word (char *string),
338   add_char (int character),
339   add_meta_char (int character),
340   close_single_paragraph (void),
341   insert_string (const char *),
342   insert (int character),
343   get_rest_of_line (int expand, char **string),
344   add_html_block_elt (char *string),
345   get_until_in_braces (char *match, char **string),
346   get_until_in_line (int expand, char *match, char **string),
347   canon_white (char *string),
348   discard_until (char *string),
349   indent (int amount),
350   kill_self_indent (int count),
351   backup_input_pointer (void),
352   inhibit_output_flushing (void),
353   uninhibit_output_flushing (void),
354   flush_output (void),
355   start_paragraph (void),
356   close_paragraph (void),
357   close_insertion_paragraph (void),
358   init_paragraph (void),
359   ignore_blank_line (void),
360   reader_loop (void),
361   discard_braces (void),
362   replace_with_expansion (int from, int *to),
363   fix_whitespace (char *string),
364   output_head (void),
365   add_html_elt (char *string);
366
367 extern int get_until (char *match, char **string),
368   set_paragraph_indent (char *string),
369   self_delimiting (int character),
370   search_forward (const char *string, int from),
371   search_forward_until_pos (char *string, int from, int end_pos),
372   next_nonwhitespace_character (void),
373   current_output_column (void),
374   fs_error (char *filename);
375
376 #if defined (VA_FPRINTF) && __STDC__
377 /* Unfortunately we must use prototypes if we are to use <stdarg.h>.  */
378 extern void add_word_args (const char *, ...),
379   add_html_block_elt_args (const char *, ...),
380   execute_string (char *, ...),
381   warning (const char *format, ...),
382   error (const char *format, ...),
383   line_error (const char *format, ...),
384   file_line_error (char *infile, int lno, const char *format, ...);
385 #else
386 extern void add_word_args (),
387   add_html_block_elt_args (),
388   execute_string (),
389   warning (),
390   error (),
391   line_error (),
392   file_line_error ();
393 #endif /* no prototypes */
394
395 #endif /* not MAKEINFO_H */