From e53897cd158150995b48cb641dda1b8697d0099b Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Sun, 12 Jul 2015 23:17:00 +0530 Subject: Divinglog import: grab information for cylinder 0 Cylinder 0 is stored on the Logbook table along with other dive metadata (not in Tank table). Signed-off-by: Miika Turkia Signed-off-by: Dirk Hohndel --- parse-xml.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/parse-xml.c b/parse-xml.c index bca7345cc..974906e58 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -23,6 +23,7 @@ int verbose, quit; int metric = 1; int last_xml_version = -1; +int diveid = -1; static xmlDoc *test_xslt_transforms(xmlDoc *doc, const char **params); @@ -2982,10 +2983,11 @@ extern int divinglog_profile(void *handle, int columns, char **data, char **colu extern int divinglog_dive(void *param, int columns, char **data, char **column) { - int retval = 0, diveid; + int retval = 0; sqlite3 *handle = (sqlite3 *)param; char *err = NULL; char get_profile_template[] = "select ProfileInt,Profile,Profile2 from Logbook where ID = %d"; + char get_cylinder0_template[] = "select 0,TankSize,PresS,PresE,PresW,O2,He,DblTank from Logbook where ID = %d"; char get_cylinder_template[] = "select TankID,TankSize,PresS,PresE,PresW,O2,He,DblTank from Tank where LogID = %d order by TankID"; char get_buffer[1024]; @@ -3036,6 +3038,13 @@ extern int divinglog_dive(void *param, int columns, char **data, char **column) cur_settings.dc.model = strdup("Divinglog import"); } + snprintf(get_buffer, sizeof(get_buffer) - 1, get_cylinder0_template, diveid); + retval = sqlite3_exec(handle, get_buffer, &divinglog_cylinder, 0, &err); + if (retval != SQLITE_OK) { + fprintf(stderr, "%s", "Database query divinglog_cylinder0 failed.\n"); + return 1; + } + snprintf(get_buffer, sizeof(get_buffer) - 1, get_cylinder_template, diveid); retval = sqlite3_exec(handle, get_buffer, &divinglog_cylinder, 0, &err); if (retval != SQLITE_OK) { -- cgit v1.2.3-70-g09d2