home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume24 / psroff3.0 / part09 / defs.h next >
Encoding:
C/C++ Source or Header  |  1991-10-09  |  11.3 KB  |  405 lines

  1. /*
  2.     Copyright 1985, 1986, 1987, 1988, 1989, 1990, 1991 Chris Lewis
  3.         All Rights Reserved
  4.  
  5.     See the LICENSE file for a full description of restrictions under which
  6.     this software is provided.
  7.  
  8.     Function:    Main header file - contains some customization
  9.  */
  10.  
  11. /*    Official Release and Patch level:    */
  12. #define    T2VERSION    "@(#)PSROFF Copyright 91/03/25 Chris Lewis - R3 PL0"
  13.  
  14. /*    Configuration parameters:
  15.  */
  16.  
  17. #undef    BSD        /* Define if you are a V7 or BSD machine */
  18.             /* strchr vs. index etc.... */
  19.  
  20. #define    ATT        /* Define if you are some sort of SIII or SV system */
  21.  
  22. #undef    BCOPY        /* Define if you don't have memcpy and friends - eg:
  23.                oldish BSD systems */
  24.  
  25. #undef  BCOPYLIB    /* Define if BCOPY is defined and you have */
  26.             /* a bcopy in your library */
  27.  
  28. /*    The name of a routine that can be called thusly:
  29.     VFPRINTF(stream, format, ap)
  30.     FILE *stream;
  31.     char *format;
  32.     va_list ap;
  33.     (eg: you have varargs.h and you have a routine functionally compatible
  34.     with System V vfprintf.  I think BSD has one too)
  35.  
  36.     undef if you don't got, and maybe my fakeout will work.
  37.  */
  38.  
  39. #define VFPRINTF    vfprintf
  40.  
  41. /* If you have the stand-alone pk2sfp distribution, do not touch
  42.    anything from here on */
  43.  
  44. /*    Font width file configuration:
  45.  
  46.     - If HEADERSIZE defined, use that many bytes as a prefix to the
  47.       compiled font width table.  HEADERSIZE 0 is the correct definition
  48.       for Xenix and most System V [o]troffs.  HEADERSIZE=32 works for Ultrix
  49.       (except RISC, see below).  HEADERSIZE=32 works properly for most Suns.
  50.     - If COFF is defined instead, use a COFF header on the beginning of
  51.       the file.  I personally know of no machine that supports these, tho,
  52.       there's unconfirmed rumours that Apollo systems might.
  53.     - If neither are defined, use a BSD/V7 style a.out.h header, this
  54.       is appropriate for V7 and BSD troffs
  55.     - If you are running RISC/Ultrix (Mips box? from DEC) define
  56.       ASCIIWIDTHS, and the rest of this stuff will be ignored - Mips
  57.       apparently changed their width table format to an ASCII form,
  58.       and DEC picked it up.  In this case IGNORE any messages about
  59.       HEADERSIZE from "make check".
  60.  
  61.     The headers I write will have something in them if HEADERSIZE > 0
  62.     and there's a font file from your original troff distribution in
  63.     /usr/lib/font/ftR (the header and trailer will be copied over).
  64.  
  65.  */
  66.  
  67. #define    HEADERSIZE 0    /* size of header in bytes */
  68. #undef    COFF        /* systems using COFF headers - See TROUBLE file
  69.                about Apollos */
  70. #undef    ASCIIWIDTHS    /* For RISC/Ultrix */
  71.  
  72. /* What do your CAT codes look like?
  73.  
  74.    If BSDHACK defined, the code to magnify the next lead by 64 replaces the
  75.    codes to set the tilt (tilt used only on 8-font CATs, which most CAT troff
  76.    programs don't support).
  77.  
  78.    Both FONT8 and BSDHACK code are *untested*.  FONT8 probably does *not*
  79.    work.
  80.  */
  81.  
  82. #undef    BSDHACK        /* Has magnify lead opcode - untested */
  83. #undef    FONT8        /* 8 Font device - untested */
  84. #define FONT4        /* Normal 4 font device */
  85.  
  86.             /* define a command for decompressing an argument
  87.                file to stdout - allows you to compress SFP's.
  88.                undef if you don't got.  The -d option may be
  89.                undocumented, but means decompress.  "-dc"
  90.                is equivalent to zcat.  -dc appears to be
  91.                in most versions of compress (eg: v3 & v4) */
  92. #define    COMPRESS    "/usr/lbin/compress -dc"
  93.  
  94. /*    Some postscript printers don't accept control-D as job termination
  95.     (DEC scriptwriters for instance, or LAN-connected printers).  In that
  96.     case, define this macro.  Alternately, if you have a proper printer
  97.     manager that does this sort of stuff, define it too.
  98.     If your printer will take "stop", specify "-S" in psrofflib's
  99.     t2arg, and leave this undefined.
  100.  */
  101. #undef    NOCONTROLD
  102.  
  103. /*    define if you don't want your Postscript printer talking to you */
  104. #undef    NOCHATTER
  105.  
  106. /*    The only advantage to commenting-out one of these is to make the
  107.     binary executable of troff2?? smaller.
  108.  */
  109.  
  110. /*    Basic drivers: */
  111. #define    PS    /* Postscript */
  112. #define    LJ    /* Laserjet - utils programs will not build with this undef'd */
  113. #define    DT    /* ditroff */
  114. #define    DIT    /* ditroff *front-end* */
  115.  
  116. /*    Laserjet driver config: */
  117. #define    PK    /* enable PK font downloading (needs LJ) */
  118.  
  119. #define    SFP    /* enable SFP incremental font downloading (needs PK).
  120.            You can still use SFP's without this turned on, but
  121.            you won't get incremental downloading */
  122.  
  123. #define    PARTIAL    /* partial (not incremental) font downloading */
  124.  
  125. #define    INCR    /* enable incremental font downloading (needs PARTIAL) */
  126.  
  127. #define    MDLF    16    /* Max # downloaded fonts permitted by your laserjet
  128.                per *page*.  16 is correct for HPLJ+ and most II's.
  129.                IIP's are 32 I think.  Some newer ones have higher
  130.                restrictions (don't put this too high even if
  131.                your printer supports it, you may run out of
  132.                memory) */
  133.  
  134. #define    PRELOAD    0    /* set to number of LJ fonts permanently
  135.                downloaded to printer.  The backend will
  136.                make sure that you don't go over the number
  137.                of fonts permitted by the printer */
  138.  
  139. #define    DEBUG        /* Do you want the debugger in?  If you encounter
  140.                problems and you want help from me, you'll have
  141.                to have this turned on */
  142.  
  143. #define    OPT        /* CAT code reorder and optimizer */
  144.  
  145. #define    DEFPL  11    /* Default page length (11 inches).
  146.                DO NOT change unless you absolutely HAVE to.
  147.                You should only need to change this if you
  148.                desire your printer to use something different
  149.                as default.  If so, you'll HAVE to change
  150.                your macro package to agree on the default - RT
  151.                owners take note! (the man macros are wrong) */
  152.  
  153. #define    DEFOFF 0.5    /* Default page offset.  DO NOT change unless you
  154.                absolutely HAVE to.  You should only need this
  155.                if: your vendor has buggered your macros to
  156.                have a different default .po offset (Xenix),
  157.                and you aren't using the macro adapter
  158.                libraries that come with psroff (eg: you're
  159.                using troff2ps directly).  See README/TROUBLE/
  160.                psroff(1) (-O vs. -rO options) */
  161.  
  162. #define    DEFYOFF   0    /* Default page vertical offset.  See README/TROUBLE/
  163.                psroff(1) -Y options too */
  164.  
  165. #define    INSPECIAL    /* enables ditroff graphics capability */
  166.  
  167. #define    NSP    256    /* number of \(xx characters. */
  168.  
  169. #define    NODECMD    "uuname -l" /* command to print on stdout the node name
  170.                of your machine.  Use hostname on BSD-derived
  171.                systems that don't have UUCP.  You can always
  172.                use "echo <nodename>" if necessary */
  173.  
  174. /*    Edit no more .... */
  175.  
  176. #define    MAXDLFONTS (MDLF - PRELOAD)    /* # fonts troff2ps can download */
  177.  
  178. /*    configuration verification */
  179.  
  180. #if    defined(BSDHACK) && defined(FONT8)
  181. #include    "BSDHACK and FONT8 cannot be defined at the same time"
  182. #endif
  183. #if    defined(FONT4) && defined(FONT8)
  184. #include    "FONT4 and FONT8 cannot be defined at the same time"
  185. #endif
  186.  
  187. #if    !defined(LJ) && defined(PK)
  188. #include    "Pointless to define PK without LJ"
  189. #endif
  190.  
  191. #if    !defined(PK) && (defined(INCR) || defined(PARTIAL))
  192. #include    "Pointless to define INCR or PARTIAL without PK"
  193. #endif
  194.  
  195. #if    defined(INCR) && !defined(PARTIAL)
  196. #include    "Don't support INCR without PARTIAL"
  197. #endif
  198.  
  199. #if    defined(SFP) && !defined(PK)
  200. #include    "Can't define SFP without PK"
  201. #endif
  202.  
  203. #include <stdio.h>
  204. #include <ctype.h>
  205.  
  206. #ifdef BSD
  207. #include <strings.h>
  208. #define    strchr    index
  209. #define    strrchr    rindex
  210. #else
  211. #include <string.h>
  212. #endif
  213.  
  214. #ifdef    BCOPY
  215. #define    memcpy(to, from, len)    bcopy(from, to, len)
  216. #define    clrarray(array, len)    bzero(array, len)
  217. #else
  218. #define    clrarray(array, len)    memset(array, '\0', len)
  219. #endif
  220.  
  221. #define    ESC    0x80
  222. #define    FLASH    0x00
  223. #define    CONTROL    0x40
  224. #define    LEAD    0x60
  225. #define    SIZE    0x50
  226.  
  227. #define    DOWN    0
  228. #define    UP    1
  229. #define    LOWER    2
  230. #define    UPPER    3
  231. #define    FORWARD    4
  232. #define    BACKWARD 5
  233.  
  234. #define    TROFFRESOLUTION    432
  235.  
  236. #define    SPECIAL        /* define if you want to support special directives */
  237. #define    FORM        /* define if you want the forms facility */
  238.  
  239. FILE    *diagFile;
  240.  
  241. #ifdef DEBUG
  242. #define    DBP(x)    if (diagFile) dprintf x
  243. extern dprintf();
  244. #else
  245. #define    DBP(x)
  246. #endif
  247.  
  248. typedef int(*FUNC)();
  249.  
  250. #define    FNULL    (FUNC) NULL
  251.  
  252. struct    troff2befont {
  253.     short    t2b_font;    /* font (troff nomenclature) S=don't change */
  254.     short    t2b_xc;        /* X-shift */
  255.     short    t2b_yc;        /* Y-shift */
  256.     short    t2b_scale;    /* point size scale adjust */
  257.     char     *t2b_charseq;    /* character sequence - may include PS */
  258. };
  259.  
  260. struct cattab {
  261.     char *ch_name;
  262.     char ch_set;
  263.     unsigned char ch_catidx;
  264.     unsigned char ch_wididx;
  265.     unsigned char ch_info;    /* used by some auxiliary programs */
  266.     char *ch_desc;
  267. };
  268.  
  269. struct backend {
  270.     char    *bename;
  271.     FUNC    beprolog,
  272.         beepilog,
  273.         beputchar,
  274.         bepage,
  275.         befontsel,    /* special function F */
  276.         beoverlay,    /* special function O */
  277.         bepassthru,    /* special function P */
  278.         bexlat,        /* Xlate function */
  279.         bedraw;        /* Ditroff draw emulation routine */
  280.     struct troff2befont
  281.         *bestdfont,    /* standard font translate table */
  282.         *besymfont;    /* symbol font translate table */
  283. };
  284.  
  285. #define    MAXFONTS    50
  286.  
  287. struct fonttable {
  288.     char *tab[4];
  289.     long flags;
  290. #ifdef    INCR
  291.     struct downmaps *map;
  292. #endif
  293. #ifdef    OPT
  294.     char *widthtable;
  295. #endif
  296. };
  297.  
  298. /*    Symbolic names for tab entries in fonttable    */
  299. #define    troffName    tab[0]    /* troff name */
  300. #define    fontName    tab[1]    /* back-end name (if used) */
  301. #define    fontSeq        tab[2]    /* sequence to emit to shift to it
  302.                    lj builtin's mostly */
  303.  
  304. /*    fontFlags is 16 characters that reflect the state of the font
  305.     at a particular pointsize - mainly for lj */
  306.  
  307. /*    Use of flags:
  308.     s:    unloaded SFP
  309.     S:    loaded SFP
  310.     p:    unloaded PK
  311.     P:    loaded PK
  312.     n:    non-existant
  313.     b:    builtin.
  314.  */
  315. #define    fontFlags    tab[3]
  316.  
  317. extern int symidx;        /* index of symbol font */
  318.  
  319. #define    INTFONTS    10    /* maximum number of builtin fonts */
  320.  
  321. extern struct fonttable fonttable[MAXFONTS+1];
  322. extern struct fonttable *xlatetable[INTFONTS];
  323. #define    EXTCHUNK    10
  324. extern struct troff2befont *extchars;
  325. extern struct cattab **spctab, **dittab;
  326. extern struct cattab *extidx;
  327. extern int extcount;
  328. extern char *pstrailer;
  329.  
  330. struct backend *be;
  331. #define    BNULL    (struct backend *) NULL
  332.  
  333. extern char *skipblanks();
  334.  
  335. /*    Common Back-end definitions */
  336.  
  337. #define    N    (unsigned char) (0xff)    /* Use standard font */
  338. #define    S    (unsigned char) (0xfe)    /* Use symbol font */
  339. #define    D    (unsigned char) (0xfd)    /* Draw macro exists - use string directly */
  340. #define    NTC    (unsigned char) (0xfc)    /* No font/Special flag */
  341.  
  342. #define    NOC    NULL
  343.  
  344. extern int currentPage;
  345. extern int pageoffset;
  346. extern int pageyoffset;
  347. extern int pagelength;
  348. extern int pagePending;
  349.  
  350. #ifdef    OPT
  351. extern char *widthtables;
  352. extern char *widthptr;
  353. extern int optimize;
  354. #endif
  355.  
  356. extern int lastFont, lastPoints;
  357. extern int lastYPos, lastXPos, specXPos, specYPos;
  358. extern char *progname, *printer, *device;
  359. extern char **prologs;
  360.  
  361. int metrics;
  362. #ifdef    DIT
  363. int ditroff;
  364. #endif
  365.  
  366. FILE *libopen();
  367.  
  368. /*    Encoding format for generating width tables from font files */
  369. /*    Used by pk2ditwid and friends */
  370. struct enctab {
  371.     char *e_name;
  372.     char *e_seq;
  373.     char e_wid;
  374. };
  375.  
  376. /*    Points in an inch */
  377. #define    POINT    72.27
  378.  
  379. #define    min(a,b)    ((a) < (b) ? (a) : (b))
  380. #define    max(a,b)    ((a) > (b) ? (a) : (b))
  381.  
  382. /* debug flags */
  383. #define    D_CAT    1    /* show cat interpretation machinery */
  384. #define    D_SPEC    2    /* show special directives */
  385. #define    D_CHAR    4    /* optimizer machinery */
  386. #define    D_FONT    8    /* font handling */
  387. #define    D_BEND    0x10    /* backend */
  388. #define    D_PK    0x20    /* PK font handling */
  389. #define    D_VERB    0x40    /* very verbose */
  390. #define    D_FLSH    0x80    /* flush after each fprintf */
  391.  
  392. extern int debug;
  393.  
  394. extern char username[];
  395.  
  396. extern char *mustmalloc();
  397.  
  398. extern char *version, *shortversion;
  399.  
  400. #define    MAXPAGE    2000
  401. #ifdef    ALONE
  402. #undef    PARTIAL
  403. #undef    INCR
  404. #endif
  405.