mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 22:20:27 +01:00
shared: add nm_utils_hexchar_to_int()
This commit is contained in:
parent
b232508707
commit
5bb8e2fa4d
1 changed files with 21 additions and 0 deletions
|
|
@ -210,6 +210,27 @@ GVariant *nm_utils_gbytes_to_variant_ay (GBytes *bytes);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline int
|
||||
nm_utils_hexchar_to_int (char ch)
|
||||
{
|
||||
G_STATIC_ASSERT_EXPR ('0' < 'A');
|
||||
G_STATIC_ASSERT_EXPR ('A' < 'a');
|
||||
|
||||
if (ch >= '0') {
|
||||
if (ch <= '9')
|
||||
return ch - '0';
|
||||
if (ch >= 'A') {
|
||||
if (ch <= 'F')
|
||||
return ((int) ch) + (10 - (int) 'A');
|
||||
if (ch >= 'a' && ch <= 'f')
|
||||
return ((int) ch) + (10 - (int) 'a');
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
const char *nm_utils_dbus_path_get_last_component (const char *dbus_path);
|
||||
|
||||
int nm_utils_dbus_path_cmp (const char *dbus_path_a, const char *dbus_path_b);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue