You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Reduce C++ wizardry
This commit is contained in:
+10
-11
@@ -50,19 +50,18 @@ Available applets:
|
||||
}
|
||||
|
||||
int magisk_main(int argc, char *argv[]) {
|
||||
// using enum DAEMON_REQUEST;
|
||||
if (argc < 2)
|
||||
usage();
|
||||
if (argv[1] == "-c"sv) {
|
||||
printf(MAGISK_VERSION ":MAGISK (" str(MAGISK_VER_CODE) ")\n");
|
||||
return 0;
|
||||
} else if (argv[1] == "-v"sv) {
|
||||
int fd = connect_daemon(DaemonRequest::CHECK_VERSION);
|
||||
int fd = connect_daemon(MainRequest::CHECK_VERSION);
|
||||
string v = read_string(fd);
|
||||
printf("%s\n", v.data());
|
||||
return 0;
|
||||
} else if (argv[1] == "-V"sv) {
|
||||
int fd = connect_daemon(DaemonRequest::CHECK_VERSION_CODE);
|
||||
int fd = connect_daemon(MainRequest::CHECK_VERSION_CODE);
|
||||
printf("%d\n", read_int(fd));
|
||||
return 0;
|
||||
} else if (argv[1] == "--list"sv) {
|
||||
@@ -82,25 +81,25 @@ int magisk_main(int argc, char *argv[]) {
|
||||
cp_afc(argv[2], argv[3]);
|
||||
return 0;
|
||||
} else if (argv[1] == "--daemon"sv) {
|
||||
int fd = connect_daemon(DaemonRequest::START_DAEMON, true);
|
||||
int fd = connect_daemon(MainRequest::START_DAEMON, true);
|
||||
close(fd);
|
||||
return 0;
|
||||
} else if (argv[1] == "--stop"sv) {
|
||||
int fd = connect_daemon(DaemonRequest::STOP_DAEMON);
|
||||
int fd = connect_daemon(MainRequest::STOP_DAEMON);
|
||||
return read_int(fd);
|
||||
} else if (argv[1] == "--post-fs-data"sv) {
|
||||
int fd = connect_daemon(DaemonRequest::POST_FS_DATA, true);
|
||||
int fd = connect_daemon(MainRequest::POST_FS_DATA, true);
|
||||
return read_int(fd);
|
||||
} else if (argv[1] == "--service"sv) {
|
||||
int fd = connect_daemon(DaemonRequest::LATE_START, true);
|
||||
int fd = connect_daemon(MainRequest::LATE_START, true);
|
||||
return read_int(fd);
|
||||
} else if (argv[1] == "--boot-complete"sv) {
|
||||
int fd = connect_daemon(DaemonRequest::BOOT_COMPLETE, true);
|
||||
int fd = connect_daemon(MainRequest::BOOT_COMPLETE, true);
|
||||
return read_int(fd);
|
||||
} else if (argv[1] == "--denylist"sv) {
|
||||
return denylist_cli(argc - 1, argv + 1);
|
||||
} else if (argc >= 3 && argv[1] == "--sqlite"sv) {
|
||||
int fd = connect_daemon(DaemonRequest::SQLITE_CMD);
|
||||
int fd = connect_daemon(MainRequest::SQLITE_CMD);
|
||||
write_string(fd, argv[2]);
|
||||
string res;
|
||||
for (;;) {
|
||||
@@ -110,10 +109,10 @@ int magisk_main(int argc, char *argv[]) {
|
||||
printf("%s\n", res.data());
|
||||
}
|
||||
} else if (argv[1] == "--remove-modules"sv) {
|
||||
int fd = connect_daemon(DaemonRequest::REMOVE_MODULES);
|
||||
int fd = connect_daemon(MainRequest::REMOVE_MODULES);
|
||||
return read_int(fd);
|
||||
} else if (argv[1] == "--path"sv) {
|
||||
int fd = connect_daemon(DaemonRequest::GET_PATH);
|
||||
int fd = connect_daemon(MainRequest::GET_PATH);
|
||||
string path = read_string(fd);
|
||||
printf("%s\n", path.data());
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user