mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-04 17:57:39 +00:00
Directly print output over socket
This commit is contained in:
parent
77fd5fa7de
commit
ba70269398
@ -247,10 +247,11 @@ bool init_list() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ls_list(int client) {
|
void ls_list(int client) {
|
||||||
write_int(client, DAEMON_SUCCESS);
|
FILE *out = fdopen(recv_fd(client), "a");
|
||||||
write_int(client, hide_list.size());
|
|
||||||
for (auto &s : hide_list)
|
for (auto &s : hide_list)
|
||||||
write_string(client, s);
|
fprintf(out, "%s\n", s.c_str());
|
||||||
|
fclose(out);
|
||||||
|
write_int(client, DAEMON_SUCCESS);
|
||||||
close(client);
|
close(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +97,8 @@ int magiskhide_main(int argc, char *argv[]) {
|
|||||||
write_int(fd, req);
|
write_int(fd, req);
|
||||||
if (req == ADD_HIDELIST || req == RM_HIDELIST)
|
if (req == ADD_HIDELIST || req == RM_HIDELIST)
|
||||||
write_string(fd, argv[2]);
|
write_string(fd, argv[2]);
|
||||||
|
if (req == LS_HIDELIST)
|
||||||
|
send_fd(fd, STDOUT_FILENO);
|
||||||
|
|
||||||
// Get response
|
// Get response
|
||||||
int code = read_int(fd);
|
int code = read_int(fd);
|
||||||
@ -129,15 +131,5 @@ int magiskhide_main(int argc, char *argv[]) {
|
|||||||
return DAEMON_ERROR;
|
return DAEMON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code == DAEMON_SUCCESS && req == LS_HIDELIST) {
|
|
||||||
int cnt = read_int(fd);
|
|
||||||
for (int i = 0; i < cnt; ++i) {
|
|
||||||
char *s = read_string(fd);
|
|
||||||
printf("%s\n", s);
|
|
||||||
free(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
return req == HIDE_STATUS ? (code == HIDE_IS_ENABLED ? 0 : 1) : code != DAEMON_SUCCESS;
|
return req == HIDE_STATUS ? (code == HIDE_IS_ENABLED ? 0 : 1) : code != DAEMON_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user