Home | History | Annotate | Line # | Download | only in makeinfo
makeinfo.h revision 1.1
      1 /*	$NetBSD: makeinfo.h,v 1.1 2016/01/14 00:11:29 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 that we process @docbook and @ifdocbook.  (--ifdocbook) */
    200 DECLARE (int, process_docbook, 0);
    201 
    202 /* Nonzero means that we process @html and @rawhtml even when not
    203    generating HTML.  (--ifhtml) */
    204 DECLARE (int, process_html, 0);
    205 
    206 /* Positive means process @ifinfo (even if not generating Info);
    207    zero means don't process @ifinfo (even if we are);
    208    -1 means we don't know yet.  (--ifinfo) */
    209 DECLARE (int, process_info, -1);
    210 
    211 /* Positive means process @ifplaintext (even if not generating plain text);
    212    zero means we don't process @ifplaintext (even if we are);
    213    -1 means we don't know yet.  (--ifplaintext) */
    214 DECLARE (int, process_plaintext, -1);
    215 
    216 /* Nonzero means that we process @tex and @iftex.  (--iftex) */
    217 DECLARE (int, process_tex, 0);
    218 
    219 /* Nonzero means that we process @xml and @ifxml.  (--ifxml) */
    220 DECLARE (int, process_xml, 0);
    221 
    222 /* Maximum number of references to a single node before complaining.
    223    (--reference-limit) */
    224 DECLARE (int, reference_warning_limit, 1000);
    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 
    245 /* C's standard macros don't check to make sure that the characters being
    247    changed are within range.  So I have to check explicitly. */
    248 
    249 #define coerce_to_upper(c) ((islower(c) ? toupper(c) : (c)))
    250 #define coerce_to_lower(c) ((isupper(c) ? tolower(c) : (c)))
    251 
    252 #define control_character_bit 0x40 /* %01000000, must be off. */
    253 #define meta_character_bit 0x080/* %10000000, must be on.  */
    254 #define CTL(c) ((c) & (~control_character_bit))
    255 #define UNCTL(c) coerce_to_upper(((c)|control_character_bit))
    256 #define META(c) ((c) | (meta_character_bit))
    257 #define UNMETA(c) ((c) & (~meta_character_bit))
    258 
    259 #define whitespace(c)       ((c) == '\t' || (c) == ' ')
    260 #define sentence_ender(c)   ((c) == '.'  || (c) == '?' || (c) == '!')
    261 #define cr_or_whitespace(c) (whitespace(c) || (c) == '\r' || (c) == '\n')
    262 
    263 #ifndef isletter
    264 #define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
    265 #endif
    266 
    267 #ifndef isupper
    268 #define isupper(c) ((c) >= 'A' && (c) <= 'Z')
    269 #endif
    270 
    271 #ifndef isdigit
    272 #define isdigit(c)  ((c) >= '0' && (c) <= '9')
    273 #endif
    274 
    275 #ifndef digit_value
    276 #define digit_value(c) ((c) - '0')
    277 #endif
    278 
    279 /* These characters are not really HTML-safe (with strict XHTML),
    280    and also there are possible collisions.  That's the whole reason we
    281    designed a new conversion scheme in the first place.  But we
    282    nevertheless need to generate the old names.  See
    283    `add_escaped_anchor_name' in html.c.  */
    284 #define OLD_HTML_SAFE "$-_.+!*'()"
    285 #define OLD_URL_SAFE_CHAR(ch) (strchr (OLD_HTML_SAFE, ch))
    286 
    287 /* For the current/stable scheme.  */
    288 #define URL_SAFE_CHAR(ch) (isalnum (ch))
    289 
    290 #define COMMAND_PREFIX '@'
    291 
    292 #define END_VERBATIM "end verbatim"
    293 
    294 /* Stuff for splitting large files.  The numbers for Emacs
    295    texinfo-format-buffer are much smaller, but memory capacities have
    296    increased so much, 50k info files seem a bit tiny these days.  */
    297 #define DEFAULT_SPLIT_SIZE 300000
    298 DECLARE (int, splitting, 1);    /* Defaults to true for now. */
    299 
    300 #define skip_whitespace() \
    301      while ((input_text_offset != input_text_length) && \
    302              whitespace (curchar())) \
    303        input_text_offset++
    304 
    305 #define skip_whitespace_and_newlines() \
    306   do { \
    307    while (input_text_offset != input_text_length \
    308           && cr_or_whitespace (curchar ())) \
    309       { \
    310          if (curchar () == '\n') \
    311            line_number++; \
    312          input_text_offset++; \
    313       } \
    314    } while (0)
    315 
    316 /* Return nonzero if STRING is the text at input_text + input_text_offset,
    317    else zero. */
    318 #define looking_at(string) \
    319   (strncmp (input_text + input_text_offset, string, strlen (string)) == 0)
    320 
    321 /* Any list with a member named `next'.  */
    322 typedef struct generic_list {
    323   struct generic_list *next;
    324 } GENERIC_LIST;
    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   add_html_elt (char *string);
    365 
    366 extern int get_until (char *match, char **string),
    367   set_paragraph_indent (char *string),
    368   self_delimiting (int character),
    369   search_forward (char *string, int from),
    370   search_forward_until_pos (char *string, int from, int end_pos),
    371   next_nonwhitespace_character (void),
    372   fs_error (char *filename);
    373 
    374 #if defined (VA_FPRINTF) && __STDC__
    375 /* Unfortunately we must use prototypes if we are to use <stdarg.h>.  */
    376 extern void add_word_args (const char *, ...),
    377   add_html_block_elt_args (const char *, ...),
    378   execute_string (char *, ...),
    379   warning (const char *format, ...),
    380   error (const char *format, ...),
    381   line_error (const char *format, ...),
    382   file_line_error (char *infile, int lno, const char *format, ...);
    383 #else
    384 extern void add_word_args (),
    385   add_html_block_elt_args (),
    386   execute_string (),
    387   warning (),
    388   error (),
    389   line_error (),
    390   file_line_error ();
    391 #endif /* no prototypes */
    392 
    393 #endif /* not MAKEINFO_H */
    394