-
Notifications
You must be signed in to change notification settings - Fork 3
/
notifications.c
67 lines (61 loc) · 1.6 KB
/
notifications.c
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <mach/mach.h>
#include <bootstrap_priv.h>
#include "UNDRequest.h"
void usage() {
puts("TODO: usage.");
exit(0);
}
int main(int argc, const char *argv[]) {
int timeout = 0, ch;
unsigned flags = 0;
char *iconPath = NULL, *soundPath = NULL, *localizationPath = NULL, *header = NULL, *message = NULL, *defaultButtonTitle = NULL;
kern_return_t ret;
UNDServerRef UNDServer;
while ((ch = getopt(argc, (char *const *)argv, "t:f:i:s:l:h:m:d:")) != -1) {
switch(ch) {
case 't':
timeout = atoi(optarg);
break;
case 'f':
flags = (unsigned)atoi(optarg);
break;
case 'i':
iconPath = optarg;
break;
case 's':
soundPath = optarg;
break;
case 'l':
localizationPath = optarg;
break;
case 'h':
header = optarg;
break;
case 'm':
message = optarg;
break;
case 'd':
defaultButtonTitle = optarg;
break;
case '?':
default:
usage();
break;
}
}
ret = bootstrap_look_up2(bootstrap_port, "com.apple.system.Kernel[UNC]Notifications", &UNDServer, 0, 0);
if (ret) {
mach_error("bootstrap_look_up2", ret);
return ret;
}
ret = UNDDisplayNoticeSimple_rpc(UNDServer, timeout, flags, iconPath ?: "", soundPath ?: "", localizationPath ?: "", header ?: "", message ?: "", defaultButtonTitle ?: "");
if (ret) {
mach_error("UNDDisplayNoticeSimple_rpc", ret);
return ret;
}
mach_port_deallocate(mach_task_self(), UNDServer);
return 0;
}