diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/chartable.c | 24 | ||||
-rw-r--r-- | src/plugins/emails.c | 42 | ||||
-rw-r--r-- | src/plugins/fuzzy_check.c | 120 | ||||
-rw-r--r-- | src/plugins/regexp.c | 100 | ||||
-rw-r--r-- | src/plugins/spf.c | 20 | ||||
-rw-r--r-- | src/plugins/surbl.c | 102 | ||||
-rw-r--r-- | src/plugins/surbl.h | 32 |
7 files changed, 220 insertions, 220 deletions
diff --git a/src/plugins/chartable.c b/src/plugins/chartable.c index 785cd3a59..2f62464a6 100644 --- a/src/plugins/chartable.c +++ b/src/plugins/chartable.c @@ -43,8 +43,8 @@ #define DEFAULT_THRESHOLD 0.1 struct chartable_ctx { - int (*filter) (struct worker_task * task); - char *symbol; + gint (*filter) (struct worker_task * task); + gchar *symbol; double threshold; memory_pool_t *chartable_pool; @@ -52,10 +52,10 @@ struct chartable_ctx { static struct chartable_ctx *chartable_module_ctx = NULL; -static int chartable_mime_filter (struct worker_task *task); +static gint chartable_mime_filter (struct worker_task *task); static void chartable_symbol_callback (struct worker_task *task, void *unused); -int +gint chartable_module_init (struct config_file *cfg, struct module_ctx **ctx) { chartable_module_ctx = g_malloc (sizeof (struct chartable_ctx)); @@ -69,11 +69,11 @@ chartable_module_init (struct config_file *cfg, struct module_ctx **ctx) } -int +gint chartable_module_config (struct config_file *cfg) { - char *value; - int res = TRUE; + gchar *value; + gint res = TRUE; if ((value = get_module_opt (cfg, "chartable", "symbol")) != NULL) { chartable_module_ctx->symbol = memory_pool_strdup (chartable_module_ctx->chartable_pool, value); @@ -98,7 +98,7 @@ chartable_module_config (struct config_file *cfg) return res; } -int +gint chartable_module_reconfig (struct config_file *cfg) { memory_pool_delete (chartable_module_ctx->chartable_pool); @@ -110,11 +110,11 @@ chartable_module_reconfig (struct config_file *cfg) static gboolean check_part (struct mime_text_part *part, gboolean raw_mode) { - unsigned char *p, *p1; + guchar *p, *p1; gunichar c, t; GUnicodeScript scc, sct; - uint32_t mark = 0, total = 0; - uint32_t remain = part->content->len; + guint32 mark = 0, total = 0; + guint32 remain = part->content->len; p = part->content->data; @@ -188,7 +188,7 @@ chartable_symbol_callback (struct worker_task *task, void *unused) } -static int +static gint chartable_mime_filter (struct worker_task *task) { /* XXX: remove it */ diff --git a/src/plugins/emails.c b/src/plugins/emails.c index 1b20b2742..29dc040a3 100644 --- a/src/plugins/emails.c +++ b/src/plugins/emails.c @@ -42,27 +42,27 @@ #define DEFAULT_SYMBOL "R_BAD_EMAIL" -static const char *email_re_text = +static const gchar *email_re_text = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+(?:[A-Z]{2}|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum)\\b"; struct email_ctx { - int (*filter) (struct worker_task * task); - char *symbol; + gint (*filter) (struct worker_task * task); + gchar *symbol; GRegex *email_re; GHashTable *blacklist; - char *blacklist_file; + gchar *blacklist_file; memory_pool_t *email_pool; }; static struct email_ctx *email_module_ctx = NULL; -static int emails_mime_filter (struct worker_task *task); +static gint emails_mime_filter (struct worker_task *task); static void emails_symbol_callback (struct worker_task *task, void *unused); -static int emails_command_handler (struct worker_task *task); +static gint emails_command_handler (struct worker_task *task); -int +gint emails_module_init (struct config_file *cfg, struct module_ctx **ctx) { GError *err = NULL; @@ -82,11 +82,11 @@ emails_module_init (struct config_file *cfg, struct module_ctx **ctx) } -int +gint emails_module_config (struct config_file *cfg) { - char *value; - int res = TRUE; + gchar *value; + gint res = TRUE; if ((value = get_module_opt (cfg, "emails", "symbol")) != NULL) { email_module_ctx->symbol = memory_pool_strdup (email_module_ctx->email_pool, value); @@ -106,7 +106,7 @@ emails_module_config (struct config_file *cfg) return res; } -int +gint emails_module_reconfig (struct config_file *cfg) { memory_pool_delete (email_module_ctx->email_pool); @@ -122,8 +122,8 @@ extract_emails (struct worker_task *task) GMatchInfo *info; GError *err = NULL; struct mime_text_part *part; - char *email_str; - int rc; + gchar *email_str; + gint rc; cur = g_list_first (task->text_parts); while (cur) { @@ -134,7 +134,7 @@ extract_emails (struct worker_task *task) continue; } - rc = g_regex_match_full (email_module_ctx->email_re, (const char *)part->orig->data, part->orig->len, 0, 0, &info, &err); + rc = g_regex_match_full (email_module_ctx->email_re, (const gchar *)part->orig->data, part->orig->len, 0, 0, &info, &err); if (rc) { while (g_match_info_matches (info)) { email_str = g_match_info_fetch (info, 0); @@ -163,12 +163,12 @@ extract_emails (struct worker_task *task) return res; } -static int +static gint emails_command_handler (struct worker_task *task) { GList *emails, *cur; - char outbuf[BUFSIZ]; - int r, num = 0; + gchar outbuf[BUFSIZ]; + gint r, num = 0; emails = extract_emails (task); @@ -181,10 +181,10 @@ emails_command_handler (struct worker_task *task) while (cur) { num++; if (g_list_next (cur) != NULL) { - r += snprintf (outbuf + r, sizeof (outbuf) - r - 2, "%s, ", (char *)cur->data); + r += snprintf (outbuf + r, sizeof (outbuf) - r - 2, "%s, ", (gchar *)cur->data); } else { - r += snprintf (outbuf + r, sizeof (outbuf) - r - 2, "%s", (char *)cur->data); + r += snprintf (outbuf + r, sizeof (outbuf) - r - 2, "%s", (gchar *)cur->data); } cur = g_list_next (cur); } @@ -213,7 +213,7 @@ emails_symbol_callback (struct worker_task *task, void *unused) while (cur) { if (g_hash_table_lookup (email_module_ctx->blacklist, cur->data) != NULL) { - insert_result (task, email_module_ctx->symbol, 1, g_list_prepend (NULL, memory_pool_strdup (task->task_pool, (char *)cur->data))); + insert_result (task, email_module_ctx->symbol, 1, g_list_prepend (NULL, memory_pool_strdup (task->task_pool, (gchar *)cur->data))); } cur = g_list_next (cur); @@ -223,7 +223,7 @@ emails_symbol_callback (struct worker_task *task, void *unused) } -static int +static gint emails_mime_filter (struct worker_task *task) { /* XXX: remove this */ diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index edfc1caa8..1942d3c5a 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -61,27 +61,27 @@ struct storage_server { struct upstream up; - char *name; + gchar *name; struct in_addr addr; - uint16_t port; + guint16 port; }; struct fuzzy_mapping { - uint32_t fuzzy_flag; - char *symbol; + guint32 fuzzy_flag; + gchar *symbol; double weight; }; struct fuzzy_mime_type { - char *type; - char *subtype; + gchar *type; + gchar *subtype; }; struct fuzzy_ctx { - int (*filter) (struct worker_task * task); - char *symbol; + gint (*filter) (struct worker_task * task); + gchar *symbol; struct storage_server *servers; - int servers_num; + gint servers_num; memory_pool_t *fuzzy_pool; double max_score; gint32 min_hash_len; @@ -94,43 +94,43 @@ struct fuzzy_ctx { }; struct fuzzy_client_session { - int state; + gint state; fuzzy_hash_t *h; struct event ev; struct timeval tv; struct worker_task *task; struct storage_server *server; - int fd; + gint fd; }; struct fuzzy_learn_session { struct event ev; fuzzy_hash_t *h; - int cmd; - int value; - int flag; - int *saved; + gint cmd; + gint value; + gint flag; + gint *saved; struct timeval tv; struct controller_session *session; struct storage_server *server; struct worker_task *task; - int fd; + gint fd; }; static struct fuzzy_ctx *fuzzy_module_ctx = NULL; static const gchar hex_digits[] = "0123456789abcdef"; -static int fuzzy_mime_filter (struct worker_task *task); +static gint fuzzy_mime_filter (struct worker_task *task); static void fuzzy_symbol_callback (struct worker_task *task, void *unused); -static void fuzzy_add_handler (char **args, struct controller_session *session); -static void fuzzy_delete_handler (char **args, struct controller_session *session); +static void fuzzy_add_handler (gchar **args, struct controller_session *session); +static void fuzzy_delete_handler (gchar **args, struct controller_session *session); /* Flags string is in format <numeric_flag>:<SYMBOL>:weight[, <numeric_flag>:<SYMBOL>:weight...] */ static void -parse_flags_string (char *str) +parse_flags_string (gchar *str) { - char **strvec, *item, *err_str, **map_str; - int num, i, t; + gchar **strvec, *item, *err_str, **map_str; + gint num, i, t; struct fuzzy_mapping *map; strvec = g_strsplit_set (str, ", ;", 0); @@ -169,10 +169,10 @@ parse_flags_string (char *str) } static GList * -parse_mime_types (const char *str) +parse_mime_types (const gchar *str) { - char **strvec, *p; - int num, i; + gchar **strvec, *p; + gint num, i; struct fuzzy_mime_type *type; GList *res = NULL; @@ -218,10 +218,10 @@ fuzzy_check_content_type (GMimeContentType *type) } static void -parse_servers_string (char *str) +parse_servers_string (gchar *str) { - char **strvec, *p, portbuf[6], *name; - int num, i, j, port; + gchar **strvec, *p, portbuf[6], *name; + gint num, i, j, port; struct hostent *hent; struct in_addr addr; @@ -277,7 +277,7 @@ parse_servers_string (char *str) } static double -fuzzy_normalize (int32_t in, double weight) +fuzzy_normalize (gint32 in, double weight) { double ms = weight, ams = fabs (ms), ain = fabs (in); @@ -297,11 +297,11 @@ fuzzy_normalize (int32_t in, double weight) return (double)in; } -static const char * +static const gchar * fuzzy_to_string (fuzzy_hash_t *h) { - static char strbuf [FUZZY_HASHLEN * 2 + 1]; - int i; + static gchar strbuf [FUZZY_HASHLEN * 2 + 1]; + gint i; guint8 byte; for (i = 0; i < FUZZY_HASHLEN; i ++) { @@ -318,7 +318,7 @@ fuzzy_to_string (fuzzy_hash_t *h) return strbuf; } -int +gint fuzzy_check_module_init (struct config_file *cfg, struct module_ctx **ctx) { fuzzy_module_ctx = g_malloc0 (sizeof (struct fuzzy_ctx)); @@ -334,11 +334,11 @@ fuzzy_check_module_init (struct config_file *cfg, struct module_ctx **ctx) return 0; } -int +gint fuzzy_check_module_config (struct config_file *cfg) { - char *value; - int res = TRUE; + gchar *value; + gint res = TRUE; if ((value = get_module_opt (cfg, "fuzzy_check", "symbol")) != NULL) { fuzzy_module_ctx->symbol = memory_pool_strdup (fuzzy_module_ctx->fuzzy_pool, value); @@ -406,7 +406,7 @@ fuzzy_check_module_config (struct config_file *cfg) return res; } -int +gint fuzzy_check_module_reconfig (struct config_file *cfg) { memory_pool_delete (fuzzy_module_ctx->fuzzy_pool); @@ -436,13 +436,13 @@ fuzzy_io_fin (void *ud) /* Call this whenever we got data from fuzzy storage */ static void -fuzzy_io_callback (int fd, short what, void *arg) +fuzzy_io_callback (gint fd, short what, void *arg) { struct fuzzy_client_session *session = arg; struct fuzzy_cmd cmd; struct fuzzy_mapping *map; - char buf[62], *err_str, *symbol; - int value = 0, flag = 0, r; + gchar buf[62], *err_str, *symbol; + gint value = 0, flag = 0, r; double nval; if (what == EV_WRITE) { @@ -522,12 +522,12 @@ fuzzy_learn_fin (void *arg) } static void -fuzzy_learn_callback (int fd, short what, void *arg) +fuzzy_learn_callback (gint fd, short what, void *arg) { struct fuzzy_learn_session *session = arg; struct fuzzy_cmd cmd; - char buf[64]; - int r; + gchar buf[64]; + gint r; if (what == EV_WRITE) { /* Send command to storage */ @@ -588,7 +588,7 @@ register_fuzzy_call (struct worker_task *task, fuzzy_hash_t *h) { struct fuzzy_client_session *session; struct storage_server *selected; - int sock; + gint sock; /* Get upstream */ #ifdef HAVE_CLOCK_GETTIME @@ -629,14 +629,14 @@ fuzzy_symbol_callback (struct worker_task *task, void *unused) struct mime_text_part *part; struct mime_part *mime_part; struct rspamd_image *image; - char *checksum; + gchar *checksum; GList *cur; fuzzy_hash_t *fake_fuzzy; /* Check whitelist */ if (fuzzy_module_ctx->whitelist && task->from_addr.s_addr != 0) { - if (radix32tree_find (fuzzy_module_ctx->whitelist, ntohl ((uint32_t) task->from_addr.s_addr)) != RADIX_NO_VALUE) { + if (radix32tree_find (fuzzy_module_ctx->whitelist, ntohl ((guint32) task->from_addr.s_addr)) != RADIX_NO_VALUE) { msg_info ("<%s>, address %s is whitelisted, skip fuzzy check", task->message_id, inet_ntoa (task->from_addr)); return; @@ -703,12 +703,12 @@ fuzzy_symbol_callback (struct worker_task *task, void *unused) G_INLINE_FUNC gboolean register_fuzzy_controller_call (struct controller_session *session, struct worker_task *task, fuzzy_hash_t *h, - int cmd, int value, int flag, int *saved) + gint cmd, gint value, gint flag, gint *saved) { struct fuzzy_learn_session *s; struct storage_server *selected; - int sock, r; - char out_buf[BUFSIZ]; + gint sock, r; + gchar out_buf[BUFSIZ]; /* Get upstream */ #ifdef HAVE_CLOCK_GETTIME @@ -765,8 +765,8 @@ fuzzy_process_handler (struct controller_session *session, f_str_t * in) struct mime_part *mime_part; struct rspamd_image *image; GList *cur; - int r, cmd = 0, value = 0, flag = 0, *saved, *sargs; - char out_buf[BUFSIZ], *checksum; + gint r, cmd = 0, value = 0, flag = 0, *saved, *sargs; + gchar out_buf[BUFSIZ], *checksum; fuzzy_hash_t fake_fuzzy; /* Extract arguments */ @@ -788,7 +788,7 @@ fuzzy_process_handler (struct controller_session *session, f_str_t * in) task->msg->len = in->len; - saved = memory_pool_alloc0 (session->session_pool, sizeof (int)); + saved = memory_pool_alloc0 (session->session_pool, sizeof (gint)); r = process_message (task); if (r == -1) { msg_warn ("processing of message failed"); @@ -897,11 +897,11 @@ fuzzy_process_handler (struct controller_session *session, f_str_t * in) } static void -fuzzy_controller_handler (char **args, struct controller_session *session, int cmd) +fuzzy_controller_handler (gchar **args, struct controller_session *session, gint cmd) { - char *arg, out_buf[BUFSIZ], *err_str; - uint32_t size; - int r, value = 1, flag = 0, *sargs; + gchar *arg, out_buf[BUFSIZ], *err_str; + guint32 size; + gint r, value = 1, flag = 0, *sargs; /* Process size */ arg = args[0]; @@ -949,7 +949,7 @@ fuzzy_controller_handler (char **args, struct controller_session *session, int c rspamd_set_dispatcher_policy (session->dispatcher, BUFFER_CHARACTER, size); session->other_handler = fuzzy_process_handler; /* Prepare args */ - sargs = memory_pool_alloc (session->session_pool, sizeof (int) * 3); + sargs = memory_pool_alloc (session->session_pool, sizeof (gint) * 3); sargs[0] = cmd; sargs[1] = value; sargs[2] = flag; @@ -957,18 +957,18 @@ fuzzy_controller_handler (char **args, struct controller_session *session, int c } static void -fuzzy_add_handler (char **args, struct controller_session *session) +fuzzy_add_handler (gchar **args, struct controller_session *session) { fuzzy_controller_handler (args, session, FUZZY_WRITE); } static void -fuzzy_delete_handler (char **args, struct controller_session *session) +fuzzy_delete_handler (gchar **args, struct controller_session *session) { fuzzy_controller_handler (args, session, FUZZY_DEL); } -static int +static gint fuzzy_mime_filter (struct worker_task *task) { /* XXX: remove this */ diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index 81c267a4a..1b726fd30 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -43,37 +43,37 @@ #define DEFAULT_STATFILE_PREFIX "./" struct regexp_module_item { - struct expression *expr; - char *symbol; - long int avg_time; + struct expression *expr; + gchar *symbol; + guint32 avg_time; gpointer lua_function; }; struct autolearn_data { - char *statfile_name; - char *symbol; + gchar *statfile_name; + gchar *symbol; float weight; }; struct regexp_ctx { - int (*filter) (struct worker_task * task); + gint (*filter) (struct worker_task * task); GHashTable *autolearn_symbols; - char *statfile_prefix; + gchar *statfile_prefix; memory_pool_t *regexp_pool; memory_pool_t *dynamic_pool; }; struct regexp_json_buf { - u_char *buf; - u_char *pos; + guint8 *buf; + guint8 *pos; size_t buflen; struct config_file *cfg; }; static struct regexp_ctx *regexp_module_ctx = NULL; -static int regexp_common_filter (struct worker_task *task); +static gint regexp_common_filter (struct worker_task *task); static gboolean rspamd_regexp_match_number (struct worker_task *task, GList * args, void *unused); static gboolean rspamd_raw_header_exists (struct worker_task *task, GList * args, void *unused); static gboolean rspamd_check_smtp_data (struct worker_task *task, GList * args, void *unused); @@ -83,17 +83,17 @@ static void process_regexp_item (struct worker_task *task, v static void regexp_dynamic_insert_result (struct worker_task *task, void *user_data) { - char *symbol = user_data; + gchar *symbol = user_data; insert_result (task, symbol, 1, NULL); } static gboolean -parse_regexp_ipmask (const char *begin, struct dynamic_map_item *addr) +parse_regexp_ipmask (const gchar *begin, struct dynamic_map_item *addr) { - const char *pos; - char ip_buf[sizeof ("255.255.255.255")], mask_buf[3], *p; - int state = 0, dots = 0; + const gchar *pos; + gchar ip_buf[sizeof ("255.255.255.255")], mask_buf[3], *p; + gint state = 0, dots = 0; bzero (ip_buf, sizeof (ip_buf)); bzero (mask_buf, sizeof (mask_buf)); @@ -173,7 +173,7 @@ parse_regexp_ipmask (const char *begin, struct dynamic_map_item *addr) /* Process regexp expression */ static gboolean -read_regexp_expression (memory_pool_t * pool, struct regexp_module_item *chain, char *symbol, char *line, gboolean raw_mode) +read_regexp_expression (memory_pool_t * pool, struct regexp_module_item *chain, gchar *symbol, gchar *line, gboolean raw_mode) { struct expression *e, *cur; @@ -201,8 +201,8 @@ read_regexp_expression (memory_pool_t * pool, struct regexp_module_item *chain, /* Callbacks for reading json dynamic rules */ -u_char * -json_regexp_read_cb (memory_pool_t * pool, u_char * chunk, size_t len, struct map_cb_data *data) +guint8 * +json_regexp_read_cb (memory_pool_t * pool, guint8 * chunk, size_t len, struct map_cb_data *data) { struct regexp_json_buf *jb; size_t free, off; @@ -245,10 +245,10 @@ void json_regexp_fin_cb (memory_pool_t * pool, struct map_cb_data *data) { struct regexp_json_buf *jb; - int nelts, i, j; + gint nelts, i, j; json_t *js, *cur_elt, *cur_nm, *it_val; json_error_t je; - char *cur_rule, *cur_symbol; + gchar *cur_rule, *cur_symbol; double score; gboolean enabled; struct regexp_module_item *cur_item; @@ -375,7 +375,7 @@ json_regexp_fin_cb (memory_pool_t * pool, struct map_cb_data *data) } /* Init function */ -int +gint regexp_module_init (struct config_file *cfg, struct module_ctx **ctx) { regexp_module_ctx = g_malloc (sizeof (struct regexp_ctx)); @@ -399,10 +399,10 @@ regexp_module_init (struct config_file *cfg, struct module_ctx **ctx) * SYMBOL:statfile:weight */ void -parse_autolearn_param (const char *param, const char *value, struct config_file *cfg) +parse_autolearn_param (const gchar *param, const gchar *value, struct config_file *cfg) { struct autolearn_data *d; - char *p; + gchar *p; p = memory_pool_strdup (regexp_module_ctx->regexp_pool, value); d = memory_pool_alloc (regexp_module_ctx->regexp_pool, sizeof (struct autolearn_data)); @@ -425,14 +425,14 @@ parse_autolearn_param (const char *param, const char *value, struct config_file } } -int +gint regexp_module_config (struct config_file *cfg) { GList *cur_opt = NULL; struct module_opt *cur; struct regexp_module_item *cur_item; - char *value; - int res = TRUE; + gchar *value; + gint res = TRUE; struct regexp_json_buf *jb, **pjb; if ((value = get_module_opt (cfg, "regexp", "statfile_prefix")) != NULL) { @@ -502,7 +502,7 @@ regexp_module_config (struct config_file *cfg) return res; } -int +gint regexp_module_reconfig (struct config_file *cfg) { memory_pool_delete (regexp_module_ctx->regexp_pool); @@ -511,10 +511,10 @@ regexp_module_reconfig (struct config_file *cfg) return regexp_module_config (cfg); } -static const char * -find_raw_header_pos (const char *headers, const char *headerv) +static const gchar * +find_raw_header_pos (const gchar *headers, const gchar *headerv) { - const char *p = headers; + const gchar *p = headers; gsize headerlen = strlen (headerv); if (headers == NULL) { @@ -581,9 +581,9 @@ tree_url_callback (gpointer key, gpointer value, void *data) } static gsize -process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *additional) +process_regexp (struct rspamd_regexp *re, struct worker_task *task, const gchar *additional) { - char *headerv, *c, t; + gchar *headerv, *c, t; struct mime_text_part *part; GList *cur, *headerlist; GRegex *regexp; @@ -594,7 +594,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char * .re = re, .found = FALSE }; - int r; + gint r; if (re == NULL) { @@ -654,17 +654,17 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char * } cur = headerlist; while (cur) { - debug_task ("found header \"%s\" with value \"%s\"", re->header, (const char *)cur->data); + debug_task ("found header \"%s\" with value \"%s\"", re->header, (const gchar *)cur->data); if (cur->data && g_regex_match_full (re->regexp, cur->data, -1, 0, 0, NULL, &err) == TRUE) { if (G_UNLIKELY (re->is_test)) { - msg_info ("process test regexp %s for header %s with value '%s' returned TRUE", re->regexp_text, re->header, (const char *)cur->data); + msg_info ("process test regexp %s for header %s with value '%s' returned TRUE", re->regexp_text, re->header, (const gchar *)cur->data); } task_cache_add (task, re, 1); return 1; } else if (G_UNLIKELY (re->is_test)) { - msg_info ("process test regexp %s for header %s with value '%s' returned FALSE", re->regexp_text, re->header, (const char *)cur->data); + msg_info ("process test regexp %s for header %s with value '%s' returned FALSE", re->regexp_text, re->header, (const gchar *)cur->data); } if (err != NULL) { msg_info ("error occured while processing regexp \"%s\": %s", re->regexp_text, err->message); @@ -700,7 +700,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char * return 1; } else if (G_UNLIKELY (re->is_test)) { - msg_info ("process test regexp %s for mime part of length %d returned FALSE", re->regexp_text, (int)part->orig->len); + msg_info ("process test regexp %s for mime part of length %d returned FALSE", re->regexp_text, (gint)part->orig->len); } if (err != NULL) { msg_info ("error occured while processing regexp \"%s\": %s", re->regexp_text, err->message); @@ -714,13 +714,13 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char * if (g_regex_match_full (re->raw_regexp, task->msg->begin, task->msg->len, 0, 0, NULL, &err) == TRUE) { if (G_UNLIKELY (re->is_test)) { - msg_info ("process test regexp %s for message of length %d returned TRUE", re->regexp_text, (int)task->msg->len); + msg_info ("process test regexp %s for message of length %d returned TRUE", re->regexp_text, (gint)task->msg->len); } task_cache_add (task, re, 1); return 1; } else if (G_UNLIKELY (re->is_test)) { - msg_info ("process test regexp %s for message of length %d returned FALSE", re->regexp_text, (int)task->msg->len); + msg_info ("process test regexp %s for message of length %d returned FALSE", re->regexp_text, (gint)task->msg->len); } if (err != NULL) { msg_info ("error occured while processing regexp \"%s\": %s", re->regexp_text, err->message); @@ -766,7 +766,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char * task_cache_add (task, re, 0); return 0; } - if ((headerv = (char *)find_raw_header_pos (task->raw_headers, re->header)) == NULL) { + if ((headerv = (gchar *)find_raw_header_pos (task->raw_headers, re->header)) == NULL) { /* No header was found */ task_cache_add (task, re, 0); return 0; @@ -826,7 +826,7 @@ optimize_regexp_expression (struct expression **e, GQueue * stack, gboolean res) { struct expression *it = (*e)->next; gboolean ret = FALSE, is_nearest = TRUE; - int skip_level = 0; + gint skip_level = 0; /* Skip nearest logical operators from optimization */ if (!it || (it->type == EXPR_OPERATION && it->content.operation != '!')) { @@ -878,7 +878,7 @@ optimize_regexp_expression (struct expression **e, GQueue * stack, gboolean res) } static gboolean -process_regexp_expression (struct expression *expr, char *symbol, struct worker_task *task, const char *additional) +process_regexp_expression (struct expression *expr, gchar *symbol, struct worker_task *task, const gchar *additional) { GQueue *stack; gsize cur, op1, op2; @@ -996,7 +996,7 @@ process_regexp_item (struct worker_task *task, void *user_data) } } -static int +static gint regexp_common_filter (struct worker_task *task) { /* XXX: remove this shit too */ @@ -1006,7 +1006,7 @@ regexp_common_filter (struct worker_task *task) static gboolean rspamd_regexp_match_number (struct worker_task *task, GList * args, void *unused) { - int param_count, res = 0; + gint param_count, res = 0; struct expression_argument *arg; GList *cur; @@ -1054,7 +1054,7 @@ rspamd_raw_header_exists (struct worker_task *task, GList * args, void *unused) msg_warn ("invalid argument to function is passed"); return FALSE; } - if (find_raw_header_pos (task->raw_headers, (char *)arg->data) == NULL) { + if (find_raw_header_pos (task->raw_headers, (gchar *)arg->data) == NULL) { return FALSE; } @@ -1062,20 +1062,20 @@ rspamd_raw_header_exists (struct worker_task *task, GList * args, void *unused) } static gboolean -match_smtp_data (struct worker_task *task, const char *re_text, const char *what) +match_smtp_data (struct worker_task *task, const gchar *re_text, const gchar *what) { struct rspamd_regexp *re; - int r; + gint r; if (*re_text == '/') { /* This is a regexp */ if ((re = re_cache_check (re_text, task->cfg->cfg_pool)) == NULL) { - re = parse_regexp (task->cfg->cfg_pool, (char *)re_text, task->cfg->raw_mode); + re = parse_regexp (task->cfg->cfg_pool, (gchar *)re_text, task->cfg->raw_mode); if (re == NULL) { msg_warn ("cannot compile regexp for function"); return FALSE; } - re_cache_add ((char *)re_text, re, task->cfg->cfg_pool); + re_cache_add ((gchar *)re_text, re, task->cfg->cfg_pool); } if ((r = task_cache_check (task, re)) == -1) { if (g_regex_match (re->regexp, what, 0, NULL) == TRUE) { @@ -1100,7 +1100,7 @@ rspamd_check_smtp_data (struct worker_task *task, GList * args, void *unused) { struct expression_argument *arg; GList *cur, *rcpt_list = NULL; - char *type, *what = NULL; + gchar *type, *what = NULL; if (args == NULL) { msg_warn ("no parameters to function"); diff --git a/src/plugins/spf.c b/src/plugins/spf.c index 315e57f58..868ad7a32 100644 --- a/src/plugins/spf.c +++ b/src/plugins/spf.c @@ -48,10 +48,10 @@ #define DEFAULT_SYMBOL_ALLOW "R_SPF_ALLOW" struct spf_ctx { - int (*filter) (struct worker_task * task); - char *symbol_fail; - char *symbol_softfail; - char *symbol_allow; + gint (*filter) (struct worker_task * task); + gchar *symbol_fail; + gchar *symbol_softfail; + gchar *symbol_allow; memory_pool_t *spf_pool; radix_tree_t *whitelist_ip; @@ -61,7 +61,7 @@ static struct spf_ctx *spf_module_ctx = NULL; static void spf_symbol_callback (struct worker_task *task, void *unused); -int +gint spf_module_init (struct config_file *cfg, struct module_ctx **ctx) { spf_module_ctx = g_malloc (sizeof (struct spf_ctx)); @@ -74,11 +74,11 @@ spf_module_init (struct config_file *cfg, struct module_ctx **ctx) } -int +gint spf_module_config (struct config_file *cfg) { - char *value; - int res = TRUE; + gchar *value; + gint res = TRUE; spf_module_ctx->whitelist_ip = radix_tree_create (); @@ -111,7 +111,7 @@ spf_module_config (struct config_file *cfg) return res; } -int +gint spf_module_reconfig (struct config_file *cfg) { memory_pool_delete (spf_module_ctx->spf_pool); @@ -126,7 +126,7 @@ spf_plugin_callback (struct spf_record *record, struct worker_task *task) { GList *cur; struct spf_addr *addr; - uint32_t s, m; + guint32 s, m; if (record) { cur = g_list_first (record->addrs); diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index 25132a0f9..71fbbd55d 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -52,11 +52,11 @@ static struct surbl_ctx *surbl_module_ctx = NULL; -static int surbl_filter (struct worker_task *task); +static gint surbl_filter (struct worker_task *task); static void surbl_test_url (struct worker_task *task, void *user_data); static void dns_callback (struct rspamd_dns_reply *reply, gpointer arg); -static void process_dns_results (struct worker_task *task, struct suffix_item *suffix, char *url, uint32_t addr); -static int urls_command_handler (struct worker_task *task); +static void process_dns_results (struct worker_task *task, struct suffix_item *suffix, gchar *url, guint32 addr); +static gint urls_command_handler (struct worker_task *task); #define NO_REGEXP (gpointer)-1 @@ -73,8 +73,8 @@ static void exception_insert (gpointer st, gconstpointer key, gpointer value) { GHashTable **t = st; - int level = 0; - const char *p = key; + gint level = 0; + const gchar *p = key; f_str_t *val; @@ -85,12 +85,12 @@ exception_insert (gpointer st, gconstpointer key, gpointer value) p ++; } if (level >= MAX_LEVELS) { - msg_err ("invalid domain in exceptions list: %s, levels: %d", (char *)key, level); + msg_err ("invalid domain in exceptions list: %s, levels: %d", (gchar *)key, level); return; } val = g_malloc (sizeof (f_str_t)); - val->begin = (char *)key; + val->begin = (gchar *)key; val->len = strlen (key); if (t[level] == NULL) { t[level] = g_hash_table_new_full (fstr_strcase_hash, fstr_strcase_equal, g_free, NULL); @@ -111,7 +111,7 @@ static void fin_exceptions_list (memory_pool_t * pool, struct map_cb_data *data) { GHashTable **t; - int i; + gint i; if (data->prev_data) { t = data->prev_data; @@ -127,7 +127,7 @@ static void redirector_insert (gpointer st, gconstpointer key, gpointer value) { GHashTable *t = st; - const char *p = key, *begin = key; + const gchar *p = key, *begin = key; gchar *new; gsize len; GRegex *re = NO_REGEXP; @@ -190,7 +190,7 @@ fin_redirectors_list (memory_pool_t * pool, struct map_cb_data *data) } } -int +gint surbl_module_init (struct config_file *cfg, struct module_ctx **ctx) { surbl_module_ctx = g_malloc (sizeof (struct surbl_ctx)); @@ -228,7 +228,7 @@ surbl_module_init (struct config_file *cfg, struct module_ctx **ctx) return 0; } -int +gint surbl_module_config (struct config_file *cfg) { GList *cur_opt; @@ -236,7 +236,7 @@ surbl_module_config (struct config_file *cfg) struct suffix_item *new_suffix; struct surbl_bit_item *new_bit; - char *value, *str, **strvec; + gchar *value, *str, **strvec; guint32 bit; gint i, idx; @@ -337,7 +337,7 @@ surbl_module_config (struct config_file *cfg) new_bit = memory_pool_alloc (surbl_module_ctx->surbl_pool, sizeof (struct surbl_bit_item)); new_bit->bit = bit; new_bit->symbol = memory_pool_strdup (surbl_module_ctx->surbl_pool, cur->value); - msg_debug ("add new bit suffix: %d with symbol: %s", (int)new_bit->bit, new_bit->symbol); + msg_debug ("add new bit suffix: %d with symbol: %s", (gint)new_bit->bit, new_bit->symbol); surbl_module_ctx->bits = g_list_prepend (surbl_module_ctx->bits, new_bit); } } @@ -357,7 +357,7 @@ surbl_module_config (struct config_file *cfg) return TRUE; } -int +gint surbl_module_reconfig (struct config_file *cfg) { /* Delete pool and objects */ @@ -394,13 +394,13 @@ surbl_module_reconfig (struct config_file *cfg) -static char * +static gchar * format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_item *suffix, gboolean append_suffix, GError ** err, gboolean forced) { GHashTable *t; - char *result = NULL, *dots[MAX_LEVELS], num_buf[sizeof("18446744073709551616")], *p; - int len, slen, r, i, dots_num = 0, level = MAX_LEVELS; + gchar *result = NULL, *dots[MAX_LEVELS], num_buf[sizeof("18446744073709551616")], *p; + gint len, slen, r, i, dots_num = 0, level = MAX_LEVELS; gboolean is_numeric = TRUE; guint64 ip_num; f_str_t f; @@ -433,13 +433,13 @@ format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_it /* This is ip address */ result = memory_pool_alloc (pool, len); r = rspamd_snprintf (result, len, "%*s.%*s.%*s.%*s", - (int)(hostname->len - (dots[2] - hostname->begin + 1)), + (gint)(hostname->len - (dots[2] - hostname->begin + 1)), dots[2] + 1, - (int)(dots[2] - dots[1] - 1), + (gint)(dots[2] - dots[1] - 1), dots[1] + 1, - (int)(dots[1] - dots[0] - 1), + (gint)(dots[1] - dots[0] - 1), dots[0] + 1, - (int)(dots[0] - hostname->begin), + (gint)(dots[0] - hostname->begin), hostname->begin); } else if (is_numeric && dots_num == 0) { @@ -461,7 +461,7 @@ format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_it ip_num &= 0xFFFFFFFF; /* Get octets */ r = rspamd_snprintf (result, len, "%ud.%ud.%ud.%ud", - (uint32_t) ip_num & 0x000000FF, (uint32_t) (ip_num & 0x0000FF00) >> 8, (uint32_t) (ip_num & 0x00FF0000) >> 16, (uint32_t) (ip_num & 0xFF000000) >> 24); + (guint32) ip_num & 0x000000FF, (guint32) (ip_num & 0x0000FF00) >> 8, (guint32) (ip_num & 0x00FF0000) >> 16, (guint32) (ip_num & 0xFF000000) >> 24); } else { /* Not a numeric url */ @@ -482,21 +482,21 @@ format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_it } if (level != MAX_LEVELS) { if (level == 0) { - r = rspamd_snprintf (result, len, "%*s", (int)hostname->len, hostname->begin); + r = rspamd_snprintf (result, len, "%*s", (gint)hostname->len, hostname->begin); } else { r = rspamd_snprintf (result, len, "%*s", - (int)(hostname->len - (dots[level - 1] - hostname->begin + 1)), + (gint)(hostname->len - (dots[level - 1] - hostname->begin + 1)), dots[level - 1] + 1); } } else if (dots_num >= 2) { r = rspamd_snprintf (result, len, "%*s", - (int)(hostname->len - (dots[dots_num - 2] - hostname->begin + 1)), + (gint)(hostname->len - (dots[dots_num - 2] - hostname->begin + 1)), dots[dots_num - 2] + 1); } else { - r = rspamd_snprintf (result, len, "%*s", (int)hostname->len, hostname->begin); + r = rspamd_snprintf (result, len, "%*s", (gint)hostname->len, hostname->begin); } } @@ -514,7 +514,7 @@ format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_it r += rspamd_snprintf (result + r, len - r, ".%s", suffix->suffix); } - msg_debug ("request: %s, dots: %d, level: %d, orig: %*s", result, dots_num, level, (int)hostname->len, hostname->begin); + msg_debug ("request: %s, dots: %d, level: %d, orig: %*s", result, dots_num, level, (gint)hostname->len, hostname->begin); return result; } @@ -523,7 +523,7 @@ static void make_surbl_requests (struct uri *url, struct worker_task *task, GTree * tree, struct suffix_item *suffix, gboolean forced) { - char *surbl_req; + gchar *surbl_req; f_str_t f; GError *err = NULL; struct dns_param *param; @@ -564,20 +564,20 @@ make_surbl_requests (struct uri *url, struct worker_task *task, GTree * tree, } static void -process_dns_results (struct worker_task *task, struct suffix_item *suffix, char *url, uint32_t addr) +process_dns_results (struct worker_task *task, struct suffix_item *suffix, gchar *url, guint32 addr) { - char *c, *symbol; + gchar *c, *symbol; GList *cur; struct surbl_bit_item *bit; - int len, found = 0; + gint len, found = 0; if ((c = strchr (suffix->symbol, '%')) != NULL && *(c + 1) == 'b') { cur = g_list_first (surbl_module_ctx->bits); while (cur) { bit = (struct surbl_bit_item *)cur->data; - debug_task ("got result(%d) AND bit(%d): %d", (int)addr, (int)ntohl (bit->bit), (int)bit->bit & (int)ntohl (addr)); - if (((int)bit->bit & (int)ntohl (addr)) != 0) { + debug_task ("got result(%d) AND bit(%d): %d", (gint)addr, (gint)ntohl (bit->bit), (gint)bit->bit & (gint)ntohl (addr)); + if (((gint)bit->bit & (gint)ntohl (addr)) != 0) { len = strlen (suffix->symbol) - 2 + strlen (bit->symbol) + 1; *c = '\0'; symbol = memory_pool_alloc (task->task_pool, len); @@ -610,7 +610,7 @@ dns_callback (struct rspamd_dns_reply *reply, gpointer arg) if (reply->code == DNS_RC_NOERROR && reply->elements) { msg_info ("<%s> domain [%s] is in surbl %s", param->task->message_id, param->host_resolve, param->suffix->suffix); elt = reply->elements->data; - process_dns_results (param->task, param->suffix, param->host_resolve, (uint32_t)elt->a.addr[0].s_addr); + process_dns_results (param->task, param->suffix, param->host_resolve, (guint32)elt->a.addr[0].s_addr); } else { debug_task ("<%s> domain [%s] is not in surbl %s", param->task->message_id, param->host_resolve, param->suffix->suffix); @@ -628,7 +628,7 @@ static void memcached_callback (memcached_ctx_t * ctx, memc_error_t error, void *data) { struct memcached_param *param = (struct memcached_param *)data; - int *url_count; + gint *url_count; switch (ctx->op) { case CMD_CONNECT: @@ -658,7 +658,7 @@ memcached_callback (memcached_ctx_t * ctx, memc_error_t error, void *data) } } else { - url_count = (int *)param->ctx->param->buf; + url_count = (gint *)param->ctx->param->buf; /* Do not check DNS for urls that have count more than max_urls */ if (*url_count > surbl_module_ctx->max_urls) { msg_info ("url '%s' has count %d, max: %d", struri (param->url), *url_count, surbl_module_ctx->max_urls); @@ -696,11 +696,11 @@ register_memcached_call (struct uri *url, struct worker_task *task, GTree * url_ struct memcached_server *selected; memcached_param_t *cur_param; gchar *sum_str; - int *url_count; + gint *url_count; param = memory_pool_alloc (task->task_pool, sizeof (struct memcached_param)); cur_param = memory_pool_alloc0 (task->task_pool, sizeof (memcached_param_t)); - url_count = memory_pool_alloc (task->task_pool, sizeof (int)); + url_count = memory_pool_alloc (task->task_pool, sizeof (gint)); param->url = url; param->task = task; @@ -710,7 +710,7 @@ register_memcached_call (struct uri *url, struct worker_task *task, GTree * url_ param->ctx = memory_pool_alloc0 (task->task_pool, sizeof (memcached_ctx_t)); cur_param->buf = (u_char *) url_count; - cur_param->bufsize = sizeof (int); + cur_param->bufsize = sizeof (gint); sum_str = g_compute_checksum_for_string (G_CHECKSUM_MD5, struri (url), -1); g_strlcpy (cur_param->key, sum_str, sizeof (cur_param->key)); @@ -759,14 +759,14 @@ free_redirector_session (void *ud) } static void -redirector_callback (int fd, short what, void *arg) +redirector_callback (gint fd, short what, void *arg) { struct redirector_param *param = (struct redirector_param *)arg; struct worker_task *task = param->task; - char url_buf[1024]; - int r; + gchar url_buf[1024]; + gint r; struct timeval *timeout; - char *p, *c; + gchar *p, *c; switch (param->state) { case STATE_CONNECT: @@ -829,7 +829,7 @@ redirector_callback (int fd, short what, void *arg) static void register_redirector_call (struct uri *url, struct worker_task *task, GTree * url_tree, struct suffix_item *suffix) { - int s = -1; + gint s = -1; struct redirector_param *param; struct timeval *timeout; struct redirector_upstream *selected; @@ -876,7 +876,7 @@ surbl_tree_url_callback (gpointer key, gpointer value, void *data) struct worker_task *task = param->task; struct uri *url = value; f_str_t f; - char *red_domain; + gchar *red_domain; GRegex *re; guint idx; @@ -945,7 +945,7 @@ surbl_test_url (struct worker_task *task, void *user_data) memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_tree_destroy, url_tree); } -static int +static gint surbl_filter (struct worker_task *task) { /* XXX: remove this shit */ @@ -956,8 +956,8 @@ static gboolean urls_command_handler (struct worker_task *task) { GList *cur; - char *outbuf, *urlstr; - int r, num = 0, buflen; + gchar *outbuf, *urlstr; + gint r, num = 0, buflen; struct uri *url; GError *err = NULL; GTree *url_tree; @@ -976,7 +976,7 @@ urls_command_handler (struct worker_task *task) buflen += sizeof (RSPAMD_REPLY_BANNER " 0 OK" CRLF CRLF "Urls: "); - outbuf = memory_pool_alloc (task->task_pool, buflen * sizeof (char)); + outbuf = memory_pool_alloc (task->task_pool, buflen * sizeof (gchar)); r = rspamd_snprintf (outbuf, buflen, "%s 0 %s" CRLF, (task->proto == SPAMC_PROTO) ? SPAMD_REPLY_BANNER : RSPAMD_REPLY_BANNER, "OK"); @@ -993,10 +993,10 @@ urls_command_handler (struct worker_task *task) f.len = url->hostlen; if ((urlstr = format_surbl_request (task->task_pool, &f, NULL, FALSE, &err, FALSE)) != NULL) { if (g_list_next (cur) != NULL) { - r += rspamd_snprintf (outbuf + r, buflen - r - 2, "%s <\"%s\">, ", (char *)urlstr, struri (url)); + r += rspamd_snprintf (outbuf + r, buflen - r - 2, "%s <\"%s\">, ", (gchar *)urlstr, struri (url)); } else { - r += rspamd_snprintf (outbuf + r, buflen - r - 2, "%s <\"%s\">", (char *)urlstr, struri (url)); + r += rspamd_snprintf (outbuf + r, buflen - r - 2, "%s <\"%s\">", (gchar *)urlstr, struri (url)); } } } diff --git a/src/plugins/surbl.h b/src/plugins/surbl.h index 1df6fae31..3760f5808 100644 --- a/src/plugins/surbl.h +++ b/src/plugins/surbl.h @@ -26,37 +26,37 @@ struct redirector_upstream { }; struct surbl_ctx { - int (*filter)(struct worker_task *task); - uint16_t weight; - unsigned int connect_timeout; - unsigned int read_timeout; - unsigned int max_urls; - unsigned int url_expire; + gint (*filter)(struct worker_task *task); + guint16 weight; + guint connect_timeout; + guint read_timeout; + guint max_urls; + guint url_expire; GList *suffixes; GList *bits; - char *metric; - const char *tld2_file; - const char *whitelist_file; + gchar *metric; + const gchar *tld2_file; + const gchar *whitelist_file; GHashTable **exceptions; GHashTable *whitelist; GHashTable *redirector_hosts; rspamd_trie_t *redirector_trie; GPtrArray *redirector_ptrs; - unsigned use_redirector; + guint use_redirector; struct redirector_upstream *redirectors; guint32 redirectors_number; memory_pool_t *surbl_pool; }; struct suffix_item { - const char *suffix; - const char *symbol; + const gchar *suffix; + const gchar *symbol; }; struct dns_param { struct uri *url; struct worker_task *task; - char *host_resolve; + gchar *host_resolve; struct suffix_item *suffix; }; @@ -69,7 +69,7 @@ struct redirector_param { STATE_READ, } state; struct event ev; - int sock; + gint sock; GTree *tree; struct suffix_item *suffix; }; @@ -83,8 +83,8 @@ struct memcached_param { }; struct surbl_bit_item { - uint32_t bit; - const char *symbol; + guint32 bit; + const gchar *symbol; }; #endif |