/* $Log:	initialize.c,v $
 * Revision 0.8  92/11/23  19:46:47  19:46:47  bt (Bo Thide')
 * Fixed resolution bug. Portable downloading. Added/changed options. PJXL color support
 * 
 * Revision 0.7  92/11/13  02:41:31  02:41:31  bt (Bo Thide')
 * More bug fixes and improvements. Support for PaintJet XL
 * 
 * Revision 0.6  92/11/10  21:47:47  21:47:47  bt (Bo Thide')
 * Bug fixes. Added -R option. Better font handling.
 * 
 * Revision 0.5  92/11/09  16:25:35  16:25:35  bt (Bo Thide')
 * Rewrite of dospecial.c. Extended \special support
 * 
 * Revision 0.4  92/11/08  02:45:50  02:45:50  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:45:42  12:45:42  bt (Bo Thide')
 * Fixed 8 bit (dc font) support.
 * 
 * Revision 0.2  92/08/23  17:28:57  17:28:57  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.
 *  */

#include <stdio.h>
#include "globals.h"
#include "paths.h"

static char rcsid[] = "$Header: initialize.c,v 0.8 92/11/23 19:46:47 bt Exp $";

/*
 * Get all variables initialized
 */

initialize()
{
	int	i,j;
	int	linelength=80;
	char	*cols;

	if(verbose)
		fprintf(stderr,BANNER);
	for(i=0; i<MAXFONTS; i++) {
		fontptr[i] = NULL;
		gfontptr[i] = NULL;
	}
	pkbase = (byte *)pkbuffer;
#ifdef DEBUG
	fprintf(stderr,"initialize: pkbase = %d\n", &pkbase);
#endif /* DEBUG */
	nextnamesfree = names + 1;
	verbose = FALSE;
	maxpages = MAXPAGES;
	startvals = 0;
	startthere[0] = FALSE;
	inpostamble = FALSE;
	maxv = INFINITY - 99;
	maxh = INFINITY - 99;
	maxs = STACKSIZE + 1;
	maxvsofar = 0;
	maxhsofar = 0;
	maxssofar = 0;
	h_posed = FALSE;
	v_posed = FALSE;
	h_offset = HOFFSET;
	r_offset = HOFFSET;
	v_offset = VOFFSET;

	lastpage = -1;
	prevpage = -1;
	actualpagecount = 0;
	nextfontdown = DYNAMICFONTBASE;
	printermem_used = 0;
	landscape = FALSE;
	manualfeed = FALSE;

	/* Initialize font descriptor data */
	fd.size = 64;
	fd.descriptor = 0;
	fd.font_type = 2;
	fd.style_MSB = 0;
	fd.reserved = 0;
	fd.baseline = 0;
	fd.cell_width = 1;
	fd.cell_height = 1;
	fd.orientation = 0;
	fd.spacing = 1;
	fd.symbol_set = 2048;	/* Largest allowed value + 1 */
	fd.pitch = 1;
	fd.height = 1;
	fd.x_height = 0;
	fd.width_type = 0;
	fd.style_LSB = 0;
	fd.stroke_weight = 0;
	fd.typeface_LSB = 0;
	fd.typeface_MSB = 0;
        fd.serif_style = 128;	/* Serif */
        fd.quality = 0;
        fd.placement = 0;
        fd.underl_dist = 0;
        fd.underl_height = 0;
        fd.text_height = 0;
        fd.text_width = 0;
        fd.first_code = 1;
        fd.last_code = 255;
        fd.pitch_ext = 0;
        fd.height_ext = 0;
        fd.cap_height = 0;
        fd.font_number = 0;
        strcpy(fd.font_name,"-TeX dvi font-");

	/* Initialize character descriptor data */
	cd.format = 4;
	cd.continuation = 0;
	cd.size = 14;
	cd.class = 1;
	cd.orientation = 0;
	cd.reserved = 0;
	cd.left_offset = 0;
	cd.top_offset = 0;
	cd.char_width = 0;
	cd.char_height = 0;
	cd.delta_x = 0;

	j = 1;
	for(i=0 ; i<8; i++)
	{ 
		power[i] = (long)j;
		j <<= 1;
	}

	/* Take a stab at line length (SYSVish) */
	if ((cols = (char *)getenv("COLUMNS")) != NULL){ 
		sscanf(cols, " %d", &linelength);
		if(linelength > 500) linelength = 500;
		if(linelength < 20) linelength = 20;
	}
  
	strcpy(pkfixname,fontpath);
	fontpathlen = strlen(pkfixname);
}
