convert to new DSN draft
[unix-history] / usr / src / usr.sbin / sendmail / src / sendmail.h
index 3e1d3d0..b81f0a0 100644 (file)
@@ -5,7 +5,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)sendmail.h  8.6 (Berkeley) %G%
+ *     @(#)sendmail.h  8.74 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -15,7 +15,7 @@
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
-static char SmailSccsId[] =    "@(#)sendmail.h 8.            %G%";
+static char SmailSccsId[] =    "@(#)sendmail.h 8.74            %G%";
 # endif
 # else /*  _DEFINE */
 # define EXTERN extern
 # endif
 # else /*  _DEFINE */
 # define EXTERN extern
@@ -43,6 +43,9 @@ static char SmailSccsId[] =   "@(#)sendmail.h 8.6             %G%";
 # ifdef DAEMON
 # include <sys/socket.h>
 # endif
 # ifdef DAEMON
 # include <sys/socket.h>
 # endif
+# ifdef NETUNIX
+# include <sys/un.h>
+# endif
 # ifdef NETINET
 # include <netinet/in.h>
 # endif
 # ifdef NETINET
 # include <netinet/in.h>
 # endif
@@ -63,10 +66,10 @@ static char SmailSccsId[] = "@(#)sendmail.h 8.6             %G%";
 **  Data structure for bit maps.
 **
 **     Each bit in this map can be referenced by an ascii character.
 **  Data structure for bit maps.
 **
 **     Each bit in this map can be referenced by an ascii character.
-**     This is 128 possible bits, or 12 8-bit bytes.
+**     This is 256 possible bits, or 32 8-bit bytes.
 */
 
 */
 
-#define BITMAPBYTES    16      /* number of bytes in a bit map */
+#define BITMAPBYTES    32      /* number of bytes in a bit map */
 #define BYTEBITS       8       /* number of bits in a byte */
 
 /* internal macros */
 #define BYTEBITS       8       /* number of bits in a byte */
 
 /* internal macros */
@@ -109,13 +112,12 @@ struct address
        char            *q_ruser;       /* real user name, or NULL if q_user */
        char            *q_host;        /* host name */
        struct mailer   *q_mailer;      /* mailer to use */
        char            *q_ruser;       /* real user name, or NULL if q_user */
        char            *q_host;        /* host name */
        struct mailer   *q_mailer;      /* mailer to use */
-       u_short         q_flags;        /* status flags, see below */
+       u_long          q_flags;        /* status flags, see below */
        uid_t           q_uid;          /* user-id of receiver (if known) */
        gid_t           q_gid;          /* group-id of receiver (if known) */
        char            *q_home;        /* home dir (local mailer only) */
        char            *q_fullname;    /* full name if known */
        char            *q_fullname;    /* full name of this person */
        uid_t           q_uid;          /* user-id of receiver (if known) */
        gid_t           q_gid;          /* group-id of receiver (if known) */
        char            *q_home;        /* home dir (local mailer only) */
        char            *q_fullname;    /* full name if known */
        char            *q_fullname;    /* full name of this person */
-       time_t          q_timeout;      /* timeout for this address */
        struct address  *q_next;        /* chain */
        struct address  *q_alias;       /* parent in alias tree */
        struct address  *q_sibling;     /* sibling in alias tree */
        struct address  *q_next;        /* chain */
        struct address  *q_alias;       /* parent in alias tree */
        struct address  *q_sibling;     /* sibling in alias tree */
@@ -124,16 +126,26 @@ struct address
 
 typedef struct address ADDRESS;
 
 
 typedef struct address ADDRESS;
 
-# define QDONTSEND     000001  /* don't send to this address */
-# define QBADADDR      000002  /* this address is verified bad */
-# define QGOODUID      000004  /* the q_uid q_gid fields are good */
-# define QPRIMARY      000010  /* set from argv */
-# define QQUEUEUP      000020  /* queue for later transmission */
-# define QSENT         000040  /* has been successfully delivered */
-# define QNOTREMOTE    000100  /* not an address for remote forwarding */
-# define QSELFREF      000200  /* this address references itself */
-# define QVERIFIED     000400  /* verified, but not expanded */
-# define QREPORT       001000  /* report this address in return message */
+# define QDONTSEND     0x00000001      /* don't send to this address */
+# define QBADADDR      0x00000002      /* this address is verified bad */
+# define QGOODUID      0x00000004      /* the q_uid q_gid fields are good */
+# define QPRIMARY      0x00000008      /* set from argv */
+# define QQUEUEUP      0x00000010      /* queue for later transmission */
+# define QSENT         0x00000020      /* has been successfully delivered */
+# define QNOTREMOTE    0x00000040      /* address not for remote forwarding */
+# define QSELFREF      0x00000080      /* this address references itself */
+# define QVERIFIED     0x00000100      /* verified, but not expanded */
+# define QREPORT       0x00000200      /* report this addr in return message */
+# define QBOGUSSHELL   0x00000400      /* user has no valid shell listed */
+# define QUNSAFEADDR   0x00000800      /* address aquired via unsafe path */
+# define QPINGONSUCCESS        0x00001000      /* give return on successful delivery */
+# define QPINGONFAILURE        0x00002000      /* give return on failure */
+# define QPINGONDELAY  0x00004000      /* give return on message delay */
+# define QHAS_RET_PARAM        0x00008000      /* RCPT command had RET argument */
+# define QRET_HDRS     0x00010000      /* don't return message body */
+# define QRELAYED      0x00020000      /* relayed to non-DSN aware mailer */
+
+# define NULLADDR      ((ADDRESS *) NULL)
 # define QPSEUDO       000040  /* only on the list for verification */
 \f/*
 **  Mailer definition structure.
 # define QPSEUDO       000040  /* only on the list for verification */
 \f/*
 **  Mailer definition structure.
@@ -162,15 +174,20 @@ struct mailer
        long    m_maxsize;      /* size limit on message to this mailer */
        int     m_linelimit;    /* max # characters per line */
        char    *m_execdir;     /* directory to chdir to before execv */
        long    m_maxsize;      /* size limit on message to this mailer */
        int     m_linelimit;    /* max # characters per line */
        char    *m_execdir;     /* directory to chdir to before execv */
+       uid_t   m_uid;          /* UID to run as */
+       gid_t   m_gid;          /* GID to run as */
+       char    *m_defcharset;  /* default character set */
 };
 
 typedef struct mailer  MAILER;
 
 /* bits for m_flags */
 # define M_ESMTP       'a'     /* run Extended SMTP protocol */
 };
 
 typedef struct mailer  MAILER;
 
 /* bits for m_flags */
 # define M_ESMTP       'a'     /* run Extended SMTP protocol */
