memory_pool_add_destructor (cfg->cfg_pool, (pool_destruct_func) g_hash_table_destroy, c->opts);
}
if (c->labels == NULL) {
- c->labels = g_hash_table_new (g_str_hash, g_str_equal);
+ c->labels = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify)g_list_free);
memory_pool_add_destructor (cfg->cfg_pool, (pool_destruct_func) g_hash_table_destroy, c->labels);
}
gpointer tptr;
struct wrk_cbdata wcd;
struct xml_subparser *subparser;
+ GList *labels;
if (g_ascii_strcasecmp (element_name, "if") == 0) {
tptr = g_queue_pop_head (ud->if_stack);
ud->cfg->statfiles = g_list_prepend (ud->cfg->statfiles, st);
g_hash_table_insert (ud->cfg->classifiers_symbols, st->symbol, ccf);
if (st->label) {
- if (g_hash_table_lookup (ccf->labels, st->label)) {
- msg_warn ("duplicate statfile label %s with symbol %s, ignoring", st->label, st->symbol);
+ if ((labels = g_hash_table_lookup (ccf->labels, st->label))) {
+ labels = g_list_append (labels, st);
}
else {
- g_hash_table_insert (ccf->labels, st->label, st);
+ g_hash_table_insert (ccf->labels, st->label, g_list_prepend (NULL, st));
}
}
ud->section_pointer = ccf;
struct classifier_config *ccf = lua_check_classifier (L);
struct statfile *st, **pst;
const gchar *label;
+ GList *cur;
+ gint i;
label = luaL_checkstring (L, 2);
if (ccf && label) {
- st = g_hash_table_lookup (ccf->labels, label);
- if (st) {
- pst = lua_newuserdata (L, sizeof (struct statfile *));
- lua_setclass (L, "rspamd{statfile}", -1);
- *pst = st;
+ cur = g_hash_table_lookup (ccf->labels, label);
+ if (cur) {
+ lua_newtable (L);
+ i = 1;
+ while (cur) {
+ st = cur->data;
+ pst = lua_newuserdata (L, sizeof (struct statfile *));
+ lua_setclass (L, "rspamd{statfile}", -1);
+ *pst = st;
+ lua_rawseti (L, -2, i++);
+ cur = g_list_next (cur);
+ }
return 1;
}
}