]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afp_zeroconf.c
Support for using $u username variable in AFP volume definitions
[netatalk.git] / etc / afpd / afp_zeroconf.c
index d5149162a1cc63bf0a4b7625afeb0b855ac14444..cf370fc3bf4b052a5defd159dcc40749fcc2bb2b 100644 (file)
 #endif
 
 #include "afp_zeroconf.h"
+#include "afp_config.h"
 
-/*
- * Global Definitions
- */
-#ifdef HAVE_AVAHI
-struct context *ctx = NULL;
+#ifdef HAVE_MDNS
+#include "afp_mdns.h"
+#elif defined (HAVE_AVAHI)
+#include "afp_avahi.h"
 #endif
 
+
 /*
  * Functions (actually they are just facades)
  */
-void zeroconf_register(int port, char *hostname)
+void zeroconf_register(const AFPObj *configs)
 {
-#if defined (HAVE_AVAHI)
-  LOG(log_info, logtype_afpd, "Attempting to register with mDNS using Avahi\n");
-  if (hostname && strlen(hostname) > 0 && port)
-  {
-    ctx = av_zeroconf_setup(port, hostname);
-  }
-  else if (hostname && strlen(hostname) > 0)
-  {
-    ctx = av_zeroconf_setup(AFP_PORT, hostname);
-  }
-  else
-  {
-    ctx = av_zeroconf_setup(AFP_PORT, NULL);
-  }
-  av_zeroconf_run(ctx);
+#if defined (HAVE_MDNS)
+  LOG(log_debug, logtype_afpd, "Attempting to register with mDNS using mDNSResponder");
+
+       md_zeroconf_register(configs);
+#elif defined (HAVE_AVAHI)
+  LOG(log_debug, logtype_afpd, "Attempting to register with mDNS using Avahi");
+
+       av_zeroconf_register(configs);
 #endif
 }
 
 void zeroconf_deregister(void)
 {
-#if defined (HAVE_AVAHI)
-  LOG(log_error, logtype_afpd, "Attempting to de-register mDNS using Avahi\n");
-  if (ctx)
-    av_zeroconf_shutdown(ctx);
+#if defined (HAVE_MDNS)
+  LOG(log_debug, logtype_afpd, "Attempting to de-register mDNS using mDNSResponder");
+       md_zeroconf_unregister();
+#elif defined (HAVE_AVAHI)
+  LOG(log_debug, logtype_afpd, "Attempting to de-register mDNS using Avahi");
+       av_zeroconf_unregister();
 #endif
 }