+# define M_ALIASABLE   'A'     /* user can be LHS of an alias */
 # define M_BLANKEND    'b'     /* ensure blank line at end of message */
 # define M_NOCOMMENT   'c'     /* don't include comment part of address */
 # define M_CANONICAL   'C'     /* make addresses canonical "u@dom" */
 # define M_BLANKEND    'b'     /* ensure blank line at end of message */
 # define M_NOCOMMENT   'c'     /* don't include comment part of address */
 # define M_CANONICAL   'C'     /* make addresses canonical "u@dom" */
+# define M_NOBRACKET   'd'     /* never angle bracket envelope route-addrs */
                /*      'D'     /* CF: include Date: */
 # define M_EXPENSIVE   'e'     /* it costs to use this mailer.... */
 # define M_ESCFROM     'E'     /* escape From lines to >From */
                /*      'D'     /* CF: include Date: */
 # define M_EXPENSIVE   'e'     /* it costs to use this mailer.... */
 # define M_ESCFROM     'E'     /* escape From lines to >From */
@@ -178,26 +195,36 @@ typedef struct mailer     MAILER;
                /*      'F'     /* CF: include From: or Resent-From: */
 # define M_NO_NULL_FROM        'g'     /* sender of errors should be $g */
 # define M_HST_UPPER   'h'     /* preserve host case distinction */
                /*      'F'     /* CF: include From: or Resent-From: */
 # define M_NO_NULL_FROM        'g'     /* sender of errors should be $g */
 # define M_HST_UPPER   'h'     /* preserve host case distinction */
-               /*      'H'     /* UIUC: MAIL11V3: preview headers */
+# define M_PREHEAD     'H'     /* MAIL11V3: preview headers */
+# define M_UDBENVELOPE 'i'     /* do udbsender rewriting on envelope */
 # define M_INTERNAL    'I'     /* SMTP to another sendmail site */
 # define M_INTERNAL    'I'     /* SMTP to another sendmail site */
+# define M_NOLOOPCHECK 'k'     /* don't check for loops in HELO command */
 # define M_LOCALMAILER 'l'     /* delivery is to this host */
 # define M_LIMITS      'L'     /* must enforce SMTP line limits */
 # define M_MUSER       'm'     /* can handle multiple users at once */
                /*      'M'     /* CF: include Message-Id: */
 # define M_NHDR                'n'     /* don't insert From line */
 # define M_LOCALMAILER 'l'     /* delivery is to this host */
 # define M_LIMITS      'L'     /* must enforce SMTP line limits */
 # define M_MUSER       'm'     /* can handle multiple users at once */
                /*      'M'     /* CF: include Message-Id: */
 # define M_NHDR                'n'     /* don't insert From line */
-               /*      'N'     /* UIUC: MAIL11V3: DATA returns multi-status */
+# define M_MANYSTATUS  'N'     /* MAIL11V3: DATA returns multi-status */
+# define M_RUNASRCPT   'o'     /* always run mailer as recipient */
 # define M_FROMPATH    'p'     /* use reverse-path in MAIL FROM: */
                /*      'P'     /* CF: include Return-Path: */
 # define M_ROPT                'r'     /* mailer takes picky -r flag */
 # define M_SECURE_PORT 'R'     /* try to send on a reserved TCP port */
 # define M_STRIPQ      's'     /* strip quote chars from user/host */
 # define M_FROMPATH    'p'     /* use reverse-path in MAIL FROM: */
                /*      'P'     /* CF: include Return-Path: */
 # define M_ROPT                'r'     /* mailer takes picky -r flag */
 # define M_SECURE_PORT 'R'     /* try to send on a reserved TCP port */
 # define M_STRIPQ      's'     /* strip quote chars from user/host */
-# define M_RESTR       'S'     /* must be daemon to execute */
+# define M_SPECIFIC_UID        'S'     /* run as specific uid/gid */
 # define M_USR_UPPER   'u'     /* preserve user case distinction */
 # define M_UGLYUUCP    'U'     /* this wants an ugly UUCP from line */
                /*      'V'     /* UIUC: !-relativize all addresses */
 # define M_USR_UPPER   'u'     /* preserve user case distinction */
 # define M_UGLYUUCP    'U'     /* this wants an ugly UUCP from line */
                /*      'V'     /* UIUC: !-relativize all addresses */
+# define M_HASPWENT    'w'     /* check for /etc/passwd entry */
                /*      'x'     /* CF: include Full-Name: */
 # define M_XDOT                'X'     /* use hidden-dot algorithm */
                /*      'x'     /* CF: include Full-Name: */
 # define M_XDOT                'X'     /* use hidden-dot algorithm */
+# define M_TRYRULESET5 '5'     /* use ruleset 5 after local aliasing */
 # define M_7BITS       '7'     /* use 7-bit path */
 # define M_7BITS       '7'     /* use 7-bit path */
+# define M_8BITS       '8'     /* force "just send 8" behaviour */
+# define M_CHECKINCLUDE        ':'     /* check for :include: files */
+# define M_CHECKPROG   '|'     /* check for |program addresses */
+# define M_CHECKFILE   '/'     /* check for /file addresses */
+# define M_CHECKUDB    '@'     /* user can be user database key */
 
 EXTERN MAILER  *Mailer[MAXMAILERS+1];
 
 
 EXTERN MAILER  *Mailer[MAXMAILERS+1];
 
@@ -236,18 +263,67 @@ struct hdrinfo
 extern struct hdrinfo  HdrInfo[];
 
 /* bits for h_flags and hi_flags */
 extern struct hdrinfo  HdrInfo[];
 
 /* bits for h_flags and hi_flags */
