* Rework the sql_exec function to use format arguments, to simplfy the code.

* Don't set the DB version until after the scan completes.  This way, if only a partial scan has been done, a full scan will be initiated the next time minidlna is started.
This commit is contained in:
Justin Maggard
2009-11-04 01:38:14 +00:00
parent 6738b8a722
commit c8fe23d838
7 changed files with 152 additions and 223 deletions

10
sql.c
View File

@ -21,12 +21,17 @@
#include "log.h"
int
sql_exec(sqlite3 * db, const char * sql)
sql_exec(sqlite3 *db, const char *fmt, ...)
{
int ret;
char *errMsg = NULL;
char *sql;
va_list ap;
//DPRINTF(E_DEBUG, L_DB_SQL, "SQL: %s\n", sql);
va_start(ap, fmt);
sql = sqlite3_vmprintf(fmt, ap);
ret = sqlite3_exec(db, sql, 0, 0, &errMsg);
if( ret != SQLITE_OK )
{
@ -34,6 +39,8 @@ sql_exec(sqlite3 * db, const char * sql)
if (errMsg)
sqlite3_free(errMsg);
}
sqlite3_free(sql);
return ret;
}
@ -51,6 +58,7 @@ sql_get_table(sqlite3 *db, const char *sql, char ***pazResult, int *pnRow, int *
if (errMsg)
sqlite3_free(errMsg);
}
return ret;
}