2008-08-06 09:39:48 +02:00
|
|
|
/*
|
|
|
|
|
config.c - Lumiera configuration system
|
|
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2008, Christian Thaeter <ct@pipapo.org>
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//TODO: Support library includes//
|
2008-08-07 06:09:50 +02:00
|
|
|
#include "lib/safeclib.h"
|
2008-08-06 09:39:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: Lumiera header includes//
|
|
|
|
|
#include "backend/config.h"
|
|
|
|
|
|
|
|
|
|
//TODO: internal/static forward declarations//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: System includes//
|
2008-08-07 06:09:50 +02:00
|
|
|
#include <stdint.h>
|
2008-08-06 09:39:48 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @file
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
NOBUG_DEFINE_FLAG_PARENT (config_all, backend);
|
|
|
|
|
NOBUG_DEFINE_FLAG_PARENT (config, config_all);
|
2008-08-07 08:10:23 +02:00
|
|
|
NOBUG_DEFINE_FLAG_PARENT (config_typed, config_all);
|
|
|
|
|
NOBUG_DEFINE_FLAG_PARENT (config_file, config_all);
|
2008-08-06 09:39:48 +02:00
|
|
|
|
|
|
|
|
LUMIERA_ERROR_DEFINE (CONFIG_SYNTAX, "Syntax error in configfile");
|
2008-08-07 06:09:50 +02:00
|
|
|
LUMIERA_ERROR_DEFINE (CONFIG_TYPE, "Config value has wrong type");
|
2008-08-06 09:39:48 +02:00
|
|
|
|
|
|
|
|
|
2008-08-06 10:11:43 +02:00
|
|
|
/* singleton config */
|
2008-08-07 08:10:23 +02:00
|
|
|
static LumieraConfig lumiera_global_config = NULL;
|
2008-08-06 10:11:43 +02:00
|
|
|
|
2008-08-06 09:39:48 +02:00
|
|
|
|
2008-08-06 10:11:04 +02:00
|
|
|
int
|
2008-08-06 09:39:48 +02:00
|
|
|
lumiera_config_init (const char* path)
|
|
|
|
|
{
|
2008-08-07 08:10:23 +02:00
|
|
|
TRACE (config);
|
|
|
|
|
REQUIRE (!lumiera_global_config, "Configuration subsystem already initialized");
|
|
|
|
|
REQUIRE (path);
|
|
|
|
|
|
|
|
|
|
NOBUG_INIT_FLAG (config_all);
|
|
|
|
|
NOBUG_INIT_FLAG (config);
|
|
|
|
|
NOBUG_INIT_FLAG (config_typed);
|
|
|
|
|
NOBUG_INIT_FLAG (config_file);
|
|
|
|
|
|
|
|
|
|
lumiera_global_config = lumiera_malloc (sizeof (*lumiera_global_config));
|
|
|
|
|
lumiera_global_config->path = lumiera_strndup (path, SIZE_MAX);
|
|
|
|
|
lumiera_rwlock_init (&lumiera_global_config->lock);
|
|
|
|
|
RESOURCE_ANNOUNCE (config, "rwlock", "config", lumiera_global_config, lumiera_global_config->rh);
|
2008-08-07 06:09:50 +02:00
|
|
|
|
|
|
|
|
return 0;
|
2008-08-06 09:39:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-08-07 06:09:50 +02:00
|
|
|
void
|
|
|
|
|
lumiera_config_destroy ()
|
2008-08-06 09:39:48 +02:00
|
|
|
{
|
2008-08-07 08:10:23 +02:00
|
|
|
TRACE (config);
|
|
|
|
|
if (lumiera_global_config)
|
2008-08-07 06:09:50 +02:00
|
|
|
{
|
2008-08-07 08:10:23 +02:00
|
|
|
RESOURCE_FORGET (config, lumiera_global_config->rh);
|
|
|
|
|
lumiera_free (lumiera_global_config->path);
|
|
|
|
|
lumiera_free (lumiera_global_config);
|
|
|
|
|
lumiera_global_config = NULL;
|
2008-08-07 06:09:50 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
WARN (config, "Tried to destroy non initialized config subsystem");
|
2008-08-06 09:39:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-08-06 10:11:04 +02:00
|
|
|
int
|
2008-08-06 09:39:48 +02:00
|
|
|
lumiera_config_load (const char* file)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED();
|
2008-08-06 10:11:04 +02:00
|
|
|
return -1;
|
2008-08-06 09:39:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-08-06 10:11:04 +02:00
|
|
|
int
|
2008-08-06 09:39:48 +02:00
|
|
|
lumiera_config_save ()
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED();
|
2008-08-06 10:11:04 +02:00
|
|
|
return -1;
|
2008-08-06 09:39:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-08-06 10:11:04 +02:00
|
|
|
int
|
2008-08-06 09:39:48 +02:00
|
|
|
lumiera_config_purge (const char* filename)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED();
|
2008-08-06 10:11:04 +02:00
|
|
|
return -1;
|
2008-08-06 09:39:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-08-06 10:11:04 +02:00
|
|
|
int
|
2008-08-06 09:39:48 +02:00
|
|
|
lumiera_config_get (const char* key, const char** value)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED();
|
2008-08-06 10:11:04 +02:00
|
|
|
// env var override
|
|
|
|
|
|
|
|
|
|
return -1;
|
2008-08-06 09:39:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-08-06 10:11:04 +02:00
|
|
|
int
|
2008-08-06 09:39:48 +02:00
|
|
|
lumiera_config_set (const char* key, const char* value)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED();
|
2008-08-06 10:11:04 +02:00
|
|
|
return -1;
|
2008-08-06 09:39:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-08-06 10:11:04 +02:00
|
|
|
int
|
2008-08-06 09:39:48 +02:00
|
|
|
lumiera_config_reset(const char* key)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED();
|
2008-08-06 10:11:04 +02:00
|
|
|
return -1;
|
2008-08-06 09:39:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-08-06 10:11:04 +02:00
|
|
|
int
|
2008-08-06 09:39:48 +02:00
|
|
|
lumiera_config_info (const char* key, const char** filename, unsigned* line)
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED();
|
2008-08-06 10:11:04 +02:00
|
|
|
return -1;
|
2008-08-06 09:39:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
// Local Variables:
|
|
|
|
|
// mode: C
|
|
|
|
|
// c-file-style: "gnu"
|
|
|
|
|
// indent-tabs-mode: nil
|
|
|
|
|
// End:
|
|
|
|
|
*/
|