#
`# magicfilter for 'ifdef(`Vendor',`the 'Vendor` ',)Printer
#
dnl
dnl Build the output-postscript filter; if this is a postscript file,
dnl just dump it to the printer, otherwise if a DEVICE is specified
dnl and either DPI or PS_OPTIONS are set, run ghostscript, else fall
dnl over dead.
dnl

define(Cat,`ifdef(`PRINTER',`pipe/>forward/',cat)')dnl
define(Filter,`ifdef(`PRINTER',`pipe/>forward/',filter)')dnl
define(PostScript,`ifdef(`PRINTER',`pipe/>forward/',postscript)')dnl
define(Copy,`ifdef(`PRINTER',filter defn(`PRINTER'),cat)')dnl
ifdef(`PRINTER', `/>forward/	Copy')

define(PSopts,`-q -dBATCH -dPARANOIDSAFER -dSAFER -dNOPAUSE ifdef(`papersize',`-sPAPERSIZE='papersize,) ifdef(`DEVICE',`-sDEVICE='DEVICE,) ifdef(`DPI', `-r'DPI ,) `ifdef(`PS_OPTIONS',defn(`PS_OPTIONS'))' -sOutputFile=@GSOUT@ - -c quit')dnl
define(PScmd, ifdef(`PATH_GS',
		`ifdef(`DEVICE', Filter PATH_GS defn(`PSopts'),
		    `ifdef(`PS_OPTIONS', Filter PATH_GS defn(`PSopts'),
			reject)')'))dnl
define(PSfilter,`ifelse(POSTSCRIPT,true, PostScript, defn(`PScmd'))')dnl
define(PDFfilter, `ifdef(`PATH_ACROREAD',
			    pipe/postscript/ PATH_ACROREAD -toPostScript,
		    `ifelse(defn(`PScmd'),reject,
			ifdef(`PATH_GS',`f'Filter PATH_GS -sDEVICE=psrgb defn(`PSopts') $FILE,reject),
			`f'defn(`PScmd') $FILE)')')dnl
ifelse(defn(`PSfilter'),reject,,
define(PSfromText, 
	`ifdef(`PATH_PSTEXT',
	    pipe/postscript/ PATH_PSTEXT ifdef(`papersize',`-T'papersize,),
	    `ifdef(`PATH_NENSCRIPT',
		pipe/postscript/ PATH_NENSCRIPT ifdef(`papersize',`-T'papersize,) @NENSCRIPT_QUIET@ -p -,
		    reject)')')dnl
#
# Portable imagemaps.
#
/p[gbp]m/	ifdef(`PATH_PNMTOPS',pipe/postscript/ PATH_PNMTOPS -quiet, reject)

#
# picture formats.
#
/gif/              ifdef(`PATH_GIFTOPPM',pipe/p[gbp]m/ PATH_GIFTOPPM,reject)
/jpeg/             ifdef(`PATH_DJPEG',pipe/p[gbp]m/ PATH_DJPEG -pnm,reject)
/PNG image/        ifdef(`PATH_PNGTOPNM',pipe/p[gbp]m/ PATH_PNGTOPNM,reject)
/TIFF image/       ifdef(`PATH_TIFFTOPNM',pipe/p[gbp]m/ PATH_TIFFTOPNM,reject)
/PC bitmap data/   ifdef(`PATH_BMPTOPPM',pipe/p[gbp]m/ PATH_BMPTOPPM,reject)
/Sun raster image/ ifdef(`PATH_RASTTOPNM',pipe/p[gbp]m/ PATH_RASTTOPNM,reject)
/SGI image data/   ifdef(`PATH_SGITOPNM',pipe/p[gbp]m/ PATH_SGITOPNM,reject)

#
# Miscellaneous formats.
#
/fig/		ifdef(`PATH_FIGTODEV',pipe/postscript/ PATH_FIGTODEV -Lps -P -l dummy,reject)
/dvi/		ifdef(`PATH_DVIPS', fpipe/postscript/ PATH_DVIPS ifdef(`XDPI',-X XDPI -Y YDPI, -D DPI) -R -q -f,reject)
/fax.*normal/	ifdef(`PATH_G3TOPBM',pipe/p[gbp]m/ PATH_G3TOPBM -stretch,reject)
/fax/		ifdef(`PATH_G3TOPBM',pipe/p[gbp]m/ PATH_G3TOPBM,reject)
)dnl

#
# compressed formats.
#
/compress/	ifdef(`PATH_ZCAT', pipe PATH_ZCAT,
		    `ifdef(`PATH_GZIP', pipe PATH_GZIP -dc, reject)')
/gzip/		ifdef(`PATH_GZIP', pipe PATH_GZIP -dc, reject)
/packed/	ifdef(`PATH_GZIP', pipe PATH_GZIP -dc, reject)
/frozen/	ifdef(`PATH_GZIP', pipe PATH_GZIP -dc, reject)
/lzh/		ifdef(`PATH_GZIP', pipe PATH_GZIP -dc, reject)
/bzip/		ifdef(`PATH_BZIP', pipe PATH_BZIP -dc, reject)

dnl
dnl after everything else, put out the methods for printing postscript,
dnl pcl, and pjl.
dnl
#
# printer languages.
#
ifelse(defn(`PSfilter'),reject,
define(`PCLprint',reject)dnl,
define(`PCLprint',`ifdef(`PATH_UNPCL',pipe PATH_UNPCL @UNPCL_FLAGS@,reject)')dnl
)dnl
define(PCLfilter, `ifelse(PCL,true,Copy,PCLprint)')dnl
define(PJLfilter, `ifelse(PJL,true,Copy,`ifelse(PCL,true,Copy,PCLprint)')')dnl

/postscript/	PSfilter
/pdf/		PDFfilter
/pcl/		PCLfilter
/Printer Job Language/		PJLfilter

dnl
dnl default print policy:  if HANDLE_TEXT is defined, use that to
dnl print the file, otherwise if PRINTER is defined, use that to
dnl print the file, otherwise if TEXT is not false, just cat it,
dnl otherwise if a PS filter is defined, use pstext, else reject it
dnl
#
# text, finally
#
/text/		ifdef(`HANDLE_TEXT',defn(`HANDLE_TEXT'),
                    `ifdef(`PRINTER',defn(`Copy'),
			`ifelse(defn(`TEXT'),false,
			    defn(`PSfromText'),
			    text defn(`TEXT_ARGS'))')')
# EOF
