[SCM] Development fot GoFind! branch, master, updated. 7fd83a263d598caa332ca3db5c100743becb0dd3
Miriam Ruiz
miriam at debian.org
Wed Apr 29 09:37:25 UTC 2009
The following commit has been merged in the master branch:
commit 7fd83a263d598caa332ca3db5c100743becb0dd3
Author: Miriam Ruiz <miriam at debian.org>
Date: Wed Apr 29 11:43:11 2009 +0200
Started integration of XDG Spec in loading of config files
Added dependency on libxdg-basedir 1.0.0
diff --git a/Makefile b/Makefile
index 408b210..3dd393f 100644
--- a/Makefile
+++ b/Makefile
@@ -21,12 +21,13 @@
MAJOR=0
MINOR=0
-PKGCONFIG_CFLAGS= `pkg-config libtagcoll2 boolstuff-0.1 --cflags`
+PKGCONFIG_FILES=libtagcoll2 boolstuff-0.1 libxdg-basedir
+PKGCONFIG_CFLAGS= `pkg-config $(PKGCONFIG_FILES) --cflags`
STATIC_CFLAGS= -O2 -g -Wall
CFLAGS= $(STATIC_CFLAGS) -fPIC
LDFLAGS= -Wl,-z,defs -Wl,--as-needed -Wl,--no-undefined
PLUGINS_LDFLAGS=
-LIBS= -lept -lept-core -lapt-pkg -lxapian -ldl `pkg-config libtagcoll2 boolstuff-0.1 --libs`
+LIBS= -lept -lept-core -lapt-pkg -lxapian -ldl `pkg-config $(PKGCONFIG_FILES) --libs`
OBJS= Engine.o Environment.o filter.o field.o gofind.o \
taghandler.o cfgmanager.o boolparser.o \
@@ -36,6 +37,8 @@ LIB_OBJS= Engine.o Environment.o filter.o field.o \
taghandler.o cfgmanager.o boolparser.o \
utf8.o dll.o guiplugin.o pkgdata.o slre.o
+HEADERS=$(shell find . -name "*.h")
+
PLUGINS= gui_cli.so gui_fltk.so gui_lua.so gui_luagtk.so
all: libgofind.so gofind $(PLUGINS)
@@ -85,20 +88,20 @@ gui_lua.o: gui_lua.cpp
gui_luagtk.o: gui_luagtk.cpp
g++ -o $@ -c $+ $(CFLAGS) $(PKGCONFIG_CFLAGS) `pkg-config lua5.1 --cflags`
-%.o: %.cpp
- g++ -o $@ -c $+ $(CFLAGS) $(PKGCONFIG_CFLAGS)
+%.o: %.cpp $(HEADERS)
+ g++ -o $@ -c $< $(CFLAGS) $(PKGCONFIG_CFLAGS)
-%.o: %.c
- gcc -o $@ -c $+ $(CFLAGS) $(PKGCONFIG_CFLAGS)
+%.o: %.c $(HEADERS)
+ gcc -o $@ -c $< $(CFLAGS) $(PKGCONFIG_CFLAGS)
%.so : %.o
g++ $(LDFLAGS) -shared $^ -o $@
-%.static.o: %.cpp
- g++ -o $@ -c $+ $(STATIC_CFLAGS) $(PKGCONFIG_CFLAGS)
+%.static.o: %.cpp $(HEADERS)
+ g++ -o $< -c $+ $(STATIC_CFLAGS) $(PKGCONFIG_CFLAGS)
-%.static.o: %.c
- gcc -o $@ -c $+ $(STATIC_CFLAGS) $(PKGCONFIG_CFLAGS)
+%.static.o: %.c $(HEADERS)
+ gcc -o $< -c $+ $(STATIC_CFLAGS) $(PKGCONFIG_CFLAGS)
TEST_OBJS= filter.test.o taghandler.test.o cfgmanager.test.o boolparser.test.o slre.test.o utf8.test.o CuTest.o dll.test.o test.o
TEST_PLUGINS= testplugin.test.so
@@ -109,14 +112,14 @@ test: $(TEST_OBJS) $(TEST_PLUGINS)
test.c:
sh CuTest.sh > $@
-test.o: test.c
- gcc -o $@ -DUNIT_TEST -c $+ $(CFLAGS) $(PKGCONFIG_CFLAGS)
+test.o: test.c $(HEADERS)
+ gcc -o $@ -DUNIT_TEST -c $< $(CFLAGS) $(PKGCONFIG_CFLAGS)
-%.test.o: %.cpp
- g++ -o $@ -DUNIT_TEST -c $+ $(CFLAGS) $(PKGCONFIG_CFLAGS)
+%.test.o: %.cpp $(HEADERS)
+ g++ -o $@ -DUNIT_TEST -c $< $(CFLAGS) $(PKGCONFIG_CFLAGS)
-%.test.o: %.c
- gcc -o $@ -DUNIT_TEST -c $+ $(CFLAGS) $(PKGCONFIG_CFLAGS)
+%.test.o: %.c $(HEADERS)
+ gcc -o $@ -DUNIT_TEST -c $< $(CFLAGS) $(PKGCONFIG_CFLAGS)
%.test.so : %.test.o
g++ $(CFLAGS) $(PKGCONFIG_CFLAGS) -DUNIT_TEST -shared $^ -o $@
diff --git a/filter.cpp b/filter.cpp
index a1a246f..c0fd46e 100644
--- a/filter.cpp
+++ b/filter.cpp
@@ -52,16 +52,8 @@ PackageFilter::~PackageFilter()
using namespace std;
-bool PackageFilter::Load(const char *filename)
+bool PackageFilter::Load(FILE *fd)
{
- 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);
@@ -69,13 +61,12 @@ bool PackageFilter::Load(const char *filename)
char *buffer = new char[fsize + 1];
memset(buffer, 0, fsize + 1);
fread(buffer, fsize, 1, fd);
- fclose(fd);
rapidxml::xml_document<> doc;
try {
doc.parse<0>(buffer);
} catch (...) {
- std::cerr << "Error loading filter: \"" << filename << "\"" << std::endl;
+ std::cerr << "Error loading filter" << std::endl;
return false;
}
@@ -132,6 +123,20 @@ bool PackageFilter::Load(const char *filename)
return true;
}
+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;
+ }
+ bool ret = Load(fd);
+ fclose(fd);
+ return ret;
+}
+
/* Find out the color of a single tag */
int PackageFilter::TagValue(const Tag &tag)
{
diff --git a/filter.h b/filter.h
index e207740..ad2f79e 100644
--- a/filter.h
+++ b/filter.h
@@ -35,6 +35,7 @@ public:
inline void Clean() { DeleteList(); }
bool Load(const char *filename);
+ bool Load(FILE *filedesc);
typedef enum {
Unknown = 1, // The calification for the tag/package is unknown
diff --git a/gofind.cpp b/gofind.cpp
index f53e9bf..7416a5e 100644
--- a/gofind.cpp
+++ b/gofind.cpp
@@ -34,6 +34,9 @@
#include <iostream>
#include <cmath>
+#include <basedir.h>
+#include <basedir_fs.h>
+
#ifdef USE_GETTEXT
#include <libintl.h>
#include <locale.h>
@@ -190,7 +193,13 @@ int main(int argc, const char* argv[])
}
pkgdata.GetPackageFilter().Clean();
- pkgdata.GetPackageFilter().Load("filter.cfg");
+ xdgHandle xdg_handle;
+ if (xdgInitHandle(&xdg_handle))
+ {
+ pkgdata.GetPackageFilter().Load("filter.cfg");
+ xdgWipeHandle(&xdg_handle);
+ }
+ else std::cerr << "Error initializing XDG Handle" << std::endl;
/*
cerr << " *** Initial:" << endl;
--
Development fot GoFind!
More information about the Pkg-games-commits
mailing list