diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2014-02-15 08:36:49 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-02-14 22:45:07 -0800 |
commit | 4b949936c26d5689c331d7c7e25b8c130e97c0e5 (patch) | |
tree | 2ea19c1e71239ef7b7f3e433cae7d76d49a307ce /parse-xml.c | |
parent | e49bd86f5e6d96161eb2518f23ce64f7969a4375 (diff) | |
download | subsurface-4b949936c26d5689c331d7c7e25b8c130e97c0e5.tar.gz |
Refactoring sqlite import support
Move the opening of DB connection to occur before DC dependent code.
This way we can try to detect log software before calling the DC
dependent import function. This prepares for adding support for
Shearwater sqlite database.
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 | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/parse-xml.c b/parse-xml.c index 2a98d3904..60a13c336 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -14,8 +14,6 @@ #include "gettext.h" -#include<sqlite3.h> - #include "dive.h" #include "device.h" @@ -1863,25 +1861,17 @@ extern int dm4_dive(void *param, int columns, char **data, char **column) return SQLITE_OK; } -int parse_dm4_buffer(const char *url, const char *buffer, int size, +int parse_dm4_buffer(const sqlite3 *handle, const char *url, const char *buffer, int size, struct dive_table *table, char **error) { int retval; char *err = NULL; - sqlite3 *handle; target_table = table; /* StartTime is converted from Suunto's nano seconds to standard * time. We also need epoch, not seconds since year 1. */ char get_dives[] = "select D.DiveId,StartTime/10000000-62135596800,Note,Duration,SourceSerialNumber,Source,MaxDepth,SampleInterval,StartTemperature,BottomTemperature,D.StartPressure,D.EndPressure,Size,CylinderWorkPressure,SurfacePressure,DiveTime,SampleInterval,ProfileBlob,TemperatureBlob,PressureBlob,Oxygen,Helium,MIX.StartPressure,MIX.EndPressure FROM Dive AS D JOIN DiveMixture AS MIX ON D.DiveId=MIX.DiveId"; - retval = sqlite3_open(url, &handle); - - if (retval) { - fprintf(stderr, translate("gettextFromC","Database connection failed '%s'.\n"), url); - return 1; - } - retval = sqlite3_exec(handle, get_dives, &dm4_dive, handle, &err); if (retval != SQLITE_OK) { @@ -1889,7 +1879,6 @@ int parse_dm4_buffer(const char *url, const char *buffer, int size, return 1; } - sqlite3_close(handle); return 0; } |