summaryrefslogtreecommitdiffstats
path: root/maildrop/formatmbox.h
diff options
context:
space:
mode:
Diffstat (limited to 'maildrop/formatmbox.h')
-rw-r--r--maildrop/formatmbox.h62
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