diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2015-02-21 13:15:03 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-02-22 07:46:44 -0800 |
commit | 5330a612c57df55c53513411fe5f87eb7b399944 (patch) | |
tree | c4173e92838913e4031d3319a11ee87c8a5859fb /parse-xml.c | |
parent | 3610c7b3b7f983ea1156860241837bde8e1dd784 (diff) | |
download | subsurface-5330a612c57df55c53513411fe5f87eb7b399944.tar.gz |
Support for gas changes in DM5 import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/parse-xml.c b/parse-xml.c index 285c681fc..d656ed31a 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -2090,6 +2090,19 @@ extern int dm5_cylinders(void *handle, int columns, char **data, char **column) return 0; } +extern int dm5_gaschange(void *handle, int columns, char **data, char **column) +{ + event_start(); + if (data[0]) + cur_event.time.seconds = atoi(data[0]); + if (data[1]) { + strcpy(cur_event.name, "gaschange"); + cur_event.value = atof(data[1]); + } + event_end(); + + return 0; +} extern int dm4_tags(void *handle, int columns, char **data, char **column) { @@ -2234,7 +2247,8 @@ extern int dm5_dive(void *param, int columns, char **data, char **column) char get_events_template[] = "select * from Mark where DiveId = %d"; char get_tags_template[] = "select Text from DiveTag where DiveId = %d"; char get_cylinders_template[] = "select * from DiveMixture where DiveId = %d"; - char get_events[64]; + char get_gaschange_template[] = "select GasChangeTime,Oxygen,Helium from DiveGasChange join DiveMixture on DiveGasChange.DiveMixtureId=DiveMixture.DiveMixtureId where DiveId = %d"; + char get_events[512]; dive_start(); cur_dive->number = atoi(data[0]); @@ -2333,6 +2347,13 @@ extern int dm5_dive(void *param, int columns, char **data, char **column) } } + snprintf(get_events, sizeof(get_events) - 1, get_gaschange_template, cur_dive->number); + retval = sqlite3_exec(handle, get_events, &dm5_gaschange, 0, &err); + if (retval != SQLITE_OK) { + fprintf(stderr, "%s", translate("gettextFromC", "Database query dm5_gaschange failed.\n")); + return 1; + } + snprintf(get_events, sizeof(get_events) - 1, get_events_template, cur_dive->number); retval = sqlite3_exec(handle, get_events, &dm4_events, 0, &err); if (retval != SQLITE_OK) { |