Commit Graph

20 Commits

Author SHA1 Message Date
João Valverde 14a1dfbe10 wsutil/inet_addr: Refactor to use C99/POSIX types
Rewrite ws_inet_pton{4,6} and ws_inet_ntop{4,6} without
GLib types.

Check for strerrorname_np() and use that is available,
to simplify error handling.

Add some minimal tests.
2021-12-27 19:02:50 +00:00
João Valverde f75b79a59d Move wmem string utility functions to wsutil 2021-12-19 10:47:50 +00:00
João Valverde fe9b1fb103 dfilter: Avoid dumping mangled UTF-8
We should not replace chars that cannot be represented
in ASCII, to avoid mangling UTF-8. This assumes every
string is UTF-8, of course.

This only affects the display of the compiled filter.

Before:

    Filter: http.user_agent == "João"

    Constants:
    00000 PUT_FVALUE	"Jo\xc3\xa3o" <FT_STRING> -> reg#1

After:

    Filter: http.user_agent == "João"

    Constants:
    00000 PUT_FVALUE	"João" <FT_STRING> -> reg#1
2021-12-02 16:04:48 +00:00
João Valverde 504de90a3c wsutil: Split format_size() enum
Use an enum to select units and a bit flag for the other options,
currently only prefix type.
2021-11-29 22:13:32 +00:00
João Valverde 9c61142195 wsutil: Add more character escapes to ws_escape_string()
Add whitespace and other escapes for a better display of strings
in the UI.
2021-11-29 17:47:53 +00:00
João Valverde 54bdc20e45 epan: Rewrite ws_escape_string() to use wmem
Return a wmem-allocated string.

Add boolean argument to enable/disable adding double quotes.
2021-11-29 17:47:53 +00:00
João Valverde 44121e2c3b Move escape_string() to wsutil
Move this utility function to wsutil. Rename to
ws_escape_string().

Also add tests.
2021-11-29 17:47:53 +00:00
João Valverde 5680d1ae0b wsutil: Improve bytes_to_str_max() API
Have these functions accept a zero max length to mean "display
the whole byte array". Change the max length parameter to receive a
number of bytes to print, not the length of the output character
string.

Adjust the macros bytes_to_str() and bytes_to_string_punct() to
produce the same output. Add more tests. Rename the functions to
bytes_to_str_maxlen() and bytes_to_str_punct_maxlen() because this is
an API break.
2021-11-09 20:57:05 +00:00
João Valverde 1883487241 ws_getopt: Add a test for optional parameter 2021-09-30 14:24:52 +00:00
João Valverde 5362d0c31b ws_getopt: Rename struct and macros
This is part of the API and should also be renamed to avoid conflicts.
2021-09-30 13:59:28 +00:00
João Valverde acffc56148 test_wsutil: Use 'static' linkage 2021-09-25 19:44:40 +01:00
João Valverde b054286744 ws_getopt: Cleaner better __getopt_msg()
This is more readable and the extra error checking is functionally
the same as the original upstream code too, that trigerred some
compiler warnings.

Add missing 'static' qualifier.

Add a test for 'ws_opterr'.
2021-09-19 13:48:09 +01:00
João Valverde dd59d1fcf9 ws_getopt: Add test suite skeleton with some basic tests 2021-09-17 14:15:55 +00:00
João Valverde 8304ced0e6 wsutil: Add some tests for word_to_hex() 2021-09-16 18:21:14 +01:00
João Valverde 44538f6e4d wsutil: Add tests for to_str_back() 2021-09-16 15:53:14 +00:00
João Valverde 20dc422550 wsutil: Add test for bytes_to_str_punct() 2021-09-15 18:38:57 +01:00
João Valverde 7b845e7194 wsutil: rename bytestring_to_str() -> bytes_to_str_punct() 2021-07-29 17:23:05 +00:00
João Valverde 177e5cda1f wsutil: Clean up unit test namespaces
Remove implicit root and separate tests for proper coverage.
2021-07-29 17:23:05 +00:00
João Valverde 1ff6cc7b27 wsutil: Add some tests for bytes_to_str() 2021-07-29 17:23:04 +00:00
João Valverde 89acb935bc wsutil: Start adding a test suite 2021-07-11 14:39:13 +00:00