diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2014-12-20 18:19:46 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-12-20 11:29:32 -0800 |
commit | 82dea858eb6d9a5156331c8264c11af4aaf3e1b0 (patch) | |
tree | 8ae33a1fcba1ef95c7b999750c8a701199107781 /parse-xml.c | |
parent | 066e95bd386c63b6a1f83111b18b9d3e39d67f29 (diff) | |
download | subsurface-82dea858eb6d9a5156331c8264c11af4aaf3e1b0.tar.gz |
Add buddy support to Cobalt DB 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 | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/parse-xml.c b/parse-xml.c index d799850eb..d5496aa05 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -2358,6 +2358,14 @@ extern int cobalt_cylinders(void *handle, int columns, char **data, char **colum return 0; } +extern int cobalt_buddies(void *handle, int columns, char **data, char **column) +{ + if (data[0]) + utf8_string(data[0], &cur_dive->buddy); + + return 0; +} + extern int cobalt_dive(void *param, int columns, char **data, char **column) { @@ -2366,6 +2374,7 @@ extern int cobalt_dive(void *param, int columns, char **data, char **column) char *err = NULL; char get_profile_template[] = "select runtime*60,(DepthPressure*10000/SurfacePressure)-10000,p.Temperature from Dive AS d JOIN TrackPoints AS p ON d.Id=p.DiveId where d.Id=%d"; char get_cylinder_template[] = "select FO2,FHe,StartingPressure,EndingPressure,TankSize,TankPressure,TotalConsumption from GasMixes where DiveID=%d and StartingPressure>0 group by FO2,FHe"; + char get_buddy_template[] = "select l.Data from Items AS i, List AS l ON i.Value1=l.Id where i.DiveId=%d and l.Type=4"; char get_buffer[1024]; dive_start(); @@ -2416,6 +2425,13 @@ extern int cobalt_dive(void *param, int columns, char **data, char **column) return 1; } + snprintf(get_buffer, sizeof(get_buffer) - 1, get_buddy_template, cur_dive->number); + retval = sqlite3_exec(handle, get_buffer, &cobalt_buddies, 0, &err); + if (retval != SQLITE_OK) { + fprintf(stderr, "%s", translate("gettextFromC", "Database query get_cylinders failed.\n")); + return 1; + } + snprintf(get_buffer, sizeof(get_buffer) - 1, get_profile_template, cur_dive->number); retval = sqlite3_exec(handle, get_buffer, &cobalt_profile_sample, 0, &err); if (retval != SQLITE_OK) { |