22b151a35a
+ added lt_db_set_datadir() and lb_db_get_datadir() functions to point to liblangtag data and override REGDATADIR define - removed LIBO_LANGTAG_DATADIR environment variable hack
104 lines
2.9 KiB
Diff
104 lines
2.9 KiB
Diff
--- misc/liblangtag-0.2/liblangtag/lt-database.c 2012-01-31 11:27:16.000000000 +0100
|
|
+++ misc/build/liblangtag-0.2/liblangtag/lt-database.c 2012-06-12 01:32:57.354123185 +0200
|
|
@@ -26,6 +26,7 @@
|
|
#include "lt-mem.h"
|
|
#include "lt-ext-module.h"
|
|
#include "lt-database.h"
|
|
+#include <string.h>
|
|
|
|
|
|
/**
|
|
@@ -44,10 +45,41 @@
|
|
static lt_grandfathered_db_t *__db_grandfathered = NULL;
|
|
static lt_redundant_db_t *__db_redundant = NULL;
|
|
|
|
+/* this is a hack and might need some proper runtime de/allocation, but ... */
|
|
+#define DATADIR_MAX_PATH_LEN 512
|
|
+static char lt_db_datadir[DATADIR_MAX_PATH_LEN] = { 0 };
|
|
+
|
|
|
|
/*< private >*/
|
|
|
|
/*< public >*/
|
|
+
|
|
+/**
|
|
+ * lt_db_set_datadir:
|
|
+ *
|
|
+ * Set the directory where database files are installed.
|
|
+ * This overrides the default prefix= location if called before
|
|
+ * lt_db_initialize().
|
|
+ */
|
|
+void
|
|
+lt_db_set_datadir(const char* path)
|
|
+{
|
|
+ strncpy( lt_db_datadir, path, DATADIR_MAX_PATH_LEN-1);
|
|
+ lt_db_datadir[DATADIR_MAX_PATH_LEN-1] = 0;
|
|
+}
|
|
+
|
|
+/**
|
|
+ * lt_db_get_datadir:
|
|
+ *
|
|
+ * Obtain the directory where database files are installed.
|
|
+ * Only if set with lt_db_set_datadir().
|
|
+ */
|
|
+const char*
|
|
+lt_db_get_datadir(void)
|
|
+{
|
|
+ return lt_db_datadir;
|
|
+}
|
|
+
|
|
/**
|
|
* lt_db_initialize:
|
|
*
|
|
--- misc/liblangtag-0.2/liblangtag/lt-database.h 2012-01-31 11:27:04.000000000 +0100
|
|
+++ misc/build/liblangtag-0.2/liblangtag/lt-database.h 2012-06-12 00:23:04.345618028 +0200
|
|
@@ -37,6 +37,8 @@
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
+void lt_db_set_datadir (const char*);
|
|
+const char* lt_db_get_datadir (void);
|
|
void lt_db_initialize (void);
|
|
void lt_db_finalize (void);
|
|
lt_lang_db_t *lt_db_get_lang (void);
|
|
--- misc/liblangtag-0.2/liblangtag/lt-xml.c 2012-02-02 09:54:51.000000000 +0100
|
|
+++ misc/build/liblangtag-0.2/liblangtag/lt-xml.c 2012-06-12 00:23:04.477618565 +0200
|
|
@@ -45,7 +45,20 @@
|
|
|
|
G_LOCK_DEFINE_STATIC (lt_xml);
|
|
|
|
+
|
|
+/* defined in lt-database.c */
|
|
+extern const char* lt_db_get_datadir(void);
|
|
+
|
|
/*< private >*/
|
|
+static const char*
|
|
+lt_xml_get_datadir()
|
|
+{
|
|
+ const char* datadir = lt_db_get_datadir();
|
|
+ if (datadir && *datadir)
|
|
+ return datadir;
|
|
+ return REGDATADIR;
|
|
+}
|
|
+
|
|
static gboolean
|
|
lt_xml_read_subtag_registry(lt_xml_t *xml,
|
|
GError **error)
|
|
@@ -62,7 +75,7 @@
|
|
if (!g_file_test(regfile, G_FILE_TEST_EXISTS)) {
|
|
g_free(regfile);
|
|
#endif
|
|
- regfile = g_build_filename(REGDATADIR, "language-subtag-registry.xml", NULL);
|
|
+ regfile = g_build_filename(lt_xml_get_datadir(), "language-subtag-registry.xml", NULL);
|
|
#ifdef GNOME_ENABLE_DEBUG
|
|
}
|
|
#endif
|
|
@@ -120,7 +133,7 @@
|
|
if (!g_file_test(regfile, G_FILE_TEST_EXISTS)) {
|
|
g_free(regfile);
|
|
#endif
|
|
- regfile = g_build_filename(REGDATADIR, "common", "bcp47", filename, NULL);
|
|
+ regfile = g_build_filename(lt_xml_get_datadir(), "common", "bcp47", filename, NULL);
|
|
#ifdef GNOME_ENABLE_DEBUG
|
|
}
|
|
#endif
|