From 22fd6276ea142c135f125edde76e46741bb7b545 Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Tue, 27 Mar 2007 15:31:34 +0000 Subject: [PATCH] This is still totally non-functional. Beginning of generic system to associate settings (name=value pairs) with targets using a general-purpose XML config format. --- src/Makefile.am | 5 +++-- src/settings.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/settings.h | 12 ++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/settings.c create mode 100644 src/settings.h diff --git a/src/Makefile.am b/src/Makefile.am index 63fd7e4..da1dfea 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 index 0000000..6ec2d74 --- /dev/null +++ b/src/settings.c @@ -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 + +#include + +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 index 0000000..858b4af --- /dev/null +++ b/src/settings.h @@ -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 + */ -- 1.7.10.4