Commit Graph

10 Commits (107f7a83abe60ff1a25db42aa864ed13f5a4c0c1)

Author SHA1 Message Date
Romain Vimont 107f7a83ab Extract binary to hex string conversion
PR #4473 <https://github.com/Genymobile/scrcpy/pull/4473>
4 months ago
Romain Vimont 137d2c9791 Remove confusing sc_str_truncate()
This util function was error-prone:
 - it accepted a buffer as parameter (not necessarily a NUL-terminated
   string) and its length (including the NUL char, if any);
 - it wrote '\0' over the last character of the buffer, so the last
   character was lost if the buffer was not a NUL-terminated string, and
   even worse, it caused undefined behavior if the length was empty;
 - it returned the length of the resulting NUL-terminated string,
   which was inconsistent with the input buffer length.

In addition, it was not necessarily optimal:
 - it wrote '\0' twice;
 - it required to know the buffer length, that is the input string
   length + 1, in advance.

Remove this function, and let the client use strcspn() manually.
2 years ago
Romain Vimont feb250a973 Fix typos reported by codespell 3 years ago
Romain Vimont b7e631791c Add util function to remove trailing '\r'
Depending on the platform and adb versions, the lines output by adb
could end with "\r\r\n". This util function helps to remove all trailing
'\r'.

PR #2827 <https://github.com/Genymobile/scrcpy/pull/2827>
3 years ago
Romain Vimont b52f87a892 Add util function to locate a column in a string
This will help to parse the result of "adb shell ip route" to find the
device IP address.

PR #2827 <https://github.com/Genymobile/scrcpy/pull/2827>
3 years ago
Romain Vimont 3653fb6b15 Add OutOfMemory log helper
Add a special LOG_OOM() function to log all OutOfMemory errors (i.e.
allocations returning NULL).
3 years ago
Romain Vimont cb65531533 Simplify sc_str_truncate()
Use strcspn() to get the prefix length directly.
3 years ago
Romain Vimont 9619ade706 Generalize string trunctation util function
Add an additional argument to let the client pass the possible end
chars.
3 years ago
Romain Vimont f2781a8b6d Expose util function to truncate first line
Move the local implementation from adb functions to the string util
functions.
3 years ago
Romain Vimont 057c7a4df4 Move str_util to str
Simplify naming.
3 years ago