summaryrefslogtreecommitdiffstats
path: root/maildrop/formatmbox.h
blob: 427fd2c24980e5fe8f05df5e979e41230228e4a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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