shared: add nm_hexchar() helper

This commit is contained in:
Thomas Haller 2020-06-20 19:43:23 +02:00
parent d53abfd989
commit 069be33fbd
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 14 additions and 0 deletions

View file

@ -23,6 +23,9 @@ G_STATIC_ASSERT (G_STRUCT_OFFSET (NMUtilsNamedValue, value_ptr) == sizeof (const
/*****************************************************************************/
const char _nm_hexchar_table_lower[16] = "0123456789abcdef";
const char _nm_hexchar_table_upper[16] = "0123456789ABCDEF";
const void *const _NM_PTRARRAY_EMPTY[1] = { NULL };
/*****************************************************************************/

View file

@ -1809,6 +1809,17 @@ int nm_utils_getpagesize (void);
/*****************************************************************************/
extern const char _nm_hexchar_table_lower[16];
extern const char _nm_hexchar_table_upper[16];
static inline char
nm_hexchar (int x, gboolean upper_case)
{
return upper_case
? _nm_hexchar_table_upper[x & 15]
: _nm_hexchar_table_lower[x & 15];
}
char *nm_utils_bin2hexstr_full (gconstpointer addr,
gsize length,
char delimiter,