/*
* Copyright (c) 1998-2001, 2003 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.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sendmail.h>
/*
** STAB -- manage the symbol table
**
** Parameters:
** name -- the name to be looked up or inserted.
** type -- the type of symbol.
** op -- what to do:
** ST_ENTER -- enter the name if not already present.
** ST_FIND -- find it only.
**
** Returns:
** pointer to a STAB entry for this name.
** NULL if not found and not entered.
**
** Side Effects:
** can update the symbol table.
*/
STAB *
char *name;
int type;
int op;
{
register STAB *s;
register int hfunc;
register char *p;
int len;
/*
** Compute the hashing function
*/
for (p = name; *p != '\0'; p++)
{
}
else
{
}
/*
** Dispose of the entry.
*/
{
{
if (s == NULL)
sm_dprintf("not found\n");
else
{
sm_dprintf("type %d val %lx %lx %lx %lx\n",
}
}
return s;
}
/*
** Make a new entry and link it in.
*/
sm_dprintf("entered\n");
/* determine size of new entry */
switch (type)
{
case ST_CLASS:
break;
case ST_ADDRESS:
break;
case ST_MAILER:
break;
case ST_ALIAS:
break;
case ST_MAPCLASS:
len = sizeof(s->s_mapclass);
break;
case ST_MAP:
break;
case ST_HOSTSIG:
break;
case ST_NAMECANON:
len = sizeof(s->s_namecanon);
break;
case ST_MACRO:
break;
case ST_RULESET:
break;
case ST_HEADER:
break;
case ST_SERVICE:
break;
#if LDAPMAP
case ST_LMAP:
break;
#endif /* LDAPMAP */
#if MILTER
case ST_MILTER:
break;
#endif /* MILTER */
case ST_QUEUE:
break;
#if SOCKETMAP
case ST_SOCKETMAP:
len = sizeof(s->s_socketmap);
break;
#endif /* SOCKETMAP */
default:
/*
** Each mailer has its own MCI stab entry:
**
** s = stab(host, ST_MCI + m->m_mno, ST_ENTER);
**
** Therefore, anything ST_MCI or larger is an s_mci.
*/
else
{
}
break;
}
/* make new entry */
/* link it in */
*ps = s;
/* set a default value for rulesets */
if (type == ST_RULESET)
s->s_ruleset = -1;
return s;
}
/*
** STABAPPLY -- apply function to all stab entries
**
** Parameters:
** func -- the function to apply. It will be given two
** parameters (the stab entry and the arg).
** arg -- an arbitrary argument, passed to func.
**
** Returns:
** none.
*/
void
int arg;
{
register STAB *s;
{
{
sm_dprintf("stabapply: trying %d/%s\n",
}
}
}
/*
** 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 queue file.
** e -- the envelope.
**
** Returns:
** none.
*/
void
int class;
ENVELOPE *e;
{
register STAB *s;
if (e == NULL)
return;
{
{
int m;
char *p;
{
"$%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
int src;
int dst;
{
register STAB *s;
{
{
}
}
}
/*
** RMEXPSTAB -- remove expired entries from SymTab.
**
** These entries need to be removed in long-running processes,
** e.g., persistent queue runners, to avoid consuming memory.
**
** XXX It might be useful to restrict the maximum TTL to avoid
** caching data very long.
**
** Parameters:
** none.
**
** Returns:
** none.
**
** Side Effects:
** can remove entries from the symbol table.
*/
#define SM_STAB_FREE(x) \
do \
{ \
char *o = (x); \
(x) = NULL; \
if (o != NULL) \
sm_free(o); \
} while (0)
void
{
int i;
STAB *s, *p, *f;
for (i = 0; i < STABSIZE; i++)
{
p = NULL;
s = SymTab[i];
while (s != NULL)
{
switch (s->s_symtype)
{
case ST_HOSTSIG:
goto next; /* not expired */
break;
case ST_NAMECANON:
goto next; /* not expired */
break;
default:
{
/* call mci_uncache? */
#if 0
/* not dynamically allocated */
#endif /* 0 */
#if SASL
/* should always by NULL */
#endif /* SASL */
{
}
break;
}
next:
p = s;
s = s->s_next;
continue;
}
/* remove entry */
f = s;
s = s->s_next;
sm_free(f); /* XXX */
if (p == NULL)
SymTab[i] = s;
else
p->s_next = s;
}
}
}
#if SM_HEAP_CHECK
/*
** DUMPSTAB -- dump symbol table.
**
** For debugging.
*/
void
dumpstab()
{
STAB *s;
total = 0;
for (i = 0; i < MAXSTTYPES; i++)
types[i] = 0;
for (i = 0; i < STABSIZE; i++)
{
s = SymTab[i];
while (s != NULL)
{
++total;
t = s->s_symtype;
if (t > MAXSTTYPES - 1)
t = MAXSTTYPES - 1;
types[t]++;
s = s->s_next;
}
}
for (i = 0; i < MAXSTTYPES; i++)
{
if (types[i] != 0)
{
}
}
}
#endif /* SM_HEAP_CHECK */