Home | History | Annotate | Line # | Download | only in makeinfo
      1 /*	$NetBSD: makeinfo.h,v 1.2 2016/01/14 00:34:53 christos Exp $	*/
      2 
      3 /* makeinfo.h -- declarations for Makeinfo.
      4    Id: makeinfo.h,v 1.17 2004/11/30 02:03:23 karl Exp
      5 
      6    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free
      7    Software Foundation, Inc.
      8 
      9    This program is free software; you can redistribute it and/or modify
     10    it under the terms of the GNU General Public License as published by
     11    the Free Software Foundation; either version 2, or (at your option)
     12    any later version.
     13 
     14    This program is distributed in the hope that it will be useful,
     15    but WITHOUT ANY WARRANTY; without even the implied warranty of
     16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17    GNU General Public License for more details.
     18 
     19    You should have received a copy of the GNU General Public License
     20    along with this program; if not, write to the Free Software
     21    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
     22 
     23    Written by Brian Fox (bfox (at) ai.mit.edu). */
     24 
     25 #ifndef MAKEINFO_H
     26 #define MAKEINFO_H
     27 
     28 #ifdef COMPILING_MAKEINFO
     29 #  define DECLARE(type,var,init) type var = init
     30 #else
     31 #  define DECLARE(type,var,init) extern type var
     32 #endif
     33 
     34 /* Hardcoded per GNU standards, not dependent on argv[0].  */
     35 DECLARE (char *, progname, "makeinfo");
     36 
     37 /* Nonzero means a string is in execution, as opposed to a file. */
     39 DECLARE (int, executing_string, 0);
     40 
     41 /* Nonzero means to inhibit writing macro expansions to the output
     42    stream, because it has already been written. */
     43 DECLARE (int, me_inhibit_expansion, 0);
     44 
     45 /* Current output stream. */
     47 DECLARE (FILE *, output_stream, NULL);
     48 
     49 DECLARE (char *, pretty_output_filename, NULL);
     50 
     51 /* Current output file name.  */
     52 DECLARE (char *, current_output_filename, NULL);
     53 
     54 /* Output paragraph buffer. */
     55 DECLARE (unsigned char *, output_paragraph, NULL);
     56 
     57 /* Offset into OUTPUT_PARAGRAPH. */
     58 DECLARE (int, output_paragraph_offset, 0);
     59 
     60 /* The output paragraph "cursor" horizontal position. */
     61 DECLARE (int, output_column, 0);
     62 
     63 /* Position in the output file. */
     64 DECLARE (int, output_position, 0);
     65 
     66 /* Number of lines in the output.  */
     67 DECLARE (int, output_line_number, 1);
     68 DECLARE (int, node_line_number, 0);
     69 
     70 /* The offset into OUTPUT_PARAGRAPH where we have a meta character
     71    produced by a markup such as @code or @dfn.  */
     72 DECLARE (int, meta_char_pos, -1);
     73 
     74 /* Nonzero means output_paragraph contains text. */
     75 DECLARE (int, paragraph_is_open, 0);
     76 
     77 /* Nonzero means that `start_paragraph' MUST be called before we pay
     78    any attention to `close_paragraph' calls. */
     79 DECLARE (int, must_start_paragraph, 0);
     80 
     81 /* Nonzero means that we have seen "@top" once already. */
     82 DECLARE (int, top_node_seen, 0);
     83 
     84 /* Nonzero means that we have seen a non-"@top" node already. */
     85 DECLARE (int, non_top_node_seen, 0);
     86 
     87 /* Nonzero indicates that indentation is temporarily turned off. */
     88 DECLARE (int, no_indent, 1);
     89 
     90 /* The amount of indentation to apply at the start of each line. */
     91 DECLARE (int, current_indent, 0);
     92 
     93 /* Nonzero means that we suppress the indentation of the first paragraph
     94    following any section heading.  */
     95 DECLARE (int, do_first_par_indent, 0);
     96 
     97 /* Amount by which @example indentation increases/decreases. */
     98 DECLARE (int, example_indentation_increment, 5);
     99 
    100 /* Amount by which @table, @defun, etc. indentation increases/decreases.  */
    101 DECLARE (int, default_indentation_increment, 5);
    102 
    103 /* Amount by which xml indentation increases/decreases.
    104    Zero means unnecessary whitespace is compressed.  */
    105 DECLARE (int, xml_indentation_increment, 2);
    106 
    107 /* Nonzero indicates that filling a line also indents the new line. */
    108 DECLARE (int, indented_fill, 0);
    109 
    110 /* Nonzero means forcing output text to be flushright. */
    111 DECLARE (int, force_flush_right, 0);
    112 
    113 /* The column at which long lines are broken. */
    114 DECLARE (int, fill_column, 72);
    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 true 8-bit output for Info and plain text.
    137    (--enable-encoding) */
    138 DECLARE (int, enable_encoding, 0);
    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 
    183 /* A colon separated list of directories to search for files included
    185    with @include.  This can be controlled with the `-I' option to makeinfo. */
    186 DECLARE (char *, include_files_path, NULL);
    187 
    188 /* The filename of the current input file.  This is never freed. */
    189 DECLARE (char *, node_filename, NULL);
    190 
    191 /* Name of CSS file to include, if any.  (--css-include).  */
    193 DECLARE (char *, css_include, NULL);
    194 
    195 /* Nonzero means do not output "Node: Foo" for node separations, that
    196    is, generate plain text.  (--no-headers) */
    197 DECLARE (int, no_headers, 0);
    198 
    199 /* Nonzero means do not output makeinfo version and source file.
    200    (--no-version-header) */
    201 DECLARE (int, no_version_header, 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 /* Maximum number of references to a single node before complaining.
    227    (--reference-limit) */
    228 DECLARE (int, reference_warning_limit, 1000);
    229 
    230 /* Default is to check node references.  (--no-validate) */
    231 DECLARE (int, validating, 1);
    232 
    233 /* Nonzero means print information about what is going on.  (--verbose) */
    234 DECLARE (int, verbose_mode, 0);
    235 
    236 /* Nonzero means prefix each @chapter, ... with a number like
    237    1, 1.1, etc.  (--number-sections) */
    238 DECLARE (int, number_sections, 1);
    239 
    240 /* Nonzero means split size.  When zero, DEFAULT_SPLIT_SIZE is used. */
    241 DECLARE (int, split_size, 0);
    242 
    243 /* Nonzero means expand node names and references while validating.
    244    This will avoid errors when the Texinfo document uses features
    245    like @@ and @value inconsistently in node names, but will slow
    246    the program by about 80%.  You HAVE been warned.  */
    247 DECLARE (int, expensive_validation, 0);
    248 
    249 /* C's standard macros don't check to make sure that the characters being
    251    changed are within range.  So I have to check explicitly. */
    252 
    253 #define coerce_to_upper(c) ((islower(c) ? toupper(c) : (c)))
    254 #define coerce_to_lower(c) ((isupper(c) ? tolower(c) : (c)))
    255 
    256 #define control_character_bit 0x40 /* %01000000, must be off. */
    257 #define meta_character_bit 0x080/* %10000000, must be on.  */
    258 #define CTL(c) ((c) & (~control_character_bit))
    259 #define UNCTL(c) coerce_to_upper(((c)|control_character_bit))
    260 #define META(c) ((c) | (meta_character_bit))
    261 #define UNMETA(c) ((c) & (~meta_character_bit))
    262 
    263 #define whitespace(c)       ((c) == '\t' || (c) == ' ')
    264 #define sentence_ender(c)   ((c) == '.'  || (c) == '?' || (c) == '!')
    265 #define cr_or_whitespace(c) (whitespace(c) || (c) == '\r' || (c) == '\n')
    266 
    267 #ifndef isletter
    268 #define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
    269 #endif
    270 
    271 #ifndef isupper
    272 #define isupper(c) ((c) >= 'A' && (c) <= 'Z')
    273 #endif
    274 
    275 #ifndef isdigit
    276 #define isdigit(c)  ((c) >= '0' && (c) <= '9')
    277 #endif
    278 
    279 #ifndef digit_value
    280 #define digit_value(c) ((c) - '0')
    281 #endif
    282 
    283 /* These characters are not really HTML-safe (with strict XHTML),
    284    and also there are possible collisions.  That's the whole reason we
    285    designed a new conversion scheme in the first place.  But we
    286    nevertheless need to generate the old names.  See
    287    `add_escaped_anchor_name' in html.c.  */
    288 #define OLD_HTML_SAFE "$-_.+!*'()"
    289 #define OLD_URL_SAFE_CHAR(ch) (strchr (OLD_HTML_SAFE, ch))
    290 
    291 /* For the current/stable scheme.  */
    292 #define URL_SAFE_CHAR(ch) (isalnum (ch))
    293 
    294 #define COMMAND_PREFIX '@'
    295 
    296 #define END_VERBATIM "end verbatim"
    297 
    298 /* Stuff for splitting large files.  The numbers for Emacs
    299    texinfo-format-buffer are much smaller, but memory capacities have
    300    increased so much, 50k info files seem a bit tiny these days.  */
    301 #define DEFAULT_SPLIT_SIZE 300000
    302 DECLARE (int, splitting, 1);    /* Defaults to true for now. */
    303 
    304 #define skip_whitespace() \
    305      while ((input_text_offset != input_text_length) && \
    306              whitespace (curchar())) \
    307        input_text_offset++
    308 
    309 #define skip_whitespace_and_newlines() \
    310   do { \
    311    while (input_text_offset != input_text_length \
    312           && cr_or_whitespace (curchar ())) \
    313       { \
    314          if (curchar () == '\n') \
    315            line_number++; \
    316          input_text_offset++; \
    317       } \
    318    } while (0)
    319 
    320 /* Return nonzero if STRING is the text at input_text + input_text_offset,
    321    else zero. */
    322 #define looking_at(string) \
    323   (strncmp (input_text + input_text_offset, string, strlen (string)) == 0)
    324 
    325 /* Any list with a member named `next'.  */
    326 typedef struct generic_list {
    327   struct generic_list *next;
    328 } GENERIC_LIST;
    329 
    330 /* Reverse the order of a list.  */
    331 extern GENERIC_LIST * reverse_list (GENERIC_LIST *list);
    332 
    333 /* Possibly return Local Variables trailer for Info output.  */
    334 extern char *info_trailer (void),
    335   *expansion (char *str, int implicit_code),
    336   *text_expansion (char *str),
    337   *maybe_escaped_expansion (char *str, int implicit_code, int do_escape_html),
    338   *full_expansion (char *str, int implicit_code);
    339 
    340 extern void free_and_clear (char **pointer),
    341   add_word (char *string),
    342   add_char (int character),
    343   add_meta_char (int character),
    344   close_single_paragraph (void),
    345   insert_string (const char *),
    346   insert (int character),
    347   get_rest_of_line (int expand, char **string),
    348   add_html_block_elt (char *string),
    349   get_until_in_braces (char *match, char **string),
    350   get_until_in_line (int expand, char *match, char **string),
    351   canon_white (char *string),
    352   discard_until (char *string),
    353   indent (int amount),
    354   kill_self_indent (int count),
    355   backup_input_pointer (void),
    356   inhibit_output_flushing (void),
    357   uninhibit_output_flushing (void),
    358   flush_output (void),
    359   start_paragraph (void),
    360   close_paragraph (void),
    361   close_insertion_paragraph (void),
    362   init_paragraph (void),
    363   ignore_blank_line (void),
    364   reader_loop (void),
    365   discard_braces (void),
    366   replace_with_expansion (int from, int *to),
    367   fix_whitespace (char *string),
    368   add_html_elt (char *string);
    369 
    370 extern int get_until (char *match, char **string),
    371   set_paragraph_indent (char *string),
    372   self_delimiting (int character),
    373   search_forward (char *string, int from),
    374   search_forward_until_pos (char *string, int from, int end_pos),
    375   next_nonwhitespace_character (void),
    376   fs_error (char *filename);
    377 
    378 #if defined (VA_FPRINTF) && __STDC__
    379 /* Unfortunately we must use prototypes if we are to use <stdarg.h>.  */
    380 extern void add_word_args (const char *, ...),
    381   add_html_block_elt_args (const char *, ...),
    382   execute_string (char *, ...),
    383   warning (const char *format, ...),
    384   error (const char *format, ...),
    385   line_error (const char *format, ...),
    386   file_line_error (char *infile, int lno, const char *format, ...);
    387 #else
    388 extern void add_word_args (),
    389   add_html_block_elt_args (),
    390   execute_string (),
    391   warning (),
    392   error (),
    393   line_error (),
    394   file_line_error ();
    395 #endif /* no prototypes */
    396 
    397 #endif /* not MAKEINFO_H */
    398