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