procmail
[Top] [All Lists]

Re: Getting Message Size into a Variable

1997-03-03 18:11:09
| 
| Paul Bartlett asked,
| 
| | I finally perfected a simple, reusable recipe for
| | throwing selected mails into the bit bucket and recording the action in
| | a condensed one-line entry in the logfile.  However, I would also like
| | to record the message size for documentation purposes, and for that I
| | need the size in a variable, but I have not figured out how to capture
| | that information.  I presume it must exist somehow, because procmail
| | can use it in a condition line.  Any suggestions gratefully received. 
| 

The other possibility for "message size" is number of bytes.
For a message that contained one hundred lines of the form
    1
    2
    3
    ...
    100
, here is the output of my testsc:

    8:02pm 0 3.68 mengwong(_at_)icg:~% procmail -m /tmp/testsc < /tmp/100
    body has 293 bytes
    body has 100 lines
    8:03pm 0 3.81 mengwong(_at_)icg:~%

is that what you're looking for?  here's the rc for that.

    :0
    * 1^1 B ?? > 1
    { BodyLength = $= }
    LOG = "body has $BodyLength bytes
    "

    :0B
    * 1^1 ^.+$
    { BodyLines = $= }
    LOG = "body has $BodyLines nonblank lines
    "

while i was experimenting, i discovered something odd:

    recipe 1 (.209^1)     scored 20
    recipe 2 (.208^1)     scored 1
    recipe 3 (.1000004^1) scored 10
    recipe 4 (.1000003^1) scored 1

shouldn't recipes 1 and 2 score the same?  similarly 3 and 4
should score the same, shouldn't they?  is this a bug in
procmail or in my system's math library?  Here are the four
recpies that produced that odd behaviour.

    :0B
    * .209^1 ^.+$
    { BodyLines = $= }
    LOG = "recipe 1 (.209^1)     scored $=
    "

    :0B
    * .208^1 ^.+$
    { }
    LOG = "recipe 2 (.208^1)     scored $=
    "

    :0B
    * .1000004^1 ^.+$
    { }
    LOG = "recipe 3 (.1000004^1) scored $=
    "

    :0B
    * .1000003^1 ^.+$
    { }
    LOG = "recipe 4 (.1000003^1) scored $=
    "

    :0
    /dev/null

i looked at misc.c and didn't see anything obvious.

         negate=scoreany=0;lscore=score;
         for(chp=buf2+1;;strcpy(buf2,buf))
copydone: { switch(*(sgetcp=buf2))
             { case '0':case '1':case '2':case '3':case '4':case '5':case '6':
               case '7':case '8':case '9':case '-':case '+':case '.':case ',':
                { char*chp3;double w;
                  w=stod(buf2,(const char**)&chp3);chp2=chp3;
                  if(chp2>buf2&&*(chp2=skpspace(chp2))=='^')
                   { double x;
                     x=stod(chp2+1,(const char**)&chp3);
                     if(chp3>chp2+1)
                      { if(score>=MAX32)
                           goto skiptrue;
                        xponent=x;weight=w;scored=scoreany=1;
                        chp2=skpspace(chp3);
                        goto copyrest;
                      }

thanks
meng

<Prev in Thread] Current Thread [Next in Thread>