[SCM] Development fot GoFind! branch, master, updated. 31f9511a3139a74c5f0d8a559a2e4dfe619752a3
Miriam Ruiz
miriam at debian.org
Mon Apr 27 22:28:59 UTC 2009
The following commit has been merged in the master branch:
commit e598dc6b4a127386aeb21861fc2559de15b2a480
Author: Miriam Ruiz <miriam at debian.org>
Date: Mon Apr 27 23:18:16 2009 +0200
Start developing XML configuration loader
diff --git a/filter.cpp b/filter.cpp
index d47d930..6385f8c 100644
--- a/filter.cpp
+++ b/filter.cpp
@@ -21,7 +21,6 @@
#include "filter.h"
#include "taghandler.h"
#include "boolparser.h"
-#include "slre.h"
#ifdef UNIT_TEST
#include "CuTest.h"
@@ -32,9 +31,14 @@
#include <vector>
#include <string.h>
+#include <stdio.h>
+#include <errno.h>
#include <ept/debtags/tag.h>
+#include "rapidxml/rapidxml.hpp"
+#include "rapidxml/rapidxml_print.hpp"
+
#define GREEN_MINIMUM 2
PackageFilter::PackageFilter()
@@ -162,6 +166,52 @@ using namespace std;
bool PackageFilter::Load(const char *filename)
{
+ cout << "Loading filter: \"" << filename << "\"" << std::endl;
+
+ FILE *fd = fopen(filename, "rb"); // Read-only mode
+ if ( fd == NULL) {
+ fprintf( stderr, "fopen failed, errno = %d (%s)\n", errno, strerror( errno));
+ return false;
+ }
+
+ fseek( fd, 0, SEEK_END);
+ int fsize = ftell(fd);
+ fseek( fd, 0, SEEK_SET);
+
+ char *buffer = new char[fsize + 1];
+ fread(buffer, fsize, 1, fd);
+ fclose(fd);
+ buffer[fsize + 1] = '\0';
+
+ rapidxml::xml_document<> doc;
+ try {
+ doc.parse<0>(buffer);
+ } catch (...) {
+ std::cerr << "Error loading filter: \"" << filename << "\"" << std::endl;
+ return false;
+ }
+
+ //std::cout << doc;
+
+ for (rapidxml::xml_node<> *filter = doc.first_node("filter");
+ filter; filter = filter->next_sibling("filter"))
+ {
+ rapidxml::xml_attribute<> *target = filter->first_attribute("target");
+ if (!target) break;
+ std::cout << target->name() << " = " << target->value() << std::endl;
+
+ for (rapidxml::xml_node<> *rule = filter->first_node("rule");
+ rule; rule = rule->next_sibling("rule"))
+ {
+ rapidxml::xml_attribute<> *condition = rule->first_attribute("condition");
+ if (!condition) break;
+ std::cout << condition->name() << " = " << condition->value() << std::endl;
+ }
+ }
+
+ return true;
+
+/*
struct slre_pattern pattern[1];
const char *pattern_text[1];
const char pattern_type[] = { 'd', '\0' };
@@ -213,6 +263,7 @@ bool PackageFilter::Load(const char *filename)
std::cerr << std::endl;
return true;
+*/
}
/* Find out the color of a single tag */
--
Development fot GoFind!
More information about the Pkg-games-commits
mailing list