1
0

fax 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #!/bin/rc
  2. view=no
  3. stdin=no
  4. switch($1){
  5. case -v
  6. view=yes
  7. shift
  8. }
  9. switch($#*){
  10. case 0 1
  11. echo usage: $0 telephone-number recipient [files]
  12. exit usage
  13. case 2
  14. stdin=yes
  15. }
  16. telno=`{echo $1|sed 's/[ \-]//g'}
  17. shift
  18. switch($telno){
  19. case [0-9]* +[0-9]*
  20. ;
  21. case *
  22. echo usage: $0 telephone-number recipient [files]
  23. exit 0
  24. }
  25. switch($telno){
  26. case ???????
  27. telno='*9,'^$telno
  28. case ??????????
  29. telno='*9,1'^$telno
  30. case 1??????????
  31. telno='*9,'^$telno
  32. case 011*
  33. telno='*9,'^$telno
  34. case +*
  35. telno=`{echo $telno | sed 's/\+/*9,011/'}
  36. }
  37. recip=$1
  38. shift
  39. script=/tmp/fax.$pid
  40. header=/tmp/faxh.$pid
  41. user=`{cat /dev/user}
  42. tmp=/tmp/fax.g3.$pid
  43. tmpin=/tmp/fax.in.$pid
  44. tmpps=/tmp/fax.ps.$pid
  45. tel=`{grep '\) '$user /lib/tel}
  46. myname=`{echo $tel | sed 's/ \(.*//'}
  47. ext=`{echo $tel | sed 's/.*\) [^ ]* [^ ]* ([^ ]*).*/\1/'}
  48. fn sigint{
  49. rm -f $tmp.* $script $header $header.* $tmpin $tmpps
  50. exit interrupt
  51. }
  52. # gather input into a file
  53. switch($stdin){
  54. case yes
  55. cat > $tmpin
  56. infiles=$tmpin
  57. case *
  58. infiles=($*)
  59. }
  60. # convert to g3
  61. g3files=()
  62. a=1
  63. for(i in $infiles){
  64. switch(`{file $i}){
  65. case *:*g3* *:*fax*
  66. g3files=($g3files $i)
  67. case *:*postscript
  68. gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$tmp'.'$#a'.%03d' -dNOPAUSE -dQUIET $i quit.ps
  69. g3files=($g3files $tmp.$#a.*)
  70. case *
  71. lp -dstdout $i > $tmpps
  72. gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$tmp'.'$#a'.%03d' -dNOPAUSE -dQUIET $tmpps quit.ps
  73. g3files=($g3files $tmp.$#a.*)
  74. }
  75. a=($a $a)
  76. }
  77. pages=`{echo $g3files|wc -w}
  78. echo -n 's/FAXddd/' > $script
  79. echo -n `{date}>> $script
  80. echo />> $script
  81. echo -n s/FAXFFF/>> $script
  82. echo -n $myname >> $script
  83. echo />> $script
  84. echo -n s/FAXEEE/>> $script
  85. echo -n $user >> $script
  86. echo />> $script
  87. echo -n s/FAXVVV/>> $script
  88. echo -n $ext >> $script
  89. echo />> $script
  90. echo -n s/FAXTTT/>> $script
  91. echo -n $recip >> $script
  92. echo />> $script
  93. echo -n s/FAXfff/>> $script
  94. echo -n $telno >> $script
  95. echo />> $script
  96. echo -n s/FAXPPP/>> $script
  97. echo -n $pages >> $script
  98. echo />> $script
  99. sed -f $script /sys/lib/fax/h.ps > $header
  100. gs -dSAFER '-sDEVICE=dfaxlow' '-sOUTPUTFILE='$header'.%03d' -dNOPAUSE -dQUIET $header quit.ps
  101. files=()
  102. for(i in $header.* $g3files){
  103. files=($files -f $i)
  104. }
  105. switch($view){
  106. case no
  107. upas/qer $files /mail/faxoutqueue fax $user $telno < /dev/null
  108. rx fax /sys/lib/fax/faxgoose
  109. case yes
  110. page $header.* $g3files
  111. }
  112. #rm -f $tmp.* $script $header $header.* $tmpin $tmpps