home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-07-02 | 48.7 KB | 1,481 lines |
- Newsgroups: comp.sources.misc
- subject: v13i094: lj2ps (09 of 12), a LaserJet to PostScript Translator
- From: lishka@uwslh.slh.wisc.edu (Chris Lishka (relaxing in the Mad-City) )
- Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 13, Issue 94
- Submitted-by: lishka@uwslh.slh.wisc.edu (Chris Lishka (relaxing in the Mad-City) )
- Archive-name: lj2ps/part09
-
- ---- Cut Here and unpack ----
- #!/bin/sh
- # This is part 09 of a multipart archive
- if touch 2>&1 | fgrep '[-amc]' > /dev/null
- then TOUCH=touch
- else TOUCH=true
- fi
- # ============= errors.c ==============
- if test X"$1" != X"-c" -a -f 'errors.c'; then
- echo "File already exists: skipping 'errors.c'"
- else
- echo "x - extracting errors.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > errors.c &&
- X/* Project: lj2ps, LaserJet PCL to PostScript translator
- X** File: errors.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 errors: v1.0, production";
- X
- X#include <stdio.h>
- X#include "errors.h"
- X#include "lj2ps.h"
- X
- X
- X /* Functions */
- Xextern void warning();
- Xextern void error();
- Xextern void fatal_error();
- Xextern void internal_error();
- X
- X
- X
- X /* warning() prints a message to stderr about a minor problem.
- X */
- Xvoid
- Xwarning(message, argument)
- X char *message, *argument;
- X{
- X
- X if( warnings ){
- X fprintf(stderr, "%s %s (%s): WARNING\n", PROGRAM, VERSION, STATUS);
- X fprintf(stderr, "%s", message);
- X if( argument[0] != '\0' ) fprintf(stderr, " (%s)\n\n", argument);
- X else fprintf(stderr, "\n\n");
- X }
- X
- X} /* warning() */
- X
- X
- X
- X /* error() prints a message to stderr about a major but recoverable problem.
- X */
- Xvoid
- Xerror(message, argument)
- X char *message, *argument;
- X{
- X
- X fprintf(stderr, "%s %s (%s): ERROR\n", PROGRAM, VERSION, STATUS);
- X fprintf(stderr, "%s", message);
- X if( argument[0] != '\0' ) fprintf(stderr, " (%s)\n\n", argument);
- X else fprintf(stderr, "\n\n");
- X
- X} /* error() */
- X
- X
- X
- X /* fatal_error() prints a message to stderr about a major and
- X ** unrecoverable problem, then exits gracelessly.
- X */
- Xvoid
- Xfatal_error(message, argument)
- X char *message, *argument;
- X{
- X
- X fprintf(stderr, "%s %s (%s): FATAL ERROR\n", PROGRAM, VERSION, STATUS);
- X fprintf(stderr, "%s", message);
- X if( argument[0] != '\0' ) fprintf(stderr, " (%s)\n\n", argument);
- X else fprintf(stderr, "\n\n");
- X
- X exit(1);
- X
- X} /* fatal_error() */
- X
- X
- X
- X /* internal_error() reports an inconsistency in the program itself.
- X ** After the error message is reported, the program is killed
- X ** gracelessly.
- X */
- Xvoid
- Xinternal_error(message, argument)
- X char *message, *argument;
- X{
- X
- X fprintf(stderr, "%s %s (%s): INTERNAL ERROR\n", PROGRAM, VERSION, STATUS);
- X fprintf(stderr, "%s", message);
- X if( argument[0] != '\0' ) fprintf(stderr, " (%s)\n\n", argument);
- X else fprintf(stderr, "\n\n");
- X
- X exit(2);
- X
- X} /* internal_error() */
- X
- SHAR_EOF
- $TOUCH -am 0630160790 errors.c &&
- chmod 0644 errors.c ||
- echo "restore of errors.c failed"
- set `wc -c errors.c`;Wc_c=$1
- if test "$Wc_c" != "2950"; then
- echo original size 2950, current size $Wc_c
- fi
- fi
- # ============= errors.h ==============
- if test X"$1" != X"-c" -a -f 'errors.h'; then
- echo "File already exists: skipping 'errors.h'"
- else
- echo "x - extracting errors.h (Text)"
- sed 's/^X//' << 'SHAR_EOF' > errors.h &&
- X/*
- X** Project: lj2ps
- X** File: errors.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 /* Global functions */
- Xextern void warning(); /* Minor problem */
- Xextern void error(); /* Major but recoverable problem */
- Xextern void fatal_error(); /* Major unrecoverable problem */
- Xextern void internal_error(); /* Problem with the programs innards */
- SHAR_EOF
- $TOUCH -am 0630160790 errors.h &&
- chmod 0644 errors.h ||
- echo "restore of errors.h failed"
- set `wc -c errors.h`;Wc_c=$1
- if test "$Wc_c" != "1170"; then
- echo original size 1170, current size $Wc_c
- fi
- fi
- # ============= lj.c ==============
- if test X"$1" != X"-c" -a -f 'lj.c'; then
- echo "File already exists: skipping 'lj.c'"
- else
- echo "x - extracting lj.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > lj.c &&
- X/* Project: lj2ps
- X** File: lj.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 lj: v1.0, production";
- X
- X /* Include files
- X */
- X#include <stdio.h>
- X#include "lj.h"
- X#include "ljcmds.h"
- X#include "ljfonts.h"
- X#include "scan.h"
- X#include "lj2ps.h"
- X
- X /* External definitions
- X */
- X
- X /* Global variables
- X */
- X /* Front panel variables */
- Xint panel_copies; /* Front panel: Copies */
- Xint panel_manual_feed; /* Front panel: Manual Feed */
- Xint panel_font_source; /* Front panel: Font Source */
- Xint panel_font_number; /* Front panel: Font Number */
- Xint panel_orientation; /* Front panel: Font Source, Font Number */
- Xint panel_form; /* Front panel: Form (i.e. lines/page) */
- X /* Postscript specific variables */
- Xdouble ps_scale_x; /* PS: scale in x direction */
- Xdouble ps_scale_y; /* PS: scale in y direction */
- Xdouble ps_offset_x; /* PS: offset in x direction */
- Xdouble ps_offset_y; /* PS: offset in y direction */
- X /* Job control */
- Xint copies; /* Number of copies */
- X /* Page control */
- Xint paper_source; /* Where the paper is coming from */
- Xint orientation; /* Portrait/landscape (code) */
- Xpsize page_size; /* Type of paper being used (structure) */
- Xdouble page_height; /* Height of physical page (inches) */
- Xdouble page_width; /* Width of physical page (inches) */
- Xdouble char_height; /* Char height (~= VMI) (inches) */
- Xdouble char_width; /* Char width (~= HMI) (inches) */
- Xdouble margin_top; /* Top margin (inches) */
- Xint text_length; /* Text length (lines) */
- Xdouble text_height; /* Text height (inches) */
- Xdouble margin_left; /* Left margin (inches) */
- Xdouble text_width; /* Text width (inches) */
- Xint perf_skip; /* 1 if perforation skip is on */
- Xint line_term; /* Current line termination mode */
- X /* Fonts */
- Xljfont font_p; /* Primary font */
- Xljfont font_s; /* Secondary font */
- Xint underline; /* Underline mode */
- X /* Font management */
- Xint font_ID; /* Current font ID */
- Xint char_code; /* Current character code */
- X /* Raster graphics */
- Xint resolution; /* Current graphics resolution */
- Xint margin_graphics; /* Graphics left margin, in dots? */
- X /* Rectangular area fill */
- Xint rect_size_h; /* Horizontal rectangle size */
- Xint rect_size_v; /* Vertical rectangle size */
- Xint fill_ID; /* Current area fill ID */
- X /* Macro */
- Xint macro_ID; /* Current macro ID */
- X /* Troubleshooting commands */
- Xint eol_wrap; /* End-of-line wrap on/off */
- Xint display_funcs; /* Display functions on/off */
- X /* Implementation variables */
- Xdouble current_x; /* Current X position (inches) */
- Xdouble current_y; /* Current Y position (inches) */
- Xint current_line; /* Current line being printed (lines) */
- Xint current_font; /* Primary or secondary (code) */
- Xint empty_line; /* Ture if line is empty (boolean) */
- Xint empty_text; /* True if text is empty (boolean) */
- Xint empty_page; /* True if page is empty (boolean) */
- Xdouble compress_width; /* Compression in x axis (%) */
- Xdouble compress_height; /* Compression in y axis (%) */
- Xdouble offset_width; /* Offset of x axis (inches) */
- Xdouble offset_height; /* Offset of y axis (inches) */
- X
- X /* Global function list
- 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 buffer */
- X/* macro lj_text_end(); */ /* End text (i.e. flush the buffer) */
- X/* macro lj_cursor_move();*//* Move cursor to a new location */
- X/* macro lj_set_font(); */ /* Use a new font to print the text */
- X/* macro lj_undl_begin();*/ /* Start underlining */
- X/* macro lj_undl_flush();*/ /* Flush the current underline request */
- X/* macro lj_undl_end(); */ /* End underlining */
- 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 /* Local constants
- X */
- X
- X /* Local structures and types
- X */
- X
- X /* Local variables
- X */
- X /* Implementation variables */
- Xstatic int new_page; /* Is the next page a new one? */
- Xstatic int page_number; /* Which page we are currently printing */
- X /* Tables */
- Xpsize paper_size[] = { /* Sizes (in inches) for paper and envelopes */
- X { LJ_PS_EXECUTIVE, 7.2500, 10.5000, 57, /* Paper sizes */
- X 0.2000, 0.2000, 0.1667, 0.3333 },
- X
- X { LJ_PS_LETTER, 8.5000, 11.0000, 60,
- X 0.2000, 0.2000, 0.1667, 0.3333 },
- X
- X { LJ_PS_LEGAL, 8.5000, 14.0000, 78,
- X 0.2000, 0.2000, 0.1667, 0.3333 },
- X
- X { LJ_PS_A4, 8.2677, 11.6929, 64,
- X 0.2000, 0.1933, 0.1667, 0.3067 },
- X
- X { LJ_PS_MONARCH, 3.8750, 7.5000, 39, /* Envelope sizes */
- X 0.2000, 0.2000, 0.1667, 0.3333 },
- X
- X { LJ_PS_COMMERCIAL10, 4.1250, 9.5000, 51,
- X 0.2000, 0.2000, 0.1667, 0.3333 },
- X
- X { LJ_PS_INTERNATIONALDL, 4.3307, 8.6614, 46,
- X 0.2000, 0.1933, 0.1667, 0.3067 },
- X
- X { LJ_PS_INTERNATIONALC5, 6.3780, 9.0157, 48,
- X 0.2000, 0.1933, 0.1667, 0.3067 },
- X
- X { 0, 0.0000, 0.0000 } /* The end must be all 0's */
- X};
- X
- X
- X /* Local macro definitions
- X */
- X
- X /* Local function list
- X */
- X
- X /* Function bodies
- X */
- X
- X
- Xvoid
- Xlj_factory_setup()
- X{
- X
- X panel_copies = 1;
- X panel_manual_feed = LJ_PS_TRAY_1;
- X panel_form = 60;
- X panel_orientation = LJ_OR_PORTRAIT;
- X panel_font_source = LJ_FS_INTERNAL;
- X panel_font_number = 0;
- X
- X ps_scale_x = 1.0;
- X ps_scale_y = 1.0;
- X ps_offset_x = 0.0;
- X ps_offset_y = 0.0;
- X
- X} /* lj_factory_setup() */
- X
- X
- X
- Xvoid
- Xlj_startup(ofile)
- X FILE *ofile;
- X{
- X
- X /* Set the default laserjet variables by executing a reset (ljcmd_E) */
- X lj_reset(ofile);
- X
- X /*
- X ** The postscript prologue
- X **
- X ** Postscript naming conventions used here:
- X **
- X ** Note: X = uppercase letter; x = lowercase letter.
- X **
- X ** X, XX, XXX: Functions
- X **
- X ** x, xx, xxx: Global variables
- X **
- X ** Xx, Xxx: Temporary variables
- X */
- X
- X /* First write out the comments */
- X fprintf(ofile, "%%!PS-Adobe-1.0\n"); /* The standard header */
- X fprintf(ofile, "%%%%Creator: %s %s (%s)\n",
- X PROGRAM, VERSION, STATUS); /* Identify oneself! */
- X fprintf(ofile, "%%%%Pages: (atend)\n");
- X fprintf(ofile, "%%%%EndComments\n");
- X fprintf(ofile, "\n");
- X
- X /* Next, write the prologue code */
- X
- X /* Set the number of copies */
- X fprintf(ofile, "/#copies %d def\n", copies);
- X
- X /* Use letter size paper (8.5"x11") */
- X/* fputs("letter\n", ofile);*/ /* XXX */
- X
- X /* Set manual or automatic feed */
- X if( (paper_source == LJ_PS_MANUAL)
- X || (paper_source == LJ_PS_MANUAL_ENVELOPE) ){
- X fprintf(ofile, "statusdict begin /manualfeed true def end\n");
- X }
- X else{
- X fprintf(ofile, "statusdict begin /manualfeed false def end\n");
- X }
- X
- X /* Define variables for the current font, font size, and font width */
- X fputs("\n", ofile);
- X fprintf(ofile, "/cf /%s def\n", font_p.ps_name);
- X fprintf(ofile, "/cs %.4f def\n", pt2in(font_p.point_size));
- X fprintf(ofile, "/cw %.4f def\n", font_p.width);
- X
- X /* Left margin */
- X fputs("\n", ofile);
- X fprintf(ofile, "/ml %.4f def\n", margin_left);
- X
- X /* Variables for underlining */
- X fputs("\n", ofile);
- X fputs("/ux 0.0 def\n", ofile); /* X coord of underline beginning */
- X fputs("/uy 0.0 def\n", ofile); /* Y coord of underline beginning */
- X
- X /* <String> S -> % Show the string */
- X fputs("\n/S /show load def\n", ofile);
- X
- X /* <X> <Y> -> % Move to (<X>,<Y>) */
- X fputs("\n/M /moveto load def\n", ofile);
- X
- X /* <DeltaX> HRM -> % Move <DeltaX> horizontally (i.e. relative) */
- X fputs("\n\
- X/HRM {\n\
- X 0 rmoveto\n\
- X} bind def\n\
- X", ofile);
- X
- X /* <Y> VM -> % Move to <Y> (i.e. vertical absolute) */
- X fputs("\n\
- X/VM {\n\
- X currentpoint pop exch moveto\n\
- X} bind def\n\
- X", ofile);
- X
- X /* Set Right Margin -- uses clippath
- X ** Note: 25 is used as an arbitrary size. The only requirement of this
- X ** number is that it must be outside the page boundaries
- X */
- X fputs("\n\
- X/RM {\n\
- X /Tr exch def\n\
- X currentpoint initclip\n\
- X newpath\n\
- X 0 0 moveto Tr 0 lineto Tr 25 lineto 0 25 lineto\n\
- X closepath clip\n\
- X moveto\n\
- X} bind def\n\
- X", ofile);
- X
- X /* <typeface> <point-size> F ->
- X ** Set the font, given typeface and point size.
- X ** Note that the character-width is derived by having PostScript
- X ** provide the width of the *space* character (which is likely
- X ** the best character to use for a proportional font).
- X */
- X fputs("\n\
- X/F {\n\
- X /Tp exch def /Tf exch def\n\
- X Tf findfont Tp scalefont setfont\n\
- X /cf Tf def /cs Tp def /cw ( ) stringwidth pop def\n\
- X} bind def\n\
- X", ofile);
- X
- X /* <typeface> <width> <height> FS ->
- X ** Set the font, given typeface, X scale factor, Y scale factor.
- X ** Note that the character-width is derived by having PostScript
- X ** provide the width of the *space* character (which is likely
- X ** the best character to use for a proportional font).
- X */
- X fputs("\n\
- X/FS {\n\
- X /Ty exch def /Tx exch def /Tf exch def\n\
- X Tf findfont [Tx 0 0 Ty 0 0] makefont setfont\n\
- X /cf Tf def /cs Ty def /cw ( ) stringwidth pop def\n\
- X} bind def\n\
- X", ofile);
- X
- X /* US -> Start a new underline */
- X fputs("\n\
- X/US {\n\
- X currentpoint /uy exch def /ux exch def\n\
- X} bind def\n\
- X", ofile);
- X
- X /* UE -> Finish (i.e. draw!) the current underline
- X **
- X ** Note that this underlining does not yet work across separate lines,
- X ** so US and UE must be called on the same line. Also, underlining does
- X ** not work backwards, so only use it if going forwards with the
- X ** underlines (yes, I know this is very limited, but tracking page motion
- X ** is a bit hard with underlining).
- X */
- X fputs("\n\
- X/UE {\n\
- X /Tcx currentpoint pop def\n\
- X gsave\n\
- X newpath\n\
- X cf findfont cs scalefont dup\n\
- X /FontMatrix get 0 get /Ts exch def /FontInfo get dup\n\
- X /UnderlinePosition get Ts mul /To exch def\n\
- X /UnderlineThickness get Ts mul /Tt exch def\n\
- X ux uy To add moveto Tcx uy To add lineto\n\
- X Tt setlinewidth stroke\n\
- X grestore\n\
- X} bind def\n\
- X", ofile);
- X
- X /* TAB -> Tab over to the next tab stop
- X ** For efficiency, this function gets the currentpoint, exch's to
- X ** get the current-x to the top-of-stack, works magic on the
- X ** current-x to figure out the position of the tab stop, exch's
- X ** again to get the arguments in the right sequence for the moveto
- X ** operator, and moves to the tab position.
- X **
- X ** Note that (1.0 + LJ_ERROR) is added to the calculation. The 1.0
- X ** represents the movement to the next tab-stop. LJ_ERROR is needed
- X ** insure that the value is within a certain error-margin in its proximity
- X ** to the tab-stop when the "cvi" (i.e. drop the decimal portion) is
- X ** performed.
- X */
- X fprintf(ofile, "\n\
- X/TAB {\n\
- X currentpoint exch\n\
- X ml sub cw div %d div %f add cvi %d mul cw mul ml add\n\
- X exch moveto\n\
- X} bind def\n\
- X",
- X LJ_TAB_WIDTH,
- X (1.0 + LJ_ERROR),
- X LJ_TAB_WIDTH);
- X
- X /* Initialization of the position stack would go here, if it was
- X ** implemented! */
- X
- X /* Mark the end of the prolog */
- X fprintf(ofile, "\n%%%%EndProlog\n");
- X
- X /* Start the first page */
- X new_page = 1;
- X page_number = 0;
- X
- X} /* lj_startup() */
- X
- X
- X
- Xvoid
- Xlj_shutdown(ofile)
- X FILE *ofile;
- X{
- X
- X fprintf(ofile, "\nstatusdict begin /manualfeed false def end\n");
- X fprintf(ofile, "%%%%Trailer\n");
- X fprintf(ofile, "%%%%Pages: %d\n", page_number);
- X
- X} /* lj_shutdown() */
- X
- X
- X
- Xvoid
- Xlj_page_begin(ofile)
- X FILE *ofile;
- X{
- X
- X /* Set starting position */
- X current_x = margin_left;
- X current_y = page_height - margin_top - char_height;
- X current_line = 1;
- X
- X /* Print the PostScript page header */
- X if( new_page ){
- X page_number++;
- X fprintf(ofile, "\n%%%%Page: ? %d\n", page_number);
- X }
- X
- X /* Save the current graphics state */
- X fputs("save\n", ofile);
- X
- X /* Note: the next three pieces of code must be in the following
- X ** order to insure that everything works correctly:
- X **
- X ** (1) Make inches the default measure
- X ** (2) Rotate the the page to landscape, if necessary
- X ** (3) Perform default offsets and page scaling
- X */
- X
- X /* Make inches the default measure. Note that this must be at the
- X ** beginning of every *page* (rather than in the prologue) because
- X ** the PostScript showpage function resets the graphics state.
- X */
- X fprintf(ofile, "72 72 scale\n");
- X
- X /* Rotate the page to the proper orientation */
- X if( orientation == LJ_OR_LANDSCAPE ){
- X fprintf(ofile,
- X "90 rotate 0 %.4f translate\n",
- X -page_size.width);
- X }
- X
- X /* Make sure everything fits in the printable region */
- X fprintf(ofile, "%.4f %.4f translate %.4f %.4f scale\n",
- X offset_width, offset_height,
- X compress_width, compress_height);
- X
- X /* Make sure that a current point exists */
- X fputs("0 0 moveto\n", ofile);
- X
- X /* Set the initial font */
- X if( current_font == LJ_FT_PRIMARY )
- X lj_set_font(ofile, font_p);
- X else
- X lj_set_font(ofile, font_s);
- X
- X /* Set the left margin */
- X fprintf(ofile, "/ml %.4f def ", margin_left);
- X
- X /* Set the right margin */
- X fprintf(ofile, " %.4f RM ",
- X margin_left + text_width);
- X
- X /* Default position */
- X fprintf(ofile,
- X "%.4f %.4f M\n", current_x, current_y);
- X
- X empty_page = 1;
- X lj_undl_mark(ofile);
- X lj_text_begin();
- X
- X} /* lj_page_begin() */
- X
- X
- X
- Xvoid
- Xlj_page_end(ofile)
- X FILE *ofile;
- X{
- X
- X lj_text_end(ofile);
- X lj_undl_flush(ofile);
- X fputs("\nrestore ", ofile);
- X if( empty_page ){
- X /* Clear the page without using erasepage! */
- X fputs("gsave newpath clippath 1 setgray fill grestore\n", ofile);
- X new_page = 0; /* Still the same physical page */
- X }
- X else{
- X fputs("showpage\n", ofile); /* Print the page */
- X new_page = 1; /* A new physical page is started */
- X }
- X
- X} /* lj_page_end() */
- X
- X
- X
- Xvoid
- Xlj_nl(ofile)
- X FILE *ofile;
- X{
- X
- X lj_text_end(ofile);
- X lj_undl_flush(ofile);
- X
- X current_x = margin_left;
- X current_y -= char_height;
- X fprintf(ofile, "%% NL\n%.4f %.4f M ", current_x, current_y);
- X
- X empty_line = 1;
- X lj_undl_mark(ofile);
- X lj_text_begin();
- X
- X} /* lj_nl() */
- X
- X
- X
- Xvoid
- Xlj_reset(ofile)
- X FILE *ofile;
- X{
- X
- X /* ***** JOB CONTROL **************************************************
- X */
- X copies = panel_copies; /* Number of copies, from the "front panel" */
- X
- X
- X /* ***** FONTS ********************************************************
- X **
- X ** Note: fonts must come before page control because the HMI (i.e.
- X ** char_width) is determined from the font.
- X */
- X
- X /* Reset the primary font */
- X if( lj_find_font(panel_font_source, panel_font_number, &font_p) == 1 ){
- X fatal_error("could not find specified font", "");
- X }
- X
- X /* Reset the secondary font */
- X if( lj_find_font(panel_font_source, panel_font_number, &font_p) == 1 ){
- X fatal_error("could not find specified font", "");
- X }
- X
- X /* Underline, should be off */
- X underline = LJ_UL_OFF;
- X
- X
- X /* ***** PAGE CONTROL ************************************************
- X */
- X
- X /* Paper source, from the "front panel" */
- X paper_source = panel_manual_feed;
- X
- X /* Page orientation, from the "front panel" */
- X orientation = panel_orientation;
- X
- X /* Determine the physical page size */
- X page_size.code = LJ_PS_LETTER; /* Letter size, by default */
- X if( lj_paper_size(&page_size) ){
- X internal_error("illegal page size", "");
- X }
- X
- X /* 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
- X /* Top margin, text height (inches), and text length (lines).
- X ** Char width and height are set here as well due to the
- X ** inter-dependencies.
- X */
- X margin_top = 0.5; /* Top and bottom margins are 1/2" */
- X text_height = page_height - margin_top - 0.5; /* 0.5 is for bottom margin */
- X char_height = text_height / panel_form;
- X char_width = font_p.width; /* inches per character */
- X text_length = text_height / char_height;
- X
- X /* Left margin + text_width (= page width - right margin) */
- X margin_left = 0.0;
- X /* Initially, the right margin is not set. To simulate this, the
- X ** text_width is set to be wider than any reasonable page width.
- X */
- X text_width = 99.00;
- X
- X /* Perforation skip */
- X perf_skip = 1;
- X
- X /* Line termination: start with normal */
- X line_term = LJ_LT_NORM;
- X
- X
- X /* ***** FONT MANAGEMENT **********************************************
- X */
- X
- X /* Current font ID, for soft fonts */
- X font_ID = 0;
- X
- X /* Current character code, for soft fonts */
- X char_code = 0;
- X
- X
- X /* ***** RASTER GRAPHICS **********************************************
- X */
- X
- X /* Graphics resolution, start at 300 dpi */
- X resolution = 75;
- X
- X /* Graphics margin, start at 0 */
- X margin_graphics = 0;
- X
- X
- X /* ***** RECTANGULAR AREA FILL ****************************************
- X */
- X
- X /* ID for filling areas (one ID used for both patterns and gray scales) */
- X fill_ID = LJ_FI_RULE; /* *Black* greyscale! */
- X
- X /* Horizontal and vertical graphics area sizes */
- X rect_size_h = 0;
- X rect_size_v = 0;
- X
- X
- X /* ***** MACRO ********************************************************
- X */
- X
- X /* Current macro ID */
- X macro_ID = 0;
- X
- X
- X /* ***** TROUBLESHOOTING COMMANDS *************************************
- X */
- X
- X /* End-of-line wrap: should be off */
- X eol_wrap = 0;
- X
- X /* Display functions should be off */
- X display_funcs = 0;
- X
- X
- X /* ***** IMPLEMENTATION VARIABLES *************************************
- X */
- X current_x = margin_left;
- X current_y = page_height - margin_top - char_height;
- X current_line = 1;
- X current_font = LJ_FT_PRIMARY;
- X empty_line = 1;
- X empty_text = 1;
- X empty_page = 1;
- X compress_width = ps_scale_x * LJ_DEFAULT_SCALE_X;
- X compress_height = ps_scale_y * LJ_DEFAULT_SCALE_Y;
- X offset_width = ps_offset_x + LJ_DEFAULT_OFFSET_X;
- X offset_height = ps_offset_y + LJ_DEFAULT_OFFSET_Y;
- X
- X} /* lj_reset() */
- X
- X
- X
- X /* lj_paper_size() looks up the dimensions of the paper or envelope
- X ** passed in the code field of the argument. If the code is legal, then
- X ** the width and height fields are filled and a 0 is returned. If the
- X ** code does not exist, then the width and height fields are undefined and
- X ** a 1 is returned.
- X */
- Xint
- Xlj_paper_size(page_size)
- X psize *page_size;
- X{
- X int found;
- X int counter;
- X
- X found = 0;
- X for( counter = 0; !found && !(paper_size[counter].code == 0); counter++ ){
- X if( page_size->code == paper_size[counter].code ){
- X found = 1;
- X page_size->width = paper_size[counter].width;
- X page_size->height = paper_size[counter].height;
- X } /* if(...) */
- X } /* for(...) */
- X
- X return( !found );
- X} /* lj_paper_size() */
- SHAR_EOF
- $TOUCH -am 0630160790 lj.c &&
- chmod 0644 lj.c ||
- echo "restore of lj.c failed"
- set `wc -c lj.c`;Wc_c=$1
- if test "$Wc_c" != "20389"; then
- echo original size 20389, current size $Wc_c
- fi
- fi
- # ============= lj.h ==============
- if test X"$1" != X"-c" -a -f 'lj.h'; then
- echo "File already exists: skipping 'lj.h'"
- else
- echo "x - extracting lj.h (Text)"
- sed 's/^X//' << 'SHAR_EOF' > lj.h &&
- X/*
- X** Project: lj2ps
- X** File: lj.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 LJ_H
- X#define LJ_H
- X
- X /* Global constants
- X */
- X /* Implementation constraints */
- X#define LJ_STRING_SIZE 256
- X#define LJ_ERROR 0.00001 /* Accuracy of floating point numbers */
- X /* Default scaling constants */
- X#define LJ_DEFAULT_SCALE_X 1.0000
- X#define LJ_DEFAULT_SCALE_Y 0.99
- X /* Default offset constants */
- X#define LJ_DEFAULT_OFFSET_X 0.2500
- X#define LJ_DEFAULT_OFFSET_Y 0.0000
- X /* Measurements */
- X#define in 1 /* Inches (base unit of measurement) */
- X#define dt 300 /* Dots per inch */
- X#define dp 720 /* Decipoints */
- X#define hi 120 /* Horizontal Index Unit */
- X#define vi 48 /* Vertical Index Unit */
- X#define pt 72 /* Points */
- X /* Tab stops */
- X#define LJ_TAB_WIDTH 8 /* Tabs occur every eight characters */
- X /* Internal codes */
- X#define LJ_UL_OFF 100 /* Underline codes */
- X#define LJ_UL_ON 101
- X#define LJ_UL_FLOAT 102
- X#define LJ_FI_RULE 200 /* Fill codes Rule */
- X#define LJ_FI_2 201 /* 2% gray */
- X#define LJ_FI_10 202 /* 10% gray */
- X#define LJ_FI_15 203 /* 15% gray */
- X#define LJ_FI_30 204 /* 30% gray */
- X#define LJ_FI_45 205 /* 45% gray */
- X#define LJ_FI_70 206 /* 70% gray */
- X#define LJ_FI_90 207 /* 90% gray */
- X#define LJ_FI_100 208 /* 100% gray */
- X#define LJ_FI_LINE_H 209 /* Horizontal lines */
- X#define LJ_FI_LINE_V 210 /* Vertical lines */
- X#define LJ_FI_DIAG_1 211 /* Diagonals 1 */
- X#define LJ_FI_DIAG_2 212 /* Diagonals 2 */
- X#define LJ_FI_GRID_SQ 213 /* Square grid */
- X#define LJ_FI_GRID_DIAG 214 /* Diagonal grid */
- X#define LJ_LT_NORM 301 /* Line termination normal */
- X#define LJ_LT_CR 302 /* cr=cr+lf lf=lf ff=ff */
- X#define LJ_LT_LF_FF 303 /* cr=cr lf=cr+lf ff=cr+ff */
- X#define LJ_LT_CR_LF_FF 304 /* cr=cr+lf lf=cr+lf ff=cr+ff */
- X#define LJ_PS_TRAY_1 301 /* Paper source */
- X#define LJ_PS_TRAY_2 302
- X#define LJ_PS_MANUAL 303
- X#define LJ_PS_MANUAL_ENVELOPE 304
- X#define LJ_OR_PORTRAIT 401 /* Orientation */
- X#define LJ_OR_LANDSCAPE 402
- X#define LJ_SS_0B 501 /* Symbol set: bit vector entries */
- X#define LJ_SS_0N 502
- X#define LJ_SS_0U 503
- X#define LJ_SS_1U 504
- X#define LJ_SS_8U 505
- X#define LJ_SS_10U 506
- X#define LJ_SS_11U 507
- X#define LJ_TF_HELV 601 /* Typefaces */
- X#define LJ_TF_TIMES 602
- X#define LJ_TF_PRES 603
- X#define LJ_TF_LP 604
- X#define LJ_TF_COUR 605
- X#define LJ_SP_PROPORTIONAL 701 /* Spacing */
- X#define LJ_SP_FIXED 702
- X#define LJ_ST_UPRIGHT 801 /* Font style */
- X#define LJ_ST_ITALIC 802
- X#define LJ_FT_PRIMARY 901 /* Primary/secondary current font */
- X#define LJ_FT_SECONDARY 902
- X#define LJ_PS_EXECUTIVE 1001 /* Page size codes */
- X#define LJ_PS_LETTER 1002
- X#define LJ_PS_LEGAL 1003
- X#define LJ_PS_A4 1004
- X#define LJ_PS_MONARCH 1005
- X#define LJ_PS_COMMERCIAL10 1006
- X#define LJ_PS_INTERNATIONALDL 1007
- X#define LJ_PS_INTERNATIONALC5 1008
- X#define LJ_FS_INTERNAL 1101 /* Font sources */
- X#define LJ_FS_LEFT 1102
- X#define LJ_FS_RIGHT 1103
- X#define LJ_FS_SOFT 1104
- X
- X /* Global structure and type definitions
- X */
- X
- X /* Data required for a laserjet font */
- Xtypedef struct {
- X /* Identifier fields */
- X int source; /* Font source: where the font is located */
- X int number; /* Font number */
- X /* Scaling fields */
- X int scale; /* True if scaling should be performed */
- X double scale_x; /* % to scale in x direction */
- X double scale_y; /* % to scale in y direction */
- X /* LaserJet font ID fields */
- X int symbol_set; /* The symbol set of the font */
- X int spacing; /* Proportional/fixed */
- X double pitch; /* (Only valid for fixed width fonts!) */
- X double point_size; /* Height of the character */
- X int style; /* Upright/italic */
- X int weight; /* Stroke weight: -3 to +3 */
- X int typeface; /* Which typeface to use */
- X char ps_name[LJ_STRING_SIZE]; /* The postscript font used for emulation */
- X double width; /* Width of a character */
- X} ljfont;
- X /* Data required to determine paper size */
- Xtypedef struct {
- X int code; /* Type of paper: letter, legal, A4, etc. */
- X double width; /* How wide (inches) */
- X double height; /* How high (inches) */
- X int default_form; /* Default value for form variable */
- X double unprint_top; /* Unprintable region - top */
- X double unprint_bottom; /* Unprintable region - bottom */
- X double unprint_left; /* Unprintable region - left */
- X double unprint_right; /* Unprintable region - right */
- X} psize;
- X
- X /* Global variables
- X */
- X /* Front panel variables */
- Xextern int panel_copies; /* Front panel: Copies */
- Xextern int panel_manual_feed; /* Front panel: Manual Feed */
- Xextern int panel_font_source; /* Front panel: Font Source */
- Xextern int panel_font_number; /* Front panel: Font Number */
- Xextern int panel_orientation; /* Front panel: Font Source, Font Number */
- Xextern int panel_form; /* Front panel: Form (i.e. lpi) */
- X /* Postscript specific variables */
- 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
- $TOUCH -am 0630160790 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
- fi
- # ============= lj2ps.c ==============
- if test X"$1" != X"-c" -a -f 'lj2ps.c'; then
- echo "File already exists: skipping 'lj2ps.c'"
- else
- 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.1, production";
- Xstatic char *RCSid = "$Header: lj2ps.c,v 1.1 90/06/30 15:55:10 lishka Release $";
- X
- X /* Include files
- X */
- X#include <stdio.h>
- X#include <math.h>
- X#include "lj2ps.h"
- X#include "lj.h"
- X#include "transform.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 0630160790 lj2ps.c &&
- chmod 0644 lj2ps.c ||
- echo "restore of lj2ps.c failed"
- set `wc -c lj2ps.c`;Wc_c=$1
- if test "$Wc_c" != "8092"; then
- echo original size 8092, current size $Wc_c
- fi
- fi
- echo "End of part 9, continue with part 10"
- exit 0
-
-