mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-31 14:45:54 +00:00
Serialize text size on 4 bytes
This will allow to send text having a size greater than 65535 bytes.
This commit is contained in:
parent
d91c5dcfd5
commit
245999aec4
10 changed files with 40 additions and 36 deletions
|
@ -8,13 +8,13 @@
|
|||
static void test_deserialize_clipboard(void) {
|
||||
const unsigned char input[] = {
|
||||
DEVICE_MSG_TYPE_CLIPBOARD,
|
||||
0x00, 0x03, // text length
|
||||
0x00, 0x00, 0x00, 0x03, // text length
|
||||
0x41, 0x42, 0x43, // "ABC"
|
||||
};
|
||||
|
||||
struct device_msg msg;
|
||||
ssize_t r = device_msg_deserialize(input, sizeof(input), &msg);
|
||||
assert(r == 6);
|
||||
assert(r == 8);
|
||||
|
||||
assert(msg.type == DEVICE_MSG_TYPE_CLIPBOARD);
|
||||
assert(msg.clipboard.text);
|
||||
|
@ -26,10 +26,12 @@ static void test_deserialize_clipboard(void) {
|
|||
static void test_deserialize_clipboard_big(void) {
|
||||
unsigned char input[DEVICE_MSG_MAX_SIZE];
|
||||
input[0] = DEVICE_MSG_TYPE_CLIPBOARD;
|
||||
input[1] = DEVICE_MSG_TEXT_MAX_LENGTH >> 8; // MSB
|
||||
input[2] = DEVICE_MSG_TEXT_MAX_LENGTH & 0xff; // LSB
|
||||
input[1] = (DEVICE_MSG_TEXT_MAX_LENGTH & 0xff000000u) >> 24;
|
||||
input[2] = (DEVICE_MSG_TEXT_MAX_LENGTH & 0x00ff0000u) >> 16;
|
||||
input[3] = (DEVICE_MSG_TEXT_MAX_LENGTH & 0x0000ff00u) >> 8;
|
||||
input[4] = DEVICE_MSG_TEXT_MAX_LENGTH & 0x000000ffu;
|
||||
|
||||
memset(input + 3, 'a', DEVICE_MSG_TEXT_MAX_LENGTH);
|
||||
memset(input + 5, 'a', DEVICE_MSG_TEXT_MAX_LENGTH);
|
||||
|
||||
struct device_msg msg;
|
||||
ssize_t r = device_msg_deserialize(input, sizeof(input), &msg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue