[comp.sources.misc] v05i001: lwf

lee@uhccux.uhcc.Hawaii.Edu (Greg Lee ) (10/22/88)

Posting-number: Volume 5, Issue 1
Submitted-by: "Greg Lee " <lee@uhccux.uhcc.Hawaii.Edu>
Archive-name: lwf/Part1

This is a modification of a program by Barry Brachman to translate ascii
files to PostScript.  The first version appeared in comp.sources.unix in
May.  This version prints Japanese, encoded in the JIS standard (two
ascii characters per kanji).  You will need the font k14.snf from the X
window system, V11, R2, to use it -- the font is not included here (it's
too big).

		Greg Lee, lee@uhccux.uhcc.hawaii.edu

--------------------cut-----------------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 3)."
# Contents:  MANIFEST Makefile README Xmd.h Xprotostr.h fc.h font.h
#   fontstruct.h kfont.c ktest lwf.man misc.h os.h range.c servermd.h
# Wrapped by lee@uhccux on Wed Oct 19 17:12:32 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(672 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                   1	This shipping list
X Makefile                   1	
X README                     1	
X X.h                        2	
X Xmd.h                      1	
X Xproto.h                   3	
X Xprotostr.h                1	
X fc.h                       1	
X font.h                     1	
X fontstruct.h               1	
X kfont.c                    1	
X ktest                      1	
X lwf.c                      2	
X lwf.man                    1	
X misc.h                     1	
X os.h                       1	
X range.c                    1	
X servermd.h                 1	
END_OF_FILE
if test 672 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(1459 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X
XCFLAGS = -O
X
X# Where to put lwf
XLWF = /uh5h/ling/lee/bin/lwf
X
X# Where to put the man page
XMAN = /uh5h/ling/lee/man/manl/lwf.1
X
X# Where to put the PostScript prologue file
X#PROLOGUE = /uh5h/ling/lee/lib/lwf.prologue
X#(prologue incorporated -- gl)
X
X# Environment options:
X#
X# -DPR=\"where pr is if not /bin/pr\"
X# -DSYSV			For System V (assumes SYSV-style pr)
X# -DREVERSE=0		Set to non-zero if page reversal is to be the default
X# -DHOSTNAME=\"yourhostname\"	If you don't have the hostname() system call
X# -DKPLACE=\"/usr/local/lib/k14.snf\"	Or wherever the kanji font is
X# -DKANJI		To include the printing of kanji
X#ENV = -DPROLOGUE=\"$(PROLOGUE)\" -DREVERSE=0
XENV = -DREVERSE=0 -DKANJI -DKPLACE=\"k14.snf\"
X
XKFONT = kfont.o
XXHEADERS = X.h Xmd.h Xproto.h Xprotostr.h fc.h font.h fontstruct.h \
X misc.h os.h servermd.h
X
Xall:	lwf
X
Xlwf: lwf.o range.o $(KFONT)
X	cc $(CLFAGS) -o lwf lwf.o range.o $(KFONT) -lm
X
Xlwf.o: lwf.c
X	cc $(CFLAGS) -c $(ENV) lwf.c
X
Xrange.o: range.c
X	cc $(CFLAGS) -c range.c
X
Xkfont.o: kfont.c $(XHEADERS)
X	cc $(CFLAGS) -c kfont.c
X
X# Create the program to demonstrate and debug the range checking routine
Xrange: range.c
X	cc $(CFLAGS) -DRANGE_DEBUG -o range range.c
X
Xinstall: lwf lwf.man
X#	cp prologue $(PROLOGUE)
X#	chmod 0644 $(PROLOGUE)
X	cp lwf $(LWF)
X	chmod 0755 $(LWF)
X	ls -l $(LWF)
X	cp lwf.man $(MAN)
X	rm -f lwf lwf.o range.o kfont.o
X
Xlint:
X	lint -abchx $(ENV) lwf.c
X
Xclean:
X	rm -f core lwf lwf.o range.o kfont.o
X
Xshar:
X	makekit -nlwf. -m
END_OF_FILE
if test 1459 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(2332 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X
XLwf converts ASCII text files to PostScript.
XIt has been tested on the Apple LaserWriter/LaserWriter+ and the NEC
XSilentwriter LC-890.  Most of the processing is done on the host
Xrather than on the printer.  The name "lwf", perhaps poorly chosen, stands
Xfor "LaserWriter Filter".
X
XThere may be a couple of minor Berkeley-isms in the program (see the
Xroutine setup()) and it is somewhat Unix dependent (eg., popen(), /bin/pr
Xare expected).  The output conforms to the Adobe 2.0 file structuring
Xconventions.  The program is set up to use the (fixed-width) Courier font.
XIf you use another font you'll have to modify the mapping table in lwf.c.
XI can't recommend a proportional font for this purpose.
X
XThe distribution includes the following files:
X
XREADME      This file
XMakefile
Xlwf.c       LaserWriter filter to convert ASCII text to PostScript
Xrange.c     Routine to check if a number is in a given range
Xlwf.man     Manual page for lwf
Xprologue    Default PostScript support file
X
XPlease check the Makefile and the configurable #defines in lwf.c.
XCheck if the man page needs to be revised for your environment.
XYou can then proceed with 'make install'.
X
XIf you come across any bugs, including nonconformance to Adobe 2.0, or
Xmake any changes you'd like to share please send mail to me rather than
Xposting to the net.
X
XEnjoy.
X
X-----
XBarry Brachman           | {ihnp4!alberta,uw-beaver,uunet}!
XDept. of Computer Science|  ubc-vision!ubc-csgrads!brachman
XUniv. of British Columbia| brachman@grads.cs.ubc.cdn
XVancouver, B.C. V6T 1W5  | brachman%ubc.csnet@csnet-relay.arpa
X(604) 228-4327           | brachman@ubc.csnet
X
X-----
X
XChanges by Greg Lee, 10/88:
X
X(1) I eliminated the prologue file by printing out the contents
Xdirectly in lwf.c (don't like unnecessary library files hanging
Xaround).  Added supported point sizes 14, 16, 18.
X
X(2) Added support for printing Japanese language text.
X
X(3) Additional files:
X
Xkfont.c		routines for accessing kanji font k14.snf
X		(adapted from the X11, R2 font compiler, by Ralph Swick)
Xk14.snf (not included)
X		kanji font for kterm, from X11, R2
Xktest		sample file with Japanese text (= a posting in gnu.emacs.gnus)
XX.h		various .h files from the X11, R2 distribution
XXmd.h
XXproto.h
XXprotostr.h
Xfc.h
Xfont.h
Xfontstruct.h
Xmisc.h
Xos.h
Xservermd.h
X
X------
XGreg Lee, lee@uhccux.uhcc.hawaii.edu
X------
END_OF_FILE
if test 2332 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'Xmd.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Xmd.h'\"
else
echo shar: Extracting \"'Xmd.h'\" \(1967 characters\)
sed "s/^X//" >'Xmd.h' <<'END_OF_FILE'
X/***********************************************************
XCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X#ifndef XMD_H
X#define XMD_H 1
X/* $Header: Xmd.h,v 1.22 87/09/07 18:07:40 toddb Exp $ */
X/*
X *  Xmd.h: MACHINE DEPENDENT DECLARATIONS.
X */
X
X/*
X * ibm pcc doesn't understand pragmas.
X */
X#if defined(ibm032) && !defined(_pcc_)
Xpragma on(pointers_compatible);
Xpragma off(char_default_unsigned);
X#endif
X
X/*
X * Bitfield suffixes for the protocol structure elements, if you
X * need them.
X */
X#define B16
X#define B32
X
Xtypedef long           INT32;
Xtypedef short          INT16;
Xtypedef char           INT8;
X
Xtypedef unsigned long CARD32;
Xtypedef unsigned short CARD16;
Xtypedef unsigned char  CARD8;
X
Xtypedef unsigned long		BITS32;
Xtypedef unsigned short		BITS16;
Xtypedef unsigned char		BYTE;
X
Xtypedef unsigned char            BOOL;
X
X#endif /* XMD_H */
END_OF_FILE
if test 1967 -ne `wc -c <'Xmd.h'`; then
    echo shar: \"'Xmd.h'\" unpacked with wrong size!
fi
# end of 'Xmd.h'
fi
if test -f 'Xprotostr.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Xprotostr.h'\"
else
echo shar: Extracting \"'Xprotostr.h'\" \(1804 characters\)
sed "s/^X//" >'Xprotostr.h' <<'END_OF_FILE'
X/* $Header: Xprotostr.h,v 1.2 88/01/30 17:49:46 rws Exp $ */
X#ifndef XPROTOSTRUCTS_H
X#define XPROTOSTRUCTS_H
X
X/***********************************************************
XCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X#include "Xmd.h"
X
X/* Used by PolySegment */
X
Xtypedef struct _xSegment {
X    INT16 x1 B16, y1 B16, x2 B16, y2 B16;
X} xSegment;
X
X/* POINT */
X
Xtypedef struct _xPoint {
X	INT16		x B16, y B16;
X} xPoint;
X
Xtypedef struct _xRectangle {
X    INT16 x B16, y B16;
X    CARD16  width B16, height B16;
X} xRectangle;
X
X/*  ARC  */
X
Xtypedef struct _xArc {
X    INT16 x B16, y B16;
X    CARD16   width B16, height B16;
X    INT16   angle1 B16, angle2 B16;
X} xArc;
X
X#endif /* XPROTOSTRUCTS_H */
END_OF_FILE
if test 1804 -ne `wc -c <'Xprotostr.h'`; then
    echo shar: \"'Xprotostr.h'\" unpacked with wrong size!
fi
# end of 'Xprotostr.h'
fi
if test -f 'fc.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fc.h'\"
else
echo shar: Extracting \"'fc.h'\" \(2107 characters\)
sed "s/^X//" >'fc.h' <<'END_OF_FILE'
X#ifdef SYSV
X#include <memory.h>
X#define bzero(b,length) memset(b,0,length)
X/* these are not strictly equivalent, but suffice for uses here */
X#define bcopy(b1,b2,length) memcpy(b2,b1,length)
X#endif /* SYSV */
X
X#define MIN(a,b) ((a)>(b)?(b):(a))
X#define MAX(a,b) ((a)>(b)?(a):(b))
X
Xtypedef struct _GlyphMap {
X    char	*bits;
X    int		h;
X    int		w;
X    int		widthBytes;
X} GlyphMap;
X
X/*
X * a structure to hold all the pointers to make it easy to pass them all
X * around. Much like the FONT structure in the server.
X */
X
Xtypedef struct _TempFont {
X    FontInfoPtr pFI;
X    CharInfoPtr pCI;
X    unsigned char *pGlyphs;
X    FontPropPtr pFP;
X} TempFont; /* not called font since collides with type in X.h */
X
X#ifdef vax
X
X#	define DEFAULTGLPAD 	1		/* default padding for glyphs */
X#	define DEFAULTBITORDER 	LSBFirst	/* default bitmap bit order */
X
X#else
X# ifdef sun
X
X#  if (sun386 || sun5)
X#	define DEFAULTGLPAD 	4		/* default padding for glyphs */
X#	define DEFAULTBITORDER 	LSBFirst	/* default bitmap bit order */
X#  else
X#	define DEFAULTGLPAD 	4		/* default padding for glyphs */
X#	define DEFAULTBITORDER 	MSBFirst	/* default bitmap bit order */
X#  endif
X
X# else
X#  ifdef apollo
X
X#	define DEFAULTGLPAD 	2		/* default padding for glyphs */
X#	define DEFAULTBITORDER 	MSBFirst	/* default bitmap bit order */
X
X#  else
X#   ifdef ibm032
X
X#	define DEFAULTGLPAD 	1		/* default padding for glyphs */
X#	define DEFAULTBITORDER 	MSBFirst	/* default bitmap bit order */
X
X#   else
X#    ifdef hpux
X
X#	define DEFAULTGLPAD 	2		/* default padding for glyphs */
X#	define DEFAULTBITORDER 	MSBFirst	/* default bitmap bit order */
X
X#    else
X#	 define DEFAULTGLPAD 	1		/* default padding for glyphs */
X#	 define DEFAULTBITORDER MSBFirst	/* default bitmap bit order */
X#   	 define UNSPECIFIED
X
X#    endif
X#   endif
X#  endif
X# endif
X#endif
X
X#define GLWIDTHBYTESPADDED(bits,nbytes) \
X	((nbytes) == 1 ? (((bits)+7)>>3)	/* pad to 1 byte */ \
X	:(nbytes) == 2 ? ((((bits)+15)>>3)&~1)	/* pad to 2 bytes */ \
X	:(nbytes) == 4 ? ((((bits)+31)>>3)&~3)	/* pad to 4 bytes */ \
X	:(nbytes) == 8 ? ((((bits)+63)>>3)&~7)	/* pad to 8 bytes */ \
X	: 0)
X
END_OF_FILE
if test 2107 -ne `wc -c <'fc.h'`; then
    echo shar: \"'fc.h'\" unpacked with wrong size!
fi
# end of 'fc.h'
fi
if test -f 'font.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'font.h'\"
else
echo shar: Extracting \"'font.h'\" \(3869 characters\)
sed "s/^X//" >'font.h' <<'END_OF_FILE'
X/***********************************************************
XCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X#ifndef FONT_H
X#define FONT_H 1
X#define FONT_FILE_VERSION	4
X
X#include "servermd.h"
X
X#define NullCharInfo ((CharInfoPtr)0)
X#define NullFontInfo ((FontInfoPtr)0)
X#define LeftToRight 0
X#define RightToLeft 1
X#define BottomToTop 2
X#define TopToBottom 3
X/*
X * for linear char sets
X */
X#define n1dChars(pfi) ((pfi)->lastCol - (pfi)->firstCol + 1)
X#define chFirst firstCol	/* usage:  pfi->chFirst */
X#define chLast lastCol		/* usage:  pfi->chLast */
X
X/*
X * for 2D char sets
X */
X#define n2dChars(pfi)	(((pfi)->lastCol - (pfi)->firstCol + 1) * \
X			 ((pfi)->lastRow - (pfi)->firstRow + 1))
X
X/*
X * Some macros that font converters and font i/o routines will need.
X */
X
X#define	GLWIDTHPIXELS(pci) \
X	((pci)->metrics.rightSideBearing - (pci)->metrics.leftSideBearing)
X#define	GLHEIGHTPIXELS(pci) \
X 	((pci)->metrics.ascent + (pci)->metrics.descent)
X
X
X/*
X * the following macro definitions describe a font file image in memory
X */
X#define ADDRCharInfoRec( pfi)	\
X	((CharInfoRec *) &(pfi)[1])
X
X#define ADDRCHARGLYPHS( pfi)	\
X	(((char *) &(pfi)[1]) + BYTESOFCHARINFO(pfi))
X#define ADDRXTHISCHARINFO( pf, ch ) \
X        ((CharInfoRec *) &((pf)->pCI[(ch) - (pf)->pFI->chFirst]))
X
X
X/*
X * pad out glyphs to a CARD32 boundary
X */
X#define ADDRXFONTPROPS( pfi)  \
X	((DIXFontProp *) ((char *)ADDRCHARGLYPHS( pfi) + BYTESOFGLYPHINFO(pfi)))
X
X#define ADDRSTRINGTAB( pfi)  \
X	((char *)ADDRXFONTPROPS( pfi) + BYTESOFPROPINFO(pfi))
X
X#define	BYTESOFFONTINFO(pfi)	(sizeof(FontInfoRec))
X#define BYTESOFCHARINFO(pfi)	(sizeof(CharInfoRec) * n2dChars(pfi))
X#define	BYTESOFPROPINFO(pfi)	(sizeof(FontPropRec) * (pfi)->nProps)
X#define	BYTESOFSTRINGINFO(pfi)	((pfi)->lenStrings)
X#define	BYTESOFGLYPHINFO(pfi)	(((pfi)->maxbounds.byteOffset+3) & ~0x3)
X 
X#define	GLYPHWIDTHBYTES(pci)	(((GLYPHWIDTHPIXELS(pci))+7) >> 3)
X#define	GLYPHHEIGHTPIXELS(pci)	(pci->metrics.ascent + pci->metrics.descent)
X#define	GLYPHWIDTHPIXELS(pci)	(pci->metrics.rightSideBearing \
X				    - pci->metrics.leftSideBearing)
X#define GLWIDTHPADDED( bc)	((bc+7) & ~0x7)
X
X#if GLYPHPADBYTES == 0 || GLYPHPADBYTES == 1
X#define	GLYPHWIDTHBYTESPADDED(pci)	(GLYPHWIDTHBYTES(pci))
X#endif
X
X#if GLYPHPADBYTES == 2
X#define	GLYPHWIDTHBYTESPADDED(pci)	((GLYPHWIDTHBYTES(pci)+1) & ~0x1)
X#endif
X
X#if GLYPHPADBYTES == 4
X#define	GLYPHWIDTHBYTESPADDED(pci)	((GLYPHWIDTHBYTES(pci)+3) & ~0x3)
X#endif
X
X#if GLYPHPADBYTES == 8 /* for a cray? */
X#define	GLYPHWIDTHBYTESPADDED(pci)	((GLYPHWIDTHBYTES(pci)+7) & ~0x7)
X#endif
X
Xtypedef struct _FontProp *FontPropPtr;
Xtypedef struct _CharInfo *CharInfoPtr;
Xtypedef struct _FontInfo *FontInfoPtr;
Xtypedef unsigned int DrawDirection;
Xtypedef struct _ExtentInfo *ExtentInfoPtr;
X
X
X#endif /* FONT_H */
END_OF_FILE
if test 3869 -ne `wc -c <'font.h'`; then
    echo shar: \"'font.h'\" unpacked with wrong size!
