1295Seric /*
23313Seric **  SENDMAIL.H -- Global definitions for sendmail.
3295Seric **
4*4162Seric **	@(#)sendmail.h	3.25	08/18/81
5295Seric */
6295Seric 
7295Seric 
8295Seric 
9295Seric 
101390Seric # include "useful.h"
111390Seric 
12295Seric /*
13295Seric **  Manifest constants.
14295Seric */
15295Seric 
16295Seric # define MAXLINE	256	/* maximum line length */
17295Seric # define MAXNAME	128	/* maximum length of a name */
181379Seric # define MAXFIELD	2500	/* maximum total length of a header field */
193234Seric # define MAXPV		40	/* maximum # of parms to mailers */
20295Seric # define MAXHOP		30	/* maximum value of HopCount */
213153Seric # define MAXATOM	15	/* max atoms per address */
224094Seric # define MAXMAILERS	10	/* maximum mailers known to system */
231516Seric # define ALIASFILE	"/usr/lib/aliases"	/* location of alias file */
244094Seric # define CONFFILE	"/usr/lib/sendmail.cf"	/* configuration file */
25295Seric 
26*4162Seric /* values for ArpaMode -- these are ordered!! */
27*4162Seric # define ARPA_NONE	0	/* not in arpanet mode */
28*4162Seric # define ARPA_OLD	1	/* in old arpanet mode */
29*4162Seric # define ARPA_MAIL	2	/* in regular arpanet mail */
30*4162Seric # define ARPA_FILE	3	/* reading over data connection */
31295Seric 
32295Seric 
33295Seric 
34295Seric 
353190Seric 
36*4162Seric 
37295Seric /*
383190Seric **  Address structure.
393190Seric **	Addresses are stored internally in this structure.
403190Seric */
413190Seric 
423190Seric struct address
433190Seric {
443190Seric 	char		*q_paddr;	/* the printname for the address */
453190Seric 	char		*q_user;	/* user name */
463190Seric 	char		*q_host;	/* host name */
473190Seric 	short		q_mailer;	/* mailer to use */
483190Seric 	short		q_rmailer;	/* real mailer (before mapping) */
494149Seric 	u_short		q_flags;	/* status flags, see below */
504079Seric 	char		*q_home;	/* home dir (local mailer only) */
513190Seric 	struct address	*q_next;	/* chain */
523190Seric };
533190Seric 
543190Seric typedef struct address ADDRESS;
553190Seric 
563190Seric # define QDONTSEND	000001	/* don't send to this address */
574068Seric # define QBADADDR	000002	/* this address is verified bad */
583190Seric 
593190Seric 
603190Seric 
613190Seric 
623190Seric 
633190Seric /*
64295Seric **  Mailer definition structure.
65295Seric **	Every mailer known to the system is declared in this
66295Seric **	structure.  It defines the pathname of the mailer, some
67295Seric **	flags associated with it, and the argument vector to
681390Seric **	pass to it.  The flags are defined in conf.c
69295Seric **
702899Seric **	The host map is a list of lists of strings.  Within each
712899Seric **	list, any host is mapped to the last host in the list.
722899Seric **	This allows multiple names, as well as doing clever
732899Seric **	mail grouping in point-to-point networks.  Note: this
742899Seric **	is only used internally, so the apparent host is still
752899Seric **	kept around.
762899Seric **
77295Seric **	The argument vector is expanded before actual use.  Every-
78295Seric **	thing is passed through except for things starting with "$".
791390Seric **	"$x" defines some interpolation, as described in conf.c
80295Seric **	"$x" where x is unknown expands to "x", so use "$$" to get "$".
81295Seric */
82295Seric 
83295Seric struct mailer
84295Seric {
853190Seric 	char	*m_name;	/* symbolic name of this mailer */
86295Seric 	char	*m_mailer;	/* pathname of the mailer to use */
874149Seric 	u_long	m_flags;	/* status flags, see below */
88295Seric 	short	m_badstat;	/* the status code to use on unknown error */
892899Seric 	char	*m_from;	/* pattern for From: header */
903049Seric 	char	**m_argv;	/* template argument vector */
913190Seric 	ADDRESS	*m_sendq;	/* list of addresses to send to */
92295Seric };
93295Seric 
944100Seric typedef struct mailer	MAILER;
954100Seric 
962899Seric # define M_FOPT		000001	/* mailer takes picky -f flag */
972899Seric # define M_ROPT		000002	/* mailer takes picky -r flag */
982899Seric # define M_QUIET	000004	/* don't print error on bad status */
992899Seric # define M_RESTR	000010	/* must be daemon to execute */
1003190Seric # define M_NHDR		000020	/* don't insert From line */
1012899Seric # define M_NOHOST	000040	/* ignore host in comparisons */
1022899Seric # define M_STRIPQ	000100	/* strip quote characters from user/host */
1033190Seric # define M_MUSER	000200	/* mailer can handle multiple users at once */
1042899Seric # define M_NEEDFROM	000400	/* need arpa-style From: line */
1052899Seric # define M_NEEDDATE	001000	/* need arpa-style Date: line */
1062899Seric # define M_MSGID	002000	/* need Message-Id: field */
1074149Seric # define M_FINAL	004000	/* mailing will effect final delivery */
1083153Seric # define M_USR_UPPER	010000	/* preserve user case distinction */
1093153Seric # define M_HST_UPPER	020000	/* preserve host case distinction */
1103390Seric # define M_FULLNAME	040000	/* want Full-Name field */
111295Seric 
1123390Seric # define M_ARPAFMT	(M_NEEDDATE|M_NEEDFROM|M_NEEDDATE)
1132899Seric 
1144100Seric extern MAILER *Mailer[];
115295Seric 
1164079Seric /* special mailer numbers */
1174079Seric # define M_LOCAL	0	/* local mailer */
1184079Seric # define M_PROG		1	/* program mailer */
1194100Seric /* mailers from 2 on are arbitrary */
120295Seric 
121295Seric 
1224079Seric 
1232899Seric /*
1242899Seric **  Header structure.
1252899Seric **	This structure is used internally to store header items.
1262899Seric */
127295Seric 
1282899Seric struct header
1292899Seric {
1302899Seric 	char		*h_field;	/* the name of the field */
1312899Seric 	char		*h_value;	/* the value of that field */
1322899Seric 	struct header	*h_link;	/* the next header */
1334149Seric 	u_short		h_flags;	/* status bits, see below */
1344149Seric 	u_long		h_mflags;	/* m_flags bits needed */
1352899Seric };
136295Seric 
1372899Seric typedef struct header	HDR;
1382899Seric 
1392899Seric extern HDR	*Header;	/* head of header list */
1402899Seric 
141295Seric /*
1422899Seric **  Header information structure.
1432899Seric **	Defined in conf.c, this struct declares the header fields
1442899Seric **	that have some magic meaning.
1452899Seric */
1462899Seric 
1472899Seric struct hdrinfo
1482899Seric {
1492899Seric 	char	*hi_field;	/* the name of the field */
1504149Seric 	u_short	hi_flags;	/* status bits, see below */
1514149Seric 	u_short	hi_mflags;	/* m_flags needed for this field */
1522899Seric };
1532899Seric 
1542899Seric extern struct hdrinfo	HdrInfo[];
1552899Seric 
1562899Seric /* bits for h_flags and hi_flags */
1573060Seric # define H_EOH		00001	/* this field terminates header */
1582899Seric # define H_DELETE	00002	/* don't send this field */
1592899Seric # define H_DEFAULT	00004	/* if another value is found, drop this */
1602899Seric # define H_USED		00010	/* indicates that this has been output */
1613386Seric # define H_CHECK	00020	/* check h_mflags against m_flags */
1623390Seric # define H_ACHECK	00040	/* ditto, but always (not just default) */
1634149Seric # define H_FORCE	00100	/* force this field, even if default */
1642899Seric 
1652899Seric 
1663153Seric /*
1673153Seric **  Rewrite rules.
1683153Seric */
1692899Seric 
1703153Seric struct rewrite
1713153Seric {
1723153Seric 	char	**r_lhs;	/* pattern match */
1733153Seric 	char	**r_rhs;	/* substitution value */
1743153Seric 	struct rewrite	*r_next;/* next in chain */
1753153Seric };
1762899Seric 
1774090Seric extern struct rewrite	*RewriteRules[];
1783153Seric 
1794060Seric # define MATCHANY	'\020'	/* match one or more tokens */
1804060Seric # define MATCHONE	'\021'	/* match exactly one token */
1814060Seric # define MATCHCLASS	'\022'	/* match one token in a class */
1823153Seric 
1833153Seric # define CANONNET	'\025'	/* canonical net, next token */
1843153Seric # define CANONHOST	'\026'	/* canonical host, next token */
1853153Seric # define CANONUSER	'\027'	/* canonical user, next N tokens */
1863153Seric 
1873153Seric 
1883153Seric 
1894056Seric /*
1904056Seric **  Symbol table definitions
1914056Seric */
1923153Seric 
1934056Seric struct symtab
1944056Seric {
1954056Seric 	char		*s_name;	/* name to be entered */
1964100Seric 	char		s_type;		/* general type (see below) */
1974056Seric 	struct symtab	*s_next;	/* pointer to next in chain */
1984100Seric 	union
1994100Seric 	{
2004100Seric 		long	sv_class;	/* bit-map of word classes */
2014100Seric 		ADDRESS	*sv_addr;	/* pointer to address header */
2024100Seric 		MAILER	*sv_mailer;	/* pointer to mailer */
2034100Seric 		char	*sv_alias;	/* alias */
2044100Seric 	}	s_value;
2054056Seric };
2064056Seric 
2074056Seric typedef struct symtab	STAB;
2084056Seric 
2094100Seric /* symbol types */
2104100Seric # define ST_UNDEF	0	/* undefined type */
2114100Seric # define ST_CLASS	1	/* class map */
2124100Seric # define ST_ADDRESS	2	/* an address in parsed format */
2134100Seric # define ST_MAILER	3	/* a mailer header */
2144100Seric # define ST_ALIAS	4	/* an alias */
2154100Seric 
2164100Seric # define s_class	s_value.sv_class
2174100Seric # define s_addr		s_value.sv_addr
2184100Seric # define s_mailer	s_value.sv_mailer
2194100Seric # define s_alias	s_value.sv_alias
2204100Seric 
2214056Seric extern STAB	*stab();
2224056Seric 
2234056Seric /* opcodes to stab */
2244056Seric # define ST_FIND	0	/* find entry */
2254056Seric # define ST_ENTER	1	/* enter if not there */
2264056Seric 
2274056Seric 
2284056Seric 
2294056Seric 
2302899Seric /*
231295Seric **  Global variables.
232295Seric */
233295Seric 
234*4162Seric extern int	ArpaMode;	/* ARPANET handling mode */
2351390Seric extern bool	FromFlag;	/* if set, "From" person is explicit */
2361390Seric extern bool	MailBack;	/* mail back response on error */
2371390Seric extern bool	BerkNet;	/* called from BerkNet */
2381390Seric extern bool	WriteBack;	/* write back response on error */
2391390Seric extern bool	NoAlias;	/* if set, don't do any aliasing */
2401390Seric extern bool	ForceMail;	/* if set, mail even if already got a copy */
2411390Seric extern bool	MeToo;		/* send to the sender also */
2421390Seric extern bool	IgnrDot;	/* don't let dot end messages */
2431390Seric extern bool	SaveFrom;	/* save leading "From" lines */
2444064Seric extern bool	Verbose;	/* set if blow-by-blow desired */
2454073Seric extern int	Debug;		/* debugging level */
2461516Seric extern int	Errors;		/* set if errors */
247295Seric extern int	ExitStat;	/* exit status code */
248295Seric extern char	InFileName[];	/* input file name */
249295Seric extern char	Transcript[];	/* the transcript file name */
2502979Seric extern ADDRESS	From;		/* the person it is from */
251295Seric extern char	*To;		/* the target person */
252295Seric extern int	HopCount;	/* hop count */
2533190Seric extern long	CurTime;	/* time of this message */
2543190Seric extern char	FromLine[];	/* a UNIX-style From line for this message */
2554100Seric extern int	AliasLevel;	/* depth of aliasing */
256295Seric 
257295Seric 
258295Seric # include	<sysexits.h>
259295Seric 
260295Seric # define setstat(s)		{ if (ExitStat == EX_OK) ExitStat = s; }
2614085Seric 
2624085Seric 
2634085Seric /* useful functions */
2644085Seric 
2654085Seric extern char	*newstr();
2664085Seric extern ADDRESS	*parse();
2674085Seric extern char	*xalloc();
2684085Seric extern char	*expand();
2694085Seric extern bool	sameaddr();
270