]> git.meshlink.io Git - catta/blobdiff - avahi-daemon/static-services.c
Allow compilation against bsdxml instead of Expat. Patch from zml. (Closes #159)
[catta] / avahi-daemon / static-services.c
index 1a58cc4138589fefc35bcb23719984f2fbb4b797..e123a217e22779e33df6430a1d0d996eaa02e620 100644 (file)
 #include <fcntl.h>
 #include <unistd.h>
 
+#ifdef USE_EXPAT_H
 #include <expat.h>
+#endif /* USE_EXPAT_H */
+
+#ifdef USE_BSDXML_H
+#include <bsdxml.h>
+#endif /* USE_BSDXML_H */
 
 #include <avahi-common/llist.h>
 #include <avahi-common/malloc.h>
@@ -222,7 +228,9 @@ static void add_static_service_group_to_server(StaticServiceGroup *g) {
         /* This service group is already registered in the server */
         return;
     
-    if (!g->chosen_name) {
+    if (!g->chosen_name || (g->replace_wildcards && strstr(g->name, "%h"))) {
+
+        avahi_free(g->chosen_name);
         
         if (g->replace_wildcards)
             g->chosen_name = replacestr(g->name, "%h", avahi_server_get_host_name(avahi_server));
@@ -682,20 +690,25 @@ void static_service_load(int in_chroot) {
     }
 
     memset(&globbuf, 0, sizeof(globbuf));
+    
     if ((globret = glob(in_chroot ? "/services/*.service" : AVAHI_SERVICE_DIR "/*.service", GLOB_ERR, NULL, &globbuf)) != 0)
+        
         switch (globret) {
+#ifdef GLOB_NOSPACE
            case GLOB_NOSPACE:
-               avahi_log_error("Not enough memory to read service directory.");
-               break;
-
-           case GLOB_ABORTED:
-               avahi_log_error("Failed to read %s.", AVAHI_SERVICE_DIR);
+               avahi_log_error("Not enough memory to read service directory "AVAHI_SERVICE_DIR".");
                break;
-
+#endif
+#ifdef GLOB_NOMATCH
             case GLOB_NOMATCH:
-               avahi_log_error("No service found in %s.", AVAHI_SERVICE_DIR);
+               avahi_log_info("No service file found in "AVAHI_SERVICE_DIR".");
+               break;
+#endif
+            default:
+               avahi_log_error("Failed to read "AVAHI_SERVICE_DIR".");
                break;
-               }
+        }
+    
     else {
         for (p = globbuf.gl_pathv; *p; p++)
             load_file(*p);