/usr.bin/m4/extern.h

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 177 lines · 110 code · 22 blank · 45 comment · 7 complexity · 55c91ffaf2c59b16d1fb4eeea71134b1 MD5 · raw file

  1. /* $OpenBSD: extern.h,v 1.51 2011/09/27 07:24:02 espie Exp $ */
  2. /* $NetBSD: extern.h,v 1.3 1996/01/13 23:25:24 pk Exp $ */
  3. /*-
  4. * Copyright (c) 1991, 1993
  5. * The Regents of the University of California. All rights reserved.
  6. *
  7. * This code is derived from software contributed to Berkeley by
  8. * Ozan Yigit at York University.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. * 3. Neither the name of the University nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  23. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  28. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  31. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. *
  34. * @(#)extern.h 8.1 (Berkeley) 6/6/93
  35. * $FreeBSD$
  36. */
  37. /* eval.c */
  38. extern void eval(const char *[], int, int, int);
  39. extern void dodefine(const char *, const char *);
  40. extern unsigned long expansion_id;
  41. /* expr.c */
  42. extern int expr(const char *);
  43. /* gnum4.c */
  44. extern void addtoincludepath(const char *);
  45. extern struct input_file *fopen_trypath(struct input_file *, const char *);
  46. extern void doindir(const char *[], int);
  47. extern void dobuiltin(const char *[], int);
  48. extern void dopatsubst(const char *[], int);
  49. extern void doregexp(const char *[], int);
  50. extern void doprintlineno(struct input_file *);
  51. extern void doprintfilename(struct input_file *);
  52. extern void doesyscmd(const char *);
  53. extern void getdivfile(const char *);
  54. extern void doformat(const char *[], int);
  55. /* look.c */
  56. #define FLAG_UNTRACED 0
  57. #define FLAG_TRACED 1
  58. #define FLAG_NO_TRACE 2
  59. extern void init_macros(void);
  60. extern ndptr lookup(const char *);
  61. extern void mark_traced(const char *, int);
  62. extern struct ohash macros;
  63. extern struct macro_definition *lookup_macro_definition(const char *);
  64. extern void macro_define(const char *, const char *);
  65. extern void macro_pushdef(const char *, const char *);
  66. extern void macro_popdef(const char *);
  67. extern void macro_undefine(const char *);
  68. extern void setup_builtin(const char *, unsigned int);
  69. extern void macro_for_all(void (*)(const char *, struct macro_definition *));
  70. #define macro_getdef(p) ((p)->d)
  71. #define macro_name(p) ((p)->name)
  72. #define macro_builtin_type(p) ((p)->builtin_type)
  73. #define is_traced(p) ((p)->trace_flags == FLAG_NO_TRACE ? (trace_flags & TRACE_ALL) : (p)->trace_flags)
  74. extern ndptr macro_getbuiltin(const char *);
  75. /* main.c */
  76. extern void outputstr(const char *);
  77. extern void do_emit_synchline(void);
  78. extern int exit_code;
  79. #define emit_synchline() do { if (synch_lines) do_emit_synchline(); } while(0)
  80. /* misc.c */
  81. extern void chrsave(int);
  82. extern char *compute_prevep(void);
  83. extern void getdiv(int);
  84. extern ptrdiff_t indx(const char *, const char *);
  85. extern void initspaces(void);
  86. extern void killdiv(void);
  87. extern void onintr(int);
  88. extern void pbnum(int);
  89. extern void pbnumbase(int, int, int);
  90. extern void pbunsigned(unsigned long);
  91. extern void pbstr(const char *);
  92. extern void pushback(int);
  93. extern void *xalloc(size_t, const char *fmt, ...);
  94. extern void *xrealloc(void *, size_t, const char *fmt, ...);
  95. extern char *xstrdup(const char *);
  96. extern void usage(void);
  97. extern void resizedivs(int);
  98. extern size_t buffer_mark(void);
  99. extern void dump_buffer(FILE *, size_t);
  100. extern void m4errx(int, const char *, ...);
  101. extern int obtain_char(struct input_file *);
  102. extern void set_input(struct input_file *, FILE *, const char *);
  103. extern void release_input(struct input_file *);
  104. /* speeded-up versions of chrsave/pushback */
  105. #define PUSHBACK(c) \
  106. do { \
  107. if (bp >= endpbb) \
  108. enlarge_bufspace(); \
  109. *bp++ = (c); \
  110. } while(0)
  111. #define CHRSAVE(c) \
  112. do { \
  113. if (ep >= endest) \
  114. enlarge_strspace(); \
  115. *ep++ = (c); \
  116. } while(0)
  117. /* and corresponding exposure for local symbols */
  118. extern void enlarge_bufspace(void);
  119. extern void enlarge_strspace(void);
  120. extern unsigned char *endpbb;
  121. extern char *endest;
  122. /* trace.c */
  123. extern unsigned int trace_flags;
  124. #define TRACE_ALL 512
  125. extern void trace_file(const char *);
  126. extern size_t trace(const char **, int, struct input_file *);
  127. extern void finish_trace(size_t);
  128. extern void set_trace_flags(const char *);
  129. extern FILE *traceout;
  130. extern stae *mstack; /* stack of m4 machine */
  131. extern char *sstack; /* shadow stack, for string space extension */
  132. extern FILE *active; /* active output file pointer */
  133. extern struct input_file infile[];/* input file stack (0=stdin) */
  134. extern FILE **outfile; /* diversion array(0=bitbucket) */
  135. extern int maxout; /* maximum number of diversions */
  136. extern int fp; /* m4 call frame pointer */
  137. extern int ilevel; /* input file stack pointer */
  138. extern int oindex; /* diversion index. */
  139. extern int sp; /* current m4 stack pointer */
  140. extern unsigned char *bp; /* first available character */
  141. extern unsigned char *buf; /* push-back buffer */
  142. extern unsigned char *bufbase; /* buffer base for this ilevel */
  143. extern unsigned char *bbase[]; /* buffer base per ilevel */
  144. extern char ecommt[MAXCCHARS+1];/* end character for comment */
  145. extern char *ep; /* first free char in strspace */
  146. extern char lquote[MAXCCHARS+1];/* left quote character (`) */
  147. extern char **m4wraps; /* m4wrap string default. */
  148. extern int maxwraps; /* size of m4wraps array */
  149. extern int wrapindex; /* current index in m4wraps */
  150. extern const char *null; /* as it says.. just a null. */
  151. extern char rquote[MAXCCHARS+1];/* right quote character (') */
  152. extern char scommt[MAXCCHARS+1];/* start character for comment */
  153. extern int synch_lines; /* line synchronisation directives */
  154. extern int mimic_gnu; /* behaves like gnu-m4 */
  155. extern int prefix_builtins; /* prefix builtin macros with m4_ */