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