
#! /bin/sh
# this is a "shar" archive - run through "/bin/sh" to extract 11 files:
#   README ljinit.h patchlevel.h main.c param.c cmd.c misc.c ljconfig.dat ljparam.dat Makefile testsheet
# Wrapped by bin@chinacat on Fri Jun 22 19:13:56 CDT 1990
# Unpacking this archive requires:  sed test wc (possibly mkdir)
# Existing files will not be clobbered unless "-c" is specified on the cmd line.
if test -f README -a "$1" != "-c" ; then
    echo "README: file exists - will not be overwritten"
else
    echo "x - README (file 1 of 11, 5389 chars)"
    sed -e 's/^X//' << 'END_OF_FILE_README' > README
X    ljinit - Hewlett Packard LaserJet Configuration Generator
X    ======   ======= ======= ======== ============= =========
X
X"ljinit" provides a high level interface to the HP PCL configuration commands
Xused by HP LaserJet printers.  For example, rather than hardcoding printer
Xescape sequences into scripts, you can use calls to "ljinit".  Example
Xusage would look something like:
X
X    ljinit setup=letter font_id=roman stroke=bold left_margin=20 /right_margin
X
X(That last argument isn't a filename.  It tells "ljinit" to suppress the
X"right_margin" setting implied by the "setup=letter" specification, and
Xthus allows printing to extend to the end of the logical page rather than
Xclipping at the margin.)
X
XLjinit allows you direct control over the low-level printer configuration
Xparameters (e.g. typeface, left margin, HMI, etc.).  It also provides
Xthree commands ("font_id", "page_id", and "setup") which simplify the
Xtask of creating configurations.
X
XThere are two data files to configure "ljinit":
X
X    - ljparam.dat - device specific parameter definitions
X    - ljconfig.dat - site specific configuration definitions
X
XThe difference between these files is that "ljparam.dat" describes the
Xcapabilities of the printer, and "ljconfig.dat" describes your site-specific
Xconfiguration preferences.
X
XLjinit has been tested under SCO XENIX 386 with an HP LaserJet IIP.  It
Xshould port easily to any System V environment.  (BSD might be tough
Xbecause it uses the SysV regex routines to validate the user's values.)
X
X
XBuilding "ljinit"
X======== ========
X
X  1)  Edit the PARAM_FILE and CONFIG_FILE definitions in "ljinit.h".
X
X  2)  Run a "make".
X
X  3)  The distributed "ljparam.dat" file contains support for all items
X      documented in HP's LaserJet Series II and LaserJet Series IIP
X      manual.  If you run a different printer or if you added capabilities
X      (e.g. fonts) not documented there, you might need to edit this
X      file.  (Please send me your changes!)
X
X  4)  The distributed "ljconfig.dat" file defines my local configuration
X      preferences.  You might very well want to change this file.  Note
X      that the "font_id" definitions describe the internal fonts for a
X      LaserJet Series IIP printer.  You might want to modify these if you
X      run a different printer or if you've added cartridge fonts.  (Please
X      send me your changes!)
X
X  5)  Install "ljparam.dat" and "ljconfig.dat" in the places you defined
X      in step 1.
X
X  6)  To test "ljinit", you can try things like:
X
X	( ljinit setup=wide ; echo "hello world" ) | lp
X	( ljinit stroke=bold ; echo "this is a test" ) | lp
X
X  7)  For the System V print system, you will want to integrate "ljinit"
X      into your interface script.  I can send you mine if you'd like an
X      example.
X
X
XWarnings, Suggestions, and Caveats
X========= ============ === =======
X
X  1)  When you get into programming "ljinit" remember the difference
X      between configuration parameters and the three special commands
X      (page_id, font_id, and setup).  The configuration parameters directly
X      correspond to a single PCL configuration command, which the special
X      commands are higher-level abstractions to simplify the task of
X      establishing a printer configuration.
X
X  2)  If you want to create your own "page_id" page layout entries in the
X      "ljconfig.dat" file, then forget all you know about the complexities
X      about page layout with the LaserJet.  If you want a left margin of
X      a half inch, say "0.50".  "ljinit" knows all the messy details about
X      physical pages, logical pages, conversion to columns, etc. and does
X      it for you automagically.
X
X  3)  The execution of a "page_id" defines a right margin at which the
X      text will be clipped.  If you want to suppress the clipping and
X      instead allow text to extend beyond the right margin all the way
X      to the end of the (logical) page, specify "/right_margin".  You can
X      do this on the command line, or in a "setup" in the "ljconfig.dat"
X      file.  (The '/' slash syntax can be used to inhibit the setting of
X      any parameter.)
X
X  4)  The "ljinit" utility is useless for proportional spaced fonts.
X      This release contains no support for soft fonts, nor is such
X      support anticipated.
X
X  5)  It's a handy program.  But in ways it's like using a sledgehammer
X      to drive a nail.
X      
X
XFine Print
X==== =====
X
X  This program is copyright 1990, Unicom Systems Development.  All rights
X  reserved.  This program is provided "as is" without any warranties,
X  express or implied.  You are granted license to use and distribute this
X  program, provided:  (1) all copyright notices remain intact, (2) you
X  will not distribute a modified version unless it is clearly marked as
X  such, (3) this program is not incorporated into a commercial product,
X  (4) you may not receive payment for the distribution of this program
X  beyond reimbursement of media and handling costs, and (5) you agree
X  that Unicom Systems Development is to be held harmless for any damages,
X  direct or incidental, for any use or application of this program.
X
X
XComments, suggestions, and bug reports are welcomed to the address below.
XEspecially if you make changes to run this with different printers,
Xparticularly the LaserJet Series IID and Series III.
X
XChip Rosenthal
X<chip@chinacat.Unicom.COM>
X
X@(#) README 1.1 90/06/20 23:04:22
X
END_OF_FILE_README
    size="`wc -c < README`"
    if test 5389 -ne "$size" ; then
	echo "README: extraction error - got $size chars"
    fi
fi
if test -f ljinit.h -a "$1" != "-c" ; then
    echo "ljinit.h: file exists - will not be overwritten"
else
    echo "x - ljinit.h (file 2 of 11, 3104 chars)"
    sed -e 's/^X//' << 'END_OF_FILE_ljinit.h' > ljinit.h
X/* @(#) ljinit.h 1.1 90/06/20 23:04:23
X *
X * file:	ljinit.h
X * package:	ljinit - HP LaserJet Initialization Generator
X *
X * Edit History:
X *
X * Wed Feb 28 13:53:23 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
X *	Original composition.
X * Wed Jun 20 23:02:47 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
X *	Cleanup and check into SCCS.
X *
X * Copyright 1990, Unicom Systems Development.  All rights reserved.
X * See accompanying README file for terms of distribution and use.
X */
X
X#define PARAM_FILE	"/local/lib/ljparam.dat"
X#define CONFIG_FILE	"/local/lib/ljconfig.dat"
X
X#define DOTS_INCH	300.0	/* number of dots printed per inch	*/
X#define POINTS_INCH	 72.0	/* number of points per inch		*/
X#define VMI_SCALE	 48.0	/* number of vmi increments per inch	*/
X#define HMI_SCALE	120.0	/* number of hmi increments per inch	*/
X
X#define TRUE		1
X#define FALSE		0
X#define BUFLEN		256
X
X#define Dprintf(level)	if ( Debug < level ) ; else fprintf
X
X#ifndef LINT
X#   define SCCSID(ID)		static char SccsId[] = ID;
X#   define COPYRIGHT(ID)	static char Copyright[] = ID;
X    typedef void * Ptr;		/* generic pointer, e.g. as malloc() returns */
X#else
X#   define SCCSID(ID)
X#   define COPYRIGHT(ID)
X    typedef char * Ptr;
X#endif
X
X#ifdef INTERN
X# define EXTERN
X#else
X# define EXTERN extern
X#endif
X
X/*
X * Globals.
X */
XEXTERN char *	Progname;		/* name of this program		      */
XEXTERN char *	Config_file;		/* file with site-specific info	      */
XEXTERN char *	Param_file;		/* file with device-specific info     */
XEXTERN char	Err_buf[BUFLEN];	/* buffer for "set_param()" messages  */
XEXTERN FILE	*Fp_config;		/* stream for "Config_file"	      */
XEXTERN FILE	*Fp_param;		/* stream for "Param_file"	      */
XEXTERN int	Debug;			/* debugging output level	      */
XEXTERN int	Inhibit_default;	/* inhibits automatic "setup=default" */
X
X/*
X * param.c - Printer parameter processing routines.
X */
Xextern void	load_param();		/* load list from parameters file     */
Xextern char *	get_param();		/* return configured value of a param */
Xextern int	set_param();		/* set a param from a spec string     */
Xextern void	exec_param();		/* generate all the setup commands    */
Xextern void	dump_param();		/* print listing of available params  */
X
X/*
X * cmd.c - Command execution procedures.
X */
Xextern void	(*find_cmd())();/* locate handler proc for a command	      */
Xextern void	cmd_setup();	/* execute a specified "setup" command	      */
Xextern void	cmd_font_id();	/* execute a specified "font_id" command      */
Xextern void	cmd_page_id();	/* execute a specified "page_id" command      */
X
X/*
X * misc.c - Support procedures.
X */
Xextern char *	fgetrec();	/* retrieve a record from a file	      */
Xextern char *	fgetline();	/* get the next line from a stream	      */
Xextern char *	strfield();	/* break line into space-delimited fields     */
Xextern int	stricmp();	/* compare strings, ignore punct and case     */
Xextern char *	strtrim();	/* trim comments, lead/trail white space      */
Xextern Ptr	Smalloc();	/* allocate memory with error checking	      */
Xextern char *	Sstrdup();	/* duplicate a string with error checking     */
X
END_OF_FILE_ljinit.h
    size="`wc -c < ljinit.h`"
    if test 3104 -ne "$size" ; then
	echo "ljinit.h: extraction error - got $size chars"
    fi
fi
if test -f patchlevel.h -a "$1" != "-c" ; then
    echo "patchlevel.h: file exists - will not be overwritten"
else
    echo "x - patchlevel.h (file 3 of 11, 194 chars)"
    sed -e 's/^X//' << 'END_OF_FILE_patchlevel.h' > patchlevel.h
X#define PATCHLEVEL 0
X
X/*
X * @(#) patchlevel.h 1.1 90/06/20 23:04:26
X *
X * Wed Jun 20 23:02:47 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
X *	Patchlevel 0.  Cleanup and check into SCCS.
X */
END_OF_FILE_patchlevel.h
    size="`wc -c < patchlevel.h`"
    if test 194 -ne "$size" ; then
	echo "patchlevel.h: extraction error - got $size chars"
    fi
fi
if test -f main.c -a "$1" != "-c" ; then
    echo "main.c: file exists - will not be overwritten"
else
    echo "x - main.c (file 4 of 11, 3778 chars)"
    sed -e 's/^X//' << 'END_OF_FILE_main.c' > main.c
X/* @(#) main.c 1.1 90/06/20 23:04:24
X *
X * file:	main.c - main procedure
X * package:	ljinit - HP LaserJet Initialization Generator
X *
X * Edit History:
X *
X * Wed Feb 28 13:53:23 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
X *	Original composition.
X * Wed Jun 20 23:02:47 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
X *	Cleanup and check into SCCS.
X *
X * Copyright 1990, Unicom Systems Development.  All rights reserved.
X * See accompanying README file for terms of distribution and use.
X */
X
X#include <stdio.h>
X#include <string.h>
X#define INTERN
X#include "ljinit.h"
X#include "patchlevel.h"
X
XSCCSID("@(#) main.c 1.1 90/06/20 23:04:24")
XCOPYRIGHT("Copyright 1990, Unicom Systems Development.  All rights reserved.")
X
X#define USAGE "\
Xusage: %s [-I] [-c config_file] [-p param_file] [arg ...]\n\
X    (or specify '-h' for help message)\n"
X
Xvoid show_usage();
X
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X    int i, do_help;
X    extern int optind;
X    extern char *optarg;
X
X    /*
X     * Initialize.
X     */
X    Config_file = CONFIG_FILE;	/* site-specific configuration defs	      */
X    Param_file = PARAM_FILE;	/* hardware dependent configuration defs      */
X    Progname = argv[0];		/* this program name			      */
X    Debug = 0;			/* debug disabled by default		      */
X    Inhibit_default = FALSE;	/* do "setup=default" by default	      */
X    do_help = FALSE;		/* no help message by default		      */
X
X    /*
X     * Process the command line options.
X     */
X    while ( (i=getopt(argc,argv,"D:Ic:p:h")) != EOF ) {
X	switch ( i ) {
X	    case 'D':  Debug = atoi(optarg);		break;
X	    case 'I':  Inhibit_default = TRUE;		break;
X	    case 'c':  Config_file = Sstrdup(optarg);	break;
X	    case 'p':  Param_file = Sstrdup(optarg);	break;
X	    case 'h':  do_help = TRUE;			break;
X	    default:   fprintf(stderr,USAGE,Progname);	exit(1);
X	}
X    }
X
X    /*
X     * Open up the data files.
X     */
X    if ( (Fp_param=fopen(Param_file,"r")) == NULL ) {
X	perror(Param_file);
X	exit(1);
X    }
X    if ( (Fp_config=fopen(Config_file,"r")) == NULL ) {
X	perror(Config_file);
X	exit(1);
X    }
X
X    /*
X     * Load in the parameters table.
X     */
X    load_param();
X
X    /*
X     * See if help was requested.
X     */
X    if ( do_help ) {
X	show_usage();
X	exit(0);
X    }
X
X    /*
X     * Initialize the setup to the default conditions.
X     */
X    if ( !Inhibit_default && set_param("setup=default") != 0 ) {
X	fprintf(stderr,"%s: error loading setup 'default' - %s\n",
X	    Progname, Err_buf);
X	exit(1);
X    }
X
X    /*
X     * Process arguments on the command line.
X     */
X    for ( i = optind ; i < argc ; ++i ) {
X	if ( set_param(argv[i]) != 0 ) {
X	    fprintf(stderr,"%s: error processing command line arg - %s\n",
X		Progname, Err_buf);
X	    exit(1);
X	}
X    }
X
X    /*
X     * Go through and execute all of parameter setups.
X     */
X    exec_param( Debug && isatty(1) ? (FILE *) NULL : stdout );
X
X    exit(0);
X    /*NOTREACHED*/
X}
X
Xstatic char *usage_text[] = {
X    "",
X    "The following parameters are available:",
X    "@PARAMS",
X    "",
X    "In addition to these parameters, the 'setup', 'font_id', and 'page_id'",
X    "commands may be used.  Non-alphabetic characters (e.g. '_') and letter",
X    "case are ignored.  Example usage:",
X    "",
X    "    ljinit setup=memo stroke=BOLD left_margin=8 /RightMargin",
X    "",
X    "Copyright 1990, Unicom Systems Development.  All rights reserved.",
X    "See accompanying README file for terms of distribution and use.",
X    "",
X    NULL
X};
X
X
Xvoid show_usage()
X{
X    int i;
X    putchar('\n');
X    printf("%s - version 1.1 (patchlevel %d)\n\n", Progname, PATCHLEVEL);
X    printf(USAGE, Progname);
X    for ( i = 0 ; usage_text[i] != NULL ; ++i ) {
X	if ( strcmp(usage_text[i],"@PARAMS") == 0 )
X	    dump_param(stdout);
X	else
X	    puts(usage_text[i]);
X    }
X}
X
END_OF_FILE_main.c
    size="`wc -c < main.c`"
    if test 3778 -ne "$size" ; then
	echo "main.c: extraction error - got $size chars"
    fi
