diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-11-11 02:20:13 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-11-11 02:20:13 -0800 |
commit | f9b9535c6921e096583d1872cbf05cfea2252c11 (patch) | |
tree | e62399c5c5e9380c9a0baca7cc108226786fd244 /dive.c | |
parent | b51710c01ed481504a8103ab339adf3c01f83f7b (diff) | |
download | subsurface-f9b9535c6921e096583d1872cbf05cfea2252c11.tar.gz |
Add tag helper functions to allow us to count dives with a given tag
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r-- | dive.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -2490,6 +2490,28 @@ void taglist_init_global() taglist_add_tag(&g_tag_list, default_tags[i]); } +bool taglist_contains(struct tag_entry *tag_list, const char *tag) +{ + while (tag_list) { + if (same_string(tag_list->tag->name, tag)) + return true; + tag_list = tag_list->next; + } + return false; +} + +int count_dives_with_tag(const char *tag) +{ + int i, counter = 0; + struct dive *d; + + for_each_dive (i, d) { + if (taglist_contains(d->tag_list, tag)) + counter++; + } + return counter; +} + struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool prefer_downloaded) { struct dive *res = alloc_dive(); |