mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Add tag helper functions to allow us to count dives with a given tag
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									b51710c01e
								
							
						
					
					
						commit
						f9b9535c69
					
				
					 2 changed files with 25 additions and 0 deletions
				
			
		
							
								
								
									
										22
									
								
								dive.c
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								dive.c
									
										
									
									
									
								
							|  | @ -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(); | ||||
|  |  | |||
							
								
								
									
										3
									
								
								dive.h
									
										
									
									
									
								
							
							
						
						
									
										3
									
								
								dive.h
									
										
									
									
									
								
							|  | @ -233,6 +233,9 @@ void taglist_cleanup(struct tag_entry **tag_list); | |||
| void taglist_init_global(); | ||||
| void taglist_free(struct tag_entry *tag_list); | ||||
| 
 | ||||
| bool taglist_contains(struct tag_entry *tag_list, const char *tag); | ||||
| int count_dives_with_tag(const char *tag); | ||||
| 
 | ||||
| struct extra_data { | ||||
| 	const char *key; | ||||
| 	const char *value; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue