diff options
author | Maximilian Güntner <maximilian.guentner@gmail.com> | 2013-11-02 02:12:42 +0100 |
---|---|---|
committer | Maximilian Güntner <maximilian.guentner@gmail.com> | 2013-11-02 02:55:03 +0100 |
commit | 6fe8cb652191728586f3731dcf6688b5a5b3efbb (patch) | |
tree | d579741fecbde7d5c9b66926fcdc40467dcfb480 /save-xml.c | |
parent | 2ef80930ff4ac15c7d68e7b3b8935c2121029fd3 (diff) | |
download | subsurface-6fe8cb652191728586f3731dcf6688b5a5b3efbb.tar.gz |
Replaced the tag implementation
The new implementation supports custom tags
which are provided by the user as well as
default tags which are provided by subsurface.
Default tags can be translated and will be written
to XML in their non-localized form.
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
Diffstat (limited to 'save-xml.c')
-rw-r--r-- | save-xml.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/save-xml.c b/save-xml.c index ab81c1590..5b0ef42ec 100644 --- a/save-xml.c +++ b/save-xml.c @@ -392,20 +392,28 @@ static void save_events(FILE *f, struct event *ev) } } -static void save_tags(FILE *f, int tags) +static void save_tags(FILE *f, struct tag_entry *tag_list) { - int i, more = 0; + int more = 0; + struct tag_entry *tmp = tag_list->next; - fprintf(f, " tags='"); - for (i = 0; i < DTAG_NR; i++) { - if (tags & (1 << i)) { + /* Only write tag attribute if the list contains at least one item */ + if (tmp != NULL) { + fprintf(f, " tags='"); + + while (tmp != NULL) { if (more) fprintf(f, ", "); - fprintf(f, "%s", dtag_names[i]); + /* If the tag has been translated, write the source to the xml file */ + if (tmp->tag->source != NULL) + fprintf(f, "%s", tmp->tag->source); + else + fprintf(f, "%s", tmp->tag->name); + tmp = tmp->next; more = 1; } + fprintf(f, "'"); } - fprintf(f, "'"); } static void show_date(FILE *f, timestamp_t when) @@ -468,8 +476,8 @@ void save_dive(FILE *f, struct dive *dive) fprintf(f, " rating='%d'", dive->rating); if (dive->visibility) fprintf(f, " visibility='%d'", dive->visibility); - if (dive->dive_tags) - save_tags(f, dive->dive_tags); + if (dive->tag_list != NULL) + save_tags(f, dive->tag_list); show_date(f, dive->when); fprintf(f, " duration='%u:%02u min'>\n", |