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