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