fi
# end of 'font.h'
fi
if test -f 'fontstruct.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fontstruct.h'\"
else
echo shar: Extracting \"'fontstruct.h'\" \(4760 characters\)
sed "s/^X//" >'fontstruct.h' <<'END_OF_FILE'
X/***********************************************************
XCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X#ifndef FONTSTRUCT_H
X#define FONTSTRUCT_H 1
X#include "font.h"
X#include "misc.h"
X
X/*
X * This file describes the Server Natural Font format.
X * SNF fonts are both CPU-dependent and frame buffer bit order dependent.
X * This file is used by:
X *	1)  the server, to hold font information read out of font files.
X *	2)  font converters
X *
X * Each font file contains the following
X * data structures, with no padding in-between.
X *
X *	1)  The XFONTINFO structure
X *		hand-padded to a two-short boundary.
X *
X *	2)  The XCHARINFO array
X *		indexed directly with character codes, both on disk
X *		and in memory.
X *
X *	3)  Character glyphs
X *		padded in the server-natural way, and
X *		ordered in the device-natural way.
X *		End of glyphs padded to 32-bit boundary.
X *
X *	4)  nProps font properties
X *
X *	5)  a sequence of null-terminated strings, for font properties
X */
X
X
Xtypedef struct _FontProp { 
X	CARD32	name;		/* offset of string */
X	INT32	value;		/* number or offset of string */
X	Bool	indirect;	/* value is a string offset */
X} FontPropRec;
X
Xtypedef struct _CharInfo {
X    xCharInfo	metrics;	/* info preformatted for Queries */
X    unsigned	byteOffset:24;	/* byte offset of the raster from pGlyphs */
X    Bool	exists:1;	/* true iff glyph exists for this char */
X    unsigned	pad:7;		/* must be zero for now */
X} CharInfoRec;
X
X/*
X * maxbounds.byteOffset is the total number of bytes in the glyph array,
X * and maxbounds.bitOffset is total width of the unpadded font.
X */
Xtypedef struct _FontInfo {
X    unsigned int	version1;   /* version stamp */
X    unsigned int	allExist;
X    unsigned int	drawDirection;
X    unsigned int	noOverlap;	/* true if:
X					 * max(rightSideBearing-characterWidth)
X					 * <= minbounds->metrics.leftSideBearing
X					 */
X    unsigned int	constantMetrics;
X    unsigned int	terminalFont;	/* Should be deprecated!  true if:
X					   constant metrics &&
X					   leftSideBearing == 0 &&
X					   rightSideBearing == characterWidth &&
X					   ascent == fontAscent &&
X					   descent == fontDescent
X					*/
X    unsigned int	linear:1;	/* true if firstRow == lastRow */
X    unsigned int	constantWidth:1;  /* true if minbounds->metrics.characterWidth
X					   *      == maxbounds->metrics.characterWidth
X					   */
X    unsigned int	inkInside:1;    /* true if for all defined glyphs:
X					 * leftSideBearing >= 0 &&
X					 * rightSideBearing <= characterWidth &&
X					 * -fontDescent <= ascent <= fontAscent &&
X					 * -fontAscent <= descent <= fontDescent
X					 */
X    unsigned int	padding:29;
X    unsigned int	firstCol;
X    unsigned int	lastCol;
X    unsigned int	firstRow;
X    unsigned int	lastRow;
X    unsigned int	nProps;
X    unsigned int	lenStrings; /* length in bytes of string table */
X    unsigned int	chDefault;  /* default character */ 
X    unsigned int	fontDescent; /* minimum for quality typography */
X    unsigned int	fontAscent;  /* minimum for quality typography */
X    CharInfoRec		minbounds;  /* MIN of glyph metrics over all chars */
X    CharInfoRec		maxbounds;  /* MAX of glyph metrics over all chars */
X    unsigned int	pixDepth;   /* intensity bits per pixel */
X    unsigned int	glyphSets;  /* number of sets of glyphs, for
X					    sub-pixel positioning */
X    unsigned int	version2;   /* version stamp double-check */
X} FontInfoRec;
X
Xtypedef struct _ExtentInfo {
X    DrawDirection	drawDirection;
X    int			fontAscent;
X    int			fontDescent;
X    int			overallAscent;
X    int			overallDescent;
X    int			overallWidth;
X    int			overallLeft;
X    int			overallRight;
X} ExtentInfoRec;
X
X#endif /* FONTSTRUCT_H */
X
END_OF_FILE
if test 4760 -ne `wc -c <'fontstruct.h'`; then
    echo shar: \"'fontstruct.h'\" unpacked with wrong size!
