X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=save-xml.c;h=d6774b5c7f880bb425f9e43209038b13568756f7;hb=3a77eb85101a5fb1dc186b88a3a02d2ae27690c7;hp=e64b380a48076ccbee46a0f7075b14c93675133f;hpb=50c2bb7c71b279237f05c1c0a530d494bad534c8;p=ext%2Fsubsurface.git diff --git a/save-xml.c b/save-xml.c index e64b380..d6774b5 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, " 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, " 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, "\n");