aboutsummaryrefslogtreecommitdiffstats
path: root/core/datatrak.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-02-28 22:45:17 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commit37146c5742503becf75468fb07aab56011cb9101 (patch)
tree666e4d609b3d9b882082fcc258d6d153c6c68fa5 /core/datatrak.c
parent926b6895bbce7cc539ca4d0c3a425876dfa33d6b (diff)
downloadsubsurface-37146c5742503becf75468fb07aab56011cb9101.tar.gz
Parser: parse into custom dive site table
To extend the undo system to dive sites, the importers and downloaders must not parse directly into the global dive site table. Instead, pass a dive_site_table argument to parse into. For now, always pass the global dive_site_table so that this commit should not cause any functional change. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/datatrak.c')
-rw-r--r--core/datatrak.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/datatrak.c b/core/datatrak.c
index 4c2a910bc..312268d44 100644
--- a/core/datatrak.c
+++ b/core/datatrak.c
@@ -138,7 +138,7 @@ 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, long maxbuf)
+static unsigned char *dt_dive_parser(unsigned char *runner, struct dive *dt_dive, struct dive_site_table *sites, long maxbuf)
{
int rc, profile_length, libdc_model;
char *tmp_notes_str = NULL;
@@ -193,10 +193,10 @@ static unsigned char *dt_dive_parser(unsigned char *runner, struct dive *dt_dive
* Locality and Dive points.
*/
snprintf(buffer, sizeof(buffer), "%s, %s", locality, dive_point);
- ds = get_dive_site_by_name(buffer, &dive_site_table);
+ ds = get_dive_site_by_name(buffer, sites);
dt_dive->dive_site = ds;
if (!dt_dive->dive_site)
- dt_dive->dive_site = create_dive_site(buffer, dt_dive->when, &dive_site_table);
+ dt_dive->dive_site = create_dive_site(buffer, dt_dive->when, sites);
free(locality);
locality = NULL;
free(dive_point);
@@ -560,7 +560,7 @@ bail:
* 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 dive_table *table, struct trip_table *trips)
+int datatrak_import(struct memblock *mem, struct dive_table *table, struct trip_table *trips, struct dive_site_table *sites)
{
UNUSED(trips);
unsigned char *runner;
@@ -582,7 +582,7 @@ int datatrak_import(struct memblock *mem, struct dive_table *table, struct trip_
while ((i < numdives) && ((long) runner < maxbuf)) {
struct dive *ptdive = alloc_dive();
- runner = dt_dive_parser(runner, ptdive, maxbuf);
+ runner = dt_dive_parser(runner, ptdive, sites, maxbuf);
if (runner == NULL) {
report_error(translate("gettextFromC", "Error: no dive"));
free(ptdive);