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
|
#define MAXSAME 16
#define MAXSAMECHAR 1024
/* status of a destination*/
typedef enum {
d_undefined, /* address has not been matched*/
d_pipe, /* repl1|repl2 == delivery command, rep*/
d_cat, /* repl1 == mail file */
d_translate, /* repl1 == translation command*/
d_alias, /* repl1 == translation*/
d_auth, /* repl1 == command to authorize*/
d_syntax, /* addr contains illegal characters*/
d_unknown, /* addr does not match a rewrite rule*/
d_loop, /* addressing loop*/
d_eloop, /* external addressing loop*/
d_noforward, /* forwarding not allowed*/
d_badmbox, /* mailbox badly formatted*/
d_resource, /* ran out of something we needed*/
d_pipeto, /* pipe to from a mailbox*/
} d_status;
/* a destination*/
typedef struct dest dest;
struct dest {
dest *next; /* for chaining*/
dest *same; /* dests with same cmd*/
dest *parent; /* destination we're a translation of*/
String *addr; /* destination address*/
String *repl1; /* substitution field 1*/
String *repl2; /* substitution field 2*/
int pstat; /* process status*/
d_status status; /* delivery status*/
int authorized; /* non-zero if we have been authorized*/
int nsame; /* number of same dests chained to this entry*/
int nchar; /* number of characters in the command*/
};
typedef struct message message;
struct message {
String *sender;
String *replyaddr;
String *date;
String *body;
String *tmp; /* name of temp file */
String *to;
int size;
int fd; /* if >= 0, the file the message is stored in*/
char haveto;
String *havefrom;
String *havesender;
String *havereplyto;
char havedate;
char havemime;
String *havesubject;
char bulk; /* if Precedence: Bulk in header */
char rfc822headers;
int received; /* number of received lines */
char *boundary; /* bondary marker for attachments */
};
/*
* exported variables
*/
extern int rmail;
extern int onatty;
extern char *thissys, *altthissys;
extern int xflg;
extern int nflg;
extern int tflg;
extern int debug;
extern int nosummary;
/*
* exported procedures
*/
extern void authorize(dest*);
extern int cat_mail(dest*, message*);
extern dest *up_bind(dest*, message*, int);
extern int ok_to_forward(char*);
extern int lookup(char*, char*, Biobuf**, char*, Biobuf**);
extern dest *d_new(String*);
extern void d_free(dest*);
extern dest *d_rm(dest**);
extern void d_insert(dest**, dest*);
extern dest *d_rm_same(dest**);
extern void d_same_insert(dest**, dest*);
extern String *d_to(dest*);
extern dest *s_to_dest(String*, dest*);
extern void gateway(message*);
extern dest *expand_local(dest*);
extern void logdelivery(dest*, char*, message*);
extern void loglist(dest*, message*, char*);
extern void logrefusal(dest*, message*, char*);
extern int default_from(message*);
extern message *m_new(void);
extern void m_free(message*);
extern message *m_read(Biobuf*, int, int);
extern int m_get(message*, long, char**);
extern int m_print(message*, Biobuf*, char*, int);
extern int m_bprint(message*, Biobuf*);
extern String *rule_parse(String*, char*, int*);
extern int getrules(void);
extern int rewrite(dest*, message*);
extern void dumprules(void);
extern void regerror(char*);
extern dest *translate(dest*);
extern char* skipequiv(char*);
extern int refuse(dest*, message*, char*, int, int);
|