From afb5a5e80f8946dc4fb7d68d753ed3d0cd6bc877 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Thu, 18 Nov 2021 21:47:17 +0100 Subject: [PATCH] Rename adb functions to adb_exec_* This paves the way to replace them by more user-friendly functions that will call them internally. --- app/src/adb.c | 18 +++++++++--------- app/src/adb.h | 18 +++++++++--------- app/src/adb_tunnel.c | 8 ++++---- app/src/file_handler.c | 4 ++-- app/src/server.c | 4 ++-- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/app/src/adb.c b/app/src/adb.c index 3a5faed3..608abca1 100644 --- a/app/src/adb.c +++ b/app/src/adb.c @@ -148,8 +148,8 @@ adb_execute(const char *serial, const char *const adb_cmd[], size_t len) { } sc_pid -adb_forward(const char *serial, uint16_t local_port, - const char *device_socket_name) { +adb_exec_forward(const char *serial, uint16_t local_port, + const char *device_socket_name) { char local[4 + 5 + 1]; // tcp:PORT char remote[108 + 14 + 1]; // localabstract:NAME sprintf(local, "tcp:%" PRIu16, local_port); @@ -159,7 +159,7 @@ adb_forward(const char *serial, uint16_t local_port, } sc_pid -adb_forward_remove(const char *serial, uint16_t local_port) { +adb_exec_forward_remove(const char *serial, uint16_t local_port) { char local[4 + 5 + 1]; // tcp:PORT sprintf(local, "tcp:%" PRIu16, local_port); const char *const adb_cmd[] = {"forward", "--remove", local}; @@ -167,8 +167,8 @@ adb_forward_remove(const char *serial, uint16_t local_port) { } sc_pid -adb_reverse(const char *serial, const char *device_socket_name, - uint16_t local_port) { +adb_exec_reverse(const char *serial, const char *device_socket_name, + uint16_t local_port) { char local[4 + 5 + 1]; // tcp:PORT char remote[108 + 14 + 1]; // localabstract:NAME sprintf(local, "tcp:%" PRIu16, local_port); @@ -178,7 +178,7 @@ adb_reverse(const char *serial, const char *device_socket_name, } sc_pid -adb_reverse_remove(const char *serial, const char *device_socket_name) { +adb_exec_reverse_remove(const char *serial, const char *device_socket_name) { char remote[108 + 14 + 1]; // localabstract:NAME snprintf(remote, sizeof(remote), "localabstract:%s", device_socket_name); const char *const adb_cmd[] = {"reverse", "--remove", remote}; @@ -186,7 +186,7 @@ adb_reverse_remove(const char *serial, const char *device_socket_name) { } sc_pid -adb_push(const char *serial, const char *local, const char *remote) { +adb_exec_push(const char *serial, const char *local, const char *remote) { #ifdef __WINDOWS__ // Windows will parse the string, so the paths must be quoted // (see sys/win/command.c) @@ -213,7 +213,7 @@ adb_push(const char *serial, const char *local, const char *remote) { } sc_pid -adb_install(const char *serial, const char *local) { +adb_exec_install(const char *serial, const char *local) { #ifdef __WINDOWS__ // Windows will parse the string, so the local name must be quoted // (see sys/win/command.c) @@ -234,7 +234,7 @@ adb_install(const char *serial, const char *local) { } sc_pid -adb_get_serialno(sc_pipe *pout) { +adb_exec_get_serialno(sc_pipe *pout) { const char *const adb_cmd[] = {"get-serialno"}; return adb_execute_p(NULL, adb_cmd, ARRAY_LEN(adb_cmd), pout); } diff --git a/app/src/adb.h b/app/src/adb.h index 0107e6d4..c2c21343 100644 --- a/app/src/adb.h +++ b/app/src/adb.h @@ -16,24 +16,24 @@ adb_execute_p(const char *serial, const char *const adb_cmd[], size_t len, sc_pipe *pout); sc_pid -adb_forward(const char *serial, uint16_t local_port, - const char *device_socket_name); +adb_exec_forward(const char *serial, uint16_t local_port, + const char *device_socket_name); sc_pid -adb_forward_remove(const char *serial, uint16_t local_port); +adb_exec_forward_remove(const char *serial, uint16_t local_port); sc_pid -adb_reverse(const char *serial, const char *device_socket_name, - uint16_t local_port); +adb_exec_reverse(const char *serial, const char *device_socket_name, + uint16_t local_port); sc_pid -adb_reverse_remove(const char *serial, const char *device_socket_name); +adb_exec_reverse_remove(const char *serial, const char *device_socket_name); sc_pid -adb_push(const char *serial, const char *local, const char *remote); +adb_exec_push(const char *serial, const char *local, const char *remote); sc_pid -adb_install(const char *serial, const char *local); +adb_exec_install(const char *serial, const char *local); /** * Execute `adb get-serialno` @@ -41,6 +41,6 @@ adb_install(const char *serial, const char *local); * The result can be read from the output parameter `pout`. */ sc_pid -adb_get_serialno(sc_pipe *pout); +adb_exec_get_serialno(sc_pipe *pout); #endif diff --git a/app/src/adb_tunnel.c b/app/src/adb_tunnel.c index df5a3d1f..b5850bf8 100644 --- a/app/src/adb_tunnel.c +++ b/app/src/adb_tunnel.c @@ -12,13 +12,13 @@ static bool enable_tunnel_reverse(struct sc_intr *intr, const char *serial, uint16_t local_port) { - sc_pid pid = adb_reverse(serial, SC_SOCKET_NAME, local_port); + sc_pid pid = adb_exec_reverse(serial, SC_SOCKET_NAME, local_port); return sc_process_check_success_intr(intr, pid, "adb reverse", true); } static bool disable_tunnel_reverse(struct sc_intr *intr, const char *serial) { - sc_pid pid = adb_reverse_remove(serial, SC_SOCKET_NAME); + sc_pid pid = adb_exec_reverse_remove(serial, SC_SOCKET_NAME); return sc_process_check_success_intr(intr, pid, "adb reverse --remove", true); } @@ -26,14 +26,14 @@ disable_tunnel_reverse(struct sc_intr *intr, const char *serial) { static bool enable_tunnel_forward(struct sc_intr *intr, const char *serial, uint16_t local_port) { - sc_pid pid = adb_forward(serial, local_port, SC_SOCKET_NAME); + sc_pid pid = adb_exec_forward(serial, local_port, SC_SOCKET_NAME); return sc_process_check_success_intr(intr, pid, "adb forward", true); } static bool disable_tunnel_forward(struct sc_intr *intr, const char *serial, uint16_t local_port) { - sc_pid pid = adb_forward_remove(serial, local_port); + sc_pid pid = adb_exec_forward_remove(serial, local_port); return sc_process_check_success_intr(intr, pid, "adb forward --remove", true); } diff --git a/app/src/file_handler.c b/app/src/file_handler.c index d84ae4cb..f7c79cff 100644 --- a/app/src/file_handler.c +++ b/app/src/file_handler.c @@ -129,10 +129,10 @@ run_file_handler(void *data) { sc_pid pid; if (req.action == ACTION_INSTALL_APK) { LOGI("Installing %s...", req.file); - pid = adb_install(serial, req.file); + pid = adb_exec_install(serial, req.file); } else { LOGI("Pushing %s...", req.file); - pid = adb_push(serial, req.file, push_target); + pid = adb_exec_push(serial, req.file, push_target); } if (req.action == ACTION_INSTALL_APK) { diff --git a/app/src/server.c b/app/src/server.c index 5ad8d70f..6d535202 100644 --- a/app/src/server.c +++ b/app/src/server.c @@ -112,7 +112,7 @@ push_server(struct sc_intr *intr, const char *serial) { free(server_path); return false; } - sc_pid pid = adb_push(serial, server_path, SC_DEVICE_SERVER_PATH); + sc_pid pid = adb_exec_push(serial, server_path, SC_DEVICE_SERVER_PATH); free(server_path); return sc_process_check_success_intr(intr, pid, "adb push", true); } @@ -425,7 +425,7 @@ sc_server_on_terminated(void *userdata) { static char * sc_server_get_serialno(struct sc_intr *intr) { sc_pipe pout; - sc_pid pid = adb_get_serialno(&pout); + sc_pid pid = adb_exec_get_serialno(&pout); if (pid == SC_PROCESS_NONE) { return false; }