]> git.saurik.com Git - uikittools.git/blame - gssc.mm
We need to kill installd in order for uicache to work.
[uikittools.git] / gssc.mm
CommitLineData
020dfc54
JF
1#import <GraphicsServices/GraphicsServices.h>
2#import <UIKit/UIKit.h>
3#include <stdio.h>
4#include <dlfcn.h>
5
6static CFArrayRef (*$GSSystemCopyCapability)(CFStringRef);
7static CFArrayRef (*$GSSystemGetCapability)(CFStringRef);
8
04ee9f37
JF
9void OnGSCapabilityChanged(
10 CFNotificationCenterRef center,
11 void *observer,
12 CFStringRef name,
13 const void *object,
14 CFDictionaryRef info
15) {
16 CFRunLoopStop(CFRunLoopGetCurrent());
17}
18
020dfc54
JF
19int 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
04ee9f37
JF
34 CFNotificationCenterAddObserver(
35 CFNotificationCenterGetDarwinNotifyCenter(),
36 NULL,
37 &OnGSCapabilityChanged,
38 CFSTR("GSCapabilitiesChanged"),
39 NULL,
40 NULL
41 );
42
020dfc54
JF
43 const NSArray *capability;
44
04ee9f37
JF
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 }
020dfc54
JF
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}