+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='", "'", 1);
+ 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_trip(FILE *f, struct dive *trip)
+{
+ struct tm *tm = gmtime(&trip->when);
+
+ fprintf(f, "<trip");
+ fprintf(f, " date='%04u-%02u-%02u'",
+ tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday);
+ if (trip->location)
+ show_utf8(f, trip->location, " location=\'","\'", 1);
+ fprintf(f, " />\n");
+}
+