+void
+zea_load_adblock(void)
+{
+ GRegex *re = NULL;
+ GError *err = NULL;
+ GIOChannel *channel = NULL;
+ gchar *path = NULL;
+ gchar *buf = NULL;
+ gsize length, term;
+
+ path = g_strdup_printf("%s/zea/adblock.black", g_get_user_config_dir());
+ channel = g_io_channel_new_file(path, "r", &err);
+ if (channel != NULL)
+ {
+ while (g_io_channel_read_line(channel, &buf, &length, &term, &err)
+ == G_IO_STATUS_NORMAL)
+ {
+ g_strstrip(buf);
+ re = g_regex_new(buf,
+ G_REGEX_CASELESS | G_REGEX_OPTIMIZE,
+ G_REGEX_MATCH_PARTIAL, &err);
+ if (err != NULL)
+ {
+ fprintf(stderr, "zea: Could not compile regex: %s\n", buf);
+ g_error_free(err);
+ err = NULL;
+ }
+ adblock_patterns = g_slist_append(adblock_patterns, re);
+
+ g_free(buf);
+ }
+
+ if (err != NULL)
+ g_free(err);
+ }
+ g_free(path);
+}
+