1 /*
2 **  POSTBOX.H -- Global definitions for postbox.
3 **
4 **	Most of these are actually allocated in globals.c
5 **
6 **	@(#)sendmail.h	3.3	03/07/81
7 */
8 
9 
10 
11 
12 # include "useful.h"
13 
14 /*
15 **  Manifest constants.
16 */
17 
18 # define MAXLINE	256	/* maximum line length */
19 # define MAXNAME	128	/* maximum length of a name */
20 # define MAXFIELD	2500	/* maximum total length of a header field */
21 # define MAXPV		15	/* maximum # of parms to mailers */
22 # define MAXHOP		30	/* maximum value of HopCount */
23 # define ALIASFILE	"/usr/lib/aliases"	/* location of alias file */
24 
25 
26 
27 
28 
29 /*
30 **  Mailer definition structure.
31 **	Every mailer known to the system is declared in this
32 **	structure.  It defines the pathname of the mailer, some
33 **	flags associated with it, and the argument vector to
34 **	pass to it.  The flags are defined in conf.c
35 **
36 **	The host map is a list of lists of strings.  Within each
37 **	list, any host is mapped to the last host in the list.
38 **	This allows multiple names, as well as doing clever
39 **	mail grouping in point-to-point networks.  Note: this
40 **	is only used internally, so the apparent host is still
41 **	kept around.
42 **
43 **	The argument vector is expanded before actual use.  Every-
44 **	thing is passed through except for things starting with "$".
45 **	"$x" defines some interpolation, as described in conf.c
46 **	"$x" where x is unknown expands to "x", so use "$$" to get "$".
47 */
48 
49 struct mailer
50 {
51 	char	*m_mailer;	/* pathname of the mailer to use */
52 	short	m_flags;	/* status flags, see below */
53 	short	m_badstat;	/* the status code to use on unknown error */
54 	char	**m_local;	/* list of local names for this host */
55 	char	*m_from;	/* pattern for From: header */
56 	char	***m_hmap;	/* host map */
57 	char	*m_argv[MAXPV];	/* template argument vector */
58 };
59 
60 # define M_FOPT		000001	/* mailer takes picky -f flag */
61 # define M_ROPT		000002	/* mailer takes picky -r flag */
62 # define M_QUIET	000004	/* don't print error on bad status */
63 # define M_RESTR	000010	/* must be daemon to execute */
64 # define M_HDR		000020	/* insert From line */
65 # define M_NOHOST	000040	/* ignore host in comparisons */
66 # define M_STRIPQ	000100	/* strip quote characters from user/host */
67 # define M_FHDR		000200	/* force good From line */
68 # define M_NEEDFROM	000400	/* need arpa-style From: line */
69 # define M_NEEDDATE	001000	/* need arpa-style Date: line */
70 # define M_MSGID	002000	/* need Message-Id: field */
71 # define M_COMMAS	004000	/* need comma-seperated address lists */
72 
73 # define M_ARPAFMT	(M_NEEDDATE|M_NEEDFROM|M_MSGID|M_COMMAS)
74 
75 extern struct mailer Mailer[];
76 
77 
78 /*
79 **  Address structure.
80 **	Addresses are stored internally in this structure.
81 */
82 
83 struct address
84 {
85 	char		*q_paddr;	/* the printname for the address */
86 	char		*q_user;	/* user name */
87 	char		*q_host;	/* host name */
88 	struct mailer	*q_mailer;	/* mailer to use */
89 	int		q_rmailer;	/* real mailer (before mapping) */
90 	struct address	*q_next;	/* chain */
91 	struct address	*q_prev;	/* back pointer */
92 };
93 
94 typedef struct address ADDRESS;
95 
96 /* some other primitives */
97 # define nxtinq(q)	((q)->q_next)
98 # define clearq(q)	(q)->q_next = (q)->q_prev = NULL
99 
100 extern ADDRESS SendQ;		/* queue of people to send to */
101 extern ADDRESS AliasQ;		/* queue of people that are aliases */
102 
103 
104 /*
105 **  Parse structure.
106 **	This table drives the parser which determines the network
107 **	to send the mail to.
108 */
109 
110 struct parsetab
111 {
112 	char	p_char;		/* trigger character */
113 	char	p_mailer;	/* the index of the mailer to call */
114 	short	p_flags;	/* see below */
115 	char	*p_arg;		/* extra info needed for some flags */
116 };
117 
118 # define P_MAP		0001	/* map p_char -> p_arg[0] */
119 # define P_HLAST	0002	/* host is last, & right associative */
120 # define P_ONE		0004	/* can only be one p_char in addr */
121 # define P_MOVE		0010	/* send untouched to host p_arg */
122 # define P_USR_UPPER	0020	/* don't map UPPER->lower in user names */
123 # define P_HST_UPPER	0040	/* don't map UPPER->lower in host names */
124 
125 
126 /*
127 **  Header structure.
128 **	This structure is used internally to store header items.
129 */
130 
131 struct header
132 {
133 	char		*h_field;	/* the name of the field */
134 	char		*h_value;	/* the value of that field */
135 	struct header	*h_link;	/* the next header */
136 	short		h_flags;	/* status bits, see below */
137 };
138 
139 typedef struct header	HDR;
140 
141 extern HDR	*Header;	/* head of header list */
142 
143 /*
144 **  Header information structure.
145 **	Defined in conf.c, this struct declares the header fields
146 **	that have some magic meaning.
147 */
148 
149 struct hdrinfo
150 {
151 	char	*hi_field;	/* the name of the field */
152 	short	hi_flags;	/* status bits, see below */
153 };
154 
155 extern struct hdrinfo	HdrInfo[];
156 
157 /* bits for h_flags and hi_flags */
158 # define H_CONCAT	00001	/* comma-concat multiple fields */
159 # define H_DELETE	00002	/* don't send this field */
160 # define H_DEFAULT	00004	/* if another value is found, drop this */
161 # define H_USED		00010	/* indicates that this has been output */
162 
163 
164 
165 
166 /*
167 **  Global variables.
168 */
169 
170 extern bool	ArpaFmt;	/* if set, message is in arpanet fmt */
171 extern bool	FromFlag;	/* if set, "From" person is explicit */
172 extern bool	Debug;		/* if set, debugging info */
173 extern bool	MailBack;	/* mail back response on error */
174 extern bool	BerkNet;	/* called from BerkNet */
175 extern bool	WriteBack;	/* write back response on error */
176 extern bool	NoAlias;	/* if set, don't do any aliasing */
177 extern bool	ForceMail;	/* if set, mail even if already got a copy */
178 extern bool	MeToo;		/* send to the sender also */
179 extern bool	UseMsgId;	/* put msg-id's in all msgs [conf.c] */
180 extern bool	IgnrDot;	/* don't let dot end messages */
181 extern bool	SaveFrom;	/* save leading "From" lines */
182 extern int	Errors;		/* set if errors */
183 extern int	ExitStat;	/* exit status code */
184 extern char	InFileName[];	/* input file name */
185 extern char	Transcript[];	/* the transcript file name */
186 extern char	*MsgId;		/* the message id for this message */
187 extern char	*Date;		/* origination date (UNIX format) */
188 extern ADDRESS	From;		/* the person it is from */
189 extern char	*To;		/* the target person */
190 extern int	HopCount;	/* hop count */
191 
192 
193 # include	<sysexits.h>
194 
195 # define setstat(s)		{ if (ExitStat == EX_OK) ExitStat = s; }
196