fi
if test -f param.c -a "$1" != "-c" ; then
    echo "param.c: file exists - will not be overwritten"
else
    echo "x - param.c (file 5 of 11, 11892 chars)"
    sed -e 's/^X//' << 'END_OF_FILE_param.c' > param.c
X/* @(#) param.c 1.1 90/06/20 23:04:25
X *
X * file:	param.c - printer parameter processing routines
X * package:	ljinit - HP LaserJet Initialization Generator
X *
X * These routines maintain the printer configuration parameters, and provide
X * a standard interface to the parameters table.
X *
X * Specifically, these routines build a list of the configurable printer 
X * parameters based upon the "param" records in the "Param_file", place
X * the user-specified values into the list, and finally produces the
X * printer command strings to effect this configuration.
X *
X * The following procedures are provided:
X *
X *   void load_param() - Called once early in the program to initialize
X *	the list of all the paramaters available for configuration.
X *
X *   char *get_param(name) - Lookup the value specified by the user for
X *	the named parameter.
X *
X *   int set_param(spec) - Perform the parameter initialization given by
X *	the specification string (e.g. "left_margin=5").
X *
X *   void exec_param(fp) - Called once all the definitions have been performed
X *	to produce the commands to achieve the desired configuration.
X *
X *   void dump_param(fp) - Produce a listing of the parameters which the
X *	user may set.
X *
X * Edit History:
X *
X * Wed Feb 28 13:53:23 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
X *	Original composition.
X * Wed Jun 20 23:02:47 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
X *	Cleanup and check into SCCS.
X *
X * Copyright 1990, Unicom Systems Development.  All rights reserved.
X * See accompanying README file for terms of distribution and use.
X */
X
X#include <stdio.h>
X#include <string.h>
X#include "ljinit.h"
X
XSCCSID("@(#) param.c 1.1 90/06/20 23:04:25")
XCOPYRIGHT("Copyright 1990, Unicom Systems Development.  All rights reserved.")
X
X/*
X * (struct pvalspec) - Description of acceptable parameter value.  This
X * structure matches a keyword specified in the parameters file (e.g. "INT")
X * and associates a regular expression which may be used to validate the
X * user-supplied value for the parameter.
X */
Xstruct pvalspec {
X    char *name;		/* Name which appears in the "param" record.	      */
X    char *descrip;	/* Description of this item for error messages.       */
X    char *pat;		/* Regular expression to validate against.	      */
X    char *re;		/* Space for the regcmp(3) compiled version of "pat". */
X};
X
X/*
X * Pvalspec_tab[] - The list of allowed parameter value types.
X */
Xstruct pvalspec Pvalspec_tab[] = {
X    { "STRING",	"string",	".",				NULL	},
X    { "INT",	"integer",	"^[0-9]+$",			NULL	},
X    { "SIGNINT","signed-int",	"^-{0,1}[0-9]+$",		NULL	},
X    { "FLOAT2",	"float-2",	"^[0-9]*(\.[0-9]{0,2}){0,1}$",	NULL	},
X    { "FLOAT4",	"float-4",	"^[0-9]*(\.[0-9]{0,4}){0,1}$",	NULL	},
X    { NULL,	NULL,		NULL,				NULL	}
X};
X
X/*
X * (struct param_item) - Description of a printer configuration parameter.
X */
Xstruct param_item {
X    char *name;			/* Name of this configuration parameter.      */
X    char *value;		/* The user-assigned value for this param.    */
X    char *cmd;			/* The PCL command to configure this param.  */
X    int do_lookup;		/* Enable translation via param file lookup.  */
X    struct pvalspec *val_spec;	/* Description of allowed parameter values.   */
X    struct param_item *next;	/* Pointer to next param in the linked list.  */
X};
X
X/*
X * Param_list - Head of the linked list of parameters specified by user.
X */
Xstruct param_item Param_list = { NULL, NULL, NULL, FALSE, NULL, NULL };
X
X
X/*
X * find_param() - Scan the list of parameters looking for the named parameter.
X */
Xstatic struct param_item *find_param(name)
Xregister char *name;
X{
X    register struct param_item *p;
X    for ( p = Param_list.next ; p != NULL ; p = p->next ) {
X	if ( stricmp(name,p->name) == 0 )
X	    return p;
X    }
X    return (struct param_item *) NULL;
X}
X
X
X/*
X * load_param() - Initialize the printer parameters table.
X *
X * Arguments:	none
X *
X * Returns:	nothing
X *
X * Errors:	Aborts program if syntax error detected in definition tables.
X *
X * This routine reads all of the "param" records from the "Param_file"
X * and places them into a linked list of (struct param_item).  It also
X * compiles the regular expresions in the "Pvalspec_tab" which are used
X * to validate the user-specified parameter values.
X */
Xvoid load_param()
X{
X    char *bufp, *s;
X    int i;
X    struct param_item *p;
X    extern char *regcmp();
X
X    /*
X     * Compile the regular expressions in the allowed parameter values list.
X     */
X    for ( i = 0 ; Pvalspec_tab[i].name != NULL ; ++i ) {
X	Pvalspec_tab[i].re = regcmp(Pvalspec_tab[i].pat,(char *)NULL);
X	if ( Pvalspec_tab[i].re == NULL ) {
X	    fprintf(stderr, "%s: internal error - bad pattern for '%s' args\n",
X		Progname, Pvalspec_tab[i].name);
X	    exit(1);
X	}
X    }
X
X    /*
X     * Go through the parameters file looking for definitions.
X     */
X    p = &Param_list;
X    rewind(Fp_param);
X    while ( (bufp=fgetline(Fp_param)) != NULL ) {
X
X	/*
X	 * Only consider "param" definitions.
X	 */
X	if ( stricmp("param",strfield(&bufp)) != 0 )
X	    continue;
X
X	/* 
X	 * Allocate and initialize a new parameter.
X	 */
X	p = p->next = (struct param_item *) Smalloc(sizeof(struct param_item));
X	p->name = NULL;
X	p->value = NULL;
X	p->cmd = NULL;
X	p->do_lookup = FALSE;
X	p->val_spec = NULL;
X	p->next = NULL;
X
X	/*
X	 * Field 1 - name of the configuration parameter.
X	 */
X	if ( *bufp == 0 )
X	    goto err_field_count;
X	p->name = Sstrdup(strfield(&bufp));
X
X	/*
X	 * Field 2 - PCL printer command to configure this parameter.
X	 */
X	if ( *bufp == 0 )
X	    goto err_field_count;
X	p->cmd = Sstrdup(strfield(&bufp));
X
X	/*
X	 * Field 3 - flag to enable translation of value via param file lookup.
X	 */
X	if ( *bufp == 0 )
X	    goto err_field_count;
X	p->do_lookup = ( stricmp(strfield(&bufp),"yes") == 0 );
X
X	/*
X	 * Field 4 - description of allowed values for this parameter.
X	 */
X	if ( *bufp == 0 )
X	    goto err_field_count;
X	s = strfield(&bufp);
X	for ( i = 0 ; Pvalspec_tab[i].name != NULL ; ++i ) {
X	    if ( stricmp(Pvalspec_tab[i].name,s) == 0 ) {
X		p->val_spec = &Pvalspec_tab[i];
X		break;
X	    }
X	}
X	if ( Pvalspec_tab[i].name == NULL ) {
X	    fprintf(stderr,
X		"%s(%s): unknown value type '%s' for parameter '%s'\n",
X		Progname, Param_file, s, p->name);
X	    exit(1);
X	}
X
X	if ( *bufp != '\0' )
X	    goto err_field_count;
X
X    }
X
X    return;
X
Xerr_field_count:
X    fprintf(stderr,"%s(%s): bad field count in parameter '%s'\n",
X	Progname,Param_file,p->name);
X    exit(1);
X}
X
X
X/*
X * get_param() - Retrieve the user-assigned value of a parameter.
X *
X * Arguments:	The name of the parameter to find.
X *
X * Returns:	Pointer to static character string containing the value,
X *		or NULL if no value has been specified.
X *
X * Errors:	None.
X *
X * Punction and letter case are insignificant in the parameter name, i.e.
X * "LeftMargin" will match the parameter named "left_margin".
X */
Xchar *get_param(name)
Xregister char *name;
X{
X    register struct param_item *p;
X    return ( (p=find_param(name)) == NULL ? (char *)NULL : p->value );
X}
X
X
X/*
X * set_param() - Specify the user-assigned value of a parameter.
X *
X * Arguments:	An assignment specification, i.e. "orientation=port".
X *
X * Returns:	0 upon success, -1 upon error.  In the event of an error,
X *		the global string "Err_buf" will describe the problem.
X *
X * Errors:	Error given upon poorly formed specifications or unknown
X *		parameter names.
X *
X * The allowed specifications are of three forms:
X *
X *	/param_name		(suppress production of a configuration param)
X *	param_name=value	(define a value for a configuration param)
X *	cmd_name=value		(run one of the high level commands)
X *
X * Punction and letter case are insignificant in the parameter name, i.e.
X * "LeftMargin" will match the parameter named "left_margin".
X */
Xint set_param(spec)
Xchar *spec;
X{
X    struct param_item *p;
X    char *name, *value;
X    void (*cmdproc)();
X    extern void free();
X
X    /*
X     * Split the specification at '=' into option name and value.
X     */
X    if ( (value=strchr(spec,'=')) != NULL ) {
X	*value++ = '\0';
X	value = strtrim(value);
X    }
X    name = strtrim(spec);
X
X    /*
X     * First, check for the "/param_name" form.
X     */
X    if ( *name == '/' ) {
X	++name;
X	if ( value != NULL )
X	    goto err_value_not_allowed;
X	if ( (p=find_param(name)) == NULL )
X	    goto err_unknown_param;
X	if ( p->value != NULL )
X	    free(p->value);
X	p->value = NULL;
X	Dprintf(4)(stderr, "set_param> inhibited '%s'\n", p->name);
X	return 0;
X    }
X
X    /*
X     * Second, check for the "param_name=value" form.
X     */
X    if ( (p=find_param(name)) != NULL ) {
X	if ( value == NULL )
X	    goto err_value_missing;
X	if ( p->value != NULL )
X	    free(p->value);
X	p->value = Sstrdup(value);
X	Dprintf(4)(stderr, "set_param> setting '%s' to '%s'\n", p->name, value);
X	return 0;
X    }
X
X    /*
X     * Finally, check for the "cmd_name=value" form.
X     */
X    if ( (cmdproc=find_cmd(name)) != NULL ) {
X	if ( value == NULL )
X	    goto err_value_missing;
X	(*cmdproc)(value);
X	return 0;
X    }
X
X    /* else fall through to 'err_unknown_param' error */
X
Xerr_unknown_param:
X    sprintf(Err_buf,"unknown parameter '%s'",name);
X    return -1;
X
Xerr_value_not_allowed:
X    sprintf(Err_buf,"value not allowed when inhibiting '%s'",name);
X    return -1;
X
Xerr_value_missing:
X    sprintf(Err_buf,"value missing on '%s'",name);
X    return -1;
X
X}
X
X
X
X/*
X * exec_param() - Emit the printer command string for the required config.
X *
X * Arguments:	File stream to send command string to, or NULL to suppress
X *		actual output of the commands.
X *
X * Returns:	Nothing.
X *
X * Errors:	Prints diagnostic message and aborts program upon an error.
X *
X * This procedure goes through all of the possible parameters in the order
X * loaded from the "Param_file", and emits a printer configuration command
X * strong for each parameter which has been assigned a value by the user.
X * This procedure will first check if the "do_lookup" flag has been defined
X * for the parameter, and in which case it will translate the mnemonic name
X * specified by the user to a printer code by performing a lookup in the
X * "Param_file".  It will then take the value and validate it according to
X * the "val_spec" for this parameter.
X */
Xvoid exec_param(fp)
XFILE *fp;
X{
X    char *value;
X    struct param_item *p;
X    extern char *regex();
X
X    /*
X     * Go through the linked list of all the possible printer parameters.
X     */
X    for ( p = Param_list.next ; p != NULL ; p = p->next ) {
X
X	/*
X	 * Only consider parameters for which a value has been assigned.
X	 */
X	if ( p->value == NULL )
X	    continue;
X
X	/*
X	 * Perform definitions file lookup to translate value.
X	 */
X	if ( p->do_lookup ) {
X	    value = fgetrec(Fp_param,p->name,p->value,(char *)NULL);
X	    if ( value == NULL ) {
X		fprintf(stderr,
X		    "%s: bad value '%s' for %s (not found in param file)\n",
X		    Progname, p->value, p->name);
X		exit(1);
X	    }
X	} else {
X	    value = p->value;
X	}
X
X	/*
X	 * Verify the parameter value.
X	 */
X	if ( regex(p->val_spec->re,value) == NULL ) {
X	    fprintf(stderr,
X		"%s: bad value '%s(%s)' for %s (illegal %s value)\n",
X		Progname, value, p->value, p->name, p->val_spec->descrip);
X	    exit(1);
X	}
X
X	/*
X	 * Generate the printer configuration string.
X	 */
X	Dprintf(3)(stderr,"exec_param> initializing '%s' to '%s(%s)'\n",
X	    p->name, value, p->value);
X	if ( fp != NULL )
X	    fprintf(fp, p->cmd, value);
X
X    }
X
X}
X
X
X/*
X * dump_param() - Dumps a list of the available configuration parameters.
X *
X * Arguments:	File stream to send listing to.
X *
X * Returns:	Nothing.
X *
X * Errors:	None.
X *
X * This procedure is used within the "help" to list all the available
X * configuration parameters.
X */
Xvoid dump_param(fp)
XFILE *fp;
X{
X    struct param_item *p;
X    int col;
X    fputs("    ",fp);
X    for ( col = 1 , p = Param_list.next ; p != NULL ; ++col , p = p->next ) {
X	if ( col == 5 ) {
X	    fputs("\n    ",fp);
X	    col = 1;
X	}
X	fprintf(fp,"%-16s",p->name);
X    }
X    putc('\n',fp);
X}
X
END_OF_FILE_param.c
    size="`wc -c < param.c`"
    if test 11892 -ne "$size" ; then
	echo "param.c: extraction error - got $size chars"
    fi
