#! /usr/local/bin/magicfilter
#
# Magicfilter Script for PriMa 
#
# You may need to change some lines or use your own file instead!
#

# PostScript files: No conversion!
0	%!		cat

# DVI files: convert to PostScript using dvips
0	\367\002	fpipe	/usr/bin/dvips -mode bjtenex -D360 -q -f

# compress'd data
0	\037\235	pipe	/bin/gzip  -cdq 

# compressed files (packed, gzip, freeze, and SCO LZH respectively)
0	\037\036	pipe	/bin/gzip  -cdq 
0	\037\213	pipe	/bin/gzip  -cdq 
0	\037\236	pipe	/bin/gzip  -cdq 
0	\037\240	pipe	/bin/gzip  -cdq 

# troff documents
0	.so\040		reject	Attempted to print a ".so" troff file.
0	.\?\?\040	fpipe	`/usr/bin/grog  -Tps $FILE` 
0	.\\\"		fpipe	`/usr/bin/grog  -Tps $FILE` 
0	'\\\"		fpipe	`/usr/bin/grog  -Tps $FILE` 
0	'.\\\"		fpipe	`/usr/bin/grog  -Tps $FILE` 
0	\\\"		fpipe	`/usr/bin/grog  -Tps $FILE` 

# ditroff
0	"x T ps"	pipe	/usr/bin/grops 
0	"x T dvi"	pipe	/usr/bin/grodvi 
0	"x T ascii"	pipe	/usr/bin/grotty 
0	"x T latin1"	pipe	/usr/bin/grotty 
0	"x T lj4"	reject	Cannot print LJ4 ditroff files.

# Portable bit-, grey- and pixmaps: convert to PostScript
0	P1\n		pipe	/usr/local/bin/pbmplus/pnmtops  \
	-scale 1000 -dpi 360 2>/dev/null
0	P2\n		pipe	/usr/local/bin/pbmplus/pnmtops  \
	-scale 1000 -dpi 360 2>/dev/null
0	P3\n		pipe	/usr/local/bin/pbmplus/pnmtops  \
	-scale 1000 -dpi 360 2>/dev/null
0	P4\n		pipe	/usr/local/bin/pbmplus/pnmtops  \
	-scale 1000 -dpi 360 2>/dev/null
0	P5\n		pipe	/usr/local/bin/pbmplus/pnmtops  \
	-scale 1000 -dpi 360 2>/dev/null
0	P6\n		pipe	/usr/local/bin/pbmplus/pnmtops  \
	-scale 1000 -dpi 360 2>/dev/null

# PJL: Sorry, this printer doesn't do PJL
0	\033%-12345X	reject	Cannot print PJL files on this printer.
0	"@PJL "		reject	Cannot print PJL files on this printer.
0	@PJL\t		reject	Cannot print PJL files on this printer.
0	@PJL\r		reject	Cannot print PJL files on this printer.
0	@PJL\n		reject	Cannot print PJL files on this printer.

# GIF files: convert to PPM
0	GIF87a		pipe	/usr/local/bin/pbmplus/giftoppm  2>/dev/null
0	GIF89a		pipe	/usr/local/bin/pbmplus/giftoppm  2>/dev/null

# JFIF (JPEG) files: convert to PPM/PGM
0	\377\330\377\340\?\?JFIF\0	pipe	/usr/local/bin/djpeg  -pnm

# TIFF files (lousy magic!!)
0	MM		pipe	/usr/local/bin/pbmplus/tifftopnm  2>/dev/null
0	II		pipe	/usr/local/bin/pbmplus/tifftopnm  2>/dev/null

# BMP files (even lousier magic -- I guess that's what you can expect
# for something out of Microsoft)
0	BM\?\?\?\?\?\?\?\?\?\?\?\?\x0c	reject	Cannot print OS/2 1.x \
	bitmaps on this printer.
0	BM\?\?\?\?\?\?\?\?\?\?\?\?\x40	reject	Cannot print OS/2 2.x \
	bitmaps on this printer.
0	BM\?\?\?\?\?\?\?\?\?\?\?\?\x28	reject	Cannot print Windows 3.x \
	bitmaps on this printer.

# Sun rasterfiles
0	\x59\xa6\x6a\x95 pipe	/usr/local/bin/pbmplus/rasttopnm  2>/dev/null

# SGI Imagelib (RGB) files
0	\x1\xda		reject	Cannot print SGI RGB files on this printer.
0	\xda\x1		reject	Cannot print SGI RGB files on this printer.

#
# Standard rejects... things we don't want to print
#

# Various archive formats
257	ustar\0		reject	Attempted to print a tar file.
257	"ustar  \0"	reject	Attempted to print a tar file.
0	07070		reject	Attempted to print a cpio file.
0	PK\3\4		reject	Attempted to print a zip file.
20	\xdc\xa7\xc7\xfd reject	Attempted to print a zoo file.

# Binaries (Linux): reject with email message
0	\013\1d\0	reject	Attempted to print a compiled binary.
0	\100\1d\0	reject	Attempted to print a compiled binary.
0	\007\1d\0	reject	Attempted to print a compiled binary.
0	\314\0d\0	reject	Attempted to print a compiled binary.
0	\177ELF		reject	Attempted to print an ELF object.
0	\007\001\0	reject	Attempted to print an object file.
216	\021\001\0\0	reject	Attempted to print a core dump file.
0	!<arch>		reject	Attempted to print an archive.
0	=<ar>		reject	Attempted to print an archive.

# Don't confuse this one with troff!
0	.snd		reject	Attempted to print Sun/NeXT audio data.

# wild guesses
# If starts with <ESC>, assume raw printer data
0	\033		cat
# optimistic troff magic
0	.		fpipe	`/usr/bin/grog  -Tps $FILE` 
# wacko troff magic
0	'''		fpipe	`/usr/bin/grog  -Tps $FILE` 

# Default entry -- for normal (text) files.  MUST BE LAST.
default			fpipe	/usr/bin/a2ps -p -1 -nP -8 -H...
