macro.h 2.9 KB

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