source: trunk/emx/src/emxdoc/emxdoc.h

Last change on this file was 18, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.6 KB
Line 
1/* emxdoc.h -- Global header file
2 Copyright (c) 1993-1999 Eberhard Mattes
3
4This file is part of emxdoc.
5
6emxdoc is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11emxdoc is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with emxdoc; see the file COPYING. If not, write to
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
20
21
22#if !defined (EXTERN)
23#define EXTERN extern
24#define INIT(X)
25#endif
26
27#define FALSE 0
28#define TRUE 1
29
30#define ENV_STACK_SIZE 8
31#define HL_STACK_SIZE 8
32#define STYLE_STACK_SIZE 8
33#define SECTION_LEVELS 3
34
35#define HL_BF 0x01
36#define HL_SL 0x02
37#define HL_TT 0x04
38#define HL_UL 0x08
39#define HL_EM 0x10
40
41#define HF_UNNUMBERED 0x01
42#define HF_HIDE 0x02
43
44/* Flag bits for the `flags' field of struct word. */
45
46#define WF_ABBREV 0x01
47
48#ifdef __GNUC__
49#define PRINTF(x,y) __attribute__ ((format (printf, x, y)))
50#define NORETURN2 __attribute__ ((noreturn))
51#else
52#define PRINTF(x,y)
53#define NORETURN2
54#endif
55
56typedef unsigned char uchar;
57
58enum tag
59{
60 TAG_HEADING,
61 TAG_TOC,
62 TAG_TITLE,
63 TAG_IPF,
64 TAG_ENDIPF,
65 TAG_ITEM,
66 TAG_SAMPLECODE,
67 TAG_ENDSAMPLECODE,
68 TAG_VERBATIM,
69 TAG_ENDVERBATIM,
70 TAG_EXAMPLE,
71 TAG_ENDEXAMPLE,
72 TAG_HEADERS,
73 TAG_ENDHEADERS,
74 TAG_PROTOTYPE,
75 TAG_ENDPROTOTYPE,
76 TAG_DESCRIPTION,
77 TAG_ENDDESCRIPTION,
78 TAG_ENUMERATE,
79 TAG_ENDENUMERATE,
80 TAG_ITEMIZE,
81 TAG_ENDITEMIZE,
82 TAG_LIST,
83 TAG_ENDLIST,
84 TAG_INDENT,
85 TAG_ENDINDENT,
86 TAG_TYPEWRITER,
87 TAG_ENDTYPEWRITER,
88 TAG_TABLE,
89 TAG_ENDTABLE,
90 TAG_LABEL,
91 TAG_TEXT,
92 TAG_ENDTEXT,
93 TAG_LATEX,
94 TAG_ENDLATEX,
95 TAG_HTML,
96 TAG_ENDHTML,
97 TAG_FORMAT,
98 TAG_STYLE,
99 TAG_REF,
100 TAG_HPT,
101 TAG_BREAK,
102 TAG_INDEX,
103 TAG_KEYWORD,
104 TAG_FUNCTION,
105 TAG_SEEALSO,
106 TAG_COMPAT,
107 TAG_SAMPLEFILE,
108 TAG_RESTRICTIONS,
109 TAG_IMPLEMENTATION,
110 TAG_BUGS,
111 TAG_RETURNVALUE,
112 TAG_PARAM,
113 TAG_LANGUAGE,
114 TAG_SYNTAX,
115 TAG_IPFMINITOC,
116 TAG_HTMLMINITOC,
117 TAG_MINITOC,
118 TAG_HTMLFRAGMENT,
119 TAG_SPECIAL,
120 TAG_FULLSTOP,
121 TAG_SET,
122 TAG_REPLACE,
123 TAG_ERRORS,
124 TAG_HINTS
125};
126
127enum style
128{
129 STYLE_NORMAL,
130 STYLE_BOLD,
131 STYLE_TTY,
132 STYLE_UNDERLINE,
133 STYLE_SLANTED,
134 STYLE_SYNTAX,
135 STYLE_PARAM,
136 STYLE_EMPHASIZE
137};
138
139enum el
140{
141 EL_END,
142 EL_WORD,
143 EL_PUNCT,
144 EL_SPACE,
145 EL_STYLE,
146 EL_ENDSTYLE,
147 EL_REF,
148 EL_BREAK
149};
150
151enum env
152{
153 ENV_NONE,
154 ENV_ENUMERATE,
155 ENV_ITEMIZE,
156 ENV_DESCRIPTION,
157 ENV_LIST,
158 ENV_INDENT,
159 ENV_TYPEWRITER
160};
161
162enum lang
163{
164 LANG_ENGLISH,
165 LANG_GERMAN
166};
167
168enum syntax
169{
170 SYNTAX_EMX,
171 SYNTAX_DVIDRV
172};
173
174struct special
175{
176 uchar *text;
177 uchar *ipf;
178 uchar *latex;
179 uchar *html;
180};
181
182struct word
183{
184 struct word *next;
185 struct word *database;
186 enum style style;
187 uchar *str;
188 uchar *repl;
189 struct special *special;
190 struct word_table *subidx;
191 int ref, idx;
192 uchar flags;
193};
194
195struct word_table;
196
197struct element
198{
199 enum el el;
200 int n;
201 struct word *wp;
202};
203
204struct environment
205{
206 enum env env;
207 int tmargin;
208 int imargin;
209 int start_line;
210 int counter;
211};
212
213struct toc
214{
215 struct toc *next;
216 int level;
217 int ref;
218 int print;
219 int global;
220 unsigned flags;
221 uchar *number;
222 uchar *title;
223};
224
225enum enc { ENC_DEFAULT = -3, ENC_AMBIGUOUS = -2, ENC_UNSUPPORTED = -1,
226 ENC_CP850 = 0, ENC_ISO8859_1, ENCODINGS };
227
228/* This is the escape character. */
229EXTERN uchar escape INIT (0xfe);
230
231/* The current input line number. */
232EXTERN int line_no INIT (0);
233
234/* The current input line. */
235EXTERN uchar input[256];
236
237/* The input encoding. */
238EXTERN enum enc input_encoding INIT (ENC_DEFAULT);
239
240/* The output encoding. */
241EXTERN enum enc output_encoding INIT (ENC_DEFAULT);
242
243/* This is the processing mode. */
244EXTERN char mode INIT (0);
245
246/* Concatenate instead of call .inf files */
247EXTERN int opt_a INIT (FALSE);
248
249/* Select line break algorithm for text output. */
250EXTERN int opt_b INIT (0);
251
252/* Use color instead of slanted type. */
253EXTERN int opt_c INIT (FALSE);
254
255/* French spacing. */
256EXTERN int opt_f INIT (FALSE);
257
258/* Gather global information. */
259EXTERN int opt_g INIT (FALSE);
260
261/* Display warning messages. */
262EXTERN int opt_w INIT (0);
263
264EXTERN const char *input_fname INIT (NULL);
265
266/* The input stream. */
267EXTERN FILE *input_file INIT (NULL);
268
269/* Non-zero if the end of the input file has been reached. */
270EXTERN int end_of_file INIT (FALSE);
271
272/* The output stream. */
273EXTERN FILE *output_file INIT (NULL);
274
275/* The global table of words. */
276EXTERN struct word_table *word_top INIT (NULL);
277
278EXTERN int hl_stack[HL_STACK_SIZE];
279EXTERN int hl_sp;
280
281/* Current line number of the output file. */
282EXTERN int output_line_no;
283
284/* Current column number of the output file. */
285EXTERN int output_x;
286
287/* Non-zero when writing output file (second pass). */
288EXTERN int out;
289
290/* Non-zero while formatting a prototype. */
291EXTERN int prototype_flag INIT (FALSE);
292
293/* The stack of nested environments. */
294EXTERN struct environment env_stack[ENV_STACK_SIZE];
295
296/* Stack pointer for stack of nested environments. */
297EXTERN int env_sp;
298
299/* Current list of formatting elements. */
300EXTERN struct element *elements INIT (NULL);
301
302/* Non-zero if a new paragraph should be started. */
303EXTERN int para_flag;
304
305/* Number of functions. */
306EXTERN int function_count;
307
308/* ... */
309EXTERN int ref_no INIT (1);
310
311/* ... */
312EXTERN int idx_no INIT (0);
313
314/* The title of the document. */
315EXTERN uchar *title INIT (NULL);
316
317/* The language of the document. */
318EXTERN enum lang language INIT (LANG_ENGLISH);
319
320/* Current tag: the tag. */
321EXTERN enum tag tg_tag;
322
323/* Current tag: style. */
324EXTERN enum style tg_style;
325
326/* Current tag: level (for h-, h=, h1 through h3, i1, i2 and index). */
327EXTERN int tg_level;
328
329/* Current tag: character for underlining (for h-, h= and h1 through h3). */
330EXTERN int tg_underline;
331
332/* Current tag: flags (such as HF_UNNUMBERED). */
333EXTERN unsigned tg_flags;
334
335
336void fatal (const char *fmt, ...) NORETURN2 PRINTF (1, 2);
337void nonfatal (const char *fmt, ...) PRINTF (1, 2);
338void warning (int level, const char *fmt, ...) PRINTF (2, 3);
339void *xmalloc (size_t n);
340uchar *xstrdup (const uchar *s);
341
342struct word_table *wt_new (unsigned hash_size);
343struct word *wt_find (struct word_table *wt, const uchar *str, unsigned hash);
344unsigned wt_hash (struct word_table *wt, const uchar *str);
345struct word *wt_add (struct word_table *wt, const uchar *str);
346int wt_walk (struct word_table *wt, int (*callback)(struct word *));
347int wt_count (const struct word_table *wt);
348
349struct word *word_find (const uchar *str, unsigned hash);
350unsigned word_hash (const uchar *str);
351struct word *word_add (const uchar *str);
352int word_walk (int (*callback)(struct word *));
353
354void write_nl (void);
355void write_break (void);
356void write_nstring (const uchar *p, size_t n);
357void write_string (const uchar *p);
358void write_line (const uchar *p);
359void write_fmt (const char *fmt, ...) PRINTF (1, 2);
360void write_space (void);
361void format_output (const uchar *p, int may_break);
362void format_string (const uchar *p, int sty, int may_break);
363void format_spaces (int n, enum style style, int may_break);
364void make_elements (const uchar *p);
365void start_hilite (int hilite);
366void end_hilite (void);
367struct word *use_reference (const uchar *p);
368void open_input (const char *name);
369void read_line (void);
370void init_file (void);
371int parse_tag (const uchar **ptr);
372void start_index (void);
Note: See TracBrowser for help on using the repository browser.