summaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2015-07-12 23:16:48 +0530
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-12 13:58:16 -0700
commite98cbdf0205fd0903c63b4879096da013e6671a0 (patch)
tree0fd9c5e5bc48a1c63e0f2a801d9271a1d12dcc3f /file.c
parentb4d5f6fd5397bde406300218e4f253e3662a19fa (diff)
downloadsubsurface-e98cbdf0205fd0903c63b4879096da013e6671a0.tar.gz
Divinglog import: basic dive info for DB import
This parses the basic metadata of a dive when importing Divinglog database. (Discarding deleted dives is my best guess as I do not have that in my sample dive.) Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'file.c')
-rw-r--r--file.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/file.c b/file.c
index 085c33379..3bbcace4d 100644
--- a/file.c
+++ b/file.c
@@ -171,6 +171,7 @@ static int try_to_open_db(const char *filename, struct memblock *mem)
char dm5_test[] = "select count(*) from sqlite_master where type='table' and name='Dive' and sql like '%SampleBlob%'";
char shearwater_test[] = "select count(*) from sqlite_master where type='table' and name='system' and sql like '%dbVersion%'";
char cobalt_test[] = "select count(*) from sqlite_master where type='table' and name='TrackPoints' and sql like '%DepthPressure%'";
+ char divinglog_test[] = "select count(*) from sqlite_master where type='table' and name='DBInfo' and sql like '%PrgName%'";
int retval;
retval = sqlite3_open(filename, &handle);
@@ -212,6 +213,14 @@ static int try_to_open_db(const char *filename, struct memblock *mem)
return retval;
}
+ /* Testing if DB schema resembles Divinglog database format */
+ retval = sqlite3_exec(handle, divinglog_test, &db_test_func, 0, NULL);
+ if (!retval) {
+ retval = parse_divinglog_buffer(handle, filename, mem->buffer, mem->size, &dive_table);
+ sqlite3_close(handle);
+ return retval;
+ }
+
sqlite3_close(handle);
return retval;