[comp.text] DVI-LaserJetII converter - Part 1 of 4

mah@hpuviea.UUCP (Michael Haberler) (01/19/89)

After several requests, here it comes: A dvi-> LaserJet II converter. Works
on MS-DOS, and Unixoids. I'm posting this for a friend who wrote it 
(neumann@awiwuw11.bitnet, aka Gustaf Neumann), so mail bugfixes there, please.

It's four parts. Unshar, and 'cat dvilj.c-part? >dvilj.c'; then make.

Enjoy,

Michael



# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by Michael Haberler <mah@hpuviea> on Wed Jan 18 17:56:28 1989
#
# This archive contains:
#	KIT		Makefile	README		commands.h	
#	dviprint.csh	findfile.h	
#

unset LANG

echo x - KIT
sed 's/^@//' >KIT <<'@EOF'
@From tuvie!AWIWUW11.BITNET!NEUMANN Wed May  4 09:41 MES 1988
Received: by hpuviea; Wed, 4 May 88 09:41:01 mes
@From: tuvie!AWIWUW11.BITNET!NEUMANN
Return-Path: <tuvie!AWIWUW11.BITNET!NEUMANN>
Received: from tuvie with uucp; Wed, 4 May 88 08:50:04
Received: by tuvie.uucp; Wed May  4 08:50:04 1988
Received: from mint.cern (mint) by cernvax.uucp (1.2/Ultrix2.0-B)
	id AA08277; Wed, 4 May 88 08:46:11 +0200
Received: by mint.cern (cernvax) (4.12/3.14)
	id AA25561; Wed, 4 May 88 08:46:03 +0200
Message-Id: <8805040646.AA25561@mint.cern>
Received: by cernvax Wed May  4 08:45:43
	from NEUMANN@AWIWUW11.BITNET for mailer@cernvax via rscs.
X-Bitnet-Sender: NEUMANN@AWIWUW11.BITNET 
Date: Tue, 03 May 88 20:05:34 WUT
To: hpuviea!mah
Comment: CROSSNET mail via MAILER@CERNVAX

You should receive additionally following files:
     
Text files:
   DVI2XX C
   DVI2XX HISTORY
   COMMANDS H
   FINDFILE H
   TESTPAGE TEX
     
regards
- gustaf


@EOF

chmod 644 KIT

echo x - Makefile
cat >Makefile <<'@EOF'
DEST	      = /usr/local/bin
EXTHDRS	      = /usr/include/ctype.h \
		/usr/include/signal.h \
		/usr/include/stdio.h \
		/usr/include/string.h \
		/usr/include/string.h
HDRS	      = commands.h \
		findfile.h
CFLAGS	      = +O1 -DLJ 
LDFLAGS	      =
LIBS	      =
LINKER	      = cc
MAKEFILE      = Makefile
OBJS	      = dvilj.o 
PRINT	      = pr
PROGRAM	      = dvilj
SRCS	      = dvilj.c 

all:		$(PROGRAM)

$(PROGRAM):     $(OBJS) $(LIBS)
		@echo -n "Loading $(PROGRAM) ... "
		@$(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)
		@echo "done"

clean:;		rm -f $(OBJS) dvilj

depend:;	@mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)

index:;		@ctags -wx $(HDRS) $(SRCS)

install:	$(PROGRAM)
		@echo Installing $(PROGRAM) in $(DEST)
		cp   $(PROGRAM) $(DEST)
		cp   dp  $(DEST)
		chmod 755   $(DEST)/$(PROGRAM) 
		chmod 755   $(DEST)/dp

print:;		@$(PRINT) $(HDRS) $(SRCS)

program:        $(PROGRAM)

tags:           $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)

update:		$(DEST)/$(PROGRAM)

$(DEST)/$(PROGRAM): $(SRCS) $(LIBS) $(HDRS) $(EXTHDRS)
		@make -f $(MAKEFILE) DEST=$(DEST) install
