modules: remove support for module unload and refcount.
[m4/ericb.git] / m4 / m4module.h
bloba6bd5139008996fbf56e5c051650a371fc1853f7
1 /* GNU m4 -- A simple macro processor
2 Copyright (C) 1989-1994, 1999-2000, 2003-2010, 2013 Free Software
3 Foundation, Inc.
5 This file is part of GNU M4.
7 GNU M4 is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU M4 is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef M4MODULE_H
22 #define M4MODULE_H 1
24 #include <m4/hash.h>
25 #include <m4/system.h>
27 BEGIN_C_DECLS
31 /* --- MODULE AUTHOR DECLARATIONS --- */
33 typedef struct m4 m4;
34 typedef struct m4_builtin m4_builtin;
35 typedef struct m4_call_info m4_call_info;
36 typedef struct m4_macro m4_macro;
37 typedef struct m4_macro_args m4_macro_args;
38 typedef struct m4_module m4_module;
39 typedef struct obstack m4_obstack;
40 typedef struct m4_string m4_string;
41 typedef struct m4_string_pair m4_string_pair;
42 typedef struct m4_symbol m4_symbol;
43 typedef struct m4_symbol_value m4_symbol_value;
45 typedef void m4_builtin_func (m4 *, m4_obstack *, size_t, m4_macro_args *);
47 /* The value of m4_builtin flags is built from these: */
48 enum {
49 /* Set if macro flattens non-text tokens, such as builtin macro
50 tokens, to the empty string prior to invoking the builtin; if
51 clear, non-text tokens must be transparently handled by the
52 builtin. May only be set if max_args is nonzero. */
53 M4_BUILTIN_FLATTEN_ARGS = (1 << 0),
54 /* Set if macro should only be recognized with arguments; may only
55 be set if min_args is nonzero. */
56 M4_BUILTIN_BLIND = (1 << 1),
57 /* Set if macro has side effects even when there are too few
58 arguments; may only be set if min_args is nonzero. */
59 M4_BUILTIN_SIDE_EFFECT = (1 << 2),
61 /* Mask of valid flag bits. Any other bits must be set to 0. */
62 M4_BUILTIN_FLAGS_MASK = (1 << 3) - 1
65 struct m4_builtin
67 m4_builtin_func * func; /* implementation of the builtin */
68 const char * name; /* name found by builtin, printed by dumpdef */
69 int flags; /* bitwise OR of M4_BUILTIN_* bits */
70 size_t min_args; /* 0-based minimum number of arguments */
71 /* max arguments, SIZE_MAX if unlimited; must be >= min_args */
72 size_t max_args;
75 struct m4_macro
77 const char *name;
78 const char *value;
79 size_t min_args; /* 0-based minimum number of arguments */
80 /* max arguments, SIZE_MAX if unlimited; must be >= min_args */
81 size_t max_args;
84 /* Describe a single string, such as a macro name. */
85 struct m4_string
87 char *str; /* Array of characters, possibly including NUL. */
88 size_t len; /* Length of string. */
91 /* Describe a pair of strings, such as begin and end quotes. */
92 struct m4_string_pair
94 char *str1; /* First string. */
95 size_t len1; /* First length. */
96 char *str2; /* Second string. */
97 size_t len2; /* Second length. */
100 /* Declare a prototype for the function "builtin_<NAME>". Note that
101 the function name includes any macro expansion of NAME. */
102 #define M4BUILTIN(name) \
103 static void CONC (builtin_, name) \
104 (m4 *, m4_obstack *, size_t, m4_macro_args *);
106 /* Begin the implementation of the function "builtin_<NAME>",
107 declaring parameter names that can be used by other helper macros
108 in this file. Note that the function name includes any macro
109 expansion of NAME. */
110 #define M4BUILTIN_HANDLER(name) \
111 static void CONC (builtin_, name) \
112 (m4 *context, m4_obstack *obs, size_t argc, m4_macro_args *argv)
114 /* Declare a prototype, then begin the implementation of the function
115 "<NAME>_LTX_m4_init_module", which will automatically be registered
116 as the initialization function for module NAME. Note that NAME is
117 intentionally used literally, rather than subjected to macro
118 expansion. */
119 #define M4INIT_HANDLER(name) \
120 void name ## _LTX_m4_init_module \
121 (m4 *, m4_module *, m4_obstack *); \
122 void name ## _LTX_m4_init_module \
123 (m4 *context, m4_module *module, m4_obstack *obs)
125 /* Declare a variable S of type "<S>_func" to be a pointer to the
126 function named S imported from the module M, or NULL if the import
127 fails. Note that M and S are intentionally used literally rather
128 than subjected to macro expansion, in all but the variable name. */
129 #define M4_MODULE_IMPORT(M, S) \
130 S ## _func *S = (S ## _func *) m4_module_import (context, #M, #S, obs)
132 /* Build an entry in a builtin table, for the builtin N implemented by
133 the function "builtin_<N>" with name NAME. Build the flags from
134 the appropriate combination of M4_BUILTIN_FLAG_* based on M if the
135 builtin transparently supports macro tokens, B if it is blind, and
136 S if it has side effects. Specify that the builtin takes MIN and
137 MAX arguments. Note that N is subject to macro expansion, and that
138 NAME is generally used as #N to avoid clashes with builtins named
139 after a standard function that is defined as a macro. */
140 #define M4BUILTIN_ENTRY(N, NAME, M, B, S, MIN, MAX) \
142 CONC (builtin_, N), NAME, \
143 (((!(M) && (MAX)) ? M4_BUILTIN_FLATTEN_ARGS : 0) \
144 | (((B) && (MIN)) ? M4_BUILTIN_BLIND : 0) \
145 | (((S) && (MIN)) ? M4_BUILTIN_SIDE_EFFECT : 0)), \
146 MIN, MAX \
149 /* Grab the text contents of argument I, or abort if the argument is
150 not text. Assumes that `m4 *context' and `m4_macro_args *argv' are
151 in scope. */
152 #define M4ARG(i) m4_arg_text (context, argv, i, false)
154 /* Grab the length of the text contents of argument I, or abort if the
155 argument is not text. Assumes that `m4 *context' and
156 `m4_macro_args *argv' are in scope. */
157 #define M4ARGLEN(i) m4_arg_len (context, argv, i, false)
159 extern bool m4_bad_argc (m4 *, size_t, const m4_call_info *, size_t,
160 size_t, bool);
161 extern bool m4_numeric_arg (m4 *, const m4_call_info *, const char *,
162 size_t, int *);
163 extern bool m4_parse_truth_arg (m4 *, const m4_call_info *, const char *,
164 size_t, bool);
165 extern m4_symbol *m4_symbol_value_lookup (m4 *, m4_macro_args *, size_t, bool);
166 extern const char *m4_info_name (const m4_call_info *);
168 /* Error handling. */
169 extern void m4_error (m4 *, int, int, const m4_call_info *, const char *, ...)
170 M4_GNUC_PRINTF (5, 6);
171 extern void m4_warn (m4 *, int, const m4_call_info *, const char *, ...)
172 M4_GNUC_PRINTF (4, 5);
174 extern const char * m4_get_program_name (void);
175 extern void m4_set_program_name (const char *);
176 extern void m4_set_exit_failure (int);
179 /* --- CONTEXT MANAGEMENT --- */
181 typedef struct m4_syntax_table m4_syntax_table;
182 typedef struct m4_symbol_table m4_symbol_table;
184 extern m4 * m4_create (void);
185 extern void m4_delete (m4 *);
187 #define m4_context_field_table \
188 M4FIELD(m4_symbol_table *, symbol_table, symtab) \
189 M4FIELD(m4_syntax_table *, syntax_table, syntax) \
190 M4FIELD(const char *, current_file, current_file) \
191 M4FIELD(int, current_line, current_line) \
192 M4FIELD(int, output_line, output_line) \
193 M4FIELD(FILE *, debug_file, debug_file) \
194 M4FIELD(m4_obstack, trace_messages, trace_messages) \
195 M4FIELD(int, exit_status, exit_status) \
196 M4FIELD(int, current_diversion, current_diversion) \
197 M4FIELD(size_t, nesting_limit_opt, nesting_limit) \
198 M4FIELD(int, debug_level_opt, debug_level) \
199 M4FIELD(size_t, max_debug_arg_length_opt, max_debug_arg_length)\
200 M4FIELD(int, regexp_syntax_opt, regexp_syntax) \
203 #define m4_context_opt_bit_table \
204 M4OPT_BIT(M4_OPT_PREFIX_BUILTINS_BIT, prefix_builtins_opt) \
205 M4OPT_BIT(M4_OPT_SUPPRESS_WARN_BIT, suppress_warnings_opt) \
206 M4OPT_BIT(M4_OPT_DISCARD_COMMENTS_BIT, discard_comments_opt) \
207 M4OPT_BIT(M4_OPT_INTERACTIVE_BIT, interactive_opt) \
208 M4OPT_BIT(M4_OPT_SYNCOUTPUT_BIT, syncoutput_opt) \
209 M4OPT_BIT(M4_OPT_POSIXLY_CORRECT_BIT, posixly_correct_opt) \
210 M4OPT_BIT(M4_OPT_FATAL_WARN_BIT, fatal_warnings_opt) \
211 M4OPT_BIT(M4_OPT_WARN_EXIT_BIT, warnings_exit_opt) \
212 M4OPT_BIT(M4_OPT_SAFER_BIT, safer_opt) \
215 #define M4FIELD(type, base, field) \
216 extern type CONC (m4_get_, base) (m4 *context); \
217 extern type CONC (m4_set_, base) (m4 *context, type value);
218 m4_context_field_table
219 #undef M4FIELD
221 #define M4OPT_BIT(bit, base) \
222 extern bool CONC (m4_get_, base) (m4 *context); \
223 extern bool CONC (m4_set_, base) (m4 *context, bool value);
224 m4_context_opt_bit_table
225 #undef M4OPT_BIT
227 #define M4SYMTAB (m4_get_symbol_table (context))
228 #define M4SYNTAX (m4_get_syntax_table (context))
232 /* --- MODULE MANAGEMENT --- */
234 typedef void m4_module_init_func (m4 *, m4_module *, m4_obstack *);
236 extern m4_module * m4_module_load (m4 *, const char *, m4_obstack *);
237 extern void * m4_module_import (m4 *, const char *, const char *,
238 m4_obstack *);
240 extern const char * m4_get_module_name (const m4_module *);
241 extern m4_module * m4_module_next (m4_module *);
245 /* --- SYMBOL TABLE MANAGEMENT --- */
248 typedef void *m4_symtab_apply_func (m4_symbol_table *, const char *, size_t,
249 m4_symbol *, void *);
251 extern m4_symbol_table *m4_symtab_create (size_t);
252 extern void m4_symtab_delete (m4_symbol_table *);
253 extern void * m4_symtab_apply (m4_symbol_table *, bool,
254 m4_symtab_apply_func *, void *);
256 extern m4_symbol *m4_symbol_lookup (m4_symbol_table *, const char *, size_t);
257 extern m4_symbol *m4_symbol_pushdef (m4_symbol_table *, const char *, size_t,
258 m4_symbol_value *);
259 extern m4_symbol *m4_symbol_define (m4_symbol_table *, const char *, size_t,
260 m4_symbol_value *);
261 extern void m4_symbol_popdef (m4_symbol_table *, const char *, size_t);
262 extern m4_symbol *m4_symbol_rename (m4_symbol_table *, const char *, size_t,
263 const char *, size_t);
265 extern void m4_symbol_delete (m4_symbol_table *, const char *, size_t);
267 #define m4_symbol_delete(symtab, name, len) M4_STMT_START \
269 while (m4_symbol_lookup (symtab, name, len)) \
270 m4_symbol_popdef (symtab, name, len); \
271 } M4_STMT_END
273 extern m4_symbol_value *m4_get_symbol_value (m4_symbol *);
274 extern bool m4_get_symbol_traced (m4_symbol *);
275 extern bool m4_set_symbol_name_traced (m4_symbol_table *,
276 const char *, size_t, bool);
277 extern void m4_symbol_print (m4 *, m4_symbol *, m4_obstack *,
278 const m4_string_pair *, bool, size_t,
279 bool);
280 extern bool m4_symbol_value_flatten_args (m4_symbol_value *);
282 #define m4_is_symbol_void(symbol) \
283 (m4_is_symbol_value_void (m4_get_symbol_value (symbol)))
284 #define m4_is_symbol_text(symbol) \
285 (m4_is_symbol_value_text (m4_get_symbol_value (symbol)))
286 #define m4_is_symbol_func(symbol) \
287 (m4_is_symbol_value_func (m4_get_symbol_value (symbol)))
288 #define m4_is_symbol_placeholder(symbol) \
289 (m4_is_symbol_value_placeholder (m4_get_symbol_value (symbol)))
290 #define m4_get_symbol_text(symbol) \
291 (m4_get_symbol_value_text (m4_get_symbol_value (symbol)))
292 #define m4_get_symbol_len(symbol) \
293 (m4_get_symbol_value_len (m4_get_symbol_value (symbol)))
294 #define m4_get_symbol_func(symbol) \
295 (m4_get_symbol_value_func (m4_get_symbol_value (symbol)))
296 #define m4_get_symbol_builtin(symbol) \
297 (m4_get_symbol_value_builtin (m4_get_symbol_value (symbol)))
298 #define m4_get_symbol_placeholder(symbol) \
299 (m4_get_symbol_value_placeholder (m4_get_symbol_value (symbol)))
300 #define m4_symbol_flatten_args(symbol) \
301 (m4_symbol_value_flatten_args (m4_get_symbol_value (symbol)))
303 extern m4_symbol_value *m4_symbol_value_create (void);
304 extern void m4_symbol_value_delete (m4_symbol_value *);
305 extern bool m4_symbol_value_copy (m4 *, m4_symbol_value *,
306 m4_symbol_value *);
307 extern bool m4_is_symbol_value_text (m4_symbol_value *);
308 extern bool m4_is_symbol_value_func (m4_symbol_value *);
309 extern bool m4_is_symbol_value_placeholder (m4_symbol_value *);
310 extern bool m4_is_symbol_value_void (m4_symbol_value *);
312 extern const char * m4_get_symbol_value_text (m4_symbol_value *);
313 extern size_t m4_get_symbol_value_len (m4_symbol_value *);
314 extern unsigned int m4_get_symbol_value_quote_age (m4_symbol_value *);
316 extern m4_builtin_func *m4_get_symbol_value_func (m4_symbol_value *);
317 extern const m4_builtin *m4_get_symbol_value_builtin (m4_symbol_value *);
318 extern const char * m4_get_symbol_value_placeholder (m4_symbol_value *);
320 extern void m4_set_symbol_value_text (m4_symbol_value *,
321 const char *, size_t,
322 unsigned int);
323 extern void m4_set_symbol_value_placeholder (m4_symbol_value *,
324 const char *);
328 /* --- BUILTIN MANAGEMENT --- */
330 extern m4_symbol_value *m4_builtin_find_by_name (m4_module *, const char *);
331 extern m4_symbol_value *m4_builtin_find_by_func (m4_module *,
332 m4_builtin_func *);
336 /* --- MACRO MANAGEMENT --- */
338 extern void m4_macro_expand_input (m4 *);
339 extern void m4_macro_call (m4 *, m4_symbol_value *, m4_obstack *,
340 m4_macro_args *);
341 extern size_t m4_arg_argc (m4_macro_args *);
342 extern const m4_call_info *m4_arg_info (m4_macro_args *);
343 extern m4_symbol_value *m4_arg_symbol (m4_macro_args *, size_t);
344 extern bool m4_is_arg_text (m4_macro_args *, size_t);
345 extern bool m4_is_arg_func (m4_macro_args *, size_t);
346 extern bool m4_is_arg_composite (m4_macro_args *, size_t);
347 extern const char *m4_arg_text (m4 *, m4_macro_args *, size_t, bool);
348 extern bool m4_arg_equal (m4 *, m4_macro_args *, size_t,
349 size_t);
350 extern bool m4_arg_empty (m4_macro_args *, size_t);
351 extern size_t m4_arg_len (m4 *, m4_macro_args *, size_t, bool);
352 extern m4_builtin_func *m4_arg_func (m4_macro_args *, size_t);
353 extern m4_obstack *m4_arg_scratch (m4 *);
354 extern m4_macro_args *m4_make_argv_ref (m4 *, m4_macro_args *, const char *,
355 size_t, bool, bool);
356 extern void m4_push_arg (m4 *, m4_obstack *, m4_macro_args *,
357 size_t);
358 extern void m4_push_args (m4 *, m4_obstack *, m4_macro_args *,
359 bool, bool);
360 extern void m4_wrap_args (m4 *, m4_macro_args *);
363 /* --- RUNTIME DEBUGGING --- */
365 /* The value of debug_level is a bitmask of the following: */
366 enum {
367 /* a: show arglist in trace output */
368 M4_DEBUG_TRACE_ARGS = (1 << 0),
369 /* e: show expansion in trace output */
370 M4_DEBUG_TRACE_EXPANSION = (1 << 1),
371 /* q: quote args and expansion in trace output */
372 M4_DEBUG_TRACE_QUOTE = (1 << 2),
373 /* t: trace all macros -- overrides trace{on,off} */
374 M4_DEBUG_TRACE_ALL = (1 << 3),
375 /* l: add line numbers to trace output */
376 M4_DEBUG_TRACE_LINE = (1 << 4),
377 /* f: add file name to trace output */
378 M4_DEBUG_TRACE_FILE = (1 << 5),
379 /* p: trace path search of include files */
380 M4_DEBUG_TRACE_PATH = (1 << 6),
381 /* c: show macro call before args collection */
382 M4_DEBUG_TRACE_CALL = (1 << 7),
383 /* i: trace changes of input files */
384 M4_DEBUG_TRACE_INPUT = (1 << 8),
385 /* x: add call id to trace output */
386 M4_DEBUG_TRACE_CALLID = (1 << 9),
387 /* m: trace module actions */
388 M4_DEBUG_TRACE_MODULE = (1 << 10),
389 /* s: trace pushdef stacks */
390 M4_DEBUG_TRACE_STACK = (1 << 11),
391 /* d: warn if dereferencing undefined macro */
392 M4_DEBUG_TRACE_DEREF = (1 << 12),
393 /* o: output dumpdef to stderr, not debug file */
394 M4_DEBUG_TRACE_OUTPUT_DUMPDEF = (1 << 13),
396 /* V: very verbose -- print everything */
397 M4_DEBUG_TRACE_VERBOSE = ((1 << 14) - 1)
400 /* initial flags, used if no -d or -E -- equiv: d */
401 #define M4_DEBUG_TRACE_INITIAL M4_DEBUG_TRACE_DEREF
403 /* default flags, used by debugmode() -- equiv: +adeq */
404 #define M4_DEBUG_TRACE_DEFAULT \
405 (M4_DEBUG_TRACE_ARGS | M4_DEBUG_TRACE_EXPANSION \
406 | M4_DEBUG_TRACE_QUOTE | M4_DEBUG_TRACE_DEREF)
408 #define m4_is_debug_bit(C,B) ((m4_get_debug_level_opt (C) & (B)) != 0)
410 extern int m4_debug_decode (m4 *, const char *, size_t);
411 extern bool m4_debug_set_output (m4 *, const m4_call_info *,
412 const char *);
413 extern void m4_debug_message_prefix (m4 *);
414 extern void m4_debug_message (m4 *, int, const char *, ...)
415 M4_GNUC_PRINTF (3, 4);
417 extern void m4_trace_prepare (m4 *, const m4_call_info *,
418 m4_symbol_value *);
421 /* --- REGEXP SYNTAX --- */
423 extern const char * m4_regexp_syntax_decode (int);
424 extern int m4_regexp_syntax_encode (const char *);
428 /* --- SYNTAX TABLE DEFINITIONS --- */
430 extern m4_syntax_table *m4_syntax_create (void);
431 extern void m4_syntax_delete (m4_syntax_table *syntax);
432 extern int m4_syntax_code (char ch);
434 extern const char * m4_get_syntax_lquote (m4_syntax_table *syntax);
435 extern const char * m4_get_syntax_rquote (m4_syntax_table *syntax);
436 extern const char * m4_get_syntax_bcomm (m4_syntax_table *syntax);
437 extern const char * m4_get_syntax_ecomm (m4_syntax_table *syntax);
438 extern const m4_string_pair *m4_get_syntax_quotes (m4_syntax_table *);
439 extern const m4_string_pair *m4_get_syntax_comments (m4_syntax_table *);
441 extern bool m4_is_syntax_single_quotes (m4_syntax_table *);
442 extern bool m4_is_syntax_single_comments (m4_syntax_table *);
443 extern bool m4_is_syntax_single_dollar (m4_syntax_table *);
444 extern bool m4_is_syntax_macro_escaped (m4_syntax_table *);
446 /* These are values to be assigned to syntax table entries. Although
447 they are bit masks for fast categorization in m4__next_token(),
448 only one value per syntax table entry is allowed. The enumeration
449 is currently sorted in order of parsing precedence. */
450 enum {
451 M4_SYNTAX_IGNORE = 0,
452 M4_SYNTAX_ESCAPE = 1 << 0,
453 M4_SYNTAX_ALPHA = 1 << 1,
454 M4_SYNTAX_LQUOTE = 1 << 2,
455 M4_SYNTAX_BCOMM = 1 << 3,
456 M4_SYNTAX_ACTIVE = 1 << 4,
457 M4_SYNTAX_NUM = 1 << 5,
458 M4_SYNTAX_SPACE = 1 << 6,
459 M4_SYNTAX_OPEN = 1 << 7,
460 M4_SYNTAX_CLOSE = 1 << 8,
461 M4_SYNTAX_COMMA = 1 << 9,
462 M4_SYNTAX_OTHER = 1 << 10,
464 /* These values are bit masks to OR with categories above, a syntax entry
465 may have any number of these in addition to a maximum of one of the
466 values above. */
467 M4_SYNTAX_DOLLAR = 1 << 11,
468 M4_SYNTAX_LBRACE = 1 << 12,
469 M4_SYNTAX_RBRACE = 1 << 13,
470 M4_SYNTAX_RQUOTE = 1 << 14,
471 M4_SYNTAX_ECOMM = 1 << 15
474 /* Mask of attribute syntax categories. */
475 #define M4_SYNTAX_MASKS (M4_SYNTAX_RQUOTE | M4_SYNTAX_ECOMM \
476 | M4_SYNTAX_DOLLAR | M4_SYNTAX_LBRACE \
477 | M4_SYNTAX_RBRACE)
478 /* Mask of basic syntax categories where any change requires a
479 recomputation of the overall syntax characteristics. */
480 #define M4_SYNTAX_SUSPECT (M4_SYNTAX_LQUOTE | M4_SYNTAX_BCOMM \
481 | M4_SYNTAX_ESCAPE)
483 #define m4_syntab(S, C) ((S)->table[(C)])
484 /* Determine if character C matches any of the bitwise-or'd syntax
485 categories T for the given syntax table S. C can be either an
486 unsigned int (including special values such as CHAR_BUILTIN) or a
487 char which will be interpreted as an unsigned char. */
488 #define m4_has_syntax(S, C, T) \
489 ((m4_syntab ((S), sizeof (C) == 1 ? to_uchar (C) : (C)) & (T)) > 0)
491 extern void m4_set_quotes (m4_syntax_table *, const char *, size_t,
492 const char *, size_t);
493 extern void m4_set_comment (m4_syntax_table *, const char *, size_t,
494 const char *, size_t);
495 extern int m4_set_syntax (m4_syntax_table *, char, char, const char *,
496 size_t);
497 extern void m4_reset_syntax (m4_syntax_table *);
501 /* --- INPUT TOKENIZATION --- */
503 extern void m4_input_init (m4 *context);
504 extern void m4_input_exit (void);
505 extern void m4_skip_line (m4 *context, const m4_call_info *);
507 /* push back input */
509 extern void m4_push_file (m4 *, FILE *, const char *, bool);
510 extern void m4_push_builtin (m4 *, m4_obstack *, m4_symbol_value *);
511 extern m4_obstack *m4_push_string_init (m4 *, const char *, int);
512 extern void m4_push_string_finish (void);
513 extern bool m4_pop_wrapup (m4 *);
514 extern void m4_input_print (m4 *, m4_obstack *, int);
518 /* --- OUTPUT MANAGEMENT --- */
520 extern void m4_output_init (m4 *);
521 extern void m4_output_exit (void);
522 extern void m4_output_text (m4 *, const char *, size_t);
523 extern void m4_divert_text (m4 *, m4_obstack *, const char *,
524 size_t, int);
525 extern void m4_shipout_int (m4_obstack *, int);
526 extern void m4_shipout_string (m4 *, m4_obstack *, const char *,
527 size_t, bool);
528 extern bool m4_shipout_string_trunc (m4_obstack *, const char *, size_t,
529 const m4_string_pair *, size_t *);
531 extern void m4_make_diversion (m4 *, int);
532 extern void m4_insert_diversion (m4 *, int);
533 extern void m4_insert_file (m4 *, FILE *);
534 extern void m4_freeze_diversions (m4 *, FILE *);
535 extern void m4_undivert_all (m4 *);
539 /* --- PATH MANAGEMENT --- */
541 extern void m4_add_include_directory (m4 *, const char *, bool);
542 extern bool m4_load_filename (m4 *, const m4_call_info *,
543 const char *, m4_obstack *, bool);
544 extern char * m4_path_search (m4 *, const char *, const char **);
545 extern FILE * m4_fopen (m4 *, const char *, const char *);
549 #define obstack_chunk_alloc xmalloc
550 #define obstack_chunk_free free
553 /* Convert a possibly-signed character to an unsigned character. This is
554 a bit safer than casting to unsigned char, since it catches some type
555 errors that the cast doesn't. */
556 #if HAVE_INLINE
557 static inline unsigned char to_uchar (char ch) { return ch; }
558 #else
559 # define to_uchar(C) ((unsigned char) (C))
560 #endif
562 END_C_DECLS
564 #endif /* !M4MODULE_H */