/*
 * Copyright (c) 2004-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: smreplycodes.h,v 1.11 2007/02/04 17:48:37 ca Exp $
 */

#ifndef SM_SMREPLYCODES_H
#define SM_SMREPLYCODES_H 1

/*
**  SMTP reply codes.
**  These are also used as return values from policy/mail filters.
**
**  Some of the return values are outside the SMTP reply code;
**  is there a better way to return different OK codes?
*/

#define SMTP_R_OK	0	/* accept this command */
#define SMTP_R_RELAY	8	/* allow relaying */
#define SMTP_R_DISCARD	90	/* discard entity (other code?) */
/* #define SMTP_R_TXT	100	 * check the error text */
/* #define SMTP_R_ACC	250 */
#define SMTP_R_D_RCPT	352	/* defer RCPT status */
#define SMTP_R_D_EOM	353	/* defer end of mail data status */
/* #define SMTP_R_DUNNO	SMTP_R_CONT unused */
#define SMTP_R_RPLCMSG	390	/* replace msg */
#define SMTP_R_SKIP	395	/* skip rest of message/"same type" (milter) */
#define SMTP_R_CONT	399	/* CONTinue */
#define SMTP_R_SSD	421	/* Session Shutting Down */
#define SMTP_R_TEMP	450
#define SMTP_R_SYNTAX	551
#define SMTP_R_REJECT	550
#define SMTP_R_PERM	SMTP_R_REJECT

/*
**  A result from SMAR/pmilter can return additional flags,
**  the lower 16 bits are reserved for a "normal" return value.
**  Note: these values MUST be coordinated with sm/smar.h!
*/

#define SMTP_R_QUICK	0x00010000	/* "QUICK" flag */
#define SMTP_R_GREY	0x00080000	/* "GREY" flag */
#define SMTP_R_GREYCHKD	0x00100000	/* grey check has been done */

/* set QUICK flag */
#define SMTP_R_SET_QUICK(ret)	((ret) | SMTP_R_QUICK)
#define SMTP_R_SET_GREY(ret)	((ret) | SMTP_R_GREY)

/* accept entire session/transaction, disable subsequent checks */
#define SMTP_R_ACCEPT	SMTP_R_SET_QUICK(SMTP_R_OK)

#define IS_SMTP_CODE(buf, off)	\
	(((buf[off] == '2') || (buf[off] == '4') || (buf[off] == '5')) \
	&& (buf[(off)+1] >= '0') && (buf[(off)+1] <= '9')	\
	&& (buf[(off)+2] >= '0') && (buf[(off)+2] <= '9'))

#endif /* SM_SMREPLYCODES_H */


syntax highlighted by Code2HTML, v. 0.9.1