###
dvilj.o: commands.h /usr/include/string.h /usr/include/signal.h \
	/usr/include/stdio.h /usr/include/ctype.h findfile.h \
	/usr/include/string.h
gupk.o: /usr/include/stdio.h
@EOF

chmod 644 Makefile

echo x - README
sed 's/^@//' >README <<'@EOF'
@From tuvie!AWIWUW11.BITNET!NEUMANN Wed May  4 09:41 MES 1988
Received: by hpuviea; Wed, 4 May 88 09:41:34 mes
@From: tuvie!AWIWUW11.BITNET!NEUMANN
Return-Path: <tuvie!AWIWUW11.BITNET!NEUMANN>
Received: from tuvie with uucp; Wed, 4 May 88 08:50:59
Received: by tuvie.uucp; Wed May  4 08:50:59 1988
Received: from mint.cern (mint) by cernvax.uucp (1.2/Ultrix2.0-B)
	id AA08368; Wed, 4 May 88 08:48:19 +0200
Received: by mint.cern (cernvax) (4.12/3.14)
	id AA25589; Wed, 4 May 88 08:48:11 +0200
Message-Id: <8805040648.AA25589@mint.cern>
Received: by cernvax Wed May  4 08:48:03
	from NEUMANN@AWIWUW11.BITNET for mailer@cernvax via rscs.
X-Bitnet-Sender: NEUMANN@AWIWUW11.BITNET 
Date: Tue, 03 May 88 20:06:09 WUT
To: hpuviea!mah
Comment: CROSSNET mail via MAILER@CERNVAX

     
                       MINIDESCRIPTION FOR DVI2XX
     
This is a description of a dvi converter (dvi= TeX's device independent
output format) that runs on PCs (XTs, ATs or compatible) under MS/DOS.
DVI2XX is able to produce either device dependent code for the
HP-LaserJet+ or for the IBM3812 (model 1) depending on a preproscessor
switch at compile time.  The documentation concerning compile switches
is located in the source.
     
DVI2XX can be called with the following options:
     
   -aXXX    directory to take fonts from
   -b       take paper for first page from alternate cassette (only 3812)
   -eXXX    output file: either drive:path\name of outputfile
                         or device (such as lpt1, nul etc)
            (default is drive:path\name of dvi file and extentsion
            '.lj' for laserjet and '.pmp' for 3812)
   -hXXX    headerfile to be copied before translation of dvi-file
            (you can send arbitrary commands to the laserprinter)
   -fXXX    print from begin of page xxx
   -tXXX    print to end of page xxx
   -mXXX    magnification
   -xXXX    global x-offset in mm on output page
   -yXXX    global y-offset in mm on output page
   -r       toggle reverse/not reverse order for output
            (default reverse=FALSE for 3812, reverse=TRUE for LJ)
   -p       turn off font preload
   -q       quiet operation
   -w       no warnings
     
If no arguments are specifyed a short help file is displayed.
     
Two 'special' commands are implemented for the 3812:
     
   \special{file=drive:path/name}
            copy specified file to the printer;
            either vector- or bitmap-graphics PMP commands
     
   \special{orientation=Value}
            set page orientation to 0, 1, 2, 3;
            rotate following output to landscape mode etc.
            Depending on print direction!
     
With the file= special TeX command I have faked the signature of
my boss with nice thick ink. It is simply the pmp command for a
polygon drawing and it looks surprisingly natural.
     
The program part for redirection of the output to the printer without
intermediate spool file was relatively tricky and uses a IOCTL bios-call.
The performance of the program is about 6 to 7 seconds per page on a
AT with 8Mhz in the 3812 mode. It is running on our configuration
via PC-NET.
     
Currently two font formats are supported: PXL 1001 and PXL 1002.
     
