1 /* 2 * Copyright (c) 1999-2000 Sendmail, Inc. and its suppliers. 3 * All rights reserved. 4 * 5 * By using this file, you agree to the terms and conditions set 6 * forth in the LICENSE file which can be found at the top level of 7 * the sendmail distribution. 8 */ 9 10 /* 11 ** LIBMILTER.H -- include file for mail filter library functions 12 */ 13 14 #ifndef _LIBMILTER_H 15 # define _LIBMILTER_H 1 16 #ifdef _DEFINE 17 # define EXTERN 18 # define INIT(x) = x 19 # ifndef lint 20 static char MilterlId[] = "@(#)$Id: libmilter.h,v 8.3.6.9 2000/09/01 00:49:04 ca Exp $"; 21 # endif /* ! lint */ 22 #else /* _DEFINE */ 23 # define EXTERN extern 24 # define INIT(x) 25 #endif /* _DEFINE */ 26 27 28 #define NOT_SENDMAIL 1 29 #define _SOCK_ADDR union bigsockaddr 30 #include "sendmail.h" 31 32 #include "libmilter/milter.h" 33 34 #ifndef __P 35 # include "sendmail/cdefs.h" 36 #endif /* ! __P */ 37 #include "sendmail/useful.h" 38 39 # define ValidSocket(sd) ((sd) >= 0) 40 # define INVALID_SOCKET -1 41 # define MI_SOCK_READ(s, b, l) (read(s, b, l)) 42 # define MI_SOCK_WRITE(s, b, l) (write(s, b, l)) 43 44 # define thread_create(ptid,wr,arg) pthread_create(ptid, NULL, wr, arg) 45 # define sthread_get_id() pthread_self() 46 47 #include <sys/time.h> 48 49 /* version info */ 50 #define MILTER_PRODUCT_NAME "libmilter" 51 #define MILTER_VERSION 100 52 53 /* some defaults */ 54 #define MI_TIMEOUT 1800 /* default timeout for read/write */ 55 #define MI_CHK_TIME 5 /* checking whether to terminate */ 56 57 #if SOMAXCONN > 20 58 # define MI_SOMAXCONN SOMAXCONN 59 #else /* SOMAXCONN */ 60 # define MI_SOMAXCONN 20 61 #endif /* SOMAXCONN */ 62 63 /* maximum number of repeated failures in mi_listener() */ 64 #define MAX_FAILS_M 16 /* malloc() */ 65 #define MAX_FAILS_T 16 /* thread creation */ 66 67 /* internal "commands", i.e., error codes */ 68 #define SMFIC_TIMEOUT ((char) 1) /* timeout */ 69 #define SMFIC_SELECT ((char) 2) /* select error */ 70 #define SMFIC_MALLOC ((char) 3) /* malloc error */ 71 #define SMFIC_RECVERR ((char) 4) /* recv() error */ 72 #define SMFIC_EOF ((char) 5) /* eof */ 73 #define SMFIC_UNKNERR ((char) 6) /* unknown error */ 74 #define SMFIC_TOOBIG ((char) 7) /* body chunk too big */ 75 #define SMFIC_VALIDCMD ' ' /* first valid command */ 76 77 /* hack */ 78 #define smi_log syslog 79 #define milter_ret int 80 #define SMI_LOG_ERR LOG_ERR 81 #define SMI_LOG_FATAL LOG_ERR 82 #define SMI_LOG_WARN LOG_WARNING 83 #define SMI_LOG_INFO LOG_INFO 84 #define SMI_LOG_DEBUG LOG_DEBUG 85 86 /* stop? */ 87 #define MILTER_CONT 0 88 #define MILTER_STOP 1 89 #define MILTER_ABRT 2 90 91 /* functions */ 92 extern int mi_handle_session __P((SMFICTX_PTR)); 93 extern int mi_engine __P((SMFICTX_PTR)); 94 extern int mi_listener __P((char *, int, smfiDesc_ptr, time_t, int)); 95 extern void mi_clr_macros __P((SMFICTX_PTR, int)); 96 extern int mi_stop __P((void)); 97 extern int mi_control_startup __P((char *)); 98 extern void mi_stop_milters __P((int)); 99 extern void mi_clean_signals __P((void)); 100 extern struct hostent *mi_gethostbyname __P((char *, int)); 101 extern void mi_closener __P((void)); 102 103 /* communication functions */ 104 extern char *mi_rd_cmd __P((socket_t, struct timeval *, char *, size_t *, char *)); 105 extern int mi_wr_cmd __P((socket_t, struct timeval *, int, char *, size_t)); 106 extern bool mi_sendok __P((SMFICTX_PTR, int)); 107 108 #endif /* !_LIBMILTER_H */ 109