Commit graph

11 commits

Author SHA1 Message Date
Romain Vimont
669e9a8d1e Fix "ip route" parsing
If a line did not end with '\r', then the final `\n' was replaced by
'\0' for parsing the current line. This `\0` was then mistakenly
considered as the end of the whole "ip route" output, so the remaining
lines were not parsed, causing "scrcpy --tcpip" to fail in some cases.

To fix the issue, read the final character of the current line before it
is (possibly) overwritten by '\0'.
2023-04-02 19:30:23 +02:00
Romain Vimont
b1d8c72780 Rename function to simplify
For consistency with sc_adb_parse_device(), do not include "from_output"
in the function name.
2022-06-09 15:02:42 +02:00
Romain Vimont
55e65fa270 Add missing return 0 in tests 2022-06-09 15:02:42 +02:00
Romain Vimont
69fb5f6ee1 Fix function declarations
Add missing void in function parameters list.
2022-06-09 15:02:42 +02:00
Romain Vimont
4b8cb042c4 Use vector for listing ADB devices
This avoids the hardcoded maximum number of ADB devices detected (16).

Refs #3029 <https://github.com/Genymobile/scrcpy/pull/3029>
PR #3035 <https://github.com/Genymobile/scrcpy/pull/3035>

Co-authored-by: Daniel Ansorregui <d.ansorregui@samsung.com>
2022-02-20 23:59:35 +01:00
Romain Vimont
6edf50d447 Remove fprintf() in tests
It was committed by mistake.
2022-02-18 19:34:54 +01:00
Romain Vimont
4389de1c23 Add adb devices parser
Add a parser of `adb device -l` output, to extract a list of devices
with their serial, state and model.

PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005>
2022-02-09 09:56:25 +01:00
Romain Vimont
5d6bd8f9cd Fix adb device ip parsing
The parser assumed that its input was a NUL-terminated string, but it
was not the case: it is just the raw output of "adb devices ip route".

In practice, it was harmless, since the output always ended with '\n'
(which was replaced by '\0' on truncation), but it was incorrect
nonetheless.

Always write a '\0' at the end of the buffer, and explicitly parse as a
NUL-terminated string. For that purpose, avoid the error-prone
sc_str_truncate() util function.
2022-02-06 14:30:07 +01:00
Romain Vimont
7810ca61b0 Move ADB code to adb/ 2022-02-04 08:39:10 +01:00
Romain Vimont
1fbc590b26 Fix memory leaks in tests
Tests were failing when run with ASAN enabled.
2021-12-31 10:49:22 +01:00
Romain Vimont
f609b406c9 Add function to find the device IP address
Parse the result of "adb shell ip route" to find the device IP address.

PR #2827 <https://github.com/Genymobile/scrcpy/pull/2827>
2021-11-29 20:39:03 +01:00