1295Seric /*
2295Seric **  DELIVERMAIL.H -- Global definitions for delivermail.
3295Seric **
4295Seric **	Most of these are actually allocated in globals.c
5295Seric **
6295Seric **	History:
7295Seric **		12/26/79 -- written.
8295Seric */
9295Seric 
10295Seric 
11295Seric 
12295Seric 
13295Seric /*
14295Seric **  Manifest constants.
15295Seric */
16295Seric 
17295Seric # define MAXLINE	256	/* maximum line length */
18295Seric # define MAXNAME	128	/* maximum length of a name */
19295Seric # define MAXPV		15	/* maximum # of parms to mailers */
20295Seric # define MAXHOP		30	/* maximum value of HopCount */
21295Seric 
22295Seric 
23295Seric 
24295Seric 
25295Seric 
26295Seric /*
27295Seric **  Mailer definition structure.
28295Seric **	Every mailer known to the system is declared in this
29295Seric **	structure.  It defines the pathname of the mailer, some
30295Seric **	flags associated with it, and the argument vector to
31295Seric **	pass to it.
32295Seric **
33295Seric **	The flags are as follows:
34295Seric **		M_FOPT -- if set, the mailer has a picky "-f"
35295Seric **			option.  In this mode, the mailer will only
36295Seric **			accept the "-f" option if the sender is
37295Seric **			actually "root", "network", and possibly
38295Seric **			(but not necessarily) if the -f argument
39295Seric **			matches the real sender.  The effect is
40295Seric **			that if the "-f" option is given to
41295Seric **			delivermail then it will be passed through
42295Seric **			(as arguments 1 & 2) to the mailer.
43295Seric **		M_ROPT -- identical to M_FOPT, except uses -r instead.
44295Seric **			UGH!
45295Seric **		M_QUIET -- if set, don't print a message if the mailer
46295Seric **			returns bad status.
47295Seric **		M_RESTR -- if set, this mailer is restricted to use
48295Seric **			by "daemon"; otherwise, we do a
49295Seric **			setuid(getuid()) before calling the mailer.
50295Seric **		M_HDR -- if set, the mailer wants us to insert a
51295Seric **			UNIX "From" line before outputting.
52295Seric **		M_NOHOST -- if set, this mailer doesn't care about
53295Seric **			the host part (e.g., the local mailer).
54295Seric **		M_STRIPQ -- if set, strip quote (`"') characters
55295Seric **			out of parameters as you transliterate them
56295Seric **			into the argument vector.  For example, the
57295Seric **			local mailer is called directly, so these
58295Seric **			should be stripped, but the program-mailer
59295Seric **			(i.e., csh) should leave them in.
60295Seric **
61295Seric **	The argument vector is expanded before actual use.  Every-
62295Seric **	thing is passed through except for things starting with "$".
63295Seric **	"$x" defines some interpolation, as defined by x:
64295Seric **		$f	The "from" person.
65295Seric **		$h	The host being sent to.
66295Seric **		$u	The user being sent to.
67295Seric **		$c	The current hop count.
68295Seric **	"$x" where x is unknown expands to "x", so use "$$" to get "$".
69295Seric */
70295Seric 
71295Seric struct mailer
72295Seric {
73295Seric 	char	*m_mailer;	/* pathname of the mailer to use */
74295Seric 	short	m_flags;	/* status flags, see below */
75295Seric 	short	m_badstat;	/* the status code to use on unknown error */
76295Seric 	char	**m_local;	/* list of local names for this host */
77295Seric 	char	*m_argv[MAXPV];	/* template argument vector */
78295Seric };
79295Seric 
80295Seric # define M_FOPT		0001	/* mailer takes picky -f flag */
81295Seric # define M_ROPT		0002	/* mailer takes picky -r flag */
82295Seric # define M_QUIET	0004	/* don't print error on bad status */
83295Seric # define M_RESTR	0010	/* must be daemon to execute */
84295Seric # define M_HDR		0020	/* insert From line */
85295Seric # define M_NOHOST	0040	/* ignore host in comparisons */
86295Seric # define M_STRIPQ	0100	/* strip quote characters from user/host */
87295Seric 
88295Seric extern struct mailer Mailer[];
89295Seric 
90295Seric 
91295Seric /*
92295Seric **  Address structure.
93295Seric **	Addresses are stored internally in this structure.
94295Seric */
95295Seric 
96295Seric struct address
97295Seric {
98295Seric 	char		*q_paddr;	/* the printname for the address */
99295Seric 	char		*q_user;	/* user name */
100295Seric 	char		*q_host;	/* host name */
101295Seric 	struct mailer	*q_mailer;	/* mailer to use */
102295Seric 	struct address	*q_next;	/* chain */
103295Seric 	struct address	*q_prev;	/* back pointer */
104295Seric };
105295Seric 
106295Seric typedef struct address addrq;
107295Seric 
108295Seric /* some other primitives */
109295Seric # define nxtinq(q)	((q)->q_next)
110295Seric # define clearq(q)	(q)->q_next = (q)->q_prev = NULL
111295Seric 
112295Seric extern addrq SendQ;		/* queue of people to send to */
113295Seric extern addrq AliasQ;		/* queue of people that are aliases */
114295Seric 
115295Seric 
116295Seric /*
117295Seric **  Parse structure.
118295Seric **	This table drives the parser which determines the network
119295Seric **	to send the mail to.
120295Seric */
121295Seric 
122295Seric struct parsetab
123295Seric {
124295Seric 	char	p_char;		/* trigger character */
125295Seric 	char	p_mailer;	/* the index of the mailer to call */
126295Seric 	short	p_flags;	/* see below */
127295Seric 	char	*p_arg;		/* extra info needed for some flags */
128295Seric };
129295Seric 
130295Seric # define P_MAP		0001	/* map p_char -> p_arg[0] */
131295Seric # define P_HLAST	0002	/* host is last, & right associative */
132295Seric # define P_ONE		0004	/* can only be one p_char in addr */
133295Seric # define P_MOVE		0010	/* send untouched to host p_arg */
134295Seric # define P_USR_UPPER	0020	/* don't map UPPER->lower in user names */
135295Seric # define P_HST_UPPER	0040	/* don't map UPPER->lower in host names */
136295Seric 
137295Seric 
138295Seric 
139295Seric 
140295Seric /*
141295Seric **  Global variables.
142295Seric */
143295Seric 
144295Seric extern char	ArpaFmt;	/* if set, message is in arpanet fmt */
145295Seric extern char	FromFlag;	/* if set, "From" person is explicit */
146295Seric extern char	Debug;		/* if set, debugging info */
147295Seric extern char	MailBack;	/* mail back response on error */
148*401Seric extern char	BerkNet;	/* called from BerkNet */
149295Seric extern char	WriteBack;	/* write back response on error */
150295Seric extern char	NoAlias;	/* if set, don't do any aliasing */
151295Seric extern char	ForceMail;	/* if set, mail even if already got a copy */
152295Seric extern char	MeToo;		/* send to the sender also */
153295Seric extern char	Error;		/* set if errors */
154295Seric extern int	ExitStat;	/* exit status code */
155295Seric extern char	InFileName[];	/* input file name */
156295Seric extern char	Transcript[];	/* the transcript file name */
157295Seric extern addrq	From;		/* the person it is from */
158295Seric extern char	*To;		/* the target person */
159295Seric extern int	HopCount;	/* hop count */
160295Seric 
161295Seric 
162295Seric # include	<sysexits.h>
163295Seric 
164295Seric # define flagset(bits, word)	((bits) & (word))
165295Seric # define setstat(s)		{ if (ExitStat == EX_OK) ExitStat = s; }
166295Seric 
167295Seric # include "useful.h"
168295Seric 
169295Seric # define BADMAIL	YES	/* mail doesn't know about new returncodes */
170