diff options
| author | Louis Burda <quent.burda@gmail.com> | 2021-12-04 13:48:01 +0100 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2021-12-20 15:31:16 +0100 |
| commit | 9fe644f0d99375ffd3011d8828f7dbd0fb103af0 (patch) | |
| tree | 71ed89f1c7316dba818bc921d772aaa1fc957dab /tag.c | |
| parent | d68d0f39ab7675745e7d177f6774736f7ec58783 (diff) | |
| download | tmus-9fe644f0d99375ffd3011d8828f7dbd0fb103af0.tar.gz tmus-9fe644f0d99375ffd3011d8828f7dbd0fb103af0.zip | |
Added more gui interaction
Diffstat (limited to 'tag.c')
| -rw-r--r-- | tag.c | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -0,0 +1,53 @@ +#include "tag.h" +#include "link.h" + +static struct link * +tagrefs_ffind(struct link *head, struct tag *tag) +{ + struct link *iter; + + for (iter = head->next; iter; iter = iter->next) { + if (UPCAST(iter, struct tag_ref)->tag == tag) + return iter; + } + + return NULL; +} + +int +tagrefs_incl(struct link *head, struct tag *tag) +{ + struct link *ref; + + ref = tagrefs_ffind(head, tag); + return ref != NULL; +} + +void +tagrefs_add(struct link *head, struct tag *tag) +{ + struct tag_ref *ref; + + if (tagrefs_incl(head, tag)) + return; + + ref = malloc(sizeof(struct tag_ref)); + ASSERT(ref != NULL); + ref->link = LINK_EMPTY; + ref->tag = tag; + link_push_back(head, &ref->link); +} + +void +tagrefs_rm(struct link *head, struct tag *tag) +{ + struct link *ref; + struct tag_ref *tagref; + + ref = tagrefs_ffind(head, tag); + if (!ref) return; + + tagref = UPCAST(ref, struct tag_ref); + link_pop(ref); + free(tagref); +} |
