/* * Parameter file for NRO word processor * * Originally by Stephen L. Browning, 5723 North Parker Avenue * Indianapolis, Indiana 46220 * * Transformed beyond immediate recognition, and * adapted for Amiga by Olaf Seibert, KosmoSoft * * Vossendijk 149-1 (study) Beek 5 (home) * 5634 TN Nijmegen 5815 CS Merselo * The Netherlands The Netherlands * Phone: * (...-31)80561045 (...-31)4786205 * or 080-561045 04786-205 * * This program is NOT in the public domain. It may, however * be distributed only at no charge, and this notice must be * included unaltered. */ #include #undef tolower #undef toupper typedef unsigned char uchar; typedef unsigned short ushort; #define EOS (uchar) '\0' #define ESC (uchar) 0x1B #undef CPMEOF (uchar) 0x1A #define NBSP (uchar) 0xA0 #define TRUE 1 #define FALSE 0 #define OK 0 #define NOARGS 0x8000 #define MACRO 0 /* Macro definition */ #define BP 1 /* Begin page */ #define BR 2 /* Break */ #define CE 3 /* Center */ #define FI 4 /* Fill */ #define FO 5 /* Footer */ #define HE 6 /* Header */ #define IN 7 /* Indent */ #define LS 8 /* Line spacing */ #define NF 9 /* No fill */ #define PL 10 /* Page lenght */ #define RM 11 /* Right margin */ #define SP 12 /* Line space */ #define TI 13 /* Temp indent */ #define UL 14 /* Underline */ #define JU 15 /* Justify */ #define NJ 16 /* No justify */ #define M1 17 /* Top margin */ #define M2 18 /* Second top margin */ #define M3 19 /* First bottom margin */ #define M4 20 /* Bottom-most margin */ #define BS 21 /* Allow/disallow '\b' in output */ #define NE 22 /* Need n lines */ #define PC 23 /* Page number character */ #define CC 24 /* Control character */ #define PO 25 /* Page offset */ #define BO 26 /* Bold face */ #define EH 27 /* Header for even numbered pages */ #define OH 28 /* Header for odd numbered pages */ #define EF 29 /* Footer for even numbered pages */ #define OF 30 /* Footer for odd numbered pages */ #define SO 31 /* Source file */ #define CU 32 /* Continuous underline */ #define DE 33 /* Define macro */ #define EN 34 /* End macro definition */ #define NR 35 /* Set number register */ #define IT 36 /* italicize */ #define UN 37 /* Undefine a macro and all later ones */ #define PN 38 /* Page numbering - roman or arabic */ #define C2 39 /* No-break second command character */ #define COMMENT 40 /* What the name says */ #define IF 41 /* Conditional without remembering */ #define IE 42 /* Conditional with remembering */ #define EL 43 /* Else part of last remembered conditional */ #define EV 44 /* Environment switch */ #define TA 45 /* Tab settings */ #define TM 46 /* Terminal Message */ #define UNKNOWN -1 /* * MAXLINE is set to a value slightly larger * than twice the longest expected input line. * Because of the way underlining is handled, the * input line which is to be underlined, can almost * triple in length. Unlike normal underlining and * boldfacing, continuous underlining affects all * characters in the buffer, and represents the * worst case condition. If the distance between * the left margin and the right margin is greater * than about 65 characters, and continuous underlining * is in effect, there is a high probability of buffer * overflow. * On the Amiga, we can use the standard codes for * bold, underline, and even italics, and let the * printer driver worry about it. */ #define MAXLINE 300 /* Was 200 */ #define MAXWORD 50 #define MAXTAB 10 #define NOTAB ((ushort) -1) #define PAGELEN 66 #define PAGEWIDTH 80 #define HUGE 0x7FFFffff #define LEFT 0 /* Indecies into header margin limit arrays */ #define RIGHT 1 #define NFILES 4 /* Nesting depth for input files */ /* * The following parameters may be defined in bdscio.h */ #define YES 1 #define NO 0 #define ERR -1 /* * The parameter values selected for macro definitions * are somewhat arbitrary. MACBUF is the storage area * for both macro names and definitions. Since macro * processing is handled by pushing back the expansion * into the pushback buffer, the longest possible expansion * would be MXMLEN characters. * It is assumed that most macro definitions will not * exceed 20 characters, hence MXMDEF of 100. */ #define MXMDEF 512 /* Maximum no. of macro definitions */ #define MACBUF 20480 /* Macro definition buffer */ #define MXMLEN 1024 /* Maximum length of each macro pushback */ #define MNLEN 10 /* Maximum length of macro name */ struct macros { int mxmdef; /* See MXMDEF */ int macbuf; int mxmlen; uchar **mnames; /* Table of pointers to macro names */ int lastp; /* Index to last mname */ uchar *emb; /* Next char avail in macro defn buffer */ uchar *mb; /* Table of macro definitions */ uchar *ppb; /* Pointer into push back buffer */ uchar *pbb; /* Push back buffer */ uchar *pbbend; /* End of push back buffer */ }; /* Control parameters for nro */ #define NUMENV 10 #define ENVSTACK 20 struct environ { int lsval; /* Current line spacing, init = 1 */ int tival; /* Current temp indent, init = 0 */ int inval; /* Current indent, >= 0, init = 0 */ int tmval; /* Current temp right margin, init = 60 */ int rmval; /* Current right margin, init = 60 */ int ceval; /* Number of lines to center, init = 0 */ int ulval; /* Number of lines to underline, init = 0 */ int cuval; /* No. lines to continuously underline, init = 0 */ int itval; /* Number of lines to italicize, init = 0 */ int juval; /* Justify if YES, init = YES */ int boval; /* Number of lines to bold face, init = 0 */ int fill; /* Fill if YES, init = YES */ int pnflg; /* Value for page numbering, init = 0 */ short dontbrk; /* Disables line breaking, init = FALSE */ int pgchr; /* Page number character, init = '#' */ int cmdchr; /* Command character, init = '.' */ int c2chr; /* No-break cmd character, init = '\'' */ int sprdir; /* Direction for spread(), init = 0 */ short reqmode; /* Requested mode for bold underline &c */ short expmode; /* Expected mode at begin of output buffer */ short curmode; /* Current mode in output buffer */ short lastie; /* Remembered conditional */ short outp; /* Next avail char position in outbuf, init = 0 */ short outw; /* Width of text currently in buffer */ short outwds; /* Number of words in buffer, init = 0 */ uchar outbuf[MAXLINE]; /* Output of filled text */ ushort tabstop[MAXTAB]; /* Tab settings */ }; /* Global variables: */ struct docctl { /* -- These should not be pushable: -- */ int bsflg; /* Can output contain '\b', init = FALSE */ short iflvl; /* Number of @} 's to be skipped */ short flevel; /* Nesting depth for source cmd, init = 0 */ int nr[26]; /* Number registers */ short curmode; /* Current mode at end of printer */ uchar envstack[ENVSTACK]; uchar envsp; /* Current environment stack depth */ #ifdef CPM short lpr; /* Output to printer, init = FALSE */ #endif }; /* Page control parameters for nro */ struct page { int curpag; /* Current output page number, init =0 */ int newpag; /* Next output page number, init = 1 */ int lineno; /* Next line to be printed, init = 0 */ int plval; /* Page length in lines, init = 66 */ int m1val; /* Margin before and including header */ int m2val; /* Margin after header */ int m3val; /* Margin after last text line */ int m4val; /* Bottom margin, including footer */ int bottom; /* Last live line on page */ /* = plval - m3val - m4val */ int offset; /* Page offset from left, init = 0 */ int frstpg; /* First page to print, init = 0 */ int lastpg; /* Last page to print, init = 30000 */ int prflg; /* Print on or off, init = TRUE */ int ehlim[2]; /* Left/right margins for headers/footers */ int ohlim[2]; /* Init = 0 and PAGEWIDTH */ int eflim[2]; int oflim[2]; uchar ehead[MAXLINE]; /* Top of page title, init = '\n' */ uchar ohead[MAXLINE]; uchar efoot[MAXLINE]; /* Bottom of page title, init = '\n' */ uchar ofoot[MAXLINE]; }; #define BSAMIGA 0 /* Use Amiga command sequences for bold & underline */ #define BSYES 1 /* Use backspaces for bold & underline */ #define BSNO 2 /* Use carriage returns for bold & underline */ #define PNARABIC 0 /* Use Arabic way of page numbering */ #define PNLROMAN 1 /* Use lowercase Roman way of page numbering */ #define PNUROMAN 2 /* Use upperercase Roman way of page numbering */ void *malloc(); uchar *getmac(), *tabexp(); short processfx(); #ifndef CPM # define prchar(c, fp) putc(c, fp) #endif #define STRINGTYP '"' /* Command has string argument */ #define MORETXT ';' /* Command seperator */ #define ESCCHAR '@' /* The substitution escape char */ #define CMDCHAR '.' /* The default command character */ #define C2CHAR '\'' /* The default no-break cmd character */ #define PGCHAR '#' /* The default page number character */ #define BEGIF ('{'|0x8000) #define ENDIF ('}'|0x8000) #define FXPLAIN 0 /* Printer command sequences */ #define FXBO 1 #define FXIT 2 #define FXUL 4 #define NOGUARD 0x8000 /* #define putlin(string, stream) fwrite(string, strlen(string), 1, stream) fputs(string, stream); */ #ifndef CPM # define iseol(c) (c) == '\n' # define isnteol(c) (c) != '\n' #else # define iseol(c) (c) == '\n' || (c) == '\r' # define isnteol(c) (c) != '\n' && (c) != '\r' #endif #undef isspace #define isspace(c) (c) == ' ' || (c) == '\t' #define isntspace(c) (c) != ' ' && (c) != '\t'