diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-01-23 10:25:31 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-01-23 12:55:33 -0800 |
commit | b6c9301e584722b9b46dffd4d759e8c60df520ad (patch) | |
tree | 2f963ec75672389692e532a8264dc83396900eb2 /parse-xml.c | |
parent | 3e5a508b15fe28083dfdf5a049d33e8769616395 (diff) | |
download | subsurface-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 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 76 |
1 files changed, 46 insertions, 30 deletions
diff --git a/parse-xml.c b/parse-xml.c index 35ebf0446..0aa4b7bf0 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -657,6 +657,40 @@ static struct divecomputer *get_dc(void) return cur_dc ? : &cur_dive->dc; } +static int match_dc_data_fields(struct divecomputer *dc, const char *name, int len, char *buf) +{ + if (MATCH(".maxdepth", depth, &dc->maxdepth)) + return 1; + if (MATCH(".meandepth", depth, &dc->meandepth)) + return 1; + if (MATCH(".depth.max", depth, &dc->maxdepth)) + return 1; + if (MATCH(".depth.mean", depth, &dc->meandepth)) + return 1; + if (MATCH(".duration", duration, &dc->duration)) + return 1; + if (MATCH(".divetime", duration, &dc->duration)) + return 1; + if (MATCH(".divetimesec", duration, &dc->duration)) + return 1; + if (MATCH(".surfacetime", duration, &dc->surfacetime)) + return 1; + if (MATCH(".airtemp", temperature, &dc->airtemp)) + return 1; + if (MATCH(".watertemp", temperature, &dc->watertemp)) + return 1; + if (MATCH(".temperature.air", temperature, &dc->airtemp)) + return 1; + if (MATCH(".temperature.water", temperature, &dc->watertemp)) + return 1; + if (MATCH(".surface.pressure", pressure, &dc->surface_pressure)) + return 1; + if (MATCH(".water.salinity", salinity, &dc->salinity)) + return 1; + + return 0; +} + /* We're in the top-level dive xml. Try to convert whatever value to a dive value */ static void try_to_fill_dc(struct divecomputer *dc, const char *name, char *buf) { @@ -675,6 +709,9 @@ static void try_to_fill_dc(struct divecomputer *dc, const char *name, char *buf) if (MATCH(".diveid", hex_value, &dc->diveid)) return; + if (match_dc_data_fields(dc, name, len, buf)) + return; + nonmatch("divecomputer", name, buf); } @@ -797,7 +834,7 @@ static int divinglog_dive_match(struct dive *dive, const char *name, int len, ch { return MATCH(".divedate", divedate, &dive->when) || MATCH(".entrytime", divetime, &dive->when) || - MATCH(".depth", depth, &dive->maxdepth) || + MATCH(".depth", depth, &dive->dc.maxdepth) || MATCH(".tanktype", utf8_string, &dive->cylinder[0].type.description) || MATCH(".tanksize", cylindersize, &dive->cylinder[0].type.size) || MATCH(".presw", pressure, &dive->cylinder[0].type.workingpressure) || @@ -856,8 +893,8 @@ success: static int uddf_dive_match(struct dive *dive, const char *name, int len, char *buf) { return MATCH(".datetime", uddf_datetime, &dive->when) || - MATCH(".diveduration", duration, &dive->duration) || - MATCH(".greatestdepth", depth, &dive->maxdepth) || + MATCH(".diveduration", duration, &dive->dc.duration) || + MATCH(".greatestdepth", depth, &dive->dc.maxdepth) || 0; } @@ -950,34 +987,13 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf) return; if (MATCH(".datetime", divedatetime, &dive->when)) return; - if (MATCH(".maxdepth", depth, &dive->maxdepth)) - return; - if (MATCH(".meandepth", depth, &dive->meandepth)) - return; - if (MATCH(".depth.max", depth, &dive->maxdepth)) - return; - if (MATCH(".depth.mean", depth, &dive->meandepth)) - return; - if (MATCH(".duration", duration, &dive->duration)) - return; - if (MATCH(".divetime", duration, &dive->duration)) - return; - if (MATCH(".divetimesec", duration, &dive->duration)) - return; - if (MATCH(".surfacetime", duration, &dive->surfacetime)) - return; - if (MATCH(".airtemp", temperature, &dive->airtemp)) - return; - if (MATCH(".watertemp", temperature, &dive->watertemp)) - return; - if (MATCH(".temperature.air", temperature, &dive->airtemp)) - return; - if (MATCH(".temperature.water", temperature, &dive->watertemp)) - return; - if (MATCH(".surface.pressure", pressure, &dive->surface_pressure)) - return; - if (MATCH(".water.salinity", salinity, &dive->salinity)) + /* + * Legacy format note: per-dive depths and duration get saved + * in the first dive computer entry + */ + if (match_dc_data_fields(&dive->dc, name, len, buf)) return; + if (MATCH(".cylinderstartpressure", pressure, &dive->cylinder[0].start)) return; if (MATCH(".cylinderendpressure", pressure, &dive->cylinder[0].end)) |