]>
git.saurik.com Git - cydia.git/blob - cydo.cpp
49e419a6e7f422d128bed908572b0359cb7f9368
10 #include <Menes/Function.h>
12 typedef Function
<void, const char *, launch_data_t
> LaunchDataIterator
;
14 void launch_data_dict_iterate(launch_data_t data
, LaunchDataIterator code
) {
15 launch_data_dict_iterate(data
, [](launch_data_t value
, const char *name
, void *baton
) {
16 (*static_cast<LaunchDataIterator
*>(baton
))(name
, value
);
20 int main(int argc
, char *argv
[]) {
21 auto request(launch_data_new_string(LAUNCH_KEY_GETJOBS
));
22 auto response(launch_msg(request
));
23 launch_data_free(request
);
25 _assert(response
!= NULL
);
26 _assert(launch_data_get_type(response
) == LAUNCH_DATA_DICTIONARY
);
28 int parent(getppid());
32 launch_data_dict_iterate(response
, [=, &cydia
](const char *name
, launch_data_t value
) {
33 if (launch_data_get_type(response
) != LAUNCH_DATA_DICTIONARY
)
36 auto integer(launch_data_dict_lookup(value
, LAUNCH_JOBKEY_PID
));
37 if (integer
== NULL
|| launch_data_get_type(integer
) != LAUNCH_DATA_INTEGER
)
40 auto pid(launch_data_get_integer(integer
));
44 auto string(launch_data_dict_lookup(value
, LAUNCH_JOBKEY_PROGRAM
));
45 if (string
== NULL
|| launch_data_get_type(string
) != LAUNCH_DATA_STRING
)
48 auto program(launch_data_get_string(string
));
52 if (strcmp(program
, "/Applications/Cydia.app/Cydia") == 0)
57 fprintf(stderr
, "thou shalt not pass\n");
64 if (argc
< 2 || argv
[1][0] != '/')
65 argv
[0] = "/usr/bin/dpkg";
72 return EX_UNAVAILABLE
;