17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Copyright (c) 1999-2004 Sendmail, Inc. and its suppliers.
37c478bd9Sstevel@tonic-gate  *	All rights reserved.
47c478bd9Sstevel@tonic-gate  *
57c478bd9Sstevel@tonic-gate  * By using this file, you agree to the terms and conditions set
67c478bd9Sstevel@tonic-gate  * forth in the LICENSE file which can be found at the top level of
77c478bd9Sstevel@tonic-gate  * the sendmail distribution.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  *
10*3ee0e492Sjbeck  *	$Id: mfapi.h,v 8.61 2006/05/04 17:02:01 ca Exp $
117c478bd9Sstevel@tonic-gate  */
127c478bd9Sstevel@tonic-gate 
137c478bd9Sstevel@tonic-gate /*
147c478bd9Sstevel@tonic-gate  *  MFAPI.H -- Global definitions for mail filter library and mail filters.
157c478bd9Sstevel@tonic-gate  */
167c478bd9Sstevel@tonic-gate 
177c478bd9Sstevel@tonic-gate #ifndef	_LIBMILTER_MFAPI_H
187c478bd9Sstevel@tonic-gate #define	_LIBMILTER_MFAPI_H
197c478bd9Sstevel@tonic-gate 
207c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
217c478bd9Sstevel@tonic-gate 
227c478bd9Sstevel@tonic-gate #ifdef __cplusplus
237c478bd9Sstevel@tonic-gate extern "C" {
247c478bd9Sstevel@tonic-gate #endif
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef SMFI_VERSION
277c478bd9Sstevel@tonic-gate #define	SMFI_VERSION	2		/* version number */
287c478bd9Sstevel@tonic-gate #endif /* ! SMFI_VERSION */
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #include <sys/types.h>
317c478bd9Sstevel@tonic-gate #include <sys/socket.h>
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <libmilter/mfdef.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #define	LIBMILTER_API		extern
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifndef _SOCK_ADDR
387c478bd9Sstevel@tonic-gate #define	_SOCK_ADDR	struct sockaddr
397c478bd9Sstevel@tonic-gate #endif /* ! _SOCK_ADDR */
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /*
427c478bd9Sstevel@tonic-gate  *  libmilter functions return one of the following to indicate
437c478bd9Sstevel@tonic-gate  *  success/failure:
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #define	MI_SUCCESS	0
477c478bd9Sstevel@tonic-gate #define	MI_FAILURE	(-1)
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /* "forward" declarations */
507c478bd9Sstevel@tonic-gate typedef struct smfi_str SMFICTX;
517c478bd9Sstevel@tonic-gate typedef struct smfi_str *SMFICTX_PTR;
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate typedef struct smfiDesc smfiDesc_str;
547c478bd9Sstevel@tonic-gate typedef struct smfiDesc	*smfiDesc_ptr;
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  *  Type which callbacks should return to indicate message status.
587c478bd9Sstevel@tonic-gate  *  This may take on one of the SMFIS_* values listed below.
597c478bd9Sstevel@tonic-gate  */
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate typedef int	sfsistat;
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate #if defined(__linux__) && defined(__GNUC__) && defined(__cplusplus) && \
647c478bd9Sstevel@tonic-gate 	__GNUC_MINOR__ >= 8
657c478bd9Sstevel@tonic-gate #define	SM__P(X)	__PMT(X)
667c478bd9Sstevel@tonic-gate #else /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */
677c478bd9Sstevel@tonic-gate #define	SM__P(X)	__P(X)
687c478bd9Sstevel@tonic-gate #endif /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /* Some platforms don't define __P -- do it for them here: */
717c478bd9Sstevel@tonic-gate #ifndef __P
727c478bd9Sstevel@tonic-gate #ifdef __STDC__
737c478bd9Sstevel@tonic-gate #define	__P(X) X
747c478bd9Sstevel@tonic-gate #else /* __STDC__ */
757c478bd9Sstevel@tonic-gate #define	__P(X) ()
767c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
777c478bd9Sstevel@tonic-gate #endif /* __P */
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate #if SM_CONF_STDBOOL_H
807c478bd9Sstevel@tonic-gate #include <stdbool.h>
817c478bd9Sstevel@tonic-gate #else /* SM_CONF_STDBOOL_H */
827c478bd9Sstevel@tonic-gate #ifndef __cplusplus
837c478bd9Sstevel@tonic-gate #ifndef bool
847c478bd9Sstevel@tonic-gate #ifndef __bool_true_false_are_defined
857c478bd9Sstevel@tonic-gate typedef int	bool;
867c478bd9Sstevel@tonic-gate #define	__bool_true_false_are_defined	1
877c478bd9Sstevel@tonic-gate #endif /* ! __bool_true_false_are_defined */
887c478bd9Sstevel@tonic-gate #endif /* bool */
897c478bd9Sstevel@tonic-gate #endif /* ! __cplusplus */
907c478bd9Sstevel@tonic-gate #endif /* SM_CONF_STDBOOL_H */
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate /*
937c478bd9Sstevel@tonic-gate  *  structure describing one milter
947c478bd9Sstevel@tonic-gate  */
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate struct smfiDesc
977c478bd9Sstevel@tonic-gate {
987c478bd9Sstevel@tonic-gate 	char		*xxfi_name;	/* filter name */
997c478bd9Sstevel@tonic-gate 	int		xxfi_version;	/* version code -- do not change */
1007c478bd9Sstevel@tonic-gate 	unsigned long	xxfi_flags;	/* flags */
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate 	/* connection info filter */
1037c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_connect) SM__P((SMFICTX *, char *,
1047c478bd9Sstevel@tonic-gate 						_SOCK_ADDR *));
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate 	/* SMTP HELO command filter */
1077c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_helo) SM__P((SMFICTX *, char *));
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate 	/* envelope sender filter */
1107c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_envfrom) SM__P((SMFICTX *, char **));
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate 	/* envelope recipient filter */
1137c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_envrcpt) SM__P((SMFICTX *, char **));
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate 	/* header filter */
1167c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_header) SM__P((SMFICTX *, char *, char *));
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate 	/* end of header */
1197c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_eoh) SM__P((SMFICTX *));
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate 	/* body block */
1227c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_body) SM__P((SMFICTX *, unsigned char *,
1237c478bd9Sstevel@tonic-gate 						size_t));
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate 	/* end of message */
1267c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_eom) SM__P((SMFICTX *));
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate 	/* message aborted */
1297c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_abort) SM__P((SMFICTX *));
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate 	/* connection cleanup */
1327c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_close) SM__P((SMFICTX *));
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate #if SMFI_VERSION > 2
1357c478bd9Sstevel@tonic-gate 	/* any unrecognized or unimplemented command filter */
1367c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_unknown) SM__P((SMFICTX *, char *));
1377c478bd9Sstevel@tonic-gate #endif /* SMFI_VERSION > 2 */
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate #if SMFI_VERSION > 3
140*3ee0e492Sjbeck 	/* SMTP DATA command filter */
1417c478bd9Sstevel@tonic-gate 	sfsistat	(*xxfi_data) SM__P((SMFICTX *));
1427c478bd9Sstevel@tonic-gate #endif /* SMFI_VERSION > 3 */
1437c478bd9Sstevel@tonic-gate };
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_opensocket __P((bool));
1467c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_register __P((struct smfiDesc));
1477c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_main __P((void));
1487c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_setbacklog __P((int));
1497c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_setdbg __P((int));
1507c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_settimeout __P((int));
1517c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_setconn __P((char *));
1527c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_stop __P((void));
1537c478bd9Sstevel@tonic-gate #if _FFR_MAXDATASIZE
1547c478bd9Sstevel@tonic-gate LIBMILTER_API size_t smfi_setmaxdatasize __P((size_t));
1557c478bd9Sstevel@tonic-gate #endif /* _FFR_MAXDATASIZE */
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate /*
1587c478bd9Sstevel@tonic-gate  *  What the filter might do -- values to be ORed together for
1597c478bd9Sstevel@tonic-gate  *  smfiDesc.xxfi_flags.
1607c478bd9Sstevel@tonic-gate  */
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate #define	SMFIF_NONE	0x00000000L	/* no flags */
1637c478bd9Sstevel@tonic-gate #define	SMFIF_ADDHDRS	0x00000001L	/* filter may add headers */
1647c478bd9Sstevel@tonic-gate #define	SMFIF_CHGBODY	0x00000002L	/* filter may replace body */
1657c478bd9Sstevel@tonic-gate #define	SMFIF_MODBODY	SMFIF_CHGBODY	/* backwards compatible */
1667c478bd9Sstevel@tonic-gate #define	SMFIF_ADDRCPT	0x00000004L	/* filter may add recipients */
1677c478bd9Sstevel@tonic-gate #define	SMFIF_DELRCPT	0x00000008L	/* filter may delete recipients */
1687c478bd9Sstevel@tonic-gate #define	SMFIF_CHGHDRS	0x00000010L	/* filter may change/delete headers */
1697c478bd9Sstevel@tonic-gate #define	SMFIF_QUARANTINE 0x00000020L	/* filter may quarantine envelope */
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate /*
1727c478bd9Sstevel@tonic-gate  *  Continue processing message/connection.
1737c478bd9Sstevel@tonic-gate  */
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate #define	SMFIS_CONTINUE	0
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate /*
1787c478bd9Sstevel@tonic-gate  *  Reject the message/connection.
1797c478bd9Sstevel@tonic-gate  *  No further routines will be called for this message
1807c478bd9Sstevel@tonic-gate  *  (or connection, if returned from a connection-oriented routine).
1817c478bd9Sstevel@tonic-gate  */
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate #define	SMFIS_REJECT	1
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate /*
1867c478bd9Sstevel@tonic-gate  *  Accept the message,
1877c478bd9Sstevel@tonic-gate  *  but silently discard the message.
1887c478bd9Sstevel@tonic-gate  *  No further routines will be called for this message.
1897c478bd9Sstevel@tonic-gate  *  This is only meaningful from message-oriented routines.
1907c478bd9Sstevel@tonic-gate  */
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate #define	SMFIS_DISCARD	2
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate /*
1957c478bd9Sstevel@tonic-gate  *  Accept the message/connection.
1967c478bd9Sstevel@tonic-gate  *  No further routines will be called for this message
1977c478bd9Sstevel@tonic-gate  *  (or connection, if returned from a connection-oriented routine;
1987c478bd9Sstevel@tonic-gate  *  in this case, it causes all messages on this connection
1997c478bd9Sstevel@tonic-gate  *  to be accepted without filtering).
2007c478bd9Sstevel@tonic-gate  */
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate #define	SMFIS_ACCEPT	3
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate /*
2057c478bd9Sstevel@tonic-gate  *  Return a temporary failure, i.e.,
2067c478bd9Sstevel@tonic-gate  *  the corresponding SMTP command will return a 4xx status code.
2077c478bd9Sstevel@tonic-gate  *  In some cases this may prevent further routines from
2087c478bd9Sstevel@tonic-gate  *  being called on this message or connection,
2097c478bd9Sstevel@tonic-gate  *  although in other cases (e.g., when processing an envelope
2107c478bd9Sstevel@tonic-gate  *  recipient) processing of the message will continue.
2117c478bd9Sstevel@tonic-gate  */
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate #define	SMFIS_TEMPFAIL	4
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate #if 0
2167c478bd9Sstevel@tonic-gate /*
2177c478bd9Sstevel@tonic-gate  *  Filter Routine Details
2187c478bd9Sstevel@tonic-gate  */
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate /* connection info filter */
2217c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_connect __P((SMFICTX *, char *, _SOCK_ADDR *));
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate /*
2247c478bd9Sstevel@tonic-gate  *  xxfi_connect(ctx, hostname, hostaddr) Invoked on each connection
2257c478bd9Sstevel@tonic-gate  *
2267c478bd9Sstevel@tonic-gate  *	char *hostname; Host domain name, as determined by a reverse lookup
2277c478bd9Sstevel@tonic-gate  *		on the host address.
2287c478bd9Sstevel@tonic-gate  *	_SOCK_ADDR *hostaddr; Host address, as determined by a getpeername
2297c478bd9Sstevel@tonic-gate  *		call on the SMTP socket.
2307c478bd9Sstevel@tonic-gate  */
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate /* SMTP HELO command filter */
2337c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_helo __P((SMFICTX *, char *));
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate /*
2367c478bd9Sstevel@tonic-gate  *  xxfi_helo(ctx, helohost) Invoked on SMTP HELO/EHLO command
2377c478bd9Sstevel@tonic-gate  *
2387c478bd9Sstevel@tonic-gate  *	char *helohost; Value passed to HELO/EHLO command, which should be
2397c478bd9Sstevel@tonic-gate  *		the domain name of the sending host (but is, in practice,
2407c478bd9Sstevel@tonic-gate  *		anything the sending host wants to send).
2417c478bd9Sstevel@tonic-gate  */
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate /* envelope sender filter */
2447c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_envfrom __P((SMFICTX *, char **));
2457c478bd9Sstevel@tonic-gate 
2467c478bd9Sstevel@tonic-gate /*
2477c478bd9Sstevel@tonic-gate  *  xxfi_envfrom(ctx, argv) Invoked on envelope from
2487c478bd9Sstevel@tonic-gate  *
2497c478bd9Sstevel@tonic-gate  *	char **argv; Null-terminated SMTP command arguments;
2507c478bd9Sstevel@tonic-gate  *		argv[0] is guaranteed to be the sender address.
2517c478bd9Sstevel@tonic-gate  *		Later arguments are the ESMTP arguments.
2527c478bd9Sstevel@tonic-gate  */
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate /* envelope recipient filter */
2557c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_envrcpt __P((SMFICTX *, char **));
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate /*
2587c478bd9Sstevel@tonic-gate  *  xxfi_envrcpt(ctx, argv) Invoked on each envelope recipient
2597c478bd9Sstevel@tonic-gate  *
2607c478bd9Sstevel@tonic-gate  *	char **argv; Null-terminated SMTP command arguments;
2617c478bd9Sstevel@tonic-gate  *		argv[0] is guaranteed to be the recipient address.
2627c478bd9Sstevel@tonic-gate  *		Later arguments are the ESMTP arguments.
2637c478bd9Sstevel@tonic-gate  */
2647c478bd9Sstevel@tonic-gate 
2657c478bd9Sstevel@tonic-gate /* unknown command filter */
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate extern sfsistat	*xxfi_unknown __P((SMFICTX *, char *));
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate /*
2707c478bd9Sstevel@tonic-gate  *  xxfi_unknown(ctx, arg) Invoked when SMTP command is not recognized or not
2717c478bd9Sstevel@tonic-gate  *  implemented.
2727c478bd9Sstevel@tonic-gate  *	char *arg; Null-terminated SMTP command
2737c478bd9Sstevel@tonic-gate  */
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate /* header filter */
2767c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_header __P((SMFICTX *, char *, char *));
2777c478bd9Sstevel@tonic-gate 
2787c478bd9Sstevel@tonic-gate /*
2797c478bd9Sstevel@tonic-gate  *  xxfi_header(ctx, headerf, headerv) Invoked on each message header. The
2807c478bd9Sstevel@tonic-gate  *  content of the header may have folded white space (that is, multiple
2817c478bd9Sstevel@tonic-gate  *  lines with following white space) included.
2827c478bd9Sstevel@tonic-gate  *
2837c478bd9Sstevel@tonic-gate  *	char *headerf; Header field name
2847c478bd9Sstevel@tonic-gate  *	char *headerv; Header field value
2857c478bd9Sstevel@tonic-gate  */
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate /* end of header */
2887c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_eoh __P((SMFICTX *));
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate /*
2917c478bd9Sstevel@tonic-gate  *  xxfi_eoh(ctx) Invoked at end of header
2927c478bd9Sstevel@tonic-gate  */
2937c478bd9Sstevel@tonic-gate 
2947c478bd9Sstevel@tonic-gate /* body block */
2957c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_body __P((SMFICTX *, unsigned char *, size_t));
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate /*
2987c478bd9Sstevel@tonic-gate  *  xxfi_body(ctx, bodyp, bodylen) Invoked for each body chunk. There may
2997c478bd9Sstevel@tonic-gate  *  be multiple body chunks passed to the filter. End-of-lines are
3007c478bd9Sstevel@tonic-gate  *  represented as received from SMTP (normally Carriage-Return/Line-Feed).
3017c478bd9Sstevel@tonic-gate  *
3027c478bd9Sstevel@tonic-gate  *	unsigned char *bodyp; Pointer to body data
3037c478bd9Sstevel@tonic-gate  *	size_t bodylen; Length of body data
3047c478bd9Sstevel@tonic-gate  */
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate /* end of message */
3077c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_eom __P((SMFICTX *));
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate /*
3107c478bd9Sstevel@tonic-gate  *  xxfi_eom(ctx) Invoked at end of message. This routine can perform
3117c478bd9Sstevel@tonic-gate  *  special operations such as modifying the message header, body, or
3127c478bd9Sstevel@tonic-gate  *  envelope.
3137c478bd9Sstevel@tonic-gate  */
3147c478bd9Sstevel@tonic-gate 
3157c478bd9Sstevel@tonic-gate /* message aborted */
3167c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_abort __P((SMFICTX *));
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate /*
3197c478bd9Sstevel@tonic-gate  *  xxfi_abort(ctx) Invoked if message is aborted outside of the control of
3207c478bd9Sstevel@tonic-gate  *  the filter, for example, if the SMTP sender issues an RSET command. If
3217c478bd9Sstevel@tonic-gate  *  xxfi_abort is called, xxfi_eom will not be called and vice versa.
3227c478bd9Sstevel@tonic-gate  */
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate /* connection cleanup */
3257c478bd9Sstevel@tonic-gate extern sfsistat	xxfi_close __P((SMFICTX *));
3267c478bd9Sstevel@tonic-gate 
3277c478bd9Sstevel@tonic-gate /*
3287c478bd9Sstevel@tonic-gate  *  xxfi_close(ctx) Invoked at end of the connection. This is called on
3297c478bd9Sstevel@tonic-gate  *  close even if the previous mail transaction was aborted.
3307c478bd9Sstevel@tonic-gate  */
3317c478bd9Sstevel@tonic-gate #endif /* 0 */
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate /*
3347c478bd9Sstevel@tonic-gate  *  Additional information is passed in to the vendor filter routines using
3357c478bd9Sstevel@tonic-gate  *  symbols. Symbols correspond closely to sendmail macros. The symbols
3367c478bd9Sstevel@tonic-gate  *  defined depend on the context. The value of a symbol is accessed using:
3377c478bd9Sstevel@tonic-gate  */
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate /* Return the value of a symbol. */
3407c478bd9Sstevel@tonic-gate LIBMILTER_API char *smfi_getsymval __P((SMFICTX *, char *));
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate /*
3437c478bd9Sstevel@tonic-gate  *  Return the value of a symbol.
3447c478bd9Sstevel@tonic-gate  *
3457c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
3467c478bd9Sstevel@tonic-gate  *	char *symname; The name of the symbol to access.
3477c478bd9Sstevel@tonic-gate  */
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate /*
3507c478bd9Sstevel@tonic-gate  *  Vendor filter routines that want to pass additional information back to
3517c478bd9Sstevel@tonic-gate  *  the MTA for use in SMTP replies may call smfi_setreply before returning.
3527c478bd9Sstevel@tonic-gate  */
3537c478bd9Sstevel@tonic-gate 
3547c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_setreply __P((SMFICTX *, char *, char *, char *));
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate /*
3577c478bd9Sstevel@tonic-gate  *  Alternatively, smfi_setmlreply can be called if a multi-line SMTP reply
3587c478bd9Sstevel@tonic-gate  *  is needed.
3597c478bd9Sstevel@tonic-gate  */
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_setmlreply __P((SMFICTX *, const char *, const char *,
3627c478bd9Sstevel@tonic-gate 					...));
3637c478bd9Sstevel@tonic-gate 
3647c478bd9Sstevel@tonic-gate /*
3657c478bd9Sstevel@tonic-gate  *  Set the specific reply code to be used in response to the active
3667c478bd9Sstevel@tonic-gate  *  command. If not specified, a generic reply code is used.
3677c478bd9Sstevel@tonic-gate  *
3687c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
3697c478bd9Sstevel@tonic-gate  *	char *rcode; The three-digit (RFC 821) SMTP reply code to be
3707c478bd9Sstevel@tonic-gate  *		returned, e.g., ``551''.
3717c478bd9Sstevel@tonic-gate  *	char *xcode; The extended (RFC 2034) reply code, e.g., ``5.7.6''.
3727c478bd9Sstevel@tonic-gate  *	char *message; The text part of the SMTP reply.
3737c478bd9Sstevel@tonic-gate  */
3747c478bd9Sstevel@tonic-gate 
3757c478bd9Sstevel@tonic-gate /*
3767c478bd9Sstevel@tonic-gate  *  The xxfi_eom routine is called at the end of a message (essentially,
3777c478bd9Sstevel@tonic-gate  *  after the final DATA dot). This routine can call some special routines
3787c478bd9Sstevel@tonic-gate  *  to modify the envelope, header, or body of the message before the
3797c478bd9Sstevel@tonic-gate  *  message is enqueued. These routines must not be called from any vendor
3807c478bd9Sstevel@tonic-gate  *  routine other than xxfi_eom.
3817c478bd9Sstevel@tonic-gate  */
3827c478bd9Sstevel@tonic-gate 
3837c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_addheader __P((SMFICTX *, char *, char *));
3847c478bd9Sstevel@tonic-gate 
3857c478bd9Sstevel@tonic-gate /*
3867c478bd9Sstevel@tonic-gate  *  Add a header to the message. It is not checked for standards
3877c478bd9Sstevel@tonic-gate  *  compliance; the mail filter must ensure that no protocols are violated
3887c478bd9Sstevel@tonic-gate  *  as a result of adding this header.
3897c478bd9Sstevel@tonic-gate  *
3907c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
3917c478bd9Sstevel@tonic-gate  *	char *headerf; Header field name
3927c478bd9Sstevel@tonic-gate  *	char *headerv; Header field value
3937c478bd9Sstevel@tonic-gate  */
3947c478bd9Sstevel@tonic-gate 
3957c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_chgheader __P((SMFICTX *, char *, int, char *));
3967c478bd9Sstevel@tonic-gate 
3977c478bd9Sstevel@tonic-gate /*
3987c478bd9Sstevel@tonic-gate  *  Change/delete a header in the message.  It is not checked for standards
3997c478bd9Sstevel@tonic-gate  *  compliance; the mail filter must ensure that no protocols are violated
4007c478bd9Sstevel@tonic-gate  *  as a result of adding this header.
4017c478bd9Sstevel@tonic-gate  *
4027c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
4037c478bd9Sstevel@tonic-gate  *	char *headerf; Header field name
4047c478bd9Sstevel@tonic-gate  *	int index; The Nth occurence of header field name
4057c478bd9Sstevel@tonic-gate  *	char *headerv; New header field value (empty for delete header)
4067c478bd9Sstevel@tonic-gate  */
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_insheader __P((SMFICTX *, int, char *, char *));
4097c478bd9Sstevel@tonic-gate 
4107c478bd9Sstevel@tonic-gate /*
4117c478bd9Sstevel@tonic-gate  *  Insert a header into the message.  It is not checked for standards
4127c478bd9Sstevel@tonic-gate  *  compliance; the mail filter must ensure that no protocols are violated
4137c478bd9Sstevel@tonic-gate  *  as a result of adding this header.
4147c478bd9Sstevel@tonic-gate  *
4157c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
4167c478bd9Sstevel@tonic-gate  *  	int idx; index into the header list where the insertion should happen
4177c478bd9Sstevel@tonic-gate  *	char *headerh; Header field name
4187c478bd9Sstevel@tonic-gate  *	char *headerv; Header field value
4197c478bd9Sstevel@tonic-gate  */
4207c478bd9Sstevel@tonic-gate 
4217c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_addrcpt __P((SMFICTX *, char *));
4227c478bd9Sstevel@tonic-gate 
4237c478bd9Sstevel@tonic-gate /*
4247c478bd9Sstevel@tonic-gate  *  Add a recipient to the envelope
4257c478bd9Sstevel@tonic-gate  *
4267c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
4277c478bd9Sstevel@tonic-gate  *	char *rcpt; Recipient to be added
4287c478bd9Sstevel@tonic-gate  */
4297c478bd9Sstevel@tonic-gate 
4307c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_delrcpt __P((SMFICTX *, char *));
4317c478bd9Sstevel@tonic-gate 
4327c478bd9Sstevel@tonic-gate /*
4337c478bd9Sstevel@tonic-gate  *  Send a "no-op" up to the MTA to tell it we're still alive, so long
4347c478bd9Sstevel@tonic-gate  *  milter-side operations don't time out.
4357c478bd9Sstevel@tonic-gate  *
4367c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
4377c478bd9Sstevel@tonic-gate  */
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_progress __P((SMFICTX *));
4407c478bd9Sstevel@tonic-gate 
4417c478bd9Sstevel@tonic-gate /*
4427c478bd9Sstevel@tonic-gate  *  Delete a recipient from the envelope
4437c478bd9Sstevel@tonic-gate  *
4447c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
4457c478bd9Sstevel@tonic-gate  *	char *rcpt; Envelope recipient to be deleted. This should be in
4467c478bd9Sstevel@tonic-gate  *		exactly the form passed to xxfi_envrcpt or the address may
4477c478bd9Sstevel@tonic-gate  *		not be deleted.
4487c478bd9Sstevel@tonic-gate  */
4497c478bd9Sstevel@tonic-gate 
4507c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_replacebody __P((SMFICTX *, unsigned char *, int));
4517c478bd9Sstevel@tonic-gate 
4527c478bd9Sstevel@tonic-gate /*
4537c478bd9Sstevel@tonic-gate  *  Replace the body of the message. This routine may be called multiple
4547c478bd9Sstevel@tonic-gate  *  times if the body is longer than convenient to send in one call. End of
4557c478bd9Sstevel@tonic-gate  *  line should be represented as Carriage-Return/Line Feed.
4567c478bd9Sstevel@tonic-gate  *
4577c478bd9Sstevel@tonic-gate  *	char *bodyp; Pointer to block of body information to insert
4587c478bd9Sstevel@tonic-gate  *	int bodylen; Length of data pointed at by bodyp
4597c478bd9Sstevel@tonic-gate  */
4607c478bd9Sstevel@tonic-gate 
4617c478bd9Sstevel@tonic-gate /*
4627c478bd9Sstevel@tonic-gate  *  If the message is aborted (for example, if the SMTP sender sends the
4637c478bd9Sstevel@tonic-gate  *  envelope but then does a QUIT or RSET before the data is sent),
4647c478bd9Sstevel@tonic-gate  *  xxfi_abort is called. This can be used to reset state.
4657c478bd9Sstevel@tonic-gate  */
4667c478bd9Sstevel@tonic-gate 
4677c478bd9Sstevel@tonic-gate /*
4687c478bd9Sstevel@tonic-gate  *  Quarantine an envelope
4697c478bd9Sstevel@tonic-gate  *
4707c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
4717c478bd9Sstevel@tonic-gate  *	char *reason: explanation
4727c478bd9Sstevel@tonic-gate  */
4737c478bd9Sstevel@tonic-gate 
4747c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_quarantine __P((SMFICTX *ctx, char *reason));
4757c478bd9Sstevel@tonic-gate 
4767c478bd9Sstevel@tonic-gate /*
4777c478bd9Sstevel@tonic-gate  *  Connection-private data (specific to an SMTP connection) can be
4787c478bd9Sstevel@tonic-gate  *  allocated using the smfi_setpriv routine; routines can access private
4797c478bd9Sstevel@tonic-gate  *  data using smfi_getpriv.
4807c478bd9Sstevel@tonic-gate  */
4817c478bd9Sstevel@tonic-gate 
4827c478bd9Sstevel@tonic-gate LIBMILTER_API int smfi_setpriv __P((SMFICTX *, void *));
4837c478bd9Sstevel@tonic-gate 
4847c478bd9Sstevel@tonic-gate /*
4857c478bd9Sstevel@tonic-gate  *  Set the private data pointer
4867c478bd9Sstevel@tonic-gate  *
4877c478bd9Sstevel@tonic-gate  *	SMFICTX *ctx; Opaque context structure
4887c478bd9Sstevel@tonic-gate  *	void *privatedata; Pointer to private data area
4897c478bd9Sstevel@tonic-gate  */
4907c478bd9Sstevel@tonic-gate 
4917c478bd9Sstevel@tonic-gate LIBMILTER_API void *smfi_getpriv __P((SMFICTX *));
4927c478bd9Sstevel@tonic-gate 
4937c478bd9Sstevel@tonic-gate #ifdef __cplusplus
4947c478bd9Sstevel@tonic-gate }
4957c478bd9Sstevel@tonic-gate #endif
4967c478bd9Sstevel@tonic-gate 
4977c478bd9Sstevel@tonic-gate #endif /* !_LIBMILTER_MFAPI_H */
498