diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/file.c | 45 | ||||
-rw-r--r-- | core/file.h | 7 | ||||
-rw-r--r-- | core/import-cobalt.c | 4 | ||||
-rw-r--r-- | core/import-csv.c | 31 | ||||
-rw-r--r-- | core/import-csv.h | 10 | ||||
-rw-r--r-- | core/import-divinglog.c | 4 | ||||
-rw-r--r-- | core/import-seac.c | 6 | ||||
-rw-r--r-- | core/import-shearwater.c | 8 | ||||
-rw-r--r-- | core/import-suunto.c | 8 | ||||
-rw-r--r-- | core/parse-xml.c | 8 | ||||
-rw-r--r-- | core/parse.h | 27 |
11 files changed, 98 insertions, 60 deletions
diff --git a/core/file.c b/core/file.c index d8f9d48a9..e6fe28df6 100644 --- a/core/file.c +++ b/core/file.c @@ -77,7 +77,7 @@ out: static void zip_read(struct zip_file *file, const char *filename, struct dive_table *table, struct trip_table *trips, - struct dive_site_table *sites, struct filter_preset_table *filter_presets) + struct dive_site_table *sites, struct device_table *devices, struct filter_preset_table *filter_presets) { int size = 1024, n, read = 0; char *mem = malloc(size); @@ -88,12 +88,12 @@ static void zip_read(struct zip_file *file, const char *filename, struct dive_ta mem = realloc(mem, size); } mem[read] = 0; - (void) parse_xml_buffer(filename, mem, read, table, trips, sites, filter_presets, NULL); + (void) parse_xml_buffer(filename, mem, read, table, trips, sites, devices, filter_presets, NULL); free(mem); } int try_to_open_zip(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, - struct filter_preset_table *filter_presets) + struct device_table *devices, struct filter_preset_table *filter_presets) { int success = 0; /* Grr. libzip needs to re-open the file, it can't take a buffer */ @@ -108,7 +108,7 @@ int try_to_open_zip(const char *filename, struct dive_table *table, struct trip_ /* skip parsing the divelogs.de pictures */ if (strstr(zip_get_name(zip, index, 0), "pictures/")) continue; - zip_read(file, filename, table, trips, sites, filter_presets); + zip_read(file, filename, table, trips, sites, devices, filter_presets); zip_fclose(file); success++; } @@ -128,7 +128,8 @@ static int db_test_func(void *param, int columns, char **data, char **column) return *data[0] == '0'; } -static int try_to_open_db(const char *filename, struct memblock *mem, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites) +static int try_to_open_db(const char *filename, struct memblock *mem, struct dive_table *table, struct trip_table *trips, + struct dive_site_table *sites, struct device_table *devices) { sqlite3 *handle; char dm4_test[] = "select count(*) from sqlite_master where type='table' and name='Dive' and sql like '%ProfileBlob%'"; @@ -150,7 +151,7 @@ static int try_to_open_db(const char *filename, struct memblock *mem, struct div /* Testing if DB schema resembles Suunto DM5 database format */ retval = sqlite3_exec(handle, dm5_test, &db_test_func, 0, NULL); if (!retval) { - retval = parse_dm5_buffer(handle, filename, mem->buffer, mem->size, table, trips, sites); + retval = parse_dm5_buffer(handle, filename, mem->buffer, mem->size, table, trips, sites, devices); sqlite3_close(handle); return retval; } @@ -158,7 +159,7 @@ static int try_to_open_db(const char *filename, struct memblock *mem, struct div /* Testing if DB schema resembles Suunto DM4 database format */ retval = sqlite3_exec(handle, dm4_test, &db_test_func, 0, NULL); if (!retval) { - retval = parse_dm4_buffer(handle, filename, mem->buffer, mem->size, table, trips, sites); + retval = parse_dm4_buffer(handle, filename, mem->buffer, mem->size, table, trips, sites, devices); sqlite3_close(handle); return retval; } @@ -166,7 +167,7 @@ static int try_to_open_db(const char *filename, struct memblock *mem, struct div /* Testing if DB schema resembles Shearwater database format */ retval = sqlite3_exec(handle, shearwater_test, &db_test_func, 0, NULL); if (!retval) { - retval = parse_shearwater_buffer(handle, filename, mem->buffer, mem->size, table, trips, sites); + retval = parse_shearwater_buffer(handle, filename, mem->buffer, mem->size, table, trips, sites, devices); sqlite3_close(handle); return retval; } @@ -174,7 +175,7 @@ static int try_to_open_db(const char *filename, struct memblock *mem, struct div /* Testing if DB schema resembles Shearwater cloud database format */ retval = sqlite3_exec(handle, shearwater_cloud_test, &db_test_func, 0, NULL); if (!retval) { - retval = parse_shearwater_cloud_buffer(handle, filename, mem->buffer, mem->size, table, trips, sites); + retval = parse_shearwater_cloud_buffer(handle, filename, mem->buffer, mem->size, table, trips, sites, devices); sqlite3_close(handle); return retval; } @@ -182,7 +183,7 @@ static int try_to_open_db(const char *filename, struct memblock *mem, struct div /* Testing if DB schema resembles Atomic Cobalt database format */ retval = sqlite3_exec(handle, cobalt_test, &db_test_func, 0, NULL); if (!retval) { - retval = parse_cobalt_buffer(handle, filename, mem->buffer, mem->size, table, trips, sites); + retval = parse_cobalt_buffer(handle, filename, mem->buffer, mem->size, table, trips, sites, devices); sqlite3_close(handle); return retval; } @@ -190,7 +191,7 @@ static int try_to_open_db(const char *filename, struct memblock *mem, struct div /* Testing if DB schema resembles Divinglog database format */ retval = sqlite3_exec(handle, divinglog_test, &db_test_func, 0, NULL); if (!retval) { - retval = parse_divinglog_buffer(handle, filename, mem->buffer, mem->size, table, trips, sites); + retval = parse_divinglog_buffer(handle, filename, mem->buffer, mem->size, table, trips, sites, devices); sqlite3_close(handle); return retval; } @@ -198,7 +199,7 @@ static int try_to_open_db(const char *filename, struct memblock *mem, struct div /* Testing if DB schema resembles Seac database format */ retval = sqlite3_exec(handle, seacsync_test, &db_test_func, 0, NULL); if (!retval) { - retval = parse_seac_buffer(handle, filename, mem->buffer, mem->size, table, trips, sites); + retval = parse_seac_buffer(handle, filename, mem->buffer, mem->size, table, trips, sites, devices); sqlite3_close(handle); return retval; } @@ -227,7 +228,7 @@ static int try_to_open_db(const char *filename, struct memblock *mem, struct div */ static int open_by_filename(const char *filename, const char *fmt, struct memblock *mem, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, - struct filter_preset_table *filter_presets) + struct device_table *devices, struct filter_preset_table *filter_presets) { // hack to be able to provide a comment for the translated string static char *csv_warning = QT_TRANSLATE_NOOP3("gettextFromC", @@ -236,7 +237,7 @@ static int open_by_filename(const char *filename, const char *fmt, struct memblo /* Suunto Dive Manager files: SDE, ZIP; divelogs.de files: DLD */ if (!strcasecmp(fmt, "SDE") || !strcasecmp(fmt, "ZIP") || !strcasecmp(fmt, "DLD")) - return try_to_open_zip(filename, table, trips, sites, filter_presets); + return try_to_open_zip(filename, table, trips, sites, devices, filter_presets); /* CSV files */ if (!strcasecmp(fmt, "CSV")) @@ -258,17 +259,18 @@ static int open_by_filename(const char *filename, const char *fmt, struct memblo } static int parse_file_buffer(const char *filename, struct memblock *mem, struct dive_table *table, - struct trip_table *trips, struct dive_site_table *sites, struct filter_preset_table *filter_presets) + struct trip_table *trips, struct dive_site_table *sites, + struct device_table *devices, struct filter_preset_table *filter_presets) { int ret; char *fmt = strrchr(filename, '.'); - if (fmt && (ret = open_by_filename(filename, fmt + 1, mem, table, trips, sites, filter_presets)) != 0) + if (fmt && (ret = open_by_filename(filename, fmt + 1, mem, table, trips, sites, devices, filter_presets)) != 0) return ret; if (!mem->size || !mem->buffer) return report_error("Out of memory parsing file %s\n", filename); - return parse_xml_buffer(filename, mem->buffer, mem->size, table, trips, sites, filter_presets, NULL); + return parse_xml_buffer(filename, mem->buffer, mem->size, table, trips, sites, devices, filter_presets, NULL); } int check_git_sha(const char *filename, struct git_repository **git_p, const char **branch_p) @@ -305,7 +307,8 @@ int check_git_sha(const char *filename, struct git_repository **git_p, const cha return 1; } -int parse_file(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, struct filter_preset_table *filter_presets) +int parse_file(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, + struct device_table *devices, struct filter_preset_table *filter_presets) { struct git_repository *git; const char *branch = NULL; @@ -336,7 +339,7 @@ int parse_file(const char *filename, struct dive_table *table, struct trip_table fmt = strrchr(filename, '.'); if (fmt && (!strcasecmp(fmt + 1, "DB") || !strcasecmp(fmt + 1, "BAK") || !strcasecmp(fmt + 1, "SQL"))) { - if (!try_to_open_db(filename, &mem, table, trips, sites)) { + if (!try_to_open_db(filename, &mem, table, trips, sites, devices)) { free(mem.buffer); return 0; } @@ -344,7 +347,7 @@ int parse_file(const char *filename, struct dive_table *table, struct trip_table /* Divesoft Freedom */ if (fmt && (!strcasecmp(fmt + 1, "DLF"))) { - ret = parse_dlf_buffer(mem.buffer, mem.size, table, trips, sites); + ret = parse_dlf_buffer(mem.buffer, mem.size, table, trips, sites, devices); free(mem.buffer); return ret; } @@ -375,7 +378,7 @@ int parse_file(const char *filename, struct dive_table *table, struct trip_table return 0; } - ret = parse_file_buffer(filename, &mem, table, trips, sites, filter_presets); + ret = parse_file_buffer(filename, &mem, table, trips, sites, devices, filter_presets); free(mem.buffer); return ret; } diff --git a/core/file.h b/core/file.h index 00b1dcbde..e479cdaac 100644 --- a/core/file.h +++ b/core/file.h @@ -13,6 +13,7 @@ struct memblock { }; struct trip_table; +struct device_table; struct dive_site_table; struct dive_table; struct zip; @@ -26,8 +27,10 @@ extern int datatrak_import(struct memblock *mem, struct memblock *wl_mem, struct extern void ostctools_import(const char *file, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); extern int readfile(const char *filename, struct memblock *mem); -extern int parse_file(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, struct filter_preset_table *filter_presets); -extern int try_to_open_zip(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, struct filter_preset_table *filter_presets); +extern int parse_file(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, + struct device_table *devices, struct filter_preset_table *filter_presets); +extern int try_to_open_zip(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, + struct device_table *devices, struct filter_preset_table *filter_presets); // Platform specific functions extern int subsurface_rename(const char *path, const char *newpath); diff --git a/core/import-cobalt.c b/core/import-cobalt.c index 28f6968a3..22bf14dbb 100644 --- a/core/import-cobalt.c +++ b/core/import-cobalt.c @@ -217,7 +217,8 @@ static int cobalt_dive(void *param, int columns, char **data, char **column) int parse_cobalt_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, - struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites) + struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, + struct device_table *devices) { UNUSED(buffer); UNUSED(size); @@ -229,6 +230,7 @@ int parse_cobalt_buffer(sqlite3 *handle, const char *url, const char *buffer, in state.target_table = table; state.trips = trips; state.sites = sites; + state.devices = devices; state.sql_handle = handle; char get_dives[] = "select Id,strftime('%s',DiveStartTime),LocationId,'buddy','notes',Units,(MaxDepthPressure*10000/SurfacePressure)-10000,DiveMinutes,SurfacePressure,SerialNumber,'model' from Dive where IsViewDeleted = 0"; diff --git a/core/import-csv.c b/core/import-csv.c index 9748ce5ef..a815408a8 100644 --- a/core/import-csv.c +++ b/core/import-csv.c @@ -105,7 +105,7 @@ static char *parse_dan_new_line(char *buf, const char *NL) static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, const char *tag); static int parse_dan_format(const char *filename, struct xml_params *params, struct dive_table *table, - struct trip_table *trips, struct dive_site_table *sites, + struct trip_table *trips, struct dive_site_table *sites, struct device_table *devices, struct filter_preset_table *filter_presets) { int ret = 0, i; @@ -210,7 +210,7 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str xml_params_add(params, "waterTemp", tmpbuf); } } - ret |= parse_xml_buffer(filename, "<csv></csv>", 11, table, trips, sites, filter_presets, params); + ret |= parse_xml_buffer(filename, "<csv></csv>", 11, table, trips, sites, devices, filter_presets, params); continue; } @@ -265,7 +265,7 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str if (try_to_xslt_open_csv(filename, &mem_csv, "csv")) return -1; - ret |= parse_xml_buffer(filename, mem_csv.buffer, mem_csv.size, table, trips, sites, filter_presets, params); + ret |= parse_xml_buffer(filename, mem_csv.buffer, mem_csv.size, table, trips, sites, devices, filter_presets, params); end_ptr += ptr - (char *)mem_csv.buffer; free(mem_csv.buffer); } @@ -277,7 +277,7 @@ static int parse_dan_format(const char *filename, struct xml_params *params, str int parse_csv_file(const char *filename, struct xml_params *params, const char *csvtemplate, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, - struct filter_preset_table *filter_presets) + struct device_table *devices, struct filter_preset_table *filter_presets) { int ret, i; struct memblock mem; @@ -297,7 +297,7 @@ int parse_csv_file(const char *filename, struct xml_params *params, const char * mem.size = 0; if (!strcmp("DL7", csvtemplate)) { - return parse_dan_format(filename, params, table, trips, sites, filter_presets); + return parse_dan_format(filename, params, table, trips, sites, devices, filter_presets); } else if (strcmp(xml_params_get_key(params, 0), "date")) { time(&now); timep = localtime(&now); @@ -329,7 +329,7 @@ int parse_csv_file(const char *filename, struct xml_params *params, const char * fprintf(stderr, "%s/xslt/%s -\n", SUBSURFACE_SOURCE, csvtemplate); } #endif - ret = parse_xml_buffer(filename, mem.buffer, mem.size, table, trips, sites, filter_presets, params); + ret = parse_xml_buffer(filename, mem.buffer, mem.size, table, trips, sites, devices, filter_presets, params); free(mem.buffer); @@ -499,7 +499,8 @@ static char *next_mkvi_key(const char *haystack) return ret; } -int parse_txt_file(const char *filename, const char *csv, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites) +int parse_txt_file(const char *filename, const char *csv, struct dive_table *table, struct trip_table *trips, + struct dive_site_table *sites, struct device_table *devices) { UNUSED(sites); struct memblock memtxt, memcsv; @@ -794,14 +795,16 @@ int parse_txt_file(const char *filename, const char *csv, struct dive_table *tab #define SBPARAMS 40 static int parse_seabear_csv_file(const char *filename, struct xml_params *params, const char *csvtemplate, - struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, struct filter_preset_table *filter_presets); -int parse_seabear_log(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, struct filter_preset_table *filter_presets) + struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, + struct device_table *devices, struct filter_preset_table *filter_presets); +int parse_seabear_log(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, + struct device_table *devices, struct filter_preset_table *filter_presets) { struct xml_params *params = alloc_xml_params(); int ret; parse_seabear_header(filename, params); - ret = parse_seabear_csv_file(filename, params, "csv", table, trips, sites, filter_presets) < 0 ? -1 : 0; + ret = parse_seabear_csv_file(filename, params, "csv", table, trips, sites, devices, filter_presets) < 0 ? -1 : 0; free_xml_params(params); @@ -811,7 +814,7 @@ int parse_seabear_log(const char *filename, struct dive_table *table, struct tri static int parse_seabear_csv_file(const char *filename, struct xml_params *params, const char *csvtemplate, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, - struct filter_preset_table *filter_presets) + struct device_table *devices, struct filter_preset_table *filter_presets) { int ret, i; struct memblock mem; @@ -929,14 +932,14 @@ static int parse_seabear_csv_file(const char *filename, struct xml_params *param fprintf(stderr, "xslt/csv2xml.xslt\n"); } - ret = parse_xml_buffer(filename, mem.buffer, mem.size, table, trips, sites, filter_presets, params); + ret = parse_xml_buffer(filename, mem.buffer, mem.size, table, trips, sites, devices, filter_presets, params); free(mem.buffer); return ret; } int parse_manual_file(const char *filename, struct xml_params *params, struct dive_table *table, struct trip_table *trips, - struct dive_site_table *sites, struct filter_preset_table *filter_presets) + struct dive_site_table *sites, struct device_table *devices, struct filter_preset_table *filter_presets) { struct memblock mem; time_t now; @@ -972,7 +975,7 @@ int parse_manual_file(const char *filename, struct xml_params *params, struct di fprintf(stderr, "%s/xslt/manualcsv2xml.xslt -\n", SUBSURFACE_SOURCE); } #endif - ret = parse_xml_buffer(filename, mem.buffer, mem.size, table, trips, sites, filter_presets, params); + ret = parse_xml_buffer(filename, mem.buffer, mem.size, table, trips, sites, devices, filter_presets, params); free(mem.buffer); return ret; diff --git a/core/import-csv.h b/core/import-csv.h index 1ef4ee46b..d73b0fe04 100644 --- a/core/import-csv.h +++ b/core/import-csv.h @@ -26,14 +26,16 @@ extern "C" { #endif int parse_csv_file(const char *filename, struct xml_params *params, const char *csvtemplate, struct dive_table *table, - struct trip_table *trips, struct dive_site_table *sites, struct filter_preset_table *filter_presets); + struct trip_table *trips, struct dive_site_table *sites, struct device_table *devices, + struct filter_preset_table *filter_presets); int try_to_open_csv(struct memblock *mem, enum csv_format type, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); -int parse_txt_file(const char *filename, const char *csv, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); +int parse_txt_file(const char *filename, const char *csv, struct dive_table *table, struct trip_table *trips, + struct dive_site_table *sites, struct device_table *devices); int parse_seabear_log(const char *filename, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, - struct filter_preset_table *filter_presets); + struct device_table *devices, struct filter_preset_table *filter_presets); int parse_manual_file(const char *filename, struct xml_params *params, struct dive_table *table, struct trip_table *trips, - struct dive_site_table *sites, struct filter_preset_table *filter_presets); + struct dive_site_table *sites, struct device_table *devices, struct filter_preset_table *filter_presets); #ifdef __cplusplus } diff --git a/core/import-divinglog.c b/core/import-divinglog.c index f3a62eaff..24ab5c548 100644 --- a/core/import-divinglog.c +++ b/core/import-divinglog.c @@ -389,7 +389,8 @@ static int divinglog_dive(void *param, int columns, char **data, char **column) int parse_divinglog_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, - struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites) + struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, + struct device_table *devices) { UNUSED(buffer); UNUSED(size); @@ -401,6 +402,7 @@ int parse_divinglog_buffer(sqlite3 *handle, const char *url, const char *buffer, state.target_table = table; state.trips = trips; state.sites = sites; + state.devices = devices; state.sql_handle = handle; char get_dives[] = "select Number,strftime('%s',Divedate || ' ' || ifnull(Entrytime,'00:00')),Country || ' - ' || City || ' - ' || Place,Buddy,Comments,Depth,Divetime,Divemaster,Airtemp,Watertemp,Weight,Divesuit,Computer,ID,Visibility,SupplyType from Logbook where UUID not in (select UUID from DeletedRecords)"; diff --git a/core/import-seac.c b/core/import-seac.c index 4b34cbe99..38c7978af 100644 --- a/core/import-seac.c +++ b/core/import-seac.c @@ -260,7 +260,8 @@ static int seac_dive(void *param, int columns, char **data, char **column) * table, to read in the sample values. */ int parse_seac_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, - struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites) + struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, + struct device_table *devices) { UNUSED(buffer); UNUSED(size); @@ -273,6 +274,7 @@ int parse_seac_buffer(sqlite3 *handle, const char *url, const char *buffer, int state.target_table = table; state.trips = trips; state.sites = sites; + state.devices = devices; state.sql_handle = handle; const char *get_dives = "SELECT dive_number, device_sn, date, timezone, time, elapsed_surface_time, dive_type, start_mode, water_type, comment, total_dive_time, max_depth, firmware_version FROM headers_dive"; @@ -300,4 +302,4 @@ int parse_seac_buffer(sqlite3 *handle, const char *url, const char *buffer, int } return 0; -}
\ No newline at end of file +} diff --git a/core/import-shearwater.c b/core/import-shearwater.c index 0b0fa8799..4dd67de2b 100644 --- a/core/import-shearwater.c +++ b/core/import-shearwater.c @@ -485,7 +485,8 @@ static int shearwater_cloud_dive(void *param, int columns, char **data, char **c } int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, - struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites) + struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, + struct device_table *devices) { UNUSED(buffer); UNUSED(size); @@ -497,6 +498,7 @@ int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buffer state.target_table = table; state.trips = trips; state.sites = sites; + state.devices = devices; state.sql_handle = handle; // So far have not seen any sample rate in Shearwater Desktop @@ -516,7 +518,8 @@ int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buffer } int parse_shearwater_cloud_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, - struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites) + struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, + struct device_table *devices) { UNUSED(buffer); UNUSED(size); @@ -528,6 +531,7 @@ int parse_shearwater_cloud_buffer(sqlite3 *handle, const char *url, const char * state.target_table = table; state.trips = trips; state.sites = sites; + state.devices = devices; state.sql_handle = handle; char get_dives[] = "select l.number,strftime('%s', DiveDate),location||' / '||site,buddy,notes,imperialUnits,maxDepth,DiveLengthTime,startSurfacePressure,computerSerial,computerModel,d.diveId,l.sampleRateMs / 1000 FROM dive_details AS d JOIN dive_logs AS l ON d.diveId=l.diveId"; diff --git a/core/import-suunto.c b/core/import-suunto.c index d34c01442..27d5680be 100644 --- a/core/import-suunto.c +++ b/core/import-suunto.c @@ -290,7 +290,8 @@ static int dm4_dive(void *param, int columns, char **data, char **column) } int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, - struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites) + struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, + struct device_table *devices) { UNUSED(buffer); UNUSED(size); @@ -303,6 +304,7 @@ int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buffer, int s state.target_table = table; state.trips = trips; state.sites = sites; + state.devices = devices; state.sql_handle = handle; /* StartTime is converted from Suunto's nano seconds to standard @@ -560,7 +562,8 @@ static int dm5_dive(void *param, int columns, char **data, char **column) } int parse_dm5_buffer(sqlite3 *handle, const char *url, const char *buffer, int size, - struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites) + struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, + struct device_table *devices) { UNUSED(buffer); UNUSED(size); @@ -573,6 +576,7 @@ int parse_dm5_buffer(sqlite3 *handle, const char *url, const char *buffer, int s state.target_table = table; state.trips = trips; state.sites = sites; + state.devices = devices; state.sql_handle = handle; /* StartTime is converted from Suunto's nano seconds to standard diff --git a/core/parse-xml.c b/core/parse-xml.c index d5bbf7ae0..b5b66c181 100644 --- a/core/parse-xml.c +++ b/core/parse-xml.c @@ -1722,7 +1722,8 @@ static const char *preprocess_divelog_de(const char *buffer) int parse_xml_buffer(const char *url, const char *buffer, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, - struct filter_preset_table *filter_presets, const struct xml_params *params) + struct device_table *devices, struct filter_preset_table *filter_presets, + const const struct xml_params *params) { UNUSED(size); xmlDoc *doc; @@ -1734,6 +1735,7 @@ int parse_xml_buffer(const char *url, const char *buffer, int size, state.target_table = table; state.trips = trips; state.sites = sites; + state.devices = devices; state.filter_presets = filter_presets; doc = xmlReadMemory(res, strlen(res), url, NULL, 0); if (!doc) @@ -1776,7 +1778,8 @@ static timestamp_t parse_dlf_timestamp(unsigned char *buffer) return offset + 946684800; } -int parse_dlf_buffer(unsigned char *buffer, size_t size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites) +int parse_dlf_buffer(unsigned char *buffer, size_t size, struct dive_table *table, struct trip_table *trips, + struct dive_site_table *sites, struct device_table *devices) { unsigned char *ptr = buffer; unsigned char event; @@ -1800,6 +1803,7 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size, struct dive_table *tabl state.target_table = table; state.trips = trips; state.sites = sites; + state.devices = devices; // Check for the correct file magic if (ptr[0] != 'D' || ptr[1] != 'i' || ptr[2] != 'v' || ptr[3] != 'E') diff --git a/core/parse.h b/core/parse.h index 3b4efe1d8..7c4529739 100644 --- a/core/parse.h +++ b/core/parse.h @@ -78,6 +78,7 @@ struct parser_state { struct dive_table *target_table; /* non-owning */ struct trip_table *trips; /* non-owning */ struct dive_site_table *sites; /* non-owning */ + struct device_table *devices; /* non-owning */ struct filter_preset_table *filter_presets; /* non-owning */ sqlite3 *sql_handle; /* for SQL based parsers */ @@ -142,16 +143,24 @@ int atoi_n(char *ptr, unsigned int len); void parse_xml_init(void); int parse_xml_buffer(const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites, - struct filter_preset_table *filter_presets, const struct xml_params *params); + struct device_table *devices, struct filter_preset_table *filter_presets, const struct xml_params *params); void parse_xml_exit(void); -int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); -int parse_dm5_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); -int parse_seac_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); -int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); -int parse_shearwater_cloud_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); -int parse_cobalt_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); -int parse_divinglog_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); -int parse_dlf_buffer(unsigned char *buffer, size_t size, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites); +int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, + struct dive_site_table *sites, struct device_table *devices); +int parse_dm5_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, + struct dive_site_table *sites, struct device_table *devices); +int parse_seac_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, + struct dive_site_table *sites, struct device_table *devices); +int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, + struct dive_site_table *sites, struct device_table *devices); +int parse_shearwater_cloud_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, + struct dive_site_table *sites, struct device_table *devices); +int parse_cobalt_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, + struct dive_site_table *sites, struct device_table *devices); +int parse_divinglog_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct dive_table *table, struct trip_table *trips, + struct dive_site_table *sites, struct device_table *devices); +int parse_dlf_buffer(unsigned char *buffer, size_t size, struct dive_table *table, struct trip_table *trips, + struct dive_site_table *sites, struct device_table *devices); #ifdef __cplusplus } #endif |