fi
# end of 'fontstruct.h'
fi
if test -f 'kfont.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'kfont.c'\"
else
echo shar: Extracting \"'kfont.c'\" \(2702 characters\)
sed "s/^X//" >'kfont.c' <<'END_OF_FILE'
X/* 
X * $Locker:  $ 
X */ 
Xstatic char	*rcsid = "$Header: showsnf.c,v 1.4 87/12/17 13:12:46 rws Exp $";
X#include <stdio.h>
X#include <sys/types.h> 
X#include <sys/file.h> 
X#ifdef SYSV
X#include <fcntl.h>
X#endif /* SYSV */
X#include <sys/stat.h> 
X#include <errno.h> 
X
X#include "misc.h"
X#include "Xmd.h"
X#include "X.h"
X#include "Xproto.h"
X#include "fontstruct.h"
X#include "font.h"
X
X#include "fc.h"
X
X#ifndef u_char
X#define u_char	unsigned char
X#endif
X
Xchar *	malloc();
X
Xint glyphPad = DEFAULTGLPAD;
Xint bitorder = DEFAULTBITORDER;
X
XTempFont	tf;
Xchar		*kbuf;
X
Xint openkfont(file)
X	char	*file;
X{
X	struct stat	st;
X	FontInfoRec f;
X	int	fd, i, strings;
X
X	if (stat(file, &st) < 0) {
X		fprintf(stderr, "can't stat %s\n", file);
X		return(0);
X	}
X
X	fd = open(file, O_RDONLY);
X	if (fd < 0) {
X		fprintf(stderr, "can't open %s\n", file);
X		return(0);
X	}
X	kbuf = malloc(st.st_size);
X	read(fd, kbuf, st.st_size);
X	close(fd);
X	tf.pFI = (FontInfoPtr)kbuf;
X	tf.pCI = (CharInfoPtr)(kbuf + BYTESOFFONTINFO(tf.pFI));
X	tf.pGlyphs = ((unsigned char *)tf.pCI) + BYTESOFCHARINFO(tf.pFI);
X	tf.pFP = (FontPropPtr)(tf.pGlyphs + BYTESOFGLYPHINFO(tf.pFI));
X	strings = (int)tf.pFP + BYTESOFPROPINFO(tf.pFI);
X
X	for (i=0; i<tf.pFI->nProps; i++) {
X		tf.pFP[i].name += strings;
X		if (tf.pFP[i].indirect)
X			tf.pFP[i].value += strings;
X	}
X	return(1);
X}
X
Xclosekfont()
X{
X	free(kbuf);
X}
X
Xchar hexstring[80];
X
Xchar *kimage(crow, ccol)
X    int     crow, ccol;
X{
X	hexstring[0] = 0;
X	DumpBitmaps(&tf, crow, ccol);
X	return(hexstring);
X}
X
XDumpBitmaps(pFont, crow, ccol)
X    TempFont *pFont;
X    int	    crow, ccol;
X{
X    int			ch;	/* current character */
X    int			r;	/* current row */
X    int			b;	/* current bit in the row */
X    FontInfoPtr		pFI = pFont->pFI;
X    CharInfoPtr		pCI = pFont->pCI;
X    u_char *		bitmap = (u_char *)pFont->pGlyphs;
X    int			bpr;
X
X    ch = (crow - pFont->pFI->firstRow)
X	 * (pFont->pFI->lastCol - pFont->pFI->firstCol + 1)
X	 + ccol - pFont->pFI->firstCol;
X
X	bpr = GLWIDTHBYTESPADDED(pCI[ch].metrics.rightSideBearing
X		- pCI[ch].metrics.leftSideBearing, glyphPad);
X
X        if ( !pCI[ch].exists || pCI[ch].metrics.characterWidth == 0)
X            return;
X
X        for (r=0; r <  pCI[ch].metrics.descent + pCI[ch].metrics.ascent; r++)
X        {
X	    unsigned char *row = bitmap + pCI[ch].byteOffset+(r*bpr);
X            for ( b=0;
X		b < pCI[ch].metrics.rightSideBearing - pCI[ch].metrics.leftSideBearing;
X		b += 4) {
X		if (bitorder == LSBFirst) {
X			addxchar( (b&4)? (row[b>>3] & 0xf0)>>4
X				     :   (row[b>>3] & 0x0f) );
X		} else {
X			addxchar( (b&4)? (row[b>>3] & 0x0f)
X				     :   (row[b>>3] & 0xf0)>>4 );
X		}
X	    }
X        }
X}
X
Xaddxchar(nib)
Xint nib;
X{	char xs[3];
X
X	sprintf(xs, "%1x", nib);
X	strcat(hexstring, xs);
X}
END_OF_FILE
if test 2702 -ne `wc -c <'kfont.c'`; then
    echo shar: \"'kfont.c'\" unpacked with wrong size!