-# define H_EOH         00001   /* this field terminates header */
-# define H_RCPT                00002   /* contains recipient addresses */
-# define H_DEFAULT     00004   /* if another value is found, drop this */
-# define H_RESENT      00010   /* this address is a "Resent-..." address */
-# define H_CHECK       00020   /* check h_mflags against m_flags */
-# define H_ACHECK      00040   /* ditto, but always (not just default) */
-# define H_FORCE       00100   /* force this field, even if default */
-# define H_TRACE       00200   /* this field contains trace information */
-# define H_FROM                00400   /* this is a from-type field */
-# define H_VALID       01000   /* this field has a validated value */
-# define H_RECEIPTTO   02000   /* this field has return receipt info */
-# define H_ERRORSTO    04000   /* this field has error address info */
+# define H_EOH         0x0001  /* this field terminates header */
+# define H_RCPT                0x0002  /* contains recipient addresses */
+# define H_DEFAULT     0x0004  /* if another value is found, drop this */
+# define H_RESENT      0x0008  /* this address is a "Resent-..." address */
+# define H_CHECK       0x0010  /* check h_mflags against m_flags */
+# define H_ACHECK      0x0020  /* ditto, but always (not just default) */
+# define H_FORCE       0x0040  /* force this field, even if default */
+# define H_TRACE       0x0080  /* this field contains trace information */
+# define H_FROM                0x0100  /* this is a from-type field */
+# define H_VALID       0x0200  /* this field has a validated value */
+# define H_RECEIPTTO   0x0400  /* this field has return receipt info */
+# define H_ERRORSTO    0x0800  /* this field has error address info */
+# define H_CTE         0x1000  /* this field is a content-transfer-encoding */
+# define H_CTYPE       0x2000  /* this is a content-type field */
+\f/*
+**  Information about currently open connections to mailers, or to
+**  hosts that we have looked up recently.
+*/
+
+# define MCI           struct mailer_con_info
+
+MCI
+{
+       short           mci_flags;      /* flag bits, see below */
+       short           mci_errno;      /* error number on last connection */
+       short           mci_herrno;     /* h_errno from last DNS lookup */
+       short           mci_exitstat;   /* exit status from last connection */
+       short           mci_state;      /* SMTP state */
+       long            mci_maxsize;    /* max size this server will accept */
+       FILE            *mci_in;        /* input side of connection */
+       FILE            *mci_out;       /* output side of connection */
+       int             mci_pid;        /* process id of subordinate proc */
+       char            *mci_phase;     /* SMTP phase string */
+       struct mailer   *mci_mailer;    /* ptr to the mailer for this conn */
+       char            *mci_host;      /* host name */
+       time_t          mci_lastuse;    /* last usage time */
+};
+
+
+/* flag bits */
+#define MCIF_VALID     0x0001          /* this entry is valid */
+#define MCIF_TEMP      0x0002          /* don't cache this connection */
+#define MCIF_CACHED    0x0004          /* currently in open cache */
+#define MCIF_ESMTP     0x0008          /* this host speaks ESMTP */
+#define MCIF_EXPN      0x0010          /* EXPN command supported */
+#define MCIF_SIZE      0x0020          /* SIZE option supported */
+#define MCIF_8BITMIME  0x0040          /* BODY=8BITMIME supported */
+#define MCIF_7BIT      0x0080          /* strip this message to 7 bits */
+#define MCIF_MULTSTAT  0x0100          /* MAIL11V3: handles MULT status */
+#define MCIF_INHEADER  0x0200          /* currently outputing header */
+#define MCIF_CVT8TO7   0x0400          /* convert from 8 to 7 bits */
+#define MCIF_DSN       0x0800          /* DSN extension supported */
+
+/* states */
+#define MCIS_CLOSED    0               /* no traffic on this connection */
+#define MCIS_OPENING   1               /* sending initial protocol */
+#define MCIS_OPEN      2               /* open, initial protocol sent */
+#define MCIS_ACTIVE    3               /* message being sent */
+#define MCIS_QUITING   4               /* running quit protocol */
+#define MCIS_SSD       5               /* service shutting down */
+#define MCIS_ERROR     6               /* I/O error on connection */
 \f/*
 **  Envelope structure.
 **     This structure defines the message itself.  There is usually
 \f/*
 **  Envelope structure.
 **     This structure defines the message itself.  There is usually
@@ -273,16 +349,17 @@ ENVELOPE
        ADDRESS         *e_sendqueue;   /* list of message recipients */
        ADDRESS         *e_errorqueue;  /* the queue for error responses */
        long            e_msgsize;      /* size of the message in bytes */
        ADDRESS         *e_sendqueue;   /* list of message recipients */
        ADDRESS         *e_errorqueue;  /* the queue for error responses */
        long            e_msgsize;      /* size of the message in bytes */
+       long            e_flags;        /* flags, see below */
        int             e_nrcpts;       /* number of recipients */
        short           e_class;        /* msg class (priority, junk, etc.) */
        int             e_nrcpts;       /* number of recipients */
        short           e_class;        /* msg class (priority, junk, etc.) */
-       short           e_flags;        /* flags, see below */
        short           e_hopcount;     /* number of times processed */
        short           e_nsent;        /* number of sends since checkpoint */
        short           e_sendmode;     /* message send mode */
        short           e_errormode;    /* error return mode */
        short           e_hopcount;     /* number of times processed */
        short           e_nsent;        /* number of sends since checkpoint */
        short           e_sendmode;     /* message send mode */
        short           e_errormode;    /* error return mode */
-       int             (*e_puthdr)__P((FILE *, MAILER *, ENVELOPE *));
+       short           e_timeoutclass; /* message timeout class */
+       int             (*e_puthdr)__P((MCI *, HDR *, ENVELOPE *, int));
                                        /* function to put header of message */
                                        /* function to put header of message */
-       int             (*e_putbody)__P((FILE *, MAILER *, ENVELOPE *, char *));
+       int             (*e_putbody)__P((MCI *, ENVELOPE *, char *, int));
                                        /* function to put body of message */
        struct envelope *e_parent;      /* the message this one encloses */
        struct envelope *e_sibling;     /* the next envelope of interest */
                                        /* function to put body of message */
        struct envelope *e_parent;      /* the message this one encloses */
        struct envelope *e_sibling;     /* the next envelope of interest */
@@ -296,23 +373,37 @@ ENVELOPE
        char            *e_message;     /* error message */
        char            *e_statmsg;     /* stat msg (changes per delivery) */
        char            *e_msgboundary; /* MIME-style message part boundary */
        char            *e_message;     /* error message */
        char            *e_statmsg;     /* stat msg (changes per delivery) */
        char            *e_msgboundary; /* MIME-style message part boundary */
-       char            *e_macro[128];  /* macro definitions */
+       char            *e_origrcpt;    /* original recipient (one only) */
+       char            *e_envid;       /* envelope id from MAIL FROM: line */
+       char            *e_omts;        /* OMTS parameter from MAIL FROM: */
+       time_t          e_dtime;        /* time of last delivery attempt */
+       int             e_ntries;       /* number of delivery attempts */
+       dev_t           e_dfdev;        /* df file's device, for crash recov */
+       ino_t           e_dfino;        /* df file's ino, for crash recovery */
+       char            *e_macro[256];  /* macro definitions */
 };
 
 /* values for e_flags */
 };
 
 /* values for e_flags */
-#define EF_OLDSTYLE    000001          /* use spaces (not commas) in hdrs */
-#define EF_INQUEUE     000002          /* this message is fully queued */
-#define EF_CLRQUEUE    000010          /* disk copy is no longer needed */
-#define EF_SENDRECEIPT 000020          /* send a return receipt */
-#define EF_FATALERRS   000040          /* fatal errors occured */
-#define EF_KEEPQUEUE   000100          /* keep queue files always */
-#define EF_RESPONSE    000200          /* this is an error or return receipt */
-#define EF_RESENT      000400          /* this message is being forwarded */
-#define EF_VRFYONLY    001000          /* verify only (don't expand aliases) */
-#define EF_WARNING     002000          /* warning message has been sent */
-#define EF_QUEUERUN    004000          /* this envelope is from queue */
-#define EF_GLOBALERRS  010000          /* treat errors as global */
-#define EF_PM_NOTIFY   020000          /* send return mail to postmaster */
+#define EF_OLDSTYLE    0x0000001       /* use spaces (not commas) in hdrs */
+#define EF_INQUEUE     0x0000002       /* this message is fully queued */
+#define EF_NORETURN    0x0000004       /* don't return the message on error */
+#define EF_CLRQUEUE    0x0000008       /* disk copy is no longer needed */
+#define EF_SENDRECEIPT 0x0000010       /* send a return receipt */
+#define EF_FATALERRS   0x0000020       /* fatal errors occured */
+#define EF_KEEPQUEUE   0x0000040       /* keep queue files always */
+#define EF_RESPONSE    0x0000080       /* this is an error or return receipt */
+#define EF_RESENT      0x0000100       /* this message is being forwarded */
+#define EF_VRFYONLY    0x0000200       /* verify only (don't expand aliases) */
+#define EF_WARNING     0x0000400       /* warning message has been sent */
+#define EF_QUEUERUN    0x0000800       /* this envelope is from queue */
+#define EF_GLOBALERRS  0x0001000       /* treat errors as global */
+#define EF_PM_NOTIFY   0x0002000       /* send return mail to postmaster */
+#define EF_METOO       0x0004000       /* send to me too */
+#define EF_LOGSENDER   0x0008000       /* need to log the sender */
+#define EF_NORECEIPT   0x0010000       /* suppress all return-receipts */
+#define EF_HAS8BIT     0x0020000       /* at least one 8-bit char in body */
+#define EF_NL_NOT_EOL  0x0040000       /* don't accept raw NL as EOLine */
+#define EF_CRLF_NOT_EOL        0x0080000       /* don't accept CR-LF as EOLine */
 
 EXTERN ENVELOPE        *CurEnv;        /* envelope currently being processed */
 \f/*
 
 EXTERN ENVELOPE        *CurEnv;        /* envelope currently being processed */
 \f/*
@@ -411,48 +502,6 @@ struct metamac
        u_char  metaval;        /* internal code (as above) */
 };
 \f/*
        u_char  metaval;        /* internal code (as above) */
 };
 \f/*
-**  Information about currently open connections to mailers, or to
-**  hosts that we have looked up recently.
-*/
-
-# define MCI   struct mailer_con_info
-
-MCI
-{
-       short           mci_flags;      /* flag bits, see below */
-       short           mci_errno;      /* error number on last connection */
-       short           mci_herrno;     /* h_errno from last DNS lookup */
-       short           mci_exitstat;   /* exit status from last connection */
-       short           mci_state;      /* SMTP state */
-       long            mci_maxsize;    /* max size this server will accept */
-       FILE            *mci_in;        /* input side of connection */
-       FILE            *mci_out;       /* output side of connection */
-       int             mci_pid;        /* process id of subordinate proc */
-       char            *mci_phase;     /* SMTP phase string */
-       struct mailer   *mci_mailer;    /* ptr to the mailer for this conn */
-       char            *mci_host;      /* host name */
-       time_t          mci_lastuse;    /* last usage time */
-};
-
-
-/* flag bits */
-#define MCIF_VALID     000001          /* this entry is valid */
-#define MCIF_TEMP      000002          /* don't cache this connection */
-#define MCIF_CACHED    000004          /* currently in open cache */
-#define MCIF_ESMTP     000010          /* this host speaks ESMTP */
-#define MCIF_EXPN      000020          /* EXPN command supported */
-#define MCIF_SIZE      000040          /* SIZE option supported */
-#define MCIF_8BITMIME  000100          /* BODY=8BITMIME supported */
-
-/* states */
-#define MCIS_CLOSED    0               /* no traffic on this connection */
-#define MCIS_OPENING   1               /* sending initial protocol */
-#define MCIS_OPEN      2               /* open, initial protocol sent */
-#define MCIS_ACTIVE    3               /* message being sent */
-#define MCIS_QUITING   4               /* running quit protocol */
-#define MCIS_SSD       5               /* service shutting down */
-#define MCIS_ERROR     6               /* I/O error on connection */
-\f/*
 **  Name canonification short circuit.
 **
 **     If the name server for a host is down, the process of trying to
 **  Name canonification short circuit.
 **
 **     If the name server for a host is down, the process of trying to
@@ -484,6 +533,7 @@ NAMECANON
 
 # define MAPCLASS      struct _mapclass
 # define MAP           struct _map
 
 # define MAPCLASS      struct _mapclass
 # define MAP           struct _map
+# define MAXMAPACTIONS 3               /* size of map_actions array */
 
 
 /*
 
 
 /*
@@ -496,11 +546,19 @@ MAP
        char            *map_mname;     /* name of this map */
        int             map_mflags;     /* flags, see below */
        char            *map_file;      /* the (nominal) filename */
        char            *map_mname;     /* name of this map */
        int             map_mflags;     /* flags, see below */
        char            *map_file;      /* the (nominal) filename */
-       void            *map_db1;       /* the open database ptr */
-       void            *map_db2;       /* an "extra" database pointer */
+       ARBPTR_T        map_db1;        /* the open database ptr */
+       ARBPTR_T        map_db2;        /* an "extra" database pointer */
+       char            *map_keycolnm;  /* key column name */
+       char            *map_valcolnm;  /* value column name */
+       u_char          map_keycolno;   /* key column number */
+       u_char          map_valcolno;   /* value column number */
+       char            map_coldelim;   /* column delimiter */
        char            *map_app;       /* to append to successful matches */
        char            *map_domain;    /* the (nominal) NIS domain */
        char            *map_rebuild;   /* program to run to do auto-rebuild */
        char            *map_app;       /* to append to successful matches */
        char            *map_domain;    /* the (nominal) NIS domain */
        char            *map_rebuild;   /* program to run to do auto-rebuild */
+       time_t          map_mtime;      /* last database modification time */
+       MAP             *map_stack[MAXMAPSTACK];   /* list for stacked maps */
+       short           map_return[MAXMAPACTIONS]; /* return bitmaps for stacked maps */
 };
 
 /* bit values for map_flags */
 };
 
 /* bit values for map_flags */
@@ -514,9 +572,16 @@ MAP
 # define MF_ALIAS      0x0080          /* this is an alias file */
 # define MF_TRY0NULL   0x0100          /* try with no null byte */
 # define MF_TRY1NULL   0x0200          /* try with the null byte */
 # define MF_ALIAS      0x0080          /* this is an alias file */
 # define MF_TRY0NULL   0x0100          /* try with no null byte */
 # define MF_TRY1NULL   0x0200          /* try with the null byte */
+# define MF_LOCKED     0x0400          /* this map is currently locked */
+# define MF_ALIASWAIT  0x0800          /* alias map in aliaswait state */
 # define MF_IMPL_HASH  0x1000          /* implicit: underlying hash database */
 # define MF_IMPL_NDBM  0x2000          /* implicit: underlying NDBM database */
 # define MF_IMPL_HASH  0x1000          /* implicit: underlying hash database */
 # define MF_IMPL_NDBM  0x2000          /* implicit: underlying NDBM database */
+# define MF_UNSAFEDB   0x4000          /* this map is world writable */
 
 
+/* indices for map_actions */
+# define MA_NOTFOUND   0               /* member map returned "not found" */
+# define MA_UNAVAIL    1               /* member map is not available */
+# define MA_TRYAGAIN   2               /* member map returns temp failure */
 
 /*
 **  The class of a map -- essentially the functions to call
 
 /*
 **  The class of a map -- essentially the functions to call
@@ -543,6 +608,7 @@ MAPCLASS
 #define MCF_ALIASOK    0x0001          /* can be used for aliases */
 #define MCF_ALIASONLY  0x0002          /* usable only for aliases */
 #define MCF_REBUILDABLE        0x0004          /* can rebuild alias files */
 #define MCF_ALIASOK    0x0001          /* can be used for aliases */
 #define MCF_ALIASONLY  0x0002          /* usable only for aliases */
 #define MCF_REBUILDABLE        0x0004          /* can rebuild alias files */
+#define MCF_OPTFILE    0x0008          /* file name is optional */
 \f/*
 **  Symbol table definitions
 */
 \f/*
 **  Symbol table definitions
 */
@@ -563,6 +629,7 @@ struct symtab
                char            *sv_hostsig;    /* host signature */
                MCI             sv_mci;         /* mailer connection info */
                NAMECANON       sv_namecanon;   /* canonical name cache */
                char            *sv_hostsig;    /* host signature */
                MCI             sv_mci;         /* mailer connection info */
                NAMECANON       sv_namecanon;   /* canonical name cache */
+               int             sv_macro;       /* macro name => id mapping */
        }       s_value;
 };
 
        }       s_value;
 };
 
@@ -578,6 +645,7 @@ typedef struct symtab       STAB;
 # define ST_MAP                6       /* mapping function */
 # define ST_HOSTSIG    7       /* host signature */
 # define ST_NAMECANON  8       /* cached canonical name */
 # define ST_MAP                6       /* mapping function */
 # define ST_HOSTSIG    7       /* host signature */
 # define ST_NAMECANON  8       /* cached canonical name */
+# define ST_MACRO      9       /* macro name to id mapping */
 # define ST_MCI                16      /* mailer connection info (offset) */
 
 # define s_class       s_value.sv_class
 # define ST_MCI                16      /* mailer connection info (offset) */
 
 # define s_class       s_value.sv_class
@@ -615,7 +683,7 @@ typedef struct event        EVENT;
 
 EXTERN EVENT   *EventQueue;            /* head of event queue */
 \f/*
 
 EXTERN EVENT   *EventQueue;            /* head of event queue */
 \f/*
-**  Operation, send, and error modes
+**  Operation, send, error, and MIME modes
 **
 **     The operation mode describes the basic operation of sendmail.
 **     This can be set from the command line, and is "send mail" by
 **
 **     The operation mode describes the basic operation of sendmail.
 **     This can be set from the command line, and is "send mail" by
@@ -634,6 +702,7 @@ EXTERN char OpMode;         /* operation mode, see below */
 
 #define MD_DELIVER     'm'             /* be a mail sender */
 #define MD_SMTP                's'             /* run SMTP on standard input */
 
 #define MD_DELIVER     'm'             /* be a mail sender */
 #define MD_SMTP                's'             /* run SMTP on standard input */
