procmail
[Top] [All Lists]

Re: Recovering Number of Lines or Size of Mail

1999-04-15 11:28:33
era eriksson <era(_at_)iki(_dot_)fi> writes:
On Tue, 13 Apr 1999 13:44:41 -0500, Philip Guenther 
<guenther(_at_)gac(_dot_)edu>
wrote:
Ralph SOBEK <sobek(_at_)irit(_dot_)fr> writes:
"PG" == Philip Guenther <guenther(_at_)gac(_dot_)edu> writes:
PG> Well, it's O(n), if that's any reassurance.
I would prefer O(k), k = constant, since I may recover this info for a
couple of thousands of e-mails...  Since procmail has it internally,
would it be too awful to pass the value along to a recipe?
As it has no need for it, procmail doesn't determine or keep track of
the line count.

The byte count (which is what I imagine is what Ralph really wanted to
ask about) should be trivial to export into a variable, though? Except
if Procmail finds out the size of the message only when the user
actually asks for it (but then the same optimization could be done on
this pseudovariable).

Nope.  Procmail knows the byte count as soon as it reads in the
message.  You can get it by scoring a length condition:

        :0
        * 1^1 > 1
        { }
        LENGTH = $=

That's the length of the entire message.  If you want the length of
just the header or body then you can narrow it with the "H ??" or
"B ??" syntax:

        :0
        * B ?? 1^1 > 1
        { }
        BODYLENGTH = $=

You can also measure the length of what's stored in a variable:

        :0
        * VAR ?? 1^1 >1
        { }
        VARLEN = $=


Philip Guenther