fi
if test -f cmd.c -a "$1" != "-c" ; then
    echo "cmd.c: file exists - will not be overwritten"
else
    echo "x - cmd.c (file 6 of 11, 11229 chars)"
    sed -e 's/^X//' << 'END_OF_FILE_cmd.c' > cmd.c
X/* @(#) cmd.c 1.1 90/06/20 23:04:22
X *
X * file:	cmd.c - command execution procedures
X * package:	ljinit - HP LaserJet Initialization Generator
X *
X * These procedures handle the "setup", "font_id", and "page_id" commands.
X * While most of this package is fairly generalized, the "font_id" and
X * "page_id" procedures have specific knowledge of the HP LaserJet
X * architecture, and furthermore, they demand that certain parameters be
X * used.
X *
X * In particular, "font_id" makes use of the following parameters:
X *
X *	orientation	symbol_set	spacing	pitch	height
X *	style		stroke		typeface
X *
X * The "page_id" command needs to access parameters named "orientation"
X * and "paper_size" as well as a "page_dim" entry in the parameters file
X * to calculate the page layout.  In turn, it sets the following parameters:
X *
X *	top_margin	text_length	vmi
X *	left_margin	right_margin	hmi
X *
X * Edit History:
X *
X * Wed Feb 28 13:53:23 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
X *	Original composition.
X * Wed Jun 20 23:02:47 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
X *	Cleanup and check into SCCS.
X *
X * Copyright 1990, Unicom Systems Development.  All rights reserved.
X * See accompanying README file for terms of distribution and use.
X */
X
X#include <stdio.h>
X#include <string.h>
X#include "ljinit.h"
X
XSCCSID("@(#) cmd.c 1.1 90/06/20 23:04:22")
XCOPYRIGHT("Copyright 1990, Unicom Systems Development.  All rights reserved.")
X
Xstatic void get_page_dim();
X
X
X/* 
X * find_cmd() - Locate handler for a command.
X *
X * Arguments:	Name of the command to be executed.
X *
X * Returns:	Pointer to a procedure which handles this command.
X *
X * Errors:	NULL if an unknown command name is specified.
X */
Xvoid (*find_cmd(name))()
Xchar *name;
X{
X    if ( stricmp(name,"setup") == 0 )		return cmd_setup;
X    if ( stricmp(name,"font_id") == 0 )		return cmd_font_id;
X    if ( stricmp(name,"page_id") == 0 )		return cmd_page_id;
X    return (void (*)())NULL;
X}
X
X
X/*
X * cmd_setup() - Execute the specified "setup".
X *
X * Arguments:	The name of a "setup".
X *
X * Returns:	Nothing.
X *
X * Errors:	Displays a diagnostic message and aborts program on error.
X *
X * The "Config_file" is searched for the specified "setup", and the arguments
X * in this record are evaluated.
X */
Xvoid cmd_setup(value)
Xchar *value;
X{
X    char *bufp, *savebuf;
X    extern void free();
X
X    Dprintf(2)(stderr,"cmd_setup> loading setup '%s'\n", value);
X
X    /*
X     * Locate this setup in the configuration file.
X     */
X    bufp = fgetrec(Fp_config,"setup",value,(char *)NULL);
X    if ( bufp == NULL ) {
X	fprintf(stderr, "%s(%s): setup '%s' not found in config file\n",
X	    Progname, Config_file, value);
X	exit(1);
X    }
X
X    /*
X     * Go through all of the items in this setup.  We need to make a copy
X     * of the setup in case we go recursive or cause fgetrec() to be run.
X     */
X    savebuf = bufp = Sstrdup(bufp);
X    while ( *bufp != '\0' ) {
X	if ( set_param(strfield(&bufp)) != 0 ) {
X	    fprintf(stderr,"%s: error processing setup '%s' - %s\n",
X		Progname, value, Err_buf);
X	    exit(1);
X	}
X    }
X    free(savebuf);
X
X}
X
X
X/*
X * cmd_font_id() - Execute the specified "font_id".
X *
X * Arguments:	The name of a "font_id".
X *
X * Returns:	Nothing.
X *
X * Errors:	Displays a diagnostic message and aborts program on error.
X *
X * The "Config_file" is searched for the specified "font_id", and the
X * parameters corresponding to a font definition (listed in "font_component[]")
X * are loaded from this record.
X */
Xvoid cmd_font_id(value)
Xchar *value;
X{
X    char *bufp, spec[BUFLEN];
X    int i;
X
X    /*
X     * The "font_component" array contains the names of all the parameters
X     * in a "font_id" record, in the order in which they appear.
X     */
X    static char *font_component[] = {
X	"orientation", "symbol_set", "spacing", "pitch",
X	"height", "style", "stroke", "typeface", NULL
X    };
X
X    Dprintf(2)(stderr,"cmd_font_id> loading font_id '%s'\n", value);
X
X    /*
X     * Locate this font_id in the configuration file.
X     */
X    bufp = fgetrec(Fp_config,"font_id",value,(char *)NULL);
X    if ( bufp == NULL ) {
X	fprintf(stderr, "%s(%s): font_id '%s' not found in config file\n",
X	    Progname, Config_file, value);
X	exit(1);
X    }
X
X    /*
X     * Load the components from the located record.
X     */
X    for ( i = 0 ; *bufp != '\0' && font_component[i] != NULL ; ++i ) {
X	strcat( strcat( strcpy(spec,font_component[i]), "="), strfield(&bufp) );
X	if ( set_param(spec) != 0 ) {
X	    fprintf(stderr,"%s: error processing font_id '%s' - %s\n",
X		Progname, value, Err_buf);
X	    exit(1);
X	}
X    }
X    if ( font_component[i] != NULL ) {
X	fprintf(stderr,"%s(%s): not enough fields in font_id '%s'\n",
X	    Progname, Config_file, value);
X	exit(1);
X    }
X    if ( *bufp != '\0' ) {
X	fprintf(stderr,"%s(%s): too many fields in font_id '%s'\n",
X	    Progname, Config_file, value);
X	exit(1);
X    }
X
X}
X
X
X/*
X * Items in a "page_dim" record which define the page dimensions.
X */
X#define DIM_PHYSICAL_PAGE_WID		0	/* dim A */
X#define DIM_PHYSICAL_PAGE_LEN		1	/* dim B */
X#define DIM_LOGICAL_PAGE_WID		2	/* dim C */
X#define DIM_MAX_LOGICAL_PAGE_LEN	3	/* dim D */
X#define DIM_LEFT_UNUSABLE_AREA		4	/* dim E */
X#define DIM_RIGHT_UNUSABLE_AREA		5	/* dim F */
X#define DIM_MIN_TOP_MARG		6	/* dim G */
X#define DIM_MIN_BOT_MARG		7	/* dim H */
X#define NUM_DIM_ITEMS			8
X
X/*
X * Items in a "page_id" record which define the page layout.
X */
X#define PAGE_LEFT_MARG		0	/* left margin in inches	      */
X#define PAGE_RIGHT_MARG		1	/* right margin in inches	      */
X#define PAGE_NUM_COLS		2	/* number of printable columns	      */
X#define PAGE_TOP_MARG		3	/* top margin in inches		      */
X#define PAGE_BOT_MARG		4	/* bottom margin in inches	      */
X#define PAGE_NUM_LINES		5	/* number of printable lines	      */
X#define NUM_PAGE_ITEMS		6
X
X/*
X * cmd_page_id() - Execute the specified "page_id".
X *
X * Arguments:	The name of a paget_id".
X *
X * Returns:	Nothing.
X *
X * Errors:	Displays a diagnostic message and aborts program on error.
X *
X * The "Config_file" is searched for the specified "page_id", and the
X * parameters associated with page layout are calculated and loaded from
X * the information in this record.  The "Param_file" will be consulted
X * for the "page_dim" record which lists the physical and logical page
X * dimensions for the selected page type and orientation.
X */
Xvoid cmd_page_id(value)
Xchar *value;
X{
X    int i;
X    char *bufp, spec[BUFLEN];
X    double printable_line_width, cols_per_inch;
X    double left_margin, right_margin;
X    double printable_line_height, lines_per_inch;
X    double page_dim[NUM_DIM_ITEMS], page_layout[NUM_PAGE_ITEMS];
X    extern double atof();
X
X    Dprintf(2)(stderr,"cmd_page_id> loading page_id '%s'\n", value);
X
X    /*
X     * Locate this page_id in the configuration file.
X     */
X    bufp = fgetrec(Fp_config,"page_id",value,(char *)NULL);
X    if ( bufp == NULL ) {
X	fprintf(stderr, "%s(%s): page_id '%s' not found in config file\n",
X	    Progname, Config_file, value);
X	exit(1);
X    }
X
X    /*
X     * Convert the fields in the record to numeric values.
X     */
X    for ( i = 0 ; *bufp != '\0' && i < NUM_PAGE_ITEMS ; ++i )
X	page_layout[i] = atof(strfield(&bufp));
X    if ( i < NUM_PAGE_ITEMS ) {
X	fprintf(stderr, "%s(%s): not enough fields in page_id '%s'",
X	    Progname, Config_file, value);
X	exit(1);
X    }
X    if ( *bufp != '\0' ) {
X	fprintf(stderr, "%s(%s): too many fields in page_id '%s'",
X	    Progname, Config_file, value);
X	exit(1);
X    }
X
X    /*
X     * Load in the page dimensions for the given paper_size/orientation.
X     */
X    get_page_dim(page_dim,"page_id");
X
X    /*
X     * Calculate width of printable area in inches and number of cols/inch.
X     */
X    printable_line_width =
X	page_dim[DIM_PHYSICAL_PAGE_WID] -
X	    (page_layout[PAGE_LEFT_MARG]+page_layout[PAGE_RIGHT_MARG]);
X    cols_per_inch = page_layout[PAGE_NUM_COLS] / printable_line_width;
X    Dprintf(5)(stderr, "cmd_page_id> printable_line_width = %f-(%f+%f) = %f\n",
X	page_dim[DIM_PHYSICAL_PAGE_WID],
X	page_layout[PAGE_LEFT_MARG], page_layout[PAGE_RIGHT_MARG],
X	printable_line_width
X    );
X    Dprintf(5)(stderr, "cmd_page_id> cols_per_inch = %f/%f = %f\n",
X	page_layout[PAGE_NUM_COLS], printable_line_width, cols_per_inch
X    );
X
X    /*
X     * Calculate the horizontal margins.
X     */
X    left_margin = cols_per_inch *
X	(page_layout[PAGE_LEFT_MARG]-page_dim[DIM_LEFT_UNUSABLE_AREA]);
X    right_margin = page_layout[PAGE_NUM_COLS] + left_margin - 1;
X
X    /*
X     * Calculate height of printable area in inches and number of lines/inch.
X     */
X    printable_line_height =
X	page_dim[DIM_PHYSICAL_PAGE_LEN] -
X	    (page_layout[PAGE_TOP_MARG]+page_layout[PAGE_BOT_MARG]);
X    lines_per_inch = page_layout[PAGE_NUM_LINES] / printable_line_height;
X    Dprintf(5)(stderr, "cmd_page_id> printable_line_height = %f-(%f+%f) = %f\n",
X	page_dim[DIM_PHYSICAL_PAGE_LEN],
X	page_layout[PAGE_TOP_MARG], page_layout[PAGE_BOT_MARG],
X	printable_line_height
X    );
X    Dprintf(5)(stderr, "cmd_page_id> lines_per_inch = %f/%f = %f\n",
X	page_layout[PAGE_NUM_LINES], printable_line_height, lines_per_inch
X    );
X
X    /*
X     * Set the page layout parameters.
X     */
X    sprintf(spec, "left_margin=%.0f", left_margin);
X    if ( set_param(spec) != 0 )
X	goto err_bad_param;
X    sprintf(spec, "right_margin=%.0f", right_margin );
X    if ( set_param(spec) != 0 )
X	goto err_bad_param;
X    sprintf(spec, "hmi=%.4f", HMI_SCALE/cols_per_inch);
X    if ( set_param(spec) != 0 )
X	goto err_bad_param;
X    sprintf(spec, "top_margin=%.0f", lines_per_inch*page_layout[PAGE_TOP_MARG]);
X    if ( set_param(spec) != 0 )
X	goto err_bad_param;
X    sprintf(spec, "text_length=%.0f", page_layout[PAGE_NUM_LINES]);
X    if ( set_param(spec) != 0 )
X	goto err_bad_param;
X    sprintf(spec, "vmi=%.4f", VMI_SCALE/lines_per_inch);
X    if ( set_param(spec) != 0 )
X	goto err_bad_param;
X    return;
X
Xerr_bad_param:
X    fprintf(stderr,"%s: error processing page_id '%s' - %s\n",
X	Progname, value, Err_buf);
X    exit(1);
X}
X
X
Xstatic void get_page_dim(page_dim,cmdname)
Xdouble page_dim[];
Xchar *cmdname;
X{
X    int i;
X    char *ps, *or, *bufp;
X    double atof();
X
X    /*
X     * Get the paper size and page orientation.
X     */
X    if ( (ps=get_param("paper_size")) == NULL ) {
X	fprintf(stderr,"%s: must define an 'page_size' before doing '%s'\n",
X	    Progname, cmdname);
X	exit(1);
X    }
X    if ( (or=get_param("orientation")) == NULL ) {
X	fprintf(stderr,"%s: must define an 'orientation' before doing '%s'\n",
X	    Progname, cmdname);
X	exit(1);
X    }
X
X    /*
X     * Now get the paper dimensions based upon the paper_size and orientation.
X     */
X    bufp = fgetrec(Fp_param,"page_dim",ps,or,(char *)NULL);
X    if ( bufp == NULL ) {
X	fprintf(stderr,"%s(%s): page_dim for %s/%s not found",
X	    Progname, Param_file, ps, or);
X	exit(1);
X    }
X
X    /*
X     * Convert the paper dimension fields to values in inches.
X     */
X    for ( i = 0 ; *bufp != '\0' && i < NUM_DIM_ITEMS ; ++i )
X	page_dim[i] = atof(strfield(&bufp)) / DOTS_INCH;
X    if ( i < NUM_DIM_ITEMS ) {
X	fprintf(stderr, "%s(%s): not enough fields in page_dim for %s/%s",
X	    Progname, Param_file, ps, or);
X	exit(1);
X    }
X    if ( *bufp != '\0' ) {
X	fprintf(stderr, "%s(%s): too many fields in page_dim for %s/%s",
X	    Progname, Param_file, ps, or);
X	exit(1);
X    }
X
X}
X
END_OF_FILE_cmd.c
    size="`wc -c < cmd.c`"
    if test 11229 -ne "$size" ; then
	echo "cmd.c: extraction error - got $size chars"
    fi
