]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/afp_zeroconf.c
fixes
[netatalk.git] / etc / afpd / afp_zeroconf.c
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
2 /*
3  * Author:  Daniel S. Haischt <me@daniel.stefan.haischt.name>
4  * Purpose: Zeroconf facade, that abstracts access to a
5  *          particular Zeroconf implementation
6  * Doc:     http://www.dns-sd.org/
7  *
8  */
9
10 #ifdef HAVE_CONFIG_H
11 #include <config.h>
12 #endif
13
14 #include "afp_zeroconf.h"
15
16 /*
17  * Global Definitions
18  */
19 #ifdef HAVE_AVAHI
20 struct context *ctx = NULL;
21 #endif
22
23 /*
24  * Functions (actually they are just facades)
25  */
26 void zeroconf_register(int port, const char *hostname)
27 {
28 #if defined (HAVE_AVAHI)
29   LOG(log_info, logtype_afpd, "Attempting to register with mDNS using Avahi\n");
30   if (hostname && strlen(hostname) > 0 && port)
31   {
32     ctx = av_zeroconf_setup(port, hostname);
33   }
34   else if (hostname && strlen(hostname) > 0)
35   {
36     ctx = av_zeroconf_setup(AFP_PORT, hostname);
37   }
38   else
39   {
40     ctx = av_zeroconf_setup(AFP_PORT, NULL);
41   }
42   av_zeroconf_run(ctx);
43 #endif
44 }
45
46 void zeroconf_deregister(void)
47 {
48 #if defined (HAVE_AVAHI)
49   LOG(log_error, logtype_afpd, "Attempting to de-register mDNS using Avahi\n");
50   if (ctx)
51     av_zeroconf_shutdown(ctx);
52 #endif
53 }