{
struct metric_result *metric_res;
struct symbol *s = NULL;
- char *opt_cpy;
gdouble w, *gr_score = NULL;
struct rspamd_symbol_def *sdef;
struct rspamd_symbols_group *gr = NULL;
struct rspamd_task *task)
{
double final_prob, h, s, *pprob;
- char *sumbuf;
+ gchar sumbuf[32];
struct rspamd_statfile *st = NULL;
struct bayes_task_closure cl;
rspamd_token_t *tok;
guint i;
gint id;
- GList *cur;
g_assert (ctx != NULL);
g_assert (tokens != NULL);
rspamd_mempool_set_variable (task->task_pool, "bayes_prob", pprob, NULL);
if (cl.processed_tokens > 0 && fabs (final_prob - 0.5) > 0.05) {
-
- sumbuf = rspamd_mempool_alloc (task->task_pool, 32);
-
/* Now we can have exactly one HAM and exactly one SPAM statfiles per classifier */
for (i = 0; i < ctx->statfiles_ids->len; i++) {
id = g_array_index (ctx->statfiles_ids, gint, i);
* Bayes p is from 0.5 to 1.0, but confidence is from 0 to 1, so
* we need to rescale it to display correctly
*/
- rspamd_snprintf (sumbuf, 32, "%.2f%%", (final_prob - 0.5) * 200.);
+ rspamd_snprintf (sumbuf, sizeof (sumbuf), "%.2f%%",
+ (final_prob - 0.5) * 200.);
final_prob = rspamd_normalize_probability (final_prob, 0.5);
g_assert (st != NULL);
- cur = g_list_prepend (NULL, sumbuf);
rspamd_task_insert_result (task,
st->stcf->symbol,
final_prob,
- cur);
+ sumbuf);
}
return TRUE;
gint level = lua_gettop (cd->L), nresults, err_idx;
lua_State *L = cd->L;
GString *tb;
+ struct symbol *s;
lua_pushcfunction (L, &rspamd_lua_traceback);
err_idx = lua_gettop (L);
if (nresults >= 1) {
/* Function returned boolean, so maybe we need to insert result? */
gint res = 0;
- GList *opts = NULL;
gint i;
gdouble flag = 1.0;
flag = res;
}
- for (i = lua_gettop (L); i >= level + first_opt; i--) {
- if (lua_type (L, i) == LUA_TSTRING) {
- const char *opt = lua_tostring (L, i);
+ s = rspamd_task_insert_result (task, cd->symbol, flag, NULL);
- opts = g_list_prepend (opts,
- rspamd_mempool_strdup (task->task_pool,
- opt));
+ if (s) {
+ for (i = lua_gettop (L); i >= level + first_opt; i--) {
+ if (lua_type (L, i) == LUA_TSTRING) {
+ const char *opt = lua_tostring (L, i);
+
+ rspamd_task_add_result_option (task, s, opt);
+ }
}
}
- rspamd_task_insert_result (task, cd->symbol, flag, opts);
}
lua_pop (L, nresults);
struct rspamd_task *task = lua_check_task (L, 1);
const gchar *symbol_name, *param;
double flag;
- GList *params = NULL;
+ struct symbol *s;
gint i, top;
if (task != NULL) {
rspamd_mempool_strdup (task->task_pool, luaL_checkstring (L, 2));
flag = luaL_checknumber (L, 3);
top = lua_gettop (L);
+ s = rspamd_task_insert_result (task, symbol_name, flag, NULL);
+
/* Get additional options */
- for (i = 4; i <= top; i++) {
- if (lua_type (L, i) == LUA_TSTRING) {
- param = luaL_checkstring (L, i);
- params =
- g_list_prepend (params,
- rspamd_mempool_strdup (task->task_pool, param));
- }
- else if (lua_type (L, i) == LUA_TTABLE) {
- lua_pushvalue (L, i);
- lua_pushnil (L);
+ if (s) {
+ for (i = 4; i <= top; i++) {
+ if (lua_type (L, i) == LUA_TSTRING) {
+ param = luaL_checkstring (L, i);
+ rspamd_task_add_result_option (task, s, param);
+ }
+ else if (lua_type (L, i) == LUA_TTABLE) {
+ lua_pushvalue (L, i);
+ lua_pushnil (L);
+
+ while (lua_next (L, -2)) {
+ param = lua_tostring (L, -1);
+ rspamd_task_add_result_option (task, s, param);
+ lua_pop (L, 1);
+ }
- while (lua_next (L, -2)) {
- param = lua_tostring (L, -1);
- params = g_list_prepend (params,
- rspamd_mempool_strdup (task->task_pool,
- param));
lua_pop (L, 1);
}
-
- lua_pop (L, 1);
}
}
- if (params) {
- params = g_list_reverse (params);
- }
-
- rspamd_task_insert_result (task, symbol_name, flag, params);
}
else {
return luaL_error (L, "invalid arguments");
if (all_done) {
DL_FOREACH (first, cur) {
const gchar *symbol = NULL;
- GList *messages = NULL;
int symbol_weight = 1;
+
if (cur->ctx == NULL) {
continue;
}
else if (cur->res == DKIM_TRYAGAIN) {
symbol = dkim_module_ctx->symbol_tempfail;
}
+
if (symbol != NULL) {
- messages = g_list_prepend (messages,
- rspamd_mempool_strdup (cur->task->task_pool,
- rspamd_dkim_get_domain (cur->ctx)));
rspamd_task_insert_result (cur->task,
symbol,
symbol_weight,
- messages);
+ rspamd_dkim_get_domain (cur->ctx));
}
}
rspamd_session_watcher_pop (res->task->s, res->w);
gchar *spf_result;
guint af, mask, bmask, addrlen;
const gchar *spf_message, *spf_symbol;
- GList *opts = NULL;
if (task->from_addr == NULL) {
return FALSE;
if (res) {
spf_result = rspamd_mempool_alloc (task->task_pool,
strlen (addr->spf_string) + 2);
- opts = g_list_prepend (opts, spf_result);
switch (addr->mech) {
case SPF_FAIL:
rspamd_task_insert_result (task,
spf_symbol,
1,
- opts);
+ spf_result);
ucl_object_insert_key (task->messages,
ucl_object_fromstring (spf_message), "spf", 0,
false);
w = rspamd_session_get_watcher (task->s);
if (!rspamd_spf_resolve (task, spf_plugin_callback, w)) {
- GList *opts = NULL;
-
- opts = g_list_prepend (opts, "(SPF): spf DNS fail");
msg_info_task ("cannot make spf request for [%s]",
task->message_id);
rspamd_task_insert_result (task,
spf_module_ctx->symbol_dnsfail,
1,
- opts);
+ "(SPF): spf DNS fail");
}
else {
rspamd_session_watcher_push (task->s);
task->message_id,
url, suffix->suffix,
bit->bit);
- rspamd_task_insert_result (task, bit->symbol, 1,
- g_list_prepend (NULL,
- rspamd_mempool_strdup (task->task_pool, url)));
+ rspamd_task_insert_result (task, bit->symbol, 1, url);
got_result = TRUE;
}
}
task->message_id,
url, suffix->suffix,
bit->bit);
- rspamd_task_insert_result (task, bit->symbol, 1,
- g_list_prepend (NULL,
- rspamd_mempool_strdup (task->task_pool, url)));
+ rspamd_task_insert_result (task, bit->symbol, 1, url);
}
}
}
msg_info_task ("<%s> domain [%s] is in surbl %s",
task->message_id,
url, suffix->suffix);
- rspamd_task_insert_result (task, suffix->symbol, 1,
- g_list_prepend (NULL,
- rspamd_mempool_strdup (task->task_pool, url)));
+ rspamd_task_insert_result (task, suffix->symbol, 1, url);
}
else {
ina.s_addr = addr;
rspamd_task_insert_result (param->task,
surbl_module_ctx->redirector_symbol,
1,
- g_list_prepend (NULL, found_tld));
+ found_tld);
}
register_redirector_call (url,