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 $ */ 3 4/*- 5 * SPDX-License-Identifier: BSD-3-Clause 6 * 7 * Copyright (c) 1991, 1993 8 * The Regents of the University of California. All rights reserved. 9 * 10 * This code is derived from software contributed to Berkeley by 11 * Ozan Yigit at York University. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 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. 24 * 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 35 * SUCH DAMAGE. 36 * 37 * @(#)extern.h 8.1 (Berkeley) 6/6/93 38 * $FreeBSD$ 39 */ 40 41/* eval.c */ 42extern void eval(const char *[], int, int, int); 43extern void dodefine(const char *, const char *); 44extern unsigned long expansion_id; 45 46/* expr.c */ 47extern int expr(const char *); 48 49/* gnum4.c */ 50extern void addtoincludepath(const char *); 51extern struct input_file *fopen_trypath(struct input_file *, const char *); 52extern void doindir(const char *[], int); 53extern void dobuiltin(const char *[], int); 54extern void dopatsubst(const char *[], int); 55extern void doregexp(const char *[], int); 56 57extern void doprintlineno(struct input_file *); 58extern void doprintfilename(struct input_file *); 59 60extern void doesyscmd(const char *); 61extern void getdivfile(const char *); 62extern void doformat(const char *[], int); 63 64extern void m4_warnx(const char *, ...); 65 66/* look.c */ 67 68#define FLAG_UNTRACED 0 69#define FLAG_TRACED 1 70#define FLAG_NO_TRACE 2 71 72extern void init_macros(void); 73extern ndptr lookup(const char *); 74extern void mark_traced(const char *, int); 75extern struct ohash macros; 76 77extern struct macro_definition *lookup_macro_definition(const char *); 78extern void macro_define(const char *, const char *); 79extern void macro_pushdef(const char *, const char *); 80extern void macro_popdef(const char *); 81extern void macro_undefine(const char *); 82extern void setup_builtin(const char *, unsigned int); 83extern 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) 88 89extern ndptr macro_getbuiltin(const char *); 90 91/* main.c */ 92extern void outputstr(const char *); 93extern void do_emit_synchline(void); 94extern int exit_code; 95#define emit_synchline() do { if (synch_lines) do_emit_synchline(); } while(0) 96 97/* misc.c */ 98extern void chrsave(int); 99extern char *compute_prevep(void); 100extern void getdiv(int); 101extern ptrdiff_t indx(const char *, const char *); 102extern void initspaces(void); 103extern void killdiv(void); 104extern void onintr(int); 105extern void pbnum(int); 106extern void pbnumbase(int, int, int); 107extern void pbunsigned(unsigned long); 108extern void pbstr(const char *); 109extern void pushback(int); 110extern void *xalloc(size_t, const char *, ...) __printf0like(2, 3); 111extern void *xcalloc(size_t, size_t, const char *, ...) __printf0like(3, 4); 112extern void *xrealloc(void *, size_t, const char *, ...) __printf0like(3, 4); 113extern void *xreallocarray(void *, size_t, size_t, const char *, ...) __printf0like(4, 5); 114extern char *xstrdup(const char *); 115extern void usage(void); 116extern void resizedivs(int); 117extern size_t buffer_mark(void); 118extern void dump_buffer(FILE *, size_t); 119extern void m4errx(int, const char *, ...) __dead2 __printf0like(2, 3); 120 121extern int obtain_char(struct input_file *); 122extern void set_input(struct input_file *, FILE *, const char *); 123extern void release_input(struct input_file *); 124 125/* speeded-up versions of chrsave/pushback */ 126#define PUSHBACK(c) \ 127 do { \ 128 if (bp >= endpbb) \ 129 enlarge_bufspace(); \ 130 *bp++ = (c); \ 131 } while(0) 132 133#define CHRSAVE(c) \ 134 do { \ 135 if (ep >= endest) \ 136 enlarge_strspace(); \ 137 *ep++ = (c); \ 138 } while(0) 139 140/* and corresponding exposure for local symbols */ 141extern void enlarge_bufspace(void); 142extern void enlarge_strspace(void); 143extern unsigned char *endpbb; 144extern char *endest; 145 146/* trace.c */ 147extern unsigned int trace_flags; 148#define TRACE_ALL 512 149extern void trace_file(const char *); 150extern size_t trace(const char **, int, struct input_file *); 151extern void finish_trace(size_t); 152extern void set_trace_flags(const char *); 153extern FILE *traceout; 154 155extern stae *mstack; /* stack of m4 machine */ 156extern char *sstack; /* shadow stack, for string space extension */ 157extern FILE *active; /* active output file pointer */ 158extern struct input_file infile[];/* input file stack (0=stdin) */ 159extern FILE **outfile; /* diversion array(0=bitbucket) */ 160extern int maxout; /* maximum number of diversions */ 161extern int fp; /* m4 call frame pointer */ 162extern int ilevel; /* input file stack pointer */ 163extern int oindex; /* diversion index. */ 164extern int sp; /* current m4 stack pointer */ 165extern unsigned char *bp; /* first available character */ 166extern unsigned char *buf; /* push-back buffer */ 167extern unsigned char *bufbase; /* buffer base for this ilevel */ 168extern unsigned char *bbase[]; /* buffer base per ilevel */ 169extern char ecommt[MAXCCHARS+1];/* end character for comment */ 170extern char *ep; /* first free char in strspace */ 171extern char lquote[MAXCCHARS+1];/* left quote character (`) */ 172extern char **m4wraps; /* m4wrap string default. */ 173extern int maxwraps; /* size of m4wraps array */ 174extern int wrapindex; /* current index in m4wraps */ 175 176extern const char *null; /* as it says.. just a null. */ 177extern char rquote[MAXCCHARS+1];/* right quote character (') */ 178extern char scommt[MAXCCHARS+1];/* start character for comment */ 179extern int synch_lines; /* line synchronisation directives */ 180 181extern int mimic_gnu; /* behaves like gnu-m4 */ 182extern int prefix_builtins; /* prefix builtin macros with m4_ */ 183extern int error_warns; /* make warnings cause exit_code = 1 */ 184extern int fatal_warns; /* make warnings fatal */ 185