Remove old db_config_* interface

This commit is contained in:
Julien BLACHE 2010-11-19 20:50:24 +01:00
parent 9507f8d059
commit 27c89cf312
2 changed files with 0 additions and 224 deletions

208
src/db.c
View File

@ -2975,214 +2975,6 @@ db_pairing_fetch_byguid(struct pairing_info *pi)
}
/* Config */
int
db_config_save_int(const char *key, int val)
{
#define Q_TMPL "UPDATE admin SET value = '%d' WHERE key = '%q';"
char *query;
char *errmsg;
int ret;
query = sqlite3_mprintf(Q_TMPL, val, key);
if (!query)
{
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
return -1;
}
DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query);
errmsg = NULL;
ret = db_exec(query, &errmsg);
if (ret != SQLITE_OK)
{
DPRINTF(E_LOG, L_DB, "Error saving int value: %s\n", errmsg);
sqlite3_free(errmsg);
sqlite3_free(query);
return -1;
}
sqlite3_free(query);
return 0;
#undef Q_TMPL
}
int
db_config_save_hex64(const char *key, uint64_t val)
{
#define Q_TMPL "INSERT INTO admin (key, value) VALUES ('%q', '%016" PRIx64 "');"
char *query;
char *errmsg;
int ret;
query = sqlite3_mprintf(Q_TMPL, key, val);
if (!query)
{
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
return -1;
}
DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query);
errmsg = NULL;
ret = db_exec(query, &errmsg);
if (ret != SQLITE_OK)
{
DPRINTF(E_LOG, L_DB, "Error saving hex64 value: %s\n", errmsg);
sqlite3_free(errmsg);
sqlite3_free(query);
return -1;
}
sqlite3_free(query);
return 0;
#undef Q_TMPL
}
int
db_config_fetch_int(const char *key, int *val)
{
#define Q_TMPL "SELECT value FROM admin WHERE key = '%q';"
sqlite3_stmt *stmt;
char *query;
int ret;
query = sqlite3_mprintf(Q_TMPL, key);
if (!query)
{
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
return -1;
}
DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query);
ret = db_blocking_prepare_v2(query, -1, &stmt, NULL);
if (ret != SQLITE_OK)
{
DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(hdl));
ret = -1;
goto out;
}
ret = db_blocking_step(stmt);
if (ret != SQLITE_ROW)
{
DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(hdl));
sqlite3_finalize(stmt);
ret = -1;
goto out;
}
*val = sqlite3_column_int(stmt, 0);
sqlite3_finalize(stmt);
ret = 0;
out:
sqlite3_free(query);
return ret;
#undef Q_TMPL
}
int
db_config_has_tuple_hex64(const char *key, uint64_t val)
{
#define Q_TMPL "SELECT 1 FROM admin WHERE key = '%q' AND value = '%016" PRIx64 "';"
sqlite3_stmt *stmt;
char *query;
int ret;
query = sqlite3_mprintf(Q_TMPL, key, val);
if (!query)
{
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
return -1;
}
DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query);
ret = db_blocking_prepare_v2(query, -1, &stmt, NULL);
if (ret != SQLITE_OK)
{
DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(hdl));
ret = -1;
goto out;
}
ret = db_blocking_step(stmt);
switch (ret)
{
case SQLITE_ROW:
ret = 1;
break;
case SQLITE_DONE:
ret = 0;
break;
default:
DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(hdl));
ret = -1;
break;
}
sqlite3_finalize(stmt);
out:
sqlite3_free(query);
return ret;
#undef Q_TMPL
}
void
db_config_clear_key(const char *key)
{
#define Q_TMPL "DELETE FROM admin WHERE key = '%q';"
char *query;
char *errmsg;
int ret;
query = sqlite3_mprintf(Q_TMPL, key);
if (!query)
{
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
return;
}
DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query);
ret = db_exec(query, &errmsg);
if (ret != SQLITE_OK)
DPRINTF(E_LOG, L_DB, "Error clearing config key %s: %s\n", key, errmsg);
sqlite3_free(errmsg);
sqlite3_free(query);
#undef Q_TMPL
}
/* Speakers */
int
db_speaker_save(uint64_t id, int selected, int volume)

View File

@ -403,22 +403,6 @@ db_pairing_add(struct pairing_info *pi);
int
db_pairing_fetch_byguid(struct pairing_info *pi);
/* Config */
int
db_config_save_int(const char *key, int val);
int
db_config_save_hex64(const char *key, uint64_t val);
int
db_config_fetch_int(const char *key, int *val);
int
db_config_has_tuple_hex64(const char *key, uint64_t val);
void
db_config_clear_key(const char *key);
/* Speakers */
int
db_speaker_save(uint64_t id, int selected, int volume);