summaryrefslogtreecommitdiffstats
path: root/core/datatrak.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-10-18 23:42:17 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-10-24 09:51:37 -0700
commit8c65558b5c432c1d0e9c6af5939faa56ffecf51a (patch)
treeb7ded4867685f70849d687d465c1653d3955b499 /core/datatrak.c
parent255f561afffb26bae5c4de0c5fe2d60effb41103 (diff)
downloadsubsurface-8c65558b5c432c1d0e9c6af5939faa56ffecf51a.tar.gz
devices: create device nodes in parsers
So far, we added a non-global device table to the parser states. Now, create device nodes in that table instead of in the global table. Thus, on undo of dive-import, the new device nodes will be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/datatrak.c')
-rw-r--r--core/datatrak.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/core/datatrak.c b/core/datatrak.c
index 720b631b3..b10ef55ad 100644
--- a/core/datatrak.c
+++ b/core/datatrak.c
@@ -159,7 +159,8 @@ static dc_status_t dt_libdc_buffer(unsigned char *ptr, int prf_length, int dc_mo
* Parses a mem buffer extracting its data and filling a subsurface's dive structure.
* Returns a pointer to last position in buffer, or NULL on failure.
*/
-static unsigned char *dt_dive_parser(unsigned char *runner, struct dive *dt_dive, struct dive_site_table *sites, long maxbuf)
+static unsigned char *dt_dive_parser(unsigned char *runner, struct dive *dt_dive, struct dive_site_table *sites,
+ struct device_table *devices, long maxbuf)
{
int rc, profile_length, libdc_model;
char *tmp_notes_str = NULL;
@@ -565,7 +566,7 @@ static unsigned char *dt_dive_parser(unsigned char *runner, struct dive *dt_dive
dt_dive->dc.deviceid = 0;
else
dt_dive->dc.deviceid = 0xffffffff;
- create_device_node(&device_table, dt_dive->dc.model, dt_dive->dc.deviceid, "", "", dt_dive->dc.model);
+ create_device_node(devices, dt_dive->dc.model, dt_dive->dc.deviceid, "", "", dt_dive->dc.model);
dt_dive->dc.next = NULL;
if (!is_SCR && dt_dive->cylinders.nr > 0) {
get_cylinder(dt_dive, 0)->end.mbar = get_cylinder(dt_dive, 0)->start.mbar -
@@ -578,6 +579,7 @@ bail:
free(devdata);
return NULL;
}
+
/*
* Parses the header of the .add file, returns the number of dives in
* the archive (must be the same than number of dives in .log file).
@@ -675,7 +677,8 @@ static void wlog_compl_parser(struct memblock *wl_mem, struct dive *dt_dive, int
* Main function call from file.c memblock is allocated (and freed) there.
* If parsing is aborted due to errors, stores correctly parsed dives.
*/
-int datatrak_import(struct memblock *mem, struct memblock *wl_mem, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites)
+int datatrak_import(struct memblock *mem, struct memblock *wl_mem, struct dive_table *table, struct trip_table *trips,
+ struct dive_site_table *sites, struct device_table *devices)
{
UNUSED(trips);
unsigned char *runner;
@@ -707,7 +710,7 @@ int datatrak_import(struct memblock *mem, struct memblock *wl_mem, struct dive_t
while ((i < numdives) && ((long) runner < maxbuf)) {
struct dive *ptdive = alloc_dive();
- runner = dt_dive_parser(runner, ptdive, sites, maxbuf);
+ runner = dt_dive_parser(runner, ptdive, sites, devices, maxbuf);
if (wl_mem)
wlog_compl_parser(wl_mem, ptdive, i);
if (runner == NULL) {