home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.sbin / sendmail / src / sendmail.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-20  |  21.3 KB  |  605 lines

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