diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-12-26 13:47:54 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-12-26 16:46:21 -0800 |
commit | e726c9d65c7d1f1b8dbe238819b4d2847b8a058d (patch) | |
tree | 4bfd79efd17829879abff84d9b1b05cbb1e3e1a1 /save-xml.c | |
parent | 1bd6f72d3191fc8f68acc9b44099e5705293db59 (diff) | |
download | subsurface-e726c9d65c7d1f1b8dbe238819b4d2847b8a058d.tar.gz |
Add settings section to XML file format and store dive computer IDs
We only store the model/deviceid/nickname for those dive computers that
are mentioned in the XML file. This should make the XML files nicely
selfcontained.
This also changes the code to consistently use model & deviceid to
identify a dive computer. The deviceid is NOT guaranteed to be collision
free between different libdivecomputer backends...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-xml.c')
-rw-r--r-- | save-xml.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/save-xml.c b/save-xml.c index fb9eb413a..88ae4e1e9 100644 --- a/save-xml.c +++ b/save-xml.c @@ -443,13 +443,14 @@ static void save_dive(FILE *f, struct dive *dive) fprintf(f, "</dive>\n"); } -#define VERSION 1 +#define VERSION 2 void save_dives(const char *filename) { int i; struct dive *dive; dive_trip_t *trip = NULL; + char *dc_xml = strdup(""); FILE *f = g_fopen(filename, "w"); @@ -459,8 +460,16 @@ void save_dives(const char *filename) /* Flush any edits of current dives back to the dives! */ update_dive(current_dive); - fprintf(f, "<dives>\n<program name='subsurface' version='%d'></program>\n", VERSION); - + fprintf(f, "<divelog program='subsurface' version='%d'>\n<settings>\n", VERSION); + for_each_dive(i, dive) { + struct divecomputer *dc = &dive->dc; + while (dc) { + add_dc_to_string(&dc_xml, dc); + dc = dc->next; + } + } + fprintf(f, dc_xml); + fprintf(f, "</settings>\n<dives>\n"); /* save the dives */ for_each_dive(i, dive) { dive_trip_t *thistrip = dive->divetrip; @@ -477,6 +486,6 @@ void save_dives(const char *filename) } if (trip) fprintf(f, "</trip>\n"); - fprintf(f, "</dives>\n"); + fprintf(f, "</dives>\n</divelog>\n"); fclose(f); } |