156160Sru/* makeinfo.h -- declarations for Makeinfo. 2146515Sru $Id: makeinfo.h,v 1.17 2004/11/30 02:03:23 karl Exp $ 321495Sjmacd 4146515Sru Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free 5116525Sru Software Foundation, Inc. 621495Sjmacd 721495Sjmacd This program is free software; you can redistribute it and/or modify 821495Sjmacd it under the terms of the GNU General Public License as published by 921495Sjmacd the Free Software Foundation; either version 2, or (at your option) 1021495Sjmacd any later version. 1121495Sjmacd 1221495Sjmacd This program is distributed in the hope that it will be useful, 1321495Sjmacd but WITHOUT ANY WARRANTY; without even the implied warranty of 1421495Sjmacd MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1521495Sjmacd GNU General Public License for more details. 1621495Sjmacd 1721495Sjmacd You should have received a copy of the GNU General Public License 1821495Sjmacd along with this program; if not, write to the Free Software 1921495Sjmacd Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 2021495Sjmacd 2121495Sjmacd Written by Brian Fox (bfox@ai.mit.edu). */ 2221495Sjmacd 2356160Sru#ifndef MAKEINFO_H 2421495Sjmacd#define MAKEINFO_H 2521495Sjmacd 2656160Sru#ifdef COMPILING_MAKEINFO 2756160Sru# define DECLARE(type,var,init) type var = init 2821495Sjmacd#else 2956160Sru# define DECLARE(type,var,init) extern type var 3021495Sjmacd#endif 3121495Sjmacd 3256160Sru/* Hardcoded per GNU standards, not dependent on argv[0]. */ 3356160SruDECLARE (char *, progname, "makeinfo"); 3456160Sru 3556160Sru/* Nonzero means a string is in execution, as opposed to a file. */ 3656160SruDECLARE (int, executing_string, 0); 3721495Sjmacd 3856160Sru/* Nonzero means to inhibit writing macro expansions to the output 3956160Sru stream, because it has already been written. */ 4056160SruDECLARE (int, me_inhibit_expansion, 0); 4156160Sru 4221495Sjmacd/* Current output stream. */ 4356160SruDECLARE (FILE *, output_stream, NULL); 4421495Sjmacd 4556160SruDECLARE (char *, pretty_output_filename, NULL); 4656160Sru 4756160Sru/* Current output file name. */ 4856160SruDECLARE (char *, current_output_filename, NULL); 4956160Sru 5021495Sjmacd/* Output paragraph buffer. */ 5156160SruDECLARE (unsigned char *, output_paragraph, NULL); 5221495Sjmacd 5321495Sjmacd/* Offset into OUTPUT_PARAGRAPH. */ 5421495SjmacdDECLARE (int, output_paragraph_offset, 0); 5521495Sjmacd 5621495Sjmacd/* The output paragraph "cursor" horizontal position. */ 5721495SjmacdDECLARE (int, output_column, 0); 5821495Sjmacd 5956160Sru/* Position in the output file. */ 6056160SruDECLARE (int, output_position, 0); 6156160Sru 62146515Sru/* Number of lines in the output. */ 63146515SruDECLARE (int, output_line_number, 1); 64146515SruDECLARE (int, node_line_number, 0); 65146515Sru 6656160Sru/* The offset into OUTPUT_PARAGRAPH where we have a meta character 6756160Sru produced by a markup such as @code or @dfn. */ 6856160SruDECLARE (int, meta_char_pos, -1); 6956160Sru 7056160Sru/* Nonzero means output_paragraph contains text. */ 7121495SjmacdDECLARE (int, paragraph_is_open, 0); 7221495Sjmacd 7356160Sru/* Nonzero means that `start_paragraph' MUST be called before we pay 7456160Sru any attention to `close_paragraph' calls. */ 7556160SruDECLARE (int, must_start_paragraph, 0); 7656160Sru 7756160Sru/* Nonzero means that we have seen "@top" once already. */ 7856160SruDECLARE (int, top_node_seen, 0); 7956160Sru 8056160Sru/* Nonzero means that we have seen a non-"@top" node already. */ 8156160SruDECLARE (int, non_top_node_seen, 0); 8256160Sru 8356160Sru/* Nonzero indicates that indentation is temporarily turned off. */ 8456160SruDECLARE (int, no_indent, 1); 8556160Sru 86116525Sru/* The amount of indentation to apply at the start of each line. */ 87116525SruDECLARE (int, current_indent, 0); 88116525Sru 89116525Sru/* Nonzero means that we suppress the indentation of the first paragraph 90116525Sru following any section heading. */ 91116525SruDECLARE (int, do_first_par_indent, 0); 92116525Sru 93116525Sru/* Amount by which @example indentation increases/decreases. */ 94146515SruDECLARE (int, example_indentation_increment, 5); 95146515Sru 96146515Sru/* Amount by which @table, @defun, etc. indentation increases/decreases. */ 97116525SruDECLARE (int, default_indentation_increment, 5); 98116525Sru 99146515Sru/* Amount by which xml indentation increases/decreases. 100146515Sru Zero means unnecessary whitespace is compressed. */ 101146515SruDECLARE (int, xml_indentation_increment, 2); 102146515Sru 10356160Sru/* Nonzero indicates that filling a line also indents the new line. */ 10456160SruDECLARE (int, indented_fill, 0); 10556160Sru 10656160Sru/* Nonzero means forcing output text to be flushright. */ 10756160SruDECLARE (int, force_flush_right, 0); 10856160Sru 10921495Sjmacd/* The column at which long lines are broken. */ 11021495SjmacdDECLARE (int, fill_column, 72); 11121495Sjmacd 11256160Sru/* Nonzero means that words are not to be split, even in long lines. This 11356160Sru gets changed for cm_w (). */ 11456160SruDECLARE (int, non_splitting_words, 0); 11556160Sru 11656160Sru/* Nonzero means that we are currently hacking the insides of an 11756160Sru insertion which would use a fixed width font. */ 11856160SruDECLARE (int, in_fixed_width_font, 0); 11956160Sru 12056160Sru/* Nonzero if we are currently processing a multitable command */ 12156160SruDECLARE (int, multitable_active, 0); 12256160Sru 123116525Sru/* Nonzero means that we're generating HTML. (--html) */ 12456160SruDECLARE (int, html, 0); 12556160Sru 126116525Sru/* Nonzero means that we're generating XML. (--xml) */ 12793139SruDECLARE (int, xml, 0); 12893139Sru 129116525Sru/* Nonzero means that we're generating DocBook. (--docbook) */ 13093139SruDECLARE (int, docbook, 0); 13193139Sru 132116525Sru/* Nonzero means true 8-bit output for Info and plain text. 133116525Sru (--enable-encoding) */ 13493139SruDECLARE (int, enable_encoding, 0); 13593139Sru 13656160Sru/* Nonzero means escape characters in HTML output. */ 13756160SruDECLARE (int, escape_html, 1); 13856160Sru 139100513Sru/* Access key number for next menu entry to be generated (1 to 9, or 10 to 140100513Sru mean no access key) */ 141100513SruDECLARE (int, next_menu_item_number, 1); 142100513Sru 14356160Sru/* Nonzero means that the use of paragraph_start_indent is inhibited. 14456160Sru @example uses this to line up the left columns of the example text. 14556160Sru A negative value for this variable is incremented each time it is used. 14656160Sru @noindent uses this to inhibit indentation for a single paragraph. */ 14756160SruDECLARE (int, inhibit_paragraph_indentation, 0); 14856160Sru 14956160Sru/* Nonzero indicates that filling will take place on long lines. */ 15056160SruDECLARE (int, filling_enabled, 1); 15156160Sru 15256160Sru/* The current node's node name. */ 15356160SruDECLARE (char *, current_node, NULL); 15456160Sru 15556160Sru/* Command name in the process of being hacked. */ 15656160SruDECLARE (char *, command, NULL); 15756160Sru 158146515Sru/* Nonzero if we have seen an @titlepage command. */ 159146515SruDECLARE (int, titlepage_cmd_present, 0); 160146515Sru 161100513Sru/* @copying ... @end copying. */ 162100513SruDECLARE (char *, copying_text, NULL); 163100513Sru 16493139Sru/* @documentdescription ... @end documentdescription. */ 165116525SruDECLARE (const char *, document_description, NULL); 16693139Sru 16756160Sru/* Nonzero if the last character inserted has the syntax class of NEWLINE. */ 16856160SruDECLARE (int, last_char_was_newline, 1); 16956160Sru 17021495Sjmacd/* The current input file state. */ 17121495SjmacdDECLARE (char *, input_filename, (char *)NULL); 17221495SjmacdDECLARE (char *, input_text, (char *)NULL); 17356160SruDECLARE (int, input_text_length, 0); 17421495SjmacdDECLARE (int, input_text_offset, 0); 17521495SjmacdDECLARE (int, line_number, 0); 17693139SruDECLARE (char *, toplevel_output_filename, NULL); 17721495Sjmacd#define curchar() input_text[input_text_offset] 17856160Sru 17956160Sru/* A colon separated list of directories to search for files included 18056160Sru with @include. This can be controlled with the `-I' option to makeinfo. */ 18156160SruDECLARE (char *, include_files_path, NULL); 18221495Sjmacd 18356160Sru/* The filename of the current input file. This is never freed. */ 18456160SruDECLARE (char *, node_filename, NULL); 18556160Sru 186116525Sru/* Name of CSS file to include, if any. (--css-include). */ 187116525SruDECLARE (char *, css_include, NULL); 188116525Sru 18956160Sru/* Nonzero means do not output "Node: Foo" for node separations, that 19056160Sru is, generate plain text. (--no-headers) */ 19156160SruDECLARE (int, no_headers, 0); 19221495Sjmacd 193146515Sru/* Nonzero means that we process @docbook and @ifdocbook. (--ifdocbook) */ 194146515SruDECLARE (int, process_docbook, 0); 195146515Sru 19656160Sru/* Nonzero means that we process @html and @rawhtml even when not 19756160Sru generating HTML. (--ifhtml) */ 19856160SruDECLARE (int, process_html, 0); 19956160Sru 200100513Sru/* Positive means process @ifinfo (even if not generating Info); 201100513Sru zero means don't process @ifinfo (even if we are); 202100513Sru -1 means we don't know yet. (--ifinfo) */ 203100513SruDECLARE (int, process_info, -1); 20456160Sru 205100513Sru/* Positive means process @ifplaintext (even if not generating plain text); 206100513Sru zero means we don't process @ifplaintext (even if we are); 207100513Sru -1 means we don't know yet. (--ifplaintext) */ 208100513SruDECLARE (int, process_plaintext, -1); 209100513Sru 21056160Sru/* Nonzero means that we process @tex and @iftex. (--iftex) */ 21156160SruDECLARE (int, process_tex, 0); 21256160Sru 213114472Sru/* Nonzero means that we process @xml and @ifxml. (--ifxml) */ 214114472SruDECLARE (int, process_xml, 0); 215114472Sru 21656160Sru/* Maximum number of references to a single node before complaining. 21756160Sru (--reference-limit) */ 21856160SruDECLARE (int, reference_warning_limit, 1000); 21956160Sru 22056160Sru/* Default is to check node references. (--no-validate) */ 22156160SruDECLARE (int, validating, 1); 22256160Sru 22356160Sru/* Nonzero means print information about what is going on. (--verbose) */ 22456160SruDECLARE (int, verbose_mode, 0); 22556160Sru 226116525Sru/* Nonzero means prefix each @chapter, ... with a number like 227116525Sru 1, 1.1, etc. (--number-sections) */ 228146515SruDECLARE (int, number_sections, 1); 22956160Sru 23093139Sru/* Nonzero means split size. When zero, DEFAULT_SPLIT_SIZE is used. */ 23193139SruDECLARE (int, split_size, 0); 23293139Sru 23356160Sru/* Nonzero means expand node names and references while validating. 23456160Sru This will avoid errors when the Texinfo document uses features 23556160Sru like @@ and @value inconsistently in node names, but will slow 23656160Sru the program by about 80%. You HAVE been warned. */ 23756160SruDECLARE (int, expensive_validation, 0); 23856160Sru 23921495Sjmacd/* C's standard macros don't check to make sure that the characters being 24021495Sjmacd changed are within range. So I have to check explicitly. */ 24121495Sjmacd 24221495Sjmacd#define coerce_to_upper(c) ((islower(c) ? toupper(c) : (c))) 24321495Sjmacd#define coerce_to_lower(c) ((isupper(c) ? tolower(c) : (c))) 24421495Sjmacd 24521495Sjmacd#define control_character_bit 0x40 /* %01000000, must be off. */ 24621495Sjmacd#define meta_character_bit 0x080/* %10000000, must be on. */ 24721495Sjmacd#define CTL(c) ((c) & (~control_character_bit)) 24821495Sjmacd#define UNCTL(c) coerce_to_upper(((c)|control_character_bit)) 24921495Sjmacd#define META(c) ((c) | (meta_character_bit)) 25021495Sjmacd#define UNMETA(c) ((c) & (~meta_character_bit)) 25121495Sjmacd 25256160Sru#define whitespace(c) ((c) == '\t' || (c) == ' ') 25356160Sru#define sentence_ender(c) ((c) == '.' || (c) == '?' || (c) == '!') 25456160Sru#define cr_or_whitespace(c) (whitespace(c) || (c) == '\r' || (c) == '\n') 25521495Sjmacd 25621495Sjmacd#ifndef isletter 25721495Sjmacd#define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z')) 25821495Sjmacd#endif 25921495Sjmacd 26021495Sjmacd#ifndef isupper 26121495Sjmacd#define isupper(c) ((c) >= 'A' && (c) <= 'Z') 26221495Sjmacd#endif 26321495Sjmacd 26421495Sjmacd#ifndef isdigit 26521495Sjmacd#define isdigit(c) ((c) >= '0' && (c) <= '9') 26621495Sjmacd#endif 26721495Sjmacd 26821495Sjmacd#ifndef digit_value 26921495Sjmacd#define digit_value(c) ((c) - '0') 27021495Sjmacd#endif 27121495Sjmacd 272146515Sru/* These characters are not really HTML-safe (with strict XHTML), 273146515Sru and also there are possible collisions. That's the whole reason we 274146515Sru designed a new conversion scheme in the first place. But we 275146515Sru nevertheless need to generate the old names. See 276146515Sru `add_escaped_anchor_name' in html.c. */ 277146515Sru#define OLD_HTML_SAFE "$-_.+!*'()" 278146515Sru#define OLD_URL_SAFE_CHAR(ch) (strchr (OLD_HTML_SAFE, ch)) 27921495Sjmacd 280146515Sru/* For the current/stable scheme. */ 281146515Sru#define URL_SAFE_CHAR(ch) (isalnum (ch)) 282146515Sru 28321495Sjmacd#define COMMAND_PREFIX '@' 28421495Sjmacd 28593139Sru#define END_VERBATIM "end verbatim" 28693139Sru 287116525Sru/* Stuff for splitting large files. The numbers for Emacs 288116525Sru texinfo-format-buffer are much smaller, but memory capacities have 289116525Sru increased so much, 50k info files seem a bit tiny these days. */ 290116525Sru#define DEFAULT_SPLIT_SIZE 300000 29142660SmarkmDECLARE (int, splitting, 1); /* Defaults to true for now. */ 29221495Sjmacd 29321495Sjmacd#define skip_whitespace() \ 29456160Sru while ((input_text_offset != input_text_length) && \ 29542660Smarkm whitespace (curchar())) \ 29621495Sjmacd input_text_offset++ 29721495Sjmacd 29821495Sjmacd#define skip_whitespace_and_newlines() \ 29921495Sjmacd do { \ 30056160Sru while (input_text_offset != input_text_length \ 30156160Sru && cr_or_whitespace (curchar ())) \ 30221495Sjmacd { \ 30342660Smarkm if (curchar () == '\n') \ 30442660Smarkm line_number++; \ 30542660Smarkm input_text_offset++; \ 30621495Sjmacd } \ 30721495Sjmacd } while (0) 30821495Sjmacd 30956160Sru/* Return nonzero if STRING is the text at input_text + input_text_offset, 31056160Sru else zero. */ 31156160Sru#define looking_at(string) \ 31256160Sru (strncmp (input_text + input_text_offset, string, strlen (string)) == 0) 31356160Sru 314146515Sru/* Any list with a member named `next'. */ 315146515Srutypedef struct generic_list { 316146515Sru struct generic_list *next; 317146515Sru} GENERIC_LIST; 318146515Sru 319146515Sru/* Reverse the order of a list. */ 320146515Sruextern GENERIC_LIST * reverse_list (GENERIC_LIST *list); 321146515Sru 322116525Sru/* Possibly return Local Variables trailer for Info output. */ 323146515Sruextern char *info_trailer (void), 324146515Sru *expansion (char *str, int implicit_code), 325146515Sru *text_expansion (char *str), 326146515Sru *maybe_escaped_expansion (char *str, int implicit_code, int do_escape_html), 327146515Sru *full_expansion (char *str, int implicit_code); 328116525Sru 329146515Sruextern void free_and_clear (char **pointer), 330146515Sru add_word (char *string), 331146515Sru add_char (int character), 332146515Sru add_meta_char (int character), 333146515Sru close_single_paragraph (void), 334146515Sru insert_string (const char *), 335146515Sru insert (int character), 336146515Sru get_rest_of_line (int expand, char **string), 337146515Sru add_html_block_elt (char *string), 338146515Sru get_until_in_braces (char *match, char **string), 339146515Sru get_until_in_line (int expand, char *match, char **string), 340146515Sru canon_white (char *string), 341146515Sru discard_until (char *string), 342146515Sru indent (int amount), 343146515Sru kill_self_indent (int count), 344146515Sru backup_input_pointer (void), 345146515Sru inhibit_output_flushing (void), 346146515Sru uninhibit_output_flushing (void), 347146515Sru flush_output (void), 348146515Sru start_paragraph (void), 349146515Sru close_paragraph (void), 350146515Sru close_insertion_paragraph (void), 351146515Sru init_paragraph (void), 352146515Sru ignore_blank_line (void), 353146515Sru reader_loop (void), 354146515Sru discard_braces (void), 355146515Sru replace_with_expansion (int from, int *to), 356146515Sru fix_whitespace (char *string), 357146515Sru add_html_elt (char *string); 358146515Sru 359146515Sruextern int get_until (char *match, char **string), 360146515Sru set_paragraph_indent (char *string), 361146515Sru self_delimiting (int character), 362146515Sru search_forward (char *string, int from), 363146515Sru search_forward_until_pos (char *string, int from, int end_pos), 364146515Sru next_nonwhitespace_character (void), 365146515Sru fs_error (char *filename); 366146515Sru 367146515Sru#if defined (VA_FPRINTF) && __STDC__ 368146515Sru/* Unfortunately we must use prototypes if we are to use <stdarg.h>. */ 369146515Sruextern void add_word_args (const char *, ...), 370146515Sru add_html_block_elt_args (const char *, ...), 371146515Sru execute_string (char *, ...), 372146515Sru warning (const char *format, ...), 373146515Sru error (const char *format, ...), 374146515Sru line_error (const char *format, ...), 375146515Sru file_line_error (char *infile, int lno, const char *format, ...); 376146515Sru#else 377146515Sruextern void add_word_args (), 378146515Sru add_html_block_elt_args (), 379146515Sru execute_string (), 380146515Sru warning (), 381146515Sru error (), 382146515Sru line_error (), 383146515Sru file_line_error (); 384146515Sru#endif /* no prototypes */ 385146515Sru 38656160Sru#endif /* not MAKEINFO_H */ 387