mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-20 19:45:00 +00:00
Cleaning code for pull request
This commit is contained in:
parent
f1fafa506d
commit
1e607c6445
6 changed files with 27 additions and 40 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue