diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-12-22 23:58:51 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-12-22 23:58:51 +0000 |
commit | 7bf934ec685f615509df5295b6d521607a036373 (patch) | |
tree | 69405c2c15a2623fd07d3bafd8be7c6263c0f3cf /utils | |
parent | 93cad030fda4f15c32494f815790d9f953068352 (diff) | |
download | rspamd-7bf934ec685f615509df5295b6d521607a036373.tar.gz rspamd-7bf934ec685f615509df5295b6d521607a036373.zip |
[Rework] Finally remove gmime dependency from Rspamd
Diffstat (limited to 'utils')
-rw-r--r-- | utils/content_type_bench.c | 118 | ||||
-rw-r--r-- | utils/mime_tool.c | 15 |
2 files changed, 12 insertions, 121 deletions
diff --git a/utils/content_type_bench.c b/utils/content_type_bench.c index 634476b64..20eebf927 100644 --- a/utils/content_type_bench.c +++ b/utils/content_type_bench.c @@ -19,7 +19,6 @@ #include "message.h" #include "util.h" #include "content_type.h" -#include <gmime/gmime.h> static gdouble total_time = 0; static gint total_parsed = 0; @@ -44,7 +43,6 @@ rspamd_process_file (const gchar *fname, gint mode) GString *buf; struct rspamd_content_type *ct; gdouble t1, t2; - GMimeContentType *gct; rspamd_ftok_t t; f = g_io_channel_new_file (fname, "r", &err); @@ -72,16 +70,9 @@ rspamd_process_file (const gchar *fname, gint mode) ct = rspamd_content_type_parse (buf->str, buf->len, pool); t2 = rspamd_get_virtual_ticks (); } - else if (mode == MODE_GMIME) { - t1 = rspamd_get_virtual_ticks (); - gct = g_mime_content_type_new_from_string (buf->str); - t2 = rspamd_get_virtual_ticks (); - } else { - t1 = rspamd_get_virtual_ticks (); - ct = rspamd_content_type_parse (buf->str, buf->len, pool); - gct = g_mime_content_type_new_from_string (buf->str); - t2 = rspamd_get_virtual_ticks (); + rspamd_fprintf ("gmime is no longer supported\n"); + exit (EXIT_FAILURE); } total_time += t2 - t1; @@ -109,107 +100,6 @@ rspamd_process_file (const gchar *fname, gint mode) } } } - else if (mode == MODE_GMIME) { - if (gct) { - total_valid ++; - - if (g_mime_content_type_get_media_type (gct)) { - total_type ++; - } - if (g_mime_content_type_get_media_subtype (gct)) { - total_subtype ++; - } - if (g_mime_content_type_get_parameter (gct, "charset")) { - total_charset ++; - } - if (g_mime_content_type_get_parameter (gct, "boundary")) { - total_boundaries ++; - } - if (g_mime_content_type_get_params (gct)) { - total_attrs ++; - } - - g_object_unref (gct); - } - } - else { - if (gct && ct) { - total_valid ++; - - if (g_mime_content_type_get_media_type (gct) && ct->type.len) { - t.begin = g_mime_content_type_get_media_type (gct); - t.len = strlen (t.begin); - - if (rspamd_ftok_casecmp (&ct->type, &t) == 0) { - total_type ++; - } - else if (verbose) { - rspamd_fprintf (stderr, "type: '%*s'(rspamd) '%s'gmime\n", - (gint)ct->type.len, ct->type.begin, - t.begin); - } - } - if (g_mime_content_type_get_media_subtype (gct) && ct->subtype.len) { - t.begin = g_mime_content_type_get_media_subtype (gct); - t.len = strlen (t.begin); - - if (rspamd_ftok_casecmp (&ct->subtype, &t) == 0) { - total_subtype ++; - } - else if (verbose) { - rspamd_fprintf (stderr, "subtype: '%*s'(rspamd) '%s'gmime\n", - (gint)ct->subtype.len, ct->subtype.begin, - t.begin); - } - } - if (g_mime_content_type_get_parameter (gct, "charset") && ct->charset.len) { - t.begin = g_mime_content_type_get_parameter (gct, "charset"); - t.len = strlen (t.begin); - - if (rspamd_ftok_casecmp (&ct->charset, &t) == 0) { - total_charset ++; - } - else if (verbose) { - rspamd_fprintf (stderr, "charset: '%*s'(rspamd) '%s'gmime\n", - (gint)ct->charset.len, ct->charset.begin, - t.begin); - } - } - else if (g_mime_content_type_get_parameter (gct, "charset")) { - if (verbose) { - rspamd_fprintf (stderr, "charset: '%s'gmime\n", - g_mime_content_type_get_parameter (gct, "charset")); - } - } - if (g_mime_content_type_get_parameter (gct, "boundary") && ct->boundary.len) { - t.begin = g_mime_content_type_get_parameter (gct, "boundary"); - t.len = strlen (t.begin); - - if (rspamd_ftok_casecmp (&ct->boundary, &t) == 0) { - total_boundaries ++; - } - else if (verbose) { - rspamd_fprintf (stderr, "boundary: '%*s'(rspamd) '%s'gmime\n", - (gint)ct->boundary.len, ct->boundary.begin, - t.begin); - } - } - else if (g_mime_content_type_get_parameter (gct, "boundary")) { - if (verbose) { - rspamd_fprintf (stderr, "boundary: '%s'gmime\n", - g_mime_content_type_get_parameter (gct, "boundary")); - } - } - } - else if (verbose) { - rspamd_fprintf (stderr, "cannot parse: %v, %d(rspamd), %d(gmime)\n", - buf, ct ? 1 : 0, gct ? 1 : 0); - } - - if (gct) { - g_object_unref (gct); - } - } } if (err) { @@ -227,8 +117,6 @@ main (int argc, char **argv) { gint i, start = 1, mode = MODE_NORMAL; - g_mime_init (0); - if (argc > 2 && *argv[1] == '-') { start = 2; @@ -273,7 +161,5 @@ main (int argc, char **argv) total_boundaries); } - g_mime_shutdown (); - return 0; } diff --git a/utils/mime_tool.c b/utils/mime_tool.c index 6b3fbccda..cdbd4c04e 100644 --- a/utils/mime_tool.c +++ b/utils/mime_tool.c @@ -22,7 +22,6 @@ #include "task.h" #include "mime_parser.h" #include "unix-std.h" -#include <gmime/gmime.h> #define MODE_NORMAL 0 #define MODE_GMIME 1 @@ -75,6 +74,7 @@ rspamd_show_message (struct rspamd_mime_part *part) part, part->parent_part); } +#if 0 static void mime_foreach_callback (GMimeObject * parent, GMimeObject * part, @@ -114,7 +114,7 @@ mime_foreach_callback (GMimeObject * parent, g_mime_content_type_get_media_subtype (type)); } } - +#endif static void rspamd_process_file (struct rspamd_config *cfg, const gchar *fname, gint mode) { @@ -123,10 +123,12 @@ rspamd_process_file (struct rspamd_config *cfg, const gchar *fname, gint mode) gpointer map; struct stat st; GError *err = NULL; +#if 0 GMimeMessage *message; GMimeParser *parser; GMimeStream *stream; GByteArray tmp; +#endif struct rspamd_mime_part *part; guint i; gdouble ts1, ts2; @@ -163,6 +165,7 @@ rspamd_process_file (struct rspamd_config *cfg, const gchar *fname, gint mode) g_error_free (err); } } +#if 0 else if (mode == MODE_GMIME) { tmp.data = map; tmp.len = st.st_size; @@ -171,7 +174,7 @@ rspamd_process_file (struct rspamd_config *cfg, const gchar *fname, gint mode) parser = g_mime_parser_new_with_stream (stream); message = g_mime_parser_construct_message (parser); } - +#endif ts2 = rspamd_get_ticks (); total_time += ts2 - ts1; @@ -190,16 +193,19 @@ rspamd_process_file (struct rspamd_config *cfg, const gchar *fname, gint mode) } } } +#if 0 else if (mode == MODE_GMIME) { g_mime_message_foreach (message, mime_foreach_callback, NULL); } +#endif rspamd_task_free (task); munmap (map, st.st_size); - +#if 0 if (mode == MODE_GMIME) { g_object_unref (message); } +#endif } int @@ -237,7 +243,6 @@ main (int argc, char **argv) rspamd_log_close (logger); REF_RELEASE (cfg); - g_mime_shutdown (); return 0; } |