Parser: parse text-based files into arbitrary table

In d815e0c947 a dive_table pointer
was added to the parsing functions to allow parsing into tables
other than the global dive table. This will be necessary for undo of
import and implementation a cleaner interface. A few cases, notably
CSV and proprietary formats were forgotten.

Implement parsing into arbitrary tables also for these cases.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-09-28 13:59:01 +02:00 committed by Dirk Hohndel
parent a5db03c2b3
commit 32a4ce6169
10 changed files with 52 additions and 51 deletions

View file

@ -132,7 +132,7 @@ static int handle_event_ver3(int code, const unsigned char *ps, unsigned int ps_
return skip;
}
static void parse_dives (int log_version, const unsigned char *buf, unsigned int buf_size)
static void parse_dives (int log_version, const unsigned char *buf, unsigned int buf_size, struct dive_table *table)
{
unsigned int ptr = 0;
unsigned char model;
@ -428,7 +428,7 @@ static void parse_dives (int log_version, const unsigned char *buf, unsigned int
// End dive
dive->downloaded = true;
record_dive(dive);
record_dive_to_table(dive, table);
dive = NULL;
mark_divelist_changed(true);
@ -442,7 +442,7 @@ static void parse_dives (int log_version, const unsigned char *buf, unsigned int
free(dive);
}
int try_to_open_liquivision(const char *filename, struct memblock *mem)
int try_to_open_liquivision(const char *filename, struct memblock *mem, struct dive_table *table)
{
UNUSED(filename);
const unsigned char *buf = mem->buffer;
@ -466,7 +466,7 @@ int try_to_open_liquivision(const char *filename, struct memblock *mem)
}
ptr += 4;
parse_dives(log_version, buf + ptr, buf_size - ptr);
parse_dives(log_version, buf + ptr, buf_size - ptr, table);
return 1;
}