aboutsummaryrefslogtreecommitdiffstats
path: root/core/parse-xml.c
AgeCommit message (Collapse)Author
2018-07-04Dive pictures: remove hashesGravatar Berthold Stoeger
In the last commits, the canonical-to-local filename map was made independent from the image hashes and the location of moved images was based on filename not hashes. The hashes are now in principle unused (except for conversion of old-style local filename lookups). Therefore, remove the hashes in this commit. This makes addition of images distinctly faster. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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-14Rename enum dive_comp_type to divemode_tGravatar Robert C. Helling
...as the usuage is not anymore about a computer but a momentary dive mode. Rename the end indicator as well. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14Read and write divemode changes (xml and git)Gravatar Willem Ferguson
This provides for reading of divemode change events from dive logs and for writing them to dive logs. This applies to xml and git divelogs. Divemode change events have the following structure: event->name = "modechange" event->value = integer corresponding to enum dive_comp_type (dive.c), reflecting the type of divemode change (OC, CCR, PSCR, etc). In the dive log file, the event value is written as a string that corresponds to each of the enum values, e.g. <event name='modechange' divemode='OC' /> This xml is also read from the dive log file and translated to an appropriate value of event->value. The file diveeventitem.cpp was udated to reflect this new way of dealing with divemode change events. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
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>
2018-03-05Cleanup: Remove hash field from picture-structureGravatar Berthold Stoeger
The hash field in the picture-structure was in principle non-operational. It was set on loading, but never actually changed. The authoritative hash comes from the filename->hash map. Therefore, make this explicit by removing the hash field from the picture structure. Instead of filling the picture structure on loading, add the hash directly to the filename->hash map. This is done in the register_hash() function, which does not overwrite old entries. I.e. the local hash has priority over the save-file. This policy might be refined in the future. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-02Warning Fix: add missing include to core/parse-xml.cGravatar Berthold Stoeger
Fallout from commit #cd5e17cf79c2f1eb896efd0436c103221de446ae Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-26Cleanup: Unify qthelper.h and qthelperfromc.hGravatar Berthold Stoeger
Since all qt-helpers are defined in qthelper.cpp, there seems to be no reason to have two include files. By unifying the two files, duplication and inconsistencies are removed. The C++-only part is simply compiled away with #ifdefs. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-19Improve profile display in plannerGravatar Willem Ferguson
This patch allows the planner to save the last manually-entered dive planner point of a dive plan. When the plan has been saved and re-opened for edit, the time of the last-entered dive planner point is used to ensure that dive planning continues from the same point in the profile as was when the original dive plan was saved. Mechanism: 1) In dive.h, create a new dc attribute dc->last_manual_time with data type of duration_t. 2) In diveplanner.c, ensure that the last manually-entered dive planner point is saved in dc->last_manual_time. 3) In save-xml.c, create a new XML attribute for the <divecomputer> element, named last-manual-time. For dive plans, the element would now look like: <divecomputer model='planned dive' last-manual-time='31:17 min'> 4) In parse-xml.c, insert code that recognises the last-manual-time XML attribute, reads the time value and assigns this time to dc->last_manual_time. 5) In diveplannermodel.cpp, method DiveplannerPointModel::loadfromdive, insert code that sets the appropriate boolean value to dp->entered by comparing newtime (i.e. time of dp) with dc->last_manual_time. 6) Diveplannermodel.cpp also accepts profile data from normal dives in the dive log, whether hand-entered or loaded from dive computer. It looks like the reduction of dive points for dives with >100 points continues to work ok. The result is that when a dive plan is saved with manually entered points up to e.g. 10 minutes into the dive, it can be re-opened for edit in the dive planner and the planner re-creates the plan with manually entered points up to 10 minutes. The rest of the points are "soft" points, shaped by the deco calculations of the planner. Improvements: Improve code for profile display in dive planner This responds to #1052. Change load-git.c and save-git.c so that the last-manual-time is also saved in the git-format dive log. Several stylistic changes in text for consistent C source code. Improvement of dive planner profile display: Do some simplification of my alterations to diveplannermodel.cpp Two small style changes in planner.c and diveplannermodel.cpp as requested ny @neolit123 Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-08Make a few functions of static linkageGravatar Berthold Stoeger
Make functions in core/file.c, core/parse.c and core/import-csv.c that were not used outside their translation unit of static linkage. parse_date is moved from core/file.c to core/import-csv.c, since it is used only there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-08Remove unused function parse_mkvi_buffer()Gravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-04parse-xml.c: add get_bool() functionGravatar Berthold Stoeger
The boolean "autogroup" was parsed as an integer. In principle OK, but let's make the type more explicit by introducing a get_bool() function. Suggested-by: "Lubomir I. Ivanov" <neolit123@gmail.com> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-26Cleanup: avoid memory leakGravatar Dirk Hohndel
Coverity CID 208314 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-27Move Cobalt and Divinglog DB parsing to parse-db.cGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27Move atoi_n to parse.cGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27Move Shearwater DB parsing into parse-db.cGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27Move metric variable to parse.cGravatar Miika Turkia
This is required when moving Shearwater DB parsing into parse-db.c Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27Move add_dive_site to parse.cGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27Move Suunto DB imports into parse-db.cGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27Refactore parse-xml.c into parse.c and parse-xml.cGravatar Miika Turkia
This should help us to move parsing that is not XML related to other files, hopefully making the code cleaner. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-11-27Store and load the planner related depth info of a cylinder in logfileGravatar Stefan Fuchs
Store cylinder.depth in XML files and in git storage. This info is in fact the gas switch depth of a specific gas/cylinder in the planner. This change avoids the need of typing in a user specific depth value again when replanning an existing planned dive. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-10Fix warningGravatar Jan Mulder
Commit 97712559192ca82d introduces a compiler warning due to mismatched pointer types. Fixed here. Reported-by: Stefan Fuchs <sfuchs@gmx.de> Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-20Silence random warningsGravatar Dirk Hohndel
None of these seem to point to actual issues, so let's quiet them. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07Store RBT value on DivingLog importGravatar Miika Turkia
Fixed-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-10-07Fix divinglog import temperature truncationGravatar Linus Torvalds
The code incorrectly divided the temperature by 10 as an integer, causing unnecessary precision loss due to truncation. Fix it, and update the test results for the now improved temperature import. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07Fix divinglog import limit checkingGravatar Linus Torvalds
The divinglog import did horrible things with the strings returned from the sqlite queries, and ended up using uninitialized values at the end of the secondary profile data strings. This rewrites the import logic to track the length of the strings properly when importing the divinglog data. We should run 'valgrind' a whole lot more than we do, I suspect. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04Don't add separate country field, use taxonomyGravatar Dirk Hohndel
The more I looked at the code that added the country to the dive site, the more it seemed redundant given what we have with the taxonomy. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02[Divesite] Save / Load the country from xmlGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-15Use dive ID instead of dive number when importing from Shearwater dbGravatar Seppo Takalo
Dive IDs are unique but same dive number can appear multiple times within the same database. This can happen for example when user changes the "next log number" from his computer. Signed-off-by: Seppo Takalo <seppo.takalo@iki.fi>
2017-09-15Convert usage of atof() to strtod_flags()Gravatar Seppo Takalo
The provided strod_flags(str, 0, 0) should work as a drop in replacement for atof() but does not care about locales which may cause atof() to fail. strtod_flags() would allow checking of conversion result, but I did not change the existing logic. This was just regexp search&replace change to get rid of atof(). I use flags 0 to get more relaxed conversion. Fixes #574 Signed-off-by: Seppo Takalo <seppo.takalo@iki.fi>
2017-09-13Detect dive mode on Shearwater DB importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-09-13Don't assume CCR mode when importing from ShearwaterGravatar Seppo Takalo
Logic was assuming CCR mode if field "averagePPO2" was present. Signed-off-by: Seppo Takalo <seppo.takalo@iki.fi>
2017-09-13Fix cylinder changes when importing from Shearwater databaseGravatar Seppo Takalo
Re-do the logic to use add_gas_switch_event() instead of creating event manually. Fix the SQL query to find the proper dive id from dive log number. Signed-off-by: Seppo Takalo <seppo.takalo@iki.fi>
2017-09-13Fix Shearwater cylinder detection logicGravatar Seppo Takalo
Fix the SQL query to find proper dive id instead of assuming log number to be the same as id. Signed-off-by: Seppo Takalo <seppo.takalo@iki.fi>
2017-09-13Ignore missing pressure values when importing from ShearwaterGravatar Seppo Takalo
Shearwater seems to report missing AI sensors as a pressure reading 4092 (raw) which is 564 bar. Signed-off-by: Seppo Takalo <seppo.takalo@iki.fi>
2017-08-29adding comments as advisedGravatar Marc Arndt
2017-08-29fixing indentationGravatar Marc Arndt
2017-08-29Ignore Divesoft Button Press EventsGravatar Marc Arndt
Prevent button press events from showing on the profile graph when we import divesoft DLF files. Reported-by: Marc Arndt Signed-off-by: Marc Arndt <marc@marcarndt.com>
2017-08-24Shearwater PerdixGravatar Miika Turkia
Reportedly the case 2 corresponds to Perdix, so it might be that both Petrel and Perdix use same model number (or the model is mistaken before). Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-08-24Support for air pressure on Shearwater Desktop importGravatar Miika Turkia
Fixes #548 Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-08-24Grab correct dive number on Shearwater Desktop importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-08-10DLF: Parse more measurements, import GPSGravatar Anton Lundin
This add support for parsing more measurements, and now imports GPS data to. Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-08-10DLF: Parse Divesoft Liberty data betterGravatar Anton Lundin
There is something with ndl / tts / temp in the Liberty DLF files. If that bit is set, the values are bogus. There is something more to it here which I haven't figured out. Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-08-10DLF: Parse diluent changes as a gaschange eventGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-08-10DLF: Import setpoint changes.Gravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-08-10DLF: Restructure loop into a for loopGravatar Anton Lundin
We always step forward 16 bytes, so make it a for loop so a continue won't throw us into a eternal loop. Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-07-25Add support for loading and saving multiple pressure samplesGravatar Linus Torvalds
This does both the XML and the git save format, because the changes really are the same, even if the actual format differs in some details. See how the two "save_samples()" routines both do the same basic setup, for example. This is fairly straightforward, with the possible exception of the odd sensor = sample->sensor[0]; default in the git pressure loading code. That line just means that if we do *not* have an explicit cylinder index for the pressure reading, we will always end up filling in the new pressure as the first pressure (because the cylinder index will match the first sensor slot). So that makes the "add_sample_pressure()" case always do the same thing it used to do for the legacy case: fill in the first slot. The actual sensor index may later change, since the legacy format has a "sensor=X" key value pair that sets the sensor, but it will also use the first sensor slot, making it all do exactly what it used to do. And on the other hand, if we're loading new-style data with cylinder pressure and sensor index together, we just end up using the new semantics for add_sample_pressure(), which tries to keep the same slot for the same sensor, but does the right thing if we already have other pressure values. The XML code has no such issues at all, since it can't share the cases anyway, and we need to have different node names for the different sensor values and cannot just have multiple "pressure" entries. Have I mentioned how much I despise XML lately? Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-24CCR is now detected from the log dataGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-07-24Map Divinglog's visibility to our starsGravatar Miika Turkia
good (1) = 5 medium (2) = 3 bad (3) = 1 There seems also to be 0 used in the log, even though it is not mentioned in the valid selections. This is not giving any stars for this option... Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-07-24Detect CCR/PSCR from Divinglog importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>