forked from conradev/Open
-
Notifications
You must be signed in to change notification settings - Fork 1
/
open.m
32 lines (24 loc) · 887 Bytes
/
open.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <CoreFoundation/CoreFoundation.h>
#include <stdio.h>
#import <rootless.h>
#ifndef SPRINGBOARDSERVICES_H_
extern int SBSLaunchApplicationWithIdentifier(CFStringRef identifier, Boolean suspended);
extern CFStringRef SBSApplicationLaunchingErrorString(int error);
#endif
int main(int argc, char **argv, char **envp)
{
int ret;
if (argc < 2) {
fprintf(stderr, "Usage: %s com.application.identifier \n", argv[0]);
return -1;
}
CFStringRef identifier = CFStringCreateWithCString(kCFAllocatorDefault, argv[1], kCFStringEncodingUTF8);
assert(identifier != NULL);
ret = SBSLaunchApplicationWithIdentifier(identifier, FALSE);
if (ret != 0) {
fprintf(stderr, "Couldn't open application: %s. Reason: %i, ", argv[1], ret);
CFShow(SBSApplicationLaunchingErrorString(ret));
}
CFRelease(identifier);
return ret;
}