-gint avahi_server_add_service_strlst(
- AvahiServer *s,
- AvahiEntryGroup *g,
- gint interface,
- guchar protocol,
- const gchar *name,
- const gchar *type,
- const gchar *domain,
- const gchar *host,
- guint16 port,
- AvahiStringList *strlst) {
-
- gchar ptr_name[256], svc_name[256], ename[64], enum_ptr[256];
- gchar *t, *d;
- AvahiRecord *r;
- gint ret = 0;
-
- g_assert(s);
- g_assert(type);
- g_assert(name);
-
- escape_service_name(ename, sizeof(ename), name);
-
- if (domain) {
- while (domain[0] == '.')
- domain++;
- } else
- domain = s->domain_name;
-
- if (!host)
- host = s->host_name_fqdn;
-
- d = avahi_normalize_name(domain);
- t = avahi_normalize_name(type);
-
- g_snprintf(ptr_name, sizeof(ptr_name), "%s.%s", t, d);
- g_snprintf(svc_name, sizeof(svc_name), "%s.%s.%s", ename, t, d);
-
- ret = avahi_server_add_ptr(s, g, interface, protocol, AVAHI_ENTRY_NULL, AVAHI_DEFAULT_TTL, ptr_name, svc_name);
-
- r = avahi_record_new_full(svc_name, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV, AVAHI_DEFAULT_TTL_HOST_NAME);
- r->data.srv.priority = 0;
- r->data.srv.weight = 0;
- r->data.srv.port = port;
- r->data.srv.name = avahi_normalize_name(host);
- ret |= avahi_server_add(s, g, interface, protocol, AVAHI_ENTRY_UNIQUE, r);
- avahi_record_unref(r);
-
- ret |= avahi_server_add_txt_strlst(s, g, interface, protocol, AVAHI_ENTRY_UNIQUE, AVAHI_DEFAULT_TTL, svc_name, strlst);
-
- g_snprintf(enum_ptr, sizeof(enum_ptr), "_services._dns-sd._udp.%s", d);
- ret |=avahi_server_add_ptr(s, g, interface, protocol, AVAHI_ENTRY_NULL, AVAHI_DEFAULT_TTL, enum_ptr, ptr_name);
-
- g_free(d);
- g_free(t);
-
- return ret;
-}