Blob


1 #!/usr/local/plan9/bin/rc
3 fn read9p {
4 srv=$1; shift
5 9p read $srv >[2=1]|grep -v '^9p\:'
6 }
8 fn dir9p {
9 srv=$1; shift
10 9p ls $srv >[2=1]|grep -v '^9p\:'
11 }
14 fn catmesg {
15 # hold on for a second
16 TMP=/tmp/$USER.`{date -n}; sleep 1
17 msg=$1;
18 read9p $msg/body >$TMP.body
19 t=`{read9p $msg/type}
20 switch($t){
21 case text/html
22 echo '
23 ,x/<!--(-?[^\-]|--[^>]|\n)*-->/ c//
24 ,x/<[^>]+>/d
25 ,p
26 u
27 ,y/<[^>]+>/d
28 ,p
29 '| sam -d $TMP.body|[2] sed '1d;/^\?/d'
30 case text/*
31 cat $TMP.body
32 case message/*
33 cat $TMP.body
34 case multipart/related
35 if (~ `{read9p $msg/1/type} text/plain)
36 catmesg $msg/1
37 if not if (~ `{read9p $msg/2/type} text/plain)
38 catmesg $msg/2
39 if not {
40 for (i in `{dir9p $msg|awk '$10 ~ /[0-9][0-9]*/ {print $10}'})
41 catmesg $msg/$i
42 }
43 case *
44 echo $t
45 # should there be more?
46 }
47 rm -f $TMP.body
48 }
50 if (~ $#* 0)
51 echo usage: msgcat mail/mbox/msgn && exit 1
53 mesg=$1
54 if (~ `{read9p $mesg/lines} '')
55 echo no such message $mesg && exit 2
58 read9p $mesg/unixheader; read9p $mesg/header
59 echo
60 catmesg $mesg
61 echo