From 9910bbc62d1c19a2cd75eeb1248c351b6a1e3f06 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Sat, 16 Dec 2017 00:54:52 +0100 Subject: utils: add osmo_escape_str() To report invalid characters in identifiers, it is desirable to escape any weird characters. Otherwise we might print stray newlines or control characters in the log output. ctrl_test.c already uses a print_escaped() function, which will be replaced by osmo_escape_str() in a subsequent patch. control_cmd.c will use osmo_escape_str() to log invalid identifiers. Change-Id: Ic685eb63dead3967d01aaa4f1e9899e5461ca49a --- include/osmocom/core/utils.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/osmocom') diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 0973b4c6..72266ae6 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -120,4 +120,7 @@ bool osmo_is_hexstr(const char *str, int min_digits, int max_digits, bool osmo_identifier_valid(const char *str); bool osmo_separated_identifiers_valid(const char *str, const char *sep_chars); +const char *osmo_escape_str(const char *str, int len); +const char *osmo_escape_str_buf(const char *str, int in_len, char *buf, size_t bufsize); + /*! @} */ -- cgit v1.2.3