[comp.sources.misc] v13i095: lj2ps

lishka@uwslh.slh.wisc.edu (Chris Lishka (relaxing in the Mad-City) ) (07/03/90)

Posting-number: Volume 13, Issue 95
Submitted-by: lishka@uwslh.slh.wisc.edu (Chris Lishka (relaxing in the Mad-City) )
Archive-name: lj2ps/part10

---- Cut Here and unpack ----
#!/bin/sh
# This is part 10 of a multipart archive
if touch 2>&1 | fgrep '[-amc]' > /dev/null
 then TOUCH=touch
 else TOUCH=true
fi
# ============= lj2ps.h ==============
if test X"$1" != X"-c" -a -f 'lj2ps.h'; then
	echo "File already exists: skipping 'lj2ps.h'"
else
echo "x - extracting lj2ps.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > lj2ps.h &&
X/*
X** Project:        lj2ps
X** File:	   lj2ps.h
X**
X** Author:	   Christopher Lishka
X** Organization:   Wisconsin State Laboratory of Hygiene
X**		   Data Processing Dept.
X**
X** Copyright (C) 1990 by Christopher Lishka.
X**
X** This program is free software; you can redistribute it and/or modify
X** it under the terms of the GNU General Public License as published by
X** the Free Software Foundation; either version 1, or (at your option)
X** any later version.
X**
X** This program is distributed in the hope that it will be useful,
X** but WITHOUT ANY WARRANTY; without even the implied warranty of
X** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X** GNU General Public License for more details.
X**
X** You should have received a copy of the GNU General Public License
X** along with this program; if not, write to the Free Software
X** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X*/
X
X#ifndef LJ2PS_H
X#define LJ2PS_H
X
X#include "lj.h"
X
X  /* Global constants
X  */
X#define PROGRAM  "lj2ps"
X#define VERSION  "1.1"
X#define STATUS	 "release"
X
X  /* Global structure and type definitions
X  */
X
X  /* Global variables
X  */
Xextern int    debug;
Xextern int    warnings;
X
X  /* Global macro definitions
X  */
X
X  /* Global functions
X  */
X#endif
SHAR_EOF
$TOUCH -am 0630160790 lj2ps.h &&
chmod 0644 lj2ps.h ||
echo "restore of lj2ps.h failed"
set `wc -c lj2ps.h`;Wc_c=$1
if test "$Wc_c" != "1251"; then
	echo original size 1251, current size $Wc_c
fi
fi
# ============= ljcmds.c ==============
if test X"$1" != X"-c" -a -f 'ljcmds.c'; then
	echo "File already exists: skipping 'ljcmds.c'"
else
echo "x - extracting ljcmds.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ljcmds.c &&
X/* Project:		lj2ps
X** File:		ljcmds.c
X**
X** Author:		Christopher Lishka
X** Organization:	Wisconsin State Laboratory of Hygiene
X**			Data Processing Dept.
X**
X** Copyright (C) 1990 by Christopher Lishka.
X**
X** This program is free software; you can redistribute it and/or modify
X** it under the terms of the GNU General Public License as published by
X** the Free Software Foundation; either version 1, or (at your option)
X** any later version.
X**
X** This program is distributed in the hope that it will be useful,
X** but WITHOUT ANY WARRANTY; without even the implied warranty of
X** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X** GNU General Public License for more details.
X**
X** You should have received a copy of the GNU General Public License
X** along with this program; if not, write to the Free Software
X** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X*/
X
Xstatic char * ModuleID = "Module ljcmds: v1.0, production";
X
X  /* Include files
X  */
X#include <stdio.h>
X#include <math.h>
X#include "ljcmds.h"
X#include "lj.h"
X#include "ljfonts.h"
X#include "scan.h"
X#include "lj2ps.h"
X
X  /* External definitions
X  */
X
X  /* Global variables
X  */
X
X  /* Global function list
X  */
Xextern void  ljcmd_undefined();	/* Command: undefined */
Xextern void  ljcmd_E();		/* Command: ^[E  reset */
Xextern void  ljcmd_Y();		/* Command: ^[Y  display functions on */
Xextern void  ljcmd_Z();		/* Command: ^[Z  display functions off */
Xextern void  ljcmd_9();		/* Command: ^[9  clear margins */
Xextern void  ljcmd_eq();	/* Command: ^[=  half-line feed */
Xextern void  ljcmd_lp();	/* Command: ^[(  primary symbol set */
Xextern void  ljcmd_rp();	/* Command: ^[)  secondary symbol set */
Xextern void  ljcmd_lp_s();	/* Command: ^[(s primary font attributes */
Xextern void  ljcmd_rp_s();	/* Command: ^[)s secondary font attributes */
Xextern void  ljcmd_amp_a();	/* Command: ^[&a margins & movement */
Xextern void  ljcmd_amp_d();	/* Command: ^[&d underline */
Xextern void  ljcmd_amp_f();	/* Command: ^[&f macros, position stack */
Xextern void  ljcmd_amp_k();	/* Command: ^[&k HMI, pitch, line termination*/
Xextern void  ljcmd_amp_l();	/* Command: ^[&l page attributes */
Xextern void  ljcmd_amp_p();	/* Command: ^[&p transparent print data */
Xextern void  ljcmd_amp_s();	/* Command: ^[&s end-of-line wrap */
Xextern void  ljcmd_star_b();	/* Command: ^[*b bitmap transfer */
Xextern void  ljcmd_star_c();	/* Command: ^[*c graphics, soft fonts */
Xextern void  ljcmd_star_p();	/* Command: ^[*p device-dependent movement */
Xextern void  ljcmd_star_r();	/* Command: ^[*r start/end graphics */
Xextern void  ljcmd_star_t();	/* Command: ^[*t graphics resolution */
X
X  /* Local constants
X  */
X
X  /* Local structures and types
X  */
X
X  /* Local variables
X  */
X
X  /* Local macro definitions
X  */
X#define operation(X) (variable[strlen(variable) - 1] == X)
X
X  /* Local function list
X  */
X
X  /* Function bodies
X  */
X
Xvoid
Xljcmd_undefined(ifile, ofile)	/* Command: undefined */
X     FILE *ifile, *ofile;
X{
X      warning("unknown LaserJet PCL command");
X} /* ljcmd_undefined() */
X
X
X
X  /* ljcmd_E(ofile) performs a LaserJet "reset" command.  This initializes
X  ** all internal variables to default values.  In addition, if the current
X  ** page is not empty, a new page is started.
X  */
Xvoid
Xljcmd_E(ofile)			/* Command: ^[E reset */
X     FILE *ofile;
X{
X
X    /* If current page is not empty, then start a new one */
X  lj_page_end(ofile);
X  
X    /* Reset the printer */
X  lj_reset(ofile);
X
X    /* Begin the next page */
X  lj_page_begin(ofile);
X
X} /* ljcmd_E() */
X
X
X
Xvoid
Xljcmd_Y(ofile)			/* Command: ^[Y display functions on */
X     FILE *ofile;
X{
X
X  warning("command <esc>Y is not implemented -- ignoring", "");
X
X} /* ljcmd_Y() */
X
X
X
Xvoid
Xljcmd_Z(ofile)			/* Command: ^[Z display functions off */
X     FILE *ofile;
X{
X
X  warning("command <esc>Z is not implemented -- ignoring", "");
X
X} /* ljcmd_Z() */
X
X
X
Xvoid
Xljcmd_9(ofile)			/* Command: ^[9 clear margins */
X     FILE *ofile;
X{
X
X  margin_left  = 0.0;		/* Reset the left margin */
X  text_width  = page_width - margin_left; /* Reset the virtual right margin */
X
X  lj_text_end(ofile);
X  fprintf(ofile, "/ml 0.0 def %.4f RM ", /* Reset the clipping path */
X	  margin_left + text_width);
X  lj_text_begin();
X
X} /* ljcmd_9() */
X
X
X
Xvoid
Xljcmd_eq(ofile)			/* Command: ^[= half-line feed */
X     FILE *ofile;
X{
X
X  lj_text_end(ofile);
X  lj_undl_flush(ofile);
X
X  lj_cursor_ver_rel(ofile, (char_height / 2));
X
X  lj_undl_mark(ofile);
X  lj_text_begin();
X
X} /* ljcmd_eq() */
X
X
X
Xvoid
Xljcmd_lp(ifile, ofile)		/* Command ^[( primary symbol set */
X     FILE *ifile, *ofile;
X{
X
X    /* Parse all of the parameters, until the scanner returnes PARAM_END */
X  do{
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X      warning("more than one symbol set in a command -- ignoring", command);
X      break;
X    case PARAM_END:
X      switch( atoi(number) ){
X      case 0:			/* 0B, 0N, 0U */
X	if( operation('B') )       font_p.symbol_set = LJ_SS_0B;
X	else if( operation('N') )  font_p.symbol_set = LJ_SS_0N;
X	else if( operation('U') )  font_p.symbol_set = LJ_SS_0U;
X#ifdef VERBOSE_WARNINGS
X	else
X	  warning("unknown symbol set -- ignoring", command);
X#endif
X	break;
X      case 1:			/* 1U */
X	if( operation('U') )  font_p.symbol_set = LJ_SS_1U;
X#ifdef VERBOSE_WARNINGS
X	else
X	  warning("unknown symbol set -- ignoring", command);
X#endif
X	break;
X      case 8:			/* 8U */
X	if( operation('U') )  font_p.symbol_set = LJ_SS_8U;
X#ifdef VERBOSE_WARNINGS
X	else
X	  warning("unknown symbol set -- ignoring", command);
X#endif
X	break;
X      case 10:			/* 10U */
X	if( operation('U') )  font_p.symbol_set = LJ_SS_10U;
X#ifdef VERBOSE_WARNINGS
X	else
X	  warning("unknown symbol set -- ignoring", command);
X#endif
X	break;
X      case 11:			/* 11U */
X	if( operation('U') )  font_p.symbol_set = LJ_SS_11U;
X#ifdef VERBOSE_WARNINGS
X	else
X	  warning("unknown symbol set -- ignoring", command);
X#endif
X	break;
X#ifdef VERBOSE_WARNINGS
X      default:
X	warning("unknown symbol set -- ignoring", command);
X#endif
X      } /* switch( number ) */
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X    lj_match_font(&font_p);
X    if( current_font == LJ_FT_PRIMARY ){
X      lj_text_end(ofile);
X      lj_undl_flush(ofile);
X      lj_set_font(ofile, font_p);
X      lj_undl_mark(ofile);
X      lj_text_begin();
X    } /* if( ... ) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_lp() */
X
X
X
Xvoid
Xljcmd_rp(ifile, ofile)		/* Command: ^[) secondary symbol set */
X     FILE *ifile, *ofile;
X{
X
X  warning("command <esc>) is not implemented -- ignoring", "");
X
X  do{
X      /* Read the next token */
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X      break;
X    case PARAM_END:
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_rp() */
X
X
X
Xvoid
Xljcmd_lp_s(ifile, ofile)	/* Command: ^[(s primary font attributes */
X     FILE *ifile, *ofile;
X{
X
X  do{
X      /* Read the next token */
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X    case PARAM_END:
X      if( operation('P') ){	/* Spacing */
X	switch( atoi(number) ){
X	case 0: font_p.spacing = LJ_SP_FIXED; break;
X	case 1: font_p.spacing = LJ_SP_PROPORTIONAL; break;
X	default:
X	  error("unknown primary font spacing code", number);
X	}
X      } /* if( P ) */
X      else if( operation('H') ){ /* Pitch */
X	font_p.pitch = atof(number);
X      } /* else if( H ) */
X      else if( operation('V') ){ /* Point size */
X	font_p.point_size = atof(number);
X      } /* else if( V ) */
X      else if( operation('S') ){ /* Style */
X	switch( atoi(number) ){
X	case 0: font_p.style = LJ_ST_UPRIGHT; break;
X	case 1: font_p.style = LJ_ST_ITALIC;  break;
X	default:
X	  error("unknonw primary font style code", number);
X	}
X      } /* else if( S ) */
X      else if( operation('B') ){ /* Stroke weight */
X	switch( pos_code ){
X	case POS_ABSOLUTE:
X	case POS_REL_POSITIVE:
X	  font_p.weight = atoi(number); break;
X	case POS_REL_NEGATIVE:
X	  font_p.weight = -(atoi(number)); break;
X	default:
X	  internal_error("unknown pos-code in primary font stroke weight", "");
X	}
X      } /* else if( B ) */
X      else if( operation('T') ){ /* Typeface */
X	switch( atoi(number) ){
X	case  4: font_p.typeface = LJ_TF_HELV;  break;
X	case  5: font_p.typeface = LJ_TF_TIMES; break;
X	case  8: font_p.typeface = LJ_TF_PRES;  break;
X	case  0: font_p.typeface = LJ_TF_LP;    break;
X	case  3: font_p.typeface = LJ_TF_COUR;  break;
X	default:
X	  error("unrecognized typeface code (possibly not supported",
X		number);
X	}
X      } /* else if( T ) */
X      else{			/* Unknown command */
X	warning("unknown command with prefix <esc>(s -- ignoring", "");
X      } /* else */
X        /* If at the *end* of the font change command, change the font! */
X      if( curr_token.code == PARAM_END ){
X	lj_match_font(&font_p);
X	if( current_font == LJ_FT_PRIMARY ){
X	  lj_text_end(ofile);
X	  lj_undl_flush(ofile);
X	  lj_set_font(ofile, font_p);
X	  lj_undl_mark(ofile);
X	  lj_text_begin();
X	} /* if( ... ) */
X      } /* if( ... ) */
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_lp_s() */
X
X
X
Xvoid
Xljcmd_rp_s(ifile, ofile)	/* Command: ^[)s secondary font attributes */
X     FILE *ifile, *ofile;
X{
X
X  warning("command family <esc>)s not implemented -- ignoring", "");
X
X  do{
X      /* Read the next token */
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X      break;
X    case PARAM_END:
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_rp_s() */
X
X
X
Xvoid
Xljcmd_amp_a(ifile, ofile)	/* Command: ^[&a margins & movement */
X     FILE *ifile, *ofile;
X{
X
X  do{
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X    case PARAM_END:
X      if( operation('R') ){	/* Move vertically by rows */
X	lj_text_end(ofile);
X	lj_undl_flush(ofile);
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute postioning */
X	  lj_cursor_ver_abs(ofile,
X			    page_height -
X			    (margin_top + char_height + ro2in(atof(number))) );
X	  break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	  lj_cursor_ver_rel(ofile, ro2in(atof(number))); break;
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  lj_cursor_ver_rel(ofile, -(ro2in(atof(number)))); break;
X	default:
X	  internal_error("illegal positioning code", "");
X	}
X	lj_undl_mark(ofile);
X	lj_text_begin();
X      }
X      else if( operation('V') ){ /* Move vertically by decipoints */
X	lj_text_end(ofile);
X	lj_undl_flush(ofile);
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute positioning */
X	  lj_cursor_ver_abs(ofile,
X			    page_height -
X			    (margin_top + dp2in(atof(number)))); break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	  lj_cursor_ver_rel(ofile, dp2in(atof(number))); break;
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  lj_cursor_ver_rel(ofile, -(dp2in(atof(number)))); break;
X	default:
X	  internal_error("illegal positioning code", "");
X	}
X	lj_undl_mark(ofile);
X	lj_text_begin();
X      }
X      else if( operation('C') ){ /* Move horizontally by columns */
X	lj_text_end(ofile);
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute postioning */
X	  lj_cursor_hor_abs(ofile, co2in(atof(number))); break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	  lj_cursor_hor_rel(ofile, co2in(atof(number))); break;
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  lj_cursor_hor_rel(ofile, -(co2in(atof(number)))); break;
X	default:
X	  internal_error("illegal positioning code", "");
X	}
X	lj_text_begin();
X      }
X      else if( operation('H') ){ /* Move horizontally by decipoints */
X	lj_text_end(ofile);
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute positioning */
X	  lj_cursor_hor_abs(ofile, dp2in(atof(number))); break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	  lj_cursor_hor_rel(ofile, dp2in(atof(number))); break;
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  lj_cursor_hor_rel(ofile, -(dp2in(atof(number)))); break;
X	default:
X	  internal_error("illegal positioning code", "");
X	}
X	lj_text_begin();
X      }
X      else if( operation('L') ){ /* Set the left margin */
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute positioning */
X	  margin_left = co2in(atof(number)); break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	  margin_left += co2in(atof(number)); break;
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  margin_left -= co2in(atof(number)); break;
X	default:
X	  internal_error("illegal positioning code", "");
X	}
X	lj_text_end(ofile);
X	fprintf(ofile, "/ml %4f def ", margin_left);
X	if( empty_line ) lj_cursor_hor_abs(ofile, margin_left);
X	lj_text_begin();
X      }
X      else if( operation('M') ){ /* Set the right margin */
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute positioning */
X	  text_width = co2in((atof(number) + 1)) - margin_left; break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	  text_width += co2in(atof(number)); break;
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  text_width -= co2in(atof(number)); break;
X	default:
X	  internal_error("illegal positioning code", "");
X	} /* switch( pos_code ) */
X	lj_text_end(ofile);
X	fprintf(ofile, "%.4f RM ", /* Reset the clipping path */
X		margin_left + text_width);
X	lj_text_begin();
X      } /* else if( M ) */
X      else{			/* Unknown command */
X	warning("unknown command with prefix <esc>&a -- ignoring", "");
X      } /* else */
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_amp_a() */
X
X
X
Xvoid
Xljcmd_amp_d(ifile, ofile)	/* Command: ^[&d underline */
X     FILE *ifile, *ofile;
X{
X
X  do{
X      /* Read the next token */
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X    case PARAM_END:
X      if( operation('D') ){
X	  /* Note: you *must* end the text before setting underline mode.
X	  ** Otherwise, the text printed *before* underlining is turned on
X	  ** is not flushed from the text buffer, and will also be
X	  ** underlined.
X	  */
X	lj_text_end(ofile);
X	lj_undl_begin(ofile);
X	lj_text_begin();
X      }
X      else if( operation('@') ){
X	lj_text_end(ofile);
X        lj_undl_end(ofile);
X        lj_text_begin();
X      }
X      else{			/* Unknown command */
X	warning("unknown command with prefix <esc>&d -- ignoring", "");
X      }
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_amp_d() */
X
X
X
Xvoid
Xljcmd_amp_f(ifile, ofile)	/* Command: ^[&f macros, position stack */
X     FILE *ifile, *ofile;
X{
X
X  warning("command family <esc>&f not implemented -- ignoring", "");
X
X  do{
X      /* Read the next token */
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X      break;
X    case PARAM_END:
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_amp_f() */
X
X
X
Xvoid
Xljcmd_amp_k(ifile, ofile)	/* Command: ^[&k HMI, pitch, line termination*/
X     FILE *ifile, *ofile;
X{
X
X  do{
X      /* Read the next token */
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X    case PARAM_END:
X      if( operation('H') ){	/* Set HMI */
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute postioning */
X	  char_width  = hi2in(atof(number)); break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	  char_width += hi2in(atof(number)); break;
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  char_width -= hi2in(atof(number)); break;
X	default:
X	  internal_error("illegal positioning code", "");
X	}
X      } /* if( K ) */
X      else{			/* Unknown command */
X	warning("unknown command with prefix <esc>&k -- ignoring", "");
X      }
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_amp_k() */
X
X
X
Xvoid
Xljcmd_amp_l(ifile, ofile)	/* Command: ^[&l page attributes */
X     FILE *ifile, *ofile;
X{
X  double tmp;
X  int old_orientation;
X
X  do{
X      /* Read the next token */
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X    case PARAM_END:
X      if( operation('A') ){ /* Set the page size */
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute positioning */
X	  switch( atoi(number) ){
X	  case  1:		/* Executive */
X	    page_size.code = LJ_PS_EXECUTIVE;
X	    warning("EXECUTIVE paper size is not available", "");
X	    break;
X	  case  2:		/* Letter */
X	    page_size.code = LJ_PS_LETTER;
X	    lj_text_end(ofile);
X	    fputs("letter ", ofile);
X	    lj_text_begin();
X	    warning("paper changed to LETTER size", "");
X	    break;
X	  case  3:		/* Legal */
X	    page_size.code = LJ_PS_LEGAL;
X	    lj_text_end(ofile);
X	    fputs("legal ", ofile);
X	    lj_text_begin();
X	    warning("paper changed to LEGAL size", "");
X	    break;
X	  case 26:		/* A4 */
X	    page_size.code = LJ_PS_A4;
X	    lj_text_end(ofile);
X	    fputs("a4 ", ofile);
X	    lj_text_begin();
X	    warning("paper changed to A4 size", "");
X	    break;
X	  case 80:		/* Monarch */
X	    page_size.code = LJ_PS_MONARCH;
X	    warning("MONARCH envelope size is not available", "");
X	    break;
X	  case 81:		/* Commercial 10 */
X	    page_size.code = LJ_PS_COMMERCIAL10;
X	    warning("COMMERCIAL-10 envelope size is not available", "");
X	    break;
X	  case 90:		/* International DL */
X	    page_size.code = LJ_PS_INTERNATIONALDL;
X	    warning("INTERNATIONAL-DL envelope size is not available", "");
X	    break;
X	  case 91:		/* International C5 */
X	    page_size.code = LJ_PS_INTERNATIONALC5;
X	    warning("INTERNATIONAL-C5 envelope size is not available", "");
X	    break;
X	  default:
X	    error("illegal paper size code", number);
X	  } /* switch( number ) */
X	    /* Find the correct paper size parameters */
X	  if( lj_paper_size(&page_size) ){
X	    internal_error("illegal page size", "");
X	  }
X	    /* Set the new page width and height */
X	  if( orientation == LJ_OR_PORTRAIT ){
X	    page_width = page_size.width;
X	    page_height = page_size.height;
X	  }
X	  else{
X	    page_width = page_size.height;
X	    page_height = page_size.width;
X	  }
X	    /* Reset several page control parameters */
X	  margin_top  = 0.5;		/* Top and bottom margins are 1/2" */
X	  text_height = page_height - margin_top - 0.5;
X	  char_height = text_height / panel_form;
X	  char_width  = font_p.width;	/* inches per character */
X	  text_length = text_height / char_height;
X	    /* Flush the current page */
X	  lj_page_end(ofile);
X	  lj_page_begin();
X	  break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  error("cannot use relative page size codes!", number);
X	default:
X	  internal_error("illegal positioning code", "");
X	}
X      } /* else if( A ) */
X      else if( operation('C') ){	/* Set VMI */
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute postioning */
X	  char_height  = vi2in(atof(number)); break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	  char_height += vi2in(atof(number)); break;
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  char_height -= vi2in(atof(number)); break;
X	default:
X	  internal_error("illegal positioning code", "");
X	}
X      } /* else if( C ) */
X      else if( operation('D') ){	/* Set lines per inch */
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute postioning */
X	  char_height  = 1 / atof(number); break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	  char_height += 1 / atof(number); break;
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  char_height -= 1 / atof(number); break;
X	default:
X	  internal_error("illegal positioning code", "");
X	}
X      } /* else if( D ) */
X      else if( operation('E') ){ /* Set the top margin */
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute positioning */
X	  margin_top =  ro2in(atof(number)); break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	  margin_top -= ro2in(atof(number)); break;
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  margin_top += ro2in(atof(number)); break;
X	default:
X	  internal_error("illegal positioning code", "");
X	}
X	if( empty_page ){
X	  current_x    = margin_left;
X	  current_y    = page_height - margin_top - char_height;
X	  current_line = 1;
X	  lj_cursor_abs(ofile, current_x, current_y);
X	}
X      }
X      else if( operation('F') ){ /* Set the text length */
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute positioning */
X	  text_length =  atoi(number); break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	  text_length += atoi(number); break;
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  text_length -= atoi(number); break;
X	default:
X	  internal_error("illegal positioning code", "");
X	}
X	  /* Reset the text_height */
X	text_height = text_length * char_height;
X      } /* else if( F ) */
X      else if( operation('H') ){ /* Set the paper source */
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute positioning */
X	  switch( atoi(number) ){
X	  case 0:		/* Eject current page */
X	    lj_page_end(ofile);
X	    lj_page_begin(ofile);
X	    break;
X	  case 1:		/* Feed from the internal tray */
X	    paper_source = LJ_PS_TRAY_1;
X	    lj_page_end(ofile);
X	    lj_page_begin(ofile);
X	    lj_text_end(ofile);
X	    fputs("statusdict begin /manualfeed false def end\n", ofile);
X	    lj_text_begin();
X	    break;
X	  case 2:		/* Manual feed */
X	    if(   (page_size.code == LJ_PS_EXECUTIVE)
X	       || (page_size.code == LJ_PS_LETTER)
X	       || (page_size.code == LJ_PS_LEGAL)
X	       || (page_size.code == LJ_PS_A4) ){
X	      paper_source = LJ_PS_MANUAL;
X	    }
X	    else{
X	      paper_source = LJ_PS_MANUAL_ENVELOPE;
X	    }
X	    lj_page_end(ofile);
X	    lj_page_begin(ofile);
X	    lj_text_end(ofile);
X	    fputs("statusdict begin /manualfeed true def end\n", ofile);
X	    lj_text_begin();
X	    break;
X	  default:
X	    error("illegal paper source code -- ignoring", number);
X	  }
X	  break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  error("illegal paper source code -- ignoring", number);
X	  break;
X	default:
X	  internal_error("illegal positioning code", "");
X	}
X      } /* else if( H ) */
X      else if( operation('O') ){ /* Set the page orientation */
X	old_orientation = orientation;
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute positioning */
X	case POS_REL_POSITIVE:	/* Relative positive */
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  switch( atoi(number) ){
X	  case 0:		/* Portrait */
X	    orientation = LJ_OR_PORTRAIT;  break;
X	  case 1:		/* Landscape */
X	    orientation = LJ_OR_LANDSCAPE; break;
X	  default:
X	    warning("illegal page orientation -- ignoring", "");
X	  } /* switch( number ) */
X	  break;
X	default:
X	  internal_error("illegal page orientation", "");
X	}
X	if( orientation != old_orientation ){
X	  lj_page_end(ofile);
X	  if( orientation == LJ_OR_PORTRAIT ){ /* Set new width & height */
X	    page_width = page_size.width;
X	    page_height = page_size.height;
X	  }
X	  else{
X	    page_width = page_size.height;
X	    page_height = page_size.width;
X	  }
X	  lj_page_begin(ofile);
X	} /* if( change in orientation ) */
X      } /* else if( O ) */
X      else if( operation('X') ){ /* Set the number of copies */
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute positioning */
X	  copies  = atoi(number); break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	  copies += atoi(number); break;
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  copies -= atoi(number); break;
X	default:
X	  internal_error("illegal number of copies", "");
X	}
X	lj_text_end(ofile);
X	lj_copies(ofile, copies);
X	lj_text_begin();
X      } /* else if( X ) */
X      else{			/* Unknown command */
X	warning("unknown command with prefix <esc>&l -- ignoring", "");
X      }
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_amp_l() */
X
X
X
Xvoid
Xljcmd_amp_p(ifile, ofile)	/* Command: ^[&p transparent print data */
X     FILE *ifile, *ofile;
X{
X
X  warning("command family <esc>&p not implemented -- ignoring", "");
X
X  do{
X      /* Read the next token */
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X      break;
X    case PARAM_END:
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_amp_p() */
X
X
X
Xvoid
Xljcmd_amp_s(ifile, ofile)	/* Command: ^[&s end-of-line wrap */
X     FILE *ifile, *ofile;
X{
X
X  warning("command family <esc>&s not implemented -- ignoring", "");
X
X  do{
X      /* Read the next token */
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X      break;
X    case PARAM_END:
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_amp_s() */
X
X
X
Xvoid
Xljcmd_star_b(ifile, ofile)	/* Command: ^[*b bitmap transfer */
X     FILE *ifile, *ofile;
X{
X
X  warning("command family <esc>*b not implemented -- ignoring", "");
X
X  do{
X      /* Read the next token */
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X      break;
X    case PARAM_END:
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_star_b() */
X
X
X
Xvoid
Xljcmd_star_c(ifile, ofile)	/* Command: ^[*c graphics, soft fonts */
X     FILE *ifile, *ofile;
X{
X
X  warning("command family <esc>*c not implemented -- ignoring", "");
X
X  do{
X      /* Read the next token */
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X      break;
X    case PARAM_END:
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_star_c() */
X
X
X
Xvoid
Xljcmd_star_p(ifile, ofile)	/* Command: ^[*p device-dependent movement */
X     FILE *ifile, *ofile;
X{
X
X  do{
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X    case PARAM_END:
X      if( operation('X') ){	/* Move horizontally by dots*/
X	lj_text_end(ofile);
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute postioning */
X	  lj_cursor_hor_abs(ofile, dt2in(atof(number))); break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	  lj_cursor_hor_rel(ofile, dt2in(atof(number))); break;
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  lj_cursor_hor_rel(ofile, -(dt2in(atof(number)))); break;
X	default:
X	  internal_error("illegal positioning code", "");
X	}
X	lj_text_begin();
X      }
X      else if( operation('Y') ){ /* Move vertically by dots */
X	lj_text_end(ofile);
X	lj_undl_flush(ofile);
X	switch( pos_code ){
X	case POS_ABSOLUTE:	/* Absolute postioning */
X	  lj_cursor_ver_abs(ofile,
X			    page_height -
X			    (margin_top + dt2in(atof(number))));
X	  break;
X	case POS_REL_POSITIVE:	/* Relative positive */
X	  lj_cursor_ver_rel(ofile, dt2in(atof(number))); break;
X	case POS_REL_NEGATIVE:	/* Relative negative */
X	  lj_cursor_ver_rel(ofile, -(dt2in(atof(number)))); break;
X	default:
X	  internal_error("illegal positioning code", "");
X	}
X	lj_undl_mark(ofile);
X	lj_text_begin();
X      } /* else if( Y ) */
X      else{			/* Unknown command */
X	warning("unknown command with prefix <esc>*p -- ignoring", "");
X      }
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_star_p() */
X
X
X
Xvoid
Xljcmd_star_r(ifile, ofile)	/* Command: ^[*r start/end graphics */
X     FILE *ifile, *ofile;
X{
X
X  warning("command family <esc>*r is not implemented -- ignoring", "");
X
X  do{
X      /* Read the next token */
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X      break;
X    case PARAM_END:
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_star_r() */
X
X
Xvoid
Xljcmd_star_t(ifile, ofile)	/* Command: ^[*t graphics resolution */
X     FILE *ifile, *ofile;
X{
X
X  warning("command family <esc>*t is not implemented -- ignoring", "");
X
X  do{
X      /* Read the next token */
X      /* If EOF is reached, then flag an error and return */
X    if( (scan() == 0) && (curr_token.code == PARAM_CONTINUE) ){
X      error("end-of-file reached while reading parameters", variable);
X    }
X#ifdef DEBUG
X    if( debug ) fprintf(stderr, "{TOKEN:%d}", curr_token.code);
X#endif
X    switch( curr_token.code ){
X    case PARAM_CONTINUE:
X      break;
X    case PARAM_END:
X      break;
X    default:
X      internal_error("illegal token encountered in parameters", "");
X    } /* switch(...) */
X  } while( curr_token.code != PARAM_END );
X
X} /* ljcmd_star_t() */
SHAR_EOF
$TOUCH -am 0630160790 ljcmds.c &&
chmod 0644 ljcmds.c ||
echo "restore of ljcmds.c failed"
set `wc -c ljcmds.c`;Wc_c=$1
if test "$Wc_c" != "33110"; then
	echo original size 33110, current size $Wc_c
fi
fi
# ============= ljcmds.h ==============
if test X"$1" != X"-c" -a -f 'ljcmds.h'; then
	echo "File already exists: skipping 'ljcmds.h'"
else
echo "x - extracting ljcmds.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > ljcmds.h &&
X/*
X** Project:		lj2ps
X** File:		ljcmds.h
X**
X** Author:		Christopher Lishka
X** Organization:	Wisconsin State Laboratory of Hygiene
X**			Data Processing Dept.
X**
X** Copyright (C) 1990 by Christopher Lishka.
X**
X** This program is free software; you can redistribute it and/or modify
X** it under the terms of the GNU General Public License as published by
X** the Free Software Foundation; either version 1, or (at your option)
X** any later version.
X**
X** This program is distributed in the hope that it will be useful,
X** but WITHOUT ANY WARRANTY; without even the implied warranty of
X** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X** GNU General Public License for more details.
X**
X** You should have received a copy of the GNU General Public License
X** along with this program; if not, write to the Free Software
X** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X*/
X
X#ifndef LJCMDS_H
X#define LJCMDS_H
X
X  /* Global constants
X  */
X
X  /* Global structure and type definitions
X  */
X
X  /* Global variables
X  */
X
X  /* Global macro definitions
X  */
X
X  /* Global functions
X  */
Xextern void  ljcmd_undefined();	/* Command: undefined */
Xextern void  ljcmd_E();		/* Command: ^[E  reset */
Xextern void  ljcmd_Y();		/* Command: ^[Y  display functions on */
Xextern void  ljcmd_Z();		/* Command: ^[Z  display functions off */
Xextern void  ljcmd_9();		/* Command: ^[9  clear margins */
Xextern void  ljcmd_eq();	/* Command: ^[=  half-line feed */
Xextern void  ljcmd_lp();	/* Command: ^[(  primary symbol set */
Xextern void  ljcmd_rp();	/* Command: ^[)  secondary symbol set */
Xextern void  ljcmd_lp_s();	/* Command: ^[(s primary font attributes */
Xextern void  ljcmd_rp_s();	/* Command: ^[)s secondary font attributes */
Xextern void  ljcmd_amp_a();	/* Command: ^[&a margins & movement */
Xextern void  ljcmd_amp_d();	/* Command: ^[&d underline */
Xextern void  ljcmd_amp_f();	/* Command: ^[&f macros, position stack */
Xextern void  ljcmd_amp_k();	/* Command: ^[&k HMI, pitch, line termination*/
Xextern void  ljcmd_amp_l();	/* Command: ^[&l page attributes */
Xextern void  ljcmd_amp_p();	/* Command: ^[&p transparent print data */
Xextern void  ljcmd_amp_s();	/* Command: ^[&s end-of-line wrap */
Xextern void  ljcmd_star_b();	/* Command: ^[*b bitmap transfer */
Xextern void  ljcmd_star_c();	/* Command: ^[*c graphics, soft fonts */
Xextern void  ljcmd_star_p();	/* Command: ^[*p device-dependent movement */
Xextern void  ljcmd_star_r();	/* Command: ^[*r start/end graphics */
Xextern void  ljcmd_star_t();	/* Command: ^[*t graphics resolution */
X
X#endif
SHAR_EOF
$TOUCH -am 0630160790 ljcmds.h &&
chmod 0644 ljcmds.h ||
echo "restore of ljcmds.h failed"
set `wc -c ljcmds.h`;Wc_c=$1
if test "$Wc_c" != "2558"; then
	echo original size 2558, current size $Wc_c
fi
fi
echo "End of part 10, continue with part 11"
exit 0