fi
# end of 'kfont.c'
fi
if test -f 'ktest' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ktest'\"
else
echo shar: Extracting \"'ktest'\" \(1506 characters\)
sed "s/^X//" >'ktest' <<'END_OF_FILE'
XPath: uhccux!humu!nosc!helios.ee.lbl.gov!lll-tis!lll-winken!uunet!tut.cis.ohio-state.edu!UUNET.UU.NET!kddlab!photon.stars.flab.fujitsu.junet!umerin
XFrom: kddlab!photon.stars.flab.fujitsu.junet!umerin@UUNET.UU.NET (Masanobu UMEDA)
XNewsgroups: gnu.emacs.gnus
XSubject: GNUS -> mh-e
XMessage-ID: <8809220642.AA00918@photon.stars.flab.fujitsu.junet>
XDate: 22 Sep 88 06:42:22 GMT
XReferences: <8809220425.AA00812@rei.stars.flab.fujitsu.junet>
XSender: daemon@tut.cis.ohio-state.edu
XDistribution: gnu
XOrganization: The Internet
XLines: 27
X
X
X   Date: Thu, 22 Sep 88 13:25:11 +0900
X   From: yuki@rei.stars.flab.fujitsu.junet
X
X   $@$^$:!$(Jmh-e $@$r;H$$$?$$$H$$$&$N$OMW$9$k$K$I$&$$$&5!G=$,$&$l$7$$$N$+$H$$(J
X   $@$&$H(J
X   (1) $@%*%j%8%J%k$KBP$7$F(J replcomps $@$H(J mhl.reply $@$,F/$$$F9%$_$N%X%C%@$,<+(J
X       $@F0E*$K$G$-$k!%(J
X   (2) C-c C-y $@$G%*%j%8%J%k$rFI$_9~$a$k(J.
X   (3) C-c C-s $@$G(J signature $@$,FI$_9~$a$k(J.
X   (4) draftfolder $@$r;H$C$F$$$k>l9g$K$OJ#?t$N(J draft $@$+$-$+$1$GCfCG$7$F$*(J
X       $@$1$k!%(J 
X   (5) Fcc $@$G95$($,%U%)%k%@$K$H$l$k!%(J
X   (6) alias $@5!G=$,;H$($k(J
X
XRMAIL $@$G4JC1$K$G$-$J$$$3$H$O(J (1) $@$@$1$G$9(J. 
X
X	(2) $@$b$A$m$s$G$-$^$9(J. 
X	(3)  C-c C-w $@$G$G$-$^$9(J.
X	(4) $@%P%C%U%!L>$rJQ99$9$l$P$G$-$^$9(J. 
X	(5) (setq mail-archive-file-name "$@%U%!%$%kL>(J") $@$G(J 
X	    $@F1$8$h$&$K(J Fcc: $@$GJ]B8$9$k$3$H$,$G$-$^$9(J.
X	    $@$?$@$7(J Unix mail format.
X	(6) $@$b$A$m$s$G$-$^$9(J.
X
XMasanobu UMEDA
Xumerin@flab.flab.Fujitsu.JUNET
Xumerin%flab.flab.Fujitsu.JUNET@uunet.uu.NET
END_OF_FILE
if test 1506 -ne `wc -c <'ktest'`; then
    echo shar: \"'ktest'\" unpacked with wrong size!
fi
# end of 'ktest'
fi
if test -f 'lwf.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'lwf.man'\"
else
echo shar: Extracting \"'lwf.man'\" \(7143 characters\)
sed "s/^X//" >'lwf.man' <<'END_OF_FILE'
X.TH LWF 1-LOCAL "21 February 1988"
X.UC
X.SH NAME
Xlwf \- ASCII to PostScript filter
X.SH SYNOPSIS
X.B lwf
X[-c#] [-d] [-i#] [-l] [-m] [-olist] [-p[str]]
X.br
X.ti +4
X[-P filename] [-r] [-s#] [-S] [-t#] [-v] [file ...]
X.SH DESCRIPTION
X.I Lwf
Xtakes one or more ASCII text files as input and produces PostScript
Xinstructions that may be sent (see \fBlpr(1)\fR) to a PostScript printer
X(e.g., an Apple LaserWriter) for printing.
XIf no files are given on the command line, the standard input is read.
XThe program correctly handles the form feed character and tabs and
Xunderstands backspacing; underscores followed by backspaces
Xmay be used to underline.
XCourier font is used for English text.
XAn external font,
X.I k14.snf
Xfrom the X window system, is used for
XJapanese language text.
XText between
X.B <ESC>$B
Xor
X.B <ESC>$J
Xor
X.B $@
Xand
X.B <ESC>(B
Xor
X.B <ESC>(J
Xor
X.B (J
Xis taken to be Japanese in the JIS code.
X(I hope this covers the conventions for switching to and
Xfrom Japanese in
X.I kterm
Xand
X.IR JTeX .)
X.PP
XThe output conforms to the Adobe 2.0 file structuring conventions.
X.PP
XNote that flag arguments apply to all of the files in the argument list.
XFor example, using ``-s8'' prints each of the files in 8 point type.
X.PP
XMultiple copies of each page can be printed by immediately following the
X.B -c
Xflag with the number of copies to make.
XThe pages are not collated.
X.PP
XLines may be indented (shifted to the right) using the \fB-i\fR flag.
XThis flag is immediately followed by the distance in inches to shift
Xall text from the left edge of the paper instead of the default amount
X(about 1/3 of an inch); the resolution is approximately 1/72 of an inch.
X.PP
XThe
X.B -l
Xflag indicates that landscape format is to be used instead of the default
Xportrait format.
X.PP
XMargins suitable for use with a three hole punch can be obtained using the
X.B -m
Xflag.
XThis flag may be used with either portrait or landscape mode.
XIn portrait mode the
X.B -m
Xflag and any indentation specified by a
X.B -i
Xflag are additive.
X.PP
XThe
X.B -o
Xflag is immediately followed by a range specification that indicates
Xwhich pages are to be printed.
XA range specification is a comma-separated list of numbers and ranges.
XA number N selects the Nth page;
Xa range N:M selects the Nth through Mth pages, inclusive;
Xan initial :N selects from the beginning up to and including the
XNth page; and a final N: selects from the Nth page to the end.
XThe default, ``:'', is to print all pages.
X.PP
XThe
X.B -p
Xflag indicates that
X.B pr(1)
Xis to be used to perform pagination and print page headers.
XAn argument string to be passed on to \fBpr(1)\fR can immediately
Xfollow the flag.
XThe usual way of producing multicolumn output is to pass a
X.B -n
Xflag to
X\fBpr(1)\fR, where
X.B n
Xis the number of columns to generate.
XNote that this string must be properly quoted if it contains whitespace,
Xmetacharacters, backslashes, etc.
X\fILwf\fR passes on the number of lines and columns to
X\fBpr(1)\fR so that multicolumn output is handled correctly.
XWhen specifying multicolumns you are responsible for selecting
Xan appropriate point size and/or landscape format.
XThe formfeed character is handled incorrectly by some versions of
X\fBpr(1)\fR when multiple columns have been specified.
XInstead of starting a new column or page it simply passes formfeeds
Xthrough.
X.B Lwf
Xfilters out these formfeeds.
X.PP
X.I Lwf
Xnormally includes a standard PostScript prologue in its output
X(usually /usr/local/lib/lwf.prologue).
XThe argument following a
X.B -P
Xflag specifies a prologue file to be substituted for the standard
Xsystem file.
X.PP
XThe default is to not perform page reversal, which is correct for printers
Xlike the NEC Silentwriter LC-890.
XThe
X.B -r
Xflag enables page reversal so that the pages appear in
Xthe correct sequence in the output tray of printers like the Apple
XLaserWriter.
X.PP
XThe
X.B -s
Xflag, immediately followed by a 7, 8, 9, 10, 11, 12, 14, 16, or 18 causes
Xthe corresponding point size to be used.
XThe default point size is 10.
X.PP
XBy default, the output of
X.I lwf
Xis intended to go through a spooler that monitors the status of the
Xprinter and separates jobs.
XThe
X.B -S
Xflag indicates that such a monitor is not being used and that a
Xheader page should be printed to separate jobs and end-of-file characters
Xshould be inserted in the output.
X.PP
XThe
X.B -t
Xflag is immediately followed by a number indicating the distance between
Xtab stops.
XThe default value is 8 characters.
X.PP
XThe
X.B -d
Xand
X.B -v
Xflags are used for debugging.
X.SH EXAMPLES
XThe command
X.sp 2
X.ti +5
Xlwf -p-2 -i0.5 -s12 file1.c file2.c | lpr -Plw
X.sp 2
Xwould print the two files on printer 'lw' in portrait format with
Xpage headings, indenting 0.5 inches from the left edge, using 12
Xpoint type.
XEach file would be printed in two columns.
X.sp 1
XThe command
X.sp 2
X.ti +5
Xlwf -l -s7 -p'-h foo' | lpr -Plw
X.sp 2
Xwould print the standard input with page headings in landscape format
Xusing 7 point type.
XThe filename for the header line would be 'foo'.
X.sp 1
XThe command
X.sp 2
X.ti +5
Xlwf -p'-h foo .login -h bar .cshrc' | lpr -Plw
X.sp 2
Xwould print the file ``.login'' with a header title ``foo'' and ``.cshrc''
Xwith the header title ``bar''.
X.sp 1
XA useful csh alias is:
X.sp 2
X.ti +5
Xalias prlw 'lwf -s7 -t4 -l -p-2 \\!* | lpr -Plw'
X.sp 2
Xwhich, when invoked as
X.sp 2
X.ti +5
Xprlw foo1 foo2
X.sp 2
Xprints foo1 and foo2, two columns per page, on printer 'lw'.
X.SH FILES
X/tmp/lwfXXXXXX		\- temporary file used for page reversal
X.br
X/usr/local/lib/k14.snf	\- Japanese font
X.SH SEE ALSO
Xpr(1), lpr(1)
X.SH LIMITATIONS
XThe maximum input line length is 1024 characters.
XThis should not present a problem since the corresponding output line
Xlength would be too long to be printed.
XThe program quits and prints a message if an input line is too long.
XOutput lines that are too long are normally silently truncated by the
Xprinter.
X.sp 2
X.I Lwf
Xcan be compiled such that there is a limit on the number of pages it can
Xproduce.
X.SH BUGS
XIt might be argued that flags should be allowed to be interspersed between
Xfile arguments.
X.sp 2
XThe character '\\001' (SOH) should not appear in the input as it is used
Xwithin the program to delimit columns.
XThe first time the program reads this character it determines the number
Xof columns being printed; all subsequent lines are expected to
Xhave this number of columns or be ``single column''.
X.sp 2
XA \fB-s\fR flag should not be passed on to \fBpr(1)\fR since
X.I lwf
Xuses it.
X.sp 2
XThe program can only handle the 9 different point sizes, the single
XLW font Courier, and the single external kanji raster font k14.
X(The data for the 14, 16, and 18 point sizes was added by GL without
Xtesting.)
XThe printing of Japanese text is slow, since the Japanese characters
Xare not loaded to the LW as a PostScript font (there are too many
Xof them to do that).
X.sp 2
XSo much for metric.
X.SH AUTHORS
XBarry Brachman
X.br
XDept. of Computer Science
X.br
XUniversity of British Columbia
X.sp
XGreg Lee, lee@uhccux.uhcc.hawaii.edu (extension to print kanji)
X.br
XDept. of Linguistics
X.br
XUniversity of Hawaii
X.sp
XCode for accessing the X font was taken from the X programs
X.I showsnf.c fontutil.c
Xwritten by Ralph Swick.
X
END_OF_FILE
if test 7143 -ne `wc -c <'lwf.man'`; then
    echo shar: \"'lwf.man'\" unpacked with wrong size!
fi
# end of 'lwf.man'
fi
if test -f 'misc.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'misc.h'\"
else
echo shar: Extracting \"'misc.h'\" \(3109 characters\)
sed "s/^X//" >'misc.h' <<'END_OF_FILE'
X/***********************************************************
XCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X/* $Header: misc.h,v 1.48 88/02/21 18:25:20 rws Exp $ */
X#ifndef MISC_H
X#define MISC_H 1
X/*
X *  X internal definitions 
X *
X */
X
X
Xextern unsigned long globalSerialNumber;
X
X#ifndef NULL
X#define NULL            0
X#endif
X
X#define MAXSCREENS	3
X#define MAXCLIENTS	128
X#define MAXFORMATS	8
X#define MAXVISUALS_PER_SCREEN 50
X
Xtypedef unsigned char *pointer;
Xtypedef int Bool;
Xtypedef unsigned long PIXEL;
Xtypedef unsigned long ATOM;
X
X
X#ifndef TRUE
X#define TRUE 1
X#define FALSE 0
X#endif
X#include "os.h" 	/* for ALLOCATE_LOCAL and DEALLOCATE_LOCAL */
X
X#define NullBox ((BoxPtr)0)
X#define MILLI_PER_MIN (1000 * 60)
X#define MILLI_PER_SECOND (1000)
X
X    /* this next is used with None and ParentRelative to tell
X       PaintWin() what to use to paint the background. Also used
X       in the macro IS_VALID_PIXMAP */
X
X#define USE_BACKGROUND_PIXEL 3
X#define USE_BORDER_PIXEL 3
X
X
X/* byte swap a long literal */
X#define lswapl(x) ((((x) & 0xff) << 24) |\
X		   (((x) & 0xff00) << 8) |\
X		   (((x) & 0xff0000) >> 8) |\
X		   (((x) >> 24) & 0xff))
X
X/* byte swap a short literal */
X#define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
X
X#define min(a, b) (((a) < (b)) ? (a) : (b))
X#define max(a, b) (((a) > (b)) ? (a) : (b))
X#define abs(a) ((a) > 0 ? (a) : -(a))
X#define fabs(a) ((a) > 0.0 ? (a) : -(a))	/* floating absolute value */
X#define sign(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))
X
X#define MAXSHORT 32767
X#define MINSHORT -MAXSHORT 
X
X
X/* byte swap a long */
X#define swapl(x, n) n = ((char *) (x))[0];\
X		 ((char *) (x))[0] = ((char *) (x))[3];\
X		 ((char *) (x))[3] = n;\
X		 n = ((char *) (x))[1];\
X		 ((char *) (x))[1] = ((char *) (x))[2];\
X		 ((char *) (x))[2] = n;
X
X/* byte swap a short */
X#define swaps(x, n) n = ((char *) (x))[0];\
X		 ((char *) (x))[0] = ((char *) (x))[1];\
X		 ((char *) (x))[1] = n
X
X
X
Xtypedef struct _DDXPoint *DDXPointPtr;
Xtypedef struct _Box *BoxPtr;
X
X#endif /* MISC_H */
END_OF_FILE
if test 3109 -ne `wc -c <'misc.h'`; then
    echo shar: \"'misc.h'\" unpacked with wrong size!
fi
# end of 'misc.h'
fi
if test -f 'os.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'os.h'\"
else
echo shar: Extracting \"'os.h'\" \(3138 characters\)
sed "s/^X//" >'os.h' <<'END_OF_FILE'
X/***********************************************************
XCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X
X/* $Header: os.h,v 1.23 88/01/04 08:34:02 rws Exp $ */
X
X#ifndef OS_H
X#define OS_H
X#include "misc.h"
X
X#define NullFID ((FID) 0)
X
X#define SCREEN_SAVER_ON   0
X#define SCREEN_SAVER_OFF  1
X#define SCREEN_SAVER_FORCER 2
X
X#define MAX_REQUEST_SIZE 16384
X
Xtypedef pointer	FID;
Xtypedef struct _FontPathRec *FontPathPtr;
Xtypedef struct _NewClientRec *NewClientPtr;
X
X/*
X * os-dependent definition of local allocation and deallocation
X * If you need something other than malloc/free for ALLOCATE/DEALLOCATE
X * LOCAL then you add that to the beginning of this set.  Note that
X * some machines do not return a valid pointer for malloc(0), in
X * which case we provide an alternate under the control of the
X * define MALLOC_0_RETURNS_NULL.  This is necessary because some
X * server code expects malloc(0) to return a valid pointer to storage.
X */
X#if defined(ibm032) && !defined(_pcc_)
X
Xchar *alloca();
X
X#define ALLOCATE_LOCAL(size) alloca((int)(size))
X#define DEALLOCATE_LOCAL(ptr)
Xpragma on(alloca);
X
X#else /* everyone else */
X
Xchar *malloc();
X
X# ifdef MALLOC_0_RETURNS_NULL
X# define ALLOCATE_LOCAL(size) malloc((unsigned)((size) > 0 ? (size) : 1))
X# else
X# define ALLOCATE_LOCAL(size) malloc((unsigned)(size))
X# endif
X
X#define DEALLOCATE_LOCAL(ptr) free((char *)(ptr))
X
X#endif
X
X#define xalloc(size) Xalloc((unsigned long)(size))
X#define xrealloc(ptr, size) Xrealloc((pointer)(ptr), (unsigned long)(size))
X#define xfree(ptr) Xfree((pointer)(ptr))
X
Xchar *ReadRequestFromClient();   /* should be xReq but then include Xproto.h */
XBool CloseDownConnection();
Xvoid CreateWellKnownSockets();
Xvoid SetDefaultFontPath();
Xvoid FreeFontRecord();
Xvoid SetFontPath();
XFontPathPtr GetFontPath();
XFontPathPtr ExpandFontNamePattern();
XFID FiOpenForRead();
Xvoid AbortServer();
Xvoid ErrorF();
Xunsigned long *Xalloc();
Xunsigned long *Xrealloc();
Xvoid Xfree();
X
Xchar *strcat();
Xchar *strncat();
Xchar *strcpy();
Xchar *strncpy();
X
X#endif /* OS_H */
END_OF_FILE
if test 3138 -ne `wc -c <'os.h'`; then
    echo shar: \"'os.h'\" unpacked with wrong size!
fi
# end of 'os.h'
fi
if test -f 'range.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'range.c'\"
else
echo shar: Extracting \"'range.c'\" \(7832 characters\)
sed "s/^X//" >'range.c' <<'END_OF_FILE'
X/* vi: set tabstop=4 : */
X
X/*
X * Return 1 if the given number is in the specified range,
X * -1 if there is an error in the range specification,
X * 0 otherwise
X *
X * Ranges have a similar (we use a colon instead of a dash) form to that
X * used by [nt]roff; i.e., a comma separated list of specifiers of the
X * form:
X *	1) n	means     x such that x = n
X *	2) :n	means all x such that x <= n
X *	3) n:	means all x such that x >= n
X *	4) n:m	means all x such that n <= x <= m
X *	5) :	means all x
X * n is an int
X *
X * Problems:
X * The routine prints an error message if the range is strange - this
X * might not always be desirable.
X *
X * Jul/86 BJB
X */
X
X/*
X * ===================================================================
X *
X * Permission is given to freely copy and distribute this software
X * providing:
X *
X *	1) You do not sell it,
X *	2) You do not use it for commercial advantage, and
X *	3) This notice accompanies the distribution
X *
X * Copyright (c) 1988
X * Barry Brachman
X * Dept. of Computer Science
X * Univ. of British Columbia
X * Vancouver, B.C. V6T 1W5
X *
X * .. {ihnp4!alberta, uw-beaver, uunet}!ubc-vision!ubc-csgrads!brachman
X * brachman@grads.cs.ubc.cdn
X * brachman%ubc.csnet@csnet-relay.arpa
X * brachman@ubc.csnet
X * ====================================================================
X */
X
X#include <ctype.h>
X#include <stdio.h>
X
X#define streq(a, b)			(!strcmp((a), (b)))
X#define smalloc(a, t, s)	((a = (t) malloc((unsigned) (s))) == NULL)
X#define srealloc(a, t, b, s) ((a = (t) realloc(b, (unsigned) (s))) == NULL)
X#define max(a, b)			((a) >= (b) ? (a) : (b))
X
X#define SEP_CHAR	':'
X#define SEP_T		0		/* separator token */
X#define NUM_T		1		/* number token */
X#define BAD_T		2		/* token for bad character */
X
X#define STR_ALLOC	80
X
Xstruct range_header {
X	char *range_str;		/* range character string */
X	int range_str_alloc;	/* length in bytes */
X	int nranges;			/* number of range entries */
X	struct range *range;
X} range_header = {
X	NULL, 0, NULL
X};
X
X/*
X * If hflag (lflag) is non-zero then the high (low) value is present
X */
Xstruct range {
X	char hflag;			/* high value present */
X	char lflag;			/* low value present */
X	int high;			/* high part of range */
X	int low;			/* low part of range */
X};
X
X#ifdef RANGE_DEBUG
X
X/*
X * This is a program for demonstrating and debugging the range checking
X * code
X * Enter a range when prompted
X * (If there is a previous range shown you may enter <return> to
X * reselect it)
X * Enter a value
X * The program will indicate whether the value is in the given range
X */
X
Xchar buf[BUFSIZ], range[BUFSIZ];
X
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X	register int i;
X	char *p;
X	struct range_header *rh;
X	struct range *r;
X	FILE *fp;
X	char *gets(), *index(), *strcpy();
X
X	buf[0] = range[0] = '\0';
X	if (argc == 2) {
X		if ((fp = fopen(argv[1], "r")) == NULL) {
X			(void) fprintf(stderr, "Can't open %s\n", argv[1]);
X			exit(1);
X			/*NOTREACHED*/
X		}
X	}
X	else
X		fp = stdin;
X
X	if (fp == stdin)
X		(void) printf("Range? ");
X	while (fgets(buf, sizeof(buf), fp) != NULL) {
X		if ((p = index(buf, '\n')) != NULL)
X			*p = '\0';
X		if (buf[0] != '\0') {
X			(void) strcpy(range, buf);
X			if (checkrange(range)) {
X				if (fp == stdin)
X					(void) printf("Range? ");
X				continue;
X			}
X			rh = &range_header;
X			(void) printf("%s (%d alloc) (%d ranges):\n",
X			      rh->range_str, rh->range_str_alloc, rh->nranges);
X			for (r = rh->range, i = 0; i < rh->nranges; i++, r++)
X				(void) printf("hflag=%d lflag=%d high=%d low=%d\n",
X					r->hflag, r->lflag, r->high, r->low);
X		}
X		if (fp != stdin)
X			continue;
X		(void) printf("Value? ");
X		if (gets(buf) == NULL)
X			break;
X		i = inrange(atoi(buf), range);
X		if (i == 0)
X			(void) printf("\tno\n");
X		else if (i == 1)
X			(void) printf("\tyes\n");
X		else if (i == -1)
X			(void) printf("\terror\n");
X		else
X			(void) printf("\tbad result\n");
X		(void) printf("Range ['%s']? ", range);
X	}
X	(void) printf("\n");
X}
X#endif RANGE_DEBUG
X
X/*
X * Check and compile the given range specification and then determine if
X * the number is in the range
X * Return -1 if there is a compilation error, 1 if the number is in the
X * range, or 0 if the number isn't in the range
X */
Xinrange(num, range_spec)
Xint num;
Xchar *range_spec;
X{
X	register int i, rc;
X	register struct range_header *rh;
X	register struct range *r;
X
X	if (checkrange(range_spec))
X		return(-1);
X	rh = &range_header;
X	rc = 0;
X	for (r = rh->range, i = 0; rc == 0 && i < rh->nranges; i++, r++) {
X		if (r->hflag) {
X			if (num > r->high)
X				continue;
X			if (r->lflag && num < r->low)
X				continue;
X			rc = 1;
X		}
X		else if (r->lflag) {
X			if (num >= r->low)
X				rc = 1;
X		}
X		else				/* both unset -> ":" */
X			rc = 1;
X	}
X	return(rc);
X}
X
X/*
X * Check and compile a range specification
X * Print a message and return -1 on error; return 0 oth.
X *
X * Could be more efficient by allocating more structures at a time... SMOP
X */
Xcheckrange(range_spec)
Xchar *range_spec;
X{
X	register struct range_header *rh;
X	register struct range *r;
X	int len;
X	int ltype, lval, rtype, rval;
X	char *p;
X	char *malloc(), *realloc(), *strcpy();
X
X	rh = &range_header;
X	/*
X	 * Check if the previous range is being used
X	 */
X	if (rh->range_str != NULL && streq(range_spec, rh->range_str))
X		return(0);
X
X	/*
X	 * New range spec
X	 * If there is enough space, reuse it; oth. allocate enough
X	 * (amount allocated never shrinks)
X	 */
X	len = max(strlen(range_spec) + 1, STR_ALLOC);
X	if (rh->range_str != NULL  && len > rh->range_str_alloc) {
X		free(rh->range_str);
X		rh->range_str = (char *) malloc((unsigned) len);
X		rh->range_str_alloc = len;
X	}
X	else if (rh->range_str == NULL) {
X		rh->range_str = (char *) malloc((unsigned) len);
X		rh->range_str_alloc = len;
X	}
X	(void) strcpy(rh->range_str, range_spec);
X	if (rh->range != NULL)
X		free((char *) rh->range);
X	rh->range = NULL;
X
X	p = range_spec;
X	while (1) {
X		lval = getnum(&p, &ltype);
X		if (ltype == BAD_T) {
X			(void) fprintf(stderr, "range: bad first number\n");
X			*rh->range_str = '\0';		/* invalidate */
X			return(-1);
X		}
X
X		if (rh->range == NULL) {
X			smalloc(r, struct range *, sizeof(struct range));
X			rh->nranges = 1;
X		}
X		else {
X			len = sizeof(struct range) * ++(rh->nranges);
X			srealloc(r, struct range *, (char *) rh->range, len);
X		}
X		rh->range = r;
X		r += rh->nranges - 1;		/* point to new one */
X		r->hflag = r->lflag = 0;
X		r->high = r->low = 0;
X
X		/*
X		 * If ltype != NUM_T there is no lval
X		 */
X		if (ltype == NUM_T) {
X			r->lflag = 1;
X			r->low = lval;
X		}
X
X		switch (*p) {
X		case ',':			/* single number */
X			r->hflag = 1;
X			r->high = lval;
X			p++;
X			continue;
X
X		case '\0':			/* single number at end */
X			r->hflag = 1;
X			r->high = lval;
X			return(0);
X
X		case ':':
X			p++;
X			if (*p == '\0')		/* no rval */
X				return(0);
X			if (*p == ',') {	/* no rval */
X				p++;
X				break;
X			}
X
X			rval = getnum(&p, &rtype);
X			if (rtype == BAD_T) {
X				(void) fprintf(stderr, "range: bad second number\n");
X				*rh->range_str = '\0';
X				return(-1);
X			}
X
X			if (lval > rval) {
X				(void) fprintf(stderr, "range: values reversed\n");
X				*rh->range_str = '\0';	/* invalidate */
X				return(-1);
X			}
X			r->hflag = 1;
X			r->high = rval;
X			if (*p == '\0')
X				return(0);
X			if (*p == ',')
X				p++;
X			break;
X
X		default:
X			(void) fprintf(stderr, "range: bad character\n");
X			*rh->range_str = '\0';		/* invalidate */
X			return(-1);
X		}
X	}
X}
X
Xstatic
Xgetnum(pp, type)
Xchar **pp;
Xint *type;
X{
X	register int sign, val;
X	register char *p;
X
X	p = *pp;
X	if (!isdigit(*p) && *p != '-') {
X		if (*p == SEP_CHAR)
X			*type = SEP_T;
X		else
X			*type = BAD_T;
X		return(0);
X	}
X	sign = 1;
X	if (*p == '-') {
X		sign = -1;
X		p++;
X	}
X	if (!isdigit(*p)) {
X		*type = BAD_T;
X		return(0);
X	}
X	for (val = 0; isdigit(*p) && *p != '\0'; p++)
X		val = val * 10 + *p - '0';
X	if (*p != '\0' && *p != ',' && *p != SEP_CHAR) {
X		*type = BAD_T;
X		return(0);
X	}
X	*pp = p;
X	*type = NUM_T;
X	return(sign * val);
X}
X
END_OF_FILE
if test 7832 -ne `wc -c <'range.c'`; then
    echo shar: \"'range.c'\" unpacked with wrong size!
fi
# end of 'range.c'
fi
if test -f 'servermd.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'servermd.h'\"
else
echo shar: Extracting \"'servermd.h'\" \(5985 characters\)
sed "s/^X//" >'servermd.h' <<'END_OF_FILE'
X/***********************************************************
XCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X#ifndef SERVERMD_H
X#define SERVERMD_H 1
X/* $Header: servermd.h,v 1.30 88/05/17 13:41:01 rws Exp $ */
X
X/*
X * The vendor string identifies the vendor responsible for the
X * server executable.
X */
X#ifndef VENDOR_STRING
X#define VENDOR_STRING "MIT X Consortium"
X#endif	VENDOR_STRING
X
X/*
X * The vendor release number identifies, for the purpose of submitting
X * traceable bug reports, the release number of software produced
X * by the vendor.
X */
X#ifndef VENDOR_RELEASE
X#define VENDOR_RELEASE	2
X#endif	VENDOR_RELEASE
X
X/*
X * Machine dependent values:
X * GLYPHPADBYTES should be chosen with consideration for the space-time
X * trade-off.  Padding to 0 bytes means that there is no wasted space
X * in the font bitmaps (both on disk and in memory), but that access of
X * the bitmaps will cause odd-address memory references.  Padding to
X * 2 bytes would ensure even address memory references and would
X * be suitable for a 68010-class machine, but at the expense of wasted
X * space in the font bitmaps.  Padding to 4 bytes would be good
X * for real 32 bit machines, etc.  Be sure that you tell the font
X * compiler what kind of padding you want because its defines are
X * kept separate from this.  See server/include/fonts.h for how
X * GLYPHPADBYTES is used.
X *
X * Along with this, you should choose an appropriate value for
X * GETLEFTBITS_ALIGNMENT, which is used in ddx/mfb/maskbits.h.  This
X * constant choses what kind of memory references are guarenteed during
X * font access; either 1, 2 or 4, for byte, word or longword access,
X * respectively.  For instance, if you have decided to to have
X * GLYPHPADBYTES == 4, then it is pointless for you to have a
X * GETLEFTBITS_ALIGNMENT > 1, because the padding of the fonts has already
X * guarenteed you that your fonts are longword aligned.  On the other
X * hand, even if you have chosen GLYPHPADBYTES == 1 to save space, you may
X * also decide that the computing involved in aligning the pointer is more
X * costly than an odd-address access; you choose GETLEFTBITS_ALIGNMENT == 1.
X * 
X * XXX: this code has changed since beta test and only GLYPHPADBYTES == 4
X * has been tested, hence all machines have this same value.
X *
X */
X
X#ifdef vax
X
X#define IMAGE_BYTE_ORDER	LSBFirst        /* Values for the VAX only */
X#define BITMAP_BIT_ORDER	LSBFirst
X#define	GLYPHPADBYTES		1
X#define GETLEFTBITS_ALIGNMENT	4
X
X#else
X# ifdef sun
X
X# if (sun386 || sun5)
X#define IMAGE_BYTE_ORDER	LSBFirst        /* Values for the SUN only */
X#define BITMAP_BIT_ORDER	LSBFirst
X# else
X#define IMAGE_BYTE_ORDER	MSBFirst        /* Values for the SUN only */
X#define BITMAP_BIT_ORDER	MSBFirst
X# endif
X
X#define	GLYPHPADBYTES		4
X#define GETLEFTBITS_ALIGNMENT	4
X
X# else
X#  ifdef apollo
X
X#define IMAGE_BYTE_ORDER	MSBFirst        /* Values for the Apollo only*/
X#define BITMAP_BIT_ORDER	MSBFirst
X#define	GLYPHPADBYTES		2
X#define GETLEFTBITS_ALIGNMENT	4
X
X#  else
X#   ifdef ibm032
X
X#define IMAGE_BYTE_ORDER	MSBFirst        /* Values for the RT only*/
X#define BITMAP_BIT_ORDER	MSBFirst
X#define	GLYPHPADBYTES		1
X#define GETLEFTBITS_ALIGNMENT	4
X/* ibm pcc doesn't understand pragmas. */
X
X#   else
X#    ifdef hpux
X
X#define IMAGE_BYTE_ORDER	MSBFirst        /* Values for the HP only */
X#define BITMAP_BIT_ORDER	MSBFirst
X#define	GLYPHPADBYTES		2
X#define	GETLEFTBITS_ALIGNMENT	4
X
X#    endif
X
X#   endif
X#  endif
X# endif
X#endif
X
X/* size of buffer to use with GetImage, measured in bytes. There's obviously
X * a trade-off between the amount of stack (or whatever ALLOCATE_LOCAL gives
X * you) used and the number of times the ddx routine has to be called.
X * 
X * for a 1024 x 864 bit monochrome screen  with a 32 bit word we get 
X * 8192/4 words per buffer 
X * (1024/32) = 32 words per scanline
X * 2048 words per buffer / 32 words per scanline = 64 scanlines per buffer
X * 864 scanlines / 64 scanlines = 14 buffers to draw a full screen
X */
X#define IMAGE_BUFSIZE		8192
X
X/* pad scanline to a longword */
X#define BITMAP_SCANLINE_UNIT	32
X#define BITMAP_SCANLINE_PAD  32
X
X#define LOG2_BITMAP_PAD		5
X#define LOG2_BYTES_PER_SCANLINE_PAD	2
X
X/* 
X *   This returns the number of padding units, for depth d and width w.
X * For bitmaps this can be calculated with the macros above.
X * Other depths require either grovelling over the formats field of the
X * screenInfo or hardwired constants.
X */
X
Xtypedef struct _PaddingInfo {
X	int	scanlinePad;
X	int	bitmapPadLog2;
X} PaddingInfo;
Xextern PaddingInfo PixmapWidthPaddingInfo[];
X
X#define PixmapWidthInPadUnits(w, d) \
X    (((w) + PixmapWidthPaddingInfo[d].scanlinePad) >> \
X	PixmapWidthPaddingInfo[d].bitmapPadLog2)
X
X/*
X *	Return the number of bytes to which a scanline of the given
X * depth and width will be padded.
X */
X#define PixmapBytePad(w, d) \
X    (PixmapWidthInPadUnits(w, d) << LOG2_BYTES_PER_SCANLINE_PAD)
X
X#endif SERVERMD_H
END_OF_FILE
if test 5985 -ne `wc -c <'servermd.h'`; then
    echo shar: \"'servermd.h'\" unpacked with wrong size!
fi
# end of 'servermd.h'
fi
echo shar: End of archive 1 \(of 3\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 3 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0

-- 
         -- Greg, lee@uhccux.uhcc.hawaii.edu