summaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-22 18:02:54 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-22 18:02:54 -0700
commit3a77eb85101a5fb1dc186b88a3a02d2ae27690c7 (patch)
treebf40abf756c788347830b1990423f9c5ce9968b8 /save-xml.c
parent50c2bb7c71b279237f05c1c0a530d494bad534c8 (diff)
downloadsubsurface-3a77eb85101a5fb1dc186b88a3a02d2ae27690c7.tar.gz
Start handling dive events
Parse them, save them, take them from libdivecomputer. This doesn't merge them or show them in the profile yet, though. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'save-xml.c')
-rw-r--r--save-xml.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/save-xml.c b/save-xml.c
index e64b380a4..d6774b5c7 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -218,6 +218,12 @@ static void save_cylinder_info(FILE *f, struct dive *dive)
}
}
+static void show_index(FILE *f, int value, const char *pre, const char *post)
+{
+ if (value)
+ fprintf(f, " %s%d%s", pre, value, post);
+}
+
static void save_sample(FILE *f, struct sample *sample)
{
fprintf(f, " <sample time='%u:%02u min'", FRACTION(sample->time.seconds,60));
@@ -229,6 +235,25 @@ static void save_sample(FILE *f, struct sample *sample)
fprintf(f, " />\n");
}
+static void save_one_event(FILE *f, struct event *ev)
+{
+ fprintf(f, " <event time='%d:%02d min'", FRACTION(ev->time.seconds,60));
+ show_index(f, ev->type, "type='", "'");
+ show_index(f, ev->flags, "flags='", "'");
+ show_index(f, ev->value, "value='", "'");
+ show_utf8(f, ev->name, " name='", "'");
+ fprintf(f, " />\n");
+}
+
+
+static void save_events(FILE *f, struct event *ev)
+{
+ while (ev) {
+ save_one_event(f, ev);
+ ev = ev->next;
+ }
+}
+
static void save_dive(FILE *f, struct dive *dive)
{
int i;
@@ -245,6 +270,7 @@ static void save_dive(FILE *f, struct dive *dive)
FRACTION(dive->duration.seconds, 60));
save_overview(f, dive);
save_cylinder_info(f, dive);
+ save_events(f, dive->events);
for (i = 0; i < dive->samples; i++)
save_sample(f, dive->sample+i);
fprintf(f, "</dive>\n");