aboutsummaryrefslogtreecommitdiffstats
path: root/save-xml.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 /save-xml.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 'save-xml.c')
-rw-r--r--save-xml.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/save-xml.c b/save-xml.c
index fe804cb6d..e9f769d3f 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -148,6 +148,18 @@ static void save_overview(struct membuffer *b, struct dive *dive)
show_utf8(b, dive->suit, " <suit>", "</suit>\n", 0);
}
+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;
@@ -158,19 +170,13 @@ 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_format(b, " <cylinder");
if (volume)
put_milli(b, " size='", volume, " l'");
put_pressure(b, cylinder->type.workingpressure, " workpressure='", " bar'");
show_utf8(b, description, " description='", "'", 1);
- 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_format(b, " />\n");
@@ -261,6 +267,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, ev->name, " name='", "'", 1);
+ 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_format(b, " />\n");
}