xref: /plan9/sys/src/cmd/upas/send/send.h (revision 3b86f2f88bade1f00206c7aa750b7add255f5724)
1 /*
2  * these limits are intended to stay within those imposed by SMTP
3  * and avoid tickling bugs in other mail systems.
4  * they both pertain to attempts to group recipients for the same
5  * destination together in a single copy of a message.
6  */
7 #define MAXSAME 32	/* max recipients; was 16 */
8 #define MAXSAMECHAR 1024 /* max chars in the list of recipients */
9 
10 /* status of a destination*/
11 typedef enum {
12 	d_undefined,	/* address has not been matched*/
13 	d_pipe,		/* repl1|repl2 == delivery command, rep*/
14 	d_cat,		/* repl1 == mail file */
15 	d_translate,	/* repl1 == translation command*/
16 	d_alias,	/* repl1 == translation*/
17 	d_auth,		/* repl1 == command to authorize*/
18 	d_syntax,	/* addr contains illegal characters*/
19 	d_unknown,	/* addr does not match a rewrite rule*/
20 	d_loop,		/* addressing loop*/
21 	d_eloop,	/* external addressing loop*/
22 	d_noforward,	/* forwarding not allowed*/
23 	d_badmbox,	/* mailbox badly formatted*/
24 	d_resource,	/* ran out of something we needed*/
25 	d_pipeto,	/* pipe to from a mailbox*/
26 } d_status;
27 
28 /* a destination*/
29 typedef struct dest dest;
30 struct dest {
31 	dest	*next;		/* for chaining*/
32 	dest	*same;		/* dests with same cmd*/
33 	dest	*parent;	/* destination we're a translation of*/
34 	String	*addr;		/* destination address*/
35 	String	*repl1;		/* substitution field 1*/
36 	String	*repl2;		/* substitution field 2*/
37 	int	pstat;		/* process status*/
38 	d_status status;	/* delivery status*/
39 	int	authorized;	/* non-zero if we have been authorized*/
40 	int	nsame;		/* number of same dests chained to this entry*/
41 	int	nchar;		/* number of characters in the command*/
42 };
43 
44 typedef struct message message;
45 struct message {
46 	String	*sender;
47 	String	*replyaddr;
48 	String	*date;
49 	String	*body;
50 	String	*tmp;		/* name of temp file */
51 	String	*to;
52 	int	size;
53 	int	fd;		/* if >= 0, the file the message is stored in*/
54 	char	haveto;
55 	String	*havefrom;
56 	String	*havesender;
57 	String	*havereplyto;
58 	char	havedate;
59 	char	havemime;
60 	String	*havesubject;
61 	char	bulk;		/* if Precedence: Bulk in header */
62 	char	rfc822headers;
63 	int	received;	/* number of received lines */
64 	char	*boundary;	/* bondary marker for attachments */
65 };
66 
67 /*
68  *  exported variables
69  */
70 extern int rmail;
71 extern int onatty;
72 extern char *thissys, *altthissys;
73 extern int xflg;
74 extern int nflg;
75 extern int tflg;
76 extern int debug;
77 extern int nosummary;
78 
79 /*
80  *  exported procedures
81  */
82 extern void	authorize(dest*);
83 extern int	cat_mail(dest*, message*);
84 extern dest	*up_bind(dest*, message*, int);
85 extern int	ok_to_forward(char*);
86 extern int	lookup(char*, char*, Biobuf**, char*, Biobuf**);
87 extern dest	*d_new(String*);
88 extern void	d_free(dest*);
89 extern dest	*d_rm(dest**);
90 extern void	d_insert(dest**, dest*);
91 extern dest	*d_rm_same(dest**);
92 extern void	d_same_insert(dest**, dest*);
93 extern String	*d_to(dest*);
94 extern dest	*s_to_dest(String*, dest*);
95 extern void	gateway(message*);
96 extern dest	*expand_local(dest*);
97 extern void	logdelivery(dest*, char*, message*);
98 extern void	loglist(dest*, message*, char*);
99 extern void	logrefusal(dest*, message*, char*);
100 extern int	default_from(message*);
101 extern message	*m_new(void);
102 extern void	m_free(message*);
103 extern message	*m_read(Biobuf*, int, int);
104 extern int	m_get(message*, long, char**);
105 extern int	m_print(message*, Biobuf*, char*, int);
106 extern int	m_bprint(message*, Biobuf*);
107 extern String	*rule_parse(String*, char*, int*);
108 extern int	getrules(void);
109 extern int	rewrite(dest*, message*);
110 extern void	dumprules(void);
111 extern void	regerror(char*);
112 extern dest	*translate(dest*);
113 extern char*	skipequiv(char*);
114 extern int	refuse(dest*, message*, char*, int, int);
115