libmilter.h revision 66494
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 2066494Sgshapirostatic char MilterlId[] = "@(#)$Id: libmilter.h,v 8.3.6.9 2000/09/01 00:49:04 ca 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) 4066494Sgshapiro# define INVALID_SOCKET -1 4166494Sgshapiro# define MI_SOCK_READ(s, b, l) (read(s, b, l)) 4266494Sgshapiro# define MI_SOCK_WRITE(s, b, l) (write(s, b, l)) 4364562Sgshapiro 4464562Sgshapiro# define thread_create(ptid,wr,arg) pthread_create(ptid, NULL, wr, arg) 4564562Sgshapiro# define sthread_get_id() pthread_self() 4664562Sgshapiro 4764562Sgshapiro#include <sys/time.h> 4864562Sgshapiro 4964562Sgshapiro/* version info */ 5064562Sgshapiro#define MILTER_PRODUCT_NAME "libmilter" 5164562Sgshapiro#define MILTER_VERSION 100 5264562Sgshapiro 5364562Sgshapiro/* some defaults */ 5464562Sgshapiro#define MI_TIMEOUT 1800 /* default timeout for read/write */ 5564562Sgshapiro#define MI_CHK_TIME 5 /* checking whether to terminate */ 5664562Sgshapiro 5766494Sgshapiro#if SOMAXCONN > 20 5866494Sgshapiro# define MI_SOMAXCONN SOMAXCONN 5966494Sgshapiro#else /* SOMAXCONN */ 6066494Sgshapiro# define MI_SOMAXCONN 20 6166494Sgshapiro#endif /* SOMAXCONN */ 6266494Sgshapiro 6364562Sgshapiro/* maximum number of repeated failures in mi_listener() */ 6464562Sgshapiro#define MAX_FAILS_M 16 /* malloc() */ 6564562Sgshapiro#define MAX_FAILS_T 16 /* thread creation */ 6664562Sgshapiro 6764562Sgshapiro/* internal "commands", i.e., error codes */ 6864562Sgshapiro#define SMFIC_TIMEOUT ((char) 1) /* timeout */ 6964562Sgshapiro#define SMFIC_SELECT ((char) 2) /* select error */ 7064562Sgshapiro#define SMFIC_MALLOC ((char) 3) /* malloc error */ 7164562Sgshapiro#define SMFIC_RECVERR ((char) 4) /* recv() error */ 7264562Sgshapiro#define SMFIC_EOF ((char) 5) /* eof */ 7364562Sgshapiro#define SMFIC_UNKNERR ((char) 6) /* unknown error */ 7464562Sgshapiro#define SMFIC_TOOBIG ((char) 7) /* body chunk too big */ 7564562Sgshapiro#define SMFIC_VALIDCMD ' ' /* first valid command */ 7664562Sgshapiro 7764562Sgshapiro/* hack */ 7864562Sgshapiro#define smi_log syslog 7964562Sgshapiro#define milter_ret int 8064562Sgshapiro#define SMI_LOG_ERR LOG_ERR 8164562Sgshapiro#define SMI_LOG_FATAL LOG_ERR 8264562Sgshapiro#define SMI_LOG_WARN LOG_WARNING 8364562Sgshapiro#define SMI_LOG_INFO LOG_INFO 8464562Sgshapiro#define SMI_LOG_DEBUG LOG_DEBUG 8564562Sgshapiro 8664562Sgshapiro/* stop? */ 8764562Sgshapiro#define MILTER_CONT 0 8864562Sgshapiro#define MILTER_STOP 1 8964562Sgshapiro#define MILTER_ABRT 2 9064562Sgshapiro 9164562Sgshapiro/* functions */ 9264562Sgshapiroextern int mi_handle_session __P((SMFICTX_PTR)); 9364562Sgshapiroextern int mi_engine __P((SMFICTX_PTR)); 9466494Sgshapiroextern int mi_listener __P((char *, int, smfiDesc_ptr, time_t, int)); 9564562Sgshapiroextern void mi_clr_macros __P((SMFICTX_PTR, int)); 9664562Sgshapiroextern int mi_stop __P((void)); 9764562Sgshapiroextern int mi_control_startup __P((char *)); 9864562Sgshapiroextern void mi_stop_milters __P((int)); 9964562Sgshapiroextern void mi_clean_signals __P((void)); 10064562Sgshapiroextern struct hostent *mi_gethostbyname __P((char *, int)); 10166494Sgshapiroextern void mi_closener __P((void)); 10264562Sgshapiro 10364562Sgshapiro/* communication functions */ 10464562Sgshapiroextern char *mi_rd_cmd __P((socket_t, struct timeval *, char *, size_t *, char *)); 10564562Sgshapiroextern int mi_wr_cmd __P((socket_t, struct timeval *, int, char *, size_t)); 10664562Sgshapiroextern bool mi_sendok __P((SMFICTX_PTR, int)); 10764562Sgshapiro 10864562Sgshapiro#endif /* !_LIBMILTER_H */ 109