| 
#!/bin/rc
# Given a upas/fs message, print the simplest
# representation we reasonably can.
D=$1
fn findalt {
	switch(`{cat $D^/type}){
		case multipart/*
			D=$D^/1
	}
	if(~ `{cat $D^/type} multipart/*)
		findalt $D
}
fn prpart {
	part=$1
	parttype=`{cat $part^/type}
	switch($parttype){
		case text/plain
			cat $part^/body
		case text/html
			htmlfmt $part^/body
		case text/texmacs
			`{doctype -n $part/body}
		case application/pdf
			pdf2ps $part/body | ps2txt
		case *
			cat $part^/body
	}
}
findalt $D
prpart $D
 |