+#define MD_ARPAFTP     'a'             /* obsolete ARPANET mode (Grey Book) */
 #define MD_DAEMON      'd'             /* run as a daemon */
 #define MD_VERIFY      'v'             /* verify: don't collect or deliver */
 #define MD_TEST                't'             /* test mode: resolve addrs only */
 #define MD_DAEMON      'd'             /* run as a daemon */
 #define MD_VERIFY      'v'             /* verify: don't collect or deliver */
 #define MD_TEST                't'             /* test mode: resolve addrs only */
@@ -659,29 +728,36 @@ EXTERN char       OpMode;         /* operation mode, see below */
 #define EM_WRITE       'w'             /* write back errors */
 #define EM_BERKNET     'e'             /* special berknet processing */
 #define EM_QUIET       'q'             /* don't print messages (stat only) */
 #define EM_WRITE       'w'             /* write back errors */
 #define EM_BERKNET     'e'             /* special berknet processing */
 #define EM_QUIET       'q'             /* don't print messages (stat only) */
+
+
+/* MIME processing mode */
+EXTERN int     MimeMode;
+
+/* bit values for MimeMode */
+#define MM_CVTMIME     0x0001          /* convert 8 to 7 bit MIME */
+#define MM_PASS8BIT    0x0002          /* just send 8 bit data blind */
+#define MM_MIME8BIT    0x0004          /* convert 8-bit data to MIME */
 \f/*
 **  Additional definitions
 */
 
 
 \f/*
 **  Additional definitions
 */
 
 
-/* Offset used to ensure that name server error * codes are unique */
-#define        MAX_ERRNO       100
-
-
 /*
 **  Privacy flags
 **     These are bit values for the PrivacyFlags word.
 */
 
 #define PRIV_PUBLIC            0       /* what have I got to hide? */
 /*
 **  Privacy flags
 **     These are bit values for the PrivacyFlags word.
 */
 
 #define PRIV_PUBLIC            0       /* what have I got to hide? */
-#define PRIV_NEEDMAILHELO      00001   /* insist on HELO for MAIL, at least */
-#define PRIV_NEEDEXPNHELO      00002   /* insist on HELO for EXPN */
-#define PRIV_NEEDVRFYHELO      00004   /* insist on HELO for VRFY */
-#define PRIV_NOEXPN            00010   /* disallow EXPN command entirely */
-#define PRIV_NOVRFY            00020   /* disallow VRFY command entirely */
-#define PRIV_AUTHWARNINGS      00040   /* flag possible authorization probs */
-#define PRIV_RESTRMAILQ                01000   /* restrict mailq command */
-#define PRIV_GOAWAY            00777   /* don't give no info, anyway, anyhow */
+#define PRIV_NEEDMAILHELO      0x0001  /* insist on HELO for MAIL, at least */
+#define PRIV_NEEDEXPNHELO      0x0002  /* insist on HELO for EXPN */
+#define PRIV_NEEDVRFYHELO      0x0004  /* insist on HELO for VRFY */
+#define PRIV_NOEXPN            0x0008  /* disallow EXPN command entirely */
+#define PRIV_NOVRFY            0x0010  /* disallow VRFY command entirely */
+#define PRIV_AUTHWARNINGS      0x0020  /* flag possible authorization probs */
+#define PRIV_NORECEIPTS                0x0040  /* disallow return receipts */
+#define PRIV_RESTRICTMAILQ     0x1000  /* restrict mailq command */
+#define PRIV_RESTRICTQRUN      0x2000  /* restrict queue run */
+#define PRIV_GOAWAY            0x0fff  /* don't give no info, anyway, anyhow */
 
 /* struct defining such things */
 struct prival
 
 /* struct defining such things */
 struct prival
@@ -692,13 +768,34 @@ struct prival
 
 
 /*
 
 
 /*
-**  Flags passed to remotename
+**  Flags passed to remotename, parseaddr, allocaddr, and buildaddr.
+*/
+
+#define RF_SENDERADDR          0x001   /* this is a sender address */
+#define RF_HEADERADDR          0x002   /* this is a header address */
+#define RF_CANONICAL           0x004   /* strip comment information */
+#define RF_ADDDOMAIN           0x008   /* OK to do domain extension */
+#define RF_COPYPARSE           0x010   /* copy parsed user & host */
+#define RF_COPYPADDR           0x020   /* copy print address */
+#define RF_COPYALL             (RF_COPYPARSE|RF_COPYPADDR)
+#define RF_COPYNONE            0
+
+
+/*
+**  Flags passed to safefile.
 */
 
 */
 
-#define RF_SENDERADDR          0001    /* this is a sender address */
-#define RF_HEADERADDR          0002    /* this is a header address */
-#define RF_CANONICAL           0004    /* strip comment information */
-#define RF_ADDDOMAIN           0010    /* OK to do domain extension */
+#define SFF_ANYFILE            0       /* no special restrictions */
+#define SFF_MUSTOWN            0x0001  /* user must own this file */
+#define SFF_NOSLINK            0x0002  /* file cannot be a symbolic link */
+#define SFF_ROOTOK             0x0004  /* ok for root to own this file */
+
+
+/*
+**  Flags passed to putheader and putbody.
+*/
+
+#define PF_DELETEMIMEHDRS      0x0001  /* delete Content-Type: and C-T-E: */
 
 
 /*
 
 
 /*
@@ -709,6 +806,9 @@ struct prival
 union bigsockaddr
 {
        struct sockaddr         sa;     /* general version */
 union bigsockaddr
 {
        struct sockaddr         sa;     /* general version */
+#ifdef NETUNIX
+       struct sockaddr_un      sunix;  /* UNIX family */
+#endif
 #ifdef NETINET
        struct sockaddr_in      sin;    /* INET family */
 #endif
 #ifdef NETINET
        struct sockaddr_in      sin;    /* INET family */
 #endif
@@ -724,6 +824,27 @@ union bigsockaddr
 };
 
 #define SOCKADDR       union bigsockaddr
 };
 
 #define SOCKADDR       union bigsockaddr
