aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNotZed <NotZed@HelixCode.com>2000-05-16 08:52:51 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-05-16 08:52:51 +0800
commit8d95e8c29eef49a9ec7db5d129cd5cf18cfc3816 (patch)
tree72bbb8c6b70141f57b4be10439e430465f084d61
parenteb1d5f12ab841a754c3e226f5b114da079cb1aef (diff)
downloadgsoc2013-evolution-8d95e8c29eef49a9ec7db5d129cd5cf18cfc3816.tar.gz
gsoc2013-evolution-8d95e8c29eef49a9ec7db5d129cd5cf18cfc3816.tar.zst
gsoc2013-evolution-8d95e8c29eef49a9ec7db5d129cd5cf18cfc3816.zip
Bunch of cleanup.
2000-05-15 NotZed <NotZed@HelixCode.com> * filter-xml.[ch]: Bunch of cleanup. * filter-xml.c (filter_*_file): New interfaces to read/write files directly, rather than messing with xmldoc crap. svn path=/trunk/; revision=3051
-rw-r--r--filter/ChangeLog5
-rw-r--r--filter/filter-editor.h2
-rw-r--r--filter/filter-xml.c86
-rw-r--r--filter/filter-xml.h8
4 files changed, 50 insertions, 51 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 3526765b40..1d759230ef 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,5 +1,10 @@
2000-05-15 NotZed <NotZed@HelixCode.com>
+ * filter-xml.[ch]: Bunch of cleanup.
+
+ * filter-xml.c (filter_*_file): New interfaces to read/write files
+ directly, rather than messing with xmldoc crap.
+
* Makefile.am: Removed filter-driver test program, now just part
of libfilter.
diff --git a/filter/filter-editor.h b/filter/filter-editor.h
index 15daeef408..212654c4c9 100644
--- a/filter/filter-editor.h
+++ b/filter/filter-editor.h
@@ -51,4 +51,6 @@ struct _FilterEditorClass {
guint filter_editor_get_type (void);
FilterEditor *filter_editor_new (void);
+void filter_editor_set_rules(FilterEditor *e, GList *rules, GList *systemoptions, GList *useroptions);
+
#endif /* ! _FILTER_EDITOR_H */
diff --git a/filter/filter-xml.c b/filter/filter-xml.c
index e59ad5199a..0df8f49ad5 100644
--- a/filter/filter-xml.c
+++ b/filter/filter-xml.c
@@ -58,7 +58,7 @@ tokenise(const char *name)
}
static int
-tokenise_xmlfreeprop(const char *name)
+tokenise_xmlfreeprop(char *name)
{
int ret = -1;
ret = tokenise(name);
@@ -95,7 +95,6 @@ find_node(xmlNodePtr start, char *name)
static xmlNodePtr
find_node_attr(xmlNodePtr start, char *name, char *attrname, char *attrvalue)
{
- xmlNodePtr node;
char *s;
d(printf("looking for node named %s with attribute %s=%s\n", name, attrname, attrvalue));
@@ -233,9 +232,6 @@ filter_find_arg(FilterArg *a, char *name)
static FilterArg *
load_optionvalue(struct filter_desc *desc, xmlNodePtr node)
{
- xmlNodePtr n;
- int token;
- int lasttoken = -2;
FilterArg *arg = NULL;
d(printf("creating arg entry for '%s'\n", desc->varname));
@@ -261,31 +257,6 @@ load_optionvalue(struct filter_desc *desc, xmlNodePtr node)
return arg;
}
-/* loads a blank (empty args) optionrule from a rule */
-static struct filter_optionrule *
-optionrule_new(struct filter_rule *rule)
-{
- GList *ldesc;
- struct filter_desc *desc;
- struct filter_optionrule *optionrule;
-
- optionrule = g_malloc0(sizeof(*optionrule));
- optionrule->rule = rule;
-
- ldesc = rule->description;
- while (ldesc) {
- desc = ldesc->data;
- if (desc->varname && desc->vartype!=-1) {
- FilterArg *arg;
- arg = load_optionvalue(desc, NULL);
- if (arg)
- optionrule->args = g_list_append(optionrule->args, arg);
- }
- ldesc = g_list_next(ldesc);
- }
- return optionrule;
-}
-
GList *
filter_load_optionset(xmlDocPtr doc, GList *rules)
{
@@ -294,7 +265,7 @@ filter_load_optionset(xmlDocPtr doc, GList *rules)
struct filter_optionrule *optionrule;
struct filter_rule *fr;
struct filter_desc *desc;
- int type, token;
+ int type;
GList *l = NULL;
GList *lrule;
GList *ldesc;
@@ -366,7 +337,7 @@ filter_load_optionset(xmlDocPtr doc, GList *rules)
xmlNodePtr
filter_write_optionset(xmlDocPtr doc, GList *optionl)
{
- xmlNodePtr root, cur, option, optionrule, optionvalue;
+ xmlNodePtr root, option, optionrule, optionvalue;
GList *optionrulel, *argl;
struct filter_optionrule *or;
@@ -423,7 +394,7 @@ filter_clone_optionrule(struct filter_optionrule *or)
arg = or->args;
while (arg) {
FilterArg *new = filter_arg_clone(FILTER_ARG(arg->data));
- gtk_object_set_data(new, "origin", arg->data);
+ gtk_object_set_data((GtkObject *)new, "origin", arg->data);
rule->args = g_list_append(rule->args, new);
arg = g_list_next(arg);
}
@@ -434,7 +405,6 @@ void
filter_clone_optionrule_free(struct filter_optionrule *or)
{
GList *argl;
- struct filter_optionrule *rule;
d(printf("---- free optionrule\n"));
@@ -548,30 +518,44 @@ filter_load_optionset_free(GList *optionl)
}
}
-#ifdef TESTER
-int main(int argc, char **argv)
+GList *filter_load_ruleset_file(const char *name)
{
- GList *rules, *options;
- xmlDocPtr doc, out, optionset, filteroptions;
+ xmlDocPtr doc;
+ GList *rules;
- gnome_init("Test", "0.0", argc, argv);
+ doc = xmlParseFile(name);
+ rules = filter_load_ruleset(doc);
+ xmlFreeDoc(doc);
- doc = xmlParseFile("filterdescription.xml");
+ return rules;
+}
+
+GList *filter_load_optionset_file(const char *name, GList *rules)
+{
+ xmlDocPtr doc;
+ GList *options;
+
+ doc = xmlParseFile(name);
+ options = filter_load_optionset(doc, rules);
+ xmlFreeDoc(doc);
- rules = load_ruleset(doc);
- options = load_optionset(doc, rules);
+ return options;
+}
+
+int filter_write_optionset_file(const char *name, GList *optionl)
+{
+ xmlDocPtr out;
+ xmlDocPtr optionset;
+ xmlNodePtr filteroptions;
+ int ret;
- out = xmlParseFile("saveoptions.xml");
- options = load_optionset(doc, rules);
-#if 0
out = xmlNewDoc("1.0");
- optionset = save_optionset(out, options);
+ optionset = filter_write_optionset(out, optionl);
filteroptions = xmlNewDocNode(out, NULL, "filteroptions", NULL);
xmlAddChild(filteroptions, optionset);
xmlDocSetRootElement(out, filteroptions);
- xmlSaveFile("saveoptions.xml", out);
-#endif
- return 0;
-}
-#endif
+ ret = xmlSaveFile(name, out);
+ xmlFreeDoc(out);
+ return ret;
+}
diff --git a/filter/filter-xml.h b/filter/filter-xml.h
index a2e0cfada0..ce8a5ffc3a 100644
--- a/filter/filter-xml.h
+++ b/filter/filter-xml.h
@@ -57,6 +57,14 @@ GList *filter_load_ruleset(xmlDocPtr doc);
GList *filter_load_optionset(xmlDocPtr doc, GList *rules);
xmlNodePtr filter_write_optionset(xmlDocPtr doc, GList *optionl);
+void filter_description_free(GList *descl);
+void filter_load_ruleset_free(GList *nodel);
+void filter_load_optionset_free(GList *optionl);
+
+GList *filter_load_ruleset_file(const char *name);
+GList *filter_load_optionset_file(const char *name, GList *rules);
+int filter_write_optionset_file(const char *name, GList *optionl);
+
/* callbacks for searching GLists of various types */
int filter_find_rule(struct filter_rule *a, char *name);
int filter_find_arg(FilterArg *a, char *name);