From 47a79ac8066193a636ff502249a8661d0fb28687 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Sat, 17 Dec 2005 17:28:29 +0000 Subject: filter-file.c Use libedataserver's e_xml_parse_file(). Use gstdio 2005-12-17 Tor Lillqvist * filter-file.c * rule-context.c: Use libedataserver's e_xml_parse_file(). Use gstdio wrappers. Use g_file_test(). svn path=/trunk/; revision=30834 --- filter/ChangeLog | 4 +++- filter/filter-file.c | 5 +---- filter/rule-context.c | 39 +++++++++++++++++++++------------------ 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/filter/ChangeLog b/filter/ChangeLog index e9e2341a03..a99ef7594c 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,6 +1,8 @@ 2005-12-17 Tor Lillqvist - * filter-file.c: Use gstdio wrappers. + * filter-file.c + * rule-context.c: Use libedataserver's e_xml_parse_file(). Use + gstdio wrappers. Use g_file_test(). 2005-08-23 Not Zed diff --git a/filter/filter-file.c b/filter/filter-file.c index 9934d92b54..a385d3330b 100644 --- a/filter/filter-file.c +++ b/filter/filter-file.c @@ -20,12 +20,10 @@ * */ - #include #include #include -#include #include #include @@ -158,7 +156,6 @@ static gboolean validate (FilterElement *fe) { FilterFile *file = (FilterFile *) fe; - struct stat st; if (!file->path) { /* FIXME: FilterElement should probably have a @@ -173,7 +170,7 @@ validate (FilterElement *fe) /* FIXME: do more to validate command-lines? */ if (strcmp (file->type, "file") == 0) { - if (g_stat (file->path, &st) == -1 || !S_ISREG (st.st_mode)) { + if (!g_file_test (file->path, G_FILE_TEST_IS_REGULAR)) { /* FIXME: FilterElement should probably have a GtkWidget member pointing to the value gotten with ::get_widget() so that we can get the parent window diff --git a/filter/rule-context.c b/filter/rule-context.c index ffab5bf655..b984b67593 100644 --- a/filter/rule-context.c +++ b/filter/rule-context.c @@ -20,10 +20,7 @@ * Boston, MA 02111-1307, USA. */ - -#ifdef HAVE_CONFIG_H #include -#endif #include #include @@ -32,23 +29,30 @@ #include #include +#include +#include + #include + #include -#include -#include "e-util/e-error.h" -#include "rule-context.h" -#include "filter-rule.h" -#include "filter-marshal.h" +#include +#include + +#include "e-util/e-error.h" +#include "e-util/e-xml-utils.h" -#include "filter-input.h" -#include "filter-option.h" #include "filter-code.h" #include "filter-colour.h" #include "filter-datespec.h" -#include "filter-int.h" #include "filter-file.h" +#include "filter-input.h" +#include "filter-int.h" #include "filter-label.h" +#include "filter-marshal.h" +#include "filter-option.h" +#include "filter-rule.h" +#include "rule-context.h" #define d(x) @@ -300,13 +304,12 @@ load(RuleContext *rc, const char *system, const char *user) xmlDocPtr systemdoc, userdoc; struct _part_set_map *part_map; struct _rule_set_map *rule_map; - struct stat st; - + rule_context_set_error(rc, NULL); d(printf("loading rules %s %s\n", system, user)); - systemdoc = xmlParseFile(system); + systemdoc = e_xml_parse_file (system); if (systemdoc == NULL) { rule_context_set_error(rc, g_strdup_printf("Unable to load system rules '%s': %s", system, g_strerror(errno))); @@ -321,9 +324,9 @@ load(RuleContext *rc, const char *system, const char *user) } /* doesn't matter if this doens't exist */ userdoc = NULL; - if (stat (user, &st) != -1 && S_ISREG (st.st_mode)) - userdoc = xmlParseFile(user); - + if (g_file_test(user, G_FILE_TEST_IS_REGULAR)) + userdoc = e_xml_parse_file (user); + /* now parse structure */ /* get rule parts */ set = root->children; @@ -528,7 +531,7 @@ revert(RuleContext *rc, const char *user) d(printf("restoring rules %s\n", user)); - userdoc = xmlParseFile(user); + userdoc = e_xml_parse_file (user); if (userdoc == NULL) /* clear out anythign we have? */ return 0; -- cgit