#!/bin/sh

TYPE=$2

if [ "$TYPE" = "spam" ]; then
        grep "here be a virus\|------ \| SA: yup, this smells \| q_s: Policy BLOCK" $1 \
        | grep -v " message for " \
        | sed -e "s/.* hits.* - message \(tagged\|quarantined\|deleted\|rejected\) .*$/Spam \1/" \
        | grep "Spam" \
        | wc -l
fi

if [ "$TYPE" = "policy" ]; then
        grep "here be a virus\|------ \| SA: yup, this smells \| q_s: Policy BLOCK" $1 \
        | grep -v " message for " \
        | sed -e "s/^.* q_s: Policy BLOCK$/Policy blocked/"  \
        | grep "Policy blocked" \
        | wc -l
fi

        grep "here be a virus\|------ \| SA: yup, this smells \| q_s: Policy BLOCK" $1 \
        | grep -v " message for " \
        | sed -e "s/^.* Process .*$/Messages processed/"  \
        | grep "Messages processed" \
        | wc -l
echo $TYPE