summaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2013-01-23 10:25:31 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-23 12:55:33 -0800
commitb6c9301e584722b9b46dffd4d759e8c60df520ad (patch)
tree2f963ec75672389692e532a8264dc83396900eb2 /save-xml.c
parent3e5a508b15fe28083dfdf5a049d33e8769616395 (diff)
downloadsubsurface-b6c9301e584722b9b46dffd4d759e8c60df520ad.tar.gz
Move more dive computer filled data to the divecomputer structure
This moves the fields 'duration', 'surfacetime', 'maxdepth', 'meandepth', 'airtemp', 'watertemp', 'salinity' and 'surface_pressure' to the per-divecomputer data structure. They are filled in by the dive computer, and normally not edited. NOTE! All actual *use* of this data was then changed from dive->field to dive->dc.field programmatically with a shell-script and sed, and the result then edited for details. So while the XML save and restore code has been updated, all the displaying etc will currently always just show the first dive computer entry. 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.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/save-xml.c b/save-xml.c
index 0fa0aee2a..690a92777 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -138,44 +138,44 @@ static void show_utf8(FILE *f, const char *text, const char *pre, const char *po
fputs(post, f);
}
-static void save_depths(FILE *f, struct dive *dive)
+static void save_depths(FILE *f, struct divecomputer *dc)
{
/* What's the point of this dive entry again? */
- if (!dive->maxdepth.mm && !dive->meandepth.mm)
+ if (!dc->maxdepth.mm && !dc->meandepth.mm)
return;
fputs(" <depth", f);
- show_depth(f, dive->maxdepth, " max='", "'");
- show_depth(f, dive->meandepth, " mean='", "'");
+ show_depth(f, dc->maxdepth, " max='", "'");
+ show_depth(f, dc->meandepth, " mean='", "'");
fputs(" />\n", f);
}
-static void save_temperatures(FILE *f, struct dive *dive)
+static void save_temperatures(FILE *f, struct divecomputer *dc)
{
- if (!dive->airtemp.mkelvin && !dive->watertemp.mkelvin)
+ if (!dc->airtemp.mkelvin && !dc->watertemp.mkelvin)
return;
fputs(" <temperature", f);
- show_temperature(f, dive->airtemp, " air='", "'");
- show_temperature(f, dive->watertemp, " water='", "'");
+ show_temperature(f, dc->airtemp, " air='", "'");
+ show_temperature(f, dc->watertemp, " water='", "'");
fputs(" />\n", f);
}
-static void save_airpressure(FILE *f, struct dive *dive)
+static void save_airpressure(FILE *f, struct divecomputer *dc)
{
- if (!dive->surface_pressure.mbar)
+ if (!dc->surface_pressure.mbar)
return;
fputs(" <surface", f);
- show_pressure(f, dive->surface_pressure, " pressure='", "'");
+ show_pressure(f, dc->surface_pressure, " pressure='", "'");
fputs(" />\n", f);
}
-static void save_salinity(FILE *f, struct dive *dive)
+static void save_salinity(FILE *f, struct divecomputer *dc)
{
/* only save if we have a value that isn't the default of sea water */
- if (!dive->salinity || dive->salinity == 10300)
+ if (!dc->salinity || dc->salinity == 10300)
return;
fputs(" <water", f);
- show_salinity(f, dive->salinity, " salinity='", "'");
+ show_salinity(f, dc->salinity, " salinity='", "'");
fputs(" />\n", f);
}
@@ -240,11 +240,6 @@ static void show_location(FILE *f, struct dive *dive)
static void save_overview(FILE *f, struct dive *dive)
{
- save_depths(f, dive);
- save_temperatures(f, dive);
- save_airpressure(f, dive);
- save_salinity(f, dive);
- show_duration(f, dive->surfacetime, " <surfacetime>", "</surfacetime>\n");
show_location(f, dive);
show_utf8(f, dive->divemaster, " <divemaster>","</divemaster>\n", 0);
show_utf8(f, dive->buddy, " <buddy>","</buddy>\n", 0);
@@ -419,7 +414,15 @@ static void save_dc(FILE *f, struct dive *dive, struct divecomputer *dc)
fprintf(f, " diveid='%08x'", dc->diveid);
if (dc->when && dc->when != dive->when)
show_date(f, dc->when);
+ if (dc->duration.seconds && dc->duration.seconds != dive->dc.duration.seconds)
+ show_duration(f, dc->duration, " duration='", "'");
fprintf(f, ">\n");
+ save_depths(f, dc);
+ save_temperatures(f, dc);
+ save_airpressure(f, dc);
+ save_salinity(f, dc);
+ show_duration(f, dc->surfacetime, " <surfacetime>", "</surfacetime>\n");
+
save_events(f, dc->events);
save_samples(f, dc->samples, dc->sample);
@@ -441,7 +444,7 @@ void save_dive(FILE *f, struct dive *dive)
fprintf(f, " visibility='%d'", dive->visibility);
show_date(f, dive->when);
fprintf(f, " duration='%u:%02u min'>\n",
- FRACTION(dive->duration.seconds, 60));
+ FRACTION(dive->dc.duration.seconds, 60));
save_overview(f, dive);
save_cylinder_info(f, dive);
save_weightsystem_info(f, dive);