Sendmail 8.13.3 Programmer's Guide

Sample Program
Milter Sample Program
Chapter 5 65
struct mlfiPriv *priv;
char *ident;
/* allocate some private memory */
priv = malloc(sizeof *priv);
if (priv == NULL)
{
/* can’t accept this message right now */
return SMFIS_TEMPFAIL;
}
memset(priv, ’\0’, sizeof *priv);
/* save the private data */
smfi_setpriv(ctx, priv);
ident = smfi_getsymval(ctx, "_");
if (ident == NULL)
ident = "???";
if ((priv->mlfi_connectfrom = strdup(ident)) == NULL)
{
(void) mlfi_cleanup(ctx, FALSE);
return SMFIS_TEMPFAIL;
}
/* continue processing */
return SMFIS_CONTINUE;
}
sfsistat
mlfi_helo(ctx, helohost)
SMFICTX *ctx;
char *helohost;
{
size_t len;
char *tls;
char *buf;
struct mlfiPriv *priv = MLFIPRIV;
tls = smfi_getsymval(ctx, "{tls_version}");
if (tls == NULL)
tls = "No TLS";
if (helohost == NULL)
helohost = "???";
len = strlen(tls) + strlen(helohost) + 3;
if ((buf = (char*) malloc(len)) == NULL)
{