home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2092 / defs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-28  |  10.5 KB  |  396 lines

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