summaryrefslogtreecommitdiffstats
path: root/load-git.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2014-08-17 12:26:21 -0600
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-10-12 07:45:37 -0400
commitdf4e26c8757a81bb40ba2fd60431d5d1ecd64b11 (patch)
treea7f46fb0a25a5131a42727ab0ca770f2fc0c8f30 /load-git.c
parentb47e0658cf5e60e18d4c9405e3b28f196ac3e2d8 (diff)
downloadsubsurface-df4e26c8757a81bb40ba2fd60431d5d1ecd64b11.tar.gz
Start sanitizing gaschange event information
Decode the gasmix data into a sane format when creating the event, and add the (currently unused) ability to specify a gas change to a particular cylinder rather than (or in addition to) the gasmix. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'load-git.c')
-rw-r--r--load-git.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/load-git.c b/load-git.c
index e61a0ca13..16aa1958f 100644
--- a/load-git.c
+++ b/load-git.c
@@ -529,6 +529,13 @@ static void parse_event_keyvalue(void *_event, const char *key, const char *valu
event->value = val;
} else if (!strcmp(key, "name")) {
/* We get the name from the string handling */
+ } else if (!strcmp(key, "cylinder")) {
+ /* NOTE! We add one here as a marker that "yes, we got a cylinder index" */
+ event->gas.index = 1+get_index(value);
+ } else if (!strcmp(key, "o2")) {
+ event->gas.mix.o2 = get_fraction(value);
+ } else if (!strcmp(key, "he")) {
+ event->gas.mix.he = get_fraction(value);
} else
report_error("Unexpected event key/value pair (%s/%s)", key, value);
}
@@ -538,7 +545,7 @@ static void parse_dc_event(char *line, struct membuffer *str, void *_dc)
int m, s = 0;
const char *name;
struct divecomputer *dc = _dc;
- struct event event = { 0 };
+ struct event event = { 0 }, *ev;
m = strtol(line, &line, 10);
if (*line == ':')
@@ -557,7 +564,17 @@ static void parse_dc_event(char *line, struct membuffer *str, void *_dc)
name = "";
if (str->len)
name = mb_cstring(str);
- add_event(dc, event.time.seconds, event.type, event.flags, event.value, name);
+ ev = add_event(dc, event.time.seconds, event.type, event.flags, event.value, name);
+ if (ev && event_is_gaschange(ev)) {
+ /*
+ * We subtract one here because "0" is "no index",
+ * and the parsing will add one for actual cylinder
+ * index data (see parse_event_keyvalue)
+ */
+ ev->gas.index = event.gas.index-1;
+ if (event.gas.mix.o2.permille || event.gas.mix.he.permille)
+ ev->gas.mix = event.gas.mix;
+ }
}
static void parse_trip_date(char *line, struct membuffer *str, void *_trip)