-AvahiServiceTypeBrowser *avahi_service_type_browser_new(AvahiServer *server, gint interface, guchar protocol, const gchar *domain, AvahiServiceTypeBrowserCallback callback, gpointer userdata) {
- AvahiServiceTypeBrowser *b;
- AvahiKey *k;
- gchar *n = NULL;
-
- g_assert(server);
- g_assert(callback);
+AvahiSServiceTypeBrowser *avahi_s_service_type_browser_new(
+ AvahiServer *server,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ const char *domain,
+ AvahiLookupFlags flags,
+ AvahiSServiceTypeBrowserCallback callback,
+ void* userdata) {
+
+ AvahiSServiceTypeBrowser *b;
+ AvahiKey *k = NULL;
+ char n[AVAHI_DOMAIN_NAME_MAX];
+ int r;
+
+ assert(server);
+ assert(callback);
+
+ AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_IF_VALID(interface), AVAHI_ERR_INVALID_INTERFACE);
+ AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
+ AVAHI_CHECK_VALIDITY_RETURN_NULL(server, !domain || avahi_is_valid_domain_name(domain), AVAHI_ERR_INVALID_DOMAIN_NAME);
+ AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
+
+ if (!domain)
+ domain = server->domain_name;
+
+ if ((r = avahi_service_name_join(n, sizeof(n), NULL, "_services._dns-sd._udp", domain)) < 0) {
+ avahi_server_set_errno(server, r);
+ return NULL;
+ }
+
+ if (!(b = avahi_new(AvahiSServiceTypeBrowser, 1))) {
+ avahi_server_set_errno(server, AVAHI_ERR_NO_MEMORY);
+ return NULL;
+ }