/* $Log:	globals.h,v $
 * Revision 0.8  92/11/23  19:47:02  19:47:02  bt (Bo Thide')
 * Fixed resolution bug. Portable downloading. Added/changed options. PJXL color support
 * 
 * Revision 0.7  92/11/13  02:41:17  02:41:17  bt (Bo Thide')
 * More bug fixes and improvements. Support for PaintJet XL
 * 
 * Revision 0.6  92/11/10  21:48:43  21:48:43  bt (Bo Thide')
 * Bug fixes. Added -R option. Better font handling.
 * 
 * Revision 0.5  92/11/09  16:25:50  16:25:50  bt (Bo Thide')
 * Rewrite of dospecial.c. Extended \special support
 * 
 * Revision 0.4  92/11/08  02:46:06  02:46:06  bt (Bo Thide')
 * Changed to portable bit manipulations. Replaced strrstr for non-POSIX compliant C. Fixed numerous bugs. Added support for more \special's.
 * 
 * Revision 0.3  92/08/24  12:43:17  12:43:17  bt (Bo Thide')
 * Fixed 8 bit (dc font) support.
 * 
 * Revision 0.2  92/08/23  17:28:53  17:28:53  bt (Bo Thide')
 * Source cleaned up.  Changed certain function calls.  Removed globals.
 * 
 * Revision 0.1  92/08/22  23:58:47  23:58:47  bt (Bo Thide')
 * First Release.
 *
 */

#ifndef _DVI2PCL_GLOBALS_INCLUDED
#define _DVI2PCL_GLOBALS_INCLUDED

#define BANNER "TeX Dvi to HP Print Command Language translator dvi2pcl 0.7.\n"
#define BITFILE_SUFFIX 		".pcl"	/* Bit file suffix */
#define BLACKBYTE		'\377'
#define DEV_LJPLUS		0
#define DEV_LJ2			1
#define DEV_LJ2D		2
#define DEV_LJ2P		3
#define DEV_LJ3SI	        4
#define DEV_LJ3P	        5
#define DEV_PJ			10
#define DEV_PJXL	        11
#define DVIFILE_SUFFIX		".dvi"	/* Dvi file suffix */
#define DYNAMICFONTBASE		256	/* Start value for internal font #'s */
#define FALSE			0
#define FIX			(1 << 20)
#define FMASK			7
#define FONTPATH		"/%dpt/%s.%d"	/* Where to look for fonts */
#define HOFFSET			200	
#define INFINITY		0x7FFFFFFF
#define MAXCHEIGHT		128	/* Max character height for printer */
#define MAXCWIDTH		128	/* Max character width for printer */
#define MAXDOWN			128	/* Max number of downloadable fonts */
#define MAXDRIFT		2	/* Max dots rounding error */
#define MAXFONTS		256	/* Max # of fonts to be used */
#define MAXPAGES		1000    /* Max # of pages of the document */
#define MAXPKSIZE		65536	/* Max .pk buffer size */
#define MAXPXLSIZE		65536	/* Max .pxl buffer size */
#define MINPRINTERMEM		122880	/* 120 KByte */
#define NAMELENGTH		255	/* Max length of file names */
#define NAMESIZE		4096	/* Max texbtuffer size for names */
#define NULL			0
#define PCLLEVEL		4	/* Default PCL level (old LaserJets) */
#define PRESCAN_OFF		0	/* Not in the prescan cycle */
#define PRESCAN_ON		1	/* In the prescan cycle */
#define RESOLUTION		300
#define SCALE		 	75780587.52		/* 72.27*2**20 */
#define STACKSIZE		100
#define TERMLINELENGTH		80
#define TRUE			1
#define USGFILE_SUFFIX		".usg"		/* Usage (log) file suffix */
#define VOFFSET		 	150
#define WHITEBYTE		'\0'


/* Global type definitions */

typedef char		byte;
typedef unsigned char	ubyte;
typedef unsigned char	bool;

#ifdef TRUE
#include <sys/types.h>
#else
typedef unsigned short	ushort;
typedef unsigned int	uint;
#endif /* TRUE */

