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