The program assumes the following pixelfile structure (the characters
under quotes are mandatory):
     
    someroot
       ...
       "pxl"1500
          amr10.pxl
          cmr10.pxl
          ...
       "pxl"1643
          amr10.pxl
          cmr10.pxl
          ...
       ...
     
300dpi files can be used with an adequate magnification (-m#1250 option).
     
The following characters (all of them occur in the program)  might be
translated wrongly by the ASCII-EBCDIC-ASCII conversion during uploading
and downloading respectively:
     
!  exclamation point
[  left square bracket
\  left slash (backslash)
]  right square bracket
{  left curly bracket
|  vertical bar
}  right curly bracket
     
If the characters in the first column do not correspond to their verbal
description fix the C-program adequately.
     
The program can be compiled with microsoft C Rel.3 or later using the
-AL compiler option. If you have no adequate C-compiler at your site I can
send also the compiled code via e-mail. If you have troubles with downloading
please send me a floppy.
     
On troubles please read first comments ot the begin of the source
program. Otherwise contact me.
     
- Gustaf Neumann
  Wirtschaftsuniversitaet Wien
  Institut fuer Informationsverabeitung und Informationswirtschaft
  A-1090 Vienna
  Augasse 2-6
  Austria (Europe)
     
EARN/BITNET: NEUMANN at AWIWUW11
ARPA: neumann%awiwuw11.bitnet@wiscvm.ARPA
=========================================================================
Date: 25 August 1987, 16:58:19 WUT
@From: NEUMANN  at AWIWUW11
Subject: New release (0.30) of dvi2xx
     
Hi (potential) dvi2xx-user...
     
There is a new relase (0.30) of the dvi/3812 and dvi/HPLJ+
converter. The new release features in the following points:
     
- it accepts the new PK 89 format (Rokicki, Tugboat Vol 6, 1985, No. 3)
  that uses much less disk storage (about 1/4th of PXL1001 files),
- it is possible to specify a 'string of paths' to be searched for the
  PXL- or PK-files; the paths are separated by semicolons,
- it accepts as file-extension either '.pxl' or '.pk',
- the formats of the pixel-files (PXL-1001, PXL-1002, PK-89)
  can be arbitrarily mixed;
  eg. CMR10 can be in PXL-1002 format, CMINCH can be in PK-89,
- the amount of storage in the PC is reduced especially when
  PK-files are used,
- an unimportant bug from the timing measurements has been removed,
- verbatim mode can be set via commandline option -v, that informs
  the user, which fonts are loaded.
     
We are using the driver here in the following setup.
We have a print-server (IBM PC-AT) that is connected on one side with
the 3812 via 19200/asynchronous port, and on the other side with a bunch
of PC-ATs via IBM PC-Net. We use PC-TeX on the ATs. Historically
all of the PXL-files  have been on the print-server in 1002-format
being accessed from the dvi-driver over the network.
     
In the new setup, each of the PCs has a small set of the most used
PK-fonts. By specifying with the commandline option of dvi2xx
'-aLOCALFONTS;SERVERFONTS' where LOCALFONTS and SERVERFONTS are valid
fontdirectories, each font is searched first in LOCALFONTS
and if it is not found there in SERVERFONTS. Only seldomly used fonts
are accessed via PC-NET. The network load was reduced in this way
drastically, the speed improvement is about 30%.
     
If you have interest to receive the new version, please send a short
note ....
     
-gustaf
=========================================================================
Date: 12 November 1987, 12:11:00 WUT
@From: NEUMANN  at AWIWUW11
Subject: New release (0.31) of dvi2xx .. supports also new dir-structure
     
The newer versions of PCTeX (and some TeX-drivers) are distributed with
fonts put into a different directory structure that uses in the
directory names RESOLUTIONS rather than MAGNIFICATIONS.
     
The old directory structure standard was:
     
    somerootA
       ...
       "pxl"1500
          amr10.pxl
          cmr10.pxl
          cminch.pk
          ...
       "pxl"1643
          amr10.pxl
          cmr10.pxl
          tt10.pk
          ...
       ...
     
The new directory structure looks like:
     
    somerootB
       ...
       "DPI"300
          amr10.pxl
          cmr10.pxl
          cminch.pk
          ...
       "DPI"329
          amr10.pxl
          cmr10.pxl
          tt10.pk
          ...
       ...
     
Rel 0.31 supports both structures, it is possible to specify
a path ('-a' option eg '-asomerootA;somerootB').
     
The search order in one directory is:
   1) look for DPI....\font.pk     where '...' is eg  240
   2) look for DPI....\font.pxl            or         300
   3) look for pxl....\font.pk     where '...' is eg 1200
   4) look for pxl....\font.pxl            or         240