/* PCL font descriptor */
typedef struct {
	ushort size;
	ubyte  descriptor;
        ubyte  font_type;
        ubyte  style_MSB;
        byte   reserved;
        ushort baseline;
        ushort cell_width;
        ushort cell_height;
        ubyte  orientation;
	bool   spacing;
        ushort symbol_set;
        ushort pitch;
        ushort height;
        ushort x_height;
	byte   width_type;	
        ubyte  style_LSB;
        byte   stroke_weight;
        ubyte  typeface_LSB;
        ubyte  typeface_MSB;
        ubyte  serif_style;
        ubyte  quality;
        byte   placement;
        byte   underl_dist;
        ubyte  underl_height;
        ushort text_height;
        ushort text_width;
        ushort first_code;
        ushort last_code;
        ubyte  pitch_ext;
        ubyte  height_ext;
        ushort cap_height;
	uint   font_number;
	char   font_name[16];
      } fdfmt;

/* PCL character descriptor */
typedef struct {
        ubyte  format;
        bool   continuation;
        ubyte  size;
        ubyte  class;
	ubyte  orientation;
	byte   reserved;
        short  left_offset;
        short  top_offset;
        ushort char_width;
        ushort char_height;
        short  delta_x;
      } cdfmt;

/* Internal character information */
typedef struct {
	short pk_char;
        long  pxl_width;
        long  tfm_width;
        long  use_count;
      } charfmt;

/* Internal font information */
typedef struct {
	long	checksum;
        long	scaled_size;
        long	design_size;
        long	space;
        short	dir_size;
	double	height;
        short	down;
        short	name; 
	short	bc;
	short	ec;
        charfmt	chr[256];
      } fontfmt;

/* Internal graphic char information */
typedef struct {
	short pxl_bytes;
	short pxl_rows;
	long x_offset;
	long y_offset;
	byte *pxl_pattern;
	} gcharfmt;

typedef gcharfmt (*gfontfmt)[256];	/* Internal graphic font information */

/* Header part of .tfm files */
typedef struct {
	short lf;
	short lh;
	short bc;
	short ec;
	short nw;
	short nh;
	short nd;
	short ni;
	short nl;
	short nk;
	short ne;
	short np;
	long  cs;
	long  ds;
	} tfmfmt;

/* Printer name and capabilities */
typedef struct {
	long mem;
	char name[16];
	char lang[8];
	} prtfmt;

/* Global variables in alphabetical order */
int		actualpagecount;
cdfmt		cd;			/* character descriptor */
charfmt		*cbase;
double		conv;
double		convpxl;
double		convtfm;
long		count[10];
int		c_black;
int		c_flag;
int		c_height;
int		c_hoffset;
int		c_nib;
int		c_voffset;
int		c_width;
long		denominator;
charfmt		*drawchar();
int		dyn_f;
byte		*endofchardata;
int		e_offset;
fdfmt		fd;			/* font descriptor */
long		firstpage;
long		firstpar();
fontfmt		*font;
int		fontpathlen;
fontfmt		*fontptr[MAXFONTS];
gfontfmt	gfont;
gfontfmt	gfontptr[MAXFONTS];
bool		inpostamble;
long		h_offset;
bool		h_posed;
int		landscape;
long		lastpage;
long		magnification;
int		manualfeed;
long		maxh;
int		maxs;
long		maxv;
long		maxhsofar;
int		maxssofar;
long		maxvsofar;
int		maxpages;
int		max_depth;
int		max_width;
int		max_offset;
char		names[NAMESIZE];
int		nextfontdown;
char		*nextnamesfree;
long		numerator;
int		o_offset;
short		outreverse;
byte		*pkbase;
long		pkbuffer[MAXPKSIZE];
byte		*pkcharinfo();
char		pkfixname[NAMELENGTH];
char		pkname[NAMELENGTH];
byte		*pk_ptr;
long		power[8];
long		prevpage;
prtfmt		printer;
long		printermem_used;
byte		pxlbuffer[MAXPXLSIZE];
int		r_offset;
int		s;
long		startcount[10];
int		startthere[10];
int		startvals;
long		v_offset;
bool		v_posed;
bool		verbose;

long		h, v, w, x, y, z;

#endif /* _DVI2PCL_GLOBALS_INCLUDED */
