Browse Source

Plan 9 from Bell Labs 2008-09-14

David du Colombier 15 years ago
parent
commit
65a64f3c18
1 changed files with 40 additions and 14 deletions
  1. 40 14
      sys/src/cmd/fax/receiverc

+ 40 - 14
sys/src/cmd/fax/receiverc

@@ -1,6 +1,11 @@
 #!/bin/rc
 #!/bin/rc
 spool=/mail/faxqueue
 spool=/mail/faxqueue
-recipients=/mail/lib/faxrecipients
+recipients=/mail/faxqueue/faxrecipients
+
+# run mail as if we're on fs
+rm /srv/fs
+9fs fs
+bind -c /n/fs/mail/faxqueue /mail/faxqueue
 
 
 #
 #
 # Arguments should be
 # Arguments should be
@@ -10,23 +15,44 @@ switch($#*){
 
 
 case 4
 case 4
 	#
 	#
-	# Check for the NYT. It's 9 pages from
-	# area-code 202.
+	# Check for the NYT. It's 9 pages from 'Via Fax             '.
 	#
 	#
-	if(~ $2 Y && ~ $4 20240*){
-		if(~ $3 9){
-			for(i in 001 002 003 004 005 006 007 008 009){
-				cp $spool/$1.$i /lib/nyt/nyt.$i
+	nyt=false
+	if(~ $2 Y && {~ $4 'Via Fax             '}){
+		switch(`{date|sed 's/ .*//'}){
+		case Mon Tue Wed Thu Fri
+			hour=`{date|sed 's/.* ([0-9][0-9]):.*/\1/'}
+			if(test $3 -gt 7 -a '(' $hour -lt 7 -o $hour -ge 21 ')')
+				nyt=true
+		case *
+			if(test $3 -gt 7)
+				nyt=true
+		}
+	}
+	switch($nyt){
+
+	case true
+		to=`{seq 0 1 $3}
+		for(i in `{seq 2 1 $3}){
+			switch($i){
+	
+			case ?
+				ext=00$i
+			case ??
+				ext=0$i
+			case ???
+				ext=$i
 			}
 			}
-			rm -f $spool/$1.*
+			cp $spool/$1.$ext /n/fs/lib/nyt/nyt.$to($i)
 		}
 		}
-		if not
-			echo NYT FAX: $* | mail rob
+		cp $spool/$1.1 /n/fs/lib/nyt/nyt.$3
+		rm -f $spool/$1.*
+	case *
+		{echo $*; echo FAX: page -w $spool/$1.'*'} | mail `{cat $recipients}
 	}
 	}
-	if not
-		echo FAX: page $spool/$1.* | mail `{cat $recipients}
 case 3
 case 3
-	echo FAX: page $spool/$1.* | mail `{cat $recipients}
+	{echo $*; echo FAX: page -w $spool/$1.'*'} | mail `{cat $recipients}
 case *
 case *
-	echo FAX BOTCH: page $spool/$1.* | mail jmk
+	{echo $*; echo FAX: page -w $spool/$1.'*'} | mail postmaster
 }
 }
+exit 0