=========================================================================
Date: 1 Dezember 1987, 14:11:00 WUT
     
Rel 0.32 initializes in LJ-mode the printer and resets it after run;
helps when operating with the LJ2
=========================================================================
Date: 18 Dezember 1987, 18:18:00 WUT
     
Rel 0.33 runs without any modifications under Unix V (HP/UX);
improved messages for missing fonts.
========================================================================
Date: 5 January 1988, 04:04:04 WUT
@From: NEUMANN  at AWIWUW11
Subject: New release (0.40) of dvi2xx
     
Hi everybody!
     
The holidays are over and there comes a new release (0.40) of DVI2XX.
It has two major improvements over the previous release:
     
a) It supports 'HUGE' pixel characters;
b) it does a better positioning which is important mainly for the 3812.
c) Page origin is now on the 3812 and on the LJ2 1 inch from the left and
   right edge of the paper.
d) Smaller output files (== higher printing speed).
     
ad a)
      The driver knows now about three types of characters:
      -  Small characters are loaded into the font-storage of
         the printer. When a small character occurs in the text,
         the character is copied internally in the printer
         to the output page. The bitmaps of small characters
         are transmitted only once to the printer.
      -  Large characters are loaded into the memory of the driver
         and are transmitted on each occurance in the text as a
         raster graphic to the printer.
      -  Huge characters (characters which raster information has
         a size more than 32767 bytes) are read on each occurance from
         the disk and are transmitted as raster graphics. They are
         not loaded permanently into the memory of the driver.
     
      Why huge Characters?
      It is quite easy to include graphics into TeX by packing
      bitmap graphics into TeX fonts. I've written some programs
      to convert graphics generated from Drawing Gallery, Framework II,
      Scanning Gallery etc. into 1001 fonts and adequate TFM files
      (if you want to have more info on that send me a note).
      The graphics easily reach a size of 100 or 200K each, and so
      it is certainly a problem to keep these in memory.
     
      There are essentially 2 common ways to include graphics in TeX.
      - Using \special to include printer dependent code.
      - Putting the graphics into characters.
     
      Advantages of the latter are:
      1) The reproduction of the graphics is not device dependent
         (rather resolution dependent). It is possible to see
         text and graphics with a good previewer together on
         the screen.
      2) TeX sizes the graphics as it sizes characters. It is not
         necessary to include size infos about the graphics in the
         TeX file. When a graphic changes its size or shape, TeX is
         able to rearrange the output.
     
      I have scanned some photos and logos and included it in TeX
      documents. It really looks great.
     
      Please note that a standard LJ+ has not enough memory to generate
      big raster graphics.
     
ad b) The driver has had some problems with positioning of rules.
      In heavy formula djungles very often some lines have been placed
      wrong by one pixel. It is not so easy to draw lines exactly where
      you want using the 3812 vector drawing facilities... Additionally
      the conversion of the internal TeX units into pixels has gotten
      more accurate (also for the LJ). The result is a overall better
      outlook of the printed pages.
     
ad c) This is true at least for the European A4 paper trays.
     
ad d) Output has been reduced by more intelligent positioning (for
      both supported printers). Additionally the driver is more clever
      now in sending bitmap graphics to the LJ. The 3812-code is
      reduced approximately by 25% on a 20 page document.
     
