]> git.saurik.com Git - uikittools.git/blob - gssc.mm
Add cfversion.
[uikittools.git] / gssc.mm
1 #import <GraphicsServices/GraphicsServices.h>
2 #import <UIKit/UIKit.h>
3 #include <stdio.h>
4 #include <dlfcn.h>
5
6 static CFArrayRef (*$GSSystemCopyCapability)(CFStringRef);
7 static CFArrayRef (*$GSSystemGetCapability)(CFStringRef);
8
9 void OnGSCapabilityChanged(
10 CFNotificationCenterRef center,
11 void *observer,
12 CFStringRef name,
13 const void *object,
14 CFDictionaryRef info
15 ) {
16 CFRunLoopStop(CFRunLoopGetCurrent());
17 }
18
19 int main(int argc, char *argv[]) {
20 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
21
22 NSString *name = nil;
23
24 if (argc == 2)
25 name = [NSString stringWithUTF8String:argv[0]];
26 else if (argc > 2) {
27 fprintf(stderr, "usage: %s [capability]\n", argv[0]);
28 exit(1);
29 }
30
31 $GSSystemCopyCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemCopyCapability"));
32 $GSSystemGetCapability = reinterpret_cast<CFArrayRef (*)(CFStringRef)>(dlsym(RTLD_DEFAULT, "GSSystemGetCapability"));
33
34 CFNotificationCenterAddObserver(
35 CFNotificationCenterGetDarwinNotifyCenter(),
36 NULL,
37 &OnGSCapabilityChanged,
38 CFSTR("GSCapabilitiesChanged"),
39 NULL,
40 NULL
41 );
42
43 const NSArray *capability;
44
45 for (;;) {
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)));
52 } else {
53 capability = nil;
54 break;
55 }
56
57 if (capability != nil)
58 break;
59
60 CFRunLoopRun();
61 }
62
63 NSLog(@"%@", capability);
64
65 /*for (NSString *value in capability)
66 printf("%s\n", [value UTF8String]);*/
67
68 [pool release];
69
70 return 0;
71 }