1#!/bin/rc 2view=no 3stdin=no 4 5switch($1){ 6case -v 7 view=yes 8 shift 9} 10 11switch($#*){ 12case 0 1 13 echo usage: $0 telephone-number recipient [files] 14 exit 0 15case 2 16 stdin=yes 17} 18 19telno=$1 20shift 21 22recip=$1 23shift 24 25script=/tmp/fax.$pid 26header=/tmp/faxh.$pid 27user=`{cat /dev/user} 28tmp=/tmp/page.$pid 29tmpin=/tmp/page.in.$pid 30tel=`{grep '\) '$user /lib/tel} 31myname=`{echo $tel | sed 's/ \(.*//'} 32ext=`{echo $tel | sed 's/.*\) [^ ]* [^ ]* ([^ ]*).*/\1/'} 33 34fn sigint{ 35 #rm -f $tmp.* $tmpin.* $script $header $header.* 36 exit interrupt 37 38} 39 40# gs insists on reading its standard input, so we read quit.ps to cut it off. 41switch($stdin){ 42case yes 43 cat > $tmpin 44 gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$tmp'.%.3d' -dNOPAUSE -dQUIET $tmpin quit.ps 45case * 46 gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$tmp'.%.3d' -dNOPAUSE -dQUIET $* quit.ps 47} 48 49pages=`{echo $tmp.*|wc -w} 50 51# use delimiters that are unlikely to be supplied in arguments 52echo -n s∮FAXddd∮ >$script 53echo -n `{date} >>$script 54echo ∮ >>$script 55echo -n s∮FAXFFF∮ >>$script 56echo -n $myname >>$script 57echo ∮ >>$script 58echo -n s∮FAXEEE∮ >>$script 59echo -n $user >>$script 60echo ∮ >>$script 61echo -n s∮FAXVVV∮ >>$script 62echo -n $ext >>$script 63echo ∮ >>$script 64echo -n s∮FAXTTT∮ >>$script 65echo -n $recip >>$script 66echo ∮ >>$script 67echo -n s∮FAXfff∮ >>$script 68echo -n $telno >>$script 69echo ∮ >>$script 70echo -n s∮FAXPPP∮ >>$script 71echo -n $pages >>$script 72echo ∮ >>$script 73sed -f $script /sys/lib/fax/h.ps > $header 74 75gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$header'.%.3d' -dNOPAUSE -dQUIET $header quit.ps 76 77files=() 78for(i in $header.* $tmp.*){ 79 files=($files -f $i) 80} 81 82switch($view){ 83case no 84 upas/qer $files /mail/faxoutqueue fax $user $telno < /dev/null 85 rx fax /sys/lib/fax/faxgoose 86case yes 87 page $header.* $tmp.* 88} 89 90#rm -f $tmp.* $header $script $header.* $tmpin 91