mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: introduce divelog structure
The parser API was very annoying, as a number of tables to-be-filled were passed in as pointers. The goal of this commit is to collect all these tables in a single struct. This should make it (more or less) clear what is actually written into the divelog files. Moreover, it should now be rather easy to search for instances, where the global logfile is accessed (and it turns out that there are many!). The divelog struct does not contain the tables as substructs, but only collects pointers. The idea is that the "divelog.h" file can be included without all the other files describing the numerous tables. To make it easier to use from C++ parts of the code, the struct implements a constructor and a destructor. Sadly, we can't use smart pointers, since the pointers are accessed from C code. Therfore the constructor and destructor are quite complex. The whole commit is large, but was mostly an automatic conversion. One oddity of note: the divelog structure also contains the "autogroup" flag, since that is saved in the divelog. This actually fixes a bug: Before, when importing dives from a different log, the autogroup flag was overwritten. This was probably not intended and does not happen anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
eebb47ec22
commit
9c253ee6c5
81 changed files with 661 additions and 698 deletions
|
@ -9,6 +9,7 @@
|
|||
#include "gettext.h"
|
||||
#include "dive.h"
|
||||
#include "divelist.h"
|
||||
#include "divelog.h"
|
||||
#include "extradata.h"
|
||||
#include "file.h"
|
||||
#include "libdivecomputer.h"
|
||||
|
@ -39,10 +40,8 @@ static int ostc_prepare_data(int data_model, dc_family_t dc_fam, device_data_t *
|
|||
* each file. So it's not necessary to iterate once and again on a parsing
|
||||
* function. Actually there's only one kind of archive for every DC model.
|
||||
*/
|
||||
void ostctools_import(const char *file, struct dive_table *divetable, struct trip_table *trips, struct dive_site_table *sites)
|
||||
void ostctools_import(const char *file, struct divelog *log)
|
||||
{
|
||||
UNUSED(trips);
|
||||
UNUSED(sites);
|
||||
FILE *archive;
|
||||
device_data_t *devdata = calloc(1, sizeof(device_data_t));
|
||||
dc_family_t dc_fam;
|
||||
|
@ -184,8 +183,8 @@ void ostctools_import(const char *file, struct dive_table *divetable, struct tri
|
|||
} else {
|
||||
add_extra_data(&ostcdive->dc, "Serial", ostcdive->dc.serial);
|
||||
}
|
||||
record_dive_to_table(ostcdive, divetable);
|
||||
sort_dive_table(divetable);
|
||||
record_dive_to_table(ostcdive, log->dives);
|
||||
sort_dive_table(log->dives);
|
||||
|
||||
close_out:
|
||||
fclose(archive);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue