[comp.sources.misc] v13i119: lj2ps 1.2

lishka@uwslh.slh.wisc.edu (Chris Lishka (hang loose...) ) (07/10/90)

Posting-number: Volume 13, Issue 119
Submitted-by: lishka@uwslh.slh.wisc.edu (Chris Lishka (hang loose...) )
Archive-name: lj2ps-1.2/part11

---- Cut Here and unpack ----
#!/bin/sh
# this is lj2ps.11 (part 11 of a multipart archive)
# do not concatenate these parts, unpack them in order with /bin/sh
# file lj.h continued
#
if touch 2>&1 | fgrep '[-amc]' > /dev/null
 then TOUCH=touch
 else TOUCH=true
fi
if test ! -r @shar_seq_.tmp; then
	echo "Please unpack part 1 first!"
	exit 1
fi
(read Scheck
 if test "$Scheck" != 11; then
	echo "Please unpack part $Scheck next!"
	exit 1
 else
	exit 0
 fi
) < @shar_seq_.tmp || exit 1
echo "x - Continuing file lj.h"
sed 's/^X//' << 'SHAR_EOF' >> lj.h &&
Xextern double ps_scale_x;	/* PS: scale in x direction */
Xextern double ps_scale_y;	/* PS: scale in y direction */
Xextern double ps_offset_x;	/* PS: offset in x direction */
Xextern double ps_offset_y;	/* PS: offset in y direction */
X  /* Job control */
Xextern int     copies;		/* Number of copies */
X  /* Page control */
Xextern int     paper_source;	/* Where the paper is coming from */
Xextern int     orientation;	/* Portrait/landscape	      (code)	  */
Xextern psize   page_size;	/* Type of paper being used   (structure) */
Xextern double  page_height;	/* Height of physical page    (inches)	  */
Xextern double  page_width;	/* Width of physical page     (inches)	  */
Xextern double  char_height;	/* Char height (~= VMI)	      (inches)	  */
Xextern double  char_width;	/* Char width  (~= HMI)	      (inches)	  */
Xextern double  margin_top;	/* Top margin                 (inches)	  */
Xextern int     text_length;	/* Text length		      (lines)	  */
Xextern double  text_height;	/* Text height                (inches)	  */
Xextern double  margin_left;	/* Left margin                (inches)    */
Xextern double  text_width;	/* Text width                 (inches)	  */
Xextern int     perf_skip;	/* 1 if perforation skip is on */
Xextern int     line_term;	/* Current line termination mode */
X  /* Fonts */
Xextern ljfont  font_p;		/* Primary font */
Xextern ljfont  font_s;		/* Secondary font */
Xextern int     underline;	/* Underline mode */
X  /* Font management */
Xextern int     font_ID;		/* Current font ID */
Xextern int     char_code;	/* Current character code */
X  /* Raster graphics */
Xextern int     resolution;	/* Current graphics resolution */
Xextern int     margin_graphics;	/* Graphics left margin, in dots? */
X  /* Rectangular area fill */
Xextern int     rect_size_h;	/* Horizontal rectangle size */
Xextern int     rect_size_v;	/* Vertical rectangle size */
Xextern int     fill_ID;		/* Current area fill ID */
X  /* Macro */
Xextern int     macro_ID;	/* Current macro ID */
X  /* Troubleshooting commands */
Xextern int     eol_wrap;	/* End-of-line wrap on/off */
Xextern int     display_func;	/* Display functions on/off */
X  /* Implementation variables */
Xextern double  current_x;	/* Current X position         (inches)	  */
Xextern double  current_y;	/* Current Y position         (inches)	  */
Xextern int     current_line;	/* Current line being printed (lines)     */
Xextern int     current_font;	/* Primary or secondary	      (code)	  */
Xextern int     empty_line;	/* True if line is empty      (boolean)   */
Xextern int     empty_text;	/* True if text is empty      (boolean)   */
Xextern int     empty_page;	/* True if page is empty      (boolean)	  */
Xextern double  compress_width;	/* Compression in x axis      (%)	  */
Xextern double  compress_height;	/* Compression in y axis      (%)	  */
Xextern double  offset_width;	/* Offset of x axis           (inches)    */
Xextern double  offset_height;	/* Offset of y axis           (inches)    */
X
X  /* Global macro definitions
X  */
X  /* Conversion macros */
X#define dt2in(x)  (x/dt)	/* Dots to inches */
X#define in2dt(x)  (x*dt)	/* Inches to dots */
X#define dp2in(x)  (x/dp)	/* Decipoints to inches */
X#define in2dp(x)  (x*dp)	/* Inches to decipoints */
X#define hi2in(x)  (x/hi)	/* Horizontal index units to inches */
X#define in2hi(x)  (x*hi)	/* Inches to horizontal index units */
X#define vi2in(x)  (x/vi)	/* Vertical index units to inches */
X#define in2vi(x)  (x*vi)	/* Inches to vertical index units */
X#define pt2in(x)  (x/pt)	/* Points to inches */
X#define in2pt(x)  (x*pt)	/* Inches to points */
X#define co2in(x)  (x*char_width) /* Columns to inches */
X#define in2co(x)  (x/char_width) /* Inches to columns */
X#define ro2in(x)  (x*char_height) /* Rows to inches */
X#define in2ro(x)  (x/char_height) /* Inches to rows */
X  /* Emulation macros */
X  /* Text buffer macros */
X#define lj_text_begin()   \
X  ( empty_text = 1 )
X#define lj_text_add(F, X) \
X  ( (empty_text?fprintf((F),"(%s",X):fputs((X),(F))), \
X   empty_text = 0, empty_line = 0, empty_page = 0 )
X#define lj_text_end(F) \
X  ( (!empty_text) \
X   ? fputs(")S ",F) \
X   : 0)
X  /* Cursor positioning macros */
X#define lj_cursor_abs(F, X, Y) \
X  (current_x = (X), current_y = (Y), \
X   fprintf(F, "%.4f %.4f M ", current_x, current_y))
X#define lj_cursor_hor_abs(F, X) \
X  (current_x = (X), fprintf(F, "%.4f %.4f M ", current_x, current_y))
X#define lj_cursor_hor_rel(F, dX) \
X  (fprintf(F, "%.4f HRM ", (dX)))
X#define lj_cursor_ver_abs(F, Y) \
X  (current_y = (Y), fprintf(F, "%.4f VM ", current_y))
X#define lj_cursor_ver_rel(F, dY) \
X  (current_y -= (dY), fprintf(F, "%.4f VM ", current_y))
X  /* Font macros */
X#define lj_set_font(Z, X) \
X  ( char_width = (X).width, \
X   ( (X).scale \
X   ? fprintf((Z), "/%s %.4f %.4f FS ", (X).ps_name, \
X	     pt2in((X).point_size) * (X).scale_x, \
X	     pt2in((X).point_size) * (X).scale_y) \
X   : fprintf((Z), "/%s %.4f F ", \
X	     (X).ps_name, \
X	     pt2in((X).point_size)) ) )
X  /* Underlining macros */
X#define lj_undl_begin(F)  (underline = LJ_UL_ON,  fputs("US ", (F)))
X#define lj_undl_mark(F) \
X  ( (underline == LJ_UL_ON) \
X   ? (fputs("US ", (F))) \
X   : 0 )
X#define lj_undl_flush(F) \
X  ( (underline == LJ_UL_ON) \
X   ? (fputs("UE ", (F))) \
X   : 0 )
X#define lj_undl_end(F)    (underline = LJ_UL_OFF, fputs("UE ", (F)))
X  /* Number of copies */
X#define lj_copies(F, C) \
X  ( fprintf((F), "/#copies %d def ", (C)) )
X
X  /* Global functions
X  */
Xextern void  lj_factory_setup(); /* Reset to factory defaults */
Xextern void  lj_startup();	/* Do before the virtual LJ is ready... */
Xextern void  lj_shutdown();	/* Do after the virtual LJ is shutdown... */
Xextern void  lj_page_begin();	/* Start a new page */
Xextern void  lj_page_end();	/* End the current page */
X/*     macro lj_text_begin();*/ /* Start text */
X/*     macro lj_text_add(); */  /* Add text to the buffer */
X/*     macro lj_text_end(); */  /* End text */
X/*     macro lj_cursor_abs();*/ /* Absolute X,Y cursor positioning */
X/*     macro lj_cursor_hor_abs(); */ /* Absolute X cursor positioning */
X/*     macro lj_cursor_hor_rel(); */ /* Relative X cursor positioning */
X/*     macro lj_cursor_ver_abs(); */ /* Absolute Y cursor positioning */
X/*     macro lj_cursor_ver_rel(); */ /* Relative Y cursor positioning */
X/*     macro lj_set_font(); */  /* Use a new font to print the text */
X/*     macro lj_undl_begin();*/	/* Start underlining */
X/*     macro lj_undl_mark();*/  /* Mark the start of a new underline */
X/*     macro lj_undl_flush();*/	/* Flush the current underline buffer */
X/*     macro lj_undl_end(); */	/* End underlining */
X/*     macro lj_copies(); */    /* Set the number of copies */
Xextern void  lj_nl();		/* Print a newline */
Xextern void  lj_reset();	/* Reset the printer to default state */
Xextern int   lj_paper_size();	/* Get the dimensions of paper and envelopes */
X
X#endif
X
SHAR_EOF
echo "File lj.h is complete" &&
$TOUCH -am 0707112690 lj.h &&
chmod 0644 lj.h ||
echo "restore of lj.h failed"
set `wc -c lj.h`;Wc_c=$1
if test "$Wc_c" != "13148"; then
	echo original size 13148, current size $Wc_c
fi
# ============= lj2ps.c ==============
echo "x - extracting lj2ps.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > lj2ps.c &&
X/* Project:        lj2ps
X** File:	   lj2ps.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 lj2ps: 1.2, release";
Xstatic char *RCSid = "$Header: lj2ps.c,v 1.2 90/07/07 11:03:46 lishka Production $";
X
X  /* Include files
X  */
X#include <stdio.h>
X#include <math.h>
X#include "lj2ps.h"
X#include "lj.h"
X#include "trans.h"
X#include "errors.h"
X
X  /* External definitions
X  */
X
X  /* Global variables
X  */
X#ifdef DEBUG
Xint    debug;			/* True if debugging is on */
X#endif
Xint    warnings;		/* True if warnings are printed */
X
X  /* Global function list
X  */
Xextern int   main();
X
X  /* Local constants
X  */
X#define MAX_NAME 256
X
X  /* Local structures and types
X  */
X
X  /* Local variables
X  */
X
X  /* Local macro definitions
X  */
X#define option(x)    (!(strncmp(x, argv[counter], strlen(x))))
X#define argument(x)  (&(argv[counter][strlen(x)]))
X#define file()       (argv[counter][0] != '-')
X
X  /* Local function list
X  */
Xstatic void  syntax();
X
X  /* Function bodies
X  */
X
X  /* syntax() prints the legal syntax of this program to stderr
X  */
Xstatic void
Xsyntax(stream)
X     FILE *stream;
X{
X
X  fprintf(stream, "%s %s (%s): the correct syntax is\n",
X	  PROGRAM, VERSION, STATUS);
X  fprintf(stream, "     %s [options] [files]\n", PROGRAM);
X  fputs("\
XIf no files are listed, input is taken from stdin.\n\
XThe following options are recognized (## indicates an argument):\n\
X\n\
X    LaserJet II Front Panel Selections:                      Default:\n\
X        -c##     Number of copies                              1 copy\n\
X        -mf      Manual feed                                   Automatic feed\n\
X        -fs##    Font source (left, right, internal, or soft)  Internal\n\
X        -fn##    Font number                                   Font 0\n\
X        -fl##    Form length                                   60 lines\n\
X    Page Orientation:\n\
X        -p       Portrait mode                                 Portrait mode\n\
X        -l       Landscape mode                                Portrait mode\n\
X    Page Scaling and Offsets:\n\
X        -xs##    Scale the width (x axis)                      1.0\n\
X        -xo##    Offset of left margin (x axis)                0.0\n\
X        -ys##    Scale the length (y axis)                     1.0\n\
X        -yo##    Offset of top margin (y axis)                 0.0\n\
X    Miscellaneous:\n\
X        -X       Print this syntax list\n\
X        -w       Do not print warning messages                 Print warnings\n\
X", stream);
X#ifdef DEBUG
X  fputs("\
X        -d##     Debug level (0 = off)                         Off (0)\n\
X", stream);
X#endif
X
X} /* syntax() */
X
X
X  /* main() hands off the work to the appropriate functions, as needed.
X  */
Xint
Xmain(argc, argv)
X    int argc; char *argv[];
X{
X  int   arguments;		/* True while still reading the arguments */
X  int   counter;		/* Generic counter */
X  FILE *input_file;		/* Current file being read */
X  FILE *output_file;		/* The file where stuff should be written */
X  int   tmp_form;		/* Temporary storage for panel_form */
X
X    /* Turn warnings on */
X  warnings = 1;
X
X    /* Only stdout is being written to */
X  output_file = stdout;
X
X    /* Set the "factory defaults" */
X  lj_factory_setup();		/* Like you just took it out of the box! */
X
X    /* Parse the command line */
X  tmp_form = -1;
X  arguments = 1;
X  for( counter = 1; arguments && (counter < argc); counter++ ){
X
X    if( option("-X") ){  syntax(stdout); exit(0);  }
X
X#ifdef DEBUG
X      /* -d: debug */
X    else if( option("-d") ){
X      warning("debugging mode is on", "");
X      debug = atoi(argument("-d"));
X    }
X#endif
X
X      /* -w: turn off warnings */
X    else if( option("-w") ){  warnings = 0; }
X
X      /* -c: number of copies */
X    else if( option("-c") ){  panel_copies = atoi(argument("-c"));  }
X
X      /* -mf: manual feed */
X    else if( option("-mf") ){ panel_manual_feed = LJ_PS_MANUAL;  }
X
X      /* -fs: font source */
X    else if( option("-fs") ){
X      if(   (strcmp(argument("-fs"), "L") == 0)
X	 || (strcmp(argument("-fs"), "l") == 0)
X	 || (strcmp(argument("-fs"), "Left") == 0)
X	 || (strcmp(argument("-fs"), "left") == 0)
X	 || (strcmp(argument("-fs"), "LEFT") == 0) ){
X	panel_font_source = LJ_FS_LEFT;
X      }
X      else if(   (strcmp(argument("-fs"), "R") == 0)
X	      || (strcmp(argument("-fs"), "r") == 0)
X	      || (strcmp(argument("-fs"), "Right") == 0)
X	      || (strcmp(argument("-fs"), "right") == 0)
X	      || (strcmp(argument("-fs"), "RIGHT") == 0) ){
X	panel_font_source = LJ_FS_RIGHT;
X      }
X      else if(   (strcmp(argument("-fs"), "I") == 0)
X	      || (strcmp(argument("-fs"), "i") == 0)
X	      || (strcmp(argument("-fs"), "Internal") == 0)
X	      || (strcmp(argument("-fs"), "internal") == 0)
X	      || (strcmp(argument("-fs"), "INTERNAL") == 0) ){
X	panel_font_source = LJ_FS_INTERNAL;
X      }
X      else if(   (strcmp(argument("-fs"), "S") == 0)
X	      || (strcmp(argument("-fs"), "s") == 0)
X	      || (strcmp(argument("-fs"), "Soft") == 0)
X	      || (strcmp(argument("-fs"), "soft") == 0)
X	      || (strcmp(argument("-fs"), "SOFT") == 0) ){
X	panel_font_source = LJ_FS_SOFT;
X      }
X      else{
X	syntax(stderr);
X	fatal_error("unrecognized font source", argument("-fs"));
X      }
X    } /* if( -fs ) */
X
X      /* -fn: font number */
X    else if( option("-fn") ){ panel_font_number = atoi(argument("-fn")); }
X
X      /* -p: portrait mode */
X    else if( option("-p") ){  panel_orientation = LJ_OR_PORTRAIT;  }
X
X      /* -l: landscape mode */
X    else if( option("-l") ){  panel_orientation = LJ_OR_LANDSCAPE; }
X
X      /* -fl: text length (i.e. lines per page) */
X    else if( option("-fl") ){ tmp_form = atoi(argument("-fl"));    }
X
X      /* -xs: scale in the x direction */
X    else if( option("-xs") ){ ps_scale_x = atof(argument("-xs"));  }
X
X      /* -ys: scale in the y direction */
X    else if( option("-ys") ){ ps_scale_y = atof(argument("-ys"));  }
X
X      /* -xo: offset in the x direction */
X    else if( option("-xo") ){ ps_offset_x = atof(argument("-xo")); }
X
X      /* -yo: offset in the y direction */
X    else if( option("-yo") ){ ps_offset_y = -(atof(argument("-yo"))); }
X
X      /* File argument */
X    else if( file() ){
X      arguments = 0;
X      break;
X    } /* if( file ) */
X
X    else{ syntax(stdout); fatal_error("unrecognized option", argv[counter]); }
X    
X  } /* for(...) */
X
X    /* Adjust the default text length to the orientation */
X  if( tmp_form > 0 ){
X    panel_form = tmp_form;
X  }
X  else{
X    if( panel_orientation == LJ_OR_LANDSCAPE ){
X      panel_form = 45;
X    }
X  }
X
X    /* Initialize the postscript file */
X  lj_startup(output_file);
X  lj_page_begin(output_file);
X
X    /* Transform the input */
X  if( arguments ){
X    transform(stdin, output_file);
X  } /* if */
X  else{
X    for( ; counter < argc; counter ++ ){
X      if( (input_file = fopen(argv[counter], "r")) == (FILE *) NULL ){
X	fatal_error("unable to open input file", argv[counter]);
X      }
X      transform(input_file, output_file); /* Transform LJ PCL -> Postscript */
X      if( fclose(input_file) == EOF ){
X	internal_error("unable to close input file", argv[counter]);
X      }
X    } /* for */
X  } /* else */
X
X    /* Finish up the postscript job */
X  lj_page_end(output_file);
X  lj_shutdown(output_file);
X
X    /* To shut lint and tcc up! */
X  return( 0 );
X
X} /* main() */
SHAR_EOF
$TOUCH -am 0707112690 lj2ps.c &&
chmod 0644 lj2ps.c ||
echo "restore of lj2ps.c failed"
set `wc -c lj2ps.c`;Wc_c=$1
if test "$Wc_c" != "8088"; then
	echo original size 8088, current size $Wc_c
fi
# ============= lj2ps.h ==============
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.2"
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 0707112690 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
# ============= ljcmds.c ==============
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 */
SHAR_EOF
echo "End of  part 11"
echo "File ljcmds.c is continued in part 12"
echo "12" > @shar_seq_.tmp
exit 0