#!/bin/sh - # # w-filter Ver1.02en # # By T.Wakaume # /usr/bin/gawk ' BEGIN { IGNORECASE=1 status=0 } #{ # print status "" NF #} status==0 && NF==0 { print status=1 next } status==0 { if(match($1, /Content-Type:/) && match($0, /multipart/)) { if(match($0, /boundary.*/)) { boundary=substr($0, RSTART, RLENGTH) sub(/.*boundary=[ \t]*/, "", boundary) if(match(boundary, /^\"/)) { sub(/^\"/, "", boundary) sub(/\".*$/, "", boundary) } else { sub(/[ \t].*$/, "", boundary) } } else { getline if(match($0, /boundary.*/)) { boundary=substr($0, RSTART, RLENGTH) sub(/.*boundary=[ \t]*/, "", boundary) if (match(boundary, /^\"/)) { sub(/^\"/, "", boundary) sub(/\".*$/, "", boundary) } else { sub(/[ \t].*$/, "", boundary) } } } if (boundary!="") { boundary="--" boundary } print "Content-Type: text/plain; charset=US-ASCII" next } else { if(match($1, /Disposition-Notification-To:/)) { next } } print } status!=0 && status!=9 { if(boundary=="") { status=9 } # if(index($0, "This is a multi-part message in MIME format.")) { next } # if (index($0, boundary)==1 && index($0, boundary "--")!=1) { getline if(match($1, /Content-Type:/) && match($0, /text\/plain/)) { if(status==1 || status==3) { status=2 } else { status=4 } } else { if(status==1) { status=3 } else { status=4 } } if(status==3 || status==4) { print "" print "** An attachment was eliminated. **" print "The content specification had been as follows:" print "" print while(NF!=0) { getline print } print "" } else { while(NF!=0) { getline } print "" } next } } status==2 { print } status==9 { print } '