]> git.meshlink.io Git - catta/blobdiff - examples/client-publish-service.c
* Add custom user-specific configure flags to bootstrap.sh
[catta] / examples / client-publish-service.c
index 9b12f5c73636b3055654807804a5b03d622069c0..e9dcffca8a6aa522db36d55e380ddbf649bcd69f 100644 (file)
@@ -29,6 +29,8 @@
 #include <assert.h>
 
 #include <avahi-client/client.h>
+#include <avahi-client/publish.h>
+
 #include <avahi-common/alternative.h>
 #include <avahi-common/simple-watch.h>
 #include <avahi-common/malloc.h>
@@ -83,17 +85,23 @@ static void create_services(AvahiClient *c) {
     snprintf(r, sizeof(r), "random=%i", rand());
 
     /* Add the service for IPP */
-    if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, name, "_ipp._tcp", NULL, NULL, 651, "test=blah", r, NULL)) < 0) {
+    if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, "_ipp._tcp", NULL, NULL, 651, "test=blah", r, NULL)) < 0) {
         fprintf(stderr, "Failed to add _ipp._tcp service: %s\n", avahi_strerror(ret));
         goto fail;
     }
 
     /* Add the same service for BSD LPR */
-    if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, name, "_printer._tcp", NULL, NULL, 515, NULL)) < 0) {
+    if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, "_printer._tcp", NULL, NULL, 515, NULL)) < 0) {
         fprintf(stderr, "Failed to add _printer._tcp service: %s\n", avahi_strerror(ret));
         goto fail;
     }
 
+    /* Add an additional (hypothetic) subtype */
+    if ((ret = avahi_entry_group_add_service_subtype(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, "_printer._tcp", NULL, "_magic._sub._printer._tcp") < 0)) {
+        fprintf(stderr, "Failed to add subtype _magic._sub._printer._tcp: %s\n", avahi_strerror(ret));
+        goto fail;
+    }
+    
     /* Tell the server to register the service */
     if ((ret = avahi_entry_group_commit(group)) < 0) {
         fprintf(stderr, "Failed to commit entry_group: %s\n", avahi_strerror(ret));