1 #import <GraphicsServices/GraphicsServices.h>
2 #import <UIKit/UIKit.h>
6 static CFArrayRef (*$GSSystemCopyCapability)(CFStringRef);
7 static CFArrayRef (*$GSSystemGetCapability)(CFStringRef);
9 void OnGSCapabilityChanged(
10 CFNotificationCenterRef center,
16 CFRunLoopStop(CFRunLoopGetCurrent());
19 int main(int argc, char *argv[]) {
20 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
25 name = [NSString stringWithUTF8String:argv[0]];
27 fprintf(stderr, "usage: %s [capability]\n", argv[0]);
31 $GSSystemCopyCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability"));
32 $GSSystemGetCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemGetCapability"));
34 CFNotificationCenterAddObserver(
35 CFNotificationCenterGetDarwinNotifyCenter(),
37 &OnGSCapabilityChanged,
38 CFSTR("GSCapabilitiesChanged"),
43 const NSArray *capability;
46 if ($GSSystemCopyCapability != NULL) {
47 capability = reinterpret_cast<const NSArray *>((*$GSSystemCopyCapability)(reinterpret_cast<CFStringRef>(name)));
48 if (capability != nil)
49 capability = [capability autorelease];
50 } else if ($GSSystemGetCapability != NULL) {
51 capability = reinterpret_cast<const NSArray *>((*$GSSystemGetCapability)(reinterpret_cast<CFStringRef>(name)));
57 if (capability != nil)
63 NSLog(@"%@", capability);
65 /*for (NSString *value in capability)
66 printf("%s\n", [value UTF8String]);*/