]>
git.ipfire.org Git - thirdparty/cups.git/blob - tools/testbtmm.c
2 * Simple test program that lists the Back to My Mac domains on a Mac.
6 * clang -o testbtmm -g testbtmm.c -framework SystemConfiguration -framework CoreFoundation
10 #include <CoreFoundation/CoreFoundation.h>
11 #include <SystemConfiguration/SystemConfiguration.h>
15 * 'dnssdAddAlias()' - Add a DNS-SD alias name.
19 show_domain(const void *key
, /* I - Key */
20 const void *value
, /* I - Value (domain) */
21 void *context
) /* I - Unused */
23 char valueStr
[1024]; /* Domain string */
29 if (CFGetTypeID((CFStringRef
)value
) == CFStringGetTypeID() &&
30 CFStringGetCString((CFStringRef
)value
, valueStr
, sizeof(valueStr
),
31 kCFStringEncodingUTF8
))
32 printf("Back to My Mac domain: \"%s\"\n", valueStr
);
34 puts("Bad Back to My Mac domain in dynamic store.");
41 SCDynamicStoreRef sc
; /* Context for dynamic store */
42 CFDictionaryRef btmm
; /* Back-to-My-Mac domains */
45 sc
= SCDynamicStoreCreate(kCFAllocatorDefault
, CFSTR("cups"), NULL
, NULL
);
49 puts("Unable to open dynamic store.");
53 btmm
= SCDynamicStoreCopyValue(sc
, CFSTR("Setup:/Network/BackToMyMac"));
54 if (btmm
&& CFGetTypeID(btmm
) == CFDictionaryGetTypeID())
56 printf("%d Back to My Mac domains.\n", (int)CFDictionaryGetCount(btmm
));
57 CFDictionaryApplyFunction(btmm
, show_domain
, NULL
);
60 puts("Bad Back to My Mac data in dynamic store.");
62 puts("No Back to My Mac domains.");