1 /* 2 * Copyright (c) 2007-2012, Vsevolod Stakhov 3 * All rights reserved. 4 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * Redistributions of source code must retain the above copyright notice, this 8 * list of conditions and the following disclaimer. Redistributions in binary form 9 * must reproduce the above copyright notice, this list of conditions and the 10 * following disclaimer in the documentation and/or other materials provided with 11 * the distribution. Neither the name of the author nor the names of its 12 * contributors may be used to endorse or promote products derived from this 13 * software without specific prior written permission. 14 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #ifndef LIBSPAMD_H 28 #define LIBSPAMD_H 29 30 #include "config.h" 31 #include "ucl.h" 32 33 struct config_file; 34 struct mlfi_priv; 35 36 struct rspamd_metric_result* spamdscan (void *ctx, struct mlfi_priv *priv, 37 struct config_file *cfg, int is_extra, int dkim_only); 38 void spamd_free_result (struct rspamd_metric_result *mres); 39 40 41 /* Structure for rspamd results */ 42 enum rspamd_metric_action { 43 METRIC_ACTION_NOACTION = 0, 44 METRIC_ACTION_GREYLIST, 45 METRIC_ACTION_ADD_HEADER, 46 METRIC_ACTION_REWRITE_SUBJECT, 47 METRIC_ACTION_SOFT_REJECT, 48 METRIC_ACTION_REJECT 49 }; 50 51 #define SPAM_IS_SPAM(res) ((res)->action >= METRIC_ACTION_ADD_HEADER) 52 #define SPAM_IS_GREYLIST(res) ((res)->action >= METRIC_ACTION_GREYLIST && (res)->action < METRIC_ACTION_SOFT_REJECT) 53 54 struct rspamd_symbol { 55 const char *symbol; 56 const ucl_object_t *options; 57 double score; 58 struct rspamd_symbol *prev, *next; 59 }; 60 61 struct rspamd_metric_result { 62 ucl_object_t *obj; 63 const char *dkim_signature; 64 const char *metric_name; 65 const char *subject; 66 const char *message; 67 const char *message_id; 68 double score; 69 double required_score; 70 double reject_score; 71 enum rspamd_metric_action action; 72 struct rspamd_symbol *symbols; 73 struct mlfi_priv *priv; 74 bool parsed; 75 bool compressed; 76 }; 77 78 #endif 79