#include <avahi-common/llist.h>
#include <avahi-common/malloc.h>
+#include <avahi-common/alternative.h>
+#include <avahi-common/error.h>
#include <avahi-core/log.h>
#include "main.h"
s->type = s->host_name = s->domain_name = NULL;
s->port = 0;
- s->protocol = AF_UNSPEC;
+ s->protocol = AVAHI_PROTO_UNSPEC;
s->txt_records = NULL;
/* This service group is already registered in the server */
return;
- if (g->chosen_name)
- avahi_free(g->chosen_name);
-
- if (g->replace_wildcards)
- g->chosen_name = replacestr(g->name, "%h", avahi_server_get_host_name(avahi_server));
- else
- g->chosen_name = avahi_strdup(g->name);
+ if (!g->chosen_name) {
+
+ if (g->replace_wildcards)
+ g->chosen_name = replacestr(g->name, "%h", avahi_server_get_host_name(avahi_server));
+ else
+ g->chosen_name = avahi_strdup(g->name);
+ }
+
if (!g->entry_group)
g->entry_group = avahi_s_entry_group_new(avahi_server, entry_group_callback, g);
int protocol;
assert(u->service);
- if (strcasecmp (u->buf, "ipv4") == 0) {
- protocol = AF_INET;
- } else if (strcasecmp (u->buf, "ipv6") == 0) {
- protocol = AF_INET6;
- } else if (strcasecmp (u->buf, "any") == 0) {
- protocol = AF_UNSPEC;
+ if (u->buf && strcasecmp (u->buf, "ipv4") == 0) {
+ protocol = AVAHI_PROTO_INET;
+ } else if (u->buf && strcasecmp (u->buf, "ipv6") == 0) {
+ protocol = AVAHI_PROTO_INET6;
+ } else if (u->buf && strcasecmp (u->buf, "any") == 0) {
+ protocol = AVAHI_PROTO_UNSPEC;
} else {
avahi_log_error("%s: parse failure: invalid protocol specification \"%s\".", u->group->filename, u->buf);
u->failed = 1;
}
u->service->protocol = protocol;
+ u->current_tag = XML_TAG_SERVICE;
break;
}