fi
if test -f misc.c -a "$1" != "-c" ; then
    echo "misc.c: file exists - will not be overwritten"
else
    echo "x - misc.c (file 7 of 11, 4200 chars)"
    sed -e 's/^X//' << 'END_OF_FILE_misc.c' > misc.c
X/* @(#) misc.c 1.1 90/06/20 23:04:25
X *
X * file:	misc.c - support procedures
X * package:	ljinit - HP LaserJet Initialization Generator
X *
X * Edit History:
X *
X * Wed Feb 28 13:53:23 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
X *	Original composition.
X * Wed Jun 20 23:02:47 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
X *	Cleanup and check into SCCS.
X *
X * Copyright 1990, Unicom Systems Development.  All rights reserved.
X * See accompanying README file for terms of distribution and use.
X */
X
X#include <stdio.h>
X#include <ctype.h>
X#include <string.h>
X#include <varargs.h>
X#include "ljinit.h"
X
XSCCSID("@(#) misc.c 1.1 90/06/20 23:04:25")
XCOPYRIGHT("Copyright 1990, Unicom Systems Development.  All rights reserved.")
X
X/*
X * fgetrec() - Retrieve a record from a file.  The first parameter is the
X * opened stream to search, followed by a list of field values to match.  A
X * pointer to the record, with the matched fields removed, is returned.  NULL
X * is returned upon lookup failure.
X */
X/*VARARGS1*/
Xchar *fgetrec(fp,va_alist)
XFILE *fp;
Xva_dcl
X{
X    va_list args;
X    int i;
X    char *bufp, *field[16];
X
X    /*
X     * Load in the list of fields.
X     */
X    va_start(args);
X    for ( i = 0 ; (field[i]=va_arg(args,char *)) != NULL ; ++i ) ;
X    va_end(args);
X
X    /*
X     * Go searching for the record which matches these fields.
X     */
X    rewind(fp);
X    while ( (bufp=fgetline(fp)) != NULL ) {
X	for ( i = 0 ; ; ++i ) {
X	    if ( field[i] == NULL )
X		return bufp;
X	    if ( stricmp(field[i],strfield(&bufp)) != 0 )
X		break;
X	}
X    }
X
X    return (char *) NULL;
X}
X
X
X/*
X * fgetline() - Get the next line from a stream.  Leading and trailing
X * whitespace is ignored.  Comments introduced with "#" are stripped.
X * Long lines may be continued by backslashes.  Blank lines are ignored.
X * Returns pointer to static data, or NULL on end of file.
X */
Xchar *fgetline(fp)
XFILE *fp;
X{
X    static char buf[BUFLEN];
X    int nchars;
X    char *bufp;
X
X    /*
X     * Clear out the buffer.
X     */
X    buf[0] = '\0';
X    nchars = 0;
X
X    /*
X     * Keep reading until we have a full line loaded.
X     */
X    for (;;) {
X
X	/*
X	 * Read into the end of the buffer.
X	 */
X	if ( fgets(buf+nchars,(int)sizeof(buf)-nchars,fp) == NULL )
X	    return (char *) NULL;
X
X	/*
X	 * Strip comments, leading/trailing white space.
X	 */
X	bufp = strtrim(buf);
X	nchars = strlen(buf);
X
X	/*
X	 * Ignore blank lines.
X	 */
X	if ( nchars == 0 )
X	    continue;
X
X	/*
X	 * If there isn't a continued line then return what we have.
X	 */
X	if ( buf[nchars-1] != '\\' )
X	    return bufp;
X
X	/*
X	 * Remove the continuation character.
X	 */
X	buf[--nchars] = '\0';
X
X    }
X
X    /*NOTREACHED*/
X}
X
X
X/*
X * strfield() - Retrieve the first space-delimited field in a line, and
X * advance the buffer pointer to the start of the next field.
X */
Xchar *strfield(bufp)
Xchar **bufp;
X{
X    register char *w1, *w2;
X    for ( w1 = *bufp ; isspace(*w1) ; ++w1 ) ;
X    w2 = w1;
X    if ( *w2 != '\0' ) {
X	for ( ++w2 ; *w2 != '\0' && !isspace(*w2) ; ++w2 ) ;
X	if ( *w2 != '\0' )
X	    for ( *w2++ = '\0' ; isspace(*w2) ; ++w2 ) ;
X    }
X    *bufp = w2;
X    return w1;
X}
X
X
X/*
X * stricmp() - Compare two strings, ignoring punctuation and letter case.
X */
Xint stricmp(s1,s2)
Xregister char *s1, *s2;
X{
X    int d;
X    do {
X	while ( *s1 != '\0' && !isalnum(*s1) )
X	    ++s1;
X	while ( *s2 != '\0' && !isalnum(*s2) )
X	    ++s2;
X	d = tolower(*s1) - tolower(*s2);
X    } while ( d == 0 && *s1++ != '\0' && *s2++ != '\0' );
X    return d;
X}
X
X
X/*
X * strtrim() - Trim comments and leading/trailing white space.
X */
Xchar *strtrim(buf)
Xregister char *buf;
X{
X    register char *s;
X
X    for ( ; isspace(*buf) ; ++buf ) ;
X    if ( (s=strchr(buf,'#')) != NULL )
X	*s = '\0';
X    for ( s = buf+strlen(buf)-1 ; s >= buf && isspace(*s) ; --s ) ;
X    *(++s) = '\0';
X    return buf;
X}
X
X
X/*
X * Smalloc() - Allocate memory with error checking.
X */
XPtr Smalloc(n)
Xregister unsigned n;
X{
X    extern Ptr malloc();
X    register Ptr s;
X    if ( (s=malloc(n)) == NULL ) {
X	fputs("malloc: out of space\n",stderr);
X	exit(2);
X    }
X    return s;
X}
X
X
X/*
X * Sstrdup() - Duplicate a string with error checking.
X */
Xchar *Sstrdup(s)
Xregister char *s;
X{
X    return strcpy( Smalloc((unsigned)strlen(s)+1), s );
X}
X
END_OF_FILE_misc.c
    size="`wc -c < misc.c`"
    if test 4200 -ne "$size" ; then
	echo "misc.c: extraction error - got $size chars"
    fi
