/*
 * Copyright (c) 2005, 2006 Sendmail, Inc. and its suppliers.
 *	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.
 *
 * $Id: pmilter.h,v 1.13 2007/02/13 03:58:24 ca Exp $
 */

#ifndef PMILTER_H
#define PMILTER_H 1
#include "sm/generic.h"

#if MTA_USE_PMILTER

sm_ret_T sspm_helo(ss_sess_P _ss_sess, bool _ehlo);
sm_ret_T sspm_mail(ss_sess_P _ss_sess, sm_ret_T _cur_status, uint _argoffset);
sm_ret_T sspm_rcpt(ss_sess_P _ss_sess, ss_rcpt_P _ss_rcpt, sm_ret_T _cur_status);
sm_ret_T sspm_data(ss_sess_P _ss_sess, bool *_pskip);
sm_ret_T sspm_msg(ss_sess_P _ss_sess, uchar *_bufp, size_t _bytes2write, bool _isrcvd, bool *_pskip);
sm_ret_T sspm_eob(ss_sess_P _ss_sess, uchar *_bufp, size_t _bytes2write, bool *_pskip);

# if MTA_USE_RSAD
sm_ret_T sspm_clrreplies(ss_ta_P _ss_ta);
# else
#  define sspm_clrreplies(_ss_ta)
# endif

/*
**  When to try again to reconnect to pmilter?
**  Note: this access "ret" directly! Should there be more error conditions
**  in which a reconnect is tried? Whenever a new error code is introduced
**  this macro must be extended which isn't very maintainable.
*/

#define SSPM_TRY_AGAIN(ss_ctx, ss_sess)					\
	do {								\
		if ((sm_error_temp(SM_EM_SMTPS, EIO) == ret ||		\
		     sm_error_temp(SM_EM_SMTPS, SM_E_WRONG_ID) == ret || \
		     sm_error_temp(SM_EM_SMTPS, SM_E_CONN_CLSD) == ret) && \
		    SSC_IS_MFLAG((ss_ctx), SSC_MFL_PM_421|SSC_MFL_PM_AGAIN) && \
		    !SSC_IS_FLAG((ss_ctx), SSC_FL_PM_TRYCONN) &&	\
		    !SSC_IS_FLAG((ss_ctx), SSC_FL_PM_TRYING))		\
		{							\
			SSC_SET_FLAG((ss_ctx), SSC_FL_PM_TRYCONN);	\
			SSC_CLR_FLAG((ss_ctx), SSC_FL_PM_USE);		\
			sm_log_write(ss_ctx->ssc_lctx,			\
				SS_LCAT_SERVER, SS_LMOD_SERVER,		\
				SM_LOG_DEBUG, 10,			\
				"sev=DBG, ss_sess=%s, status=set_tryconn2milt" \
				, ss_sess->ssse_id);			\
		}							\
	} while (0)

/*
 * deferred rcpt reply: remove
 * see include/sm/pmfdef.h, PM_RCPT_*
 */
#define PM_RCPT_RSAD	0x04

#endif /* MTA_USE_PMILTER */

#endif /* PMILTER_H */


syntax highlighted by Code2HTML, v. 0.9.1