mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 11:19:16 +02:00
clients/meta: allow formatting 16-bit values formatted as 0x%04x
This is the preferred way to format WPAN short addresses and PAN IDs.
(cherry picked from commit 8901193816)
This commit is contained in:
parent
19c650d5d6
commit
1a2db338d1
1 changed files with 26 additions and 5 deletions
|
|
@ -14,7 +14,7 @@
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* Copyright 2010 - 2017 Red Hat, Inc.
|
* Copyright 2010 - 2018 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nm-default.h"
|
#include "nm-default.h"
|
||||||
|
|
@ -784,7 +784,9 @@ _get_fcn_gobject_int (ARGS_GET_FCN)
|
||||||
GParamSpec *pspec;
|
GParamSpec *pspec;
|
||||||
nm_auto_unset_gvalue GValue gval = G_VALUE_INIT;
|
nm_auto_unset_gvalue GValue gval = G_VALUE_INIT;
|
||||||
gint64 v;
|
gint64 v;
|
||||||
|
guint base = 10;
|
||||||
const NMMetaUtilsIntValueInfo *value_infos;
|
const NMMetaUtilsIntValueInfo *value_infos;
|
||||||
|
char *return_str;
|
||||||
|
|
||||||
RETURN_UNSUPPORTED_GET_TYPE ();
|
RETURN_UNSUPPORTED_GET_TYPE ();
|
||||||
|
|
||||||
|
|
@ -810,19 +812,38 @@ _get_fcn_gobject_int (ARGS_GET_FCN)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( property_info->property_typ_data
|
||||||
|
&& property_info->property_typ_data->subtype.gobject_int.base > 0) {
|
||||||
|
base = property_info->property_typ_data->subtype.gobject_int.base;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (base) {
|
||||||
|
case 10:
|
||||||
|
return_str = g_strdup_printf ("%"G_GINT64_FORMAT, v);
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
return_str = g_strdup_printf ("0x%"G_GINT64_MODIFIER"x", v);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return_str = NULL;
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
if ( get_type == NM_META_ACCESSOR_GET_TYPE_PRETTY
|
if ( get_type == NM_META_ACCESSOR_GET_TYPE_PRETTY
|
||||||
&& property_info->property_typ_data
|
&& property_info->property_typ_data
|
||||||
&& (value_infos = property_info->property_typ_data->subtype.gobject_int.value_infos)) {
|
&& (value_infos = property_info->property_typ_data->subtype.gobject_int.value_infos)) {
|
||||||
for (; value_infos->nick; value_infos++) {
|
for (; value_infos->nick; value_infos++) {
|
||||||
if (value_infos->value == v) {
|
if (value_infos->value == v) {
|
||||||
RETURN_STR_TO_FREE (g_strdup_printf ("%lli (%s)",
|
char *old_str = return_str;
|
||||||
(long long) v,
|
|
||||||
value_infos->nick));
|
return_str = g_strdup_printf ("%s (%s)", old_str, value_infos->nick);
|
||||||
|
g_free (old_str);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_STR_TO_FREE (g_strdup_printf ("%"G_GINT64_FORMAT, v));
|
RETURN_STR_TO_FREE (return_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gconstpointer
|
static gconstpointer
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue