/* continue processing */ return SMFIS_CONTINUE;

}

sfsistat

mlfi_body(ctx, bodyp, bodylen) SMFICTX *ctx; u_char *bodyp; size_t bodylen;

{

/* output body block to log file */

if (fwrite(bodyp, bodylen, 1, MLFIPRIV->mlfi_fp) <= 0)

{

/* write failed */

(void) mlfi_cleanup(ctx, false); return SMFIS_TEMPFAIL;

}

/* continue processing */ return SMFIS_CONTINUE;

}

sfsistat

mlfi_eom(ctx)

SMFICTX *ctx;

{

return mlfi_cleanup(ctx,true);

}

Sfsistat

mlfi_close(ctx) SMFICTX *ctx;

{

return SMFIS_ACCEPT;

}

sfsistat

mlfi_abort(ctx) SMFICTX *ctx;

{

return mlfi_cleanup(ctx, false);

}

sfsistat

mlfi_cleanup(ctx,ok) SMFICTX *ctx; bool ok;

{

sfsistat rstat = SMFIS_CONTINUE; struct mlfiPriv *priv = MLFIPRIV; char *p;

char host[512]; char hbuf[1024];

if (priv == NULL) return rstat;

/* close the archive file */

if (priv->mlfi_fp != NULL && fclose(priv->mlfi_fp)== EOF)

{

/* failed; we have to wait until later */ rstat = SMFIS_TEMPFAIL;

(void) unlink(priv->mlfi_fname);

}

else if (ok)

{

/* add a header to the message announcing our presence

*/if (gethostname(host, sizeof host) < 0) snprintf(host, sizeof host, "localhost");

p = strrchr(priv->mlfi_fname, '/'); if (p == NULL)

p = priv->mlfi_fname;

else

p++;

snprintf(hbuf, sizeof hbuf, "%s@%s", p, host); smfi_addheader(ctx,"X-Archived", hbuf);

}

else

{

/* message was aborted -- delete the archive file */ (void) unlink(priv->mlfi_fname);

}

/* release private memory */ free(priv->mlfi_fname); free(priv); smfi_setpriv(ctx, NULL);

/* return status */ return rstat;

}

struct smfiDesc smfilter =

270 Sendmail Supplemental Information