util: Add conversion util for uppercase hex string
PATCH 1/1 util: Add conversion util for uppercase hex string
--- ell/util.c | 22 ++++++++++++++++++++++ ell/util.h | 1 + 2 files changed, 23 insertions(+)
ell/util.c +22 -0
@@ -365,6 +365,28 @@ LIB_EXPORT char *l_util_hexstring(const unsigned char *buf, size_t len) }/** +* l_util_hexstring_upper: +* @buf: buffer pointer +* @len: length of buffer +* +* Returns: a newly allocated uppercase hex string +**/ +LIB_EXPORT char *l_util_hexstring_upper(const unsigned char *buf, size_t len) +{ +char *str; +char *p; + + str =l_util_hexstring (buf, len); +if (!str) +return NULL ; + +for (p = str; *p !='\0' ; p++) + *p =toupper (*p); + +return str; +} + +/** * l_util_from_hexstring: * @str: Null-terminated string containing the hex-encoded bytes * @out_len: Number of bytes decoded
ell/util.h +1 -0
@@ -276,6 +276,7 @@ bool l_str_has_prefix(const char *str, const char *prefix);bool l_str_has_suffix (const char *str,const char *suffix);char *l_util_hexstring (const unsigned char *buf,size_t len); +char *l_util_hexstring_upper (const unsigned char *buf,size_t len);unsigned char *l_util_from_hexstring (const char *str,size_t *out_len);typedef void (*l_util_hexdump_func_t ) (const char *str,void *user_data);
Signature · 1 line
2.13.6