Eliminate magic MN_LOCAL and MN_PROG; change q_mailer item in ADDRESS
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sat, 24 Oct 1981 11:38:33 +0000 (03:38 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sat, 24 Oct 1981 11:38:33 +0000 (03:38 -0800)
to be pointer to mailer rather than index.

SCCS-vsn: usr.sbin/sendmail/src/alias.c 3.26
SCCS-vsn: usr.sbin/sendmail/src/conf.c 3.36
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 3.49
SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 3.49
SCCS-vsn: usr.sbin/sendmail/src/parseaddr.c 3.31
SCCS-vsn: usr.sbin/sendmail/src/savemail.c 3.20
SCCS-vsn: usr.sbin/sendmail/src/version.c 3.56
SCCS-vsn: usr.sbin/sendmail/src/main.c 3.46
SCCS-vsn: usr.sbin/sendmail/src/recipient.c 3.27

usr/src/usr.sbin/sendmail/src/alias.c
usr/src/usr.sbin/sendmail/src/conf.c
usr/src/usr.sbin/sendmail/src/deliver.c
usr/src/usr.sbin/sendmail/src/main.c
usr/src/usr.sbin/sendmail/src/parseaddr.c
usr/src/usr.sbin/sendmail/src/recipient.c
usr/src/usr.sbin/sendmail/src/savemail.c
usr/src/usr.sbin/sendmail/src/sendmail.h
usr/src/usr.sbin/sendmail/src/version.c

index 22743b3..daf35eb 100644 (file)
@@ -4,9 +4,9 @@
 # include "sendmail.h"
 
 # ifdef DBM
 # include "sendmail.h"
 
 # ifdef DBM
-static char SccsId[] = "@(#)alias.c    3.25    %G%     (with DBM)";
+static char SccsId[] = "@(#)alias.c    3.26    %G%     (with DBM)";
 # else DBM
 # else DBM
-static char SccsId[] = "@(#)alias.c    3.25    %G%     (without DBM)";
+static char SccsId[] = "@(#)alias.c    3.26    %G%     (without DBM)";
 # endif DBM
 
 /*
 # endif DBM
 
 /*
@@ -362,7 +362,7 @@ readaliases(aliasfile, init)
                                break;
                        lineno++;
                }
                                break;
                        lineno++;
                }
-               if (al.q_mailer != MN_LOCAL)
+               if (al.q_mailer != LocalMailer)
                {
                        syserr("aliases: %d: cannot alias non-local names", lineno);
                        continue;
                {
                        syserr("aliases: %d: cannot alias non-local names", lineno);
                        continue;
@@ -434,7 +434,7 @@ forward(user)
                printf("forward(%s)\n", user->q_paddr);
 # endif DEBUG
 
                printf("forward(%s)\n", user->q_paddr);
 # endif DEBUG
 
-       if (user->q_mailer != MN_LOCAL || bitset(QBADADDR, user->q_flags))
+       if (user->q_mailer != LocalMailer || bitset(QBADADDR, user->q_flags))
                return;
 # ifdef DEBUG
        if (user->q_home == NULL)
                return;
 # ifdef DEBUG
        if (user->q_home == NULL)
index b80ec6c..fcd0ff7 100644 (file)
@@ -36,7 +36,7 @@
 
 
 
 
 
 
-static char SccsId[] = "@(#)conf.c     3.35    %G%";
+static char SccsId[] = "@(#)conf.c     3.36    %G%";
 \f/*
 **  Header info table
 **     Final (null) entry contains the flags used for any other field.
 \f/*
 **  Header info table
 **     Final (null) entry contains the flags used for any other field.
@@ -394,7 +394,7 @@ checkcompat(to)
 {
        register STAB *s;
 
 {
        register STAB *s;
 
-       if (to->q_mailer != MN_LOCAL && MsgSize > 100000)
+       if (to->q_mailer != LocalMailer && MsgSize > 100000)
        {
                usrerr("Message exceeds 100000 bytes");
                NoReturn++;
        {
                usrerr("Message exceeds 100000 bytes");
                NoReturn++;
@@ -402,7 +402,7 @@ checkcompat(to)
        }
 # ifdef ING70
        s = stab("arpa", ST_MAILER, ST_FIND);
        }
 # ifdef ING70
        s = stab("arpa", ST_MAILER, ST_FIND);
-       if (s != NULL && From.q_mailer != MN_LOCAL && to->q_mailer == s->s_mailer->m_mno)
+       if (s != NULL && From.q_mailer != LocalMailer && to->q_mailer == s->s_mailer)
        {
                usrerr("No ARPA mail through this machine: see your system administration");
                return (FALSE);
        {
                usrerr("No ARPA mail through this machine: see your system administration");
                return (FALSE);
index d8ed37a..9fb4d3c 100644 (file)
@@ -7,7 +7,7 @@
 # include <syslog.h>
 # endif LOG
 
 # include <syslog.h>
 # endif LOG
 
-static char SccsId[] = "@(#)deliver.c  3.48    %G%";
+static char SccsId[] = "@(#)deliver.c  3.49    %G%";
 
 /*
 **  DELIVER -- Deliver a message to a list of addresses.
 
 /*
 **  DELIVER -- Deliver a message to a list of addresses.
@@ -61,7 +61,7 @@ deliver(to, editfcn)
 # ifdef DEBUG
        if (Debug)
                printf("\n--deliver, mailer=%d, host=`%s', first user=`%s'\n",
 # ifdef DEBUG
        if (Debug)
                printf("\n--deliver, mailer=%d, host=`%s', first user=`%s'\n",
-                       to->q_mailer, to->q_host, to->q_user);
+                       to->q_mailer->m_mno, to->q_host, to->q_user);
 # endif DEBUG
 
        /*
 # endif DEBUG
 
        /*
@@ -73,7 +73,7 @@ deliver(to, editfcn)
        **      manifest lower limit of 4 for MAXPV.
        */
 
        **      manifest lower limit of 4 for MAXPV.
        */
 
-       m = Mailer[to->q_mailer];
+       m = to->q_mailer;
        host = to->q_host;
 
        /* rewrite from address, using rewriting rules */
        host = to->q_host;
 
        /* rewrite from address, using rewriting rules */
@@ -153,7 +153,7 @@ deliver(to, editfcn)
                        continue;
 
                /* compute effective uid/gid when sending */
                        continue;
 
                /* compute effective uid/gid when sending */
-               if (to->q_mailer == MN_PROG)
+               if (to->q_mailer == ProgMailer)
                        ctladdr = getctladdr(to);
 
                user = to->q_user;
                        ctladdr = getctladdr(to);
 
                user = to->q_user;
@@ -204,8 +204,8 @@ deliver(to, editfcn)
                        continue;
 
                /* save statistics.... */
                        continue;
 
                /* save statistics.... */
-               Stat.stat_nt[to->q_mailer]++;
-               Stat.stat_bt[to->q_mailer] += kbytes(MsgSize);
+               Stat.stat_nt[to->q_mailer->m_mno]++;
+               Stat.stat_bt[to->q_mailer->m_mno] += kbytes(MsgSize);
 
                /*
                **  See if this user name is "special".
 
                /*
                **  See if this user name is "special".
@@ -217,7 +217,7 @@ deliver(to, editfcn)
                **      with the others, so we fudge on the To person.
                */
 
                **      with the others, so we fudge on the To person.
                */
 
-               if (m == Mailer[MN_LOCAL])
+               if (m == LocalMailer)
                {
                        if (index(user, '/') != NULL)
                        {
                {
                        if (index(user, '/') != NULL)
                        {
@@ -882,7 +882,7 @@ sendall(verifyonly)
                                To = q->q_paddr;
                                if (!bitset(QDONTSEND|QBADADDR, q->q_flags))
                                {
                                To = q->q_paddr;
                                if (!bitset(QDONTSEND|QBADADDR, q->q_flags))
                                {
-                                       if (q->q_mailer == MN_LOCAL || q->q_mailer == MN_PROG)
+                                       if (bitset(M_LOCAL, q->q_mailer->m_flags))
                                                message(Arpa_Info, "deliverable");
                                        else
                                                message(Arpa_Info, "queueable");
                                                message(Arpa_Info, "deliverable");
                                        else
                                                message(Arpa_Info, "queueable");
index ca832b0..534b457 100644 (file)
@@ -8,7 +8,7 @@
 # include <syslog.h>
 # endif LOG
 
 # include <syslog.h>
 # endif LOG
 
-static char    SccsId[] = "@(#)main.c  3.45    %G%";
+static char    SccsId[] = "@(#)main.c  3.46    %G%";
 
 /*
 **  SENDMAIL -- Post mail to a set of destinations.
 
 /*
 **  SENDMAIL -- Post mail to a set of destinations.
@@ -141,6 +141,7 @@ main(argc, argv)
        bool aliasinit = FALSE;
        extern char *ttyname();
        extern bool safefile();
        bool aliasinit = FALSE;
        extern char *ttyname();
        extern bool safefile();
+       STAB *st;
        bool canrename;
 
        argv[argc] = NULL;
        bool canrename;
 
        argv[argc] = NULL;
@@ -399,12 +400,27 @@ main(argc, argv)
 
        /*
        **  Read system control file.
 
        /*
        **  Read system control file.
+       **      Extract special fields for local use.
        */
 
        readcf(ConfFile, safecf);
        */
 
        readcf(ConfFile, safecf);
+
+       /* our name for SMTP codes */
        (void) expand("$i", ibuf, &ibuf[sizeof ibuf - 1]);
        HostName = ibuf;
 
        (void) expand("$i", ibuf, &ibuf[sizeof ibuf - 1]);
        HostName = ibuf;
 
+       /* the indices of local and program mailers */
+       st = stab("local", ST_MAILER, ST_FIND);
+       if (st == NULL)
+               syserr("No local mailer defined");
+       else
+               LocalMailer = st->s_mailer;
+       st = stab("prog", ST_MAILER, ST_FIND);
+       if (st == NULL)
+               syserr("No prog mailer defined");
+       else
+               ProgMailer = st->s_mailer;
+
        /*
        **  Initialize aliases.
        */
        /*
        **  Initialize aliases.
        */
@@ -491,8 +507,8 @@ main(argc, argv)
        errno = 0;
 
        /* collect statistics */
        errno = 0;
 
        /* collect statistics */
-       Stat.stat_nf[From.q_mailer]++;
-       Stat.stat_bf[From.q_mailer] += kbytes(MsgSize);
+       Stat.stat_nf[From.q_mailer->m_mno]++;
+       Stat.stat_bf[From.q_mailer->m_mno] += kbytes(MsgSize);
 
        /*
        **  Arrange that the person who is sending the mail
 
        /*
        **  Arrange that the person who is sending the mail
index ea02535..739df98 100644 (file)
@@ -1,6 +1,6 @@
 # include "sendmail.h"
 
 # include "sendmail.h"
 
-static char    SccsId[] = "@(#)parseaddr.c     3.30    %G%";
+static char    SccsId[] = "@(#)parseaddr.c     3.31    %G%";
 
 /*
 **  PARSE -- Parse an address
 
 /*
 **  PARSE -- Parse an address
@@ -89,7 +89,7 @@ parse(addr, a, copyf)
        a = buildaddr(pvp, a);
        if (a == NULL)
                return (NULL);
        a = buildaddr(pvp, a);
        if (a == NULL)
                return (NULL);
-       m = Mailer[a->q_mailer];
+       m = a->q_mailer;
 
        /*
        **  Make local copies of the host & user and then
 
        /*
        **  Make local copies of the host & user and then
@@ -756,7 +756,7 @@ buildaddr(tv, a)
                usrerr(buf);
                return (NULL);
        }
                usrerr(buf);
                return (NULL);
        }
-       for (mp = Mailer, i = 0; (m = *mp++) != NULL; i++)
+       for (mp = Mailer; (m = *mp++) != NULL; )
        {
                if (strcmp(m->m_name, *tv) == 0)
                        break;
        {
                if (strcmp(m->m_name, *tv) == 0)
                        break;
@@ -766,7 +766,7 @@ buildaddr(tv, a)
                syserr("buildaddr: unknown net %s", *tv);
                return (NULL);
        }
                syserr("buildaddr: unknown net %s", *tv);
                return (NULL);
        }
-       a->q_mailer = i;
+       a->q_mailer = m;
 
        /* figure out what host (if any) */
        tv++;
 
        /* figure out what host (if any) */
        tv++;
@@ -869,7 +869,7 @@ sameaddr(a, b, wildflg)
                return (FALSE);
 
        /* if the mailer ignores hosts, we have succeeded! */
                return (FALSE);
 
        /* if the mailer ignores hosts, we have succeeded! */
-       if (bitset(M_LOCAL, Mailer[a->q_mailer]->m_flags))
+       if (bitset(M_LOCAL, a->q_mailer->m_flags))
                return (TRUE);
 
        /* otherwise compare hosts (but be careful for NULL ptrs) */
                return (TRUE);
 
        /* otherwise compare hosts (but be careful for NULL ptrs) */
@@ -905,7 +905,7 @@ printaddr(a, follow)
                printf("%x=", a);
                (void) fflush(stdout);
                printf("%s: mailer %d (%s), host `%s', user `%s'\n", a->q_paddr,
                printf("%x=", a);
                (void) fflush(stdout);
                printf("%s: mailer %d (%s), host `%s', user `%s'\n", a->q_paddr,
-                      a->q_mailer, Mailer[a->q_mailer]->m_name, a->q_host, a->q_user);
+                      a->q_mailer->m_mno, a->q_mailer->m_name, a->q_host, a->q_user);
                printf("\tnext=%x, flags=%o, rmailer %d\n", a->q_next,
                       a->q_flags, a->q_rmailer);
 
                printf("\tnext=%x, flags=%o, rmailer %d\n", a->q_next,
                       a->q_flags, a->q_rmailer);
 
index 729146a..d310bf9 100644 (file)
@@ -3,7 +3,7 @@
 # include <sys/stat.h>
 # include "sendmail.h"
 
 # include <sys/stat.h>
 # include "sendmail.h"
 
-static char SccsId[] = "@(#)recipient.c        3.26    %G%";
+static char SccsId[] = "@(#)recipient.c        3.27    %G%";
 
 /*
 **  SENDTO -- Designate a send list.
 
 /*
 **  SENDTO -- Designate a send list.
@@ -126,7 +126,7 @@ recipient(a)
        extern ADDRESS *getctladdr();
 
        To = a->q_paddr;
        extern ADDRESS *getctladdr();
 
        To = a->q_paddr;
-       m = Mailer[a->q_mailer];
+       m = a->q_mailer;
        errno = 0;
 # ifdef DEBUG
        if (Debug)
        errno = 0;
 # ifdef DEBUG
        if (Debug)
@@ -147,12 +147,11 @@ recipient(a)
        **  Do sickly crude mapping for program mailing, etc.
        */
 
        **  Do sickly crude mapping for program mailing, etc.
        */
 
-       if (a->q_mailer == MN_LOCAL)
+       if (a->q_mailer == LocalMailer)
        {
                if (a->q_user[0] == '|')
                {
        {
                if (a->q_user[0] == '|')
                {
-                       a->q_mailer = MN_PROG;
-                       m = Mailer[MN_PROG];
+                       a->q_mailer = m = ProgMailer;
                        a->q_user++;
                        if (a->q_alias == NULL && Debug == 0)
                        {
                        a->q_user++;
                        if (a->q_alias == NULL && Debug == 0)
                        {
@@ -200,7 +199,7 @@ recipient(a)
        **  Alias the name and handle :include: specs.
        */
 
        **  Alias the name and handle :include: specs.
        */
 
-       if (a->q_mailer == MN_LOCAL)
+       if (a->q_mailer == LocalMailer)
        {
                if (strncmp(a->q_user, ":include:", 9) == 0)
                {
        {
                if (strncmp(a->q_user, ":include:", 9) == 0)
                {
@@ -226,7 +225,7 @@ recipient(a)
        **  the user (which is probably correct anyway).
        */
 
        **  the user (which is probably correct anyway).
        */
 
-       if (!bitset(QDONTSEND, a->q_flags) && a->q_mailer == MN_LOCAL)
+       if (!bitset(QDONTSEND, a->q_flags) && a->q_mailer == LocalMailer)
        {
                char buf[MAXNAME];
                register char *p;
        {
                char buf[MAXNAME];
                register char *p;
index 52675c4..a711e87 100644 (file)
@@ -1,7 +1,7 @@
 # include <pwd.h>
 # include "sendmail.h"
 
 # include <pwd.h>
 # include "sendmail.h"
 
-static char    SccsId[] = "@(#)savemail.c      3.19    %G%";
+static char    SccsId[] = "@(#)savemail.c      3.20    %G%";
 
 /*
 **  SAVEMAIL -- Save mail on error
 
 /*
 **  SAVEMAIL -- Save mail on error
@@ -146,7 +146,7 @@ savemail()
        if (ArpaMode != ARPA_NONE)
                return;
        p = NULL;
        if (ArpaMode != ARPA_NONE)
                return;
        p = NULL;
-       if (From.q_mailer == MN_LOCAL)
+       if (From.q_mailer == LocalMailer)
        {
                if (From.q_home != NULL)
                        p = From.q_home;
        {
                if (From.q_home != NULL)
                        p = From.q_home;
@@ -170,7 +170,7 @@ savemail()
                (void) expand("$z/dead.letter", buf, &buf[sizeof buf - 1]);
                To = buf;
                i = mailfile(buf, &From);
                (void) expand("$z/dead.letter", buf, &buf[sizeof buf - 1]);
                To = buf;
                i = mailfile(buf, &From);
-               giveresponse(i, TRUE, Mailer[MN_LOCAL]);
+               giveresponse(i, TRUE, LocalMailer);
        }
 
        /* add terminator to writeback message */
        }
 
        /* add terminator to writeback message */
index 5703e66..5a24e96 100644 (file)
@@ -6,7 +6,7 @@
 
 # ifdef _DEFINE
 # define EXTERN
 
 # ifdef _DEFINE
 # define EXTERN
-static char SmailSccsId[] =    "@(#)sendmail.h 3.48    %G%";
+static char SmailSccsId[] =    "@(#)sendmail.h 3.49    %G%";
 # else  _DEFINE
 # define EXTERN extern
 # endif _DEFINE
 # else  _DEFINE
 # define EXTERN extern
 # endif _DEFINE
@@ -54,7 +54,7 @@ struct address
        char            *q_paddr;       /* the printname for the address */
        char            *q_user;        /* user name */
        char            *q_host;        /* host name */
        char            *q_paddr;       /* the printname for the address */
        char            *q_user;        /* user name */
        char            *q_host;        /* host name */
-       short           q_mailer;       /* mailer to use */
+       struct mailer   *q_mailer;      /* mailer to use */
        short           q_rmailer;      /* real mailer (before mapping) */
        u_short         q_flags;        /* status flags, see below */
        short           q_uid;          /* user-id of receiver (if known) */
        short           q_rmailer;      /* real mailer (before mapping) */
        u_short         q_flags;        /* status flags, see below */
        short           q_uid;          /* user-id of receiver (if known) */
@@ -125,13 +125,10 @@ typedef struct mailer     MAILER;
 
 # define M_ARPAFMT     (M_NEEDDATE|M_NEEDFROM|M_MSGID)
 
 
 # define M_ARPAFMT     (M_NEEDDATE|M_NEEDFROM|M_MSGID)
 
-EXTERN MAILER *Mailer[MAXMAILERS+1];
-
-/* special mailer numbers */
-# define MN_LOCAL      0       /* local mailer */
-# define MN_PROG       1       /* program mailer */
-/* mailers from 2 on are arbitrary */
+EXTERN MAILER  *Mailer[MAXMAILERS+1];
 
 
+EXTERN MAILER  *LocalMailer;           /* ptr to local mailer */
+EXTERN MAILER  *ProgMailer;            /* ptr to program mailer */
 
 
 /*
 
 
 /*
index 672145e..eaa2ed7 100644 (file)
@@ -1,3 +1,3 @@
-static char    SccsId[] = "@(#)SendMail version 3.55 of %G%";
+static char    SccsId[] = "@(#)SendMail version 3.56 of %G%";
 
 
-char   Version[] = "3.55 [%G%]";
+char   Version[] = "3.56 [%G%]";