Caveat: the driver is a little bit slower.
I hope I have not introduced to many new bugs.
=========================================================================
Date: 12 February 1988, 02:39:20 WUT
@From: NEUMANN  at AWIWUW11
Subject: New release (0.41) of dvi2xx
     
Hi everybody!
     
It's time for a new release of dvi2xx. The newest version (0.41)
features in the following points:
     
  - significantly better performance
  - a bunch of new options
     
Performance:
  The following figures are measured on a reasonably standard TeX
  document (16 pages long, contains several formulas and tables)
  on a PC/AT. The last two colums are also valid on Unix machines.
     
        time to convert dvi file  size of output file    printing speed
        (times faster as 0.40)    (index rel to 0.40)    (index rel 0.40)
     
  3812:           2.5                    0.64                  0.70
    LJ:           2.7                    0.53                  0.90
     
  The relative poor performance increase in printing speed for the LJ
  is due to the parallel (centronics) connection in the test configura-
  tion. It would increase to a similar value as for the 3812 if the
  printer is connected by a serial line and communication becomes the
  bottleneck.
     
  3 reasons are responsible for the improvements:
  -  More intelligent positioning commands for setting the characters
     on the page.
  -  Parts of the floating point arithmetic are changed now to integer
     arithmetic.
  -  MSC Rel. 5 is significantly faster as MSC Rel. 4 for the large
     memory model.
     
New options:
  -c (copies): specify number of copies to print
  -X define X page origin in dots
  -Y define Y page origin in dots
     HINT: -X and -Y allows you to set the page origin on your
           printer exactly to 1in/1in from the left corner. The
           provided testfile TESTPAGE.TEX helps you to figure out
           where the page origin is currently set to.
           (Mostly important for LJs and clones)
  -g (go): print without resetting the LJ at begin of file.
     
Changed options:
  -r option (reverse) on LJ: default changed to "print from
     first page to last"
  -x (set x offset relative to page origin in mm):
     accepts now floating point numbers
  -y (set y offset relative to page origin in mm):
     accepts now floating point numbers
     
  NOTE that options are now case sensitive!
     
Other changes:
  -  Warning messages are printed now to stdout instead of stderr.
     It is therefore easy now to redirect it.
  -  A bug in the computation of magnifications for directory names
     is removed (the computed value was sometimes wrong by 1).
  -  Several warning messages has been improved.
     
Send me a short note if you want to receive 0.41. Please indicate
your favorite flavor (source/compiled, uuencode etc).
     
-gustaf


@EOF

chmod 644 README

