home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / fileutil / cawf / store.c < prev    next >
Text File  |  1991-04-26  |  8KB  |  173 lines

  1. /*
  2.  *    store.c - cawf(1) storage areas
  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 "cawf.h"
  32.  
  33. struct rx Pat[] = {
  34.     { "^\\.(i[ef]|el)",                 NULL},    /* 0 */
  35.     { "^\\.i[ef] !",                                NULL},  /* 1 */
  36.     { "^\\.i[ef] !?\\\\n\\(\\.\\$[<=>][0-9] ",    NULL},    /* 2 */
  37.     { "^\\.i[ef] !?'\\\\\\$[0-9]'[^']*' ",        NULL},    /* 3 */
  38.     { "^\\.i[ef] !?[nt] ",                          NULL},  /* 4 */
  39.     { "\\\\\\$[0-9]",                               NULL},  /* 5 */
  40.     { "^[ \t]*$",                    NULL},  /* 6 */
  41.     { "\\\\|\t|-|  ",                NULL},    /* 7 */
  42.     { "[.!?:][]\\)'\\\"\\*]*$",                     NULL},  /* 8 */
  43.     { ",fP",                    NULL},    /* 9 */
  44.     { ",tP",                    NULL},    /* 10 */
  45.     { "^(ta|ll|ls|in|ti|po|ne|sp|pl|nr)",           NULL},  /* 11 */
  46.     { "^(ll|ls|in|ti|po|pl)",                       NULL},  /* 12 */
  47.     { "[]\\)'\\\"\\*]",                             NULL},  /* 13 */
  48.     { "^(LH|CH|RH|LF|CF|RF)",            NULL},    /* 14 */
  49.     { "^\\.i[ef]",                     NULL},    /* 15 */
  50.     { NULL,                                         NULL}   /* END */
  51. };
  52.  
  53. int Adj = BOTHADJ;            /* output line adjustment mode */
  54. char *Aftnxt = NULL;                    /* action after next line */
  55. char *Args[] = {NULL, NULL,        /* 10 macro arguments */
  56.         NULL, NULL,
  57.         NULL, NULL,
  58.         NULL, NULL,
  59.         NULL, NULL};
  60. char *Argstack[10*MAXSP];               /* stack for Expand()'s "args[]" */
  61. int Backc = 0;                /* last word ended with '\\c' */
  62. int Botmarg = 5;            /* bottom margin */
  63. int Centering = 0;            /* centering count */
  64. int Condstack[MAXSP];                   /* stack for Expand()'s "cond" */
  65. char *Cont = NULL;            /* continue line append */
  66. int Contlen = 0;            /* continue line append length */
  67. int Curmx = -1;                /* current macro index */
  68. FILE *Efs = NULL;            /* error file stream */
  69. char *Eol = NULL;            /* end of line information */
  70. int Eollen = 0;                /* end of line length */
  71. int Err = 0;                            /* error flag */
  72. char *F = NULL;                         /* field value */
  73. struct fcode Fcode[] = {        /* font codes */
  74.     { 'B',  '\0'},            /* Bold */
  75.     { 'I',  '\0'},            /* Italic */
  76.     { 'R',  '\0'},            /* Roman */
  77.     { '\0', '\0'}
  78. };
  79. int Fill = 0;                /* fill status */
  80. char Font[] = { '\0', '\0' };        /* current font */
  81. int Fph = 0;                /* first page header status */
  82. int Fsp = 0;                /* files stack pointer (for .so) */
  83. char *Ftc = NULL;            /* center footer */
  84. char *Ftl = NULL;            /* left footer */
  85. char *Ftr = NULL;            /* right footer */
  86. char *Hdc = NULL;            /* center header */
  87. int Hdft = 0;                /* header/footer status */
  88. char *Hdl = NULL;            /* left header */
  89. char *Hdr = NULL;            /* right header */
  90. struct hytab Hychar[MAXHYCH];        /* hyphen characters */
  91. FILE *Ifs = NULL;            /* input file stream */
  92. FILE *Ifs_stk[MAXFSTK];                 /* Ifs stack */
  93. int Ind = 0;                /* indentation amount */
  94. char *Inname = NULL;                    /* input file name */
  95. char *Inn_stk[MAXFSTK];                 /* Inname stack */
  96. int LL = 78;                /* line length (default) */
  97. char Line[MAXLINE];                 /* input line */
  98. int Lockil = 0;                          /* pass 2 line number is locked
  99.                                          * (processing is inside macro) */
  100. int Marg = 0;                /* macro argument - man, ms, etc. */
  101. struct macro Macrotab[MAXMACRO];        /* macro table */
  102. char *Macrotxt[MAXMTXT];                /* macro text */
  103. int Mtx = 0;                            /* macro text index */
  104. int Mxstack[MAXSP];                     /* stack for Expand()'s "mx" */
  105. int Nfc;                /* number of font codes */
  106. int Nhnr[MAXNHNR];                      /* ".NH" numbers */
  107. int Nhy = 0;                /* number of Hychar[] entries */
  108. int Nleftstack[MAXSP];                  /* stack for Expand()'s "nleft" */
  109. int Nmac = 0;                           /* number of macros */
  110. int Nnr = 0;                /* number of Numb[] entries */
  111. int Nospmode = 1;                        /* no space mode */
  112. int Nparms = 0;                /* number of Parms[] entries */
  113. int NR = 0;                             /* number of record ala awk */
  114. int NR_stk[MAXFSTK];                       /* NR stack */
  115. int Nsch = 0;                /* number of Schar[] entries */
  116. int Nstr = 0;                /* number of entries in Str[] */
  117. int Ntabs = 0;                /* number of TAB positions */
  118. struct nbr Numb[MAXNR];            /* number registers */
  119. int Nxtln = 1;                /* next line number */
  120. int Outll = -1;                /* output line length */
  121. char Outln[MAXOLL*2];            /* output line */
  122. int Outlx = 0;                /* output line index */
  123. int P2il = 0;                             /* pass 2 input line number */
  124. char *P2name = NULL;            /* pass 2 input file name */
  125. int P3fill = 1;                /* pass 3 fill status */
  126. int Padchar[MAXOLL];            /* padding character locations */
  127. int Padfrom = PADLEFT;            /* which end to pad from */
  128. int Padx = 0;                /* Padchar[] index */
  129. struct parms Parms[] = {                /* parameter registers */
  130.     { {'i', 'n'}, "indent", 0, 0      },
  131.     { {'l', 'l'}, "linelen", 0, 0     },
  132.     { {'l', 's'}, "vspace", 0, 0      },
  133.     { {'t', 'i'}, "tempindent", 0, 0  },
  134.     { {'p', 'o'}, "pageoffset", 0, 0  },
  135.     { {'p', 'l'}, "pagelen", 0, 0     },
  136.     { {'\0', '\0'}, NULL, 0, 0        }
  137. };
  138. char Pass1ln[MAXLINE];                /* pass 1 output line */
  139. char Pass2ln[MAXLINE];                /* pass 2 output line */
  140. int Pglen = 66;                /* page length */
  141. int Pgoff = 0;                /* page offset */
  142. char *Pname = NULL;                     /* program name */
  143. char Prevfont = '\0';            /* previous font */
  144. int Ptrstack[MAXSP];                    /* stack for Expand()'s "ptr" */
  145. struct scale Scale[] = {        /* scaling factors */
  146.     { 'i',    (240.0)             },
  147.     { 'c',    ((240.0 * 50.0)/127.0)    },
  148.     { 'P',    (240.0/6.0)        },
  149.     { 'p',    (240.0/72.0)        },
  150.     { 'u',  (1.0)                   },
  151.     { 'm',  (1.0)                   },
  152.     { 'n',  (1.0)                   },
  153.     { 'v',  (1.0)                   },
  154.     { '\0',    (0.0)            }
  155. };
  156. double Scalen = 0.0;            /* 'n' scaling factor */
  157. double Scaleu = 0.0;            /* 'u' scaling factor */
  158. double Scalev = 0.0;            /* 'v' scaling factor */
  159. struct schtab Schar[MAXSCH];        /* special characters */
  160. int Sp = -1;                /* stack pointer */
  161. struct str Str[MAXSTR];                 /* ".ds" strings */
  162. int Sx = -1;                /* string index */
  163. int Tabs[MAXEXP+1];            /* TAB positions */
  164. int Thispg = 1;                /* this page number */
  165. int Tind = 0;                 /* temporary indentation amount */
  166. int Topmarg = 5;            /* top margin */
  167. int Uhyph = 0;                /* hyphen usage state */
  168. int Vspace = 1;                /* vertical (inter-text-line) spacing */
  169. char Word[MAXLINE];                     /* pass 2 word buffer */
  170. int Wordl = 0;                          /* effective length of Word[] */
  171. int Wordx = 0;                          /* Word[] index */
  172. 
  173.