bug-mailfromd
Re: [Bug-mailfromd] how to get the index used in header functions
Marc <Marc@xxxxxxxxxxxxxxxxx> ha escrit:
> I was wondering how to get the index that can be used in these functions?
There are at least two ways. One I hinted on in my previois letter. In
more detail, it goes like that:
prog eom
do
set msg current_message()
number found
loop for set i 1,
set i i + 1
do
try
do
set hdr unfold(message_find_header(msg, "Received", i))
if hdr matches 'NEEDLE'
set found i
fi
done
catch e_not_found
do
break
done
echo hdr
done
if found
header_delete
fi
(replace NEEDLE with the text you are looking for).
Another one is to trace headers in the 'prog header', in a similar
manner:
number nr 0
number found
prog header
do
if not found and $1 == "Received"
set nr nr + 1
if $2 matches 'NEEDLE'
set found nr
continue
fi
fi
...
prog eom
do
if nr > 0
# delete the header here
...
Notice, that both recipes are somewhat simplified. You will have to
polish them up a bit.
Regards,
Sergey