home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 145_01 / roffdata.c < prev    next >
Text File  |  1979-12-31  |  10KB  |  318 lines

  1. #define    MSDOS    1    /* Not BDS-C, that's for sure!    */
  2. #define    C86    1    /* Computer Innovations compiler    */
  3. #define    DeSmet    0    /* DeSmet compiler - funnyness with fopen    */
  4. #define    BDS    0
  5.  
  6. /********************************************************/
  7. /*                            */
  8. /*            ROFF4, Version 1.60            */
  9. /*                            */
  10. /*(C) 1983,4 by Ernest E. Bergmann            */
  11. /*        Physics, Building #16            */
  12. /*        Lehigh Univerisity            */
  13. /*        Bethlehem, Pa. 18015            */
  14. /*                            */
  15. /* Permission is hereby granted for all commercial and    */
  16. /* non-commercial reproduction and distribution of this    */
  17. /* material provided this notice is included.        */
  18. /*                            */
  19. /********************************************************/
  20. /*FEB 19, 1984*/
  21. /*Jan 15, 1984*/
  22. #if BDS
  23. #include "bdscio.h"
  24. #else
  25. #include "stdio.h"
  26. #include "bdsjunk.h"
  27. #endif
  28.  
  29. /*June 27, 1983 eliminate directed input*/
  30. #if BDS
  31. char _doflag;    /* flag if directed /O being used */
  32. char  **_nullpos; /*???*/
  33. char _dobuf[BUFSIZ];    /* /O buffer used for direction  */
  34. char sav_out_file[20];    /*??? added to work with dioinit
  35.                 and dioflush() ???*/
  36.  
  37. #endif
  38. #if C86
  39. FILE    *_dobuf;
  40. #endif
  41. #if DeSmet
  42. FILE    _dobuf;
  43. #define    dos    _os
  44. #endif
  45.  
  46. #if MSDOS
  47. extern char *fgets2();
  48. #endif
  49.  
  50. int     debug;
  51. int PAGESTOP;
  52. int JUSTIFY;
  53. int FFEED;
  54. int FIRSTPAGE,LASTPAGE;/*for selectively printing output*/
  55. int SUPPRESS;/*if true,no output is passed by putchar()*/
  56.  
  57. #if BDS
  58. #define STDERR        4
  59. #else
  60. #define STDERR        2
  61. #endif
  62.  
  63. /* send error messages to console while in DIO */
  64. #define STKSIZ        3
  65. #define DEBUG        ( debug != 0 )
  66. #define HUGE        135    /* generally large number */
  67. #define LSZ        255    /* line buffer size*/
  68. #define    COMMAND        '.'    /* all commands starts with this */
  69. #define    CONSOLE        -5    /* one of output options */
  70. #define PRINTER     -4    /* another */
  71. #if BDS
  72. #define FILE        -3    /* another */
  73. #else
  74. #define FFILE        -3    /* another */
  75. #endif
  76. #define    UNKNOWN        -1    /* returned if doesn't recg. command */
  77. #define    NO_VAL        -32760    /* returned when no argument w/commad */
  78. #define WE_HAVE_A_WORD   1       /* returned by getwrd func. */
  79. #define    NO        0
  80. #define    YES        1
  81. #define UNDERLINE    '\137'
  82. #define    CR        0x0D
  83. #define BACKSPACE    '\b'
  84. #define NUMSIGN        '#'    /* for title strings */
  85. #define NEWLINE        '\n'
  86. #define TAB        '\t'
  87. #define BLANK        ' '
  88. #define FORMF        0x0C    /* formfeed for printer */
  89. #define SQUOTE        0x27    /* single quote */
  90. #define DQUOTE        0x22    /* double quote */
  91. #define TRSIZ        2000    /*size of TRTBL*/
  92.  
  93. #define TRANSLATE 2    /* May 23, 1983*/
  94. #define BLACK 1
  95. #define WHITE 0
  96. #define CONTROL -1
  97. #define SENTINEL -2
  98. #define HTAB    -3
  99. #define OTHERS -4
  100. #define XCHAR '-'
  101. #define UCHAR '_'
  102.  
  103. #define FI        1    /* fill lines */
  104. #define TI        2    /* temporary indent */
  105. #define BP        3    /* begin page  */
  106. #define BR        4    /* causes break */
  107. #define CE        5    /* center line(s) */
  108. #define IN        7    /* left indent */
  109. #define LS        8    /* line spacing */
  110. #define NF        9    /* no fill */
  111. #define PL        10    /* set page length */
  112. #define RM        11    /* set right margin */
  113. #define SP        12    /* add blank line(s) */
  114. #define ST        13    /* stop(pause) at page start?*/
  115. #define FO        14    /* footer title */
  116. #define HE        15    /* header title */
  117. #define M1        16    /* top margin */
  118. #define M2        17    /* second top margin */
  119. #define M3        18    /* first bottom margin */
  120. #define M4        19    /* bottom-most margin       */
  121. #define IG        20    /* "ignore";comments,Nov 6,82*/
  122. #define NE        21    /* "need";Nov 7,82*/
  123. #define FF        22    /* "formfeed";Nov 10*/
  124. #define SC        23    /* "space character";Nov13*/
  125. #define OW        24    /* "output width";Nov 13*/
  126. #define TS        25    /* "tabsize";Nov 13*/
  127. #define EH        26    /* "even headers";Nov 14*/
  128. #define OH        27    /* "odd headers"*/
  129. #define EF        28    /* "even footers"*/
  130. #define OF        29    /* "odd footers"*/
  131. #define AB        30    /* "abort";Nov 15*/
  132. #define DB        31    /* "debug"*/
  133. #define TC        32    /* "translation flag char"*/
  134. #define TR        33    /* "def translation string"*/
  135. #define CF        34    /* Dec 4:control flag char*/
  136. #define IC        35    /* insert character */
  137. #define OU        36    /* output */
  138. #define JU        37    /* right justify?*/
  139. #define NJ        38    /* don't right justify*/
  140. #define WH        39    /* whole line spacing code*/
  141. #define FR        40    /* fractional spacing,code*/
  142. #define DS        41    /*define string*/
  143. #define DM        42    /*define macro*/
  144. #define EM        43    /*end macro*/
  145. #define RG        44    /*register variable*/
  146. #define DI        45    /*diversion*/
  147. #define ED        46    /*end diversion*/
  148. #define SO        47    /*"source", include*/
  149. #define PC        48    /*printer control definition*/
  150. #define SA        49    /*"say" inline msg to console*/
  151. #define BJ        50    /*break with right justification */
  152. /*                of current line*/
  153.  
  154. int FILL;    /* set to YES or NO */
  155. int _FILL[STKSIZ];    /*convert global value to a stack*/
  156. int LSVAL;    /* line spacing value -> default will be 1 */
  157. int _LSVAL[STKSIZ];
  158. int TIVAL;    /* temporary indent -> default  0 */
  159. int INVAL;    /* left indent -> default  0 */
  160. int _INVAL[STKSIZ];
  161. int RMVAL;    /* right margin -> default  PAGEWIDTH */
  162. int _RMVAL[STKSIZ];
  163. int CEVAL;    /* set equal to number of lines to be centered    */
  164. int TCVAL;    /*translation flag char*/
  165. int _TCVAL[STKSIZ];
  166.         /* default is 0                                   */
  167. int SPVAL;    /* blank lines to be spaced down */
  168.  
  169. int CURPAG;    /* current output page number; init = 0 */
  170. int NEWPAG;    /* next output page number; init = 1 */
  171. int VLINENO;    /* virtual (intended) line advances on page,
  172.             see vadv()*/
  173. int FVLINENO;    /* + line fraction */
  174. int PLINENO;    /* printer's actual line advances on page,
  175.             see padv()*/
  176. int FPLINENO;    /* + line fraction */
  177. int PLVAL;    /* page length in lines */
  178. int _PLVAL[STKSIZ];
  179. int M1VAL;    /* margin before& including header in lines*/
  180. int _M1VAL[STKSIZ];
  181. int M2VAL;    /* margin after header in lines*/
  182. int _M2VAL[STKSIZ];
  183. int M3VAL;    /* margin after last text line in lines*/
  184. int _M3VAL[STKSIZ];
  185. int M4VAL;    /* bottom margin, including footer in lines*/
  186. int _M4VAL[STKSIZ];
  187. int BOTTOM;    /* end of text area in lines;start of M3+M4 */
  188. int SCVAL;    /* space character*/
  189. int _SCVAL[STKSIZ];
  190. int OWVAL;    /* output device width*/
  191. int _OWVAL[STKSIZ];
  192. int TABSIZ;    /* spacing of tabstops*/
  193. int _TABSIZ[STKSIZ];
  194. int SENTENCE;    /* Nov 20*/
  195. int CFVAL;    /*Dec 4:control flag character value*/
  196. int _CFVAL[STKSIZ];
  197. int ICVAL;    /*insert character*/
  198. int _ICVAL[STKSIZ];
  199.  
  200. char LINE[ LSZ ];    /*input line buffer, Nov 26*/
  201. char EHEAD[ LSZ ],*EH2,*EH3;    /* even header title */
  202. char OHEAD[ LSZ ],*OH2,*OH3;    /* odd header title */
  203. char EFOOT[ LSZ ],*EF2,*EF3;    /* even footer title */
  204. char OFOOT[ LSZ ],*OF2,*OF3;    /* even footer title */
  205.  
  206.  
  207. /* defaults for global parameters */
  208.  
  209. #define FI_DEF        1
  210. #define    LS_DEF        1
  211. #define    IN_DEF        0
  212. #define    RM_DEF        60
  213. #define    TI_DEF        0
  214. #define    CE_DEF        1
  215. #define    UL_DEF        -1
  216. #define M1_DEF        2
  217. #define M2_DEF        2
  218. #define M3_DEF        2
  219. #define M4_DEF        2
  220. #define PL_DEF        66
  221. #define FF_DEF        YES    /* .ff defaults to "on" */
  222. #define FF_INI        NO    /* initial setting*/
  223. #define SC_INI        BLANK
  224. #define OW_INI        60    /*initial output width*/
  225. #define TS_DEF        8    /*standard tabsize*/
  226. #define TC_DEF        '~'    /*translation flag default*/
  227. #define CF_DEF        '^'    /*Dec 4*/
  228. #define IC_DEF        '\\'
  229. #define CW_DEF        12    /* 12/120" */
  230. #define JU_INI        YES    /*right justification*/
  231. #define REGDEF         1    /*default for register var.*/
  232.                 /*when .rg has no numeric arg*/
  233.  
  234. int DIR;    /* for "spreading" of lines    */
  235. int OUTWRDS;    /* no. words in OUTBUF; init = 0 */
  236. char OUTBUF[ LSZ ];    /*lines to be filled collected here */
  237. int OUTW;    /*current display width of OUTBUF*/
  238. int OUTPOS;    /* =strlen(OUTBUF) */
  239. int WTOP,LTOP,OUTTOP;    /*zero|negative;levels of subscripts*/
  240. int WBOT,LBOT,OUTBOT;    /*zero|positive;levels of subscripts*/
  241. int OLDLN;        /*position of previous main line*/
  242. int OLDBOT;        /*OUTBOT for previous line;reset
  243.             each page*/
  244. int FRQ,FRVAL;    /* fractional line?, what fraction size*/
  245. char *FRSTRING; /* ^ to code for fractional spacing*/
  246. char *WHSTRING;    /* ^ to code for whole line spacing*/
  247. char *CPTR[128-' '];    /*pointer table for print control*/
  248. char *TPTR[128-' '];    /*pointer table for translation strings
  249.               for char; initialize to null */
  250. char TRTBL[TRSIZ];    /*holds translation strings*/
  251. char *TREND;        /*^to end of above;init = TRTBL*/
  252. int DLINK;        /*^ head of diversion list*/
  253. int *RLINK;        /*^ head of register variable list*/
  254. int *SLINK,*MLINK;    /*points to head of linked
  255.             string, macro lists*/
  256. #if BDS
  257. struct _buf *IOBUF;
  258. #endif
  259. #if    C86
  260. FILE    *iobuf;
  261. #endif
  262. #if    DeSmet
  263. FILE    iobuf;
  264. #endif
  265. /*following added for buffered and formatted output:  */
  266. char OUTBUF2[LSZ];    /*for line to be output in fancy fmt*/
  267. int BPOS,CP,PP;        /*buffer,column,printer positions*/
  268. char XBUF[LSZ];        /*strikout buffer*/
  269. int XF,XCOL;        /* " flag and column */
  270. char UBUF[LSZ];        /*underline buffer*/
  271. int UF,UCOL;        /* " flag and column */
  272. int FIRST;        /*flag for first pass*/
  273. char DBUF[LSZ];        /*double strike buffer*/
  274. int DPOS;
  275. int OCNT;
  276. int MCNT;
  277. int BLKCNT;
  278.  
  279. #define    REVSCROLL    FALSE
  280. #define CANBS        FALSE
  281.  
  282. #define BACKSIZE    LSZ
  283. char BACKBUF[BACKSIZE];
  284. int BINP;    /*position in above;init to 0*/
  285. #define BELL    '\007'
  286. char KEYBD;        /*boolean & prompt for keyboard input*/
  287. char KLINE[MAXLINE];    /*keyboard line input buffer*/
  288. char *KPTR;        /*pointer for above*/
  289.  
  290. struct divfd
  291.     {char *nm;    /*name*/
  292.     int cs;        /*character count*/
  293.     int ls;        /*line count*/
  294. #if BDS
  295.     struct _buf *bf; /*to iobuf if open, FALSE otherwise*/
  296. #endif
  297. #if C86
  298.     FILE *bf; /*to iobuf if open, FALSE otherwise*/
  299. #endif
  300. #if    DeSmet
  301.     FILE bf; /*to iobuf if open, FALSE otherwise*/
  302. #endif
  303. };
  304.  
  305. #define FMAX        4    /* # of additional files open*/
  306. int    FPTR;
  307. #if BDS
  308. struct _buf *FSTACK[FMAX];
  309. #endif
  310. #if C86
  311. FILE *FSTACK[FMAX];
  312. #endif
  313. #if DeSmet
  314. FILE FSTACK[FMAX];
  315. #endif
  316. int    TFLAG;/*added for start(), complete()*/
  317. int XF2,UF2,MCNT2;
  318.