summaryrefslogtreecommitdiffstats
path: root/avahi-common
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-09-25 19:58:12 +0000
committerLennart Poettering <lennart@poettering.net>2005-09-25 19:58:12 +0000
commit8371548df70d1948bf04140c5f73eddd1edac12b (patch)
tree5d6ea04f4d3196bc23c5ca2ab0bea59c39b76d37 /avahi-common
parent1a0fb70d743f900859d9278c6ae01cfc2a993dad (diff)
add new function avahi_domain_ends_with()
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@605 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-common')
-rw-r--r--avahi-common/domain.c18
-rw-r--r--avahi-common/domain.h3
2 files changed, 21 insertions, 0 deletions
diff --git a/avahi-common/domain.c b/avahi-common/domain.c
index 3703a04..1a4f8a6 100644
--- a/avahi-common/domain.c
+++ b/avahi-common/domain.c
@@ -337,3 +337,21 @@ unsigned avahi_domain_hash(const char *s) {
hash = 31 * hash + tolower(*p);
}
}
+
+int avahi_domain_ends_with(const char *domain, const char *suffix) {
+ assert(domain);
+ assert(suffix);
+
+ assert(avahi_is_valid_domain_name(domain));
+ assert(avahi_is_valid_domain_name(suffix));
+
+ for (;;) {
+ char dummy[64];
+
+ if (avahi_domain_equal(domain, suffix))
+ return 1;
+
+ if (!(avahi_unescape_label(&domain, dummy, sizeof(dummy))))
+ return 0;
+ }
+}
diff --git a/avahi-common/domain.h b/avahi-common/domain.h
index 88cf4d3..0464915 100644
--- a/avahi-common/domain.h
+++ b/avahi-common/domain.h
@@ -70,6 +70,9 @@ int avahi_is_valid_host_name(const char *t);
/** Return some kind of hash value for the domain, useful for using domains as hash table keys. */
unsigned avahi_domain_hash(const char *name);
+/** Returns 1 if the the end labels of domain are eqal to suffix */
+int avahi_domain_ends_with(const char *domain, const char *suffix);
+
#ifndef DOXYGEN_SHOULD_SKIP_THIS
AVAHI_C_DECL_END
#endif