config_db.c File Reference

Go to the source code of this file.

Classes

struct  _ConfigDb

Defines

#define CONFIGDB_BASENAME   "config.db"
#define CONFIGDB_DIR   CONFIG_DIR
#define CONFIGDB_FILE   (CONFIGDB_DIR DIR_SEP CONFIGDB_BASENAME)
#define FINALIZE_SQL_STATEMENT(lvalue)   if (lvalue) { sqlite3_finalize(lvalue); lvalue = NULL; }
#define do_nothing   ((void)0)
#define set_sql_error
#define handle_sql_error_done   { set_sql_error; goto done; }
#define handle_sql_error_false   { set_sql_error; return FALSE; }

Functions

static gboolean create_config_db (GError **error)
static gboolean ensure_config_db_created (GError **error)
static gboolean prepare_sql_statements (ConfigDb *self, GError **error)
static void destroy_sql_statements (ConfigDb *self)
static void close_config_db_session (ConfigDb *self)
static gboolean open_config_db_session (ConfigDb *self, GError **error)
ConfigDbConfigDb_new (GError **error)
void ConfigDb_destroy (ConfigDb *self)
static gchar * db_get (ConfigDb *self, const gchar *name, GError **error)
gchar * ConfigDb_get_generic (ConfigDb *self, const gchar *name, GError **error)
static gboolean db_set (ConfigDb *self, const gchar *name, const gchar *value, GError **error)
gboolean ConfigDb_set_generic (ConfigDb *self, const gchar *name, const gchar *value, GError **error)

Variables

static const char create_tables_sql []

Define Documentation

#define CONFIGDB_BASENAME   "config.db"

Config database file.

Definition at line 16 of file config_db.c.

#define CONFIGDB_DIR   CONFIG_DIR

Definition at line 17 of file config_db.c.

Referenced by create_config_db().

#define CONFIGDB_FILE   (CONFIGDB_DIR DIR_SEP CONFIGDB_BASENAME)
#define do_nothing   ((void)0)

Definition at line 154 of file config_db.c.

Referenced by db_get().

#define FINALIZE_SQL_STATEMENT ( lvalue   )     if (lvalue) { sqlite3_finalize(lvalue); lvalue = NULL; }

Definition at line 70 of file config_db.c.

Referenced by destroy_sql_statements().

#define handle_sql_error_done   { set_sql_error; goto done; }

Definition at line 163 of file config_db.c.

Referenced by db_get().

#define handle_sql_error_false   { set_sql_error; return FALSE; }

Definition at line 165 of file config_db.c.

Referenced by db_set().

#define set_sql_error
Value:
if (error)                \
    *error = gx_error_new(domain_cl2app, code_database_command,   \
        "ConfigDb database access error: %s (%d)",  \
        sqlite3_errmsg(self->db),     \
        sqlite3_errcode(self->db));

Definition at line 156 of file config_db.c.


Function Documentation

static void close_config_db_session ( ConfigDb self  )  [static]

Definition at line 79 of file config_db.c.

References destroy_sql_statements(), logg, and sqlite3_close().

Referenced by ConfigDb_destroy(), and open_config_db_session().

void ConfigDb_destroy ( ConfigDb self  ) 

Definition at line 145 of file config_db.c.

References close_config_db_session(), and mutex_destroy.

Referenced by ConfigDb_new(), and kr_Controller_destroy().

gchar* ConfigDb_get_generic ( ConfigDb self,
const gchar *  name,
GError **  error 
)

Definition at line 230 of file config_db.c.

References db_get(), and mutex_synchronized.

ConfigDb* ConfigDb_new ( GError **  error  ) 
gboolean ConfigDb_set_generic ( ConfigDb self,
const gchar *  name,
const gchar *  value,
GError **  error 
)
static gboolean create_config_db ( GError **  error  )  [static]

Definition at line 23 of file config_db.c.

References CONFIGDB_DIR, CONFIGDB_FILE, create_database(), and create_tables_sql.

Referenced by ensure_config_db_created().

static gchar* db_get ( ConfigDb self,
const gchar *  name,
GError **  error 
) [static]
static gboolean db_set ( ConfigDb self,
const gchar *  name,
const gchar *  value,
GError **  error 
) [static]
static void destroy_sql_statements ( ConfigDb self  )  [static]

Definition at line 73 of file config_db.c.

References FINALIZE_SQL_STATEMENT.

Referenced by close_config_db_session(), and log_db_close_session().

static gboolean ensure_config_db_created ( GError **  error  )  [static]

Definition at line 31 of file config_db.c.

References assert_error_unset, CONFIGDB_FILE, create_config_db(), and logg.

Referenced by ConfigDb_new().

static gboolean open_config_db_session ( ConfigDb self,
GError **  error 
) [static]
static gboolean prepare_sql_statements ( ConfigDb self,
GError **  error 
) [static]

Variable Documentation

const char create_tables_sql[] [static]
Initial value:
  "create table configuration (name TEXT UNIQUE, value TEXT);"

Definition at line 20 of file config_db.c.

Referenced by create_config_db().


ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:58 2011 by Doxygen 1.6.1