makeinfo.h 13 KB

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