aboutsummaryrefslogtreecommitdiffstats
path: root/core/import-shearwater.c
AgeCommit message (Collapse)Author
2019-11-09Cylinders: access cylinders with get_cylinder()Gravatar Berthold Stoeger
Instead of accessing the cylinder table directly, use the get_cylinder() function. This gives less unwieldy expressions. But more importantly, the function does bound checking. This is crucial for now as the code hasn't be properly audited since the change to arbitrarily sized cylinder tables. Accesses of invalid cylinder indexes may lead to silent data-corruption that is sometimes not even noticed by valgrind. Returning NULL instead of an invalid pointer will make debugging much easier. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Cleanup: return cylinder from cylinder_start() in parserGravatar Berthold Stoeger
Most callers of this function accessed the newly generated cylinder immediately after calling this function. Thus, for convenience, return the added cylinder. This avoids a number of verbose expressions. On the flip side, cylinder_start() now has to be cast to function returning void in a the "nesting" function table. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Core: remove MAX_CYLINDERS restrictionGravatar Berthold Stoeger
Instead of using fixed size arrays, use a new cylinder_table structure. The code copies the weightsystem code, but is significantly more complex because cylinders are such an integral part of the core. Two functions to access the cylinders were added: get_cylinder() and get_or_create_cylinder() The former does a simple array access and supposes that the cylinder exists. The latter is used by the parser(s) and if a cylinder with the given id does not exist, cylinders up to that id are generated. One point will make C programmers cringe: the cylinder structure is passed by value. This is due to the way the table-macros work. A refactoring of the table macros is planned. It has to be noted that the size of a cylinder_t is 64 bytes, i.e. 8 long words on a 64-bit architecture, so passing on the stack is probably not even significantly slower than passing as reference. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-10-26Cleanup: pass NULL pointer for error string pointerGravatar Dirk Hohndel
Since we never did anything with the error string, why even ask for it. And this way we don't have to deal with the memory returned, either. Found by Coverity. Fixes CIDs 350124, 350113, 350106, 350099, 350091 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-04-12Parser: parse into custom dive site tableGravatar Berthold Stoeger
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>
2019-01-09Parser: add trip_table parameter to parsing functionsGravatar Berthold Stoeger
To allow parsing into arbitrary trip_tables, add the corresponding parameter to the parsing functions and the parser state. Currently, all callers pass the global trip_table so there should be no change in functionality. These arguments will be replaced in subsequent commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-03Use state structure for sample rate infoGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2019-01-01Use correct value for PO2Gravatar Miika Turkia
averagePPO2 appears to be correct value instead of currentPPO2SetPoint. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-31Grab correct setpoint on Shearwater cloud importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-30Use different time field as it seems to be more correctGravatar Miika Turkia
The starTimestamp is 4 hours apart on 2 different DCs within the sample log. DiveDate on the dive_logs table seems to be correct, but must be converted from human readable format. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-29Sample rate varies between divesGravatar Miika Turkia
Seems that Shearwater cloud stores sample rate into the database and it is not constant within the log. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-29Initial support for Shearwater CloudGravatar Miika Turkia
This works to some extent to part of a sample log I received. However, still quite a bit more work is needed. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-29Shearwater import: dive id might be large than intGravatar Miika Turkia
I encountered this while implementing Shearwater Cloud import, but it makes sense to increase the size for dive id for Shearwater Desktop as well. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-10-23Parser: make parser (mostly) reentrantGravatar Berthold Stoeger
Introduce a parser_state structure, which describes (most) of the global parser state. Create such a structure in the entry routines to the parser and pass it down to the individual functions. The parser state is initialized and freed with the init_parser_state() and free_parser_state() functions. The main benefits are: 1) Isolation of parser state. 2) Keeping the global name space tidy. 3) Prevent memory leaks which could happen in truncated files by freeing all the parser state after parse. A somewhat controversial point might be that the individual parsing functions are split in those that need parser-state and those that don't. This means that there are now two versions of the MATCH macro, viz. one for the former and one for the latter. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-27Remove unnecessary {}Gravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-05-27Shearwater import: avoid running atoi multiple timesGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-05-27Shearwater import: support for DC reported ceilingGravatar Miika Turkia
This adds support for DC reported ceiling when importing the Shearwater Desktop database. Both AI and non-AI versions are tested, but not all possible paths. For non-AI the DC reported ceiling was from firstStopDepth and for the AI version it was from the decoCeiling field. I do not currently know when each of these fields are used, but at least this works on my test data. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-05-24core: replace (void) with UNUSED(x) and include ssrf.hGravatar jan Iversen
Unused parameters in C are "silenced" by adding UNUSED(x) Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-14Core: introduce new subsurface-string headerGravatar Dirk Hohndel
First small step to shrinking dive.h. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-29Move Shearwater DB import into its own fileGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>