]> git.meshlink.io Git - catta/blobdiff - avahi-common/rr.c
* add some autoconf check for pygtk and gtk.glade
[catta] / avahi-common / rr.c
index 7e974c4843f6052ca9f4821eb78f8238ceb07dee..c510e7f4c510f442ee4dc49859e9b1a44a4cabc0 100644 (file)
@@ -39,7 +39,7 @@ AvahiKey *avahi_key_new(const gchar *name, guint16 class, guint16 type) {
     k = g_new(AvahiKey, 1);
     k->ref = 1;
     k->name = avahi_normalize_name(name);    
-    k->class = class;
+    k->clazz = class;
     k->type = type;
 
 /*     g_message("%p %% ref=1", k); */
@@ -70,7 +70,7 @@ void avahi_key_unref(AvahiKey *k) {
     }
 }
 
-AvahiRecord *avahi_record_new(AvahiKey *k) {
+AvahiRecord *avahi_record_new(AvahiKey *k, guint32 ttl) {
     AvahiRecord *r;
     
     g_assert(k);
@@ -81,19 +81,19 @@ AvahiRecord *avahi_record_new(AvahiKey *k) {
 
     memset(&r->data, 0, sizeof(r->data));
 
-    r->ttl = AVAHI_DEFAULT_TTL;
+    r->ttl = ttl != (guint32) -1 ? ttl : AVAHI_DEFAULT_TTL;
 
     return r;
 }
 
-AvahiRecord *avahi_record_new_full(const gchar *name, guint16 class, guint16 type) {
+AvahiRecord *avahi_record_new_full(const gchar *name, guint16 class, guint16 type, guint32 ttl) {
     AvahiRecord *r;
     AvahiKey *k;
 
     g_assert(name);
     
     k = avahi_key_new(name, class, type);
-    r = avahi_record_new(k);
+    r = avahi_record_new(k, ttl);
     avahi_key_unref(k);
 
     return r;
@@ -148,11 +148,15 @@ void avahi_record_unref(AvahiRecord *r) {
 const gchar *avahi_dns_class_to_string(guint16 class) {
     if (class & AVAHI_DNS_CACHE_FLUSH) 
         return "FLUSH";
-    
-    if (class == AVAHI_DNS_CLASS_IN)
-        return "IN";
 
-    return NULL;
+    switch (class) {
+        case AVAHI_DNS_CLASS_IN:
+            return "IN";
+        case AVAHI_DNS_CLASS_ANY:
+            return "ANY";
+        default:
+            return NULL;
+    }
 }
 
 const gchar *avahi_dns_type_to_string(guint16 type) {
@@ -178,14 +182,13 @@ const gchar *avahi_dns_type_to_string(guint16 type) {
     }
 }
 
-
 gchar *avahi_key_to_string(const AvahiKey *k) {
     g_assert(k);
     g_assert(k->ref >= 1);
     
     return g_strdup_printf("%s\t%s\t%s",
                            k->name,
-                           avahi_dns_class_to_string(k->class),
+                           avahi_dns_class_to_string(k->clazz),
                            avahi_dns_type_to_string(k->type));
 }
 
@@ -250,7 +253,7 @@ gboolean avahi_key_equal(const AvahiKey *a, const AvahiKey *b) {
     
     return avahi_domain_equal(a->name, b->name) &&
         a->type == b->type &&
-        a->class == b->class;
+        a->clazz == b->clazz;
 }
 
 gboolean avahi_key_pattern_match(const AvahiKey *pattern, const AvahiKey *k) {
@@ -266,23 +269,24 @@ gboolean avahi_key_pattern_match(const AvahiKey *pattern, const AvahiKey *k) {
     
     return avahi_domain_equal(pattern->name, k->name) &&
         (pattern->type == k->type || pattern->type == AVAHI_DNS_TYPE_ANY) &&
-        pattern->class == k->class;
+        (pattern->clazz == k->clazz || pattern->clazz == AVAHI_DNS_CLASS_ANY);
 }
 
 gboolean avahi_key_is_pattern(const AvahiKey *k) {
     g_assert(k);
 
-    return k->type == AVAHI_DNS_TYPE_ANY;
+    return
+        k->type == AVAHI_DNS_TYPE_ANY ||
+        k->clazz == AVAHI_DNS_CLASS_ANY;
 }
 
-
 guint avahi_key_hash(const AvahiKey *k) {
     g_assert(k);
 
     return
         avahi_domain_hash(k->name) + 
         k->type +
-        k->class;
+        k->clazz;
 }
 
 static gboolean rdata_equal(const AvahiRecord *a, const AvahiRecord *b) {
@@ -313,8 +317,8 @@ static gboolean rdata_equal(const AvahiRecord *a, const AvahiRecord *b) {
 
         case AVAHI_DNS_TYPE_HINFO:
             return
-                !g_utf8_collate(a->data.hinfo.cpu, b->data.hinfo.cpu) &&
-                !g_utf8_collate(a->data.hinfo.os, b->data.hinfo.os);
+                !strcmp(a->data.hinfo.cpu, b->data.hinfo.cpu) &&
+                !strcmp(a->data.hinfo.os, b->data.hinfo.os);
 
         case AVAHI_DNS_TYPE_TXT:
             return avahi_string_list_equal(a->data.txt.string_list, b->data.txt.string_list);
@@ -476,7 +480,7 @@ gint avahi_record_lexicographical_compare(AvahiRecord *a, AvahiRecord *b) {
     if (a == b)
         return 0;
 
-    if ((r = uint16_cmp(a->key->class, b->key->class)) ||
+    if ((r = uint16_cmp(a->key->clazz, b->key->clazz)) ||
         (r = uint16_cmp(a->key->type, b->key->type)))
         return r;