1295Seric /*
23313Seric **  SENDMAIL.H -- Global definitions for sendmail.
3295Seric **
4*4374Seric **	@(#)sendmail.h	3.40	09/12/81
5295Seric */
6295Seric 
7295Seric 
8295Seric 
94371Seric # ifdef _DEFINE
104371Seric # define EXTERN
114371Seric # else  _DEFINE
124371Seric # define EXTERN extern
134371Seric # endif _DEFINE
14295Seric 
154183Seric # include <stdio.h>
164183Seric # include <ctype.h>
171390Seric # include "useful.h"
181390Seric 
19295Seric /*
204284Seric **  Configuration constants.
214284Seric **	There shouldn't be much need to change these....
22295Seric */
23295Seric 
24*4374Seric # define MAXLINE	256		/* max line length */
25*4374Seric # define MAXNAME	128		/* max length of a name */
26*4374Seric # define MAXFIELD	2500		/* max total length of a hdr field */
27*4374Seric # define MAXPV		40		/* max # of parms to mailers */
28*4374Seric # define MAXHOP		30		/* max value of HopCount */
29*4374Seric # define MAXATOM	15		/* max atoms per address */
30*4374Seric # define MAXMAILERS	10		/* maximum mailers known to system */
31*4374Seric # define SPACESUB	('.'|0200)	/* substitution for <lwsp> */
32295Seric 
334162Seric /* values for ArpaMode -- these are ordered!! */
344162Seric # define ARPA_NONE	0	/* not in arpanet mode */
354162Seric # define ARPA_OLD	1	/* in old arpanet mode */
364162Seric # define ARPA_MAIL	2	/* in regular arpanet mail */
374162Seric # define ARPA_FILE	3	/* reading over data connection */
38295Seric 
394167Seric extern char	Arpa_Info[];	/* the message number for Arpanet info */
40295Seric 
41295Seric 
42295Seric 
433190Seric 
444162Seric 
454167Seric 
46295Seric /*
473190Seric **  Address structure.
483190Seric **	Addresses are stored internally in this structure.
493190Seric */
503190Seric 
513190Seric struct address
523190Seric {
533190Seric 	char		*q_paddr;	/* the printname for the address */
543190Seric 	char		*q_user;	/* user name */
553190Seric 	char		*q_host;	/* host name */
563190Seric 	short		q_mailer;	/* mailer to use */
573190Seric 	short		q_rmailer;	/* real mailer (before mapping) */
584149Seric 	u_short		q_flags;	/* status flags, see below */
594213Seric 	short		q_uid;		/* user-id of receiver (if known) */
604079Seric 	char		*q_home;	/* home dir (local mailer only) */
613190Seric 	struct address	*q_next;	/* chain */
623190Seric };
633190Seric 
643190Seric typedef struct address ADDRESS;
653190Seric 
663190Seric # define QDONTSEND	000001	/* don't send to this address */
674068Seric # define QBADADDR	000002	/* this address is verified bad */
683190Seric 
693190Seric 
703190Seric 
713190Seric 
723190Seric 
733190Seric /*
74295Seric **  Mailer definition structure.
75295Seric **	Every mailer known to the system is declared in this
76295Seric **	structure.  It defines the pathname of the mailer, some
77295Seric **	flags associated with it, and the argument vector to
781390Seric **	pass to it.  The flags are defined in conf.c
79295Seric **
802899Seric **	The host map is a list of lists of strings.  Within each
812899Seric **	list, any host is mapped to the last host in the list.
822899Seric **	This allows multiple names, as well as doing clever
832899Seric **	mail grouping in point-to-point networks.  Note: this
842899Seric **	is only used internally, so the apparent host is still
852899Seric **	kept around.
862899Seric **
874171Seric **	The argument vector is expanded before actual use.  All
884171Seric **	words except the first are passed through the macro
894171Seric **	processor.
90295Seric */
91295Seric 
92295Seric struct mailer
93295Seric {
943190Seric 	char	*m_name;	/* symbolic name of this mailer */
95295Seric 	char	*m_mailer;	/* pathname of the mailer to use */
964149Seric 	u_long	m_flags;	/* status flags, see below */
97295Seric 	short	m_badstat;	/* the status code to use on unknown error */
982899Seric 	char	*m_from;	/* pattern for From: header */
993049Seric 	char	**m_argv;	/* template argument vector */
1003190Seric 	ADDRESS	*m_sendq;	/* list of addresses to send to */
101295Seric };
102295Seric 
1034100Seric typedef struct mailer	MAILER;
1044100Seric 
1052899Seric # define M_FOPT		000001	/* mailer takes picky -f flag */
1062899Seric # define M_ROPT		000002	/* mailer takes picky -r flag */
1072899Seric # define M_QUIET	000004	/* don't print error on bad status */
1082899Seric # define M_RESTR	000010	/* must be daemon to execute */
1093190Seric # define M_NHDR		000020	/* don't insert From line */
1104192Seric # define M_LOCAL	000040	/* delivery is to this host */
1112899Seric # define M_STRIPQ	000100	/* strip quote characters from user/host */
1123190Seric # define M_MUSER	000200	/* mailer can handle multiple users at once */
1132899Seric # define M_NEEDFROM	000400	/* need arpa-style From: line */
1142899Seric # define M_NEEDDATE	001000	/* need arpa-style Date: line */
1152899Seric # define M_MSGID	002000	/* need Message-Id: field */
1163153Seric # define M_USR_UPPER	010000	/* preserve user case distinction */
1173153Seric # define M_HST_UPPER	020000	/* preserve host case distinction */
1183390Seric # define M_FULLNAME	040000	/* want Full-Name field */
119295Seric 
1204317Seric # define M_ARPAFMT	(M_NEEDDATE|M_NEEDFROM|M_MSGID)
1212899Seric 
1224371Seric EXTERN MAILER *Mailer[MAXMAILERS+1];
123295Seric 
1244079Seric /* special mailer numbers */
1254192Seric # define MN_LOCAL	0	/* local mailer */
1264192Seric # define MN_PROG	1	/* program mailer */
1274100Seric /* mailers from 2 on are arbitrary */
128295Seric 
129295Seric 
1304079Seric 
1312899Seric /*
1322899Seric **  Header structure.
1332899Seric **	This structure is used internally to store header items.
1342899Seric */
135295Seric 
1362899Seric struct header
1372899Seric {
1382899Seric 	char		*h_field;	/* the name of the field */
1392899Seric 	char		*h_value;	/* the value of that field */
1402899Seric 	struct header	*h_link;	/* the next header */
1414149Seric 	u_short		h_flags;	/* status bits, see below */
1424149Seric 	u_long		h_mflags;	/* m_flags bits needed */
1432899Seric };
144295Seric 
1452899Seric typedef struct header	HDR;
1462899Seric 
1474371Seric EXTERN HDR	*Header;	/* head of header list */
1482899Seric 
149295Seric /*
1502899Seric **  Header information structure.
1512899Seric **	Defined in conf.c, this struct declares the header fields
1522899Seric **	that have some magic meaning.
1532899Seric */
1542899Seric 
1552899Seric struct hdrinfo
1562899Seric {
1572899Seric 	char	*hi_field;	/* the name of the field */
1584149Seric 	u_short	hi_flags;	/* status bits, see below */
1594149Seric 	u_short	hi_mflags;	/* m_flags needed for this field */
1602899Seric };
1612899Seric 
1622899Seric extern struct hdrinfo	HdrInfo[];
1632899Seric 
1642899Seric /* bits for h_flags and hi_flags */
1653060Seric # define H_EOH		00001	/* this field terminates header */
1662899Seric # define H_DEFAULT	00004	/* if another value is found, drop this */
1672899Seric # define H_USED		00010	/* indicates that this has been output */
1683386Seric # define H_CHECK	00020	/* check h_mflags against m_flags */
1693390Seric # define H_ACHECK	00040	/* ditto, but always (not just default) */
1704149Seric # define H_FORCE	00100	/* force this field, even if default */
1714222Seric # define H_ADDR		00200	/* this field contains addresses */
1722899Seric 
1732899Seric 
1743153Seric /*
1753153Seric **  Rewrite rules.
1763153Seric */
1772899Seric 
1783153Seric struct rewrite
1793153Seric {
1803153Seric 	char	**r_lhs;	/* pattern match */
1813153Seric 	char	**r_rhs;	/* substitution value */
1823153Seric 	struct rewrite	*r_next;/* next in chain */
1833153Seric };
1842899Seric 
1854090Seric extern struct rewrite	*RewriteRules[];
1863153Seric 
1874060Seric # define MATCHANY	'\020'	/* match one or more tokens */
1884060Seric # define MATCHONE	'\021'	/* match exactly one token */
1894060Seric # define MATCHCLASS	'\022'	/* match one token in a class */
1903153Seric 
1913153Seric # define CANONNET	'\025'	/* canonical net, next token */
1923153Seric # define CANONHOST	'\026'	/* canonical host, next token */
1933153Seric # define CANONUSER	'\027'	/* canonical user, next N tokens */
1943153Seric 
1953153Seric 
1963153Seric 
1974056Seric /*
1984056Seric **  Symbol table definitions
1994056Seric */
2003153Seric 
2014056Seric struct symtab
2024056Seric {
2034056Seric 	char		*s_name;	/* name to be entered */
2044100Seric 	char		s_type;		/* general type (see below) */
2054056Seric 	struct symtab	*s_next;	/* pointer to next in chain */
2064100Seric 	union
2074100Seric 	{
2084100Seric 		long	sv_class;	/* bit-map of word classes */
2094100Seric 		ADDRESS	*sv_addr;	/* pointer to address header */
2104100Seric 		MAILER	*sv_mailer;	/* pointer to mailer */
2114100Seric 		char	*sv_alias;	/* alias */
2124100Seric 	}	s_value;
2134056Seric };
2144056Seric 
2154056Seric typedef struct symtab	STAB;
2164056Seric 
2174100Seric /* symbol types */
2184100Seric # define ST_UNDEF	0	/* undefined type */
2194100Seric # define ST_CLASS	1	/* class map */
2204100Seric # define ST_ADDRESS	2	/* an address in parsed format */
2214100Seric # define ST_MAILER	3	/* a mailer header */
2224100Seric # define ST_ALIAS	4	/* an alias */
2234100Seric 
2244100Seric # define s_class	s_value.sv_class
2254100Seric # define s_addr		s_value.sv_addr
2264100Seric # define s_mailer	s_value.sv_mailer
2274100Seric # define s_alias	s_value.sv_alias
2284100Seric 
2294056Seric extern STAB	*stab();
2304056Seric 
2314056Seric /* opcodes to stab */
2324056Seric # define ST_FIND	0	/* find entry */
2334056Seric # define ST_ENTER	1	/* enter if not there */
2344056Seric 
2354056Seric 
2364056Seric 
2374056Seric 
2382899Seric /*
2394284Seric **  Statistics structure.
2404284Seric */
2414284Seric 
2424284Seric struct statistics
2434284Seric {
2444284Seric 	time_t	stat_itime;		/* file initialization time */
2454284Seric 	short	stat_size;		/* size of this structure */
2464284Seric 	long	stat_nf[MAXMAILERS];	/* # msgs from each mailer */
2474284Seric 	long	stat_bf[MAXMAILERS];	/* kbytes from each mailer */
2484284Seric 	long	stat_nt[MAXMAILERS];	/* # msgs to each mailer */
2494284Seric 	long	stat_bt[MAXMAILERS];	/* kbytes to each mailer */
2504284Seric };
2514284Seric 
2524371Seric EXTERN struct statistics	Stat;
2534284Seric extern long			kbytes();	/* for _bf, _bt */
2544284Seric 
2554284Seric 
2564284Seric 
2574284Seric 
2584284Seric /*
259295Seric **  Global variables.
260295Seric */
261295Seric 
2624371Seric EXTERN bool	FromFlag;	/* if set, "From" person is explicit */
2634371Seric EXTERN bool	MailBack;	/* mail back response on error */
2644371Seric EXTERN bool	BerkNet;	/* called from BerkNet */
2654371Seric EXTERN bool	WriteBack;	/* write back response on error */
2664371Seric EXTERN bool	NoAlias;	/* if set, don't do any aliasing */
2674371Seric EXTERN bool	ForceMail;	/* if set, mail even if already got a copy */
2684371Seric EXTERN bool	MeToo;		/* send to the sender also */
2694371Seric EXTERN bool	IgnrDot;	/* don't let dot end messages */
2704371Seric EXTERN bool	SaveFrom;	/* save leading "From" lines */
2714371Seric EXTERN bool	Verbose;	/* set if blow-by-blow desired */
2724371Seric EXTERN bool	GrabTo;		/* if set, get recipients from msg */
2734371Seric EXTERN bool	DontSend;	/* mark recipients as QDONTSEND */
2744371Seric EXTERN bool	NoReturn;	/* don't return letter to sender */
2754371Seric EXTERN int	OldUmask;	/* umask when sendmail starts up */
2764371Seric EXTERN int	Debug;		/* debugging level */
2774371Seric EXTERN int	Errors;		/* set if errors */
2784371Seric EXTERN int	ExitStat;	/* exit status code */
2794371Seric EXTERN int	ArpaMode;	/* ARPANET handling mode */
2804371Seric EXTERN long	MsgSize;	/* size of the message in bytes */
281295Seric extern char	InFileName[];	/* input file name */
282295Seric extern char	Transcript[];	/* the transcript file name */
2834371Seric EXTERN FILE	*TempFile;	/* mail temp file */
2844371Seric EXTERN ADDRESS	From;		/* the person it is from */
2854371Seric EXTERN char	*To;		/* the target person */
2864371Seric EXTERN int	HopCount;	/* hop count */
2874371Seric EXTERN long	CurTime;	/* time of this message */
2884371Seric EXTERN int	AliasLevel;	/* depth of aliasing */
2894371Seric EXTERN char	*OrigFrom;	/* the From: line read from the message */
2904371Seric EXTERN bool	SuprErrs;	/* set if we are suppressing errors */
2914371Seric EXTERN bool	HasXscrpt;	/* set if we have a transcript */
292295Seric 
293295Seric 
294295Seric # include	<sysexits.h>
295295Seric 
296295Seric # define setstat(s)		{ if (ExitStat == EX_OK) ExitStat = s; }
2974085Seric 
2984085Seric 
2994085Seric /* useful functions */
3004085Seric 
3014085Seric extern char	*newstr();
3024085Seric extern ADDRESS	*parse();
3034085Seric extern char	*xalloc();
3044085Seric extern char	*expand();
3054085Seric extern bool	sameaddr();
306