164562Sgshapiro/*
2261370Sgshapiro * Copyright (c) 1999-2004, 2006, 2008, 2012 Proofpoint, Inc. and its suppliers.
364562Sgshapiro *	All rights reserved.
464562Sgshapiro *
564562Sgshapiro * By using this file, you agree to the terms and conditions set
664562Sgshapiro * forth in the LICENSE file which can be found at the top level of
764562Sgshapiro * the sendmail distribution.
864562Sgshapiro *
964562Sgshapiro *
10266711Sgshapiro *	$Id: mfapi.h,v 8.83 2013-11-22 20:51:27 ca Exp $
1164562Sgshapiro */
1264562Sgshapiro
1364562Sgshapiro/*
1464562Sgshapiro**  MFAPI.H -- Global definitions for mail filter library and mail filters.
1564562Sgshapiro*/
1664562Sgshapiro
1764562Sgshapiro#ifndef _LIBMILTER_MFAPI_H
1864562Sgshapiro# define _LIBMILTER_MFAPI_H	1
1964562Sgshapiro
20132943Sgshapiro#ifndef SMFI_VERSION
21203004Sgshapiro# if _FFR_MDS_NEGOTIATE
22203004Sgshapiro#  define SMFI_VERSION	0x01000002	/* libmilter version number */
23203004Sgshapiro
24203004Sgshapiro   /* first libmilter version that has MDS support */
25203004Sgshapiro#  define SMFI_VERSION_MDS	0x01000002
26203004Sgshapiro# else /* _FFR_MDS_NEGOTIATE */
27203004Sgshapiro#  define SMFI_VERSION	0x01000001	/* libmilter version number */
28203004Sgshapiro# endif /* _FFR_MDS_NEGOTIATE */
29132943Sgshapiro#endif /* ! SMFI_VERSION */
30132943Sgshapiro
31168515Sgshapiro#define SM_LM_VRS_MAJOR(v)	(((v) & 0x7f000000) >> 24)
32168515Sgshapiro#define SM_LM_VRS_MINOR(v)	(((v) & 0x007fff00) >> 8)
33168515Sgshapiro#define SM_LM_VRS_PLVL(v)	((v) & 0x0000007f)
34168515Sgshapiro
3594334Sgshapiro# include <sys/types.h>
3690792Sgshapiro# include <sys/socket.h>
3790792Sgshapiro
38132943Sgshapiro#include "libmilter/mfdef.h"
39132943Sgshapiro
4064562Sgshapiro# define LIBMILTER_API		extern
4164562Sgshapiro
4264562Sgshapiro
43132943Sgshapiro/* Only need to export C interface if used by C++ source code */
44132943Sgshapiro#ifdef __cplusplus
45132943Sgshapiroextern "C" {
46132943Sgshapiro#endif /* __cplusplus */
47132943Sgshapiro
4864562Sgshapiro#ifndef _SOCK_ADDR
4964562Sgshapiro# define _SOCK_ADDR	struct sockaddr
5064562Sgshapiro#endif /* ! _SOCK_ADDR */
5164562Sgshapiro
5264562Sgshapiro/*
5364562Sgshapiro**  libmilter functions return one of the following to indicate
54168515Sgshapiro**  success/failure(/continue):
5564562Sgshapiro*/
5664562Sgshapiro
5764562Sgshapiro#define MI_SUCCESS	0
5864562Sgshapiro#define MI_FAILURE	(-1)
59168515Sgshapiro#if _FFR_WORKERS_POOL
60168515Sgshapiro# define MI_CONTINUE	1
61168515Sgshapiro#endif /* _FFR_WORKERS_POOL */
6264562Sgshapiro
6364562Sgshapiro/* "forward" declarations */
6464562Sgshapirotypedef struct smfi_str SMFICTX;
6564562Sgshapirotypedef struct smfi_str *SMFICTX_PTR;
6664562Sgshapiro
6764562Sgshapirotypedef struct smfiDesc smfiDesc_str;
6864562Sgshapirotypedef struct smfiDesc	*smfiDesc_ptr;
6964562Sgshapiro
7064562Sgshapiro/*
7164562Sgshapiro**  Type which callbacks should return to indicate message status.
7264562Sgshapiro**  This may take on one of the SMFIS_* values listed below.
7364562Sgshapiro*/
7464562Sgshapiro
7564562Sgshapirotypedef int	sfsistat;
7664562Sgshapiro
7764562Sgshapiro#if defined(__linux__) && defined(__GNUC__) && defined(__cplusplus) && __GNUC_MINOR__ >= 8
7864562Sgshapiro# define SM__P(X)	__PMT(X)
7964562Sgshapiro#else /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */
8064562Sgshapiro# define SM__P(X)	__P(X)
8164562Sgshapiro#endif /* __linux__ && __GNUC__ && __cplusplus && _GNUC_MINOR__ >= 8 */
8264562Sgshapiro
8364562Sgshapiro/* Some platforms don't define __P -- do it for them here: */
8464562Sgshapiro#ifndef __P
8564562Sgshapiro# ifdef __STDC__
8664562Sgshapiro#  define __P(X) X
8764562Sgshapiro# else /* __STDC__ */
8864562Sgshapiro#  define __P(X) ()
8964562Sgshapiro# endif /* __STDC__ */
9064562Sgshapiro#endif /* __P */
9164562Sgshapiro
92132943Sgshapiro#if SM_CONF_STDBOOL_H
93132943Sgshapiro# include <stdbool.h>
94132943Sgshapiro#else /* SM_CONF_STDBOOL_H */
95132943Sgshapiro# ifndef __cplusplus
96132943Sgshapiro#  ifndef bool
97132943Sgshapiro#   ifndef __bool_true_false_are_defined
98132943Sgshapirotypedef int	bool;
99244827Sgshapiro#    define false	0
100244827Sgshapiro#    define true	1
101132943Sgshapiro#    define __bool_true_false_are_defined	1
102132943Sgshapiro#   endif /* ! __bool_true_false_are_defined */
103132943Sgshapiro#  endif /* bool */
104132943Sgshapiro# endif /* ! __cplusplus */
105132943Sgshapiro#endif /* SM_CONF_STDBOOL_H */
106132943Sgshapiro
10790792Sgshapiro/*
10890792Sgshapiro**  structure describing one milter
10990792Sgshapiro*/
11090792Sgshapiro
11164562Sgshapirostruct smfiDesc
11264562Sgshapiro{
11364562Sgshapiro	char		*xxfi_name;	/* filter name */
11464562Sgshapiro	int		xxfi_version;	/* version code -- do not change */
11590792Sgshapiro	unsigned long	xxfi_flags;	/* flags */
11664562Sgshapiro
11764562Sgshapiro	/* connection info filter */
11864562Sgshapiro	sfsistat	(*xxfi_connect) SM__P((SMFICTX *, char *, _SOCK_ADDR *));
11964562Sgshapiro
12064562Sgshapiro	/* SMTP HELO command filter */
12164562Sgshapiro	sfsistat	(*xxfi_helo) SM__P((SMFICTX *, char *));
12264562Sgshapiro
12364562Sgshapiro	/* envelope sender filter */
12464562Sgshapiro	sfsistat	(*xxfi_envfrom) SM__P((SMFICTX *, char **));
12564562Sgshapiro
12664562Sgshapiro	/* envelope recipient filter */
12764562Sgshapiro	sfsistat	(*xxfi_envrcpt) SM__P((SMFICTX *, char **));
12864562Sgshapiro
12964562Sgshapiro	/* header filter */
13064562Sgshapiro	sfsistat	(*xxfi_header) SM__P((SMFICTX *, char *, char *));
13164562Sgshapiro
13264562Sgshapiro	/* end of header */
13364562Sgshapiro	sfsistat	(*xxfi_eoh) SM__P((SMFICTX *));
13464562Sgshapiro
13564562Sgshapiro	/* body block */
13690792Sgshapiro	sfsistat	(*xxfi_body) SM__P((SMFICTX *, unsigned char *, size_t));
13764562Sgshapiro
13864562Sgshapiro	/* end of message */
13964562Sgshapiro	sfsistat	(*xxfi_eom) SM__P((SMFICTX *));
14064562Sgshapiro
14164562Sgshapiro	/* message aborted */
14264562Sgshapiro	sfsistat	(*xxfi_abort) SM__P((SMFICTX *));
14364562Sgshapiro
14464562Sgshapiro	/* connection cleanup */
14564562Sgshapiro	sfsistat	(*xxfi_close) SM__P((SMFICTX *));
146132943Sgshapiro
147132943Sgshapiro	/* any unrecognized or unimplemented command filter */
148168515Sgshapiro	sfsistat	(*xxfi_unknown) SM__P((SMFICTX *, const char *));
149132943Sgshapiro
150159609Sgshapiro	/* SMTP DATA command filter */
151132943Sgshapiro	sfsistat	(*xxfi_data) SM__P((SMFICTX *));
152168515Sgshapiro
153168515Sgshapiro	/* negotiation callback */
154168515Sgshapiro	sfsistat	(*xxfi_negotiate) SM__P((SMFICTX *,
155168515Sgshapiro					unsigned long, unsigned long,
156168515Sgshapiro					unsigned long, unsigned long,
157168515Sgshapiro					unsigned long *, unsigned long *,
158168515Sgshapiro					unsigned long *, unsigned long *));
159168515Sgshapiro
160168515Sgshapiro#if 0
161168515Sgshapiro	/* signal handler callback, not yet implemented. */
162168515Sgshapiro	int		(*xxfi_signal) SM__P((int));
163168515Sgshapiro#endif
164168515Sgshapiro
16564562Sgshapiro};
16664562Sgshapiro
167125820SgshapiroLIBMILTER_API int smfi_opensocket __P((bool));
16864562SgshapiroLIBMILTER_API int smfi_register __P((struct smfiDesc));
16964562SgshapiroLIBMILTER_API int smfi_main __P((void));
17094334SgshapiroLIBMILTER_API int smfi_setbacklog __P((int));
17164562SgshapiroLIBMILTER_API int smfi_setdbg __P((int));
17264562SgshapiroLIBMILTER_API int smfi_settimeout __P((int));
17364562SgshapiroLIBMILTER_API int smfi_setconn __P((char *));
17466494SgshapiroLIBMILTER_API int smfi_stop __P((void));
175132943SgshapiroLIBMILTER_API size_t smfi_setmaxdatasize __P((size_t));
176168515SgshapiroLIBMILTER_API int smfi_version __P((unsigned int *, unsigned int *, unsigned int *));
17764562Sgshapiro
17864562Sgshapiro/*
17990792Sgshapiro**  What the filter might do -- values to be ORed together for
18090792Sgshapiro**  smfiDesc.xxfi_flags.
18190792Sgshapiro*/
18290792Sgshapiro
18390792Sgshapiro#define SMFIF_NONE	0x00000000L	/* no flags */
18490792Sgshapiro#define SMFIF_ADDHDRS	0x00000001L	/* filter may add headers */
18590792Sgshapiro#define SMFIF_CHGBODY	0x00000002L	/* filter may replace body */
18690792Sgshapiro#define SMFIF_MODBODY	SMFIF_CHGBODY	/* backwards compatible */
18790792Sgshapiro#define SMFIF_ADDRCPT	0x00000004L	/* filter may add recipients */
18890792Sgshapiro#define SMFIF_DELRCPT	0x00000008L	/* filter may delete recipients */
18990792Sgshapiro#define SMFIF_CHGHDRS	0x00000010L	/* filter may change/delete headers */
190132943Sgshapiro#define SMFIF_QUARANTINE 0x00000020L	/* filter may quarantine envelope */
19190792Sgshapiro
192168515Sgshapiro/* filter may change "from" (envelope sender) */
193168515Sgshapiro#define SMFIF_CHGFROM	0x00000040L
194168515Sgshapiro#define SMFIF_ADDRCPT_PAR	0x00000080L	/* add recipients incl. args */
195168515Sgshapiro
196168515Sgshapiro/* filter can send set of symbols (macros) that it wants */
197168515Sgshapiro#define SMFIF_SETSYMLIST	0x00000100L
198168515Sgshapiro
199168515Sgshapiro
20090792Sgshapiro/*
201168515Sgshapiro**  Macro "places";
202168515Sgshapiro**  Notes:
203168515Sgshapiro**  - must be coordinated with libmilter/engine.c and sendmail/milter.c
204168515Sgshapiro**  - the order MUST NOT be changed as it would break compatibility between
205168515Sgshapiro**	different versions. It's ok to append new entries however
206168515Sgshapiro**	(hence the list is not sorted by the SMT protocol steps).
207168515Sgshapiro*/
208168515Sgshapiro
209244928Sgshapiro#define SMFIM_NOMACROS	(-1)	/* Do NOT use, internal only */
210168515Sgshapiro#define SMFIM_FIRST	0	/* Do NOT use, internal marker only */
211168515Sgshapiro#define SMFIM_CONNECT	0	/* connect */
212168515Sgshapiro#define SMFIM_HELO	1	/* HELO/EHLO */
213168515Sgshapiro#define SMFIM_ENVFROM	2	/* MAIL From */
214168515Sgshapiro#define SMFIM_ENVRCPT	3	/* RCPT To */
215168515Sgshapiro#define SMFIM_DATA	4	/* DATA */
216168515Sgshapiro#define SMFIM_EOM	5	/* end of message (final dot) */
217168515Sgshapiro#define SMFIM_EOH	6	/* end of header */
218168515Sgshapiro#define SMFIM_LAST	6	/* Do NOT use, internal marker only */
219168515Sgshapiro
220168515Sgshapiro/*
22164562Sgshapiro**  Continue processing message/connection.
22264562Sgshapiro*/
22364562Sgshapiro
22464562Sgshapiro#define SMFIS_CONTINUE	0
22564562Sgshapiro
22664562Sgshapiro/*
22764562Sgshapiro**  Reject the message/connection.
22864562Sgshapiro**  No further routines will be called for this message
22964562Sgshapiro**  (or connection, if returned from a connection-oriented routine).
23064562Sgshapiro*/
23164562Sgshapiro
23264562Sgshapiro#define SMFIS_REJECT	1
23364562Sgshapiro
23464562Sgshapiro/*
23564562Sgshapiro**  Accept the message,
23664562Sgshapiro**  but silently discard the message.
23764562Sgshapiro**  No further routines will be called for this message.
23864562Sgshapiro**  This is only meaningful from message-oriented routines.
23964562Sgshapiro*/
24064562Sgshapiro
24164562Sgshapiro#define SMFIS_DISCARD	2
24264562Sgshapiro
24364562Sgshapiro/*
24464562Sgshapiro**  Accept the message/connection.
24564562Sgshapiro**  No further routines will be called for this message
24664562Sgshapiro**  (or connection, if returned from a connection-oriented routine;
24764562Sgshapiro**  in this case, it causes all messages on this connection
24864562Sgshapiro**  to be accepted without filtering).
24964562Sgshapiro*/
25064562Sgshapiro
25164562Sgshapiro#define SMFIS_ACCEPT	3
25264562Sgshapiro
25364562Sgshapiro/*
25464562Sgshapiro**  Return a temporary failure, i.e.,
25564562Sgshapiro**  the corresponding SMTP command will return a 4xx status code.
25664562Sgshapiro**  In some cases this may prevent further routines from
25764562Sgshapiro**  being called on this message or connection,
25864562Sgshapiro**  although in other cases (e.g., when processing an envelope
25964562Sgshapiro**  recipient) processing of the message will continue.
26064562Sgshapiro*/
26164562Sgshapiro
26264562Sgshapiro#define SMFIS_TEMPFAIL	4
26364562Sgshapiro
264168515Sgshapiro/*
265168515Sgshapiro**  Do not send a reply to the MTA
266168515Sgshapiro*/
267168515Sgshapiro
268168515Sgshapiro#define SMFIS_NOREPLY	7
269168515Sgshapiro
270168515Sgshapiro/*
271168515Sgshapiro**  Skip over rest of same callbacks, e.g., body.
272168515Sgshapiro*/
273168515Sgshapiro
274168515Sgshapiro#define SMFIS_SKIP	8
275168515Sgshapiro
276168515Sgshapiro/* xxfi_negotiate: use all existing protocol options/actions */
277168515Sgshapiro#define SMFIS_ALL_OPTS	10
278168515Sgshapiro
27964562Sgshapiro#if 0
28064562Sgshapiro/*
28164562Sgshapiro**  Filter Routine Details
28264562Sgshapiro*/
28364562Sgshapiro
28464562Sgshapiro/* connection info filter */
28564562Sgshapiroextern sfsistat	xxfi_connect __P((SMFICTX *, char *, _SOCK_ADDR *));
28664562Sgshapiro
28764562Sgshapiro/*
28864562Sgshapiro**  xxfi_connect(ctx, hostname, hostaddr) Invoked on each connection
28964562Sgshapiro**
29064562Sgshapiro**	char *hostname; Host domain name, as determined by a reverse lookup
29164562Sgshapiro**		on the host address.
29264562Sgshapiro**	_SOCK_ADDR *hostaddr; Host address, as determined by a getpeername
29364562Sgshapiro**		call on the SMTP socket.
29464562Sgshapiro*/
29564562Sgshapiro
29664562Sgshapiro/* SMTP HELO command filter */
29764562Sgshapiroextern sfsistat	xxfi_helo __P((SMFICTX *, char *));
29864562Sgshapiro
29964562Sgshapiro/*
30064562Sgshapiro**  xxfi_helo(ctx, helohost) Invoked on SMTP HELO/EHLO command
30164562Sgshapiro**
30264562Sgshapiro**	char *helohost; Value passed to HELO/EHLO command, which should be
30364562Sgshapiro**		the domain name of the sending host (but is, in practice,
30464562Sgshapiro**		anything the sending host wants to send).
30564562Sgshapiro*/
30664562Sgshapiro
30764562Sgshapiro/* envelope sender filter */
30864562Sgshapiroextern sfsistat	xxfi_envfrom __P((SMFICTX *, char **));
30964562Sgshapiro
31064562Sgshapiro/*
31164562Sgshapiro**  xxfi_envfrom(ctx, argv) Invoked on envelope from
31264562Sgshapiro**
31364562Sgshapiro**	char **argv; Null-terminated SMTP command arguments;
31464562Sgshapiro**		argv[0] is guaranteed to be the sender address.
31564562Sgshapiro**		Later arguments are the ESMTP arguments.
31664562Sgshapiro*/
31764562Sgshapiro
31864562Sgshapiro/* envelope recipient filter */
31964562Sgshapiroextern sfsistat	xxfi_envrcpt __P((SMFICTX *, char **));
32064562Sgshapiro
32164562Sgshapiro/*
32264562Sgshapiro**  xxfi_envrcpt(ctx, argv) Invoked on each envelope recipient
32364562Sgshapiro**
32464562Sgshapiro**	char **argv; Null-terminated SMTP command arguments;
32564562Sgshapiro**		argv[0] is guaranteed to be the recipient address.
32664562Sgshapiro**		Later arguments are the ESMTP arguments.
32764562Sgshapiro*/
32864562Sgshapiro
329132943Sgshapiro/* unknown command filter */
330132943Sgshapiro
331168515Sgshapiroextern sfsistat	*xxfi_unknown __P((SMFICTX *, const char *));
332132943Sgshapiro
333132943Sgshapiro/*
334132943Sgshapiro**  xxfi_unknown(ctx, arg) Invoked when SMTP command is not recognized or not
335132943Sgshapiro**  implemented.
336168515Sgshapiro**	const char *arg; Null-terminated SMTP command
337132943Sgshapiro*/
338132943Sgshapiro
33964562Sgshapiro/* header filter */
34064562Sgshapiroextern sfsistat	xxfi_header __P((SMFICTX *, char *, char *));
34164562Sgshapiro
34264562Sgshapiro/*
34364562Sgshapiro**  xxfi_header(ctx, headerf, headerv) Invoked on each message header. The
34464562Sgshapiro**  content of the header may have folded white space (that is, multiple
34564562Sgshapiro**  lines with following white space) included.
34664562Sgshapiro**
34764562Sgshapiro**	char *headerf; Header field name
34864562Sgshapiro**	char *headerv; Header field value
34964562Sgshapiro*/
35064562Sgshapiro
35164562Sgshapiro/* end of header */
35264562Sgshapiroextern sfsistat	xxfi_eoh __P((SMFICTX *));
35364562Sgshapiro
35464562Sgshapiro/*
35564562Sgshapiro**  xxfi_eoh(ctx) Invoked at end of header
35664562Sgshapiro*/
35764562Sgshapiro
35864562Sgshapiro/* body block */
35990792Sgshapiroextern sfsistat	xxfi_body __P((SMFICTX *, unsigned char *, size_t));
36064562Sgshapiro
36164562Sgshapiro/*
36264562Sgshapiro**  xxfi_body(ctx, bodyp, bodylen) Invoked for each body chunk. There may
36364562Sgshapiro**  be multiple body chunks passed to the filter. End-of-lines are
36464562Sgshapiro**  represented as received from SMTP (normally Carriage-Return/Line-Feed).
36564562Sgshapiro**
36690792Sgshapiro**	unsigned char *bodyp; Pointer to body data
36764562Sgshapiro**	size_t bodylen; Length of body data
36864562Sgshapiro*/
36964562Sgshapiro
37064562Sgshapiro/* end of message */
37164562Sgshapiroextern sfsistat	xxfi_eom __P((SMFICTX *));
37264562Sgshapiro
37364562Sgshapiro/*
37464562Sgshapiro**  xxfi_eom(ctx) Invoked at end of message. This routine can perform
37564562Sgshapiro**  special operations such as modifying the message header, body, or
37664562Sgshapiro**  envelope.
37764562Sgshapiro*/
37864562Sgshapiro
37964562Sgshapiro/* message aborted */
38064562Sgshapiroextern sfsistat	xxfi_abort __P((SMFICTX *));
38164562Sgshapiro
38264562Sgshapiro/*
38364562Sgshapiro**  xxfi_abort(ctx) Invoked if message is aborted outside of the control of
38464562Sgshapiro**  the filter, for example, if the SMTP sender issues an RSET command. If
38564562Sgshapiro**  xxfi_abort is called, xxfi_eom will not be called and vice versa.
38664562Sgshapiro*/
38764562Sgshapiro
38864562Sgshapiro/* connection cleanup */
38964562Sgshapiroextern sfsistat	xxfi_close __P((SMFICTX *));
39064562Sgshapiro
39164562Sgshapiro/*
39264562Sgshapiro**  xxfi_close(ctx) Invoked at end of the connection. This is called on
39364562Sgshapiro**  close even if the previous mail transaction was aborted.
39464562Sgshapiro*/
39564562Sgshapiro#endif /* 0 */
39664562Sgshapiro
39764562Sgshapiro/*
39864562Sgshapiro**  Additional information is passed in to the vendor filter routines using
39964562Sgshapiro**  symbols. Symbols correspond closely to sendmail macros. The symbols
40064562Sgshapiro**  defined depend on the context. The value of a symbol is accessed using:
40164562Sgshapiro*/
40264562Sgshapiro
40364562Sgshapiro/* Return the value of a symbol. */
40464562SgshapiroLIBMILTER_API char * smfi_getsymval __P((SMFICTX *, char *));
40564562Sgshapiro
40664562Sgshapiro/*
40764562Sgshapiro**  Return the value of a symbol.
40864562Sgshapiro**
40964562Sgshapiro**	SMFICTX *ctx; Opaque context structure
41064562Sgshapiro**	char *symname; The name of the symbol to access.
41164562Sgshapiro*/
41264562Sgshapiro
41364562Sgshapiro/*
41464562Sgshapiro**  Vendor filter routines that want to pass additional information back to
41564562Sgshapiro**  the MTA for use in SMTP replies may call smfi_setreply before returning.
41664562Sgshapiro*/
41764562Sgshapiro
41864562SgshapiroLIBMILTER_API int smfi_setreply __P((SMFICTX *, char *, char *, char *));
41964562Sgshapiro
42064562Sgshapiro/*
42190792Sgshapiro**  Alternatively, smfi_setmlreply can be called if a multi-line SMTP reply
42290792Sgshapiro**  is needed.
42390792Sgshapiro*/
42490792Sgshapiro
42590792SgshapiroLIBMILTER_API int smfi_setmlreply __P((SMFICTX *, const char *, const char *, ...));
42690792Sgshapiro
42790792Sgshapiro/*
42864562Sgshapiro**  Set the specific reply code to be used in response to the active
42964562Sgshapiro**  command. If not specified, a generic reply code is used.
43064562Sgshapiro**
43164562Sgshapiro**	SMFICTX *ctx; Opaque context structure
43264562Sgshapiro**	char *rcode; The three-digit (RFC 821) SMTP reply code to be
43364562Sgshapiro**		returned, e.g., ``551''.
43464562Sgshapiro**	char *xcode; The extended (RFC 2034) reply code, e.g., ``5.7.6''.
43564562Sgshapiro**	char *message; The text part of the SMTP reply.
43664562Sgshapiro*/
43764562Sgshapiro
43864562Sgshapiro/*
43964562Sgshapiro**  The xxfi_eom routine is called at the end of a message (essentially,
44064562Sgshapiro**  after the final DATA dot). This routine can call some special routines
44164562Sgshapiro**  to modify the envelope, header, or body of the message before the
44264562Sgshapiro**  message is enqueued. These routines must not be called from any vendor
44364562Sgshapiro**  routine other than xxfi_eom.
44464562Sgshapiro*/
44564562Sgshapiro
44664562SgshapiroLIBMILTER_API int smfi_addheader __P((SMFICTX *, char *, char *));
44764562Sgshapiro
44864562Sgshapiro/*
449132943Sgshapiro**  Add a header to the message. It is not checked for standards
450132943Sgshapiro**  compliance; the mail filter must ensure that no protocols are violated
451132943Sgshapiro**  as a result of adding this header.
45264562Sgshapiro**
45364562Sgshapiro**	SMFICTX *ctx; Opaque context structure
45464562Sgshapiro**	char *headerf; Header field name
45564562Sgshapiro**	char *headerv; Header field value
45664562Sgshapiro*/
45764562Sgshapiro
45864562SgshapiroLIBMILTER_API int smfi_chgheader __P((SMFICTX *, char *, int, char *));
45964562Sgshapiro
46064562Sgshapiro/*
46164562Sgshapiro**  Change/delete a header in the message.  It is not checked for standards
46264562Sgshapiro**  compliance; the mail filter must ensure that no protocols are violated
46364562Sgshapiro**  as a result of adding this header.
46464562Sgshapiro**
46564562Sgshapiro**	SMFICTX *ctx; Opaque context structure
46664562Sgshapiro**	char *headerf; Header field name
46764562Sgshapiro**	int index; The Nth occurence of header field name
46864562Sgshapiro**	char *headerv; New header field value (empty for delete header)
46964562Sgshapiro*/
47064562Sgshapiro
471132943SgshapiroLIBMILTER_API int smfi_insheader __P((SMFICTX *, int, char *, char *));
472132943Sgshapiro
473132943Sgshapiro/*
474132943Sgshapiro**  Insert a header into the message.  It is not checked for standards
475132943Sgshapiro**  compliance; the mail filter must ensure that no protocols are violated
476132943Sgshapiro**  as a result of adding this header.
477132943Sgshapiro**
478132943Sgshapiro**	SMFICTX *ctx; Opaque context structure
479132943Sgshapiro**  	int idx; index into the header list where the insertion should happen
480132943Sgshapiro**	char *headerh; Header field name
481132943Sgshapiro**	char *headerv; Header field value
482132943Sgshapiro*/
483132943Sgshapiro
484168515SgshapiroLIBMILTER_API int smfi_chgfrom __P((SMFICTX *, char *, char *));
485168515Sgshapiro
486168515Sgshapiro/*
487168515Sgshapiro**  Modify envelope sender address
488168515Sgshapiro**
489168515Sgshapiro**	SMFICTX *ctx; Opaque context structure
490168515Sgshapiro**	char *mail; New envelope sender address
491168515Sgshapiro**	char *args; ESMTP arguments
492168515Sgshapiro*/
493168515Sgshapiro
494168515Sgshapiro
49564562SgshapiroLIBMILTER_API int smfi_addrcpt __P((SMFICTX *, char *));
49664562Sgshapiro
49764562Sgshapiro/*
49864562Sgshapiro**  Add a recipient to the envelope
49964562Sgshapiro**
50064562Sgshapiro**	SMFICTX *ctx; Opaque context structure
50164562Sgshapiro**	char *rcpt; Recipient to be added
50264562Sgshapiro*/
50364562Sgshapiro
504168515SgshapiroLIBMILTER_API int smfi_addrcpt_par __P((SMFICTX *, char *, char *));
505168515Sgshapiro
506168515Sgshapiro/*
507168515Sgshapiro**  Add a recipient to the envelope
508168515Sgshapiro**
509168515Sgshapiro**	SMFICTX *ctx; Opaque context structure
510168515Sgshapiro**	char *rcpt; Recipient to be added
511168515Sgshapiro**	char *args; ESMTP arguments
512168515Sgshapiro*/
513168515Sgshapiro
514168515Sgshapiro
51564562SgshapiroLIBMILTER_API int smfi_delrcpt __P((SMFICTX *, char *));
51664562Sgshapiro
51764562Sgshapiro/*
51894334Sgshapiro**  Send a "no-op" up to the MTA to tell it we're still alive, so long
51994334Sgshapiro**  milter-side operations don't time out.
52094334Sgshapiro**
52194334Sgshapiro**	SMFICTX *ctx; Opaque context structure
52294334Sgshapiro*/
52394334Sgshapiro
52494334SgshapiroLIBMILTER_API int smfi_progress __P((SMFICTX *));
52594334Sgshapiro
52694334Sgshapiro/*
52764562Sgshapiro**  Delete a recipient from the envelope
52864562Sgshapiro**
52964562Sgshapiro**	SMFICTX *ctx; Opaque context structure
53064562Sgshapiro**	char *rcpt; Envelope recipient to be deleted. This should be in
53164562Sgshapiro**		exactly the form passed to xxfi_envrcpt or the address may
53264562Sgshapiro**		not be deleted.
53364562Sgshapiro*/
53464562Sgshapiro
53590792SgshapiroLIBMILTER_API int smfi_replacebody __P((SMFICTX *, unsigned char *, int));
53664562Sgshapiro
53764562Sgshapiro/*
53864562Sgshapiro**  Replace the body of the message. This routine may be called multiple
53964562Sgshapiro**  times if the body is longer than convenient to send in one call. End of
54064562Sgshapiro**  line should be represented as Carriage-Return/Line Feed.
54164562Sgshapiro**
54264562Sgshapiro**	char *bodyp; Pointer to block of body information to insert
54364562Sgshapiro**	int bodylen; Length of data pointed at by bodyp
54464562Sgshapiro*/
54564562Sgshapiro
54664562Sgshapiro/*
54764562Sgshapiro**  If the message is aborted (for example, if the SMTP sender sends the
54864562Sgshapiro**  envelope but then does a QUIT or RSET before the data is sent),
54964562Sgshapiro**  xxfi_abort is called. This can be used to reset state.
55064562Sgshapiro*/
55164562Sgshapiro
55290792Sgshapiro/*
55390792Sgshapiro**  Quarantine an envelope
55490792Sgshapiro**
55590792Sgshapiro**	SMFICTX *ctx; Opaque context structure
55690792Sgshapiro**	char *reason: explanation
55790792Sgshapiro*/
55864562Sgshapiro
55990792SgshapiroLIBMILTER_API int smfi_quarantine __P((SMFICTX *ctx, char *reason));
56090792Sgshapiro
56164562Sgshapiro/*
56264562Sgshapiro**  Connection-private data (specific to an SMTP connection) can be
56364562Sgshapiro**  allocated using the smfi_setpriv routine; routines can access private
56464562Sgshapiro**  data using smfi_getpriv.
56564562Sgshapiro*/
56664562Sgshapiro
56764562SgshapiroLIBMILTER_API int smfi_setpriv __P((SMFICTX *, void *));
56864562Sgshapiro
56964562Sgshapiro/*
57064562Sgshapiro**  Set the private data pointer
57164562Sgshapiro**
57264562Sgshapiro**	SMFICTX *ctx; Opaque context structure
57364562Sgshapiro**	void *privatedata; Pointer to private data area
57464562Sgshapiro*/
57564562Sgshapiro
57664562SgshapiroLIBMILTER_API void *smfi_getpriv __P((SMFICTX *));
57764562Sgshapiro
578168515Sgshapiro/*
579168515Sgshapiro**  Get the private data pointer
580168515Sgshapiro**
581168515Sgshapiro**	SMFICTX *ctx; Opaque context structure
582168515Sgshapiro**	void *privatedata; Pointer to private data area
583168515Sgshapiro*/
584168515Sgshapiro
585168515SgshapiroLIBMILTER_API int smfi_setsymlist __P((SMFICTX *, int, char *));
586168515Sgshapiro
587168515Sgshapiro/*
588168515Sgshapiro**  Set list of symbols (macros) to receive
589168515Sgshapiro**
590168515Sgshapiro**	SMFICTX *ctx; Opaque context structure
591168515Sgshapiro**	int where; where in the SMTP dialogue should the macros be sent
592168515Sgshapiro**	char *macros; list of macros (space separated)
593168515Sgshapiro*/
594168515Sgshapiro
595168515Sgshapiro#if _FFR_THREAD_MONITOR
596168515SgshapiroLIBMILTER_API int smfi_set_max_exec_time __P((unsigned int));
597168515Sgshapiro#endif /* _FFR_THREAD_MONITOR */
598168515Sgshapiro
599132943Sgshapiro#ifdef __cplusplus
600132943Sgshapiro}
601132943Sgshapiro#endif /* __cplusplus */
60264562Sgshapiro
603110560Sgshapiro#endif /* ! _LIBMILTER_MFAPI_H */
604