diff --git a/app/src/cli.c b/app/src/cli.c index f3b4d427..6dc1e9fe 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -458,9 +458,9 @@ guess_record_format(const char *filename) { char** str_split(const char *a_str, const char a_delim) { - char** result = 0; + char **result = 0; size_t count = 0; - char* tmp = (char*)a_str; + char *tmp = (char*)a_str; char str[100]; strncpy(str, a_str, sizeof(str)); char* last_comma = 0; @@ -480,8 +480,8 @@ str_split(const char *a_str, const char a_delim) { /* Add space for trailing token. */ count += last_comma < (str + strlen(str) - 1); - /* Add space for terminating null string so caller - knows where the list of returned strings ends. */ + /* Add space for terminating null string so caller + knows where the list of returned strings ends. */ count++; result = malloc(sizeof(char*) * count); @@ -506,7 +506,7 @@ str_split(const char *a_str, const char a_delim) { bool check_if_ip_valid(char *ip) { int num, dots = 0; - char* ptr; + char *ptr; if (ip == NULL) return 0; @@ -539,9 +539,9 @@ check_if_ip_valid(char *ip) { uint32_t convert_ip_to_int(char* ip_string) { int num, dots = 0; - char* ptr; + char *ptr; - char* ip = "0x"; + char *ip = "0x"; ptr = strtok(ip_string, "."); //Cut the string using dot as delimiter @@ -566,12 +566,12 @@ parse_serve_args(const char *optarg, char **s_protocol, uint32_t *s_ip, uint16_t bool ip_valid = false; bool port_valid = false; - char* protocol = NULL; - char* ip = NULL; + char *protocol = NULL; + char *ip = NULL; uint32_t ip_value; - char* port = NULL; - - char** values; + char *port = NULL; + char **values; + values = str_split(optarg, ':'); if (values) { @@ -755,8 +755,7 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) { case OPT_SERVE: if (!parse_serve_args(optarg, &opts->serve_protocol, &opts->serve_ip, &opts->serve_port)) { return false; - } - else { + } else { opts->serve = true; } break; diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index f46366c8..f27d733b 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -309,7 +309,7 @@ scrcpy(const struct scrcpy_options *options) { } } - if (!server_start(&server, options->serial, ¶ms, serv)) { + if (!server_start(&server, options->serial, ¶ms)) { return false; } diff --git a/app/src/serve.c b/app/src/serve.c index 2acabae7..50b45775 100644 --- a/app/src/serve.c +++ b/app/src/serve.c @@ -13,7 +13,7 @@ # define SOCKET_ERROR (-1) void -serve_init(struct serve* serve, char *protocol, uint32_t ip, uint16_t port) { +serve_init(struct serve *serve, char *protocol, uint32_t ip, uint16_t port) { serve->protocol = protocol; serve->ip = ip; serve->port = port; @@ -21,7 +21,7 @@ serve_init(struct serve* serve, char *protocol, uint32_t ip, uint16_t port) { } bool -serve_start(struct serve* serve) { +serve_start(struct serve *serve) { LOGD("Starting serve thread"); socket_t Listensocket; @@ -53,7 +53,7 @@ serve_start(struct serve* serve) { } bool -serve_push(struct serve* serve, const AVPacket *packet) { +serve_push(struct serve *serve, const AVPacket *packet) { if (serve->isServeReady) { if (net_send(serve->socket, packet->data, packet->size) == SOCKET_ERROR) { @@ -68,6 +68,6 @@ serve_push(struct serve* serve, const AVPacket *packet) { } void -serve_stop(struct serve* serve) { +serve_stop(struct serve *serve) { net_close(serve->socket); } \ No newline at end of file diff --git a/app/src/serve.h b/app/src/serve.h index ef3b57e3..5643e890 100644 --- a/app/src/serve.h +++ b/app/src/serve.h @@ -19,14 +19,14 @@ struct serve { }; void -serve_init(struct serve* serve, char* protocol, uint32_t ip, uint16_t port); +serve_init(struct serve *serve, char *protocol, uint32_t ip, uint16_t port); bool -serve_start(struct serve* serve); +serve_start(struct serve *serve); bool -serve_push(struct serve* serve, const AVPacket *packet); +serve_push(struct serve *serve, const AVPacket *packet); void -serve_stop(struct serve* serve); +serve_stop(struct serve *serve); #endif \ No newline at end of file diff --git a/app/src/server.c b/app/src/server.c index 1672a23f..64f71ae2 100644 --- a/app/src/server.c +++ b/app/src/server.c @@ -350,7 +350,7 @@ run_wait_server(void *data) { bool server_start(struct server *server, const char *serial, - const struct server_params *params, struct serve* serve) { + const struct server_params *params) { server->port_range = params->port_range; if (serial) { @@ -368,22 +368,10 @@ server_start(struct server *server, const char *serial, goto error1; } - /*server->serve = serve; - if (server->serve) { - if (server->serve->isServeReady == true) { - server->process = execute_server(server, params); - if (server->process == PROCESS_NONE) { - goto error2; - } - } + server->process = execute_server(server, params); + if (server->process == PROCESS_NONE) { + goto error2; } - else {*/ - // server will connect to our server socket - server->process = execute_server(server, params); - if (server->process == PROCESS_NONE) { - goto error2; - } - //} // If the server process dies before connecting to the server socket, then // the client will be stuck forever on accept(). To avoid the problem, we diff --git a/app/src/server.h b/app/src/server.h index c9b21340..5b7ce9b1 100644 --- a/app/src/server.h +++ b/app/src/server.h @@ -61,7 +61,7 @@ server_init(struct server *server); // push, enable tunnel et start the server bool server_start(struct server *server, const char *serial, - const struct server_params *params, struct serve* serve); + const struct server_params *params); // block until the communication with the server is established bool