This is still totally non-functional.
authorSebastian Hammer <quinn@indexdata.com>
Tue, 27 Mar 2007 15:31:34 +0000 (15:31 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Tue, 27 Mar 2007 15:31:34 +0000 (15:31 +0000)
Beginning of generic system to associate settings (name=value pairs) with
targets using a general-purpose XML config format.

src/Makefile.am
src/settings.c [new file with mode: 0644]
src/settings.h [new file with mode: 0644]

index 63fd7e4..da1dfea 100644 (file)
@@ -1,5 +1,5 @@
 # ParaZ. Copyright (C) 2006-2007, Index Data.
-# $Id: Makefile.am,v 1.3 2007-03-15 16:50:56 quinn Exp $
+# $Id: Makefile.am,v 1.4 2007-03-27 15:31:34 quinn Exp $
 
 bin_PROGRAMS = pazpar2
 
@@ -12,4 +12,5 @@ pazpar2_SOURCES = config.c config.h eventl.c eventl.h \
        http.c http_command.c http_command.h http.h \
        pazpar2.c pazpar2.h reclists.c reclists.h \
        relevance.c relevance.h termlists.c termlists.h \
-       util.c util.h zeerex.c zeerex.h database.c database.h
+       util.c util.h zeerex.c zeerex.h database.c database.h \
+       settings.h settings.c
diff --git a/src/settings.c b/src/settings.c
new file mode 100644 (file)
index 0000000..6ec2d74
--- /dev/null
@@ -0,0 +1,57 @@
+// $Id: settings.c,v 1.1 2007-03-27 15:31:34 quinn Exp $
+// This module implements a generic system of settings (attribute-value) that can 
+// be associated with search targets. The system supports both default values,
+// per-target overrides, and per-user settings.
+//
+
+#include <string.h>
+
+#include <yaz/nmem.h>
+
+static NMEM nmem = 0;
+
+struct setting
+{
+};
+
+struct setting_dictionary
+{
+};
+
+// Recursively read files in a directory structure, calling 
+static void read_settings(const char *path, void *context,
+               void (*fun)(void *context, struct setting *set))
+{
+}
+
+static void prepare_dictionary(void *context, struct setting *set)
+{
+}
+
+static void update_databases(void *context, struct setting *set)
+{
+}
+
+// If we ever decide we need to be able to specify multiple settings directories,
+// the two calls to read_settings must be split -- so the dictionary is prepared
+// for the contents of every directory before the databases are updated.
+void settings_read(const char *path)
+{
+    struct setting_dictionary *new;
+    if (!nmem)
+        nmem = nmem_create();
+    else
+        nmem_reset(nmem);
+    new = nmem_malloc(nmem, sizeof(*new));
+    memset(new, sizeof(*new), 0);
+    read_settings(path, new, prepare_dictionary);
+    read_settings(path, new, update_databases);
+}
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
diff --git a/src/settings.h b/src/settings.h
new file mode 100644 (file)
index 0000000..858b4af
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef SETTINGS_H
+#define SETTINGS_H
+
+#endif
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */