From 5330a612c57df55c53513411fe5f87eb7b399944 Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Sat, 21 Feb 2015 13:15:03 +0200 Subject: Support for gas changes in DM5 import Signed-off-by: Miika Turkia Signed-off-by: Dirk Hohndel --- parse-xml.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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) { -- cgit v1.2.3-70-g09d2