Rename maximum_size to max_size

The long option is --max-size, so for consistency, adapt the code
accordingly.
This commit is contained in:
Romain Vimont
2018-02-01 12:18:06 +01:00
parent 213b721ff9
commit ee93f3f23a
8 changed files with 30 additions and 28 deletions

View File

@@ -6,11 +6,12 @@
#include <SDL2/SDL.h>
#define DEFAULT_LOCAL_PORT 27183
#define DEFAULT_MAX_SIZE 0
struct args {
const char *serial;
Uint16 port;
Uint16 maximum_size;
Uint16 max_size;
};
static int parse_args(struct args *args, int argc, char *argv[]) {
@@ -40,14 +41,14 @@ static int parse_args(struct args *args, int argc, char *argv[]) {
char *endptr;
long value = strtol(optarg, &endptr, 0);
if (*optarg == '\0' || *endptr != '\0') {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid maximum size: %s\n", optarg);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid max size: %s\n", optarg);
return -1;
}
if (value & ~0xffff) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Maximum size must be between 0 and 65535: %ld\n", value);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Max size must be between 0 and 65535: %ld\n", value);
return -1;
}
args->maximum_size = (Uint16) value;
args->max_size = (Uint16) value;
break;
}
default:
@@ -72,6 +73,7 @@ int main(int argc, char *argv[]) {
struct args args = {
.serial = NULL,
.max_size = DEFAULT_MAX_SIZE,
.port = DEFAULT_LOCAL_PORT,
};
if (parse_args(&args, argc, argv)) {
@@ -86,7 +88,7 @@ int main(int argc, char *argv[]) {
SDL_LogSetAllPriority(SDL_LOG_PRIORITY_DEBUG);
res = scrcpy(args.serial, args.port, args.maximum_size) ? 0 : 1;
res = scrcpy(args.serial, args.port, args.max_size) ? 0 : 1;
avformat_network_deinit(); // ignore failure

View File

@@ -382,7 +382,7 @@ void event_loop(void) {
}
}
SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 maximum_size) {
SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 max_size) {
SDL_bool ret = 0;
process_t push_proc = push_server(serial);
@@ -402,7 +402,7 @@ SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 maximum_size) {
}
// server will connect to our socket
process_t server = start_server(serial, maximum_size);
process_t server = start_server(serial, max_size);
if (server == PROCESS_NONE) {
ret = SDL_FALSE;
SDLNet_TCP_Close(server_socket);

View File

@@ -3,6 +3,6 @@
#include <SDL2/SDL_stdinc.h>
SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 maximum_size);
SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 max_size);
#endif

View File

@@ -21,16 +21,16 @@ process_t disable_tunnel(const char *serial) {
return adb_reverse_remove(serial, SOCKET_NAME);
}
process_t start_server(const char *serial, Uint16 maximum_size) {
char maximum_size_string[6];
sprintf(maximum_size_string, "%d", maximum_size);
process_t start_server(const char *serial, Uint16 max_size) {
char max_size_string[6];
sprintf(max_size_string, "%d", max_size);
const char *const cmd[] = {
"shell",
"CLASSPATH=/data/local/tmp/scrcpy.apk",
"app_process",
"/", // unused
"com.genymobile.scrcpy.ScrCpyServer",
maximum_size_string,
max_size_string,
};
return adb_execute(serial, cmd, sizeof(cmd) / sizeof(cmd[0]));
}

View File

@@ -4,5 +4,5 @@ process_t push_server(const char *serial);
process_t enable_tunnel(const char *serial, Uint16 local_port);
process_t disable_tunnel(const char *serial);
process_t start_server(const char *serial, Uint16 maximum_size);
process_t start_server(const char *serial, Uint16 max_size);
void stop_server(process_t server);