Browse Source

Plan 9 from Bell Labs 2008-04-14

David du Colombier 13 years ago
parent
commit
0756174e7e
5 changed files with 71 additions and 60 deletions
  1. 2 2
      dist/replica/_plan9.db
  2. 2 2
      dist/replica/plan9.db
  3. 2 0
      dist/replica/plan9.log
  4. 49 51
      rc/bin/fax
  5. 16 5
      sys/man/4/telco

+ 2 - 2
dist/replica/_plan9.db

@@ -5526,7 +5526,7 @@ rc/bin/dontkill - 775 sys sys 1207346989 293
 rc/bin/dosmnt - 775 sys sys 1109288224 303
 rc/bin/dpost - 775 sys sys 1192741346 220
 rc/bin/eject - 775 sys sys 945617207 123
-rc/bin/fax - 775 sys sys 1127394677 2385
+rc/bin/fax - 775 sys sys 1208110476 2401
 rc/bin/fedex - 775 sys sys 1195162568 1236
 rc/bin/fshalt - 775 sys sys 1192741344 1862
 rc/bin/homespool - 775 sys sys 945617207 339
@@ -7760,7 +7760,7 @@ sys/man/4/sacfs - 664 sys sys 1196638944 907
 sys/man/4/snap - 664 sys sys 1196638944 1908
 sys/man/4/srv - 664 sys sys 1196638944 4970
 sys/man/4/tapefs - 664 sys sys 1196638944 1861
-sys/man/4/telco - 664 sys sys 1196638944 4359
+sys/man/4/telco - 664 sys sys 1208111302 4561
 sys/man/4/u9fs - 664 sys sys 1206913743 5223
 sys/man/4/upasfs - 664 sys sys 1196638944 6212
 sys/man/4/usb - 664 sys sys 1206739773 5725

+ 2 - 2
dist/replica/plan9.db

@@ -5526,7 +5526,7 @@ rc/bin/dontkill - 775 sys sys 1207346989 293
 rc/bin/dosmnt - 775 sys sys 1109288224 303
 rc/bin/dpost - 775 sys sys 1192741346 220
 rc/bin/eject - 775 sys sys 945617207 123
-rc/bin/fax - 775 sys sys 1127394677 2385
+rc/bin/fax - 775 sys sys 1208110476 2401
 rc/bin/fedex - 775 sys sys 1195162568 1236
 rc/bin/fshalt - 775 sys sys 1192741344 1862
 rc/bin/homespool - 775 sys sys 945617207 339
@@ -7760,7 +7760,7 @@ sys/man/4/sacfs - 664 sys sys 1196638944 907
 sys/man/4/snap - 664 sys sys 1196638944 1908
 sys/man/4/srv - 664 sys sys 1196638944 4970
 sys/man/4/tapefs - 664 sys sys 1196638944 1861
-sys/man/4/telco - 664 sys sys 1196638944 4359
+sys/man/4/telco - 664 sys sys 1208111302 4561
 sys/man/4/u9fs - 664 sys sys 1206913743 5223
 sys/man/4/upasfs - 664 sys sys 1196638944 6212
 sys/man/4/usb - 664 sys sys 1206739773 5725

+ 2 - 0
dist/replica/plan9.log

@@ -18982,3 +18982,5 @@
 1207767605 0 c sys/man/8/ndb - 664 sys sys 1207767560 15239
 1207868404 0 c sys/man/3/ip - 664 sys sys 1207867035 27434
 1207960204 0 c sys/man/4/cdfs - 664 sys sys 1207959658 4803
+1208111404 0 c rc/bin/fax - 775 sys sys 1208110476 2401
+1208111404 1 c sys/man/4/telco - 664 sys sys 1208111302 4561

+ 49 - 51
rc/bin/fax

@@ -1,43 +1,44 @@
 #!/bin/rc
+# fax [-v] telephone-number recipient [file ...] - send files via fax
+rfork e
 view=no
 stdin=no
 
+fn usage {
+	echo 'usage: fax [-v] telephone-number recipient [file ...]' >[1=2]
+	exit usage
+}
+
 switch($1){
 case -v
 	view=yes
 	shift
 }
 
-switch($#*){
+switch ($#*) {
 case 0 1
-	echo usage: $0 telephone-number recipient [files]
-	exit usage
+	usage
 case 2
 	stdin=yes
 }
-
 telno=`{echo $1|sed 's/[ \-]//g'}
 shift
 
-switch($telno){
-case [0-9]* +[0-9]*
-	;
-case *
-	echo usage: $0 telephone-number recipient [files]
-	exit 0
-}
+if (! ~ $telno [0-9]* +[0-9]*)
+	usage
 
+# our old phone system needed *9 to get outside; the new one just needs 9
 switch($telno){
 case ???????
-	telno='*9,'^$telno
+	telno='9,'^$telno
 case ??????????
-	telno='*9,1'^$telno
+	telno='9,1'^$telno
 case 1??????????
-	telno='*9,'^$telno
+	telno='9,'^$telno
 case 011*
-	telno='*9,'^$telno
+	telno='9,'^$telno
 case +*
-	telno=`{echo $telno | sed 's/\+/*9,011/'}
+	telno=`{echo $telno | sed 's/\+/9,011/'}
 }
 
 recip=$1
@@ -51,17 +52,22 @@ tmpin=/tmp/fax.in.$pid
 tmpps=/tmp/fax.ps.$pid
 tel=`{grep '\) '$user /lib/tel}
 myname=`{echo $tel | sed 's/ \(.*//'}
+if (~ $#myname 0)
+	myname=''
 ext=`{echo $tel | sed 's/.*\) [^ ]* [^ ]* ([^ ]*).*/\1/'}
 
-fn sigint{
+fn sigexit {
 	rm -f $tmp.* $script $header $header.* $tmpin $tmpps
+}
+fn sigint {
+	sigexit
 	exit interrupt
 }
 
 # gather input into a file
 switch($stdin){
 case yes
-	cat > $tmpin
+	cat >$tmpin
 	infiles=$tmpin
 case *
 	infiles=($*)
@@ -75,42 +81,36 @@ for(i in $infiles){
 	case *:*g3* *:*fax*
 		g3files=($g3files $i)
 	case *:*postscript
-		gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$tmp'.'$#a'.%03d' -dNOPAUSE -dQUIET $i quit.ps
+		gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$tmp'.'$#a'.%03d' \
+			-dNOPAUSE -dQUIET $i quit.ps
 		g3files=($g3files $tmp.$#a.*)
 	case *
-		lp -dstdout $i > $tmpps
-		gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$tmp'.'$#a'.%03d' -dNOPAUSE -dQUIET $tmpps quit.ps
+		lp -dstdout $i >$tmpps
+		gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$tmp'.'$#a'.%03d' \
+			-dNOPAUSE -dQUIET $tmpps quit.ps
 		g3files=($g3files $tmp.$#a.*)
 	}
-	a=($a $a)
+	a=($a 1)		# count by increasing list length
 }
 
 pages=`{echo $g3files|wc -w}
 
-echo -n 's/FAXddd/' > $script
-echo -n `{date}>> $script
-echo />> $script
-echo -n s/FAXFFF/>> $script
-echo -n $myname >>  $script
-echo />> $script
-echo -n s/FAXEEE/>> $script
-echo -n $user >>  $script
-echo />> $script
-echo -n s/FAXVVV/>> $script
-echo -n $ext >>  $script
-echo />> $script
-echo -n s/FAXTTT/>> $script
-echo -n $recip >>  $script
-echo />> $script
-echo -n s/FAXfff/>> $script
-echo -n $telno >>  $script
-echo />> $script
-echo -n s/FAXPPP/>> $script
-echo -n $pages >>  $script
-echo />> $script
-sed -f $script /sys/lib/fax/h.ps > $header
-
-gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$header'.%03d' -dNOPAUSE -dQUIET $header quit.ps
+# use delimiters that are unlikely to be supplied in arguments
+{
+	echo -n s∮FAXddd∮
+	echo -n `{date}		# treat `{} output list specially
+	echo ∮
+	echo s∮FAXFFF∮$"myname^∮
+	echo s∮FAXEEE∮$"user^∮
+	echo s∮FAXVVV∮$"ext^∮
+	echo s∮FAXTTT∮$"recip^∮
+	echo s∮FAXfff∮$"telno^∮
+	echo s∮FAXPPP∮$"pages^∮
+} >>$script
+sed -f $script /sys/lib/fax/h.ps >$header
+
+gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$header'.%03d' \
+	-dNOPAUSE -dQUIET $header quit.ps
 
 files=()
 for(i in $header.* $g3files){
@@ -118,11 +118,9 @@ for(i in $header.* $g3files){
 }
 
 switch($view){
-case no
-	upas/qer $files /mail/faxoutqueue fax $user $telno < /dev/null
-	rx fax /sys/lib/fax/faxgoose
 case yes
 	page $header.* $g3files
+case *
+	upas/qer $files /mail/faxoutqueue fax $user $telno	</dev/null
+	rx fax /sys/lib/fax/faxgoose				</dev/null
 }
-
-#rm -f $tmp.* $script $header $header.* $tmpin $tmpps

+ 16 - 5
sys/man/4/telco

@@ -27,6 +27,9 @@ telco, faxreceive, faxsend, fax, telcofax, telcodata \- telephone dialer network
 ]
 .PP
 .B fax
+[
+.B -v
+]
 .I telno
 .I recipient
 [
@@ -125,7 +128,7 @@ Hayes command subset.
 .I Faxreceive
 is normally started by
 .BR /rc/bin/service/telcofax .
-It inputs and spools a CCITT Group 3 (G3) encoded FAX, and then starts the
+It reads and spools a CCITT Group 3 (G3) encoded FAX, and then starts the
 script
 .BR /sys/lib/fax/receiverc ,
 passing it four arguments: the spool file name,
@@ -159,9 +162,11 @@ are names of files containing G3 encoded
 FAX images, one per page.
 .PP
 .I Fax
-is a shell script that queues
-PostScript, G3, or text files to be transmitted to a
-FAX machine.
+is a shell script that converts to G3 format
+PostScript, G3, text, or other files acceptable to
+.IR lp (1)
+and queues the result
+to be transmitted to a FAX machine.
 A standard cover sheet, derived from
 .BR /sys/lib/fax/h.ps ,
 is sent before the message.
@@ -172,7 +177,13 @@ is the name of the recipient to be placed
 on the cover sheet.
 If no
 .I files
-are specified, standard input is sent.
+are specified, standard input is converted and sent.
+The
+.B -v
+option invokes
+.IR page (1)
+on the generated G3 files
+instead of transmitting them via FAX machine.
 .SH EXAMPLE
 Start the dialer on a PC, then use
 .I con