Commit 67144406 authored by Thomas Haller's avatar Thomas Haller

all/trivial: rename hexstr<>bin conversion functions

"bin2str" and "str2bin" are not very clear. These strings are
hex-strings. Rename.
parent 474a0dbf
......@@ -212,15 +212,15 @@ guint nm_setting_ethtool_init_features (NMSettingEthtool *setting,
guint8 *_nm_utils_hwaddr_aton (const char *asc, gpointer buffer, gsize buffer_length, gsize *out_length);
const char *nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_case, char *buf, gsize buf_len);
char *_nm_utils_bin2str (gconstpointer addr, gsize length, gboolean upper_case);
void _nm_utils_bin2str_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out);
guint8 *_nm_utils_str2bin_full (const char *asc,
gboolean delimiter_required,
const char *delimiter_candidates,
guint8 *buffer,
gsize buffer_length,
gsize *out_len);
char *_nm_utils_bin2hexstr (gconstpointer addr, gsize length, gboolean upper_case);
void _nm_utils_bin2hexstr_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out);
guint8 *_nm_utils_hexstr2bin_full (const char *asc,
gboolean delimiter_required,
const char *delimiter_candidates,
guint8 *buffer,
gsize buffer_length,
gsize *out_len);
GSList * _nm_utils_hash_values_to_slist (GHashTable *hash);
......
......@@ -3527,12 +3527,12 @@ nm_utils_hwaddr_len (int type)
}
guint8 *
_nm_utils_str2bin_full (const char *asc,
gboolean delimiter_required,
const char *delimiter_candidates,
guint8 *buffer,
gsize buffer_length,
gsize *out_len)
_nm_utils_hexstr2bin_full (const char *asc,
gboolean delimiter_required,
const char *delimiter_candidates,
guint8 *buffer,
gsize buffer_length,
gsize *out_len)
{
const char *in = asc;
guint8 *out = buffer;
......@@ -3602,7 +3602,7 @@ _nm_utils_str2bin_full (const char *asc,
return buffer;
}
#define hwaddr_aton(asc, buffer, buffer_length, out_len) _nm_utils_str2bin_full ((asc), TRUE, ":-", (buffer), (buffer_length), (out_len))
#define hwaddr_aton(asc, buffer, buffer_length, out_len) _nm_utils_hexstr2bin_full ((asc), TRUE, ":-", (buffer), (buffer_length), (out_len))
/**
* nm_utils_hexstr2bin:
......@@ -3628,7 +3628,7 @@ nm_utils_hexstr2bin (const char *hex)
buffer_length = strlen (hex) / 2 + 3;
buffer = g_malloc (buffer_length);
if (!_nm_utils_str2bin_full (hex, FALSE, ":", buffer, buffer_length, &len)) {
if (!_nm_utils_hexstr2bin_full (hex, FALSE, ":", buffer, buffer_length, &len)) {
g_free (buffer);
return NULL;
}
......@@ -3729,7 +3729,7 @@ nm_utils_hwaddr_aton (const char *asc, gpointer buffer, gsize length)
}
void
_nm_utils_bin2str_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out)
_nm_utils_bin2hexstr_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out)
{
const guint8 *in = addr;
const char *LOOKUP = upper_case ? "0123456789ABCDEF" : "0123456789abcdef";
......@@ -3779,7 +3779,7 @@ nm_utils_bin2hexstr (gconstpointer src, gsize len, int final_len)
g_return_val_if_fail (final_len < 0 || (gsize) final_len < buflen, NULL);
result = g_malloc (buflen);
_nm_utils_bin2str_full (src, len, '\0', FALSE, result);
_nm_utils_bin2hexstr_full (src, len, '\0', FALSE, result);
/* Cut converted key off at the correct length for this cipher type */
if (final_len >= 0 && (gsize) final_len < buflen)
......@@ -3806,7 +3806,7 @@ nm_utils_hwaddr_ntoa (gconstpointer addr, gsize length)
g_return_val_if_fail (length > 0, g_strdup (""));
result = g_malloc (length * 3);
_nm_utils_bin2str_full (addr, length, ':', TRUE, result);
_nm_utils_bin2hexstr_full (addr, length, ':', TRUE, result);
return result;
}
......@@ -3819,12 +3819,12 @@ nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_cas
if (buf_len < addr_len * 3)
g_return_val_if_reached (NULL);
_nm_utils_bin2str_full (addr, addr_len, ':', upper_case, buf);
_nm_utils_bin2hexstr_full (addr, addr_len, ':', upper_case, buf);
return buf;
}
/**
* _nm_utils_bin2str:
* _nm_utils_bin2hexstr:
* @addr: (type guint8) (array length=length): a binary hardware address
* @length: the length of @addr
* @upper_case: the case for the hexadecimal digits.
......@@ -3834,7 +3834,7 @@ nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_cas
* Return value: (transfer full): the textual form of @addr
*/
char *
_nm_utils_bin2str (gconstpointer addr, gsize length, gboolean upper_case)
_nm_utils_bin2hexstr (gconstpointer addr, gsize length, gboolean upper_case)
{
char *result;
......@@ -3842,7 +3842,7 @@ _nm_utils_bin2str (gconstpointer addr, gsize length, gboolean upper_case)
g_return_val_if_fail (length > 0, g_strdup (""));
result = g_malloc (length * 3);
_nm_utils_bin2str_full (addr, length, ':', upper_case, result);
_nm_utils_bin2hexstr_full (addr, length, ':', upper_case, result);
return result;
}
......@@ -4510,7 +4510,7 @@ _nm_utils_dhcp_duid_valid (const char *duid, GBytes **out_duid_bin)
return TRUE;
}
if (_nm_utils_str2bin_full (duid, FALSE, ":", duid_arr, sizeof (duid_arr), &duid_len)) {
if (_nm_utils_hexstr2bin_full (duid, FALSE, ":", duid_arr, sizeof (duid_arr), &duid_len)) {
/* MAX DUID length is 128 octects + the type code (2 octects). */
if ( duid_len > 2
&& duid_len <= (128 + 2)) {
......
......@@ -14417,9 +14417,9 @@ nm_device_spawn_iface_helper (NMDevice *self)
if (client_id) {
g_ptr_array_add (argv, g_strdup ("--dhcp4-clientid"));
g_ptr_array_add (argv,
_nm_utils_bin2str (g_bytes_get_data (client_id, NULL),
g_bytes_get_size (client_id),
FALSE));
_nm_utils_bin2hexstr (g_bytes_get_data (client_id, NULL),
g_bytes_get_size (client_id),
FALSE));
}
hostname = nm_dhcp_client_get_hostname (priv->dhcp4.client);
......@@ -14457,9 +14457,9 @@ nm_device_spawn_iface_helper (NMDevice *self)
if (nm_device_get_ip_iface_identifier (self, &iid, FALSE)) {
g_ptr_array_add (argv, g_strdup ("--iid"));
g_ptr_array_add (argv,
_nm_utils_bin2str (iid.id_u8,
sizeof (NMUtilsIPv6IfaceId),
FALSE));
_nm_utils_bin2hexstr (iid.id_u8,
sizeof (NMUtilsIPv6IfaceId),
FALSE));
}
g_ptr_array_add (argv, g_strdup ("--addr-gen-mode"));
......
......@@ -729,7 +729,7 @@ nm_dhcp_utils_duid_to_string (GBytes *duid)
g_return_val_if_fail (duid != NULL, NULL);
data = g_bytes_get_data (duid, &len);
return _nm_utils_bin2str (data, len, FALSE);
return _nm_utils_bin2hexstr (data, len, FALSE);
}
/**
......
......@@ -189,7 +189,7 @@ _secret_password_raw_to_bytes (const char *ifcfg_key,
password_raw += 2;
secret = nm_secret_buf_new (strlen (password_raw) / 2 + 3);
if (!_nm_utils_str2bin_full (password_raw, FALSE, ":", secret->bin, secret->len, &len)) {
if (!_nm_utils_hexstr2bin_full (password_raw, FALSE, ":", secret->bin, secret->len, &len)) {
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Invalid hex password in %s",
ifcfg_key);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment