1/* macro.h -- declarations for macro.c.
2   $Id: macro.h,v 1.2 2004/04/11 17:56:47 karl Exp $
3
4   Copyright (C) 1998, 99 Free Software Foundation, Inc.
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with this program; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19   */
20
21#ifndef MACRO_H
22#define MACRO_H
23
24extern FILE *macro_expansion_output_stream;
25extern char *macro_expansion_filename;
26extern int me_executing_string;
27extern int only_macro_expansion;
28
29/* Here is a structure used to remember input text strings and offsets
30   within them. */
31typedef struct {
32  char *pointer;                /* Pointer to the input text. */
33  int offset;                   /* Offset of the last character output. */
34} ITEXT;
35
36/* Macro definitions for user-defined commands. */
37typedef struct {
38  char *name;                   /* Name of the macro. */
39  char **arglist;               /* Args to replace when executing. */
40  char *body;                   /* Macro body. */
41  char *source_file;            /* File where this macro is defined. */
42  int source_lineno;            /* Line number within FILENAME. */
43  int inhibited;                /* Nonzero means make find_macro () fail. */
44  int flags;                    /* ME_RECURSE, ME_QUOTE_ARG, etc. */
45} MACRO_DEF;
46
47/* flags for MACRO_DEF */
48#define ME_RECURSE      0x01
49#define ME_QUOTE_ARG    0x02
50
51extern void execute_macro (MACRO_DEF *def);
52extern MACRO_DEF *find_macro (char *name);
53extern char *expand_macro (MACRO_DEF *def);
54
55extern ITEXT *remember_itext (char *pointer, int offset);
56extern void forget_itext (char *pointer);
57extern void maybe_write_itext (char *pointer, int offset);
58extern void write_region_to_macro_output (char *string, int start, int end);
59extern void append_to_expansion_output (int offset);
60extern void me_append_before_this_command (void);
61extern void me_execute_string (char *execution_string);
62extern void me_execute_string_keep_state (char *execution_string,
63    char *append_string);
64
65extern char *alias_expand (char *tok);
66extern int enclosure_command (char *tok);
67extern void enclosure_expand (int arg, int start, int end);
68
69/* The @commands.  */
70extern void cm_macro (void), cm_rmacro (void), cm_unmacro (void);
71extern void cm_alias (void), cm_definfoenclose (void);
72
73extern int array_len (char **array);
74extern void free_array (char **array);
75extern char **get_brace_args (int quote_single);
76
77#endif /* not MACRO_H */
78