summaryrefslogtreecommitdiff
path: root/apps/tagcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/tagcache.c')
-rw-r--r--apps/tagcache.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 1c180b7f43..ca2421171b 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -592,6 +592,23 @@ inline static bool str_ends_with(const char *str1, const char *str2)
592 return !strcasecmp(&str1[str_len - clause_len], str2); 592 return !strcasecmp(&str1[str_len - clause_len], str2);
593} 593}
594 594
595inline static bool str_oneof(const char *str, const char *list)
596{
597 const char *sep;
598 int l, len = strlen(str);
599
600 while (*list)
601 {
602 sep = strchr(list, '|');
603 l = sep ? (long)sep - (long)list : (int)strlen(list);
604 if ((l==len) && !strncasecmp(str, list, len))
605 return true;
606 list += sep ? l + 1 : l;
607 }
608
609 return false;
610}
611
595static bool check_against_clause(long numeric, const char *str, 612static bool check_against_clause(long numeric, const char *str,
596 const struct tagcache_search_clause *clause) 613 const struct tagcache_search_clause *clause)
597{ 614{
@@ -643,6 +660,8 @@ static bool check_against_clause(long numeric, const char *str,
643 return str_ends_with(str, clause->str); 660 return str_ends_with(str, clause->str);
644 case clause_not_ends_with: 661 case clause_not_ends_with:
645 return !str_ends_with(str, clause->str); 662 return !str_ends_with(str, clause->str);
663 case clause_oneof:
664 return str_oneof(str, clause->str);
646 665
647 default: 666 default:
648 logf("Incorrect tag: %d", clause->type); 667 logf("Incorrect tag: %d", clause->type);