summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2018-01-07 15:51:28 +0200
committerGravatar mturkia <miika.turkia@gmail.com>2018-01-08 06:06:12 +0200
commit6a2ea71a36c89100db74719dedbdd224aacd2cf1 (patch)
tree975e1151a942a3aaf1158c4586f25b39ae5c43f8 /core
parent5e9e6625d0a9723c0add2ce1a1b6a4386d6f9811 (diff)
downloadsubsurface-6a2ea71a36c89100db74719dedbdd224aacd2cf1.tar.gz
Parse water temperature from ZDT
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Diffstat (limited to 'core')
-rw-r--r--core/import-csv.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/core/import-csv.c b/core/import-csv.c
index d866fc254..439e67a8d 100644
--- a/core/import-csv.c
+++ b/core/import-csv.c
@@ -169,6 +169,23 @@ int parse_dan_format(const char *filename, char **params, int pnr)
/* We got a trailer, no samples on this dive */
if (strncmp(iter, "ZDT", 3) == 0) {
end_ptr = iter - (char *)mem.buffer;
+
+ /* Water temperature */
+ memset(tmpbuf, 0, sizeof(tmpbuf));
+ for (i = 0; i < 5 && iter; ++i)
+ iter = strchr(iter + 1, '|');
+
+ if (iter && iter + 1) {
+ iter = iter + 1;
+ iter_end = strchr(iter, '|');
+
+ if (iter_end) {
+ memcpy(tmpbuf, iter, iter_end - iter);
+ params[pnr_local++] = "waterTemp";
+ params[pnr_local++] = strdup(tmpbuf);
+ }
+ }
+ params[pnr_local] = NULL;
ret |= parse_xml_buffer(filename, "<csv></csv>", 11, &dive_table, (const char **)params);
continue;
}
@@ -204,6 +221,26 @@ int parse_dan_format(const char *filename, char **params, int pnr)
}
mem_csv.size = ptr - (char*)mem_csv.buffer;
+ iter = parse_dan_new_line(ptr + 1, NL);
+ if (iter && strncmp(iter, "ZDT", 3) == 0) {
+ /* Water temperature */
+ memset(tmpbuf, 0, sizeof(tmpbuf));
+ for (i = 0; i < 5 && iter; ++i)
+ iter = strchr(iter + 1, '|');
+
+ if (iter && iter + 1) {
+ iter = iter + 1;
+ iter_end = strchr(iter, '|');
+
+ if (iter_end) {
+ memcpy(tmpbuf, iter, iter_end - iter);
+ params[pnr_local++] = "waterTemp";
+ params[pnr_local++] = strdup(tmpbuf);
+ }
+ }
+ params[pnr_local] = NULL;
+ }
+
if (try_to_xslt_open_csv(filename, &mem_csv, "csv"))
return -1;