diff options
| author | Sam Varshavchik | 2013-08-19 16:39:41 -0400 |
|---|---|---|
| committer | Sam Varshavchik | 2013-08-25 14:43:51 -0400 |
| commit | 9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch) | |
| tree | 7a81a04cb51efb078ee350859a64be2ebc6b8813 /maildrop/formatmbox.h | |
| parent | a9520698b770168d1f33d6301463bb70a19655ec (diff) | |
| download | courier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2 | |
Initial checkin
Imported from subversion report, converted to git. Updated all paths in
scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'maildrop/formatmbox.h')
| -rw-r--r-- | maildrop/formatmbox.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/maildrop/formatmbox.h b/maildrop/formatmbox.h new file mode 100644 index 0000000..427fd2c --- /dev/null +++ b/maildrop/formatmbox.h @@ -0,0 +1,62 @@ +#ifndef formatmbox_h +#define formatmbox_h + + +#include "config.h" +#include "buffer.h" +#include "mio.h" + +////////////////////////////////////////////////////////////////////////////// +// +// FormatMbox class returns consecutive lines from the current message, +// formatted for delivery into a mailbox. That means the lines are +// terminate with either <LF> or <CRLF> (defined at compilation time). +// Furthermore, the message can be optionally preceded by the From line. +// +// Mandatory calling sequence: +// +// int HasMsg() - return 0 if there's a message to deliver, or -1 if +// the message is empty (none). +// void Init(flag) - initialize. Flag is non-zero if the message is to +// have a From line (and embedded From lines to be +// escaped). Flag is zero if the message should not +// be molested by From lines (when writing to a pipe). +// Buffer NextLine() - return consecutive lines, until a NULL pointer is +// returned. +// +// When NULL pointer is returned, the hdrfrom, hdrsubject, and msgsize will +// contain message information (suitable for logging). +// +////////////////////////////////////////////////////////////////////////////// + +class FormatMbox { + + Buffer msglinebuf; + Buffer tempbuf; + int do_escape; + + Buffer * (FormatMbox::* next_func)(void); + + Buffer *GetFromLine(void); + Buffer *GetLineBuffer(void); + Buffer *GetNextLineBuffer(void); + + int inheader; +public: + + Buffer hdrfrom, hdrsubject; + unsigned long msgsize; + + FormatMbox() {} + ~FormatMbox() {} + + int HasMsg(); + void Init(int); + Buffer *NextLine() + { + return ( (this->*next_func)() ); + } + + int DeliverTo(class Mio &); +} ; +#endif |
