]>
git.saurik.com Git - uikittools.git/blob - ldrestart.cpp
1 /* Cydia - iPhone UIKit Front-End for Debian APT
2 * Copyright (C) 2008-2015 Jay Freeman (saurik)
5 /* GNU General Public License, Version 3 {{{ */
7 * Cydia is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation, either version 3 of the License,
10 * or (at your option) any later version.
12 * Cydia is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Cydia. If not, see <http://www.gnu.org/licenses/>.
34 void process(launch_data_t value
, const char *name
, void *baton
) {
35 if (launch_data_get_type(value
) != LAUNCH_DATA_DICTIONARY
)
38 auto integer(launch_data_dict_lookup(value
, LAUNCH_JOBKEY_PID
));
39 if (integer
== NULL
|| launch_data_get_type(integer
) != LAUNCH_DATA_INTEGER
)
42 auto pid(launch_data_get_integer(integer
));
43 if (kill(pid
, 0) == -1)
46 auto string(launch_data_dict_lookup(value
, LAUNCH_JOBKEY_LABEL
));
47 if (string
== NULL
|| launch_data_get_type(string
) != LAUNCH_DATA_STRING
)
49 auto label(launch_data_get_string(string
));
51 auto stop(launch_data_alloc(LAUNCH_DATA_DICTIONARY
));
52 launch_data_dict_insert(stop
, string
, LAUNCH_KEY_STOPJOB
);
54 auto result(launch_msg(stop
));
55 launch_data_free(stop
);
59 if (launch_data_get_type(result
) != LAUNCH_DATA_ERRNO
)
60 fprintf(stderr
, "%s\n", label
);
61 else if (auto number
= launch_data_get_errno(result
))
62 fprintf(stderr
, "%s: %s\n", label
, strerror(number
));
64 launch_data_free(result
);
67 int main(int argc
, char *argv
[]) {
68 auto request(launch_data_new_string(LAUNCH_KEY_GETJOBS
));
69 auto response(launch_msg(request
));
70 launch_data_free(request
);
73 return EX_UNAVAILABLE
;
74 if (launch_data_get_type(response
) != LAUNCH_DATA_DICTIONARY
)
77 launch_data_dict_iterate(response
, &process
, NULL
);