1 /*
2  * Copyright (c) 1983 Eric P. Allman
3  * Copyright (c) 1988 Regents of the University of California.
4  * All rights reserved.
5  *
6  * %sccs.include.redist.c%
7  *
8  *	@(#)sendmail.h	5.43 (Berkeley) 11/16/92
9  */
10 
11 /*
12 **  SENDMAIL.H -- Global definitions for sendmail.
13 */
14 
15 # ifdef _DEFINE
16 # define EXTERN
17 # ifndef lint
18 static char SmailSccsId[] =	"@(#)sendmail.h	5.43		11/16/92";
19 # endif lint
20 # else /*  _DEFINE */
21 # define EXTERN extern
22 # endif /* _DEFINE */
23 
24 # include <stddef.h>
25 # include <stdlib.h>
26 # include <stdio.h>
27 # include <ctype.h>
28 # include <setjmp.h>
29 # include <sysexits.h>
30 # include <string.h>
31 # include <time.h>
32 # include <errno.h>
33 
34 # include "conf.h"
35 # include "useful.h"
36 
37 # ifdef LOG
38 # include <syslog.h>
39 # endif /* LOG */
40 
41 # ifdef DAEMON
42 # include <sys/socket.h>
43 # include <netinet/in.h>
44 # endif /* DAEMON */
45 
46 
47 # define PSBUFSIZE	(MAXNAME + MAXATOM)	/* size of prescan buffer */
48 
49 
50 /*
51 **  Data structure for bit maps.
52 **
53 **	Each bit in this map can be referenced by an ascii character.
54 **	This is 128 possible bits, or 12 8-bit bytes.
55 */
56 
57 #define BITMAPBYTES	16	/* number of bytes in a bit map */
58 #define BYTEBITS	8	/* number of bits in a byte */
59 
60 /* internal macros */
61 #define _BITWORD(bit)	(bit / (BYTEBITS * sizeof (int)))
62 #define _BITBIT(bit)	(1 << (bit % (BYTEBITS * sizeof (int))))
63 
64 typedef int	BITMAP[BITMAPBYTES / sizeof (int)];
65 
66 /* test bit number N */
67 #define bitnset(bit, map)	((map)[_BITWORD(bit)] & _BITBIT(bit))
68 
69 /* set bit number N */
70 #define setbitn(bit, map)	(map)[_BITWORD(bit)] |= _BITBIT(bit)
71 
72 /* clear bit number N */
73 #define clrbitn(bit, map)	(map)[_BITWORD(bit)] &= ~_BITBIT(bit)
74 
75 /* clear an entire bit map */
76 #define clrbitmap(map)		bzero((char *) map, BITMAPBYTES)
77 /*
78 **  Address structure.
79 **	Addresses are stored internally in this structure.
80 */
81 
82 struct address
83 {
84 	char		*q_paddr;	/* the printname for the address */
85 	char		*q_user;	/* user name */
86 	char		*q_ruser;	/* real user name, or NULL if q_user */
87 	char		*q_host;	/* host name */
88 	struct mailer	*q_mailer;	/* mailer to use */
89 	u_short		q_flags;	/* status flags, see below */
90 	uid_t		q_uid;		/* user-id of receiver (if known) */
91 	gid_t		q_gid;		/* group-id of receiver (if known) */
92 	char		*q_home;	/* home dir (local mailer only) */
93 	char		*q_fullname;	/* full name if known */
94 	struct address	*q_next;	/* chain */
95 	struct address	*q_alias;	/* address this results from */
96 	struct address	*q_tchain;	/* temporary use chain */
97 	time_t		q_timeout;	/* timeout for this address */
98 };
99 
100 typedef struct address ADDRESS;
101 
102 # define QDONTSEND	000001	/* don't send to this address */
103 # define QBADADDR	000002	/* this address is verified bad */
104 # define QGOODUID	000004	/* the q_uid q_gid fields are good */
105 # define QPRIMARY	000010	/* set from argv */
106 # define QQUEUEUP	000020	/* queue for later transmission */
107 # define QSENT		000040	/* has been successfully delivered */
108 # define QNOTREMOTE	000100	/* not an address for remote forwarding */
109 /*
110 **  Mailer definition structure.
111 **	Every mailer known to the system is declared in this
112 **	structure.  It defines the pathname of the mailer, some
113 **	flags associated with it, and the argument vector to
114 **	pass to it.  The flags are defined in conf.c
115 **
116 **	The argument vector is expanded before actual use.  All
117 **	words except the first are passed through the macro
118 **	processor.
119 */
120 
121 struct mailer
122 {
123 	char	*m_name;	/* symbolic name of this mailer */
124 	char	*m_mailer;	/* pathname of the mailer to use */
125 	BITMAP	m_flags;	/* status flags, see below */
126 	short	m_mno;		/* mailer number internally */
127 	char	**m_argv;	/* template argument vector */
128 	short	m_s_rwset;	/* rewriting set for sender addresses */
129 	short	m_r_rwset;	/* rewriting set for recipient addresses */
130 	char	*m_eol;		/* end of line string */
131 	long	m_maxsize;	/* size limit on message to this mailer */
132 	int	m_linelimit;	/* max # characters per line */
133 };
134 
135 typedef struct mailer	MAILER;
136 
137 /* bits for m_flags */
138 # define M_CANONICAL	'C'	/* make addresses canonical "u@dom" */
139 # define M_EXPENSIVE	'e'	/* it costs to use this mailer.... */
140 # define M_ESCFROM	'E'	/* escape From lines to >From */
141 # define M_FOPT		'f'	/* mailer takes picky -f flag */
142 # define M_HST_UPPER	'h'	/* preserve host case distinction */
143 # define M_INTERNAL	'I'	/* SMTP to another sendmail site */
144 # define M_LOCAL	'l'	/* delivery is to this host */
145 # define M_LIMITS	'L'	/* must enforce SMTP line limits */
146 # define M_MUSER	'm'	/* can handle multiple users at once */
147 # define M_NHDR		'n'	/* don't insert From line */
148 # define M_FROMPATH	'p'	/* use reverse-path in MAIL FROM: */
149 # define M_ROPT		'r'	/* mailer takes picky -r flag */
150 # define M_SECURE_PORT	'R'	/* try to send on a reserved TCP port */
151 # define M_STRIPQ	's'	/* strip quote chars from user/host */
152 # define M_RESTR	'S'	/* must be daemon to execute */
153 # define M_USR_UPPER	'u'	/* preserve user case distinction */
154 # define M_UGLYUUCP	'U'	/* this wants an ugly UUCP from line */
155 # define M_XDOT		'X'	/* use hidden-dot algorithm */
156 # define M_7BITS	'7'	/* use 7-bit path */
157 
158 EXTERN MAILER	*Mailer[MAXMAILERS+1];
159 
160 EXTERN MAILER	*LocalMailer;		/* ptr to local mailer */
161 EXTERN MAILER	*ProgMailer;		/* ptr to program mailer */
162 /*
163 **  Header structure.
164 **	This structure is used internally to store header items.
165 */
166 
167 struct header
168 {
169 	char		*h_field;	/* the name of the field */
170 	char		*h_value;	/* the value of that field */
171 	struct header	*h_link;	/* the next header */
172 	u_short		h_flags;	/* status bits, see below */
173 	BITMAP		h_mflags;	/* m_flags bits needed */
174 };
175 
176 typedef struct header	HDR;
177 
178 /*
179 **  Header information structure.
180 **	Defined in conf.c, this struct declares the header fields
181 **	that have some magic meaning.
182 */
183 
184 struct hdrinfo
185 {
186 	char	*hi_field;	/* the name of the field */
187 	u_short	hi_flags;	/* status bits, see below */
188 };
189 
190 extern struct hdrinfo	HdrInfo[];
191 
192 /* bits for h_flags and hi_flags */
193 # define H_EOH		00001	/* this field terminates header */
194 # define H_RCPT		00002	/* contains recipient addresses */
195 # define H_DEFAULT	00004	/* if another value is found, drop this */
196 # define H_RESENT	00010	/* this address is a "Resent-..." address */
197 # define H_CHECK	00020	/* check h_mflags against m_flags */
198 # define H_ACHECK	00040	/* ditto, but always (not just default) */
199 # define H_FORCE	00100	/* force this field, even if default */
200 # define H_TRACE	00200	/* this field contains trace information */
201 # define H_FROM		00400	/* this is a from-type field */
202 # define H_VALID	01000	/* this field has a validated value */
203 /*
204 **  Envelope structure.
205 **	This structure defines the message itself.  There is usually
206 **	only one of these -- for the message that we originally read
207 **	and which is our primary interest -- but other envelopes can
208 **	be generated during processing.  For example, error messages
209 **	will have their own envelope.
210 */
211 
212 struct envelope
213 {
214 	HDR		*e_header;	/* head of header list */
215 	long		e_msgpriority;	/* adjusted priority of this message */
216 	time_t		e_ctime;	/* time message appeared in the queue */
217 	char		*e_to;		/* the target person */
218 	char		*e_receiptto;	/* return receipt address */
219 	ADDRESS		e_from;		/* the person it is from */
220 	char		*e_sender;	/* string version of from person */
221 	char		*e_returnpath;	/* string version of return path */
222 	char		**e_fromdomain;	/* the domain part of the sender */
223 	ADDRESS		*e_sendqueue;	/* list of message recipients */
224 	ADDRESS		*e_errorqueue;	/* the queue for error responses */
225 	long		e_msgsize;	/* size of the message in bytes */
226 	int		e_nrcpts;	/* number of recipients */
227 	short		e_class;	/* msg class (priority, junk, etc.) */
228 	short		e_flags;	/* flags, see below */
229 	short		e_hopcount;	/* number of times processed */
230 	int		(*e_puthdr)();	/* function to put header of message */
231 	int		(*e_putbody)();	/* function to put body of message */
232 	struct envelope	*e_parent;	/* the message this one encloses */
233 	struct envelope *e_sibling;	/* the next envelope of interest */
234 	char		*e_df;		/* location of temp file */
235 	FILE		*e_dfp;		/* temporary file */
236 	char		*e_id;		/* code for this entry in queue */
237 	FILE		*e_xfp;		/* transcript file */
238 	FILE		*e_lockfp;	/* the lock file for this message */
239 	char		*e_message;	/* error message */
240 	char		*e_macro[128];	/* macro definitions */
241 };
242 
243 typedef struct envelope	ENVELOPE;
244 
245 /* values for e_flags */
246 #define EF_OLDSTYLE	000001		/* use spaces (not commas) in hdrs */
247 #define EF_INQUEUE	000002		/* this message is fully queued */
248 #define EF_TIMEOUT	000004		/* this message is too old */
249 #define EF_CLRQUEUE	000010		/* disk copy is no longer needed */
250 #define EF_SENDRECEIPT	000020		/* send a return receipt */
251 #define EF_FATALERRS	000040		/* fatal errors occured */
252 #define EF_KEEPQUEUE	000100		/* keep queue files always */
253 #define EF_RESPONSE	000200		/* this is an error or return receipt */
254 #define EF_RESENT	000400		/* this message is being forwarded */
255 
256 EXTERN ENVELOPE	*CurEnv;	/* envelope currently being processed */
257 /*
258 **  Message priority classes.
259 **
260 **	The message class is read directly from the Priority: header
261 **	field in the message.
262 **
263 **	CurEnv->e_msgpriority is the number of bytes in the message plus
264 **	the creation time (so that jobs ``tend'' to be ordered correctly),
265 **	adjusted by the message class, the number of recipients, and the
266 **	amount of time the message has been sitting around.  This number
267 **	is used to order the queue.  Higher values mean LOWER priority.
268 **
269 **	Each priority class point is worth WkClassFact priority points;
270 **	each recipient is worth WkRecipFact priority points.  Each time
271 **	we reprocess a message the priority is adjusted by WkTimeFact.
272 **	WkTimeFact should normally decrease the priority so that jobs
273 **	that have historically failed will be run later; thanks go to
274 **	Jay Lepreau at Utah for pointing out the error in my thinking.
275 **
276 **	The "class" is this number, unadjusted by the age or size of
277 **	this message.  Classes with negative representations will have
278 **	error messages thrown away if they are not local.
279 */
280 
281 struct priority
282 {
283 	char	*pri_name;	/* external name of priority */
284 	int	pri_val;	/* internal value for same */
285 };
286 
287 EXTERN struct priority	Priorities[MAXPRIORITIES];
288 EXTERN int		NumPriorities;	/* pointer into Priorities */
289 /*
290 **  Rewrite rules.
291 */
292 
293 struct rewrite
294 {
295 	char	**r_lhs;	/* pattern match */
296 	char	**r_rhs;	/* substitution value */
297 	struct rewrite	*r_next;/* next in chain */
298 };
299 
300 EXTERN struct rewrite	*RewriteRules[MAXRWSETS];
301 
302 /*
303 **  Special characters in rewriting rules.
304 **	These are used internally only.
305 **	The COND* rules are actually used in macros rather than in
306 **		rewriting rules, but are given here because they
307 **		cannot conflict.
308 */
309 
310 /* left hand side items */
311 # define MATCHZANY	'\020'	/* match zero or more tokens */
312 # define MATCHANY	'\021'	/* match one or more tokens */
313 # define MATCHONE	'\022'	/* match exactly one token */
314 # define MATCHCLASS	'\023'	/* match one token in a class */
315 # define MATCHNCLASS	'\024'	/* match anything not in class */
316 # define MATCHREPL	'\025'	/* replacement on RHS for above */
317 
318 /* right hand side items */
319 # define CANONNET	'\026'	/* canonical net, next token */
320 # define CANONHOST	'\027'	/* canonical host, next token */
321 # define CANONUSER	'\030'	/* canonical user, next N tokens */
322 # define CALLSUBR	'\031'	/* call another rewriting set */
323 
324 /* conditionals in macros */
325 # define CONDIF		'\032'	/* conditional if-then */
326 # define CONDELSE	'\033'	/* conditional else */
327 # define CONDFI		'\034'	/* conditional fi */
328 
329 /* bracket characters for host name lookup */
330 # define HOSTBEGIN	'\035'	/* hostname lookup begin */
331 # define HOSTEND	'\036'	/* hostname lookup end */
332 
333 /* bracket characters for generalized lookup */
334 # define LOOKUPBEGIN	'\005'	/* generalized lookup begin */
335 # define LOOKUPEND	'\006'	/* generalized lookup end */
336 
337 /* \001 is also reserved as the macro expansion character */
338 
339 /* external <==> internal mapping table */
340 struct metamac
341 {
342 	char	metaname;	/* external code (after $) */
343 	char	metaval;	/* internal code (as above) */
344 };
345 /*
346 **  Information about currently open connections to mailers, or to
347 **  hosts that we have looked up recently.
348 */
349 
350 # define MCI	struct mailer_con_info
351 
352 MCI
353 {
354 	short		mci_flags;	/* flag bits, see below */
355 	short		mci_errno;	/* error number on last connection */
356 	short		mci_exitstat;	/* exit status from last connection */
357 	short		mci_state;	/* SMTP state */
358 	FILE		*mci_in;	/* input side of connection */
359 	FILE		*mci_out;	/* output side of connection */
360 	int		mci_pid;	/* process id of subordinate proc */
361 	char		*mci_phase;	/* SMTP phase string */
362 	struct mailer	*mci_mailer;	/* ptr to the mailer for this conn */
363 	char		*mci_host;	/* host name */
364 	time_t		mci_lastuse;	/* last usage time */
365 };
366 
367 
368 /* flag bits */
369 #define MCIF_VALID	00001		/* this entry is valid */
370 #define MCIF_TEMP	00002		/* don't cache this connection */
371 #define MCIF_CACHED	00004		/* currently in open cache */
372 
373 /* states */
374 #define MCIS_CLOSED	0		/* no traffic on this connection */
375 #define MCIS_OPENING	1		/* sending initial protocol */
376 #define MCIS_OPEN	2		/* open, initial protocol sent */
377 #define MCIS_ACTIVE	3		/* message being sent */
378 #define MCIS_QUITING	4		/* running quit protocol */
379 #define MCIS_SSD	5		/* service shutting down */
380 #define MCIS_ERROR	6		/* I/O error on connection */
381 /*
382 **  Mapping functions
383 **
384 **	These allow arbitrary mappings in the config file.  The idea
385 **	(albeit not the implementation) comes from IDA sendmail.
386 */
387 
388 
389 /*
390 **  The class of a map -- essentially the functions to call
391 */
392 
393 # define MAPCLASS	struct _mapclass
394 
395 MAPCLASS
396 {
397 	bool	(*map_init)();		/* initialization function */
398 	char	*(*map_lookup)();	/* lookup function */
399 };
400 
401 
402 /*
403 **  An actual map.
404 */
405 
406 # define MAP		struct _map
407 
408 MAP
409 {
410 	MAPCLASS	*map_class;	/* the class of this map */
411 	int		map_flags;	/* flags, see below */
412 	char		*map_file;	/* the (nominal) filename */
413 	void		*map_db;	/* the open database ptr */
414 	char		*map_app;	/* to append to successful matches */
415 };
416 
417 /* bit values for map_flags */
418 # define MF_VALID	00001		/* this entry is valid */
419 # define MF_INCLNULL	00002		/* include null byte in key */
420 # define MF_OPTIONAL	00004		/* don't complain if map not found */
421 # define MF_FOLDCASE	00010		/* fold case in keys */
422 /*
423 **  Symbol table definitions
424 */
425 
426 struct symtab
427 {
428 	char		*s_name;	/* name to be entered */
429 	char		s_type;		/* general type (see below) */
430 	struct symtab	*s_next;	/* pointer to next in chain */
431 	union
432 	{
433 		BITMAP		sv_class;	/* bit-map of word classes */
434 		ADDRESS		*sv_addr;	/* pointer to address header */
435 		MAILER		*sv_mailer;	/* pointer to mailer */
436 		char		*sv_alias;	/* alias */
437 		MAPCLASS	sv_mapclass;	/* mapping function class */
438 		MAP		sv_map;		/* mapping function */
439 		MCI		sv_mci;		/* mailer connection info */
440 	}	s_value;
441 };
442 
443 typedef struct symtab	STAB;
444 
445 /* symbol types */
446 # define ST_UNDEF	0	/* undefined type */
447 # define ST_CLASS	1	/* class map */
448 # define ST_ADDRESS	2	/* an address in parsed format */
449 # define ST_MAILER	3	/* a mailer header */
450 # define ST_ALIAS	4	/* an alias */
451 # define ST_MAPCLASS	5	/* mapping function class */
452 # define ST_MAP		6	/* mapping function */
453 # define ST_MCI		16	/* mailer connection info (offset) */
454 
455 # define s_class	s_value.sv_class
456 # define s_address	s_value.sv_addr
457 # define s_mailer	s_value.sv_mailer
458 # define s_alias	s_value.sv_alias
459 # define s_mci		s_value.sv_mci
460 # define s_mapclass	s_value.sv_mapclass
461 # define s_map		s_value.sv_map
462 
463 extern STAB	*stab();
464 
465 /* opcodes to stab */
466 # define ST_FIND	0	/* find entry */
467 # define ST_ENTER	1	/* enter if not there */
468 /*
469 **  STRUCT EVENT -- event queue.
470 **
471 **	Maintained in sorted order.
472 **
473 **	We store the pid of the process that set this event to insure
474 **	that when we fork we will not take events intended for the parent.
475 */
476 
477 struct event
478 {
479 	time_t		ev_time;	/* time of the function call */
480 	int		(*ev_func)();	/* function to call */
481 	int		ev_arg;		/* argument to ev_func */
482 	int		ev_pid;		/* pid that set this event */
483 	struct event	*ev_link;	/* link to next item */
484 };
485 
486 typedef struct event	EVENT;
487 
488 EXTERN EVENT	*EventQueue;		/* head of event queue */
489 /*
490 **  Operation, send, and error modes
491 **
492 **	The operation mode describes the basic operation of sendmail.
493 **	This can be set from the command line, and is "send mail" by
494 **	default.
495 **
496 **	The send mode tells how to send mail.  It can be set in the
497 **	configuration file.  It's setting determines how quickly the
498 **	mail will be delivered versus the load on your system.  If the
499 **	-v (verbose) flag is given, it will be forced to SM_DELIVER
500 **	mode.
501 **
502 **	The error mode tells how to return errors.
503 */
504 
505 EXTERN char	OpMode;		/* operation mode, see below */
506 
507 #define MD_DELIVER	'm'		/* be a mail sender */
508 #define MD_SMTP		's'		/* run SMTP on standard input */
509 #define MD_DAEMON	'd'		/* run as a daemon */
510 #define MD_VERIFY	'v'		/* verify: don't collect or deliver */
511 #define MD_TEST		't'		/* test mode: resolve addrs only */
512 #define MD_INITALIAS	'i'		/* initialize alias database */
513 #define MD_PRINT	'p'		/* print the queue */
514 #define MD_FREEZE	'z'		/* freeze the configuration file */
515 
516 
517 EXTERN char	SendMode;	/* send mode, see below */
518 
519 #define SM_DELIVER	'i'		/* interactive delivery */
520 #define SM_QUICKD	'j'		/* deliver w/o queueing */
521 #define SM_FORK		'b'		/* deliver in background */
522 #define SM_QUEUE	'q'		/* queue, don't deliver */
523 #define SM_VERIFY	'v'		/* verify only (used internally) */
524 
525 /* used only as a parameter to sendall */
526 #define SM_DEFAULT	'\0'		/* unspecified, use SendMode */
527 
528 
529 EXTERN char	ErrorMode;	/* error mode, see below */
530 
531 #define EM_PRINT	'p'		/* print errors */
532 #define EM_MAIL		'm'		/* mail back errors */
533 #define EM_WRITE	'w'		/* write back errors */
534 #define EM_BERKNET	'e'		/* special berknet processing */
535 #define EM_QUIET	'q'		/* don't print messages (stat only) */
536 
537 /* offset used to issure that the error messages for name server error
538  * codes are unique.
539  */
540 #define	MAX_ERRNO	100
541 /*
542 **  Global variables.
543 */
544 
545 EXTERN bool	FromFlag;	/* if set, "From" person is explicit */
546 EXTERN bool	NoAlias;	/* if set, don't do any aliasing */
547 EXTERN bool	ForceMail;	/* if set, mail even if already got a copy */
548 EXTERN bool	MeToo;		/* send to the sender also */
549 EXTERN bool	IgnrDot;	/* don't let dot end messages */
550 EXTERN bool	SaveFrom;	/* save leading "From" lines */
551 EXTERN bool	Verbose;	/* set if blow-by-blow desired */
552 EXTERN bool	GrabTo;		/* if set, get recipients from msg */
553 EXTERN bool	NoReturn;	/* don't return letter to sender */
554 EXTERN bool	SuprErrs;	/* set if we are suppressing errors */
555 EXTERN bool	QueueRun;	/* currently running message from the queue */
556 EXTERN bool	HoldErrs;	/* only output errors to transcript */
557 EXTERN bool	NoConnect;	/* don't connect to non-local mailers */
558 EXTERN bool	SuperSafe;	/* be extra careful, even if expensive */
559 EXTERN bool	ForkQueueRuns;	/* fork for each job when running the queue */
560 EXTERN bool	AutoRebuild;	/* auto-rebuild the alias database as needed */
561 EXTERN bool	CheckAliases;	/* parse addresses during newaliases */
562 EXTERN bool	UseNameServer;	/* use internet domain name server */
563 EXTERN bool	EightBit;	/* try to preserve 8-bit data */
564 EXTERN int	SafeAlias;	/* minutes to wait until @:@ in alias file */
565 EXTERN time_t	TimeOut;	/* time until timeout */
566 EXTERN FILE	*InChannel;	/* input connection */
567 EXTERN FILE	*OutChannel;	/* output connection */
568 EXTERN uid_t	RealUid;	/* when Daemon, real uid of caller */
569 EXTERN gid_t	RealGid;	/* when Daemon, real gid of caller */
570 EXTERN uid_t	DefUid;		/* default uid to run as */
571 EXTERN gid_t	DefGid;		/* default gid to run as */
572 EXTERN char	*DefUser;	/* default user to run as (from DefUid) */
573 EXTERN int	OldUmask;	/* umask when sendmail starts up */
574 EXTERN int	Errors;		/* set if errors (local to single pass) */
575 EXTERN int	ExitStat;	/* exit status code */
576 EXTERN int	AliasLevel;	/* depth of aliasing */
577 EXTERN int	MotherPid;	/* proc id of parent process */
578 EXTERN int	LineNumber;	/* line number in current input */
579 EXTERN time_t	ReadTimeout;	/* timeout on reads */
580 EXTERN int	LogLevel;	/* level of logging to perform */
581 EXTERN int	FileMode;	/* mode on files */
582 EXTERN int	QueueLA;	/* load average starting forced queueing */
583 EXTERN int	RefuseLA;	/* load average refusing connections are */
584 EXTERN int	CurrentLA;	/* current load average */
585 EXTERN int	QueueFactor;	/* slope of queue function */
586 EXTERN time_t	QueueIntvl;	/* intervals between running the queue */
587 EXTERN char	*AliasFile;	/* location of alias file */
588 EXTERN char	*HelpFile;	/* location of SMTP help file */
589 EXTERN char	*ErrMsgFile;	/* file to prepend to all error messages */
590 EXTERN char	*StatFile;	/* location of statistics summary */
591 EXTERN char	*QueueDir;	/* location of queue directory */
592 EXTERN char	*FileName;	/* name to print on error messages */
593 EXTERN char	*SmtpPhase;	/* current phase in SMTP processing */
594 EXTERN char	*MyHostName;	/* name of this host for SMTP messages */
595 EXTERN char	*RealHostName;	/* name of host we are talking to */
596 EXTERN struct	sockaddr_in RealHostAddr;/* address of host we are talking to */
597 EXTERN char	*CurHostName;	/* current host we are dealing with */
598 EXTERN jmp_buf	TopFrame;	/* branch-to-top-of-loop-on-error frame */
599 EXTERN bool	QuickAbort;	/*  .... but only if we want a quick abort */
600 EXTERN bool	LogUsrErrs;	/* syslog user errors (e.g., SMTP RCPT cmd) */
601 extern char	*ConfFile;	/* location of configuration file [conf.c] */
602 extern char	*FreezeFile;	/* location of frozen memory image [conf.c] */
603 extern char	Arpa_Info[];	/* the reply code for Arpanet info [conf.c] */
604 extern ADDRESS	NullAddress;	/* a null (template) address [main.c] */
605 EXTERN char	SpaceSub;	/* substitution for <lwsp> */
606 EXTERN int	WkClassFact;	/* multiplier for message class -> priority */
607 EXTERN int	WkRecipFact;	/* multiplier for # of recipients -> priority */
608 EXTERN int	WkTimeFact;	/* priority offset each time this job is run */
609 EXTERN char	*PostMasterCopy;	/* address to get errs cc's */
610 EXTERN char	*TrustedUsers[MAXTRUST+1];	/* list of trusted users */
611 EXTERN char	*UserEnviron[MAXUSERENVIRON+1];	/* saved user environment */
612 EXTERN int	CheckpointInterval;	/* queue file checkpoint interval */
613 EXTERN bool	NoWildcardMX;	/* we don't have wildcard MX records */
614 EXTERN char	*UdbSpec;	/* user database source spec [udbexpand.c] */
615 EXTERN int	MaxHopCount;	/* number of hops until we give an error */
616 EXTERN int	ConfigLevel;	/* config file level -- what does .cf expect? */
617 EXTERN char	*TimeZoneSpec;	/* override time zone specification */
618 EXTERN bool	MatchGecos;	/* look for user names in gecos field */
619 EXTERN int	MaxMciCache;	/* maximum entries in MCI cache */
620 EXTERN time_t	MciCacheTimeout;	/* maximum idle time on connections */
621 /*
622 **  Trace information
623 */
624 
625 /* trace vector and macros for debugging flags */
626 EXTERN u_char	tTdvect[100];
627 # define tTd(flag, level)	(tTdvect[flag] >= level)
628 # define tTdlevel(flag)		(tTdvect[flag])
629 /*
630 **  Miscellaneous information.
631 */
632 
633 
634 
635 /*
636 **  Some in-line functions
637 */
638 
639 /* set exit status */
640 #define setstat(s)	{ \
641 				if (ExitStat == EX_OK || ExitStat == EX_TEMPFAIL) \
642 					ExitStat = s; \
643 			}
644 
645 /* make a copy of a string */
646 #define newstr(s)	strcpy(xalloc(strlen(s) + 1), s)
647 
648 #define STRUCTCOPY(s, d)	d = s
649 
650 
651 /*
652 **  Declarations of useful functions
653 */
654 
655 extern ADDRESS	*parseaddr();
656 extern char	*xalloc();
657 extern bool	sameaddr();
658 extern FILE	*dfopen();
659 extern EVENT	*setevent();
660 extern char	*sfgets();
661 extern char	*queuename();
662 extern time_t	curtime();
663