echo x - commands.h
cat >commands.h <<'@EOF'
/* DVI COMMANDS */
#define  SETC_000         0     /* typeset character 0 and move right */
#define  SETC_127       127     /* typeset character 127 and move right */
#define  SET1           128     /* typeset a character and move right */
#define  SET2           129     /* ??? */
#define  SET3           130     /* ??? */
#define  SET4           131     /* ??? */
#define  SET_RULE       132     /* typeset a rule and move right */
#define  PUT1           133     /* typeset a character */
#define  PUT2           134     /* ??? */
#define  PUT3           135     /* ??? */
#define  PUT4           136     /* ??? */
#define  PUT_RULE       137     /* typeset a rule */
#define  NOP            138     /* no operation */
#define  BOP            139     /* beginning of page */
#define  EOP            140     /* ending of page */
#define  PUSH           141     /* save the current positions */
#define  POP            142     /* restore previous positions */
#define  RIGHT1         143     /* move right */
#define  RIGHT2         144     /* ??? */
#define  RIGHT3         145     /* ??? */
#define  RIGHT4         146     /* ??? */
#define  W0             147     /* move right by :w: */
#define  W1             148     /* move right and set :w: */
#define  W2             149     /* ??? */
#define  W3             150     /* ??? */
#define  W4             151     /* ??? */
#define  X0             152     /* move right by :x: */
#define  X1             153     /* move right and set :x: */
#define  X2             154     /* ??? */
#define  X3             155     /* ??? */
#define  X4             156     /* ??? */
#define  DOWN1          157     /* move down */
#define  DOWN2          158     /* ??? */
#define  DOWN3          159     /* ??? */
#define  DOWN4          160     /* ??? */
#define  Y0             161     /* move down by :y: */
#define  Y1             162     /* move down and set :y: */
#define  Y2             163     /* ??? */
#define  Y3             164     /* ??? */
#define  Y4             165     /* ??? */
#define  Z0             166     /* move down by :z: */
#define  Z1             167     /* move down and set :z: */
#define  Z2             168     /* ??? */
#define  Z3             169     /* ??? */
#define  Z4             170     /* ??? */
#define  FONT_00        171     /* set current font to 0 */
#define  FONT_63        234     /* set current font to 0 */
#define  FNT1           235     /* set current font */
#define  FNT2           236     /* Same as FNT1, except that arg is 2 bytes */
#define  FNT3           237     /* Same as FNT1, except that arg is 3 bytes */
#define  FNT4           238     /* Same as FNT1, except that arg is 4 bytes */
#define  XXX1           239     /* extension to :.DVI primitives */
#define  XXX2           240     /* Like XXX1, but 0<=k<65536 */
#define  XXX3           241     /* Like XXX1, but 0<=k<:t$2^:24:$:> */
#define  XXX4           242     /* potentially long extension to :.DVI
                                   primitives */
#define  FNT_DEF1       243     /* define the meaning of a font number */
#define  FNT_DEF2       244     /* ??? */
#define  FNT_DEF3       245     /* ??? */
#define  FNT_DEF4       246     /* ??? */
#define  PRE            247     /* preamble */
#define  POST           248     /* postamble beginning */
#define  POST_POST      249     /* postamble ending */
        /*  undefined_commands           250,251,252,253,254,255 */


@EOF

chmod 644 commands.h

echo x - dviprint.csh
cat >dviprint.csh <<'@EOF'
#! /bin/csh -f
#	Script to print dvi files on a laserjet.
#	M. Haberler 3/9/87
#	- adaptded for V0.41 4/88
unset verbose
set unkflag
set file=""
set unquiet=""
set searchpath=""
set startat =""
set headerfile=""
set mag=""
set preload=""
set quiet=""
set reverse=""
set topage=""
set nowarn=""
set xoff=""
set yoff=""
set xorg=""
set yorg=""
set lpdest=""
set lpcopies=""
set lpsilent="-s"
set lpverbose=""

foreach argument ( $* )
    while ( 1 )
        switch ( $argument )
            case "-v":
		set unquiet="-v"
		set lpsilent=""
		set lpverbose="-w"
		break
	    case "-a*":
                set searchpath=$argument
		break
	    case "-f*":
                set startat=$argument
		break
	    case "-h*":
                set headerfile=$argument
		break
	    case "-m*":
                set mag=$argument
		break
	    case "-p":
                set preload=$argument
		break
	    case "-q*":
                set quiet=$argument
		break
	    case "-r":
                set reverse=$argument
		break
	    case "-t*":
                set topage=$argument
		break
	    case "-w":
                set nowarn=$argument
		break
	    case "-X*":
                set xorg=$argument
		break
	    case "-Y*":
                set yorg=$argument
		break
	    case "-x*":
                set xoff=$argument
		break
	    case "-y*":
                set yoff=$argument
		break
	    case "-d*":
                set lpdest=$argument
		break
	    case "-n*":
                set lpcopies=$argument
		break
            case "-*":    
                echo Unknown flag: \"$argument\"
                set unkflag = "$unkflag $argument"
                break
	    case "*":
		set file=$argument
		break
        endsw
        set argument = -`expr "$argument" : '-.\(.*\)'` || break
    end
