3 // $Id: spamass-milter.h,v 1.23 2005/04/07 02:04:24 dnelson Exp $
5 // Main include file for SpamAss-Milter
7 // Copyright (c) 2002 Georg C. F. Greve <greve@gnu.org>,
8 // all rights maintained by FSF Europe e.V.,
9 // Villa Vogelsang, Antonienallee 1, 45279 Essen, Germany
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 // Michael Brown <michaelb@opentext.com>
28 #ifndef _SPAMASS_MILTER_H
29 #define _SPAMASS_MILTER_H
32 #include <sys/cdefs.h>
34 #if !defined(__printflike)
35 #define __printflike(a,b)
42 string retrieve_field(const string&, const string&);
44 sfsistat mlfi_connect(SMFICTX*, char*, _SOCK_ADDR*);
45 sfsistat mlfi_helo(SMFICTX*, char*);
46 sfsistat mlfi_envrcpt(SMFICTX*, char**);
47 sfsistat mlfi_envfrom(SMFICTX*, char**);
48 sfsistat mlfi_header(SMFICTX*, char*, char*);
49 sfsistat mlfi_eoh(SMFICTX*);
50 sfsistat mlfi_body(SMFICTX*, u_char *, size_t);
51 sfsistat mlfi_eom(SMFICTX*);
52 sfsistat mlfi_close(SMFICTX*);
53 sfsistat mlfi_abort(SMFICTX*);
54 sfsistat mlfi_abort(SMFICTX*);
56 extern struct smfiDesc smfilter;
58 /* struct describing a single network */
61 struct in_addr network;
62 struct in_addr netmask;
65 /* an array of networks */
76 D_ALWAYS, D_FUNC, D_POLL, D_UORI, D_STR, D_MISC, D_NET, D_SPAMC, D_RCPT,
87 void output(const void*, long);
88 void output(const void*);
95 string& spam_status();
97 string& spam_report();
98 string& spam_prev_content_type();
99 string& spam_checker_version();
100 string& spam_level();
101 string& content_type();
103 string& rcpt(); /* first RCPT TO: recipient (raw) */
104 string& from(); /* MAIL FROM: sender (raw) */
105 string& connectip(); /* IP of sending machine */
106 string local_user(); /* username part of first expanded recipient */
107 string full_user(); /* full first expanded recipient */
108 int numrcpt(); /* total RCPT TO: recpients */
109 int set_numrcpt(); /* increment total RCPT count */
110 int set_numrcpt(const int); /* set total RCPT count to n */
111 string::size_type set_spam_status(const string&);
112 string::size_type set_spam_flag(const string&);
113 string::size_type set_spam_report(const string&);
114 string::size_type set_spam_prev_content_type(const string&);
115 string::size_type set_spam_checker_version(const string&);
116 string::size_type set_spam_level(const string&);
117 string::size_type set_content_type(const string&);
118 string::size_type set_subject(const string&);
119 string::size_type set_rcpt(const string&);
120 string::size_type set_from(const string&);
121 string::size_type set_connectip(const string&);
124 void empty_and_close_pipe();
130 bool running; /* XXX merge running, connected, and pid */
131 bool connected; /* are we connected to spamc? */
133 // This is where we store the mail after it
134 // was piped through SpamAssassin
137 // Data written via output() but before Connect() is stored here
140 // Variables for SpamAssassin influenced fields
141 string x_spam_status, x_spam_flag, x_spam_report, x_spam_prev_content_type;
142 string x_spam_checker_version, x_spam_level, _content_type, _subject;
144 // Envelope info: MAIL FROM:, RCPT TO:, and IP address of remote host
145 // _rcpt only holds the first recipient if there are more than one
146 string _from, _rcpt, _connectip;
148 // Counter to keep track of the number of recipients
151 // The list of recipients for the current message
152 list <string> recipients;
154 // List of recipients after alias/virtusertable expansion
155 list <string> expandedrcpt;
157 // the sendmail queue id for this message; used for logging
160 // Process handling variables
165 /* Private data structure to carry per-client data between calls */
168 struct in_addr connect_ip; // remote IP address
170 SpamAssassin *assassin; // pointer to the SA object if we're processing a message
173 /* This hack is the only way to call pointers to member functions! */
174 typedef string::size_type (SpamAssassin::*t_setter)(const string &val);
175 #define callsetter(object, ptrToMember) ((object).*(ptrToMember))
177 int assassinate(SMFICTX*, SpamAssassin*);
179 void throw_error(const string&);
180 void debug(enum debuglevel, const char* fmt, ...) __printflike(2, 3);
181 string::size_type find_nocase(const string&, const string&, string::size_type = 0);
182 int cmp_nocase_partial(const string&, const string&);
183 void closeall(int fd);
184 void parse_networklist(char *string, struct networklist *list);
185 int ip_in_networklist(struct in_addr ip, struct networklist *list);
186 void parse_debuglevel(char* string);
187 char *strlwr(char *str);
188 void warnmacro(char *macro, char *scope);
189 FILE *popenv(char *const argv[], const char *type);