1 /* $OpenBSD: extern.h,v 1.29 2002/02/16 21:27:48 millert 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. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the University of 22 * California, Berkeley and its contributors. 23 * 4. Neither the name of the University nor the names of its contributors 24 * may be used to endorse or promote products derived from this software 25 * without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * @(#)extern.h 8.1 (Berkeley) 6/6/93 40 * $FreeBSD: src/usr.bin/m4/extern.h,v 1.3.6.3 2002/07/15 02:06:15 jmallett Exp $ 41 */ 42 43 /* eval.c */ 44 extern void eval(const char *[], int, int); 45 extern void dodefine(const char *, const char *); 46 extern unsigned long expansion_id; 47 48 /* expr.c */ 49 extern int expr(const char *); 50 51 /* gnum4.c */ 52 extern void addtoincludepath(const char *); 53 extern struct input_file *fopen_trypath(struct input_file *, const char *); 54 extern void doindir(const char *[], int); 55 extern void dobuiltin(const char *[], int); 56 extern void dopatsubst(const char *[], int); 57 extern void doregexp(const char *[], int); 58 59 extern void doprintlineno(struct input_file *); 60 extern void doprintfilename(struct input_file *); 61 62 extern void doesyscmd(const char *); 63 64 65 /* look.c */ 66 extern ndptr addent(const char *); 67 extern unsigned hash(const char *); 68 extern ndptr lookup(const char *); 69 extern void remhash(const char *, int); 70 71 /* main.c */ 72 extern void outputstr(const char *); 73 extern int builtin_type(const char *); 74 extern const char *builtin_realname(int); 75 extern void emitline(void); 76 77 /* misc.c */ 78 extern void chrsave(int); 79 extern char *compute_prevep(void); 80 extern void getdiv(int); 81 extern ptrdiff_t indx(const char *, const char *); 82 extern void initspaces(void); 83 extern void killdiv(void); 84 extern void onintr(int); 85 extern void pbnum(int); 86 extern void pbunsigned(unsigned long); 87 extern void pbstr(const char *); 88 extern void putback(int); 89 extern void *xalloc(size_t); 90 extern char *xstrdup(const char *); 91 extern void usage(void); 92 extern void resizedivs(int); 93 extern size_t buffer_mark(void); 94 extern void dump_buffer(FILE *, size_t); 95 96 extern int obtain_char(struct input_file *); 97 extern void set_input(struct input_file *, FILE *, const char *); 98 extern void release_input(struct input_file *); 99 100 /* speeded-up versions of chrsave/putback */ 101 #define PUTBACK(c) \ 102 do { \ 103 if (bp >= endpbb) \ 104 enlarge_bufspace(); \ 105 *bp++ = (c); \ 106 } while(0) 107 108 #define CHRSAVE(c) \ 109 do { \ 110 if (ep >= endest) \ 111 enlarge_strspace(); \ 112 *ep++ = (c); \ 113 } while(0) 114 115 /* and corresponding exposure for local symbols */ 116 extern void enlarge_bufspace(void); 117 extern void enlarge_strspace(void); 118 extern char *endpbb; 119 extern char *endest; 120 121 /* trace.c */ 122 extern void mark_traced(const char *, int); 123 extern int is_traced(const char *); 124 extern void trace_file(const char *); 125 extern ssize_t trace(const char **, int, struct input_file *); 126 extern void finish_trace(size_t); 127 extern int traced_macros; 128 extern void set_trace_flags(const char *); 129 extern FILE *traceout; 130 131 extern ndptr hashtab[]; /* hash table for macros etc. */ 132 extern stae *mstack; /* stack of m4 machine */ 133 extern char *sstack; /* shadow stack, for string space extension */ 134 extern FILE *active; /* active output file pointer */ 135 extern struct input_file infile[];/* input file stack (0=stdin) */ 136 extern char *inname[]; /* names of these input files */ 137 extern int inlineno[]; /* current number in each input file */ 138 extern FILE **outfile; /* diversion array(0=bitbucket) */ 139 extern int maxout; /* maximum number of diversions */ 140 extern int fp; /* m4 call frame pointer */ 141 extern int ilevel; /* input file stack pointer */ 142 extern int oindex; /* diversion index. */ 143 extern int sp; /* current m4 stack pointer */ 144 extern char *bp; /* first available character */ 145 extern char *buf; /* push-back buffer */ 146 extern char *bufbase; /* buffer base for this ilevel */ 147 extern char *bbase[]; /* buffer base per ilevel */ 148 extern char ecommt[MAXCCHARS+1];/* end character for comment */ 149 extern char *ep; /* first free char in strspace */ 150 extern char lquote[MAXCCHARS+1];/* left quote character (`) */ 151 extern const char *m4wraps; /* m4wrap string default. */ 152 extern const char *null; /* as it says.. just a null. */ 153 extern char rquote[MAXCCHARS+1];/* right quote character (') */ 154 extern char scommt[MAXCCHARS+1];/* start character for comment */ 155 extern int synccpp; /* Line synchronisation for C preprocessor */ 156 157 extern int mimic_gnu; /* behaves like gnu-m4 */ 158 159 /* get a possibly pushed-back-character, increment lineno if need be */ 160 static __inline int gpbc(void) 161 { 162 int chscratch; /* Scratch space. */ 163 164 if (bp > bufbase) { 165 if (*--bp) 166 return ((unsigned char)*bp); 167 else 168 return (EOF); 169 } 170 chscratch = obtain_char(infile+ilevel); 171 if (chscratch == '\n') 172 ++inlineno[ilevel]; 173 return (chscratch); 174 } 175