1295Seric /*
22979Seric **  POSTBOX.H -- Global definitions for postbox.
3295Seric **
4295Seric **	Most of these are actually allocated in globals.c
5295Seric **
6*3060Seric **	@(#)sendmail.h	3.5	03/07/81
7295Seric */
8295Seric 
9295Seric 
10295Seric 
11295Seric 
121390Seric # include "useful.h"
131390Seric 
14295Seric /*
15295Seric **  Manifest constants.
16295Seric */
17295Seric 
18295Seric # define MAXLINE	256	/* maximum line length */
19295Seric # define MAXNAME	128	/* maximum length of a name */
201379Seric # define MAXFIELD	2500	/* maximum total length of a header field */
21295Seric # define MAXPV		15	/* maximum # of parms to mailers */
22295Seric # define MAXHOP		30	/* maximum value of HopCount */
231516Seric # define ALIASFILE	"/usr/lib/aliases"	/* location of alias file */
24295Seric 
25295Seric 
26295Seric 
27295Seric 
28295Seric 
29295Seric /*
30295Seric **  Mailer definition structure.
31295Seric **	Every mailer known to the system is declared in this
32295Seric **	structure.  It defines the pathname of the mailer, some
33295Seric **	flags associated with it, and the argument vector to
341390Seric **	pass to it.  The flags are defined in conf.c
35295Seric **
362899Seric **	The host map is a list of lists of strings.  Within each
372899Seric **	list, any host is mapped to the last host in the list.
382899Seric **	This allows multiple names, as well as doing clever
392899Seric **	mail grouping in point-to-point networks.  Note: this
402899Seric **	is only used internally, so the apparent host is still
412899Seric **	kept around.
422899Seric **
43295Seric **	The argument vector is expanded before actual use.  Every-
44295Seric **	thing is passed through except for things starting with "$".
451390Seric **	"$x" defines some interpolation, as described in conf.c
46295Seric **	"$x" where x is unknown expands to "x", so use "$$" to get "$".
47295Seric */
48295Seric 
49295Seric struct mailer
50295Seric {
51295Seric 	char	*m_mailer;	/* pathname of the mailer to use */
52295Seric 	short	m_flags;	/* status flags, see below */
53295Seric 	short	m_badstat;	/* the status code to use on unknown error */
54295Seric 	char	**m_local;	/* list of local names for this host */
552899Seric 	char	*m_from;	/* pattern for From: header */
562899Seric 	char	***m_hmap;	/* host map */
573049Seric 	char	**m_argv;	/* template argument vector */
58295Seric };
59295Seric 
602899Seric # define M_FOPT		000001	/* mailer takes picky -f flag */
612899Seric # define M_ROPT		000002	/* mailer takes picky -r flag */
622899Seric # define M_QUIET	000004	/* don't print error on bad status */
632899Seric # define M_RESTR	000010	/* must be daemon to execute */
642899Seric # define M_HDR		000020	/* insert From line */
652899Seric # define M_NOHOST	000040	/* ignore host in comparisons */
662899Seric # define M_STRIPQ	000100	/* strip quote characters from user/host */
672899Seric # define M_FHDR		000200	/* force good From line */
682899Seric # define M_NEEDFROM	000400	/* need arpa-style From: line */
692899Seric # define M_NEEDDATE	001000	/* need arpa-style Date: line */
702899Seric # define M_MSGID	002000	/* need Message-Id: field */
712899Seric # define M_COMMAS	004000	/* need comma-seperated address lists */
72295Seric 
732899Seric # define M_ARPAFMT	(M_NEEDDATE|M_NEEDFROM|M_MSGID|M_COMMAS)
742899Seric 
753049Seric extern struct mailer *Mailer[];
76295Seric 
77295Seric 
78295Seric /*
79295Seric **  Address structure.
80295Seric **	Addresses are stored internally in this structure.
81295Seric */
82295Seric 
83295Seric struct address
84295Seric {
85295Seric 	char		*q_paddr;	/* the printname for the address */
86295Seric 	char		*q_user;	/* user name */
87295Seric 	char		*q_host;	/* host name */
883049Seric 	short		q_mailer;	/* mailer to use */
893049Seric 	short		q_rmailer;	/* real mailer (before mapping) */
90295Seric 	struct address	*q_next;	/* chain */
91295Seric 	struct address	*q_prev;	/* back pointer */
92295Seric };
93295Seric 
942979Seric typedef struct address ADDRESS;
95295Seric 
96295Seric /* some other primitives */
97295Seric # define nxtinq(q)	((q)->q_next)
98295Seric # define clearq(q)	(q)->q_next = (q)->q_prev = NULL
99295Seric 
1002979Seric extern ADDRESS SendQ;		/* queue of people to send to */
1012979Seric extern ADDRESS AliasQ;		/* queue of people that are aliases */
102295Seric 
103295Seric 
104295Seric /*
105295Seric **  Parse structure.
106295Seric **	This table drives the parser which determines the network
107295Seric **	to send the mail to.
108295Seric */
109295Seric 
110295Seric struct parsetab
111295Seric {
112295Seric 	char	p_char;		/* trigger character */
113295Seric 	char	p_mailer;	/* the index of the mailer to call */
114295Seric 	short	p_flags;	/* see below */
115295Seric 	char	*p_arg;		/* extra info needed for some flags */
116295Seric };
117295Seric 
118295Seric # define P_MAP		0001	/* map p_char -> p_arg[0] */
119295Seric # define P_HLAST	0002	/* host is last, & right associative */
120295Seric # define P_ONE		0004	/* can only be one p_char in addr */
121295Seric # define P_MOVE		0010	/* send untouched to host p_arg */
122295Seric # define P_USR_UPPER	0020	/* don't map UPPER->lower in user names */
123295Seric # define P_HST_UPPER	0040	/* don't map UPPER->lower in host names */
124295Seric 
125295Seric 
1262899Seric /*
1272899Seric **  Header structure.
1282899Seric **	This structure is used internally to store header items.
1292899Seric */
130295Seric 
1312899Seric struct header
1322899Seric {
1332899Seric 	char		*h_field;	/* the name of the field */
1342899Seric 	char		*h_value;	/* the value of that field */
1352899Seric 	struct header	*h_link;	/* the next header */
1362899Seric 	short		h_flags;	/* status bits, see below */
1372899Seric };
138295Seric 
1392899Seric typedef struct header	HDR;
1402899Seric 
1412899Seric extern HDR	*Header;	/* head of header list */
1422899Seric 
143295Seric /*
1442899Seric **  Header information structure.
1452899Seric **	Defined in conf.c, this struct declares the header fields
1462899Seric **	that have some magic meaning.
1472899Seric */
1482899Seric 
1492899Seric struct hdrinfo
1502899Seric {
1512899Seric 	char	*hi_field;	/* the name of the field */
1522899Seric 	short	hi_flags;	/* status bits, see below */
153*3060Seric 	char	**hi_pptr;	/* &ptr to point to this value */
1542899Seric };
1552899Seric 
1562899Seric extern struct hdrinfo	HdrInfo[];
1572899Seric 
1582899Seric /* bits for h_flags and hi_flags */
159*3060Seric # define H_EOH		00001	/* this field terminates header */
1602899Seric # define H_DELETE	00002	/* don't send this field */
1612899Seric # define H_DEFAULT	00004	/* if another value is found, drop this */
1622899Seric # define H_USED		00010	/* indicates that this has been output */
1632899Seric 
1642899Seric 
1652899Seric 
1662899Seric 
1672899Seric /*
168295Seric **  Global variables.
169295Seric */
170295Seric 
1711390Seric extern bool	ArpaFmt;	/* if set, message is in arpanet fmt */
1721390Seric extern bool	FromFlag;	/* if set, "From" person is explicit */
1731390Seric extern bool	Debug;		/* if set, debugging info */
1741390Seric extern bool	MailBack;	/* mail back response on error */
1751390Seric extern bool	BerkNet;	/* called from BerkNet */
1761390Seric extern bool	WriteBack;	/* write back response on error */
1771390Seric extern bool	NoAlias;	/* if set, don't do any aliasing */
1781390Seric extern bool	ForceMail;	/* if set, mail even if already got a copy */
1791390Seric extern bool	MeToo;		/* send to the sender also */
1801390Seric extern bool	UseMsgId;	/* put msg-id's in all msgs [conf.c] */
1811390Seric extern bool	IgnrDot;	/* don't let dot end messages */
1821390Seric extern bool	SaveFrom;	/* save leading "From" lines */
1831516Seric extern int	Errors;		/* set if errors */
184295Seric extern int	ExitStat;	/* exit status code */
185295Seric extern char	InFileName[];	/* input file name */
186295Seric extern char	Transcript[];	/* the transcript file name */
1872899Seric extern char	*MsgId;		/* the message id for this message */
1882899Seric extern char	*Date;		/* origination date (UNIX format) */
1892979Seric extern ADDRESS	From;		/* the person it is from */
190295Seric extern char	*To;		/* the target person */
191295Seric extern int	HopCount;	/* hop count */
192295Seric 
193295Seric 
194295Seric # include	<sysexits.h>
195295Seric 
196295Seric # define setstat(s)		{ if (ExitStat == EX_OK) ExitStat = s; }
197