]> git.meshlink.io Git - catta/commitdiff
* drop trailing dot in avahi_normalize_name()
authorLennart Poettering <lennart@poettering.net>
Thu, 28 Jul 2005 00:01:44 +0000 (00:01 +0000)
committerLennart Poettering <lennart@poettering.net>
Thu, 28 Jul 2005 00:01:44 +0000 (00:01 +0000)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@180 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-common/rr.c
avahi-common/util.c
avahi-core/browse-domain.c
avahi-core/browse-service-type.c
avahi-core/browse-service.c
avahi-core/dns.c
avahi-core/resolve-service.c
avahi-core/server.c
avahi-daemon/dbus-protocol.c
todo

index 2a25321f4c2dc1ae971701efbaf62edf8ba4eb1c..c510e7f4c510f442ee4dc49859e9b1a44a4cabc0 100644 (file)
@@ -182,7 +182,6 @@ 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);
index c9a3143aac2163b67ceb751fd5487e1da5ff0c0d..8be7b8830b90e4c856f2ab93878c77cadd7d5e22 100644 (file)
@@ -84,13 +84,12 @@ gchar *avahi_normalize_name(const gchar *s) {
 
     unescape_uneeded(s, tmp, sizeof(tmp));
 
-    if ((l = strlen(tmp)) == 0)
-        return g_strdup(".");
+    l = strlen(tmp);
 
-    if (tmp[l-1] == '.')
-        return g_strdup(tmp);
+    while (l > 0 && tmp[l-1] == '.')
+        tmp[--l] = 0;
 
-    return g_strdup_printf("%s.", tmp);
+    return g_strdup(tmp);
 }
 
 gint avahi_timeval_compare(const GTimeVal *a, const GTimeVal *b) {
index 06ad64acf3ef541e44fa6c7ebd1f5a31fc69bfd1..7a9561148504fcb5f789c5be589ca526e676415b 100644 (file)
@@ -63,7 +63,7 @@ AvahiDomainBrowser *avahi_domain_browser_new(AvahiServer *server, gint interface
 
     b = g_new(AvahiDomainBrowser, 1);
     b->server = server;
-    b->domain_name = avahi_normalize_name(domain ? domain : "local.");
+    b->domain_name = avahi_normalize_name(domain ? domain : "local");
     b->callback = callback;
     b->userdata = userdata;
 
index 21c115790117c68b017bd56719314611734102a3..bc0e0fc265af054ca2e05cfbab72d7793bc75695 100644 (file)
@@ -92,7 +92,7 @@ AvahiServiceTypeBrowser *avahi_service_type_browser_new(AvahiServer *server, gin
 
     b = g_new(AvahiServiceTypeBrowser, 1);
     b->server = server;
-    b->domain_name = avahi_normalize_name(domain ? domain : "local.");
+    b->domain_name = avahi_normalize_name(domain ? domain : "local");
     b->callback = callback;
     b->userdata = userdata;
 
index 280de6e068f1096e6442aab803b51d27c6d3a159..500ec31e21523fb7e0bf7a24b51216ffc6cf05ff 100644 (file)
@@ -95,12 +95,12 @@ AvahiServiceBrowser *avahi_service_browser_new(AvahiServer *server, gint interfa
 
     b = g_new(AvahiServiceBrowser, 1);
     b->server = server;
-    b->domain_name = avahi_normalize_name(domain ? domain : "local.");
+    b->domain_name = avahi_normalize_name(domain ? domain : "local");
     b->service_type = avahi_normalize_name(service_type);
     b->callback = callback;
     b->userdata = userdata;
 
-    n = g_strdup_printf("%s%s", b->service_type, b->domain_name);
+    n = g_strdup_printf("%s.%s", b->service_type, b->domain_name);
     k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR);
     g_free(n);
     
index 5213e97eb45e8e14e48d9163174c83ffa5acde04..f5d4075e99000ca8e6412ff6e920a43de5e55ad1 100644 (file)
@@ -432,7 +432,6 @@ gint avahi_dns_packet_consume_string(AvahiDnsPacket *p, gchar *ret_string, guint
     p->rindex += 1+k;
 
     return 0;
-    
 }
 
 gconstpointer avahi_dns_packet_get_rptr(AvahiDnsPacket *p) {
index 8fe9fd26a9d1838e203fdfe88453ab9435e4a00a..6567d374226436573360ea03d4220c09aa2048a5 100644 (file)
@@ -208,7 +208,7 @@ AvahiServiceResolver *avahi_service_resolver_new(AvahiServer *server, gint inter
 
     r = g_new(AvahiServiceResolver, 1);
     r->server = server;
-    r->service_name = avahi_normalize_name(name);
+    r->service_name = g_strdup(name);
     r->service_type = avahi_normalize_name(type);
     r->domain_name = avahi_normalize_name(domain);
     r->callback = callback;
@@ -221,7 +221,7 @@ AvahiServiceResolver *avahi_service_resolver_new(AvahiServer *server, gint inter
     n = t;
     l = sizeof(t);
     avahi_escape_label((guint8*) name, strlen(name), &n, &l);
-    snprintf(n, l, ".%s%s", r->service_type, r->domain_name);
+    snprintf(n, l, ".%s.%s", r->service_type, r->domain_name);
 
     avahi_elapse_time(&tv, 1000, 0);
     r->time_event = avahi_time_event_queue_add(server->time_event_queue, &tv, time_event_callback, r);
index 9619ab4ea19ce16ed4e1d8e2923e39f4fe57764e..b3ab0090fc176a0ec7e7ad6909e02443ff5b98d4 100644 (file)
@@ -1249,7 +1249,7 @@ gint avahi_server_set_domain_name(AvahiServer *s, const gchar *domain_name) {
     withdraw_host_rrs(s);
 
     g_free(s->domain_name);
-    s->domain_name = domain_name ? avahi_normalize_name(domain_name) : g_strdup("local.");
+    s->domain_name = domain_name ? avahi_normalize_name(domain_name) : g_strdup("local");
     update_fqdn(s);
 
     delayed_register_stuff(s);
@@ -1347,7 +1347,7 @@ AvahiServer *avahi_server_new(GMainContext *c, const AvahiServerConfig *sc, Avah
     /* Get host name */
     s->host_name = s->config.host_name ? avahi_normalize_name(s->config.host_name) : avahi_get_host_name();
     s->host_name[strcspn(s->host_name, ".")] = 0;
-    s->domain_name = s->config.domain_name ? avahi_normalize_name(s->config.domain_name) : g_strdup("local.");
+    s->domain_name = s->config.domain_name ? avahi_normalize_name(s->config.domain_name) : g_strdup("local");
     s->host_name_fqdn = NULL;
     update_fqdn(s);
 
@@ -1717,6 +1717,7 @@ gint avahi_server_add_service_strlst(
     AvahiStringList *strlst) {
 
     gchar ptr_name[256], svc_name[256], ename[64], enum_ptr[256];
+    gchar *t, *d;
     AvahiRecord *r;
     gint ret = 0;
     
@@ -1735,9 +1736,12 @@ gint avahi_server_add_service_strlst(
     if (!host)
         host = s->host_name_fqdn;
 
-    snprintf(ptr_name, sizeof(ptr_name), "%s.%s", type, domain);
-    snprintf(svc_name, sizeof(svc_name), "%s.%s.%s", ename, type, domain);
+    d = avahi_normalize_name(domain);
+    t = avahi_normalize_name(type);
     
+    snprintf(ptr_name, sizeof(ptr_name), "%s.%s", t, d);
+    snprintf(svc_name, sizeof(svc_name), "%s.%s.%s", ename, t, d);
+
     ret = avahi_server_add_ptr(s, g, interface, protocol, AVAHI_ENTRY_NULL, AVAHI_DEFAULT_TTL, ptr_name, svc_name);
 
     r = avahi_record_new_full(svc_name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV, AVAHI_DEFAULT_TTL_HOST_NAME);
@@ -1750,9 +1754,12 @@ gint avahi_server_add_service_strlst(
 
     ret |= avahi_server_add_txt_strlst(s, g, interface, protocol, AVAHI_ENTRY_UNIQUE, AVAHI_DEFAULT_TTL, svc_name, strlst);
 
-    snprintf(enum_ptr, sizeof(enum_ptr), "_services._dns-sd._udp.%s", domain);
+    snprintf(enum_ptr, sizeof(enum_ptr), "_services._dns-sd._udp.%s", d);
     ret |=avahi_server_add_ptr(s, g, interface, protocol, AVAHI_ENTRY_NULL, AVAHI_DEFAULT_TTL, enum_ptr, ptr_name);
 
+    g_free(d);
+    g_free(t);
+    
     return ret;
 }
 
@@ -1870,7 +1877,7 @@ gint avahi_server_add_dns_server_name(
     guint16 port /** should be 53 */) {
 
     gint ret = -1;
-    gchar t[256];
+    gchar t[256], *d;
     AvahiRecord *r;
     
     g_assert(s);
@@ -1883,7 +1890,9 @@ gint avahi_server_add_dns_server_name(
     } else
         domain = s->domain_name;
 
-    snprintf(t, sizeof(t), "%s.%s", type == AVAHI_DNS_SERVER_RESOLVE ? "_domain._udp" : "_dns-update._udp", domain);
+    d = avahi_normalize_name(domain);
+    snprintf(t, sizeof(t), "%s.%s", type == AVAHI_DNS_SERVER_RESOLVE ? "_domain._udp" : "_dns-update._udp", d);
+    g_free(d);
     
     r = avahi_record_new_full(t, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV, AVAHI_DEFAULT_TTL_HOST_NAME);
     r->data.srv.priority = 0;
@@ -1896,7 +1905,6 @@ gint avahi_server_add_dns_server_name(
     return ret;
 }
 
-
 static void post_query_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, gpointer userdata) {
     AvahiKey *k = userdata;
 
index 7be5ee0049dce43b4a4b1f292f6539734118e7e1..a1582ab86796aeafd02a4ab44174c07e4cbadc1e 100644 (file)
@@ -199,6 +199,7 @@ static DBusHandlerResult msg_signal_filter_impl(DBusConnection *c, DBusMessage *
 
         avahi_log_info("dbus: name acquired (%s)", name);
         return DBUS_HANDLER_RESULT_HANDLED;
+        
     } else if (dbus_message_is_signal(m, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
         gchar *name, *old, *new;
 
@@ -289,6 +290,7 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m,
 
         entry_group_free(i);
         return respond_ok(c, m);
+        
     } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "Commit")) {
 
         if (!dbus_message_get_args(m, &error, DBUS_TYPE_INVALID)) {
@@ -298,6 +300,7 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m,
 
         avahi_entry_group_commit(i->entry_group);
         return respond_ok(c, m);
+        
     } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "GetState")) {
         DBusMessage *reply;
         gint32 t;
@@ -314,6 +317,7 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m,
         dbus_message_unref(reply);
         
         return DBUS_HANDLER_RESULT_HANDLED;
+        
     } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddService")) {
         gint32 interface, protocol;
         gchar *type, *name, *domain, *host;
@@ -353,6 +357,7 @@ static DBusHandlerResult msg_entry_group_impl(DBusConnection *c, DBusMessage *m,
             avahi_log_info("Successfully added service: %s", name);
         
         return respond_ok(c, m);
+        
     } else if (dbus_message_is_method_call(m, AVAHI_DBUS_INTERFACE_ENTRY_GROUP, "AddAddress")) {
         gint32 interface, protocol;
         gchar *name, *address;
diff --git a/todo b/todo
index 1822fa9a9840e89972145b59cb69af31c4cbf649..208d2c7589cc1c20de2f42a961d93b2a4e41d0a0 100644 (file)
--- a/todo
+++ b/todo
@@ -1,6 +1,7 @@
 todo:
+* finish DBUS stuff
 * release!
-* drop trailing dot on avahi_normalize_name()
+
 later:
 * support for special domain PTR records based on local IP subnet address
 * Changes resulting in updated RFC of 7th June 2005:
@@ -44,3 +45,4 @@ done:
 * test against apple test suite
 * sensible logging
 * c++ support
+* drop trailing dot on avahi_normalize_name()