Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
185802fbe2 | ||
|
|
78f566bd6d |
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@@ -197,9 +198,9 @@ scrcpy_print_usage(const char *arg0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_integer_arg(const char *s, long *out, bool accept_suffix, long min,
|
parse_integer_arg(const char *s, long long *out, bool accept_suffix,
|
||||||
long max, const char *name) {
|
long long min, long long max, const char *name) {
|
||||||
long value;
|
long long value;
|
||||||
bool ok;
|
bool ok;
|
||||||
if (accept_suffix) {
|
if (accept_suffix) {
|
||||||
ok = parse_integer_with_suffix(s, &value);
|
ok = parse_integer_with_suffix(s, &value);
|
||||||
@@ -212,8 +213,8 @@ parse_integer_arg(const char *s, long *out, bool accept_suffix, long min,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (value < min || value > max) {
|
if (value < min || value > max) {
|
||||||
LOGE("Could not parse %s: value (%ld) out-of-range (%ld; %ld)",
|
LOGE("Could not parse %s: value (%" PRIlld ") out-of-range (%"
|
||||||
name, value, min, max);
|
PRIlld "; %" PRIlld ")", name, value, min, max);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,10 +224,8 @@ parse_integer_arg(const char *s, long *out, bool accept_suffix, long min,
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_bit_rate(const char *s, uint32_t *bit_rate) {
|
parse_bit_rate(const char *s, uint32_t *bit_rate) {
|
||||||
long value;
|
long long value;
|
||||||
// long may be 32 bits (it is the case on mingw), so do not use more than
|
bool ok = parse_integer_arg(s, &value, true, 0, 0xFFFFFFFFLL, "bit-rate");
|
||||||
// 31 bits (long is signed)
|
|
||||||
bool ok = parse_integer_arg(s, &value, true, 0, 0x7FFFFFFF, "bit-rate");
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -237,7 +236,7 @@ parse_bit_rate(const char *s, uint32_t *bit_rate) {
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_max_size(const char *s, uint16_t *max_size) {
|
parse_max_size(const char *s, uint16_t *max_size) {
|
||||||
long value;
|
long long value;
|
||||||
bool ok = parse_integer_arg(s, &value, false, 0, 0xFFFF, "max size");
|
bool ok = parse_integer_arg(s, &value, false, 0, 0xFFFF, "max size");
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return false;
|
return false;
|
||||||
@@ -249,7 +248,7 @@ parse_max_size(const char *s, uint16_t *max_size) {
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_max_fps(const char *s, uint16_t *max_fps) {
|
parse_max_fps(const char *s, uint16_t *max_fps) {
|
||||||
long value;
|
long long value;
|
||||||
bool ok = parse_integer_arg(s, &value, false, 0, 1000, "max fps");
|
bool ok = parse_integer_arg(s, &value, false, 0, 1000, "max fps");
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return false;
|
return false;
|
||||||
@@ -261,7 +260,7 @@ parse_max_fps(const char *s, uint16_t *max_fps) {
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_window_position(const char *s, int16_t *position) {
|
parse_window_position(const char *s, int16_t *position) {
|
||||||
long value;
|
long long value;
|
||||||
bool ok = parse_integer_arg(s, &value, false, -1, 0x7FFF,
|
bool ok = parse_integer_arg(s, &value, false, -1, 0x7FFF,
|
||||||
"window position");
|
"window position");
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
@@ -274,7 +273,7 @@ parse_window_position(const char *s, int16_t *position) {
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_window_dimension(const char *s, uint16_t *dimension) {
|
parse_window_dimension(const char *s, uint16_t *dimension) {
|
||||||
long value;
|
long long value;
|
||||||
bool ok = parse_integer_arg(s, &value, false, 0, 0xFFFF,
|
bool ok = parse_integer_arg(s, &value, false, 0, 0xFFFF,
|
||||||
"window dimension");
|
"window dimension");
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
@@ -287,7 +286,7 @@ parse_window_dimension(const char *s, uint16_t *dimension) {
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_port(const char *s, uint16_t *port) {
|
parse_port(const char *s, uint16_t *port) {
|
||||||
long value;
|
long long value;
|
||||||
bool ok = parse_integer_arg(s, &value, false, 0, 0xFFFF, "port");
|
bool ok = parse_integer_arg(s, &value, false, 0, 0xFFFF, "port");
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -4,38 +4,8 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
// not needed here, but winsock2.h must never be included AFTER windows.h
|
|
||||||
# include <winsock2.h>
|
|
||||||
# include <windows.h>
|
|
||||||
# define PATH_SEPARATOR '\\'
|
|
||||||
# define PRIexitcode "lu"
|
|
||||||
// <https://stackoverflow.com/a/44383330/1987178>
|
|
||||||
# ifdef _WIN64
|
|
||||||
# define PRIsizet PRIu64
|
|
||||||
# else
|
|
||||||
# define PRIsizet PRIu32
|
|
||||||
# endif
|
|
||||||
# define PROCESS_NONE NULL
|
|
||||||
# define NO_EXIT_CODE -1u // max value as unsigned
|
|
||||||
typedef HANDLE process_t;
|
|
||||||
typedef DWORD exit_code_t;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
# include <sys/types.h>
|
|
||||||
# define PATH_SEPARATOR '/'
|
|
||||||
# define PRIsizet "zu"
|
|
||||||
# define PRIexitcode "d"
|
|
||||||
# define PROCESS_NONE -1
|
|
||||||
# define NO_EXIT_CODE -1
|
|
||||||
typedef pid_t process_t;
|
|
||||||
typedef int exit_code_t;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
enum process_result {
|
enum process_result {
|
||||||
PROCESS_SUCCESS,
|
PROCESS_SUCCESS,
|
||||||
|
|||||||
@@ -5,6 +5,44 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
// not needed here, but winsock2.h must never be included AFTER windows.h
|
||||||
|
# include <winsock2.h>
|
||||||
|
# include <windows.h>
|
||||||
|
# define PATH_SEPARATOR '\\'
|
||||||
|
# define PRIexitcode "lu"
|
||||||
|
// <https://stackoverflow.com/a/44383330/1987178>
|
||||||
|
# ifdef _WIN64
|
||||||
|
# define PRIsizet PRIu64
|
||||||
|
# else
|
||||||
|
# define PRIsizet PRIu32
|
||||||
|
# endif
|
||||||
|
# define PROCESS_NONE NULL
|
||||||
|
# define NO_EXIT_CODE -1u // max value as unsigned
|
||||||
|
typedef HANDLE process_t;
|
||||||
|
typedef DWORD exit_code_t;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
# include <sys/types.h>
|
||||||
|
# define PATH_SEPARATOR '/'
|
||||||
|
# define PRIsizet "zu"
|
||||||
|
# define PRIexitcode "d"
|
||||||
|
# define PROCESS_NONE -1
|
||||||
|
# define NO_EXIT_CODE -1
|
||||||
|
typedef pid_t process_t;
|
||||||
|
typedef int exit_code_t;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// in MinGW, "%ll" is not supported as printf format for long long
|
||||||
|
# ifdef __MINGW32__
|
||||||
|
# define PRIlld "I64d"
|
||||||
|
# else
|
||||||
|
# define PRIlld "lld"
|
||||||
|
# endif
|
||||||
|
|
||||||
#define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
|
#define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
|
||||||
#define MIN(X,Y) (X) < (Y) ? (X) : (Y)
|
#define MIN(X,Y) (X) < (Y) ? (X) : (Y)
|
||||||
#define MAX(X,Y) (X) > (Y) ? (X) : (Y)
|
#define MAX(X,Y) (X) > (Y) ? (X) : (Y)
|
||||||
|
|||||||
@@ -63,13 +63,13 @@ strquote(const char *src) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
parse_integer(const char *s, long *out) {
|
parse_integer(const char *s, long long *out) {
|
||||||
char *endptr;
|
char *endptr;
|
||||||
if (*s == '\0') {
|
if (*s == '\0') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
errno = 0;
|
errno = 0;
|
||||||
long value = strtol(s, &endptr, 0);
|
long long value = strtol(s, &endptr, 0);
|
||||||
if (errno == ERANGE) {
|
if (errno == ERANGE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -82,13 +82,13 @@ parse_integer(const char *s, long *out) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
parse_integer_with_suffix(const char *s, long *out) {
|
parse_integer_with_suffix(const char *s, long long *out) {
|
||||||
char *endptr;
|
char *endptr;
|
||||||
if (*s == '\0') {
|
if (*s == '\0') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
errno = 0;
|
errno = 0;
|
||||||
long value = strtol(s, &endptr, 0);
|
long long value = strtoll(s, &endptr, 0);
|
||||||
if (errno == ERANGE) {
|
if (errno == ERANGE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -106,8 +106,8 @@ parse_integer_with_suffix(const char *s, long *out) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((value < 0 && LONG_MIN / mul > value) ||
|
if ((value < 0 && LLONG_MIN / mul > value) ||
|
||||||
(value > 0 && LONG_MAX / mul < value)) {
|
(value > 0 && LLONG_MAX / mul < value)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,14 +29,14 @@ strquote(const char *src);
|
|||||||
// parse s as an integer into value
|
// parse s as an integer into value
|
||||||
// returns true if the conversion succeeded, false otherwise
|
// returns true if the conversion succeeded, false otherwise
|
||||||
bool
|
bool
|
||||||
parse_integer(const char *s, long *out);
|
parse_integer(const char *s, long long *out);
|
||||||
|
|
||||||
// parse s as an integer into value
|
// parse s as an integer into value
|
||||||
// like parse_integer(), but accept 'k'/'K' (x1000) and 'm'/'M' (x1000000) as
|
// like parse_integer(), but accept 'k'/'K' (x1000) and 'm'/'M' (x1000000) as
|
||||||
// suffix
|
// suffix
|
||||||
// returns true if the conversion succeeded, false otherwise
|
// returns true if the conversion succeeded, false otherwise
|
||||||
bool
|
bool
|
||||||
parse_integer_with_suffix(const char *s, long *out);
|
parse_integer_with_suffix(const char *s, long long *out);
|
||||||
|
|
||||||
// return the index to truncate a UTF-8 string at a valid position
|
// return the index to truncate a UTF-8 string at a valid position
|
||||||
size_t
|
size_t
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ static void test_utf8_truncate(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void test_parse_integer(void) {
|
static void test_parse_integer(void) {
|
||||||
long value;
|
long long value;
|
||||||
bool ok = parse_integer("1234", &value);
|
bool ok = parse_integer("1234", &value);
|
||||||
assert(ok);
|
assert(ok);
|
||||||
assert(value == 1234);
|
assert(value == 1234);
|
||||||
@@ -188,7 +188,7 @@ static void test_parse_integer(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void test_parse_integer_with_suffix(void) {
|
static void test_parse_integer_with_suffix(void) {
|
||||||
long value;
|
long long value;
|
||||||
bool ok = parse_integer_with_suffix("1234", &value);
|
bool ok = parse_integer_with_suffix("1234", &value);
|
||||||
assert(ok);
|
assert(ok);
|
||||||
assert(value == 1234);
|
assert(value == 1234);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
project('scrcpy', 'c',
|
project('scrcpy', 'c',
|
||||||
version: '1.12.1',
|
version: '1.12',
|
||||||
meson_version: '>= 0.37',
|
meson_version: '>= 0.37',
|
||||||
default_options: [
|
default_options: [
|
||||||
'c_std=c11',
|
'c_std=c11',
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ android {
|
|||||||
applicationId "com.genymobile.scrcpy"
|
applicationId "com.genymobile.scrcpy"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 14
|
versionCode 13
|
||||||
versionName "1.12.1"
|
versionName "1.12"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
SCRCPY_DEBUG=false
|
SCRCPY_DEBUG=false
|
||||||
SCRCPY_VERSION_NAME=1.12.1
|
SCRCPY_VERSION_NAME=1.12
|
||||||
|
|
||||||
PLATFORM=${ANDROID_PLATFORM:-29}
|
PLATFORM=${ANDROID_PLATFORM:-29}
|
||||||
BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-29.0.2}
|
BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-29.0.2}
|
||||||
|
|||||||
Reference in New Issue
Block a user