X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=save-xml.c;h=4183b1c51ade4cb9fb36c0f2727d56a3b601fbbb;hb=c52b95d502fb79e52d5927b7c59addef984d23e2;hp=e64b380a48076ccbee46a0f7075b14c93675133f;hpb=5804c2970eaaf0215b9862f767cf7aa745083744;p=ext%2Fsubsurface.git diff --git a/save-xml.c b/save-xml.c index e64b380..4183b1c 100644 --- a/save-xml.c +++ b/save-xml.c @@ -162,7 +162,7 @@ static void show_location(FILE *f, struct dive *dive) */ if (latitude || longitude) { int len = snprintf(buffer, sizeof(buffer)-4, - " ", + " ", latitude, longitude); if (!dive->location) { memcpy(&buffer[len-1], "/>\n", 4); @@ -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");