fi
if test -f ljconfig.dat -a "$1" != "-c" ; then
    echo "ljconfig.dat: file exists - will not be overwritten"
else
    echo "x - ljconfig.dat (file 8 of 11, 8793 chars)"
    sed -e 's/^X//' << 'END_OF_FILE_ljconfig.dat' > ljconfig.dat
X# @(#) ljconfig.dat 1.1.1.1 90/06/22 19:13:25
X#
X# file:		ljconfig.dat - site specific configuration definitions
X# package:	ljinit - HP LaserJet Initialization Generator
X#
X# This file contains the site-specific definitions which are used to evaluate
X# the "setup", "pageid", and "fontid" commands.  The file is broken into three
X# sections, corresponding to the three commands.  Chances are good you'll want
X# to customize this file for the printer configurations you frequently use.
X#
X# Edit History:
X#
X# Wed Feb 28 13:53:23 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
X#	Original composition.
X# Wed Jun 20 23:02:47 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
X# 	Cleanup and check into SCCS.
X#
X# Copyright 1990, Unicom Systems Development.  All rights reserved.
X# See accompanying README file for terms of distribution and use.
X#
X
X##############################################################################
X#
X# Setup Definitions
X#
X
X#
X# There must be a "default" setup defined.  It is evaluated before any of the
X# specifications on the command line, unless "-I" is specified to inhibit it.
X#
Xsetup default	setup=letter
X
X#
X# The "common" setup is a convenience to describe the things which are used
X# in most of the other setup definitions.
X#
Xsetup common				\
X		reset=yes		\
X		paper_size=letter	\
X		paper_source=internal	\
X		line_term=map_lf	\
X		line_wrap=disable	\
X		perf_skip=enable
X
X#
X# And finally, below are the setups which we use locally for 8.5x11 printing.
X#
Xsetup letter	setup=common font_id=I000  page_id=letter
Xsetup form	setup=common font_id=I002  page_id=form
Xsetup listing	setup=common font_id=I002  page_id=listing
Xsetup wide	setup=common font_id=I001  page_id=wide
Xsetup land	setup=common font_id=I001L page_id=land
X
X#
X# And the setup for envelope printing.
X#
Xsetup envelope				\
X		reset=yes		\
X		paper_size=com10	\
X		paper_source=manual_env	\
X		line_term=map_lf	\
X		line_wrap=disable	\
X		perf_skip=enable	\
X		font_id=I000L		\
X		clear_margins=yes	\
X		top_margin=10		\
X		left_margin=30
X
X
X############################################################################## 
X#
X# Page Layout Definitions
X#
X# A page layout definition specifies the desired margins (in inches) and the
X# number of chars/line and lines/page.  From this information, the following
X# parameters are automatically calculated and set:
X#
X#	left_margin	right_margin	hmi
X#	top_margin	text_length	vmi
X#
X#                   left  right    num    top    bot    num    intended use 
X#                   marg   marg   cols   marg   marg  lines    (orient/font)
X
Xpage_id  letter     0.60   0.60     72   0.50   0.50     66  # port/10cpi
Xpage_id  form       0.60   0.60     78   0.50   0.50     66  # port/12cpi
Xpage_id  listing    1.00   1.00     80   0.50   0.50     66  # port/12cpi
Xpage_id  wide       0.50   0.50    132   0.50   0.50     66  # port/teeny
Xpage_id  land       0.50   0.50    167   0.50   0.50     66  # land/teeny
X
X
X##############################################################################
X#
X# Font Definitions
X#
X# A font definition specifies all the components which comprise a font.
X# They are, in order:
X#
X#	orientation	symbol_set	spacing		pitch
X#	height		style		stroke		typeface
X#
X# The distributed definitions are for a LaserJet IIP, and the names
X# correspond to those printed on the IIP test sheet (except I append
X# "L" for landscape fonts).
X#
X
X#
X# Portrait Fonts
X#
X#               orien symbol_set space pitch ht    style   stroke typeface 
X
Xfont_id  I000   port  hp_roman8  fixed 10    12    upright medium courier
Xfont_id  I001   port  hp_roman8  fixed 16.67  8.5  upright medium line_printer
Xfont_id  I002   port  hp_roman8  fixed 12    10    upright medium courier
Xfont_id  I003   port  hp_roman8  fixed 12    10    upright bold   courier
Xfont_id  I004   port  hp_roman8  fixed 12    10    italic  bold   courier
Xfont_id  I005   port  hp_roman8  fixed 10    12    upright bold   courier
Xfont_id  I006   port  hp_roman8  fixed 10    12    upright bold   courier
Xfont_id  I007   port  iso_100    fixed 16.67  8.5  upright medium line_printer
Xfont_id  I008   port  iso_100    fixed 12    10    upright medium courier
Xfont_id  I009   port  iso_100    fixed 12    10    upright bold   courier
Xfont_id  I010   port  iso_100    fixed 12    10    italic  medium courier
Xfont_id  I011   port  iso_100    fixed 10    12    upright medium courier
Xfont_id  I012   port  iso_100    fixed 10    12    upright bold   courier
Xfont_id  I013   port  iso_100    fixed 10    12    italic  medium courier
Xfont_id  I014   port  pc_8       fixed 16.67  8.5  upright medium line_printer
Xfont_id  I015   port  pc_8       fixed 12    10    upright medium courier
Xfont_id  I016   port  pc_8       fixed 12    10    upright bold   courier
Xfont_id  I017   port  pc_8       fixed 12    10    italic  medium courier
Xfont_id  I018   port  pc_8       fixed 10    12    upright medium courier
Xfont_id  I019   port  pc_8       fixed 10    12    upright bold   courier
Xfont_id  I020   port  pc_8       fixed 10    12    italic  medium courier
Xfont_id  I021   port  pc_8dn     fixed 16.67  8.5  upright medium line_printer
Xfont_id  I022   port  pc_8dn     fixed 12    10    upright medium courier
Xfont_id  I023   port  pc_8dn     fixed 12    10    upright bold   courier
Xfont_id  I024   port  pc_8dn     fixed 12    10    italic  medium courier
Xfont_id  I025   port  pc_8dn     fixed 10    12    upright medium courier
Xfont_id  I026   port  pc_8dn     fixed 10    12    upright bold   courier
Xfont_id  I027   port  pc_8dn     fixed 10    12    italic  medium courier
Xfont_id  I028   port  pc_850     fixed 16.67  8.5  upright medium line_printer
Xfont_id  I029   port  pc_850     fixed 12    10    upright medium courier
Xfont_id  I030   port  pc_850     fixed 12    10    upright bold   courier
Xfont_id  I031   port  pc_850     fixed 12    10    italic  medium courier
Xfont_id  I032   port  pc_850     fixed 10    12    upright medium courier
Xfont_id  I033   port  pc_850     fixed 10    12    upright bold   courier
Xfont_id  I034   port  pc_850     fixed 10    12    italic  medium courier
X
X#
X# Landscape Fonts
X#
X#               orien symbol_set space pitch ht    style   stroke typeface 
X
Xfont_id  I000L  land  hp_roman8  fixed 10    12    upright medium courier
Xfont_id  I001L  land  hp_roman8  fixed 16.67  8.5  upright medium line_printer
Xfont_id  I002L  land  hp_roman8  fixed 12    10    upright medium courier
Xfont_id  I003L  land  hp_roman8  fixed 12    10    upright bold   courier
Xfont_id  I004L  land  hp_roman8  fixed 12    10    italic  bold   courier
Xfont_id  I005L  land  hp_roman8  fixed 10    12    upright bold   courier
Xfont_id  I006L  land  hp_roman8  fixed 10    12    upright bold   courier
Xfont_id  I007L  land  iso_100    fixed 16.67  8.5  upright medium line_printer
Xfont_id  I008L  land  iso_100    fixed 12    10    upright medium courier
Xfont_id  I009L  land  iso_100    fixed 12    10    upright bold   courier
Xfont_id  I010L  land  iso_100    fixed 12    10    italic  medium courier
Xfont_id  I011L  land  iso_100    fixed 10    12    upright medium courier
Xfont_id  I012L  land  iso_100    fixed 10    12    upright bold   courier
Xfont_id  I013L  land  iso_100    fixed 10    12    italic  medium courier
Xfont_id  I014L  land  pc_8       fixed 16.67  8.5  upright medium line_printer
Xfont_id  I015L  land  pc_8       fixed 12    10    upright medium courier
Xfont_id  I016L  land  pc_8       fixed 12    10    upright bold   courier
Xfont_id  I017L  land  pc_8       fixed 12    10    italic  medium courier
Xfont_id  I018L  land  pc_8       fixed 10    12    upright medium courier
Xfont_id  I019L  land  pc_8       fixed 10    12    upright bold   courier
Xfont_id  I020L  land  pc_8       fixed 10    12    italic  medium courier
Xfont_id  I021L  land  pc_8dn     fixed 16.67  8.5  upright medium line_printer
Xfont_id  I022L  land  pc_8dn     fixed 12    10    upright medium courier
Xfont_id  I023L  land  pc_8dn     fixed 12    10    upright bold   courier
Xfont_id  I024L  land  pc_8dn     fixed 12    10    italic  medium courier
Xfont_id  I025L  land  pc_8dn     fixed 10    12    upright medium courier
Xfont_id  I026L  land  pc_8dn     fixed 10    12    upright bold   courier
Xfont_id  I027L  land  pc_8dn     fixed 10    12    italic  medium courier
Xfont_id  I028L  land  pc_850     fixed 16.67  8.5  upright medium line_printer
Xfont_id  I029L  land  pc_850     fixed 12    10    upright medium courier
Xfont_id  I030L  land  pc_850     fixed 12    10    upright bold   courier
Xfont_id  I031L  land  pc_850     fixed 12    10    italic  medium courier
Xfont_id  I032L  land  pc_850     fixed 10    12    upright medium courier
Xfont_id  I033L  land  pc_850     fixed 10    12    upright bold   courier
Xfont_id  I034L  land  pc_850     fixed 10    12    italic  medium courier
X
END_OF_FILE_ljconfig.dat
    size="`wc -c < ljconfig.dat`"
    if test 8793 -ne "$size" ; then
	echo "ljconfig.dat: extraction error - got $size chars"
    fi
