[9] | 1 | /*
|
---|
| 2 | * cawf.h - definitions for cawf(1)
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | /*
|
---|
| 6 | * Copyright (c) 1991 Purdue University Research Foundation,
|
---|
| 7 | * West Lafayette, Indiana 47907. All rights reserved.
|
---|
| 8 | *
|
---|
| 9 | * Written by Victor A. Abell <abe@mace.cc.purdue.edu>, Purdue
|
---|
| 10 | * University Computing Center. Not derived from licensed software;
|
---|
| 11 | * derived from awf(1) by Henry Spencer of the University of Toronto.
|
---|
| 12 | *
|
---|
| 13 | * Permission is granted to anyone to use this software for any
|
---|
| 14 | * purpose on any computer system, and to alter it and redistribute
|
---|
| 15 | * it freely, subject to the following restrictions:
|
---|
| 16 | *
|
---|
| 17 | * 1. The author is not responsible for any consequences of use of
|
---|
| 18 | * this software, even if they arise from flaws in it.
|
---|
| 19 | *
|
---|
| 20 | * 2. The origin of this software must not be misrepresented, either
|
---|
| 21 | * by explicit claim or by omission. Credits must appear in the
|
---|
| 22 | * documentation.
|
---|
| 23 | *
|
---|
| 24 | * 3. Altered versions must be plainly marked as such, and must not
|
---|
| 25 | * be misrepresented as being the original software. Credits must
|
---|
| 26 | * appear in the documentation.
|
---|
| 27 | *
|
---|
| 28 | * 4. This notice may not be removed or altered.
|
---|
| 29 | */
|
---|
| 30 |
|
---|
| 31 | #include <stdio.h>
|
---|
| 32 | #ifdef UNIX
|
---|
| 33 | #include <sys/types.h>
|
---|
| 34 | #else
|
---|
| 35 | #include <sys\types.h>
|
---|
| 36 | #endif
|
---|
| 37 | #include "regexp.h"
|
---|
| 38 | #include "cawflib.h"
|
---|
| 39 | #include "proto.h"
|
---|
| 40 |
|
---|
| 41 | #define DEVCONFIG "device.cf" /* device configuration file */
|
---|
| 42 | #define ESC '\033' /* ESCape character */
|
---|
| 43 | #define MAXEXP 30 /* maximum expressions
|
---|
| 44 | * (and TABs) */
|
---|
| 45 | #define MAXFSTK 5 /* maximum file stack
|
---|
| 46 | * (for .so) */
|
---|
| 47 | #define MAXHYCH 10 /* maximum hyphen characters */
|
---|
| 48 | #define MAXLINE 512 /* maximum line length */
|
---|
| 49 | #define MAXMACRO 100 /* maximum number of macros */
|
---|
| 50 | #define MAXMTXT 1024 /* maximum macro text lines */
|
---|
| 51 | #define MAXNHNR 10 /* maximum ".NH" numbers
|
---|
| 52 | * (but 0 not used) */
|
---|
| 53 | #define MAXNR 50 /* maximum number reg */
|
---|
| 54 | #define MAXOLL 512 /* maximum output line length */
|
---|
| 55 | #define MAXSCH 256 /* maximum special characters */
|
---|
| 56 | #define MAXSP 25 /* maximum stack pointer (for
|
---|
| 57 | * nesting of macro calls) */
|
---|
| 58 | #define MAXSTR 100 /* maximum ".ds" strings */
|
---|
| 59 |
|
---|
| 60 | /*
|
---|
| 61 | * Output line adjustment modes
|
---|
| 62 | */
|
---|
| 63 |
|
---|
| 64 | #define LEFTADJ 0
|
---|
| 65 | #define RIGHTADJ 1
|
---|
| 66 | #define BOTHADJ 2
|
---|
| 67 |
|
---|
| 68 | /*
|
---|
| 69 | * Error handling codes
|
---|
| 70 | */
|
---|
| 71 |
|
---|
| 72 | #define FATAL 0 /* fatal error */
|
---|
| 73 | #define LINE 0 /* display line */
|
---|
| 74 | #define NOLINE 1 /* don't display line */
|
---|
| 75 | #define WARN 1 /* warning error */
|
---|
| 76 |
|
---|
| 77 | /*
|
---|
| 78 | * Padding directions
|
---|
| 79 | */
|
---|
| 80 |
|
---|
| 81 | #define PADLEFT 0 /* pad from left */
|
---|
| 82 | #define PADRIGHT 1 /* pad from right */
|
---|
| 83 |
|
---|
| 84 | /*
|
---|
| 85 | * Pass 3 signal codes
|
---|
| 86 | */
|
---|
| 87 |
|
---|
| 88 | #define NOBREAK -1
|
---|
| 89 | #define DOBREAK -2
|
---|
| 90 | #define MESSAGE -3
|
---|
| 91 |
|
---|
| 92 | /*
|
---|
| 93 | * Macro argument types
|
---|
| 94 | */
|
---|
| 95 |
|
---|
| 96 | #define MANMACROS 1 /* -man */
|
---|
| 97 | #define MSMACROS 2 /* -ms */
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 | struct fcode {
|
---|
| 101 | unsigned char nm; /* font name character */
|
---|
| 102 | unsigned char status; /* status */
|
---|
| 103 | };
|
---|
| 104 |
|
---|
| 105 | struct fontstr { /* font control strings */
|
---|
| 106 |
|
---|
| 107 | unsigned char *i; /* font initialization string */
|
---|
| 108 | int il; /* length of *i */
|
---|
| 109 | unsigned char *b; /* bold */
|
---|
| 110 | int bl; /* length of *bb */
|
---|
| 111 | unsigned char *it; /* italic */
|
---|
| 112 | int itl; /* length of *itb */
|
---|
| 113 | unsigned char *r; /* roman string */
|
---|
| 114 | int rl; /* length of *r */
|
---|
| 115 | };
|
---|
| 116 |
|
---|
| 117 | struct hytab {
|
---|
| 118 | unsigned char font; /* font name character */
|
---|
| 119 | int len; /* effective length */
|
---|
| 120 | unsigned char *str; /* value string */
|
---|
| 121 | };
|
---|
| 122 |
|
---|
| 123 | struct macro {
|
---|
| 124 | unsigned char name[2]; /* macro name */
|
---|
| 125 | int bx; /* beginning Macrotxt[] index */
|
---|
| 126 | int ct; /* index count */
|
---|
| 127 | };
|
---|
| 128 |
|
---|
| 129 | struct nbr {
|
---|
| 130 | unsigned char nm[2]; /* register name */
|
---|
| 131 | int val; /* value */
|
---|
| 132 | };
|
---|
| 133 |
|
---|
| 134 | struct parms {
|
---|
| 135 | char nm[2]; /* parameter name */
|
---|
| 136 | char *cmd; /* pass 3 command */
|
---|
| 137 | int val; /* current value */
|
---|
| 138 | int prev; /* previous value */
|
---|
| 139 | };
|
---|
| 140 |
|
---|
| 141 | struct rx {
|
---|
| 142 | char *re; /* regular expression */
|
---|
| 143 | struct regexp *pat; /* compiled pattern */
|
---|
| 144 | };
|
---|
| 145 |
|
---|
| 146 | struct scale {
|
---|
| 147 | unsigned char nm; /* scale factor name */
|
---|
| 148 | double val; /* value */
|
---|
| 149 | };
|
---|
| 150 |
|
---|
| 151 | struct schtab {
|
---|
| 152 | unsigned char nm[2]; /* character name */
|
---|
| 153 | int len; /* effective length */
|
---|
| 154 | unsigned char *str; /* value string */
|
---|
| 155 | };
|
---|
| 156 |
|
---|
| 157 | struct str {
|
---|
| 158 | unsigned char nm[2]; /* string name */
|
---|
| 159 | unsigned char *str; /* string value */
|
---|
| 160 | };
|
---|
| 161 |
|
---|
| 162 | extern int Adj; /* output line adjustment mode */
|
---|
| 163 | extern unsigned char *Aftnxt; /* action after next line */
|
---|
| 164 | extern unsigned char *Args[]; /* macro arguments */
|
---|
| 165 | extern unsigned char *Argstack[]; /* stack for Expand()'s "args[]" */
|
---|
| 166 | extern int Backc; /* last word ended with '\\c' */
|
---|
| 167 | extern int Botmarg; /* bottom margin */
|
---|
| 168 | extern int Centering; /* centering count */
|
---|
| 169 | extern int Condstack[]; /* stack for Expand()'s "cond" */
|
---|
| 170 | extern unsigned char *Cont; /* continue line append */
|
---|
| 171 | extern int Contlen; /* continue line append length */
|
---|
| 172 | extern int Curmx; /* current macro name */
|
---|
| 173 | extern char *Device; /* output device name */
|
---|
| 174 | extern char *Devconf; /* device configuration file path */
|
---|
| 175 | extern char *Devfont; /* output device font */
|
---|
| 176 | extern int Divert; /* diversion status */
|
---|
| 177 | extern FILE *Efs; /* error file stream pointer */
|
---|
| 178 | extern unsigned char *Eol; /* end of line information */
|
---|
| 179 | extern int Eollen; /* end of line length */
|
---|
| 180 | extern int Err; /* error flag */
|
---|
| 181 | extern unsigned char *F; /* field value */
|
---|
| 182 | extern struct fcode Fcode[]; /* font codes */
|
---|
| 183 | extern int Fill; /* fill status */
|
---|
| 184 | extern unsigned char Font[]; /* current font */
|
---|
| 185 | extern int Fontctl; /* output font control */
|
---|
| 186 | extern char Fontstat; /* output font status */
|
---|
| 187 | extern int Fph; /* first page header status */
|
---|
| 188 | extern int Fsp; /* files stack pointer (for .so) */
|
---|
| 189 | extern struct fontstr Fstr; /* font control strings */
|
---|
| 190 | extern unsigned char *Ftc; /* center footer */
|
---|
| 191 | extern unsigned char *Ftl; /* left footer */
|
---|
| 192 | extern unsigned char *Ftr; /* right footer */
|
---|
| 193 | extern unsigned char *Hdc; /* center header */
|
---|
| 194 | extern int Hdft; /* header/footer status */
|
---|
| 195 | extern unsigned char *Hdl; /* left header */
|
---|
| 196 | extern unsigned char *Hdr; /* right header */
|
---|
| 197 | extern FILE *Ifs; /* input file stream */
|
---|
| 198 | extern FILE *Ifs_stk[]; /* Ifs stack */
|
---|
| 199 | extern int Ind; /* indentation amount */
|
---|
| 200 | extern unsigned char *Inname; /* input file name */
|
---|
| 201 | extern unsigned char *Inn_stk[]; /* Inname stack */
|
---|
| 202 | extern struct hytab Hychar[]; /* hyphen characters */
|
---|
| 203 | extern int LL; /* line length */
|
---|
| 204 | extern unsigned char Line[]; /* input line */
|
---|
| 205 | extern int Lockil; /* pass 2 line number is locked
|
---|
| 206 | * (processing is inside macro) */
|
---|
| 207 | extern int Marg; /* macro argument - man, ms, etc. */
|
---|
| 208 | extern struct macro Macrotab[]; /* macro table */
|
---|
| 209 | extern int Macrostack[]; /* stack for Expand()'s "macro" */
|
---|
| 210 | extern unsigned char *Macrotxt[]; /* macro text */
|
---|
| 211 | extern int Mtx; /* macro text index */
|
---|
| 212 | extern int Mxstack[]; /* stack for Expand()'s "mx" */
|
---|
| 213 | extern int Nhnr[]; /* ".NH" numbers */
|
---|
| 214 | extern int Nhy; /* number of Hychar[] entries */
|
---|
| 215 | extern int Nleftstack[]; /* stack for Expand()'s "nleft" */
|
---|
| 216 | extern int Nmac; /* number of macros */
|
---|
| 217 | extern int Nnr; /* number of Numb[] entries */
|
---|
| 218 | extern int Nospmode; /* no space mode */
|
---|
| 219 | extern int Nparms; /* number of Parms[] entries */
|
---|
| 220 | extern int NR; /* number of record, ala awk */
|
---|
| 221 | extern int NR_stk[]; /* NR stack */
|
---|
| 222 | extern int Nsch; /* number of Schar[] entries */
|
---|
| 223 | extern int Nstr; /* number of entries in Str[] */
|
---|
| 224 | extern int Ntabs; /* number of TAB positions */
|
---|
| 225 | extern struct nbr Numb[]; /* number registers */
|
---|
| 226 | extern int Nxtln; /* next line number */
|
---|
| 227 | extern char *optarg; /* getopt(3) argument pointer */
|
---|
| 228 | extern int optind; /* getopt(3) index */
|
---|
| 229 | extern int Outll; /* output line length */
|
---|
| 230 | extern unsigned char Outln[]; /* output line */
|
---|
| 231 | extern int Outlx; /* output line index */
|
---|
| 232 | extern int P2il; /* pass 2 input line number */
|
---|
| 233 | extern unsigned char *P2name; /* pass 2 input file name */
|
---|
| 234 | extern int P3fill; /* pass 3 fill status */
|
---|
| 235 | extern int Padchar[]; /* padding character locations */
|
---|
| 236 | extern int Padfrom; /* which end to pad from */
|
---|
| 237 | extern int Padx; /* Padchar[] index */
|
---|
| 238 | extern struct parms Parms[]; /* parameter registers */
|
---|
| 239 | extern unsigned char Pass1ln[]; /* pass 1 output line */
|
---|
| 240 | extern unsigned char Pass2ln[]; /* pass 2 output line */
|
---|
| 241 | extern struct rx Pat[]; /* compiled regexp patterns */
|
---|
| 242 | extern int Pglen; /* page length */
|
---|
| 243 | extern int Pgoff; /* page offset */
|
---|
| 244 | extern char *Pname; /* program name */
|
---|
| 245 | extern unsigned char Prevfont; /* previous font */
|
---|
| 246 | extern int Ptrstack[]; /* stack for Expand()'s "ptr" */
|
---|
| 247 | extern struct scale Scale[]; /* scaling factors */
|
---|
| 248 | extern double Scalen; /* 'n' scaling factor */
|
---|
| 249 | extern double Scaleu; /* 'u' scaling factor */
|
---|
| 250 | extern double Scalev; /* 'v' scaling factor */
|
---|
| 251 | extern struct schtab Schar[]; /* special characters */
|
---|
| 252 | extern int Sp; /* stack pointer */
|
---|
| 253 | extern struct str Str[]; /* ".ds" strings */
|
---|
| 254 | extern int Sx; /* string index */
|
---|
| 255 | extern int Tabs[]; /* TAB positions */
|
---|
| 256 | extern int Thispg; /* this page number */
|
---|
| 257 | extern int Tind; /* temporary indentation amount */
|
---|
| 258 | extern int Topmarg; /* top margin */
|
---|
| 259 | extern unsigned char *Trtbl; /* .tr table */
|
---|
| 260 | extern int Uhyph; /* hyphen usage state */
|
---|
| 261 | extern int Vspace; /* vertical (inter-text-line) spacing */
|
---|
| 262 | extern unsigned char Word[]; /* pass 2 word buffer */
|
---|
| 263 | extern int Wordl; /* effective length of Word[] */
|
---|
| 264 | extern int Wordx; /* Word[] index */
|
---|
| 265 | extern int Dowarn; /* Enables warnings when true */
|
---|