libmilter.h revision 64562
164562Sgshapiro/*
264562Sgshapiro * Copyright (c) 1999-2000 Sendmail, 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
1064562Sgshapiro/*
1164562Sgshapiro**  LIBMILTER.H -- include file for mail filter library functions
1264562Sgshapiro*/
1364562Sgshapiro
1464562Sgshapiro#ifndef _LIBMILTER_H
1564562Sgshapiro# define _LIBMILTER_H	1
1664562Sgshapiro#ifdef _DEFINE
1764562Sgshapiro# define EXTERN
1864562Sgshapiro# define INIT(x)	= x
1964562Sgshapiro# ifndef lint
2064562Sgshapirostatic char MilterlId[] = "@(#)$Id: libmilter.h,v 8.3.6.4 2000/06/09 07:12:13 gshapiro Exp $";
2164562Sgshapiro# endif /* ! lint */
2264562Sgshapiro#else /* _DEFINE */
2364562Sgshapiro# define EXTERN extern
2464562Sgshapiro# define INIT(x)
2564562Sgshapiro#endif /* _DEFINE */
2664562Sgshapiro
2764562Sgshapiro
2864562Sgshapiro#define NOT_SENDMAIL	1
2964562Sgshapiro#define _SOCK_ADDR	union bigsockaddr
3064562Sgshapiro#include "sendmail.h"
3164562Sgshapiro
3264562Sgshapiro#include "libmilter/milter.h"
3364562Sgshapiro
3464562Sgshapiro#ifndef __P
3564562Sgshapiro# include "sendmail/cdefs.h"
3664562Sgshapiro#endif /* ! __P */
3764562Sgshapiro#include "sendmail/useful.h"
3864562Sgshapiro
3964562Sgshapiro# define ValidSocket(sd)	((sd) >= 0)
4064562Sgshapiro
4164562Sgshapiro# define thread_create(ptid,wr,arg) pthread_create(ptid, NULL, wr, arg)
4264562Sgshapiro# define sthread_get_id()	pthread_self()
4364562Sgshapiro
4464562Sgshapiro#include <sys/time.h>
4564562Sgshapiro
4664562Sgshapiro/* version info */
4764562Sgshapiro#define MILTER_PRODUCT_NAME	"libmilter"
4864562Sgshapiro#define MILTER_VERSION		100
4964562Sgshapiro
5064562Sgshapiro/* some defaults */
5164562Sgshapiro#define MI_TIMEOUT	1800		/* default timeout for read/write */
5264562Sgshapiro#define MI_CHK_TIME	5		/* checking whether to terminate */
5364562Sgshapiro
5464562Sgshapiro/* maximum number of repeated failures in mi_listener() */
5564562Sgshapiro#define MAX_FAILS_M	16	/* malloc() */
5664562Sgshapiro#define MAX_FAILS_T	16	/* thread creation */
5764562Sgshapiro
5864562Sgshapiro/* internal "commands", i.e., error codes */
5964562Sgshapiro#define SMFIC_TIMEOUT	((char) 1)	/* timeout */
6064562Sgshapiro#define SMFIC_SELECT	((char) 2)	/* select error */
6164562Sgshapiro#define SMFIC_MALLOC	((char) 3)	/* malloc error */
6264562Sgshapiro#define SMFIC_RECVERR	((char) 4)	/* recv() error */
6364562Sgshapiro#define SMFIC_EOF	((char) 5)	/* eof */
6464562Sgshapiro#define SMFIC_UNKNERR	((char) 6)	/* unknown error */
6564562Sgshapiro#define SMFIC_TOOBIG	((char) 7)	/* body chunk too big */
6664562Sgshapiro#define SMFIC_VALIDCMD	' '		/* first valid command */
6764562Sgshapiro
6864562Sgshapiro/* hack */
6964562Sgshapiro#define smi_log		syslog
7064562Sgshapiro#define milter_ret	int
7164562Sgshapiro#define SMI_LOG_ERR	LOG_ERR
7264562Sgshapiro#define SMI_LOG_FATAL	LOG_ERR
7364562Sgshapiro#define SMI_LOG_WARN	LOG_WARNING
7464562Sgshapiro#define SMI_LOG_INFO	LOG_INFO
7564562Sgshapiro#define SMI_LOG_DEBUG	LOG_DEBUG
7664562Sgshapiro
7764562Sgshapiro#define MI_INVALID_SOCKET	(-1)
7864562Sgshapiro
7964562Sgshapiro/* stop? */
8064562Sgshapiro#define MILTER_CONT	0
8164562Sgshapiro#define MILTER_STOP	1
8264562Sgshapiro#define MILTER_ABRT	2
8364562Sgshapiro
8464562Sgshapiro/* functions */
8564562Sgshapiroextern int	mi_handle_session __P((SMFICTX_PTR));
8664562Sgshapiroextern int	mi_engine __P((SMFICTX_PTR));
8764562Sgshapiroextern int	mi_listener __P((char *, int, smfiDesc_ptr, time_t));
8864562Sgshapiroextern void	mi_clr_macros __P((SMFICTX_PTR, int));
8964562Sgshapiroextern int	mi_stop __P((void));
9064562Sgshapiroextern int	mi_control_startup __P((char *));
9164562Sgshapiroextern void	mi_stop_milters __P((int));
9264562Sgshapiroextern void	mi_clean_signals __P((void));
9364562Sgshapiroextern struct hostent *mi_gethostbyname __P((char *, int));
9464562Sgshapiro
9564562Sgshapiro/* communication functions */
9664562Sgshapiroextern char	*mi_rd_cmd __P((socket_t, struct timeval *, char *, size_t *, char *));
9764562Sgshapiroextern int	mi_wr_cmd __P((socket_t, struct timeval *, int, char *, size_t));
9864562Sgshapiroextern bool	mi_sendok __P((SMFICTX_PTR, int));
9964562Sgshapiro
10064562Sgshapiro#endif /* !_LIBMILTER_H */
101