end

dvilj $unquiet $searchpath $startat $headerfile $mag \
	$preload $quiet $reverse $topage $nowarn $xoff $yoff  \
	-e/usr/tmp/dvilj$$  $file
set xxx=$status
if ($xxx == 2) then
	echo "\n"
	echo bad return status from dvilj, nothing printed
else
	if ($xxx == 1) then
		echo "\n"
	    	echo Non-Fatal errors during conversion, printing anyway
	else
		echo "\n"
		echo Conversion ok, printing
	endif
	cat /usr/tmp/dvilj$$ | lp -onb -oraw  $lpdest $lpcopies $lpsilent $lpverbose
endif
rm  -f /usr/tmp/dvilj$$ 

#This is the DVI to HP Laserjet+ converter version 0.30 HP-9000/800
#usage: dvilj [OPTIONS] dvifile
#OPTIONS are:
#	-aX ..... X= searchpath leading to pixel-files (PK or PXL)
#	-eX ..... X= outputfile
#	-fX ..... print from begin of page number X
#	-hX ..... X= name of headerfile
#	-mX ..... magnification X=0;h;1;2;3;4;5;#xxxx
#	-p  ..... turn off font-preload 
#	-q  ..... quiet operation
#	-r  ..... don't process pages in reverse order
#	-tX ..... print to end of page number X
#	-w  ..... don't print out warnings
#	-v  ..... tell user what pixel-files are used
#	-xX ..... X= x-offset on printout in mm
#	-yX ..... X= y-offset on printout in mm
#
#
#	lp options
#	-or	raw output
#	-onb 	no banner
#	-dDEST	which printer
#	-s	silent
#	-w	write msg to terminal after done
#	-nNUMBER	make NUMBER copies (1=default)


@EOF

chmod 755 dviprint.csh

echo x - findfile.h
cat >findfile.h <<'@EOF'
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
int stat();
     
bool
findfile(path,n,fontmag,name)
char path[STRSIZE];  /* PIXEL path */
char n[STRSIZE];     /* name of font */
long fontmag;        /* magnification */
char name[STRSIZE];  /* full name of PXL file  (returned) */
{
    char local_path[STRSIZE];
    char * pathpt, *pppt;
    struct stat s;
    int rc;
    int resolution;
     
    pathpt = strcpy(local_path,path);
    resolution = (int)(fontmag/5.0 +0.5) ;
     
    do {
       pppt = strchr(pathpt , ';' );
       if (pppt != NULL) {
          *pppt = '\0';
          pppt++;
          }
     
       sprintf(name,"%s/dpi%d/%s.pk",pathpt,resolution,n);
       if ((rc = stat(name,&s))!=0) {
           sprintf(name,"%s/dpi%d/%s.pxl",pathpt,resolution,n);
           if ((rc = stat(name,&s))!=0) {
               sprintf(name,"%s/pxl%ld/%s.pk",pathpt,fontmag,n);
               if ((rc = stat(name,&s))!=0) {
                   sprintf(name,"%s/pxl%ld/%s.pxl",pathpt,fontmag,n);
                   rc = stat(name,&s);
               }
           }
       }
     
       if (rc==0) return(TRUE);
       else pathpt = pppt;
     } while (pathpt!=NULL);
     
    /* return error messaage */
    sprintf(name,"font not found: <%s>/<dpi%d;pxl%ld>/%s.<pk;pxl>",
                  path,resolution,fontmag,n);
     
return(FALSE);
}


@EOF

chmod 644 findfile.h

exit 0
-- 
Michael Haberler		mah@hpuviea.uucp 
Hewlett-Packard Austria GmbH, 	...mcvax!tuvie!hpuviea!mah
Lieblgasse 1 			...hplabs!hpfcla!hpbbn!hpuviea!mah
A-1220 Vienna, Austria		Tel: (0043) (222) 2500 x412 (9-18 CET)