use wordinclass() abstraction for searching classes
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Wed, 25 Jan 1995 00:28:37 +0000 (16:28 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Wed, 25 Jan 1995 00:28:37 +0000 (16:28 -0800)
SCCS-vsn: usr.sbin/sendmail/src/macro.c 8.6
SCCS-vsn: usr.sbin/sendmail/src/main.c 8.76
SCCS-vsn: usr.sbin/sendmail/src/parseaddr.c 8.48
SCCS-vsn: usr.sbin/sendmail/src/domain.c 8.30

usr/src/usr.sbin/sendmail/src/domain.c
usr/src/usr.sbin/sendmail/src/macro.c
usr/src/usr.sbin/sendmail/src/main.c
usr/src/usr.sbin/sendmail/src/parseaddr.c

index d18bb46..ff5f477 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #if NAMED_BIND
 
 #ifndef lint
 #if NAMED_BIND
-static char sccsid[] = "@(#)domain.c   8.29 (Berkeley) %G% (with name server)";
+static char sccsid[] = "@(#)domain.c   8.30 (Berkeley) %G% (with name server)";
 #else
 #else
-static char sccsid[] = "@(#)domain.c   8.29 (Berkeley) %G% (without name server)";
+static char sccsid[] = "@(#)domain.c   8.30 (Berkeley) %G% (without name server)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -89,7 +89,6 @@ getmxrr(host, mxhosts, droplocalhost, rcode)
        u_short pref, localpref, type;
        char *fallbackMX = FallBackMX;
        static bool firsttime = TRUE;
        u_short pref, localpref, type;
        char *fallbackMX = FallBackMX;
        static bool firsttime = TRUE;
-       STAB *st;
        bool trycanon = FALSE;
        u_short prefer[MAXMXHOSTS];
        int weight[MAXMXHOSTS];
        bool trycanon = FALSE;
        u_short prefer[MAXMXHOSTS];
        int weight[MAXMXHOSTS];
@@ -107,9 +106,7 @@ getmxrr(host, mxhosts, droplocalhost, rcode)
                        /* this entry is bogus */
                        fallbackMX = FallBackMX = NULL;
                }
                        /* this entry is bogus */
                        fallbackMX = FallBackMX = NULL;
                }
-               else if (droplocalhost &&
-                        (st = stab(fallbackMX, ST_CLASS, ST_FIND)) != NULL &&
-                        bitnset('w', st->s_class))
+               else if (droplocalhost && wordinclass(fallbackMX, 'w'))
                {
                        /* don't use fallback for this pass */
                        fallbackMX = NULL;
                {
                        /* don't use fallback for this pass */
                        fallbackMX = NULL;
@@ -206,9 +203,7 @@ getmxrr(host, mxhosts, droplocalhost, rcode)
                                   (RES_UNC_T) bp, buflen)) < 0)
                        break;
                cp += n;
                                   (RES_UNC_T) bp, buflen)) < 0)
                        break;
                cp += n;
-               if (droplocalhost &&
-                   (st = stab(bp, ST_CLASS, ST_FIND)) != NULL &&
-                   bitnset('w', st->s_class))
+               if (droplocalhost && wordinclass(bp, 'w'))
                {
                        if (tTd(8, 3))
                                printf("found localhost (%s) in MX list, pref=%d\n",
                {
                        if (tTd(8, 3))
                                printf("found localhost (%s) in MX list, pref=%d\n",
index 822bd12..25e35ca 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)macro.c    8.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)macro.c    8.6 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -388,3 +388,25 @@ macid(p, ep)
                printf("0x%x\n", mid);
        return mid;
 }
                printf("0x%x\n", mid);
        return mid;
 }
+\f/*
+**  WORDINCLASS -- tell if a word is in a specific class
+**
+**     Parameters:
+**             word -- the name of the word to look up.
+**             cl -- the class name.
+**
+**     Returns:
+**             TRUE if word can be found in cl.
+**             FALSE otherwise.
+*/
+
+bool
+wordinclass(word, cl)
+       char *word;
+       char cl;
+{
+       register STAB *s;
+
+       s = stab(word, ST_CLASS, ST_FIND);
+       return s != NULL && bitnset(cl, s->s_class);
+}
index 003088d..86479f2 100644 (file)
@@ -13,7 +13,7 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     8.75 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     8.76 (Berkeley) %G%";
 #endif /* not lint */
 
 #define        _DEFINE
 #endif /* not lint */
 
 #define        _DEFINE
@@ -1510,15 +1510,13 @@ dumpstate(when)
 {
 #ifdef LOG
        register char *j = macvalue('j', CurEnv);
 {
 #ifdef LOG
        register char *j = macvalue('j', CurEnv);
-       register STAB *s;
 
        syslog(LOG_DEBUG, "--- dumping state on %s: $j = %s ---",
                when,
                j == NULL ? "<NULL>" : j);
        if (j != NULL)
        {
 
        syslog(LOG_DEBUG, "--- dumping state on %s: $j = %s ---",
                when,
                j == NULL ? "<NULL>" : j);
        if (j != NULL)
        {
-               s = stab(j, ST_CLASS, ST_FIND);
-               if (s == NULL || !bitnset('w', s->s_class))
+               if (!wordinclass(j, 'w'))
                        syslog(LOG_DEBUG, "*** $j not in $=w ***");
        }
        syslog(LOG_DEBUG, "--- open file descriptors: ---");
                        syslog(LOG_DEBUG, "*** $j not in $=w ***");
        }
        syslog(LOG_DEBUG, "--- open file descriptors: ---");
index 486c6f9..dacdbcf 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)parseaddr.c        8.47 (Berkeley) %G%";
+static char sccsid[] = "@(#)parseaddr.c        8.48 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #include "sendmail.h"