diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2000-08-12 21:55:49 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2000-08-12 21:55:49 +0000 |
commit | c3cd75415d60bc002b20182ffd3383ea9e901a80 (patch) | |
tree | 211dfd0f771f89d6abe14fa94cab53985a9d0116 /contrib/sendmail/src/stab.c | |
parent | 231592eb7942ebd4becae24ea8e018acea3742a9 (diff) | |
parent | 4332139a9a11f773ffe5109bed871561e3c290a1 (diff) | |
download | FreeBSD-src-c3cd75415d60bc002b20182ffd3383ea9e901a80.zip FreeBSD-src-c3cd75415d60bc002b20182ffd3383ea9e901a80.tar.gz |
This commit was generated by cvs2svn to compensate for changes in r64562,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/sendmail/src/stab.c')
-rw-r--r-- | contrib/sendmail/src/stab.c | 161 |
1 files changed, 140 insertions, 21 deletions
diff --git a/contrib/sendmail/src/stab.c b/contrib/sendmail/src/stab.c index 37b87a3..2177ae6 100644 --- a/contrib/sendmail/src/stab.c +++ b/contrib/sendmail/src/stab.c @@ -1,5 +1,6 @@ /* - * Copyright (c) 1998 Sendmail, Inc. All rights reserved. + * Copyright (c) 1998, 1999 Sendmail, Inc. and its suppliers. + * All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -11,10 +12,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)stab.c 8.19 (Berkeley) 5/19/1998"; -#endif /* not lint */ +static char id[] = "@(#)$Id: stab.c,v 8.40.16.2 2000/06/05 21:46:59 gshapiro Exp $"; +#endif /* ! lint */ -# include "sendmail.h" +#include <sendmail.h> /* ** STAB -- manage the symbol table @@ -35,7 +36,7 @@ static char sccsid[] = "@(#)stab.c 8.19 (Berkeley) 5/19/1998"; ** can update the symbol table. */ -# define STABSIZE 2003 +#define STABSIZE 2003 static STAB *SymTab[STABSIZE]; @@ -50,10 +51,9 @@ stab(name, type, op) register int hfunc; register char *p; int len; - extern char lower __P((char)); if (tTd(36, 5)) - printf("STAB: %s %d ", name, type); + dprintf("STAB: %s %d ", name, type); /* ** Compute the hashing function @@ -64,7 +64,7 @@ stab(name, type, op) hfunc = ((hfunc << 1) ^ (lower(*p) & 0377)) % STABSIZE; if (tTd(36, 9)) - printf("(hfunc=%d) ", hfunc); + dprintf("(hfunc=%d) ", hfunc); ps = &SymTab[hfunc]; if (type == ST_MACRO || type == ST_RULESET) @@ -89,16 +89,16 @@ stab(name, type, op) if (tTd(36, 5)) { if (s == NULL) - printf("not found\n"); + dprintf("not found\n"); else { long *lp = (long *) s->s_class; - printf("type %d val %lx %lx %lx %lx\n", + dprintf("type %d val %lx %lx %lx %lx\n", s->s_type, lp[0], lp[1], lp[2], lp[3]); } } - return (s); + return s; } /* @@ -106,10 +106,9 @@ stab(name, type, op) */ if (tTd(36, 5)) - printf("entered\n"); + dprintf("entered\n"); /* determine size of new entry */ -#if _FFR_MEMORY_MISER switch (type) { case ST_CLASS: @@ -122,6 +121,7 @@ stab(name, type, op) case ST_MAILER: len = sizeof s->s_mailer; + break; case ST_ALIAS: len = sizeof s->s_alias; @@ -151,15 +151,35 @@ stab(name, type, op) len = sizeof s->s_ruleset; break; + case ST_HEADER: + len = sizeof s->s_header; + break; + case ST_SERVICE: len = sizeof s->s_service; break; - case ST_HEADER: - len = sizeof s->s_header; +#ifdef LDAPMAP + case ST_LDAP: + len = sizeof s->s_ldap; break; +#endif /* LDAPMAP */ + +#if _FFR_MILTER + case ST_MILTER: + len = sizeof s->s_milter; + break; +#endif /* _FFR_MILTER */ default: + /* + ** Each mailer has it's own MCI stab entry: + ** + ** s = stab(host, ST_MCI + m->m_mno, ST_ENTER); + ** + ** Therefore, anything ST_MCI or larger is an s_mci. + */ + if (type >= ST_MCI) len = sizeof s->s_mci; else @@ -170,13 +190,13 @@ stab(name, type, op) break; } len += sizeof *s - sizeof s->s_value; -#else - len = sizeof *s; -#endif + + if (tTd(36, 15)) + dprintf("size of stab entry: %d\n", len); /* make new entry */ s = (STAB *) xalloc(len); - bzero((char *) s, len); + memset((char *) s, '\0', len); s->s_name = newstr(name); s->s_type = type; s->s_len = len; @@ -184,7 +204,11 @@ stab(name, type, op) /* link it in */ *ps = s; - return (s); + /* set a default value for rulesets */ + if (type == ST_RULESET) + s->s_ruleset = -1; + + return s; } /* ** STABAPPLY -- apply function to all stab entries @@ -211,9 +235,104 @@ stabapply(func, arg) for (s = *shead; s != NULL; s = s->s_next) { if (tTd(36, 90)) - printf("stabapply: trying %d/%s\n", + dprintf("stabapply: trying %d/%s\n", s->s_type, s->s_name); func(s, arg); } } } +/* +** QUEUEUP_MACROS -- queueup the macros in a class +** +** Write the macros listed in the specified class into the +** file referenced by qfp. +** +** Parameters: +** class -- class ID. +** qfp -- file pointer to the qf file. +** e -- the envelope. +** +** Returns: +** none. +*/ + +void +queueup_macros(class, qfp, e) + int class; + FILE *qfp; + ENVELOPE *e; +{ + register STAB **shead; + register STAB *s; + + if (e == NULL) + return; + + for (shead = SymTab; shead < &SymTab[STABSIZE]; shead++) + { + for (s = *shead; s != NULL; s = s->s_next) + { + int m; + char *p; + + if (s->s_type == ST_CLASS && + bitnset(class & 0xff, s->s_class) && + (m = macid(s->s_name, NULL)) != '\0' && + (p = macvalue(m, e)) != NULL) + { + /* + ** HACK ALERT: Unfortunately, 8.10 and + ** 8.11 reused the ${if_addr} and + ** ${if_family} macros for both the incoming + ** interface address/family (getrequests()) + ** and the outgoing interface address/family + ** (makeconnection()). In order for D_BINDIF + ** to work properly, have to preserve the + ** incoming information in the queue file for + ** later delivery attempts. The original + ** information is stored in the envelope + ** in readqf() so it can be stored in + ** queueup_macros(). This should be fixed + ** in 8.12. + */ + + if (e->e_if_macros[EIF_ADDR] != NULL && + strcmp(s->s_name, "{if_addr}") == 0) + p = e->e_if_macros[EIF_ADDR]; + + fprintf(qfp, "$%s%s\n", + s->s_name, + denlstring(p, TRUE, FALSE)); + } + } + } +} +/* +** COPY_CLASS -- copy class members from one class to another +** +** Parameters: +** src -- source class. +** dst -- destination class. +** +** Returns: +** none. +*/ + +void +copy_class(src, dst) + int src; + int dst; +{ + register STAB **shead; + register STAB *s; + + for (shead = SymTab; shead < &SymTab[STABSIZE]; shead++) + { + for (s = *shead; s != NULL; s = s->s_next) + { + if (s->s_type == ST_CLASS && + bitnset(src & 0xff, s->s_class)) + setbitn(dst, s->s_class); + } + } +} |