xref: /plan9/mail/lib/msgcat.rc (revision 09762551a2283940baa4807956116d4373b76937)
1#!/bin/rc
2
3rfork ne
4
5if(~ $1 /mail/fs/mbox*){
6	dir=$*
7}
8if not{
9	upas/fs -f $1
10	dir=/mail/fs/mbox/[0-9]*
11}
12
13fn catmsg {
14	t=`{cat type}
15	switch($t){
16	case text/html
17		echo '
18			,x/<!--(-?[^\-]|--[^>]|\n)*-->/ c//
19			,x/<[^>]+>/d
20			,p
21			u
22			,y/<[^>]+>/d
23			,p
24		' | sam -d body |[2] sed '1d;/^\?/d'
25	case text/*
26		cat body
27	case message/*
28		cat body
29	case multipart/alternative
30		if(~ `{cat 1/type} text/plain)
31			cd 1 && {catmsg; cd ..}
32		if not if (~ `{cat 2/type >[2]/dev/null} text/plain)
33			cd 2 && {catmsg; cd ..}
34		if not {
35			for (i in [0-9]*)
36				cd $i && {catmsg; cd ..}
37		}
38	case *
39		echo $t
40	}
41}
42
43for(i in $dir){
44	cd $i
45	cat unixheader header
46	echo
47	catmsg
48	echo
49}
50