+
+
+/*
+**  Vendor codes
+**
+**     Vendors can customize sendmail to add special behaviour,
+**     generally for back compatibility.  Ideally, this should
+**     be set up in the .cf file using the "V" command.  However,
+**     it's quite reasonable for some vendors to want the default
+**     be their old version; this can be set using
+**             -DVENDOR_DEFAULT=VENDOR_xxx
+**     in the Makefile.
+**
+**     Vendors should apply to sendmail@CS.Berkeley.EDU for
+**     unique vendor codes.
+*/
+
+#define VENDOR_BERKELEY        1       /* Berkeley-native configuration file */
+#define VENDOR_SUN     2       /* Sun-native configuration file */
+
+EXTERN int     VendorCode;     /* vendor-specific operation enhancements */
 \f/*
 **  Global variables.
 */
 \f/*
 **  Global variables.
 */
@@ -734,7 +855,6 @@ EXTERN bool IgnrDot;        /* don't let dot end messages */
 EXTERN bool    SaveFrom;       /* save leading "From" lines */
 EXTERN bool    Verbose;        /* set if blow-by-blow desired */
 EXTERN bool    GrabTo;         /* if set, get recipients from msg */
 EXTERN bool    SaveFrom;       /* save leading "From" lines */
 EXTERN bool    Verbose;        /* set if blow-by-blow desired */
 EXTERN bool    GrabTo;         /* if set, get recipients from msg */
-EXTERN bool    NoReturn;       /* don't return letter to sender */
 EXTERN bool    SuprErrs;       /* set if we are suppressing errors */
 EXTERN bool    HoldErrs;       /* only output errors to transcript */
 EXTERN bool    NoConnect;      /* don't connect to non-local mailers */
 EXTERN bool    SuprErrs;       /* set if we are suppressing errors */
 EXTERN bool    HoldErrs;       /* only output errors to transcript */
 EXTERN bool    NoConnect;      /* don't connect to non-local mailers */
@@ -743,9 +863,10 @@ EXTERN bool        ForkQueueRuns;  /* fork for each job when running the queue */
 EXTERN bool    AutoRebuild;    /* auto-rebuild the alias database as needed */
 EXTERN bool    CheckAliases;   /* parse addresses during newaliases */
 EXTERN bool    NoAlias;        /* suppress aliasing */
 EXTERN bool    AutoRebuild;    /* auto-rebuild the alias database as needed */
 EXTERN bool    CheckAliases;   /* parse addresses during newaliases */
 EXTERN bool    NoAlias;        /* suppress aliasing */
-EXTERN bool    UseNameServer;  /* use internet domain name server */
-EXTERN bool    SevenBit;       /* force 7-bit data */
-EXTERN int     SafeAlias;      /* minutes to wait until @:@ in alias file */
+EXTERN bool    UseNameServer;  /* using DNS -- interpret h_errno & MX RRs */
+EXTERN bool    SevenBitInput;  /* force 7-bit data on input */
+EXTERN bool    HasEightBits;   /* has at least one eight bit input byte */
+EXTERN time_t  SafeAlias;      /* interval to wait until @:@ in alias file */
 EXTERN FILE    *InChannel;     /* input connection */
 EXTERN FILE    *OutChannel;    /* output connection */
 EXTERN uid_t   RealUid;        /* when Daemon, real uid of caller */
 EXTERN FILE    *InChannel;     /* input connection */
 EXTERN FILE    *OutChannel;    /* output connection */
 EXTERN uid_t   RealUid;        /* when Daemon, real uid of caller */
@@ -782,10 +903,11 @@ EXTERN bool       SendMIMEErrors; /* send error messages in MIME format */
 EXTERN bool    MatchGecos;     /* look for user names in gecos field */
 EXTERN bool    UseErrorsTo;    /* use Errors-To: header (back compat) */
 EXTERN bool    TryNullMXList;  /* if we are the best MX, try host directly */
 EXTERN bool    MatchGecos;     /* look for user names in gecos field */
 EXTERN bool    UseErrorsTo;    /* use Errors-To: header (back compat) */
 EXTERN bool    TryNullMXList;  /* if we are the best MX, try host directly */
+EXTERN bool    InChild;        /* true if running in an SMTP subprocess */
+EXTERN bool    DisConnected;   /* running with OutChannel redirected to xf */
 EXTERN char    SpaceSub;       /* substitution for <lwsp> */
 EXTERN int     PrivacyFlags;   /* privacy flags */
 EXTERN char    SpaceSub;       /* substitution for <lwsp> */
 EXTERN int     PrivacyFlags;   /* privacy flags */
-extern char    *ConfFile;      /* location of configuration file [conf.c] */
-extern char    *FreezeFile;    /* location of frozen memory image [conf.c] */
+EXTERN char    *ConfFile;      /* location of configuration file [conf.c] */
 extern char    *PidFile;       /* location of proc id file [conf.c] */
 extern ADDRESS NullAddress;    /* a null (template) address [main.c] */
 EXTERN long    WkClassFact;    /* multiplier for message class -> priority */
 extern char    *PidFile;       /* location of proc id file [conf.c] */
 extern ADDRESS NullAddress;    /* a null (template) address [main.c] */
 EXTERN long    WkClassFact;    /* multiplier for message class -> priority */
@@ -799,15 +921,23 @@ EXTERN char       *ForwardPath;   /* path to search for .forward files */
 EXTERN long    MinBlocksFree;  /* min # of blocks free on queue fs */
 EXTERN char    *FallBackMX;    /* fall back MX host */
 EXTERN long    MaxMessageSize; /* advertised max size we will accept */
 EXTERN long    MinBlocksFree;  /* min # of blocks free on queue fs */
 EXTERN char    *FallBackMX;    /* fall back MX host */
 EXTERN long    MaxMessageSize; /* advertised max size we will accept */
+EXTERN time_t  MaxHostStatAge; /* max age of cached host status info */
+EXTERN time_t  MinQueueAge;    /* min delivery interval */
+EXTERN char    *ServiceSwitchFile;     /* backup service switch */
+EXTERN char    *DefaultCharSet;        /* default character set for MIME */
+EXTERN int     DeliveryNiceness;       /* how nice to be during delivery */
 EXTERN char    *PostMasterCopy;        /* address to get errs cc's */
 EXTERN int     CheckpointInterval;     /* queue file checkpoint interval */
 EXTERN bool    DontPruneRoutes;        /* don't prune source routes */
 EXTERN char    *PostMasterCopy;        /* address to get errs cc's */
 EXTERN int     CheckpointInterval;     /* queue file checkpoint interval */
 EXTERN bool    DontPruneRoutes;        /* don't prune source routes */
+EXTERN bool    BrokenSmtpPeers;        /* peers can't handle 2-line greeting */
+EXTERN bool    SortQueueByHost;        /* order queue by host name first */
 EXTERN int     MaxMciCache;            /* maximum entries in MCI cache */
 EXTERN time_t  MciCacheTimeout;        /* maximum idle time on connections */
 EXTERN char    *QueueLimitRecipient;   /* limit queue runs to this recipient */
 EXTERN char    *QueueLimitSender;      /* limit queue runs to this sender */
 EXTERN char    *QueueLimitId;          /* limit queue runs to this id */
 EXTERN FILE    *TrafficLogFile;        /* file in which to log all traffic */
 EXTERN int     MaxMciCache;            /* maximum entries in MCI cache */
 EXTERN time_t  MciCacheTimeout;        /* maximum idle time on connections */
 EXTERN char    *QueueLimitRecipient;   /* limit queue runs to this recipient */
 EXTERN char    *QueueLimitSender;      /* limit queue runs to this sender */
 EXTERN char    *QueueLimitId;          /* limit queue runs to this id */
 EXTERN FILE    *TrafficLogFile;        /* file in which to log all traffic */
+extern int     errno;
 
 
 /*
 
 
 /*
@@ -818,6 +948,7 @@ EXTERN FILE *TrafficLogFile;        /* file in which to log all traffic */
 
 EXTERN struct
 {
 
 EXTERN struct
 {
+                       /* RFC 1123-specified timeouts [minimum value] */
        time_t  to_initial;     /* initial greeting timeout [5m] */
        time_t  to_mail;        /* MAIL command [5m] */
        time_t  to_rcpt;        /* RCPT command [5m] */
        time_t  to_initial;     /* initial greeting timeout [5m] */
        time_t  to_mail;        /* MAIL command [5m] */
        time_t  to_rcpt;        /* RCPT command [5m] */
@@ -830,11 +961,18 @@ EXTERN struct
        time_t  to_helo;        /* HELO command */
        time_t  to_quit;        /* QUIT command */
        time_t  to_miscshort;   /* misc short commands (NOOP, VERB, etc) */
        time_t  to_helo;        /* HELO command */
        time_t  to_quit;        /* QUIT command */
        time_t  to_miscshort;   /* misc short commands (NOOP, VERB, etc) */
+       time_t  to_ident;       /* IDENT protocol requests */
+       time_t  to_fileopen;    /* opening :include: and .forward files */
                        /* following are per message */
                        /* following are per message */
-       time_t  to_q_return;    /* queue return timeout */
-       time_t  to_q_warning;   /* queue warning timeout */
+       time_t  to_q_return[MAXTOCLASS];        /* queue return timeouts */
+       time_t  to_q_warning[MAXTOCLASS];       /* queue warning timeouts */
 } TimeOuts;
 
 } TimeOuts;
 
+/* timeout classes for return and warning timeouts */
+# define TOC_NORMAL    0       /* normal delivery */
+# define TOC_URGENT    1       /* urgent delivery */
+# define TOC_NONURGENT 2       /* non-urgent delivery */
+
 
 /*
 **  Trace information
 
 /*
 **  Trace information
@@ -883,7 +1021,10 @@ extern const char *errstring __P((int));
 extern void            expand __P((char *, char *, char *, ENVELOPE *));
 extern void            define __P((int, char *, ENVELOPE *));
 extern char            *macvalue __P((int, ENVELOPE *));
 extern void            expand __P((char *, char *, char *, ENVELOPE *));
 extern void            define __P((int, char *, ENVELOPE *));
 extern char            *macvalue __P((int, ENVELOPE *));
-extern char            **prescan __P((char *, int, char[], char **));
+extern char            *macname __P((int));
+extern int             macid __P((char *, char **));
+extern char            **prescan __P((char *, int, char[], int, char **));
+extern int             rewrite __P((char **, int, int, ENVELOPE *));
 extern char            *fgetfolded __P((char *, int, FILE *));
 extern ADDRESS         *recipient __P((ADDRESS *, ADDRESS **, ENVELOPE *));
 extern ENVELOPE                *newenvelope __P((ENVELOPE *, ENVELOPE *));
 extern char            *fgetfolded __P((char *, int, FILE *));
 extern ADDRESS         *recipient __P((ADDRESS *, ADDRESS **, ENVELOPE *));
 extern ENVELOPE                *newenvelope __P((ENVELOPE *, ENVELOPE *));
@@ -897,10 +1038,17 @@ extern ADDRESS           *getctladdr __P((ADDRESS *));
 extern char            *anynet_ntoa __P((SOCKADDR *));
 extern char            *remotename __P((char *, MAILER *, int, int *, ENVELOPE *));
 extern bool            shouldqueue __P((long, time_t));
 extern char            *anynet_ntoa __P((SOCKADDR *));
 extern char            *remotename __P((char *, MAILER *, int, int *, ENVELOPE *));
 extern bool            shouldqueue __P((long, time_t));
-extern bool            lockfile __P((int, char *, int));
+extern bool            lockfile __P((int, char *, char *, int));
 extern char            *hostsignature __P((MAILER *, char *, ENVELOPE *));
 extern void            openxscript __P((ENVELOPE *));
 extern void            closexscript __P((ENVELOPE *));
 extern char            *hostsignature __P((MAILER *, char *, ENVELOPE *));
 extern void            openxscript __P((ENVELOPE *));
 extern void            closexscript __P((ENVELOPE *));
+extern sigfunc_t       setsignal __P((int, sigfunc_t));
+extern char            *shortenstring __P((char *, int));
+extern bool            usershellok __P((char *));
+extern void            commaize __P((HDR *, char *, int, MCI *, ENVELOPE *));
+extern char            *hvalue __P((char *, HDR *));
+extern char            *defcharset __P((ENVELOPE *));
+extern bool            emptyaddr __P((ADDRESS *));
 
 /* ellipsis is a different case though */
 #ifdef __STDC__
 
 /* ellipsis is a different case though */
 #ifdef __STDC__