ifile-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ifile-discuss] Re: Maildir format


From: Karl Vogel
Subject: [Ifile-discuss] Re: Maildir format
Date: 26 May 2003 18:44:13 -0400

>> On 26 May 2003 15:59:26 +0200, 
>> "clemens fischer" <address@hidden> said:

C> "Karl Vogel" <address@hidden>:
   >> This is perfect for a filter of some kind to open each message and
   >> append "X-Ifile-Result: {good,other,spam}" to the header:
   >> 
   >> me% ifile -c -q ??? | update-header

C> sorry, i don't get this.  ifile will respond with "good" or "bad" (in
C> your example), but it won't put headers noting the outcome to each
C> message.  that depens on magical "update-header", of course.  this
C> program gets ifiles result on stdin, then how will it put an appropriate
C> header into the message?

   update-header would read lines from stdin consisting of the filename
   and message classification, and modify each message in place.  A short
   perl version could look something like this:

      #!/bin/perl
      # update-header -- read file and msg type, add ifile header.

      while (<>)
      {
          chomp;
          ($file, $type) = split;

          # store entire message
          open (F, "< $file") || die "can't read $file";
          $_ = do { local $/; <F> };
          close (F);

          # find end of header
          $nl = index ($_, "\n\n");
          die "no blank line" if $nl < 0;

          # write original header, msg type, and remainder
          open (F, "> $file") || die "can't write $file";
          print F substr($_, 0, $nl+1);
          print F "X-Ifile-Result: $type\n";
          print F substr($_, $nl+1);
          close (F);
      }

      exit (0);

   The goal is to avoid multiple runs of ifile.  The amount of time ifile
   spends on initialization and loading its wordlist should be fairly
   constant, depending mostly on the size of .idata.  We'll spend that
   time whether we process one mail message or a thousand, so we may as
   well handle as many messages as we can for any one run.

-- 
Karl Vogel                      I don't speak for the USAF or my company
address@hidden                          http://www.pobox.com/~vogelke

Dew is formed on leaves when the sun shines down on them and makes them
perspire.    --submitted to science and health teachers, Jr High thru college





reply via email to

[Prev in Thread] Current Thread [Next in Thread]