[geocode-glib] server: Use path from geoip.pc to locate the database



commit 8c49ab29c74a62346b3da26c553d476d327bf457
Author: Bastien Nocera <hadess hadess net>
Date:   Sun Jan 13 21:34:24 2013 +0100

    server: Use path from geoip.pc to locate the database
    
    Unless it's overridden by the GEOIP_DATABASE_PATH envvar.

 configure.ac                                  |    3 +++
 geocode-glib/geocode-ip-server/Makefile.am    |    2 +-
 geocode-glib/geocode-ip-server/geoip-lookup.c |    6 ++----
 3 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 558e9a2..6fdfe54 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,6 +71,9 @@ PKG_CHECK_MODULES(GEOCODE_SERVER,
 GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
 AC_SUBST(GLIB_GENMARSHAL)
 
+GEOIP_DATABASE_PATH=`$PKG_CONFIG --variable=databasedir geoip`
+AC_SUBST(GEOIP_DATABASE_PATH)
+
 GOBJECT_INTROSPECTION_CHECK([0.6.3])
 
 GNOME_DEBUG_CHECK
diff --git a/geocode-glib/geocode-ip-server/Makefile.am b/geocode-glib/geocode-ip-server/Makefile.am
index c0b494c..74d58c9 100644
--- a/geocode-glib/geocode-ip-server/Makefile.am
+++ b/geocode-glib/geocode-ip-server/Makefile.am
@@ -2,7 +2,7 @@ include $(top_srcdir)/Makefile.decl
 
 BUILT_GIRSOURCES =
 
-AM_CFLAGS = -I$(top_srcdir) $(GEOCODE_SERVER_CFLAGS) $(COMMON_CFLAGS) $(WARN_CFLAGS) $(DISABLE_DEPRECATED)
+AM_CFLAGS = -I$(top_srcdir) $(GEOCODE_SERVER_CFLAGS) $(COMMON_CFLAGS) $(WARN_CFLAGS) $(DISABLE_DEPRECATED) -DGEOIP_DATABASE_PATH=\""$(GEOIP_DATABASE_PATH)"\"
 
 TEST_PROGS += geoip-lookup
 noinst_PROGRAMS = $(TEST_PROGS)
diff --git a/geocode-glib/geocode-ip-server/geoip-lookup.c b/geocode-glib/geocode-ip-server/geoip-lookup.c
index 593d035..5404f9a 100644
--- a/geocode-glib/geocode-ip-server/geoip-lookup.c
+++ b/geocode-glib/geocode-ip-server/geoip-lookup.c
@@ -148,10 +148,8 @@ ip_addr_lookup (const gchar *ipaddress)
         const gchar *db;
 
         db = g_getenv ("GEOIP_DATABASE_PATH");
-        if (!db) {
-                print_error_in_json (DATABASE_ERR, NULL);
-                return;
-        }
+        if (!db)
+                db = GEOIP_DATABASE_PATH "/GeoLiteCity.dat";
 
         gi = GeoIP_open (db, GEOIP_INDEX_CACHE);
         if (gi == NULL) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]