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 * $DragonFly: src/usr.bin/m4/extern.h,v 1.2 2003/06/17 04:29:28 dillon Exp $ 42 */ 43 44 /* eval.c */ 45 extern void eval(const char *[], int, int); 46 extern void dodefine(const char *, const char *); 47 extern unsigned long expansion_id; 48 49 /* expr.c */ 50 extern int expr(const char *); 51 52 /* gnum4.c */ 53 extern void addtoincludepath(const char *); 54 extern struct input_file *fopen_trypath(struct input_file *, const char *); 55 extern void doindir(const char *[], int); 56 extern void dobuiltin(const char *[], int); 57 extern void dopatsubst(const char *[], int); 58 extern void doregexp(const char *[], int); 59 60 extern void doprintlineno(struct input_file *); 61 extern void doprintfilename(struct input_file *); 62 63 extern void doesyscmd(const char *); 64 65 66 /* look.c */ 67 extern ndptr addent(const char *); 68 extern unsigned hash(const char *); 69 extern ndptr lookup(const char *); 70 extern void remhash(const char *, int); 71 72 /* main.c */ 73 extern void outputstr(const char *); 74 extern int builtin_type(const char *); 75 extern const char *builtin_realname(int); 76 extern void emitline(void); 77 78 /* misc.c */ 79 extern void chrsave(int); 80 extern char *compute_prevep(void); 81 extern void getdiv(int); 82 extern ptrdiff_t indx(const char *, const char *); 83 extern void initspaces(void); 84 extern void killdiv(void); 85 extern void onintr(int); 86 extern void pbnum(int); 87 extern void pbunsigned(unsigned long); 88 extern void pbstr(const char *); 89 extern void putback(int); 90 extern void *xalloc(size_t); 91 extern char *xstrdup(const char *); 92 extern void usage(void); 93 extern void resizedivs(int); 94 extern size_t buffer_mark(void); 95 extern void dump_buffer(FILE *, size_t); 96 97 extern int obtain_char(struct input_file *); 98 extern void set_input(struct input_file *, FILE *, const char *); 99 extern void release_input(struct input_file *); 100 101 /* speeded-up versions of chrsave/putback */ 102 #define PUTBACK(c) \ 103 do { \ 104 if (bp >= endpbb) \ 105 enlarge_bufspace(); \ 106 *bp++ = (c); \ 107 } while(0) 108 109 #define CHRSAVE(c) \ 110 do { \ 111 if (ep >= endest) \ 112 enlarge_strspace(); \ 113 *ep++ = (c); \ 114 } while(0) 115 116 /* and corresponding exposure for local symbols */ 117 extern void enlarge_bufspace(void); 118 extern void enlarge_strspace(void); 119 extern char *endpbb; 120 extern char *endest; 121 122 /* trace.c */ 123 extern void mark_traced(const char *, int); 124 extern int is_traced(const char *); 125 extern void trace_file(const char *); 126 extern ssize_t trace(const char **, int, struct input_file *); 127 extern void finish_trace(size_t); 128 extern int traced_macros; 129 extern void set_trace_flags(const char *); 130 extern FILE *traceout; 131 132 extern ndptr hashtab[]; /* hash table for macros etc. */ 133 extern stae *mstack; /* stack of m4 machine */ 134 extern char *sstack; /* shadow stack, for string space extension */ 135 extern FILE *active; /* active output file pointer */ 136 extern struct input_file infile[];/* input file stack (0=stdin) */ 137 extern char *inname[]; /* names of these input files */ 138 extern int inlineno[]; /* current number in each input file */ 139 extern FILE **outfile; /* diversion array(0=bitbucket) */ 140 extern int maxout; /* maximum number of diversions */ 141 extern int fp; /* m4 call frame pointer */ 142 extern int ilevel; /* input file stack pointer */ 143 extern int oindex; /* diversion index. */ 144 extern int sp; /* current m4 stack pointer */ 145 extern char *bp; /* first available character */ 146 extern char *buf; /* push-back buffer */ 147 extern char *bufbase; /* buffer base for this ilevel */ 148 extern char *bbase[]; /* buffer base per ilevel */ 149 extern char ecommt[MAXCCHARS+1];/* end character for comment */ 150 extern char *ep; /* first free char in strspace */ 151 extern char lquote[MAXCCHARS+1];/* left quote character (`) */ 152 extern const char *m4wraps; /* m4wrap string default. */ 153 extern const char *null; /* as it says.. just a null. */ 154 extern char rquote[MAXCCHARS+1];/* right quote character (') */ 155 extern char scommt[MAXCCHARS+1];/* start character for comment */ 156 extern int synccpp; /* Line synchronisation for C preprocessor */ 157 158 extern int mimic_gnu; /* behaves like gnu-m4 */ 159 160 /* get a possibly pushed-back-character, increment lineno if need be */ 161 static __inline int gpbc(void) 162 { 163 int chscratch; /* Scratch space. */ 164 165 if (bp > bufbase) { 166 if (*--bp) 167 return ((unsigned char)*bp); 168 else 169 return (EOF); 170 } 171 chscratch = obtain_char(infile+ilevel); 172 if (chscratch == '\n') 173 ++inlineno[ilevel]; 174 return (chscratch); 175 } 176