File: submit.h

package info (click to toggle)
courier 1.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 49,084 kB
  • sloc: ansic: 126,176; cpp: 24,278; sh: 8,957; perl: 4,127; makefile: 3,192; sed: 16
file content (152 lines) | stat: -rw-r--r-- 4,022 bytes parent folder | download | duplicates (8)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
** Copyright 1998 - 2001 Double Precision, Inc.
** See COPYING for distribution information.
*/

#ifndef	submit_h
#define	submit_h

#include	"afx/afx.h"
#include	"dbobj.h"
#include	"courier.h"
#if	HAVE_SYS_STAT_H
#include	<sys/stat.h>
#endif
#if	HAVE_UNISTD_H
#include	<unistd.h>
#endif
#include	<fstream>
#include	<time.h>

#include	<list>
#include	<string>
#include	<set>

/////////////////////////////////////////////////////////////////////////////
//
// The SubmitFile class creates one or more control files in
// ${localstatedir}/tmp.
//
// The drudge work in submit.C calculates the actual sender/recipients,
// including aliases.dat lookups, and we get a raw list of addresses
//
// The SubmitFile class is implemented in submit2.C
//
// void Sender(const char *sender, const char *envid, char dsnformat)
//		- specifies envelope sender 'envid', and dsn format 'dsnformat'
// int ChkRecipient(const char *) - returns non-zero if this is a duplicate
// 				recipient, zero if not.
//
// void AddReceipient(const char *recipient, const char *orecipient,
//		const char *dsn, int isalias)
//                                - records recipient address 'recipient',
//				  which is original recipient 'orecipient',
//                                with delivery status notifications set to
//				  'dsn'.  'isalias' is non zero if this is
//				  a local alias, in which case the recipient
//				  is immediately marked as being received.
// void ReceipientFilter(struct rw_transport *module,
//		const char *host,
//		const char *address);
//				- After the message is received, it can be
//				optionally spam filtered.  Record recipient
//				information now, and then run each individual
//				recipient address's filter later.
//				ReceipientFilter supplies the recipient info
//				for the last address called to AddReceipient.
//				Addresses resulting from alias expansion are
//				not filtered.
//
// void interrupt() - should be called if process receives an interrupt.
//                    interrupt() deletes any temporary files that were created.
//
/////////////////////////////////////////////////////////////////////////////

struct	rfc2045;
struct	rw_transport;

class RcptFilterInfo {
public:
	unsigned num_control_file;
	unsigned num_receipient;

	struct rw_transport *driver;
	std::string host;
	std::string address;
	unsigned rcptnum;
} ;

class SubmitFile {
private:

static	SubmitFile *current_submit_file;

	unsigned num_control_files_created;

	std::string name1stctlfile();
	std::string namefile(const char *, unsigned n);

 public:
	std::set<std::string> all_files;
 private:
	unsigned	rcptcount;
	afxopipestream	ctlfile;
	afxiopipestream	datfile;
	ino_t		ctlinodenum;
	ino_t		ctlpid;
	time_t		ctltimestamp;
	std::string	basemsgid;

	struct		rfc2045 *rwrfcptr;
	const char 	*frommta;
	unsigned long	bytecount;
	unsigned long	sizelimit;
	int		diskfull;
	unsigned	diskspacecheck;
	std::string	sender, envid, dsnformat;
	std::string	receipient;
	std::set<std::string> addrlist_map;
	DbObj					addrlist_gdbm;

	std::list<RcptFilterInfo> rcptfilterlist;
	std::fstream	rcptfilterlist_file;

	const char *sending_module;

	void	openctl();
	void	closectl();
public:
	SubmitFile();
	~SubmitFile();

	std::string QueueID();
	void SendingModule(const char *p) {sending_module=p;}
	void Sender(const char *, const char *, const char *, char);
	int ChkRecipient(const char *);
	void AddReceipient(const char *, const char *, const char *, int);

	void ReceipientFilter(struct rw_transport *,
			const char *,
			const char *,
			unsigned);

	void MessageStart();
	void Message(const char *);
	int MessageEnd(unsigned, int, int);

	static std::string get_msgid_for_filtering(unsigned, void *);

static	void interrupt();
static	void trapsignals();


private:
	int datafilter(const char *, unsigned, const char *);

	void do_datafilter( unsigned &, int &, int,
			    struct rw_transport *, std::string, std::string, unsigned,

			    unsigned, unsigned, const char *, unsigned nrcpts);
} ;

#endif