home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d197 / nro.lha / Nro / nro.h < prev    next >
C/C++ Source or Header  |  1989-03-28  |  11KB  |  287 lines

  1.  
  2. /*
  3.  *    Parameter file for NRO word processor
  4.  *
  5.  *    Originally by Stephen L. Browning, 5723 North Parker Avenue
  6.  *    Indianapolis, Indiana 46220
  7.  *
  8.  *    Transformed beyond immediate recognition, and
  9.  *    adapted for Amiga by Olaf Seibert, KosmoSoft
  10.  *
  11.  *    Vossendijk 149-1 (study)   Beek 5 (home)
  12.  *    5634 TN  Nijmegen          5815 CS  Merselo
  13.  *    The Netherlands            The Netherlands
  14.  *    Phone:
  15.  *           (...-31)80561045     (...-31)4786205
  16.  *        or 080-561045           04786-205
  17.  *
  18.  *    This program is NOT in the public domain. It may, however
  19.  *    be distributed only at no charge, and this notice must be
  20.  *    included unaltered.
  21.  */
  22.  
  23.  
  24. #include <ctype.h>
  25. #undef tolower
  26. #undef toupper
  27.  
  28. typedef unsigned char uchar;
  29. typedef unsigned short ushort;
  30.  
  31. #define EOS    (uchar) '\0'
  32. #define ESC    (uchar) 0x1B
  33. #undef  CPMEOF    (uchar) 0x1A
  34. #define NBSP    (uchar) 0xA0
  35.  
  36. #define TRUE    1
  37. #define FALSE    0
  38. #define OK    0
  39.  
  40. #define NOARGS    0x8000
  41.  
  42. #define MACRO     0      /* Macro definition */
  43. #define BP     1      /* Begin page   */
  44. #define BR     2      /* Break        */
  45. #define CE     3      /* Center       */
  46. #define FI     4      /* Fill         */
  47. #define FO     5      /* Footer       */
  48. #define HE     6      /* Header       */
  49. #define IN     7      /* Indent       */
  50. #define LS     8      /* Line spacing */
  51. #define NF     9      /* No fill      */
  52. #define PL    10      /* Page lenght  */
  53. #define RM    11      /* Right margin */
  54. #define SP    12      /* Line space   */
  55. #define TI    13      /* Temp indent  */
  56. #define UL    14      /* Underline    */
  57. #define JU    15      /* Justify      */
  58. #define NJ    16      /* No justify   */
  59. #define M1    17      /* Top margin   */
  60. #define M2    18      /* Second top margin    */
  61. #define M3    19      /* First bottom margin  */
  62. #define M4    20      /* Bottom-most margin   */
  63. #define BS    21      /* Allow/disallow '\b' in output */
  64. #define NE    22      /* Need n lines */
  65. #define PC    23      /* Page number character */
  66. #define CC    24      /* Control character    */
  67. #define PO    25      /* Page offset  */
  68. #define BO    26      /* Bold face    */
  69. #define EH    27      /* Header for even numbered pages       */
  70. #define OH    28      /* Header for odd numbered pages        */
  71. #define EF    29      /* Footer for even numbered pages       */
  72. #define OF    30      /* Footer for odd numbered pages        */
  73. #define SO    31      /* Source file  */
  74. #define CU    32      /* Continuous underline */
  75. #define DE    33      /* Define macro */
  76. #define EN    34      /* End macro definition */
  77. #define NR    35      /* Set number register  */
  78. #define IT    36    /* italicize    */
  79. #define UN    37    /* Undefine a macro and all later ones */
  80. #define PN    38    /* Page numbering - roman or arabic */
  81. #define C2    39    /* No-break second command character */
  82. #define COMMENT    40    /* What the name says */
  83. #define IF    41    /* Conditional without remembering */
  84. #define IE    42    /* Conditional with remembering */
  85. #define EL    43    /* Else part of last remembered conditional */
  86. #define EV    44    /* Environment switch */
  87. #define TA    45    /* Tab settings */
  88. #define TM    46    /* Terminal Message */
  89.  
  90.  
  91. #define UNKNOWN -1
  92.  
  93. /*
  94.  *      MAXLINE is set to a value slightly larger
  95.  *      than twice the longest expected input line.
  96.  *      Because of the way underlining is handled, the
  97.  *      input line which is to be underlined, can almost
  98.  *      triple in length.  Unlike normal underlining and
  99.  *      boldfacing, continuous underlining affects all
  100.  *      characters in the buffer, and represents the
  101.  *      worst case condition.  If the distance between
  102.  *      the left margin and the right margin is greater
  103.  *      than about 65 characters, and continuous underlining
  104.  *      is in effect, there is a high probability of buffer
  105.  *      overflow.
  106.  *    On the Amiga, we can use the standard codes for 
  107.  *    bold, underline, and even italics, and let the
  108.  *    printer driver worry about it.
  109.  */
  110.  
  111. #define MAXLINE        300    /* Was 200 */
  112. #define MAXWORD        50
  113. #define MAXTAB        10
  114. #define NOTAB        ((ushort) -1)
  115. #define PAGELEN        66
  116. #define PAGEWIDTH    80
  117. #define HUGE        0x7FFFffff
  118. #define LEFT        0    /* Indecies into header margin limit arrays */
  119. #define RIGHT        1
  120. #define NFILES        4    /* Nesting depth for input files */
  121.  
  122. /*
  123.  *      The following parameters may be defined in bdscio.h
  124.  */
  125.  
  126. #define YES     1
  127. #define NO      0
  128. #define ERR     -1
  129.  
  130. /*
  131.  *      The parameter values selected for macro definitions
  132.  *      are somewhat arbitrary.  MACBUF is the storage area
  133.  *      for both macro names and definitions.  Since macro
  134.  *      processing is handled by pushing back the expansion
  135.  *      into the pushback buffer, the longest possible expansion
  136.  *      would be MXMLEN characters.
  137.  *      It is assumed that most macro definitions will not
  138.  *      exceed 20 characters, hence MXMDEF of 100.
  139.  */
  140.  
  141. #define MXMDEF  512             /* Maximum no. of macro definitions */
  142. #define MACBUF  20480           /* Macro definition buffer */
  143. #define MXMLEN  1024            /* Maximum length of each macro pushback */
  144. #define MNLEN   10              /* Maximum length of macro name */
  145.  
  146. struct macros {
  147.     int   mxmdef;        /* See MXMDEF */
  148.     int   macbuf;
  149.     int   mxmlen;
  150.         uchar **mnames;        /* Table of pointers to macro names */
  151.         int   lastp;        /* Index to last mname  */
  152.         uchar *emb;        /* Next char avail in macro defn buffer */
  153.         uchar *mb;        /* Table of macro definitions */
  154.         uchar *ppb;        /* Pointer into push back buffer */
  155.         uchar *pbb;        /* Push back buffer */
  156.         uchar *pbbend;    /* End of push back buffer */
  157. };
  158.  
  159.  
  160. /* Control parameters for nro */
  161.  
  162. #define NUMENV        10
  163. #define ENVSTACK    20
  164.  
  165. struct environ {
  166.         int   lsval;    /* Current line spacing, init = 1       */
  167.         int   tival;    /* Current temp indent, init = 0        */
  168.         int   inval;    /* Current indent, >= 0, init = 0       */
  169.         int   tmval;    /* Current temp right margin, init = 60 */
  170.         int   rmval;    /* Current right margin, init = 60      */
  171.         int   ceval;    /* Number of lines to center, init = 0  */
  172.         int   ulval;    /* Number of lines to underline, init = 0 */
  173.         int   cuval;    /* No. lines to continuously underline, init = 0 */
  174.     int   itval;    /* Number of lines to italicize, init = 0 */
  175.         int   juval;    /* Justify if YES, init = YES           */
  176.         int   boval;    /* Number of lines to bold face, init = 0 */
  177.  
  178.         int   fill;    /* Fill if YES, init = YES              */
  179.     int   pnflg;    /* Value for page numbering, init = 0   */
  180.     short dontbrk;    /* Disables line breaking, init = FALSE */
  181.  
  182.         int   pgchr;    /* Page number character, init = '#'    */
  183.         int   cmdchr;    /* Command character, init = '.'        */
  184.         int   c2chr;    /* No-break cmd character, init = '\''  */
  185.         int   sprdir;    /* Direction for spread(), init = 0     */
  186.  
  187.     short reqmode;    /* Requested mode for bold underline &c */
  188.     short expmode;    /* Expected mode at begin of output buffer */
  189.     short curmode;    /* Current mode in output buffer        */
  190.  
  191.     short lastie;    /* Remembered conditional               */
  192.  
  193.         short outp;    /* Next avail char position in outbuf, init = 0 */
  194.         short outw;    /* Width of text currently in buffer    */
  195.         short outwds;    /* Number of words in buffer, init = 0  */
  196.         uchar outbuf[MAXLINE];    /* Output of filled text        */
  197.     ushort tabstop[MAXTAB]; /* Tab settings                 */
  198. };
  199.  
  200. /* Global variables: */
  201.  
  202. struct docctl {        /* -- These should not be pushable: --  */
  203.         int   bsflg;    /* Can output contain '\b', init = FALSE */
  204.     short iflvl;    /* Number of @} 's to be skipped        */
  205.         short flevel;    /* Nesting depth for source cmd, init = 0 */
  206.         int   nr[26];    /* Number registers                     */
  207.     short curmode;    /* Current mode at end of printer       */
  208.     uchar envstack[ENVSTACK];
  209.     uchar envsp;    /* Current environment stack depth      */
  210. #ifdef CPM
  211.         short lpr;    /* Output to printer, init = FALSE      */
  212. #endif
  213. };
  214.  
  215.  
  216. /* Page control parameters for nro */
  217.  
  218. struct page {
  219.         int   curpag;    /* Current output page number, init =0  */
  220.         int   newpag;    /* Next output page number, init = 1    */
  221.         int   lineno;    /* Next line to be printed, init = 0    */
  222.         int   plval;    /* Page length in lines, init = 66      */
  223.         int   m1val;    /* Margin before and including header   */
  224.         int   m2val;    /* Margin after header                  */
  225.         int   m3val;    /* Margin after last text line          */
  226.         int   m4val;    /* Bottom margin, including footer      */
  227.         int   bottom;    /* Last live line on page               */
  228.             /*   = plval - m3val - m4val            */
  229.         int   offset;    /* Page offset from left, init = 0      */
  230.         int   frstpg;    /* First page to print, init = 0        */
  231.         int   lastpg;    /* Last page to print, init = 30000     */
  232.         int   prflg;    /* Print on or off, init = TRUE         */
  233.         int   ehlim[2];    /* Left/right margins for headers/footers     */
  234.         int   ohlim[2];    /* Init = 0 and PAGEWIDTH                     */
  235.         int   eflim[2];
  236.         int   oflim[2];
  237.         uchar ehead[MAXLINE];    /* Top of page title, init = '\n'     */
  238.         uchar ohead[MAXLINE];
  239.         uchar efoot[MAXLINE];    /* Bottom of page title, init = '\n'  */
  240.         uchar ofoot[MAXLINE];
  241. };
  242.  
  243. #define BSAMIGA   0  /* Use Amiga command sequences for bold & underline */
  244. #define BSYES     1  /* Use backspaces for bold & underline         */
  245. #define BSNO      2  /* Use carriage returns for bold & underline   */
  246.  
  247. #define PNARABIC  0  /* Use Arabic way of page numbering            */
  248. #define PNLROMAN  1  /* Use lowercase Roman way of page numbering   */
  249. #define PNUROMAN  2  /* Use upperercase Roman way of page numbering */
  250.  
  251. void *malloc();
  252. uchar *getmac(), *tabexp();
  253. short processfx();
  254.  
  255. #ifndef CPM
  256. # define prchar(c, fp)    putc(c, fp)
  257. #endif
  258.  
  259. #define STRINGTYP    '"'    /* Command has string argument          */
  260. #define MORETXT        ';'    /* Command seperator                    */
  261. #define ESCCHAR        '@'    /* The substitution escape char         */
  262. #define CMDCHAR        '.'    /* The default command character        */
  263. #define C2CHAR        '\''    /* The default no-break cmd character   */
  264. #define PGCHAR        '#'    /* The default page number character    */
  265.  
  266. #define BEGIF        ('{'|0x8000)
  267. #define ENDIF        ('}'|0x8000)
  268.  
  269. #define FXPLAIN        0    /* Printer command sequences */
  270. #define FXBO        1
  271. #define FXIT        2
  272. #define FXUL        4
  273.  
  274. #define NOGUARD        0x8000
  275.  
  276. /* #define putlin(string, stream)    fwrite(string, strlen(string), 1, stream) fputs(string, stream); */
  277. #ifndef CPM
  278. #  define iseol(c)    (c) == '\n'
  279. #  define isnteol(c)    (c) != '\n'
  280. #else
  281. #  define iseol(c)    (c) == '\n' || (c) == '\r'
  282. #  define isnteol(c)    (c) != '\n' && (c) != '\r'
  283. #endif
  284. #undef isspace
  285. #define isspace(c)    (c) == ' ' || (c) == '\t'
  286. #define isntspace(c)    (c) != ' ' && (c) != '\t'
  287.