* A simple check to test if a table exists
*
*/
-gboolean db_check(sqlite3 *db, const gchar *table)
+gboolean
+db_check(sqlite3 *db, const gchar *table)
{
gchar **pszResult;
guint nRow, nColumn;
* Close the database connection
*
*/
-gboolean db_close(sqlite3 **db)
+gboolean
+db_close(sqlite3 **db)
{
if (db && *db) {
+ g_print("Closing database.\n");
sqlite3_close(*db);
*db=NULL;
}
* Connect to given sqlite database
*
*/
-gboolean db_connect(sqlite3 **ndb, const gchar *mapper_db)
+gboolean
+db_connect(sqlite3 **db, const gchar *mapper_db)
{
-sqlite3 *db;
-
-if (ndb && *ndb)
- db=*ndb;
-else
- db=NULL;
-
-if (db) {
- sqlite3_close(db);
- db = NULL;
+if (db && *db) {
+ sqlite3_close(*db);
+ *db=NULL;
}
if (!mapper_db)
return FALSE;
-if (SQLITE_OK != (sqlite3_open(mapper_db, &db))) {
- sqlite3_close(db);
- db = NULL;
- *ndb=db;
+if (SQLITE_OK!=(sqlite3_open(mapper_db, db))) {
+ sqlite3_close(*db);
+ *db=NULL;
return FALSE;
}
/* Use smaller cache as the IT does not have much memory to spare */
#ifdef WITH_DEVICE_770
-sqlite3_exec(db, "PRAGMA cache_size = 1000;", NULL, NULL, NULL);
+sqlite3_exec(*db, "PRAGMA cache_size = 1000;", NULL, NULL, NULL);
#else
-sqlite3_exec(db, "PRAGMA cache_size = 8000;", NULL, NULL, NULL);
+sqlite3_exec(*db, "PRAGMA cache_size = 8000;", NULL, NULL, NULL);
#endif
-*ndb=db;
-
return TRUE;
}