From: Vsevolod Stakhov Date: Mon, 6 Apr 2015 12:48:35 +0000 (+0100) Subject: Use TLD file directly within API. X-Git-Tag: 0.9.0~329 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d3a212a0e7ec28b4c9ed139b2d566155782bcba8;p=rspamd.git Use TLD file directly within API. --- diff --git a/src/libserver/url.c b/src/libserver/url.c index dff3ea1fc..b4c605d36 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -890,7 +890,7 @@ rspamd_url_add_static_matchers (GArray *matchers) } void -rspamd_url_init (struct rspamd_config *cfg) +rspamd_url_init (const gchar *tld_file) { guint i; gchar patbuf[128]; @@ -904,8 +904,8 @@ rspamd_url_init (struct rspamd_config *cfg) url_scanner->tld_trie = rspamd_trie_create (TRUE); rspamd_url_add_static_matchers (url_scanner->matchers); - if (cfg != NULL && cfg->tld_file) { - rspamd_url_parse_tld_file (cfg->tld_file, url_scanner); + if (tld_file != NULL) { + rspamd_url_parse_tld_file (tld_file, url_scanner); } else { msg_warn ("tld extension file is not specified, url matching is limited"); diff --git a/src/libserver/url.h b/src/libserver/url.h index a066d214d..8dc2a7032 100644 --- a/src/libserver/url.h +++ b/src/libserver/url.h @@ -7,7 +7,6 @@ struct rspamd_task; struct mime_text_part; -struct rspamd_config; struct rspamd_url { gchar *string; @@ -67,7 +66,7 @@ enum rspamd_url_protocol { * Initialize url library * @param cfg */ -void rspamd_url_init (struct rspamd_config *cfg); +void rspamd_url_init (const gchar *tld_file); /* * Parse urls inside text diff --git a/src/main.c b/src/main.c index 6cfbf114b..2d6216b1f 100644 --- a/src/main.c +++ b/src/main.c @@ -1358,7 +1358,7 @@ main (gint argc, gchar **argv, gchar **env) } rspamd_stat_init (rspamd_main->cfg); - rspamd_url_init (rspamd_main->cfg); + rspamd_url_init (rspamd_main->cfg->tld_file); /* Insert classifiers symbols */ (void)rspamd_config_insert_classify_symbols (rspamd_main->cfg); diff --git a/test/lua/unit/url.lua b/test/lua/unit/url.lua index dd6f4b760..a593ac153 100644 --- a/test/lua/unit/url.lua +++ b/test/lua/unit/url.lua @@ -42,7 +42,7 @@ context("URL check functions", function() struct rspamd_url* rspamd_url_get_next (void *pool, const char *start, char const **pos); void * rspamd_mempool_new (unsigned long size); - void rspamd_url_init (struct rspamd_config *cfg); + void rspamd_url_init (const char *tld_file); ]] test("Extract urls from text", function()