Back to index

courier  0.68.2
formatmbox.h
Go to the documentation of this file.
00001 #ifndef       formatmbox_h
00002 #define       formatmbox_h
00003 
00004 
00005 #include      "config.h"
00006 #include      "buffer.h"
00007 #include      "mio.h"
00008 
00010 //
00011 // FormatMbox class returns consecutive lines from the current message,
00012 // formatted for delivery into a mailbox.  That means the lines are
00013 // terminate with either <LF> or <CRLF> (defined at compilation time).
00014 // Furthermore, the message can be optionally preceded by the From line.
00015 //
00016 // Mandatory calling sequence:
00017 //
00018 //  int HasMsg() - return 0 if there's a message to deliver, or -1 if
00019 //                 the message is empty (none).
00020 //  void Init(flag) - initialize.  Flag is non-zero if the message is to
00021 //                    have a From line (and embedded From lines to be
00022 //                    escaped).  Flag is zero if the message should not
00023 //                    be molested by From lines (when writing to a pipe).
00024 //  Buffer NextLine() - return consecutive lines, until a NULL pointer is
00025 //                      returned.
00026 //
00027 //  When NULL pointer is returned, the hdrfrom, hdrsubject, and msgsize will
00028 //  contain message information (suitable for logging).
00029 //
00031 
00032 class FormatMbox {
00033 
00034        Buffer msglinebuf;
00035        Buffer tempbuf;
00036        int    do_escape;
00037 
00038        Buffer * (FormatMbox::* next_func)(void);
00039 
00040        Buffer *GetFromLine(void);
00041        Buffer *GetLineBuffer(void);
00042        Buffer *GetNextLineBuffer(void);
00043 
00044        int    inheader;
00045 public:
00046 
00047        Buffer hdrfrom, hdrsubject;
00048        unsigned long msgsize;
00049 
00050        FormatMbox()  {}
00051        ~FormatMbox() {}
00052 
00053        int    HasMsg();
00054        void   Init(int);
00055        Buffer *NextLine()
00056               {
00057                      return ( (this->*next_func)() );
00058               }
00059 
00060        int    DeliverTo(class Mio &);
00061 } ;
00062 #endif