From d599e57c04d5824c9270ac8f064f94be32bfcf57 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Sat, 21 Jul 2007 20:52:59 +0300 Subject: [PATCH] Formating. --- src/cb.c | 21 +++++++-------------- src/poi.c | 33 ++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/cb.c b/src/cb.c index ac71df6..e8dce37 100644 --- a/src/cb.c +++ b/src/cb.c @@ -502,27 +502,20 @@ gboolean menu_cb_goto_nearpoi(GtkAction * action) unit2latlon(_center.unitx, _center.unity, lat, lon); } - if (SQLITE_OK == - sqlite3_bind_double(_stmt_select_nearest_poi, 1, lat) - && SQLITE_OK == - sqlite3_bind_double(_stmt_select_nearest_poi, 2, lon) + if (SQLITE_OK == sqlite3_bind_double(_stmt_select_nearest_poi, 1, lat) + && SQLITE_OK == sqlite3_bind_double(_stmt_select_nearest_poi, 2, lon) && SQLITE_ROW == sqlite3_step(_stmt_select_nearest_poi)) { guint unitx, unity; gchar *banner; const gchar *poi_label, *cat_label; - lat = - sqlite3_column_double(_stmt_select_nearest_poi, 0); - lon = - sqlite3_column_double(_stmt_select_nearest_poi, 1); - poi_label = - sqlite3_column_text(_stmt_select_nearest_poi, 2); - cat_label = - sqlite3_column_text(_stmt_select_nearest_poi, 3); + lat = sqlite3_column_double(_stmt_select_nearest_poi, 0); + lon = sqlite3_column_double(_stmt_select_nearest_poi, 1); + poi_label = sqlite3_column_text(_stmt_select_nearest_poi, 2); + cat_label = sqlite3_column_text(_stmt_select_nearest_poi, 3); latlon2unit(lat, lon, unitx, unity); - banner = - g_strdup_printf("%s (%s)", poi_label, cat_label); + banner = g_strdup_printf("%s (%s)", poi_label, cat_label); MACRO_BANNER_SHOW_INFO(_window, banner); g_free(banner); diff --git a/src/poi.c b/src/poi.c index a1b01ef..a82aba6 100644 --- a/src/poi.c +++ b/src/poi.c @@ -103,7 +103,7 @@ sqlite3_stmt *sql_cat; gint i; g_printf("Checking default categories\n"); -sqlite3_prepare(db,"insert into category (cat_id, label, desc, enabled)" +sqlite3_prepare_v2(db,"insert into category (cat_id, label, desc, enabled)" " values (?, ?, ?, 1)", -1, &sql_cat, NULL); @@ -172,7 +172,7 @@ gboolean poi_db_prepare(sqlite3 *db) { /* select from poi */ - sqlite3_prepare(db, + sqlite3_prepare_v2(db, "select p.lat, p.lon, p.poi_id, p.label, p.desc," " p.cat_id, c.label, c.desc, c.icon, c.color" " from poi p, category c " @@ -182,7 +182,7 @@ poi_db_prepare(sqlite3 *db) -1, &_stmt_select_poi, NULL); /* select nearest pois */ - sqlite3_prepare(db, + sqlite3_prepare_v2(db, "select p.lat, p.lon, p.label, c.label, c.icon, c.color" " from poi p, category c " " where c.enabled = 1 and p.cat_id = c.cat_id " @@ -193,46 +193,46 @@ poi_db_prepare(sqlite3 *db) -1, &_stmt_select_nearest_poi, NULL); /* insert poi */ - sqlite3_prepare(db, + sqlite3_prepare_v2(db, "insert into poi (lat, lon, label, desc, cat_id, public)" " values (?, ?, ?, ?, ?, 1)", -1, &_stmt_insert_poi, NULL); /* update poi */ - sqlite3_prepare(db, "update poi set label = ?, desc = ?, " + sqlite3_prepare_v2(db, "update poi set label = ?, desc = ?, " "cat_id = ? where poi_id = ?", -1, &_stmt_update_poi, NULL); /* delete from poi */ - sqlite3_prepare(db, "delete from poi where poi_id = ?", + sqlite3_prepare_v2(db, "delete from poi where poi_id = ?", -1, &_stmt_delete_poi, NULL); /* delete from poi by cat_id */ - sqlite3_prepare(db, "delete from poi where cat_id = ?", + sqlite3_prepare_v2(db, "delete from poi where cat_id = ?", -1, &_stmt_delete_poi_by_catid, NULL); /* get next poilabel */ - sqlite3_prepare(db, "select ifnull(max(poi_id) + 1,1) from poi", + sqlite3_prepare_v2(db, "select ifnull(max(poi_id) + 1,1) from poi", -1, &_stmt_nextlabel_poi, NULL); /* select from category */ - sqlite3_prepare(db, + sqlite3_prepare_v2(db, "select c.label, c.desc, c.enabled" " from category c where c.cat_id = ?", -1, &_stmt_select_cat, NULL); /* insert into category */ - sqlite3_prepare(db, + sqlite3_prepare_v2(db, "insert into category (label, desc, enabled)" " values (?, ?, ?)", -1, &_stmt_insert_cat, NULL); /* update category */ - sqlite3_prepare(db, + sqlite3_prepare_v2(db, "update category set label = ?, desc = ?," " enabled = ? where poi_id = ?", -1, &_stmt_update_cat, NULL); /* delete from category */ - sqlite3_prepare(db,"delete from category where cat_id = ?", + sqlite3_prepare_v2(db,"delete from category where cat_id = ?", -1, &_stmt_delete_cat, NULL); /* enable category */ - sqlite3_prepare(db, + sqlite3_prepare_v2(db, "update category set enabled = ?" " where cat_id = ?", -1, &_stmt_toggle_cat, NULL); /* select all category */ - sqlite3_prepare(db, + sqlite3_prepare_v2(db, "select c.cat_id, c.label, c.desc, c.enabled, c.icon, c.color," " count(p.poi_id)" " from category c" @@ -259,7 +259,10 @@ poi_db_connect(sqlite3 **db, const gchar *poi_db) { if (db_connect(db, poi_db)) { poi_db_create(*db); - poi_db_prepare(*db); + if (poi_db_prepare(*db)==FALSE) + g_printerr("Failed to prepare POI SQL statements"); + if (osm_db_prepare(*db)==FALSE) + g_printerr("Failed to prepare OSM SQL statements"); return TRUE; } return FALSE; -- 2.39.5