pcre_extra *raw_extra;
regexp_id_t id;
ref_entry_t ref;
+ gpointer ud;
gint flags;
};
REF_RELEASE (re);
}
+void
+rspamd_regexp_set_ud (rspamd_regexp_t *re, gpointer ud)
+{
+ g_assert (re != NULL);
+
+ re->ud = ud;
+}
+
+gpointer
+rspamd_regexp_get_ud (rspamd_regexp_t *re)
+{
+ g_assert (re != NULL);
+
+ return re->ud;
+}
+
static gboolean
rspamd_regexp_equal (gconstpointer a, gconstpointer b)
{
return res;
}
+void rspamd_regexp_cache_insert (struct rspamd_regexp_cache* cache,
+ const gchar *pattern,
+ const gchar *flags, rspamd_regexp_t *re)
+{
+ g_assert (re != NULL);
+ g_assert (pattern != NULL);
+
+ if (cache == NULL) {
+ cache = global_re_cache;
+ }
+
+ g_assert (cache != NULL);
+ /* Generate custom id */
+ rspamd_regexp_generate_id (pattern, flags, re->id);
+
+ REF_RETAIN (re);
+ g_hash_table_insert (cache->tbl, re->id, re);
+}
+
gboolean
rspamd_regexp_cache_remove (struct rspamd_regexp_cache *cache,
rspamd_regexp_t *re)
*/
void rspamd_regexp_unref (rspamd_regexp_t *re);
+/**
+ * Set auxiliary userdata for the specified regexp
+ * @param re regexp object
+ * @param ud opaque pointer
+ */
+void rspamd_regexp_set_ud (rspamd_regexp_t *re, gpointer ud);
+
+/**
+ * Get userdata for a regexp object
+ * @param re regexp object
+ * @return opaque pointer
+ */
+gpointer rspamd_regexp_get_ud (rspamd_regexp_t *re);
+
/**
* Get pattern for the specified regexp object
* @param re
const gchar *pattern,
const gchar *flags);
+/**
+ * Insert item to the cache using custom pattern and flags
+ * @param cache
+ * @param pattern
+ * @param flags
+ * @param re
+ */
+void rspamd_regexp_cache_insert (struct rspamd_regexp_cache* cache,
+ const gchar *pattern,
+ const gchar *flags, rspamd_regexp_t *re);
+
/**
* Create or get cached regexp from the specified cache
* @param cache regexp cache. if NULL, the superglobal cache is used (*not* thread-safe)