aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/examples/printing/diablo-if-net7
-rw-r--r--share/examples/printing/hpdf59
-rw-r--r--share/examples/printing/hpif11
-rw-r--r--share/examples/printing/hpof8
-rw-r--r--share/examples/printing/hprf8
-rw-r--r--share/examples/printing/hpvf10
-rw-r--r--share/examples/printing/if-simple9
-rw-r--r--share/examples/printing/if-simpleX10
-rw-r--r--share/examples/printing/ifhp32
-rw-r--r--share/examples/printing/make-ps-header79
-rw-r--r--share/examples/printing/netprint24
-rw-r--r--share/examples/printing/psdf8
-rw-r--r--share/examples/printing/psdfX31
-rw-r--r--share/examples/printing/psif23
-rw-r--r--share/examples/printing/pstf6
-rw-r--r--share/examples/printing/pstfX6
16 files changed, 331 insertions, 0 deletions
diff --git a/share/examples/printing/diablo-if-net b/share/examples/printing/diablo-if-net
new file mode 100644
index 000000000000..b2ba028f2343
--- /dev/null
+++ b/share/examples/printing/diablo-if-net
@@ -0,0 +1,7 @@
+#!/bin/sh
+#
+# diablo-if-net - Text filter for Diablo printer `scrivener' listening
+# on port 5100. Installed in /usr/local/libexec/diablo-if-net
+#
+
+exec /usr/libexec/lpr/lpf "$@" | /usr/local/libexec/netprint scrivener 5100
diff --git a/share/examples/printing/hpdf b/share/examples/printing/hpdf
new file mode 100644
index 000000000000..d03c3ac70dfd
--- /dev/null
+++ b/share/examples/printing/hpdf
@@ -0,0 +1,59 @@
+#!/bin/sh
+#
+# hpdf - Print DVI data on HP/PCL printer
+# Installed in /usr/local/libexec/hpdf
+
+PATH=/usr/local/bin:$PATH; export PATH
+
+#
+# Define a function to clean up our temporary files. These exist
+# in the current directory, which will be the spooling directory
+# for the printer.
+#
+cleanup() {
+ rm -f hpdf$$.dvi
+}
+
+#
+# Define a function to handle fatal errors: print the given message
+# and exit 2. Exiting with 2 tells LPD to do not try to reprint the
+# job.
+#
+fatal() {
+ echo "$@" 1>&2
+ cleanup
+ exit 2
+}
+
+#
+# If user removes the job, LPD will send SIGINT, so trap SIGINT
+# (and a few other signals) to clean up after ourselves.
+#
+trap cleanup 1 2 15
+
+#
+# Make sure we are not colliding with any existing files.
+#
+cleanup
+
+#
+# Link the DVI input file to standard input (the file to print).
+#
+ln -s /dev/fd/0 hpdf$$.dvi || fatal "Cannot symlink /dev/fd/0"
+
+#
+# Make LF = CR+LF
+#
+printf "\033&k2G" || fatal "Cannot initialize printer"
+
+#
+# Convert and print. Return value from dvilj2p does not seem to be
+# reliable, so we ignore it.
+#
+dvilj2p -M1 -q -e- dfhp$$.dvi
+
+#
+# Clean up and exit
+#
+cleanup
+exit 0
diff --git a/share/examples/printing/hpif b/share/examples/printing/hpif
new file mode 100644
index 000000000000..69f1f34c55fd
--- /dev/null
+++ b/share/examples/printing/hpif
@@ -0,0 +1,11 @@
+#!/bin/sh
+#
+# hpif - Simple text input filter for lpd for HP-PCL based printers
+# Installed in /usr/local/libexec/hpif
+#
+# Simply copies stdin to stdout. Ignores all filter arguments.
+# Tells printer to treat LF as CR+LF. Writes a form feed character
+# after printing job.
+
+printf "\033&k2G" && cat && printf "\f" && exit 0
+exit 2
diff --git a/share/examples/printing/hpof b/share/examples/printing/hpof
new file mode 100644
index 000000000000..691b07f95d16
--- /dev/null
+++ b/share/examples/printing/hpof
@@ -0,0 +1,8 @@
+#!/bin/sh
+#
+# hpof - Output filter for Hewlett Packard PCL-compatible printers
+# Installed in /usr/local/libexec/hpof
+
+
+printf "\033&k2G" || exit 2
+exec /usr/libexec/lpr/lpf
diff --git a/share/examples/printing/hprf b/share/examples/printing/hprf
new file mode 100644
index 000000000000..37ad583fd9e1
--- /dev/null
+++ b/share/examples/printing/hprf
@@ -0,0 +1,8 @@
+#!/bin/sh
+#
+# hprf - FORTRAN text filter for LaserJet 3si:
+# Installed in /usr/local/libexec/hprf
+#
+
+printf "\033&k2G" && fpr && printf "\f" && exit 0
+exit 2
diff --git a/share/examples/printing/hpvf b/share/examples/printing/hpvf
new file mode 100644
index 000000000000..233de809745b
--- /dev/null
+++ b/share/examples/printing/hpvf
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# hpvf - Convert GIF files into HP/PCL, then print
+# Installed in /usr/local/libexec/hpvf
+
+PATH=/usr/X11R6/bin:$PATH; export PATH
+
+giftopnm | ppmtopgm | pgmtopbm | pbmtolj -resolution 300 \
+ && exit 0 \
+ || exit 2
diff --git a/share/examples/printing/if-simple b/share/examples/printing/if-simple
new file mode 100644
index 000000000000..7a5bf97ab38f
--- /dev/null
+++ b/share/examples/printing/if-simple
@@ -0,0 +1,9 @@
+#!/bin/sh
+#
+# if-simple - Simple text input filter for lpd
+# Installed in /usr/local/libexec/if-simple
+#
+# Simply copies stdin to stdout. Ignores all filter arguments.
+
+/bin/cat && exit 0
+exit 2
diff --git a/share/examples/printing/if-simpleX b/share/examples/printing/if-simpleX
new file mode 100644
index 000000000000..c14b4a25d12b
--- /dev/null
+++ b/share/examples/printing/if-simpleX
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# if-simple - Simple text input filter for lpd
+# Installed in /usr/local/libexec/if-simple
+#
+# Simply copies stdin to stdout. Ignores all filter arguments.
+# Writes a form feed character (\f) after printing job.
+
+/bin/cat && printf "\f" && exit 0
+exit 2
diff --git a/share/examples/printing/ifhp b/share/examples/printing/ifhp
new file mode 100644
index 000000000000..21e6643473e3
--- /dev/null
+++ b/share/examples/printing/ifhp
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# ifhp - Print Ghostscript-simulated PostScript on a DesJet 500
+# Installed in /usr/local/libexec/hpif
+
+#
+# Treat LF as CR+LF:
+#
+printf "\033&k2G" || exit 2
+
+#
+# Read first two characters of the file
+#
+read first_line
+first_two_chars=`expr "$first_line" : '\(..\)'`
+
+if [ "$first_two_chars" = "%!" ]; then
+ #
+ # It is PostScript; use Ghostscript to scan-convert and print it
+ #
+ /usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 -sOutputFile=- - \
+ && exit 0
+
+else
+ #
+ # Plain text or HP/PCL, so just print it directly; print a form
+ # at the end to eject the last page.
+ #
+ echo $first_line && cat && printf "\f" && exit 2
+fi
+
+exit 2
diff --git a/share/examples/printing/make-ps-header b/share/examples/printing/make-ps-header
new file mode 100644
index 000000000000..19e38ab7c779
--- /dev/null
+++ b/share/examples/printing/make-ps-header
@@ -0,0 +1,79 @@
+#!/bin/sh
+#
+# make-ps-header - make a PostScript header page on stdout
+# Installed in /usr/local/libexec/make-ps-header
+#
+
+#
+# These are PostScript units (72 to the inch). Modify for A4 or
+# whatever size paper you are using:
+#
+page_width=612
+page_height=792
+border=72
+
+#
+# Check arguments
+#
+if [ $# -ne 3 ]; then
+ echo "Usage: `basename $0` <user> <host> <job>" 1>&2
+ exit 1
+fi
+
+#
+# Save these, mostly for readability in the PostScript, below.
+#
+user=$1
+host=$2
+job=$3
+date=`date`
+
+#
+# Send the PostScript code to stdout.
+#
+exec cat <<EOF
+%!PS
+
+%
+% Make sure we do not interfere with user's job that will follow
+%
+save
+
+%
+% Make a thick, unpleasant border around the edge of the paper.
+%
+$border $border moveto
+$page_width $border 2 mul sub 0 rlineto
+0 $page_height $border 2 mul sub rlineto
+currentscreen 3 -1 roll pop 100 3 1 roll setscreen
+$border 2 mul $page_width sub 0 rlineto closepath
+0.8 setgray 10 setlinewidth stroke 0 setgray
+
+%
+% Display user's login name, nice and large and prominent
+%
+/Helvetica-Bold findfont 64 scalefont setfont
+$page_width ($user) stringwidth pop sub 2 div $page_height 200 sub moveto
+($user) show
+
+%
+% Now show the boring particulars
+%
+/Helvetica findfont 14 scalefont setfont
+/y 200 def
+[ (Job:) (Host:) (Date:) ] {
+ 200 y moveto show /y y 18 sub def
+} forall
+
+/Helvetica-Bold findfont 14 scalefont setfont
+/y 200 def
+[ ($job) ($host) ($date) ] {
+ 270 y moveto show /y y 18 sub def
+} forall
+
+%
+% That is it
+%
+restore
+showpage
+EOF
diff --git a/share/examples/printing/netprint b/share/examples/printing/netprint
new file mode 100644
index 000000000000..9b5010cc8cc5
--- /dev/null
+++ b/share/examples/printing/netprint
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+#
+# netprint - Text filter for printer attached to network
+# Installed in /usr/local/libexec/netprint
+#
+
+$#ARGV eq 1 || die "Usage: $0 <printer-hostname> <port-number>";
+
+$printer_host = $ARGV[0];
+$printer_port = $ARGV[1];
+
+require 'sys/socket.ph';
+
+($ignore, $ignore, $protocol) = getprotobyname('tcp');
+($ignore, $ignore, $ignore, $ignore, $address)
+ = gethostbyname($printer_host);
+
+$sockaddr = pack('S n a4 x8', &AF_INET, $printer_port, $address);
+
+socket(PRINTER, &PF_INET, &SOCK_STREAM, $protocol)
+ || die "Can't create TCP/IP stream socket: $!";
+connect(PRINTER, $sockaddr) || die "Can't contact $printer_host: $!";
+while (<STDIN>) { print PRINTER; }
+exit 0;
diff --git a/share/examples/printing/psdf b/share/examples/printing/psdf
new file mode 100644
index 000000000000..e0d429b953c2
--- /dev/null
+++ b/share/examples/printing/psdf
@@ -0,0 +1,8 @@
+#!bin/sh
+#
+# psdf - DVI to PostScript printer filter
+# Installed in /usr/local/libexec/psdf
+#
+# Invoked by lpd when user runs lpr -d
+#
+exec /usr/local/bin/dvips -f | /usr/local/libexec/lprps "$@"
diff --git a/share/examples/printing/psdfX b/share/examples/printing/psdfX
new file mode 100644
index 000000000000..43bdc4100bdb
--- /dev/null
+++ b/share/examples/printing/psdfX
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+# psdf - DVI to PostScript printer filter
+# Installed in /usr/local/libexec/psdf
+#
+# Invoked by lpd when user runs lpr -d
+#
+
+orig_args="$@"
+
+fail() {
+ echo "$@" 1>&2
+ exit 2
+}
+
+while getopts "x:y:n:h:" option; do
+ case $option in
+ x|y) ;; # Ignore
+ n) login=$OPTARG ;;
+ h) host=$OPTARG ;;
+ *) echo "LPD started `basename $0` wrong." 1>&2
+ exit 2
+ ;;
+ esac
+done
+
+[ "$login" ] || fail "No login name"
+[ "$host" ] || fail "No host name"
+
+( /u/kelly/freebsd/printing/filters/make-ps-header $login $host "DVI File"
+ /usr/local/bin/dvips -f ) | eval /usr/local/libexec/lprps $orig_args
diff --git a/share/examples/printing/psif b/share/examples/printing/psif
new file mode 100644
index 000000000000..2a657e01aae7
--- /dev/null
+++ b/share/examples/printing/psif
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# psif - Print PostScript or plain text on a PostScript printer
+# Script version; NOT the version that comes with lprps
+# Installed in /usr/local/libexec/psif
+#
+
+read first_line
+first_two_chars=`expr "$first_line" : '\(..\)'`
+
+if [ "$first_two_chars" = "%!" ]; then
+ #
+ # PostScript job, print it.
+ #
+ echo $first_line && cat && printf "\004" && exit 0
+ exit 2
+else
+ #
+ # Plain text, convert it, then print it.
+ #
+ ( echo $first_line; cat ) | /usr/local/bin/textps && printf "\004" && exit 0
+ exit 2
+fi
diff --git a/share/examples/printing/pstf b/share/examples/printing/pstf
new file mode 100644
index 000000000000..308adc19e2ab
--- /dev/null
+++ b/share/examples/printing/pstf
@@ -0,0 +1,6 @@
+#!/bin/sh
+#
+# pstf - Convert groff's troff data into PS, then print.
+# Installed in /usr/local/libexec/pstf
+#
+exec grops | /usr/local/libexec/lprps "$@"
diff --git a/share/examples/printing/pstfX b/share/examples/printing/pstfX
new file mode 100644
index 000000000000..1af7134223c2
--- /dev/null
+++ b/share/examples/printing/pstfX
@@ -0,0 +1,6 @@
+#!/bin/sh
+#
+# pstf - Convert groff's troff data into PS, then print.
+# Installed in /usr/local/libexec/pstf
+#
+exec grops