diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2014-12-27 22:10:44 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-12-28 06:41:21 -0800 |
commit | ce1f69f025a6bd1a99deccfe906534fe2141d3c1 (patch) | |
tree | 76426bd6077bb7222a5cfd2267b1416bec5c6686 /parse-xml.c | |
parent | 2461a731fc4c485c3d54f4cd5def37aaaf6cb829 (diff) | |
download | subsurface-ce1f69f025a6bd1a99deccfe906534fe2141d3c1.tar.gz |
Initial support for Divesoft Freedom
This parses the dive profile from Divesoft Freedom log file. Only the
depth profile is currently supported. There is also something wrong as
the log file cannot be given as parameter but must be opened or imported
once Subsurface is running. Note that so far no metadata is parsed.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/parse-xml.c b/parse-xml.c index ac7820971..218268dc3 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -2531,6 +2531,34 @@ int parse_cobalt_buffer(sqlite3 *handle, const char *url, const char *buffer, in return 0; } +int parse_dlf_buffer(char *buffer, size_t size) +{ + char *ptr = (char *)buffer; + bool event; + + /* Skipping the dive header for now */ + ptr += 32; + + dive_start(); + + while (ptr < buffer + size) { + event = ptr[0] & 0x0f; + if (event == 1) { + /* dive event */ + } else { + sample_start(); + cur_sample->time.seconds = ((ptr[0] >> 4) & 0x0f) + + ((ptr[1] << 4) & 0xff0) + + (ptr[2] & 0x0f) * 3600; /* hours */ + cur_sample->depth.mm = ((ptr[4] & 0xff) + ((ptr[5] << 8) & 0xff00)) * 10; + sample_end(); + } + ptr += 16; + } + dive_end(); +} + + void parse_xml_init(void) { LIBXML_TEST_VERSION |