+
+unsigned avahi_domain_hash(const char *s) {
+ unsigned hash = 0;
+
+ for (;;) {
+ char c[65], *p;
+
+ if (!avahi_unescape_label(&s, c, sizeof(c)))
+ return hash;
+
+ if (!c[0])
+ continue;
+
+ for (p = c; *p; p++)
+ 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;
+ }
+}