fi
if test -f ljparam.dat -a "$1" != "-c" ; then
    echo "ljparam.dat: file exists - will not be overwritten"
else
    echo "x - ljparam.dat (file 9 of 11, 9636 chars)"
    sed -e 's/^X//' << 'END_OF_FILE_ljparam.dat' > ljparam.dat
X# @(#) ljparam.dat 1.1 90/06/20 23:04:24
X#
X# file:		ljparam.dat - device specific definitions
X# package:	ljinit - HP LaserJet Initialization Generator
X#
X# Edit History:
X#
X# Wed Feb 28 13:53:23 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
X#	Original composition.
X# Wed Jun 20 23:02:47 1990 - Chip Rosenthal <chip@chinacat.Unicom.COM>
X#	Cleanup and check into SCCS.
X#
X# Copyright 1990, Unicom Systems Development.  All rights reserved.
X# See accompanying README file for terms of distribution and use.
X#
X
X
X##############################################################################
X#
X# This file describes all the device-dependant parameters for the printer.
X# The distributed version has been tested with an HP LaserJet IIP printer.
X#
X# Some notes on the format of this file:
X#   - It is a sequence of records with space delimited fields.
X#   - Everything from a '#' to the end of line is ignored.
X#   - Blank lines are ignored.
X#   - Long lines may be continued with a backslash.
X#   - Punctuation and letter case are insignificant in the field values.
X#
X# There are three kinds of records in this file:
X#   - "param" records - describes a printer configuration parameter.
X#   - param value records - declares mnemonic names usable with params.
X#   - "page_dim" records - describes page dimensions.
X#
X# This file is broken into three sections, into which the three record types
X# are grouped.  Descriptions at the start of each section describes the
X# records which appear there.
X
X
X##############################################################################
X#
X# Parameter Definitions
X#
X# All of the LaserJet printer configuration parameters are defined here.
X# Each line is an entry which describes one parameter.  The order of the
X# "param" records is critical, they are emitted to the printer in the
X# order they occur in this file.  Also, be careful about changing names
X# around -- the procedures which handle the "page_id" and "font_id"
X# commands have specific knowledge of the parameter names they need to set.
X#
X# Each "param" record must have the following four fields:
X#
X# (1) The name of the printer configuration parameter.
X#
X# (2) The HP PCL code to configure this parameter.  This code will be
X#     run through a printf() command, so ensure that special characters
X#     are escaped appropriately.  A "%s" within the code will be replaced
X#     with the parameter value specified by the user.
X#
X# (3) A flag which indicates whether a lookup should be performed on this
X#     parameter.  If the value is "yes" (or "YES"), then "ljinit" will
X#     take the user-supplied value and translate it according to the
X#     definitions in section two of this file.  Any other value in this
X#     field means that the value specified by the user is what should
X#     be incorporated directly into the command sent to the printer.
X#
X# (4) A description of the allowed types for the value.  The following
X#     types may be given:
X#
X#     	STRING	An arbitrary tesxt string.
X#     	INT	A positive integer.
X# 	SIGNINT	An integer.
X#	FLOAT2	A floating point value with up to 2 decimal digits.
X#	FLOAT4	A floating point value with up to 4 decimal digits.
X#
X#	name		code		lookup?	value_type
X#
Xparam	reset		\033E		no	STRING
Xparam	paper_source	\033&l%sH	yes	INT
Xparam	paper_size	\033&l%sA	yes	INT
Xparam	line_term	\033&k%sG	yes	INT
Xparam	line_wrap	\033&s%sC	yes	INT
Xparam	orientation	\033&l%sO	yes	INT
Xparam	symbol_set	\033(%s		yes	STRING
Xparam	spacing		\033(s%sP	yes	INT
Xparam	pitch		\033(s%sH	no	FLOAT2
Xparam	height		\033(s%sV	no	FLOAT2
Xparam	style		\033(s%sS	yes	INT
Xparam	stroke		\033(s%sB	yes	SIGNINT
Xparam	typeface	\033(s%sT	yes	INT
Xparam	long_offset	\033&l%sU	no	SIGNINT
Xparam	short_offset	\033&l%sZ	no	SIGNINT
Xparam	clear_margins	\0339		no	STRING
Xparam	hmi		\033&k%sH	no	FLOAT4
Xparam	left_margin	\033&a%sL	no	INT
Xparam	right_margin	\033&a%sM	no	INT
Xparam	vmi		\033&l%sC	no	FLOAT4
Xparam	text_length	\033&l%sF	no	INT
Xparam	top_margin	\033&l%sE	no	INT
Xparam	perf_skip	\033&l%sL	yes	INT
X
X
X##############################################################################
X#
X# Parameter Values
X#
X# When the third field in a "param" record is "yes", then the user's
X# value will be translated according to the rules in this section.
X# Each translation record has three fields:
X#
X#   - The parameter name to which this translation applies.
X#
X#   - The parameter value specified by the user.
X#
X#   - The parameter value to substitute for the user's value.
X#
X# Remember that letter case and punctuation are not significant when
X# matches upon fields 1 and 2 are performed.
X#
X
Xorientation	PORT			0	# portrait page orientation
Xorientation	LAND			1	# landscape page orientation
X
Xperf_skip	DISABLE			0	# disable perforation skip
Xperf_skip	ENABLE			1	# enable perforation skip
X
Xline_term	MAP_OFF			0	# CR=CR    LF=LF    FF=FF
Xline_term	MAP_CR			1	# CR=CR+LF LF=LF    FF=FF
Xline_term	MAP_LF			2	# CR=CR    LF=CR+LF FF=CR+FF
Xline_term	MAP_ALL			3	# CR=CR+LF LF=CR+LF FF=CR+FF
X
Xline_wrap	DISABLE			1	# disable long line wrap
Xline_wrap	ENABLE			0	# enable long line wrap
X
Xsymbol_set	HP_MATH7		0A	# HP Math-7
Xsymbol_set	HP_LINEDRAW		0B	# HP Line Draw
Xsymbol_set	ISO_60			0D	# ISO 60: Norwegian version 1
Xsymbol_set	ISO_61			1D	# ISO 61: Norwegian version 2
Xsymbol_set	HP_ROMAN		0E	# HP Roman Extension
Xsymbol_set	ISO_04			1E	# ISO 4: United Kingdom
Xsymbol_set	ISO_25			0F	# ISO 25: French
Xsymbol_set	ISO_69			1F	# ISO 69: French
Xsymbol_set	HP_GERMAN		0G	# HP German
Xsymbol_set	ISO_21			1G	# ISO 21: German
Xsymbol_set	HP_GREEK8		8G	# HP Greek-8
Xsymbol_set	ISO_15			0I	# ISO 15: Italian
Xsymbol_set	ISO_14			0K	# ISO 14: JIS ASCII
Xsymbol_set	ISO_57			2K	# ISO 57: Chinese
Xsymbol_set	TECHNICAL_7		1M	# Technical-7
Xsymbol_set	HP_MATH8		8M	# HP Math-8
Xsymbol_set	ISO_100			0N	# ISO 100: ECMA-94 (Latin 1)
Xsymbol_set	OCR_A			0O	# OCR A
Xsymbol_set	OCR_B			1O	# OCR B
Xsymbol_set	ISO_11			0S	# ISO 11: Swedish
Xsymbol_set	HP_SPANISH		1S	# HP Spanish
Xsymbol_set	ISO_17			2S	# ISO 17: Spanish
Xsymbol_set	ISO_10			3S	# ISO 10: Swedish
Xsymbol_set	ISO_16			4S	# ISO 16: Portugese
Xsymbol_set	ISO_84			5S	# ISO 84: Portugese
Xsymbol_set	ISO_85			6S	# ISO 85: Spanish
Xsymbol_set	ISO_6			0U	# ISO 6: ASCII
Xsymbol_set	HP_LEGAL		1U	# HP Legal
Xsymbol_set	ISO_2			2U	# ISO 2: Internat Ref Version
Xsymbol_set	OEM_1			7U	# OEM-1
Xsymbol_set	HP_ROMAN8		8U	# HP Roman-8
Xsymbol_set	PC_8			10U	# PC-8
Xsymbol_set	PC_8DN			11U	# PC-8 (D/N)
Xsymbol_set	HP_PIFONT		15U	# HP Pi Font
X
Xspacing		FIXED			0	# fixed font spacing
Xspacing		PROP			1	# proportional font spacing
X
Xstyle		UPRIGHT			0
Xstyle		ITALIC			1
X
Xstroke		ULTRA_THIN		-7
Xstroke		THIN			-5
Xstroke		LIGHT			-3
Xstroke		MEDIUM			 0
Xstroke		BOLD			 3
Xstroke		BLACK			 5
Xstroke		ULTRA_BLACK		 7
X
Xtypeface	LINE_PRINTER		0
Xtypeface	COURIER			3
Xtypeface	HELVETICA		4
Xtypeface	TIMES_ROMAN		5
Xtypeface	LETTER_GOTHIC		6
Xtypeface	PRESTIGE		8
Xtypeface	PRESENTATIONS		11
Xtypeface	OPTIMA			17
Xtypeface	GARAMOND		18
Xtypeface	COOPER_BLACK		19
Xtypeface	CORONET_BOLD		20
Xtypeface	BROADWAY		21
Xtypeface	BAUER_BODONI_BLACK_COND	22
Xtypeface	CENTURY_SCHOOLBOOK	23
Xtypeface	UNIVERSITY_ROMAN	24
X
Xpaper_source	CURRENT			0	# paper source unchanged
Xpaper_source	INTERNAL		1	# feed from internal tray
Xpaper_source	MANUAL			2	# paper from manual input
Xpaper_source	MANUAL_ENV		3	# envelope from manual input
Xpaper_source	LOWER			4	# lower cassette tray
X
Xpaper_size	EXECUTIVE		1	# 7.25" x 10.5" paper
Xpaper_size	LETTER			2	# 8.50" x 11.0" paper
Xpaper_size	LEGAL			3	# 8.50" x 14.0" paper
Xpaper_size	A4			26	# 210mm x 297mm paper
Xpaper_size	MONARCH			80	# letter envelope
Xpaper_size	COM10			81	# business envelope
Xpaper_size	DL			90	# 110mm x 220mm envelope
Xpaper_size	C5			91	# 162mm x 229mm envelope
X
X
X##############################################################################
X#
X# Page Dimensions (in dots)
X#
X# This section defines the dimensions of the page given particular "paper_size"
X# and "orientation" values.  This information was taken from the "LaserJet
X# Series II Technical Reference Manual".  Please don't change it.
X#
X#   A = physical page width
X#   B = physical page length
X#   C = logical page width
X#   D = max logical page length
X#   E = left physical page edge to left logical page edge
X#   F = right physical page edge to right logical page edge
X#   G = top physical page edge to top printable area edge
X#   H = bottom physical page edge to bottom printable area edge
X#
X#                             A     B     C     D     E     F     G     H
X#
Xpage_dim  letter     port  2550  3300  2400  3300    50   100    60    60
Xpage_dim  legal      port  2550  4200  2400  4200    50   100    60    60
Xpage_dim  executive  port  2175  3150  2025  3150    50   100    60    60
Xpage_dim  a4         port  2480  3507  2338  3507    50    92    60    58
Xpage_dim  com10      port  1237  2850  1087  2850    50   100    60    60
Xpage_dim  monarc     port  1162  2250  1012  2250    50   100    60    60
Xpage_dim  c5         port  1913  2704  1771  2704    50    92    60    58
Xpage_dim  dl         port  1299  2598  1157  2598    50    92    60    58
Xpage_dim  letter     land  3300  2550  3180  2550    60    60    50   100
Xpage_dim  legal      land  4200  2550  4080  2550    60    60    50   100
Xpage_dim  executive  land  3150  2175  3030  2175    60    60    50   100
Xpage_dim  a4         land  3507  2480  3389  2480    60    58    50    92
Xpage_dim  com10      land  2850  1237  2730  1237    60    60    50   100
Xpage_dim  monarc     land  2250  1162  2130  1162    60    60    50   100
Xpage_dim  c5         land  2704  1913  2586  1913    60    58    50    92
Xpage_dim  dl         land  2598  1299  2480  1299    60    58    50    92
X
END_OF_FILE_ljparam.dat
    size="`wc -c < ljparam.dat`"
    if test 9636 -ne "$size" ; then
	echo "ljparam.dat: extraction error - got $size chars"
    fi
fi
if test -f Makefile -a "$1" != "-c" ; then
    echo "Makefile: file exists - will not be overwritten"
else
    echo "x - Makefile (file 10 of 11, 1556 chars)"
    sed -e 's/^X//' << 'END_OF_FILE_Makefile' > Makefile
X
X# @(#) Makefile 1.1.1.1 90/06/22 17:40:59
X# Makefile for "ljinit" (generated by /local/bin/makemake version 1.00.09)
X# Created by bin@chinacat on Fri Jun 22 17:37:24 CDT 1990
X
XSHELL = /bin/sh
XCC = cc
XDEFS = 
XCOPTS = -O
XLOPTS = 
XLIBS = 
XDEBUG = -g -DDEBUG
XLINTFLAGS = -DLINT
X
XTARG = ljinit
XOTHERS = 
X
XSRCS = main.c param.c cmd.c misc.c
X
XOBJS = main.o param.o cmd.o misc.o
X
X# Any edits below this line will be lost if "makemake" is rerun!
X# Commands may be inserted after the '#%custom' line at the end of this file.
X
XCFLAGS = $(COPTS) $(DEFS) # $(DEBUG)
XLFLAGS = $(LOPTS) # $(DEBUG)
X
Xall:		$(TARG) $(OTHERS)
Xinstall:	all		; inst Install
Xclean:				; rm -f $(TARG) $(OBJS) a.out core $(TARG).lint
Xclobber:	clean		; inst -u Install
Xlint:		$(TARG).lint
X
X$(TARG):		$(OBJS)
X		$(CC) $(LFLAGS) -o $@ $(OBJS) $(LIBS)
X
X$(TARG).lint:	$(TARG)
X		lint $(LINTFLAGS) $(DEFS) $(SRCS) $(LIBS) > $@
X
Xmain.o: ljinit.h main.c patchlevel.h
Xparam.o: ljinit.h param.c
Xcmd.o: cmd.c ljinit.h
Xmisc.o: ljinit.h misc.c
X
Xmake:		;
X		/local/bin/makemake -i -v1.00.09 -aMakefile \
X		    -DSHELL='$(SHELL)' -DCC='$(CC)' -DDEFS='$(DEFS)' \
X		    -DCOPTS='$(COPTS)' -DLOPTS='$(LOPTS)' -DLIBS='$(LIBS)' \
X		    -DDEBUG='$(DEBUG)' -DLINTFLAGS='$(LINTFLAGS)' \
X		    -DOTHERS='$(OTHERS)' $(TARG) $(SRCS)
X
X#%custom - commands below this line will be maintained if 'makemake' is rerun
X
XSOURCES = README ljinit.h patchlevel.h main.c param.c cmd.c misc.c \
X	ljconfig.dat ljparam.dat Makefile testsheet
X
Xshar:		ljinit.shar
Xljinit.shar:	$(SOURCES)		; shar $(SOURCES) > $@
X
Xbom:					; what $(SOURCES)
X
END_OF_FILE_Makefile
    size="`wc -c < Makefile`"
    if test 1556 -ne "$size" ; then
	echo "Makefile: extraction error - got $size chars"
    fi
fi
if test -f testsheet -a "$1" != "-c" ; then
    echo "testsheet: file exists - will not be overwritten"
else
    echo "x - testsheet (file 11 of 11, 5894 chars)"
    sed -e 's/^X//' << 'END_OF_FILE_testsheet' > testsheet
XLine 01    <<< the quick brown fox jumped over the lazy dog >>>  Line 01
XLine 02    <<< the quick brown fox jumped over the lazy dog >>>  Line 02
XLine 03    <<< the quick brown fox jumped over the lazy dog >>>  Line 03
XLine 04    <<< the quick brown fox jumped over the lazy dog >>>  Line 04
XLine 05    <<< the quick brown fox jumped over the lazy dog >>>  Line 05
XLine 06    <<< the quick brown fox jumped over the lazy dog >>>  Line 06
XLine 07    <<< the quick brown fox jumped over the lazy dog >>>  Line 07
XLine 08    <<< the quick brown fox jumped over the lazy dog >>>  Line 08
XLine 09    <<< the quick brown fox jumped over the lazy dog >>>  Line 09
X
X---------==========----------==========----------==========----------==========----------==========----------==========----------==========----------==========----------==========----------==========----------==========----------==========----------=
X0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222
X0000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999000000000011111111112222222222333333333344444444445
X1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
X---------==========----------==========----------==========----------==========----------==========----------==========----------==========----------==========----------==========----------==========----------==========----------==========----------=
X
XLine 17    <<< the quick brown fox jumped over the lazy dog >>>  Line 17
XLine 18    <<< the quick brown fox jumped over the lazy dog >>>  Line 18
XLine 19    <<< the quick brown fox jumped over the lazy dog >>>  Line 19
XLine 20    <<< the quick brown fox jumped over the lazy dog >>>  Line 20
XLine 21    <<< the quick brown fox jumped over the lazy dog >>>  Line 21
XLine 22    <<< the quick brown fox jumped over the lazy dog >>>  Line 22
XLine 23    <<< the quick brown fox jumped over the lazy dog >>>  Line 23
XLine 24    <<< the quick brown fox jumped over the lazy dog >>>  Line 24
XLine 25    <<< the quick brown fox jumped over the lazy dog >>>  Line 25
XLine 26    <<< the quick brown fox jumped over the lazy dog >>>  Line 26
XLine 27    <<< the quick brown fox jumped over the lazy dog >>>  Line 27
XLine 28    <<< the quick brown fox jumped over the lazy dog >>>  Line 28
XLine 29    <<< the quick brown fox jumped over the lazy dog >>>  Line 29
XLine 30    <<< the quick brown fox jumped over the lazy dog >>>  Line 30
XLine 31    <<< the quick brown fox jumped over the lazy dog >>>  Line 31
XLine 32    <<< the quick brown fox jumped over the lazy dog >>>  Line 32
XLine 33    <<< the quick brown fox jumped over the lazy dog >>>  Line 33
XLine 34    <<< the quick brown fox jumped over the lazy dog >>>  Line 34
XLine 35    <<< the quick brown fox jumped over the lazy dog >>>  Line 35
XLine 36    <<< the quick brown fox jumped over the lazy dog >>>  Line 36
XLine 37    <<< the quick brown fox jumped over the lazy dog >>>  Line 37
XLine 38    <<< the quick brown fox jumped over the lazy dog >>>  Line 38
XLine 39    <<< the quick brown fox jumped over the lazy dog >>>  Line 39
XLine 40    <<< the quick brown fox jumped over the lazy dog >>>  Line 40
XLine 41    <<< the quick brown fox jumped over the lazy dog >>>  Line 41
XLine 42    <<< the quick brown fox jumped over the lazy dog >>>  Line 42
XLine 43    <<< the quick brown fox jumped over the lazy dog >>>  Line 43
XLine 44    <<< the quick brown fox jumped over the lazy dog >>>  Line 44
XLine 45    <<< the quick brown fox jumped over the lazy dog >>>  Line 45
XLine 46    <<< the quick brown fox jumped over the lazy dog >>>  Line 46
XLine 47    <<< the quick brown fox jumped over the lazy dog >>>  Line 47
XLine 48    <<< the quick brown fox jumped over the lazy dog >>>  Line 48
XLine 49    <<< the quick brown fox jumped over the lazy dog >>>  Line 49
XLine 50    <<< the quick brown fox jumped over the lazy dog >>>  Line 50
XLine 51    <<< the quick brown fox jumped over the lazy dog >>>  Line 51
XLine 52    <<< the quick brown fox jumped over the lazy dog >>>  Line 52
XLine 53    <<< the quick brown fox jumped over the lazy dog >>>  Line 53
XLine 54    <<< the quick brown fox jumped over the lazy dog >>>  Line 54
XLine 55    <<< the quick brown fox jumped over the lazy dog >>>  Line 55
XLine 56    <<< the quick brown fox jumped over the lazy dog >>>  Line 56
XLine 57    <<< the quick brown fox jumped over the lazy dog >>>  Line 57
XLine 58    <<< the quick brown fox jumped over the lazy dog >>>  Line 58
XLine 59    <<< the quick brown fox jumped over the lazy dog >>>  Line 59
XLine 60    <<< the quick brown fox jumped over the lazy dog >>>  Line 60
XLine 61    <<< the quick brown fox jumped over the lazy dog >>>  Line 61
XLine 62    <<< the quick brown fox jumped over the lazy dog >>>  Line 62
XLine 63    <<< the quick brown fox jumped over the lazy dog >>>  Line 63
XLine 64    <<< the quick brown fox jumped over the lazy dog >>>  Line 64
XLine 65    <<< the quick brown fox jumped over the lazy dog >>>  Line 65
XLine 66    <<< the quick brown fox jumped over the lazy dog >>>  Line 66
XLine 67    <<< the quick brown fox jumped over the lazy dog >>>  Line 67
XLine 68    <<< the quick brown fox jumped over the lazy dog >>>  Line 68
XLine 69    <<< the quick brown fox jumped over the lazy dog >>>  Line 69
XLine 70    <<< the quick brown fox jumped over the lazy dog >>>  Line 70
X
X@(#) testsheet 1.1 90/06/20 23:04:26
END_OF_FILE_testsheet
    size="`wc -c < testsheet`"
    if test 5894 -ne "$size" ; then
	echo "testsheet: extraction error - got $size chars"
    fi
fi
echo "done - 11 files extracted"
exit 0
-- 
Chip Rosenthal                            |  You aren't some icon carved out
chip@chinacat.Unicom.COM                  |  of soap, sent down here to clean
Unicom Systems Development, 512-482-8260  |  up my reputation.  -John Hiatt


