From df4e26c8757a81bb40ba2fd60431d5d1ecd64b11 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 17 Aug 2014 12:26:21 -0600 Subject: 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 Signed-off-by: Dirk Hohndel --- save-git.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'save-git.c') diff --git a/save-git.c b/save-git.c index a1ef022fb..308a02c83 100644 --- a/save-git.c +++ b/save-git.c @@ -119,6 +119,18 @@ static void save_tags(struct membuffer *b, struct tag_entry *tags) put_string(b, "\n"); } +static void put_gasmix(struct membuffer *b, struct gasmix *mix) +{ + int o2 = mix->o2.permille; + int he = mix->he.permille; + + if (o2) { + put_format(b, " o2=%u.%u%%", FRACTION(o2, 10)); + if (he) + put_format(b, " he=%u.%u%%", FRACTION(he, 10)); + } +} + static void save_cylinder_info(struct membuffer *b, struct dive *dive) { int i, nr; @@ -128,8 +140,6 @@ static void save_cylinder_info(struct membuffer *b, struct dive *dive) cylinder_t *cylinder = dive->cylinder + i; int volume = cylinder->type.size.mliter; const char *description = cylinder->type.description; - int o2 = cylinder->gasmix.o2.permille; - int he = cylinder->gasmix.he.permille; put_string(b, "cylinder"); if (volume) @@ -137,11 +147,7 @@ static void save_cylinder_info(struct membuffer *b, struct dive *dive) put_pressure(b, cylinder->type.workingpressure, " workpressure=", "bar"); show_utf8(b, " description=", description, ""); strip_mb(b); - if (o2) { - put_format(b, " o2=%u.%u%%", FRACTION(o2, 10)); - if (he) - put_format(b, " he=%u.%u%%", FRACTION(he, 10)); - } + put_gasmix(b, &cylinder->gasmix); put_pressure(b, cylinder->start, " start=", "bar"); put_pressure(b, cylinder->end, " end=", "bar"); put_string(b, "\n"); @@ -292,6 +298,13 @@ static void save_one_event(struct membuffer *b, struct event *ev) show_index(b, ev->flags, "flags=", ""); show_index(b, ev->value, "value=", ""); show_utf8(b, " name=", ev->name, ""); + if (event_is_gaschange(ev)) { + if (ev->gas.index >= 0) { + show_index(b, ev->gas.index, "cylinder=", ""); + put_gasmix(b, &ev->gas.mix); + } else if (!event_gasmix_redundant(ev)) + put_gasmix(b, &ev->gas.mix); + } put_string(b, "\n"); } -- cgit v1.2.3-70-g09d2