From: Eric Allman Date: Wed, 25 Jan 1995 00:28:37 +0000 (-0800) Subject: use wordinclass() abstraction for searching classes X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/c85d44caebb4ef7391acd36afbe9a39c9070671c use wordinclass() abstraction for searching classes 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 --- diff --git a/usr/src/usr.sbin/sendmail/src/domain.c b/usr/src/usr.sbin/sendmail/src/domain.c index d18bb46347..ff5f477cbc 100644 --- a/usr/src/usr.sbin/sendmail/src/domain.c +++ b/usr/src/usr.sbin/sendmail/src/domain.c @@ -10,9 +10,9 @@ #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 -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 */ @@ -89,7 +89,6 @@ getmxrr(host, mxhosts, droplocalhost, rcode) u_short pref, localpref, type; char *fallbackMX = FallBackMX; static bool firsttime = TRUE; - STAB *st; 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; } - 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; @@ -206,9 +203,7 @@ getmxrr(host, mxhosts, droplocalhost, rcode) (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", diff --git a/usr/src/usr.sbin/sendmail/src/macro.c b/usr/src/usr.sbin/sendmail/src/macro.c index 822bd12086..25e35cad5a 100644 --- a/usr/src/usr.sbin/sendmail/src/macro.c +++ b/usr/src/usr.sbin/sendmail/src/macro.c @@ -7,7 +7,7 @@ */ #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" @@ -388,3 +388,25 @@ macid(p, ep) printf("0x%x\n", mid); return mid; } + /* +** 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); +} diff --git a/usr/src/usr.sbin/sendmail/src/main.c b/usr/src/usr.sbin/sendmail/src/main.c index 003088def9..86479f2e94 100644 --- a/usr/src/usr.sbin/sendmail/src/main.c +++ b/usr/src/usr.sbin/sendmail/src/main.c @@ -13,7 +13,7 @@ static char copyright[] = #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 @@ -1510,15 +1510,13 @@ dumpstate(when) { #ifdef LOG register char *j = macvalue('j', CurEnv); - register STAB *s; syslog(LOG_DEBUG, "--- dumping state on %s: $j = %s ---", when, j == 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: ---"); diff --git a/usr/src/usr.sbin/sendmail/src/parseaddr.c b/usr/src/usr.sbin/sendmail/src/parseaddr.c index 486c6f90bc..dacdbcff51 100644 --- a/usr/src/usr.sbin/sendmail/src/parseaddr.c +++ b/usr/src/usr.sbin/sendmail/src/parseaddr.c @@ -7,7 +7,7 @@ */ #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"