+static void server_callback(AvahiServer *s, AvahiServerState state, void *userdata) {
+ DaemonConfig *c = userdata;
+
+ assert(s);
+ assert(c);
+
+ /* This function is possibly called before the global variable
+ * avahi_server has been set, therefore we do it explicitly */
+
+ avahi_server = s;
+
+#ifdef HAVE_DBUS
+ if (c->enable_dbus && state != AVAHI_SERVER_INVALID && state != AVAHI_SERVER_FAILURE)
+ dbus_protocol_server_state_changed(state);
+#endif
+
+ switch (state) {
+ case AVAHI_SERVER_RUNNING:
+ avahi_log_info("Server startup complete. Host name is %s. Local service cookie is %u.", avahi_server_get_host_name_fqdn(s), avahi_server_get_local_service_cookie(s));
+
+ avahi_set_proc_title(argv0, "%s: running [%s]", argv0, avahi_server_get_host_name_fqdn(s));
+
+ static_service_add_to_server();
+ static_hosts_add_to_server();
+
+ remove_dns_server_entry_groups();
+
+ if (c->publish_resolv_conf && resolv_conf && resolv_conf[0])
+ resolv_conf_entry_group = add_dns_servers(s, resolv_conf_entry_group, resolv_conf);
+
+ if (c->publish_dns_servers && c->publish_dns_servers[0])
+ dns_servers_entry_group = add_dns_servers(s, dns_servers_entry_group, c->publish_dns_servers);
+
+ simple_protocol_restart_queries();
+ break;
+
+ case AVAHI_SERVER_COLLISION: {
+ char *n;
+
+ avahi_set_proc_title(argv0, "%s: collision", argv0);
+
+ static_service_remove_from_server();
+ static_hosts_remove_from_server();
+ remove_dns_server_entry_groups();
+
+ n = avahi_alternative_host_name(avahi_server_get_host_name(s));
+ avahi_log_warn("Host name conflict, retrying with <%s>", n);
+ avahi_server_set_host_name(s, n);
+ avahi_free(n);
+
+ break;
+ }
+
+ case AVAHI_SERVER_FAILURE:
+
+ avahi_log_error("Server error: %s", avahi_strerror(avahi_server_errno(s)));
+ avahi_simple_poll_quit(simple_poll_api);
+ break;
+
+ case AVAHI_SERVER_REGISTERING:
+
+ avahi_set_proc_title(argv0, "%s: registering [%s]", argv0, avahi_server_get_host_name_fqdn(s));
+
+ static_service_remove_from_server();
+ static_hosts_remove_from_server();
+ remove_dns_server_entry_groups();
+
+ break;
+
+ case AVAHI_SERVER_INVALID:
+ break;
+
+ }
+}
+
+static void help(FILE *f) {