mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-06 04:28:29 +02:00
all: merge branch 'th/utils-api-rename'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/947
This commit is contained in:
commit
d196e4962b
61 changed files with 810 additions and 875 deletions
|
|
@ -356,7 +356,7 @@ br2684_create_iface(NMDeviceAdsl *self)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
nm_utils_strdup_reset(&priv->nas_ifname, ni.ifname);
|
||||
nm_strdup_reset(&priv->nas_ifname, ni.ifname);
|
||||
_LOGD(LOGD_ADSL, "waiting for br2684 iface '%s' to appear", priv->nas_ifname);
|
||||
priv->nas_update_count = 0;
|
||||
priv->nas_update_id = g_timeout_add(100, nas_update_cb, self);
|
||||
|
|
|
|||
|
|
@ -382,64 +382,56 @@ _bzobj_to_string(const BzDBusObj *bzobj, char *buf, gsize len)
|
|||
buf[0] = '\0';
|
||||
|
||||
if (bzobj->d_has_adapter_iface) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, prefix);
|
||||
nm_strbuf_append_str(&buf, &len, prefix);
|
||||
prefix = ", ";
|
||||
nm_utils_strbuf_append_str(&buf, &len, "Adapter1 {");
|
||||
nm_strbuf_append_str(&buf, &len, "Adapter1 {");
|
||||
if (bzobj->d_adapter.address) {
|
||||
nm_utils_strbuf_append(&buf, &len, " d.address: \"%s\"", bzobj->d_adapter.address);
|
||||
nm_strbuf_append(&buf, &len, " d.address: \"%s\"", bzobj->d_adapter.address);
|
||||
if (bzobj->d_adapter_powered)
|
||||
nm_utils_strbuf_append_str(&buf, &len, ",");
|
||||
nm_strbuf_append_str(&buf, &len, ",");
|
||||
}
|
||||
if (bzobj->d_adapter_powered)
|
||||
nm_utils_strbuf_append(&buf, &len, " d.powered: 1");
|
||||
nm_utils_strbuf_append_str(&buf, &len, " }");
|
||||
nm_strbuf_append(&buf, &len, " d.powered: 1");
|
||||
nm_strbuf_append_str(&buf, &len, " }");
|
||||
}
|
||||
|
||||
if (bzobj->d_has_device_iface) {
|
||||
const char *prefix1 = "";
|
||||
|
||||
nm_utils_strbuf_append_str(&buf, &len, prefix);
|
||||
nm_strbuf_append_str(&buf, &len, prefix);
|
||||
prefix = ", ";
|
||||
nm_utils_strbuf_append_str(&buf, &len, "Device1 {");
|
||||
nm_strbuf_append_str(&buf, &len, "Device1 {");
|
||||
if (bzobj->d_device.address) {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
"%s d.address: \"%s\"",
|
||||
prefix1,
|
||||
bzobj->d_device.address);
|
||||
nm_strbuf_append(&buf, &len, "%s d.address: \"%s\"", prefix1, bzobj->d_device.address);
|
||||
prefix1 = ",";
|
||||
}
|
||||
if (bzobj->d_device.name) {
|
||||
nm_utils_strbuf_append(&buf, &len, "%s d.name: \"%s\"", prefix1, bzobj->d_device.name);
|
||||
nm_strbuf_append(&buf, &len, "%s d.name: \"%s\"", prefix1, bzobj->d_device.name);
|
||||
prefix1 = ",";
|
||||
}
|
||||
if (bzobj->d_device.adapter) {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
"%s d.adapter: \"%s\"",
|
||||
prefix1,
|
||||
bzobj->d_device.adapter);
|
||||
nm_strbuf_append(&buf, &len, "%s d.adapter: \"%s\"", prefix1, bzobj->d_device.adapter);
|
||||
prefix1 = ",";
|
||||
}
|
||||
if (bzobj->d_device_capabilities != NM_BT_CAPABILITY_NONE) {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
"%s d.capabilities: \"%s\"",
|
||||
prefix1,
|
||||
nm_bluetooth_capability_to_string(bzobj->d_device_capabilities,
|
||||
sbuf_cap,
|
||||
sizeof(sbuf_cap)));
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
"%s d.capabilities: \"%s\"",
|
||||
prefix1,
|
||||
nm_bluetooth_capability_to_string(bzobj->d_device_capabilities,
|
||||
sbuf_cap,
|
||||
sizeof(sbuf_cap)));
|
||||
prefix1 = ",";
|
||||
}
|
||||
if (bzobj->d_device_connected) {
|
||||
nm_utils_strbuf_append(&buf, &len, "%s d.connected: 1", prefix1);
|
||||
nm_strbuf_append(&buf, &len, "%s d.connected: 1", prefix1);
|
||||
prefix1 = ",";
|
||||
}
|
||||
if (bzobj->d_device_paired) {
|
||||
nm_utils_strbuf_append(&buf, &len, "%s d.paired: 1", prefix1);
|
||||
nm_strbuf_append(&buf, &len, "%s d.paired: 1", prefix1);
|
||||
prefix1 = ",";
|
||||
}
|
||||
nm_utils_strbuf_append_str(&buf, &len, " }");
|
||||
nm_strbuf_append_str(&buf, &len, " }");
|
||||
}
|
||||
|
||||
network_server_is_usable = _bzobjs_network_server_is_usable(bzobj, TRUE);
|
||||
|
|
@ -450,43 +442,43 @@ _bzobj_to_string(const BzDBusObj *bzobj, char *buf, gsize len)
|
|||
|| !nm_streq0(bzobj->d_has_adapter_iface ? bzobj->d_adapter.address : NULL,
|
||||
bzobj->x_network_server.adapter_address)
|
||||
|| bzobj->x_network_server.device_br || bzobj->x_network_server.r_req_data) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, prefix);
|
||||
nm_strbuf_append_str(&buf, &len, prefix);
|
||||
prefix = ", ";
|
||||
|
||||
nm_utils_strbuf_append(&buf, &len, "NetworkServer1 { ");
|
||||
nm_strbuf_append(&buf, &len, "NetworkServer1 { ");
|
||||
|
||||
if (!bzobj->d_has_network_server_iface)
|
||||
nm_utils_strbuf_append(&buf, &len, " has-d-iface: 0, ");
|
||||
nm_strbuf_append(&buf, &len, " has-d-iface: 0, ");
|
||||
|
||||
if (network_server_is_usable != (!c_list_is_empty(&bzobj->x_network_server.lst)))
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
"usable: %d, used: %d",
|
||||
!!network_server_is_usable,
|
||||
!network_server_is_usable);
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
"usable: %d, used: %d",
|
||||
!!network_server_is_usable,
|
||||
!network_server_is_usable);
|
||||
else if (network_server_is_usable)
|
||||
nm_utils_strbuf_append(&buf, &len, "used: 1");
|
||||
nm_strbuf_append(&buf, &len, "used: 1");
|
||||
else
|
||||
nm_utils_strbuf_append(&buf, &len, "usable: 0");
|
||||
nm_strbuf_append(&buf, &len, "usable: 0");
|
||||
|
||||
if (!nm_streq0(bzobj->d_has_adapter_iface ? bzobj->d_adapter.address : NULL,
|
||||
bzobj->x_network_server.adapter_address)) {
|
||||
if (bzobj->x_network_server.adapter_address)
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
", adapter-address: \"%s\"",
|
||||
bzobj->x_network_server.adapter_address);
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
", adapter-address: \"%s\"",
|
||||
bzobj->x_network_server.adapter_address);
|
||||
else
|
||||
nm_utils_strbuf_append(&buf, &len, ", adapter-address: <NULL>");
|
||||
nm_strbuf_append(&buf, &len, ", adapter-address: <NULL>");
|
||||
}
|
||||
|
||||
if (bzobj->x_network_server.device_br)
|
||||
nm_utils_strbuf_append(&buf, &len, ", bridge-device: 1");
|
||||
nm_strbuf_append(&buf, &len, ", bridge-device: 1");
|
||||
|
||||
if (bzobj->x_network_server.r_req_data)
|
||||
nm_utils_strbuf_append(&buf, &len, ", register-in-progress: 1");
|
||||
nm_strbuf_append(&buf, &len, ", register-in-progress: 1");
|
||||
|
||||
nm_utils_strbuf_append_str(&buf, &len, " }");
|
||||
nm_strbuf_append_str(&buf, &len, " }");
|
||||
}
|
||||
|
||||
device_is_usable = _bzobjs_device_is_usable(bzobj, NULL, &create_panu_connection);
|
||||
|
|
@ -497,76 +489,72 @@ _bzobj_to_string(const BzDBusObj *bzobj, char *buf, gsize len)
|
|||
|| bzobj->x_device_connect_bt_type != NM_BT_CAPABILITY_NONE
|
||||
|| bzobj->x_device.connect_dun_context || bzobj->x_device.c_req_data
|
||||
|| bzobj->x_device_is_connected != bzobj->d_network_connected) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, prefix);
|
||||
nm_strbuf_append_str(&buf, &len, prefix);
|
||||
prefix = ", ";
|
||||
nm_utils_strbuf_append_str(&buf, &len, "Network1 {");
|
||||
nm_strbuf_append_str(&buf, &len, "Network1 {");
|
||||
if (bzobj->d_network.interface)
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" d.interface: \"%s\", ",
|
||||
bzobj->d_network.interface);
|
||||
nm_strbuf_append(&buf, &len, " d.interface: \"%s\", ", bzobj->d_network.interface);
|
||||
if (bzobj->d_network_connected)
|
||||
nm_utils_strbuf_append(&buf, &len, " d.connected: %d, ", !!bzobj->d_network_connected);
|
||||
nm_strbuf_append(&buf, &len, " d.connected: %d, ", !!bzobj->d_network_connected);
|
||||
if (!bzobj->d_has_network_iface)
|
||||
nm_utils_strbuf_append(&buf, &len, " has-d-iface: 0, ");
|
||||
nm_strbuf_append(&buf, &len, " has-d-iface: 0, ");
|
||||
if (device_is_usable != bzobj->x_device_is_usable)
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" usable: %d, used: %d",
|
||||
!!device_is_usable,
|
||||
!device_is_usable);
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
" usable: %d, used: %d",
|
||||
!!device_is_usable,
|
||||
!device_is_usable);
|
||||
else if (device_is_usable)
|
||||
nm_utils_strbuf_append(&buf, &len, " used: 1");
|
||||
nm_strbuf_append(&buf, &len, " used: 1");
|
||||
else
|
||||
nm_utils_strbuf_append(&buf, &len, " usable: 0");
|
||||
nm_strbuf_append(&buf, &len, " usable: 0");
|
||||
|
||||
if (create_panu_connection)
|
||||
nm_utils_strbuf_append(&buf, &len, ", create-panu-connection: 1");
|
||||
nm_strbuf_append(&buf, &len, ", create-panu-connection: 1");
|
||||
|
||||
if (bzobj->x_device.panu_connection)
|
||||
nm_utils_strbuf_append(&buf, &len, ", has-panu-connection: 1");
|
||||
nm_strbuf_append(&buf, &len, ", has-panu-connection: 1");
|
||||
|
||||
if (bzobj->x_device.device_bt)
|
||||
nm_utils_strbuf_append(&buf, &len, ", has-device: 1");
|
||||
nm_strbuf_append(&buf, &len, ", has-device: 1");
|
||||
|
||||
if (bzobj->x_device_connect_bt_type != NM_BT_CAPABILITY_NONE
|
||||
|| bzobj->x_device.connect_dun_context) {
|
||||
nm_utils_strbuf_append(
|
||||
&buf,
|
||||
&len,
|
||||
", connect: %s%s",
|
||||
nm_bluetooth_capability_to_string(bzobj->x_device_connect_bt_type,
|
||||
sbuf_cap,
|
||||
sizeof(sbuf_cap)),
|
||||
bzobj->x_device.connect_dun_context ? ",with-dun-context" : "");
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
", connect: %s%s",
|
||||
nm_bluetooth_capability_to_string(bzobj->x_device_connect_bt_type,
|
||||
sbuf_cap,
|
||||
sizeof(sbuf_cap)),
|
||||
bzobj->x_device.connect_dun_context ? ",with-dun-context" : "");
|
||||
}
|
||||
|
||||
if (bzobj->x_device.c_req_data)
|
||||
nm_utils_strbuf_append(&buf, &len, ", connecting: 1");
|
||||
nm_strbuf_append(&buf, &len, ", connecting: 1");
|
||||
|
||||
if (bzobj->x_device_is_connected != bzobj->d_network_connected)
|
||||
nm_utils_strbuf_append(&buf, &len, ", connected: %d", !!bzobj->x_device_is_connected);
|
||||
nm_strbuf_append(&buf, &len, ", connected: %d", !!bzobj->x_device_is_connected);
|
||||
|
||||
nm_utils_strbuf_append_str(&buf, &len, " }");
|
||||
nm_strbuf_append_str(&buf, &len, " }");
|
||||
}
|
||||
|
||||
if (_bzobjs_is_dead(bzobj)) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, prefix);
|
||||
nm_strbuf_append_str(&buf, &len, prefix);
|
||||
prefix = ", ";
|
||||
nm_utils_strbuf_append_str(&buf, &len, "dead: 1");
|
||||
nm_strbuf_append_str(&buf, &len, "dead: 1");
|
||||
}
|
||||
|
||||
if (!c_list_is_empty(&bzobj->process_change_lst)) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, prefix);
|
||||
nm_strbuf_append_str(&buf, &len, prefix);
|
||||
prefix = ", ";
|
||||
nm_utils_strbuf_append(&buf, &len, "change-pending-on-idle: 1");
|
||||
nm_strbuf_append(&buf, &len, "change-pending-on-idle: 1");
|
||||
}
|
||||
|
||||
if (_bzobjs_adapter_is_usable_for_device(bzobj)
|
||||
!= bzobj->was_usable_adapter_for_device_before) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, prefix);
|
||||
nm_strbuf_append_str(&buf, &len, prefix);
|
||||
prefix = ", ";
|
||||
nm_utils_strbuf_append(&buf, &len, "change-usable-adapter-for-device: 1");
|
||||
nm_strbuf_append(&buf, &len, "change-usable-adapter-for-device: 1");
|
||||
}
|
||||
|
||||
return buf0;
|
||||
|
|
|
|||
|
|
@ -250,9 +250,8 @@ set_arp_targets(NMDevice *device, const char *cur_arp_ip_target, const char *new
|
|||
gsize i;
|
||||
gsize j;
|
||||
|
||||
cur_strv = nm_utils_strsplit_set_full(cur_arp_ip_target,
|
||||
NM_ASCII_SPACES,
|
||||
NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
cur_strv =
|
||||
nm_strsplit_set_full(cur_arp_ip_target, NM_ASCII_SPACES, NM_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
new_strv = nm_utils_bond_option_arp_ip_targets_split(new_arp_ip_target);
|
||||
|
||||
cur_len = NM_PTRARRAY_LEN(cur_strv);
|
||||
|
|
|
|||
|
|
@ -5803,7 +5803,7 @@ nm_device_update_from_platform_link(NMDevice *self, const NMPlatformLink *plink)
|
|||
_notify(self, PROP_PATH);
|
||||
}
|
||||
|
||||
if (plink && !nm_str_is_empty(plink->name) && nm_utils_strdup_reset(&priv->iface_, plink->name))
|
||||
if (plink && !nm_str_is_empty(plink->name) && nm_strdup_reset(&priv->iface_, plink->name))
|
||||
_notify(self, PROP_IFACE);
|
||||
|
||||
str = plink ? plink->driver : NULL;
|
||||
|
|
@ -14738,15 +14738,15 @@ _unmanaged_flags2str(NMUnmanagedFlags flags, NMUnmanagedFlags mask, char *buf, g
|
|||
tmp = buf2;
|
||||
while (TRUE) {
|
||||
if (add_separator)
|
||||
nm_utils_strbuf_append_c(&b, &len, ',');
|
||||
nm_strbuf_append_c(&b, &len, ',');
|
||||
add_separator = TRUE;
|
||||
|
||||
tmp2 = strchr(tmp, ',');
|
||||
if (tmp2)
|
||||
tmp2[0] = '\0';
|
||||
|
||||
nm_utils_strbuf_append_c(&b, &len, '!');
|
||||
nm_utils_strbuf_append_str(&b, &len, tmp);
|
||||
nm_strbuf_append_c(&b, &len, '!');
|
||||
nm_strbuf_append_str(&b, &len, tmp);
|
||||
if (!tmp2)
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -1595,7 +1595,7 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
|||
iter = json_object_iter(ovs);
|
||||
s = json_object_iter_key(iter);
|
||||
if (s)
|
||||
nm_utils_strdup_reset(&priv->db_uuid, s);
|
||||
nm_strdup_reset(&priv->db_uuid, s);
|
||||
}
|
||||
|
||||
json_object_foreach (interface, key, value) {
|
||||
|
|
@ -1665,8 +1665,8 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
|||
|
||||
nm_assert(nm_streq0(ovs_interface->name, name));
|
||||
|
||||
changed |= nm_utils_strdup_reset(&ovs_interface->type, type);
|
||||
changed |= nm_utils_strdup_reset(&ovs_interface->connection_uuid, connection_uuid);
|
||||
changed |= nm_strdup_reset(&ovs_interface->type, type);
|
||||
changed |= nm_strdup_reset(&ovs_interface->connection_uuid, connection_uuid);
|
||||
if (!_external_ids_equal(ovs_interface->external_ids, external_ids_arr)) {
|
||||
NM_SWAP(&ovs_interface->external_ids, &external_ids_arr);
|
||||
changed = TRUE;
|
||||
|
|
@ -1776,8 +1776,8 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
|||
|
||||
nm_assert(nm_streq0(ovs_port->name, name));
|
||||
|
||||
changed |= nm_utils_strdup_reset(&ovs_port->name, name);
|
||||
changed |= nm_utils_strdup_reset(&ovs_port->connection_uuid, connection_uuid);
|
||||
changed |= nm_strdup_reset(&ovs_port->name, name);
|
||||
changed |= nm_strdup_reset(&ovs_port->connection_uuid, connection_uuid);
|
||||
if (nm_strv_ptrarray_cmp(ovs_port->interfaces, interfaces) != 0) {
|
||||
NM_SWAP(&ovs_port->interfaces, &interfaces);
|
||||
changed = TRUE;
|
||||
|
|
@ -1881,8 +1881,8 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
|||
|
||||
nm_assert(nm_streq0(ovs_bridge->name, name));
|
||||
|
||||
changed = nm_utils_strdup_reset(&ovs_bridge->name, name);
|
||||
changed = nm_utils_strdup_reset(&ovs_bridge->connection_uuid, connection_uuid);
|
||||
changed = nm_strdup_reset(&ovs_bridge->name, name);
|
||||
changed = nm_strdup_reset(&ovs_bridge->connection_uuid, connection_uuid);
|
||||
if (nm_strv_ptrarray_cmp(ovs_bridge->ports, ports) != 0) {
|
||||
NM_SWAP(&ovs_bridge->ports, &ports);
|
||||
changed = TRUE;
|
||||
|
|
@ -2569,12 +2569,10 @@ nm_ovsdb_set_external_ids(NMOvsdb * self,
|
|||
gs_unref_hashtable GHashTable *exid_old = NULL;
|
||||
gs_unref_hashtable GHashTable *exid_new = NULL;
|
||||
|
||||
exid_old = s_exid_old
|
||||
? nm_utils_strdict_clone(_nm_setting_ovs_external_ids_get_data(s_exid_old))
|
||||
: NULL;
|
||||
exid_new = s_exid_new
|
||||
? nm_utils_strdict_clone(_nm_setting_ovs_external_ids_get_data(s_exid_new))
|
||||
: NULL;
|
||||
exid_old =
|
||||
s_exid_old ? nm_strdict_clone(_nm_setting_ovs_external_ids_get_data(s_exid_old)) : NULL;
|
||||
exid_new =
|
||||
s_exid_new ? nm_strdict_clone(_nm_setting_ovs_external_ids_get_data(s_exid_new)) : NULL;
|
||||
|
||||
ovsdb_call_method(self,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ nm_wifi_p2p_peer_set_name(NMWifiP2PPeer *peer, const char *str)
|
|||
{
|
||||
NMWifiP2PPeerPrivate *priv = NM_WIFI_P2P_PEER_GET_PRIVATE(peer);
|
||||
|
||||
if (!nm_utils_strdup_reset(&priv->name, str))
|
||||
if (!nm_strdup_reset(&priv->name, str))
|
||||
return FALSE;
|
||||
_notify(peer, PROP_NAME);
|
||||
return TRUE;
|
||||
|
|
@ -187,7 +187,7 @@ nm_wifi_p2p_peer_set_manufacturer(NMWifiP2PPeer *peer, const char *str)
|
|||
{
|
||||
NMWifiP2PPeerPrivate *priv = NM_WIFI_P2P_PEER_GET_PRIVATE(peer);
|
||||
|
||||
if (!nm_utils_strdup_reset(&priv->manufacturer, str))
|
||||
if (!nm_strdup_reset(&priv->manufacturer, str))
|
||||
return FALSE;
|
||||
_notify(peer, PROP_MANUFACTURER);
|
||||
return TRUE;
|
||||
|
|
@ -206,7 +206,7 @@ nm_wifi_p2p_peer_set_model(NMWifiP2PPeer *peer, const char *str)
|
|||
{
|
||||
NMWifiP2PPeerPrivate *priv = NM_WIFI_P2P_PEER_GET_PRIVATE(peer);
|
||||
|
||||
if (!nm_utils_strdup_reset(&priv->model, str))
|
||||
if (!nm_strdup_reset(&priv->model, str))
|
||||
return FALSE;
|
||||
_notify(peer, PROP_MODEL);
|
||||
return TRUE;
|
||||
|
|
@ -225,7 +225,7 @@ nm_wifi_p2p_peer_set_model_number(NMWifiP2PPeer *peer, const char *str)
|
|||
{
|
||||
NMWifiP2PPeerPrivate *priv = NM_WIFI_P2P_PEER_GET_PRIVATE(peer);
|
||||
|
||||
if (!nm_utils_strdup_reset(&priv->model_number, str))
|
||||
if (!nm_strdup_reset(&priv->model_number, str))
|
||||
return FALSE;
|
||||
_notify(peer, PROP_MODEL_NUMBER);
|
||||
return TRUE;
|
||||
|
|
@ -244,7 +244,7 @@ nm_wifi_p2p_peer_set_serial(NMWifiP2PPeer *peer, const char *str)
|
|||
{
|
||||
NMWifiP2PPeerPrivate *priv = NM_WIFI_P2P_PEER_GET_PRIVATE(peer);
|
||||
|
||||
if (!nm_utils_strdup_reset(&priv->serial, str))
|
||||
if (!nm_strdup_reset(&priv->serial, str))
|
||||
return FALSE;
|
||||
_notify(peer, PROP_SERIAL);
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ nm_dhcp_client_set_state(NMDhcpClient *self,
|
|||
gs_free const char **keys = NULL;
|
||||
guint i, nkeys;
|
||||
|
||||
keys = nm_utils_strdict_get_keys(options, TRUE, &nkeys);
|
||||
keys = nm_strdict_get_keys(options, TRUE, &nkeys);
|
||||
for (i = 0; i < nkeys; i++) {
|
||||
_LOGD("option %-20s => '%s'", keys[i], (char *) g_hash_table_lookup(options, keys[i]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ grab_request_options(GPtrArray *store, const char *line)
|
|||
gsize i;
|
||||
|
||||
/* Grab each 'request' or 'also request' option and save for later */
|
||||
line_v = nm_utils_strsplit_set(line, "\t ,");
|
||||
line_v = nm_strsplit_set(line, "\t ,");
|
||||
for (i = 0; line_v && line_v[i]; i++) {
|
||||
const char *ss = nm_str_skip_leading_spaces(line_v[i]);
|
||||
gsize l;
|
||||
|
|
@ -330,7 +330,7 @@ nm_dhcp_dhclient_create_config(const char * interface,
|
|||
g_string_append_printf(new_contents, _("# Merged from %s\n\n"), orig_path);
|
||||
intf[0] = '\0';
|
||||
|
||||
lines = nm_utils_strsplit_set(orig_contents, "\n\r");
|
||||
lines = nm_strsplit_set(orig_contents, "\n\r");
|
||||
for (line_i = 0; lines && lines[line_i]; line_i++) {
|
||||
const char *line = nm_str_skip_leading_spaces(lines[line_i]);
|
||||
const char *p;
|
||||
|
|
@ -620,7 +620,7 @@ nm_dhcp_dhclient_read_duid(const char *leasefile, GError **error)
|
|||
if (!g_file_get_contents(leasefile, &contents, NULL, error))
|
||||
return NULL;
|
||||
|
||||
contents_v = nm_utils_strsplit_set(contents, "\n\r");
|
||||
contents_v = nm_strsplit_set(contents, "\n\r");
|
||||
for (i = 0; contents_v && contents_v[i]; i++) {
|
||||
const char *p = nm_str_skip_leading_spaces(contents_v[i]);
|
||||
GBytes * duid;
|
||||
|
|
@ -671,7 +671,7 @@ nm_dhcp_dhclient_save_duid(const char *leasefile, GBytes *duid, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
lines = nm_utils_strsplit_set_with_empty(contents, "\n\r");
|
||||
lines = nm_strsplit_set_with_empty(contents, "\n\r");
|
||||
}
|
||||
|
||||
s = g_string_sized_new(len + 50);
|
||||
|
|
|
|||
|
|
@ -601,7 +601,7 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx,
|
|||
nm_str_buf_append_len0(&sbuf, (const char *) l_data, l_data_len);
|
||||
|
||||
/* Multiple domains sometimes stuffed into option 15 "Domain Name". */
|
||||
domains = nm_utils_strsplit_set(nm_str_buf_get_str(&sbuf), " ");
|
||||
domains = nm_strsplit_set(nm_str_buf_get_str(&sbuf), " ");
|
||||
|
||||
nm_str_buf_reset(&sbuf);
|
||||
if (domains) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ ip4_process_dhcpcd_rfc3442_routes(const char * iface,
|
|||
const char ** r;
|
||||
gboolean have_routes = FALSE;
|
||||
|
||||
routes = nm_utils_strsplit_set(str, " ");
|
||||
routes = nm_strsplit_set(str, " ");
|
||||
if (!routes)
|
||||
return FALSE;
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ ip4_process_dhclient_rfc3442_routes(const char * iface,
|
|||
const char *const * o;
|
||||
gboolean have_routes = FALSE;
|
||||
|
||||
octets = nm_utils_strsplit_set_with_empty(str, " .");
|
||||
octets = nm_strsplit_set_with_empty(str, " .");
|
||||
if (NM_PTRARRAY_LEN(octets) < 5) {
|
||||
_LOG2W(LOGD_DHCP4, iface, "ignoring invalid classless static routes '%s'", str);
|
||||
return FALSE;
|
||||
|
|
@ -296,7 +296,7 @@ process_classful_routes(const char * iface,
|
|||
if (!str)
|
||||
return;
|
||||
|
||||
searches = nm_utils_strsplit_set(str, " ");
|
||||
searches = nm_strsplit_set(str, " ");
|
||||
if (!searches)
|
||||
return;
|
||||
|
||||
|
|
@ -376,7 +376,7 @@ process_domain_search(const char *iface, const char *str, GFunc add_func, gpoint
|
|||
return;
|
||||
}
|
||||
|
||||
searches = nm_utils_strsplit_set(unescaped, " ");
|
||||
searches = nm_strsplit_set(unescaped, " ");
|
||||
for (s = searches; searches && *s; s++) {
|
||||
_LOG2I(LOGD_DHCP, iface, " domain search '%s'", *s);
|
||||
add_func((gpointer) *s, user_data);
|
||||
|
|
@ -450,7 +450,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
|
|||
*/
|
||||
str = g_hash_table_lookup(options, "routers");
|
||||
if (str) {
|
||||
gs_free const char **routers = nm_utils_strsplit_set(str, " ");
|
||||
gs_free const char **routers = nm_strsplit_set(str, " ");
|
||||
const char ** s;
|
||||
|
||||
for (s = routers; routers && *s; s++) {
|
||||
|
|
@ -491,7 +491,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
|
|||
|
||||
str = g_hash_table_lookup(options, "domain_name_servers");
|
||||
if (str) {
|
||||
gs_free const char **dns = nm_utils_strsplit_set(str, " ");
|
||||
gs_free const char **dns = nm_strsplit_set(str, " ");
|
||||
const char ** s;
|
||||
|
||||
for (s = dns; dns && *s; s++) {
|
||||
|
|
@ -507,7 +507,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
|
|||
|
||||
str = g_hash_table_lookup(options, "domain_name");
|
||||
if (str) {
|
||||
gs_free const char **domains = nm_utils_strsplit_set(str, " ");
|
||||
gs_free const char **domains = nm_strsplit_set(str, " ");
|
||||
const char ** s;
|
||||
|
||||
for (s = domains; domains && *s; s++) {
|
||||
|
|
@ -522,7 +522,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
|
|||
|
||||
str = g_hash_table_lookup(options, "netbios_name_servers");
|
||||
if (str) {
|
||||
gs_free const char **nbns = nm_utils_strsplit_set(str, " ");
|
||||
gs_free const char **nbns = nm_strsplit_set(str, " ");
|
||||
const char ** s;
|
||||
|
||||
for (s = nbns; nbns && *s; s++) {
|
||||
|
|
@ -557,7 +557,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
|
|||
|
||||
str = g_hash_table_lookup(options, "nis_servers");
|
||||
if (str) {
|
||||
gs_free const char **nis = nm_utils_strsplit_set(str, " ");
|
||||
gs_free const char **nis = nm_strsplit_set(str, " ");
|
||||
const char ** s;
|
||||
|
||||
for (s = nis; nis && *s; s++) {
|
||||
|
|
@ -689,7 +689,7 @@ nm_dhcp_utils_ip6_config_from_options(NMDedupMultiIndex *multi_idx,
|
|||
|
||||
str = g_hash_table_lookup(options, "dhcp6_name_servers");
|
||||
if (str) {
|
||||
gs_free const char **dns = nm_utils_strsplit_set(str, " ");
|
||||
gs_free const char **dns = nm_strsplit_set(str, " ");
|
||||
const char ** s;
|
||||
|
||||
for (s = dns; dns && *s; s++) {
|
||||
|
|
|
|||
|
|
@ -596,7 +596,7 @@ name_owner_changed(NMDnsSystemdResolved *self, const char *owner)
|
|||
|
||||
nm_clear_g_source_inst(&priv->try_start_timeout_source);
|
||||
|
||||
nm_utils_strdup_reset(&priv->dbus_owner, owner);
|
||||
nm_strdup_reset(&priv->dbus_owner, owner);
|
||||
|
||||
if (owner) {
|
||||
priv->try_start_blocked = FALSE;
|
||||
|
|
|
|||
|
|
@ -1026,7 +1026,7 @@ global_dns_config_seal_domains(NMGlobalDnsConfig *dns_config)
|
|||
if (g_hash_table_size(dns_config->domains) == 0)
|
||||
nm_clear_pointer(&dns_config->domains, g_hash_table_unref);
|
||||
else
|
||||
dns_config->domain_list = nm_utils_strdict_get_keys(dns_config->domains, TRUE, NULL);
|
||||
dns_config->domain_list = nm_strdict_get_keys(dns_config->domains, TRUE, NULL);
|
||||
}
|
||||
|
||||
static NMGlobalDnsConfig *
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ no_auto_default_from_file(const char *no_auto_default_file)
|
|||
gsize i;
|
||||
|
||||
if (no_auto_default_file && g_file_get_contents(no_auto_default_file, &data, NULL, NULL))
|
||||
list = nm_utils_strsplit_set(data, "\n");
|
||||
list = nm_strsplit_set(data, "\n");
|
||||
|
||||
if (list) {
|
||||
for (i = 0; list[i]; i++)
|
||||
|
|
|
|||
|
|
@ -4072,8 +4072,8 @@ nm_utils_get_reverse_dns_domains_ip_4(guint32 addr, guint8 plen, GPtrArray *doma
|
|||
len = len0;
|
||||
str = s = g_malloc(len);
|
||||
for (i = octets; i > 0; i--)
|
||||
nm_utils_strbuf_append(&s, &len, "%u.", p[i - 1] & 0xff);
|
||||
nm_utils_strbuf_append_str(&s, &len, "in-addr.arpa");
|
||||
nm_strbuf_append(&s, &len, "%u.", p[i - 1] & 0xff);
|
||||
nm_strbuf_append_str(&s, &len, "in-addr.arpa");
|
||||
|
||||
g_ptr_array_add(domains, str);
|
||||
|
||||
|
|
@ -4124,8 +4124,8 @@ nm_utils_get_reverse_dns_domains_ip_6(const struct in6_addr *ip, guint8 plen, GP
|
|||
str = s = g_malloc(len);
|
||||
|
||||
for (j = nibbles - 1; j >= 0; j--)
|
||||
nm_utils_strbuf_append(&s, &len, "%x.", (addr.s6_addr[j / 2] >> N_SHIFT(j)) & 0xf);
|
||||
nm_utils_strbuf_append_str(&s, &len, "ip6.arpa");
|
||||
nm_strbuf_append(&s, &len, "%x.", (addr.s6_addr[j / 2] >> N_SHIFT(j)) & 0xf);
|
||||
nm_strbuf_append_str(&s, &len, "ip6.arpa");
|
||||
|
||||
g_ptr_array_add(domains, str);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ do_helper(const char *iface,
|
|||
cmdline = g_strdup_vprintf(fmt, args);
|
||||
va_end(args);
|
||||
|
||||
split = nm_utils_strsplit_set_with_empty(cmdline, " ");
|
||||
split = nm_strsplit_set_with_empty(cmdline, " ");
|
||||
if (!split) {
|
||||
g_set_error(error,
|
||||
NM_MANAGER_ERROR,
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ nm_dhcp_config_set_options(NMDhcpConfig *self, GHashTable *options)
|
|||
priv = NM_DHCP_CONFIG_GET_PRIVATE(self);
|
||||
|
||||
nm_g_variant_unref(priv->options);
|
||||
priv->options = g_variant_ref_sink(nm_utils_strdict_to_variant_asv(options));
|
||||
priv->options = g_variant_ref_sink(nm_strdict_to_variant_asv(options));
|
||||
_notify(self, PROP_OPTIONS);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -439,27 +439,23 @@ nm_l3_config_data_log(const NML3ConfigData *self,
|
|||
const char *s_prefix = "ndisc: ";
|
||||
|
||||
if (self->ndisc_hop_limit_set) {
|
||||
nm_utils_strbuf_append(&p,
|
||||
&l,
|
||||
"%shop-limit=%d",
|
||||
s_prefix,
|
||||
self->ndisc_hop_limit_val);
|
||||
nm_strbuf_append(&p, &l, "%shop-limit=%d", s_prefix, self->ndisc_hop_limit_val);
|
||||
s_prefix = ", ";
|
||||
}
|
||||
if (self->ndisc_reachable_time_msec_set) {
|
||||
nm_utils_strbuf_append(&p,
|
||||
&l,
|
||||
"%sreachable-time-msec=%u",
|
||||
s_prefix,
|
||||
self->ndisc_reachable_time_msec_val);
|
||||
nm_strbuf_append(&p,
|
||||
&l,
|
||||
"%sreachable-time-msec=%u",
|
||||
s_prefix,
|
||||
self->ndisc_reachable_time_msec_val);
|
||||
s_prefix = ", ";
|
||||
}
|
||||
if (self->ndisc_retrans_timer_msec_set) {
|
||||
nm_utils_strbuf_append(&p,
|
||||
&l,
|
||||
"%sretrans-timer-msec=%u",
|
||||
s_prefix,
|
||||
self->ndisc_retrans_timer_msec_val);
|
||||
nm_strbuf_append(&p,
|
||||
&l,
|
||||
"%sretrans-timer-msec=%u",
|
||||
s_prefix,
|
||||
self->ndisc_retrans_timer_msec_val);
|
||||
s_prefix = ", ";
|
||||
}
|
||||
_L("%s", sbuf);
|
||||
|
|
|
|||
|
|
@ -358,31 +358,29 @@ _l3_config_notify_data_to_string(const NML3ConfigNotifyData *notify_data,
|
|||
nm_assert(sbuf_size > 0);
|
||||
|
||||
_l3_config_notify_type_to_string(notify_data->notify_type, s, l);
|
||||
nm_utils_strbuf_seek_end(&s, &l);
|
||||
nm_strbuf_seek_end(&s, &l);
|
||||
|
||||
switch (notify_data->notify_type) {
|
||||
case NM_L3_CONFIG_NOTIFY_TYPE_L3CD_CHANGED:
|
||||
nm_utils_strbuf_append(
|
||||
&s,
|
||||
&l,
|
||||
", l3cd-old=%s",
|
||||
NM_HASH_OBFUSCATE_PTR_STR(notify_data->l3cd_changed.l3cd_old, sbufobf));
|
||||
nm_utils_strbuf_append(
|
||||
&s,
|
||||
&l,
|
||||
", l3cd-new=%s",
|
||||
NM_HASH_OBFUSCATE_PTR_STR(notify_data->l3cd_changed.l3cd_new, sbufobf));
|
||||
nm_utils_strbuf_append(&s, &l, ", commited=%d", notify_data->l3cd_changed.commited);
|
||||
nm_strbuf_append(&s,
|
||||
&l,
|
||||
", l3cd-old=%s",
|
||||
NM_HASH_OBFUSCATE_PTR_STR(notify_data->l3cd_changed.l3cd_old, sbufobf));
|
||||
nm_strbuf_append(&s,
|
||||
&l,
|
||||
", l3cd-new=%s",
|
||||
NM_HASH_OBFUSCATE_PTR_STR(notify_data->l3cd_changed.l3cd_new, sbufobf));
|
||||
nm_strbuf_append(&s, &l, ", commited=%d", notify_data->l3cd_changed.commited);
|
||||
break;
|
||||
case NM_L3_CONFIG_NOTIFY_TYPE_ACD_EVENT:
|
||||
nm_utils_strbuf_append(&s,
|
||||
&l,
|
||||
", addr=%s, state=%s",
|
||||
_nm_utils_inet4_ntop(notify_data->acd_event.info.addr, sbuf_addr),
|
||||
_l3_acd_addr_state_to_string(notify_data->acd_event.info.state));
|
||||
nm_strbuf_append(&s,
|
||||
&l,
|
||||
", addr=%s, state=%s",
|
||||
_nm_utils_inet4_ntop(notify_data->acd_event.info.addr, sbuf_addr),
|
||||
_l3_acd_addr_state_to_string(notify_data->acd_event.info.state));
|
||||
break;
|
||||
case NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE:
|
||||
nm_utils_strbuf_append(
|
||||
nm_strbuf_append(
|
||||
&s,
|
||||
&l,
|
||||
", obj-type=%s, change=%s, obj=",
|
||||
|
|
@ -391,15 +389,15 @@ _l3_config_notify_data_to_string(const NML3ConfigNotifyData *notify_data,
|
|||
nmp_object_to_string(notify_data->platform_change.obj, NMP_OBJECT_TO_STRING_PUBLIC, s, l);
|
||||
break;
|
||||
case NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE_ON_IDLE:
|
||||
nm_utils_strbuf_append(&s,
|
||||
&l,
|
||||
", obj-type-flags=0x%x",
|
||||
notify_data->platform_change_on_idle.obj_type_flags);
|
||||
nm_strbuf_append(&s,
|
||||
&l,
|
||||
", obj-type-flags=0x%x",
|
||||
notify_data->platform_change_on_idle.obj_type_flags);
|
||||
break;
|
||||
case NM_L3_CONFIG_NOTIFY_TYPE_IPV4LL_EVENT:
|
||||
nm_assert(NM_IS_L3_IPV4LL(notify_data->ipv4ll_event.ipv4ll));
|
||||
addr4 = nm_l3_ipv4ll_get_addr(notify_data->ipv4ll_event.ipv4ll);
|
||||
nm_utils_strbuf_append(
|
||||
nm_strbuf_append(
|
||||
&s,
|
||||
&l,
|
||||
", ipv4ll=" NM_HASH_OBFUSCATE_PTR_FMT "%s%s, state=%s",
|
||||
|
|
|
|||
|
|
@ -848,7 +848,7 @@ _unhandled_specs_from_hashtable(GHashTable *hash)
|
|||
GSList * list = NULL;
|
||||
guint i, l;
|
||||
|
||||
keys = nm_utils_strdict_get_keys(hash, TRUE, &l);
|
||||
keys = nm_strdict_get_keys(hash, TRUE, &l);
|
||||
for (i = l; i > 0;) {
|
||||
i--;
|
||||
list = g_slist_prepend(list, g_strdup(keys[i]));
|
||||
|
|
|
|||
|
|
@ -474,7 +474,7 @@ make_connection_setting(const char *file,
|
|||
if (v) {
|
||||
gs_free const char **items = NULL;
|
||||
|
||||
items = nm_utils_strsplit_set(v, " ");
|
||||
items = nm_strsplit_set(v, " ");
|
||||
for (iter = items; iter && *iter; iter++) {
|
||||
if (!nm_setting_connection_add_permission(s_con, "user", *iter, NULL))
|
||||
PARSE_WARNING("invalid USERS item '%s'", *iter);
|
||||
|
|
@ -490,7 +490,7 @@ make_connection_setting(const char *file,
|
|||
if (v) {
|
||||
gs_free const char **items = NULL;
|
||||
|
||||
items = nm_utils_strsplit_set(v, " \t");
|
||||
items = nm_strsplit_set(v, " \t");
|
||||
for (iter = items; iter && *iter; iter++) {
|
||||
if (!nm_setting_connection_add_secondary(s_con, *iter))
|
||||
PARSE_WARNING("secondary connection UUID '%s' already added", *iter);
|
||||
|
|
@ -1036,7 +1036,7 @@ parse_route_line(const char *line,
|
|||
* Maybe later we want to support some form of quotation here.
|
||||
* Which of course, would be incompatible with initscripts.
|
||||
*/
|
||||
words_free = nm_utils_strsplit_set(line, " \t\n");
|
||||
words_free = nm_strsplit_set(line, " \t\n");
|
||||
|
||||
words = words_free ?: NM_PTRARRAY_EMPTY(const char *);
|
||||
|
||||
|
|
@ -1582,7 +1582,7 @@ parse_dns_options(NMSettingIPConfig *ip_config, const char *value)
|
|||
if (!nm_setting_ip_config_has_dns_options(ip_config))
|
||||
nm_setting_ip_config_clear_dns_options(ip_config, TRUE);
|
||||
|
||||
options = nm_utils_strsplit_set(value, " ");
|
||||
options = nm_strsplit_set(value, " ");
|
||||
if (options) {
|
||||
for (item = options; *item; item++) {
|
||||
if (!nm_setting_ip_config_add_dns_option(ip_config, *item))
|
||||
|
|
@ -1999,7 +1999,7 @@ make_ip4_setting(shvarFile *ifcfg,
|
|||
if (v) {
|
||||
gs_free const char **searches = NULL;
|
||||
|
||||
searches = nm_utils_strsplit_set(v, " ");
|
||||
searches = nm_strsplit_set(v, " ");
|
||||
if (searches) {
|
||||
for (item = searches; *item; item++) {
|
||||
if (!nm_setting_ip_config_add_dns_search(s_ip4, *item))
|
||||
|
|
@ -2059,7 +2059,7 @@ make_ip4_setting(shvarFile *ifcfg,
|
|||
if (v) {
|
||||
gs_free const char **searches = NULL;
|
||||
|
||||
searches = nm_utils_strsplit_set(v, " ");
|
||||
searches = nm_strsplit_set(v, " ");
|
||||
if (searches) {
|
||||
for (item = searches; *item; item++) {
|
||||
if (!nm_setting_ip_config_add_dns_search(s_ip4, *item))
|
||||
|
|
@ -2433,7 +2433,7 @@ make_ip6_setting(shvarFile *ifcfg, shvarFile *network_ifcfg, gboolean routes_rea
|
|||
ipv6addr_secondaries ?: "",
|
||||
NULL);
|
||||
|
||||
list = nm_utils_strsplit_set(value, " ");
|
||||
list = nm_strsplit_set(value, " ");
|
||||
for (iter = list, i = 0; iter && *iter; iter++, i++) {
|
||||
NMIPAddress *addr = NULL;
|
||||
|
||||
|
|
@ -2532,7 +2532,7 @@ make_ip6_setting(shvarFile *ifcfg, shvarFile *network_ifcfg, gboolean routes_rea
|
|||
if (v) {
|
||||
gs_free const char **searches = NULL;
|
||||
|
||||
searches = nm_utils_strsplit_set(v, " ");
|
||||
searches = nm_strsplit_set(v, " ");
|
||||
if (searches) {
|
||||
for (iter = searches; *iter; iter++) {
|
||||
if (!nm_setting_ip_config_add_dns_search(s_ip6, *iter))
|
||||
|
|
@ -2949,7 +2949,7 @@ read_dcb_percent_array(shvarFile * ifcfg,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
split = nm_utils_strsplit_set(val, ",");
|
||||
split = nm_strsplit_set(val, ",");
|
||||
if (NM_PTRARRAY_LEN(split) != 8) {
|
||||
PARSE_WARNING("invalid %s percentage list value '%s'", prop, val);
|
||||
g_set_error_literal(error,
|
||||
|
|
@ -3368,7 +3368,7 @@ fill_wpa_ciphers(shvarFile *ifcfg, NMSettingWirelessSecurity *wsec, gboolean gro
|
|||
if (!p)
|
||||
return TRUE;
|
||||
|
||||
list = nm_utils_strsplit_set(p, " ");
|
||||
list = nm_strsplit_set(p, " ");
|
||||
for (iter = list; iter && *iter; iter++, i++) {
|
||||
if (!strcmp(*iter, "CCMP")) {
|
||||
if (group)
|
||||
|
|
@ -3604,7 +3604,7 @@ parse_8021x_phase2_auth(shvarFile * ifcfg,
|
|||
}
|
||||
|
||||
inner_auth = g_ascii_strdown(v, -1);
|
||||
list = nm_utils_strsplit_set(inner_auth, " ");
|
||||
list = nm_strsplit_set(inner_auth, " ");
|
||||
for (iter = list; iter && *iter; iter++) {
|
||||
if (NM_IN_STRSET(*iter, "pap", "chap", "mschap", "mschapv2", "gtc", "otp", "md5")) {
|
||||
if (num_auth == 0) {
|
||||
|
|
@ -3779,7 +3779,7 @@ eap_fast_reader(const char * eap_method,
|
|||
if (fast_provisioning) {
|
||||
gs_free const char **list = NULL;
|
||||
|
||||
list = nm_utils_strsplit_set(fast_provisioning, " \t");
|
||||
list = nm_strsplit_set(fast_provisioning, " \t");
|
||||
for (iter = list; iter && *iter; iter++) {
|
||||
if (strcmp(*iter, "allow-unauth") == 0)
|
||||
allow_unauth = TRUE;
|
||||
|
|
@ -3857,7 +3857,7 @@ read_8021x_list_value(shvarFile * ifcfg,
|
|||
if (!v)
|
||||
return;
|
||||
|
||||
strv = nm_utils_strsplit_set(v, " \t");
|
||||
strv = nm_strsplit_set(v, " \t");
|
||||
if (strv)
|
||||
g_object_set(setting, prop_name, strv, NULL);
|
||||
}
|
||||
|
|
@ -3884,7 +3884,7 @@ fill_8021x(shvarFile *ifcfg, const char *file, const char *key_mgmt, gboolean wi
|
|||
return NULL;
|
||||
}
|
||||
|
||||
list = nm_utils_strsplit_set(v, " ");
|
||||
list = nm_strsplit_set(v, " ");
|
||||
|
||||
s_8021x = (NMSetting8021x *) nm_setting_802_1x_new();
|
||||
|
||||
|
|
@ -4237,7 +4237,7 @@ transform_hwaddr_blacklist(const char *blacklist)
|
|||
const char **strv;
|
||||
gsize i, j;
|
||||
|
||||
strv = nm_utils_strsplit_set(blacklist, " \t");
|
||||
strv = nm_strsplit_set(blacklist, " \t");
|
||||
if (!strv)
|
||||
return NULL;
|
||||
for (i = 0, j = 0; strv[j]; j++) {
|
||||
|
|
@ -4706,7 +4706,7 @@ parse_ethtool_option(const char * value,
|
|||
gs_free const char **words = NULL;
|
||||
NMEthtoolType ethtool_type = NM_ETHTOOL_TYPE_UNKNOWN;
|
||||
|
||||
words = nm_utils_strsplit_set(value, " \t\n");
|
||||
words = nm_strsplit_set(value, " \t\n");
|
||||
if (!words)
|
||||
return;
|
||||
|
||||
|
|
@ -4968,7 +4968,7 @@ parse_ethtool_options(shvarFile *ifcfg, NMConnection *connection)
|
|||
gs_free const char **opts = NULL;
|
||||
const char *const * iter;
|
||||
|
||||
opts = nm_utils_strsplit_set(ethtool_opts, ";");
|
||||
opts = nm_strsplit_set(ethtool_opts, ";");
|
||||
for (iter = opts; iter && iter[0]; iter++) {
|
||||
/* in case of repeated wol_passwords, parse_ethtool_option()
|
||||
* will do the right thing and clear wol_password before resetting. */
|
||||
|
|
@ -5076,7 +5076,7 @@ make_wired_setting(shvarFile *ifcfg, const char *file, NMSetting8021x **s_8021x,
|
|||
gs_free const char **chans = NULL;
|
||||
guint32 num_chans;
|
||||
|
||||
chans = nm_utils_strsplit_set(cvalue, ",");
|
||||
chans = nm_strsplit_set(cvalue, ",");
|
||||
num_chans = NM_PTRARRAY_LEN(chans);
|
||||
if (num_chans < 2 || num_chans > 3) {
|
||||
PARSE_WARNING("invalid SUBCHANNELS '%s' (%u channels, 2 or 3 expected)",
|
||||
|
|
@ -5448,7 +5448,7 @@ make_bond_setting(shvarFile *ifcfg, const char *file, GError **error)
|
|||
gs_free const char **items = NULL;
|
||||
const char *const * iter;
|
||||
|
||||
items = nm_utils_strsplit_set(v, " ");
|
||||
items = nm_strsplit_set(v, " ");
|
||||
for (iter = items; iter && *iter; iter++) {
|
||||
gs_free char *key = NULL;
|
||||
const char * val;
|
||||
|
|
@ -5758,7 +5758,7 @@ handle_bridging_opts(NMSetting * setting,
|
|||
gs_free const char **items = NULL;
|
||||
const char *const * iter;
|
||||
|
||||
items = nm_utils_strsplit_set(value, " ");
|
||||
items = nm_strsplit_set(value, " ");
|
||||
for (iter = items; iter && *iter; iter++) {
|
||||
gs_free char *key = NULL;
|
||||
const char * val;
|
||||
|
|
@ -6019,7 +6019,7 @@ parse_prio_map_list(NMSettingVlan *s_vlan, shvarFile *ifcfg, const char *key, NM
|
|||
v = svGetValueStr(ifcfg, key, &value);
|
||||
if (!v)
|
||||
return;
|
||||
list = nm_utils_strsplit_set(v, ",");
|
||||
list = nm_strsplit_set(v, ",");
|
||||
|
||||
for (iter = list; iter && *iter; iter++) {
|
||||
if (!strchr(*iter, ':'))
|
||||
|
|
@ -6130,7 +6130,7 @@ make_vlan_setting(shvarFile *ifcfg, const char *file, GError **error)
|
|||
gs_free const char **strv = NULL;
|
||||
const char *const * ptr;
|
||||
|
||||
strv = nm_utils_strsplit_set(v, ", ");
|
||||
strv = nm_strsplit_set(v, ", ");
|
||||
for (ptr = strv; ptr && *ptr; ptr++) {
|
||||
if (nm_streq(*ptr, "GVRP") && gvrp == -1)
|
||||
vlan_flags |= NM_VLAN_FLAG_GVRP;
|
||||
|
|
@ -6276,7 +6276,7 @@ check_dns_search_domains(shvarFile *ifcfg, NMSetting *s_ip4, NMSetting *s_ip6)
|
|||
gs_free const char **searches = NULL;
|
||||
const char *const * item;
|
||||
|
||||
searches = nm_utils_strsplit_set(v, " ");
|
||||
searches = nm_strsplit_set(v, " ");
|
||||
if (searches) {
|
||||
for (item = searches; *item; item++) {
|
||||
if (!nm_setting_ip_config_add_dns_search(NM_SETTING_IP_CONFIG(s_ip6), *item))
|
||||
|
|
|
|||
|
|
@ -1442,12 +1442,12 @@ write_vlan_setting(NMConnection *connection, shvarFile *ifcfg, gboolean *wired,
|
|||
svSetValueBoolean(ifcfg, "REORDER_HDR", NM_FLAGS_HAS(vlan_flags, NM_VLAN_FLAG_REORDER_HEADERS));
|
||||
svSetValueBoolean(ifcfg, "GVRP", NM_FLAGS_HAS(vlan_flags, NM_VLAN_FLAG_GVRP));
|
||||
|
||||
nm_utils_strbuf_init(s_buf, &s_buf_ptr, &s_buf_len);
|
||||
nm_strbuf_init_arr(s_buf, &s_buf_ptr, &s_buf_len);
|
||||
|
||||
if (NM_FLAGS_HAS(vlan_flags, NM_VLAN_FLAG_LOOSE_BINDING))
|
||||
nm_utils_strbuf_append_str(&s_buf_ptr, &s_buf_len, "LOOSE_BINDING");
|
||||
nm_strbuf_append_str(&s_buf_ptr, &s_buf_len, "LOOSE_BINDING");
|
||||
if (!NM_FLAGS_HAS(vlan_flags, NM_VLAN_FLAG_REORDER_HEADERS))
|
||||
nm_utils_strbuf_append(&s_buf_ptr, &s_buf_len, "%sNO_REORDER_HDR", s_buf[0] ? "," : "");
|
||||
nm_strbuf_append(&s_buf_ptr, &s_buf_len, "%sNO_REORDER_HDR", s_buf[0] ? "," : "");
|
||||
|
||||
svSetValueStr(ifcfg, "VLAN_FLAGS", s_buf);
|
||||
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ ifupdown_ip4_add_dns(NMSettingIPConfig *s_ip4, const char *dns)
|
|||
if (dns == NULL)
|
||||
return;
|
||||
|
||||
list = nm_utils_strsplit_set(dns, " \t");
|
||||
list = nm_strsplit_set(dns, " \t");
|
||||
for (iter = list; iter && *iter; iter++) {
|
||||
if (!inet_pton(AF_INET, *iter, &addr)) {
|
||||
_LOGW(" ignoring invalid nameserver '%s'", *iter);
|
||||
|
|
@ -497,7 +497,7 @@ update_ip4_setting_from_if_block(NMConnection *connection, if_block *block, GErr
|
|||
gs_free const char **list = NULL;
|
||||
const char ** iter;
|
||||
|
||||
list = nm_utils_strsplit_set(search_v, " \t");
|
||||
list = nm_strsplit_set(search_v, " \t");
|
||||
for (iter = list; iter && *iter; iter++) {
|
||||
if (!nm_setting_ip_config_add_dns_search(s_ip4, *iter))
|
||||
_LOGW(" duplicate DNS domain '%s'", *iter);
|
||||
|
|
@ -521,7 +521,7 @@ ifupdown_ip6_add_dns(NMSettingIPConfig *s_ip6, const char *dns)
|
|||
if (dns == NULL)
|
||||
return;
|
||||
|
||||
list = nm_utils_strsplit_set(dns, " \t");
|
||||
list = nm_strsplit_set(dns, " \t");
|
||||
for (iter = list; iter && *iter; iter++) {
|
||||
if (!inet_pton(AF_INET6, *iter, &addr)) {
|
||||
_LOGW(" ignoring invalid nameserver '%s'", *iter);
|
||||
|
|
@ -605,7 +605,7 @@ update_ip6_setting_from_if_block(NMConnection *connection, if_block *block, GErr
|
|||
gs_free const char **list = NULL;
|
||||
const char ** iter;
|
||||
|
||||
list = nm_utils_strsplit_set(search_v, " \t");
|
||||
list = nm_strsplit_set(search_v, " \t");
|
||||
for (iter = list; iter && *iter; iter++) {
|
||||
if (!nm_setting_ip_config_add_dns_search(s_ip6, *iter))
|
||||
_LOGW(" duplicate DNS domain '%s'", *iter);
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ _unmanaged_specs(GHashTable *eni_ifaces)
|
|||
GSList * specs = NULL;
|
||||
guint i, len;
|
||||
|
||||
keys = nm_utils_strdict_get_keys(eni_ifaces, TRUE, &len);
|
||||
keys = nm_strdict_get_keys(eni_ifaces, TRUE, &len);
|
||||
for (i = len; i > 0;) {
|
||||
i--;
|
||||
specs = g_slist_prepend(specs,
|
||||
|
|
@ -264,7 +264,7 @@ load_eni_ifaces(NMSIfupdownPlugin *self)
|
|||
|
||||
_LOGD("parse: found bridge ports %s for %s", ports, block->name);
|
||||
|
||||
port_ifaces = nm_utils_strsplit_set(ports, " \t");
|
||||
port_ifaces = nm_strsplit_set(ports, " \t");
|
||||
for (i = 0; port_ifaces && port_ifaces[i]; i++) {
|
||||
const char *token = port_ifaces[i];
|
||||
|
||||
|
|
|
|||
|
|
@ -101,27 +101,27 @@ _extra_flags_to_string(char * str,
|
|||
const char *str0 = str;
|
||||
|
||||
if (!is_nm_generated && !is_volatile && !is_external)
|
||||
nm_utils_strbuf_append_str(&str, &str_len, "");
|
||||
nm_strbuf_append_str(&str, &str_len, "");
|
||||
else {
|
||||
char ch = '(';
|
||||
|
||||
nm_utils_strbuf_append_c(&str, &str_len, ' ');
|
||||
nm_strbuf_append_c(&str, &str_len, ' ');
|
||||
if (is_nm_generated) {
|
||||
nm_utils_strbuf_append_c(&str, &str_len, ch);
|
||||
nm_utils_strbuf_append_str(&str, &str_len, "nm-generated");
|
||||
nm_strbuf_append_c(&str, &str_len, ch);
|
||||
nm_strbuf_append_str(&str, &str_len, "nm-generated");
|
||||
ch = ',';
|
||||
}
|
||||
if (is_volatile) {
|
||||
nm_utils_strbuf_append_c(&str, &str_len, ch);
|
||||
nm_utils_strbuf_append_str(&str, &str_len, "volatile");
|
||||
nm_strbuf_append_c(&str, &str_len, ch);
|
||||
nm_strbuf_append_str(&str, &str_len, "volatile");
|
||||
ch = ',';
|
||||
}
|
||||
if (is_external) {
|
||||
nm_utils_strbuf_append_c(&str, &str_len, ch);
|
||||
nm_utils_strbuf_append_str(&str, &str_len, "external");
|
||||
nm_strbuf_append_c(&str, &str_len, ch);
|
||||
nm_strbuf_append_str(&str, &str_len, "external");
|
||||
ch = ',';
|
||||
}
|
||||
nm_utils_strbuf_append_c(&str, &str_len, ')');
|
||||
nm_strbuf_append_c(&str, &str_len, ')');
|
||||
}
|
||||
|
||||
return str0;
|
||||
|
|
|
|||
|
|
@ -918,19 +918,19 @@ _peer_info_properties_changed(NMSupplicantInterface *self,
|
|||
peer_info->signal_percent = nm_wifi_utils_level_to_quality(v_i32);
|
||||
|
||||
if (nm_g_variant_lookup(properties, "DeviceName", "&s", &v_s))
|
||||
nm_utils_strdup_reset(&peer_info->device_name, v_s);
|
||||
nm_strdup_reset(&peer_info->device_name, v_s);
|
||||
|
||||
if (nm_g_variant_lookup(properties, "Manufacturer", "&s", &v_s))
|
||||
nm_utils_strdup_reset(&peer_info->manufacturer, v_s);
|
||||
nm_strdup_reset(&peer_info->manufacturer, v_s);
|
||||
|
||||
if (nm_g_variant_lookup(properties, "Model", "&s", &v_s))
|
||||
nm_utils_strdup_reset(&peer_info->model, v_s);
|
||||
nm_strdup_reset(&peer_info->model, v_s);
|
||||
|
||||
if (nm_g_variant_lookup(properties, "ModelNumber", "&s", &v_s))
|
||||
nm_utils_strdup_reset(&peer_info->model_number, v_s);
|
||||
nm_strdup_reset(&peer_info->model_number, v_s);
|
||||
|
||||
if (nm_g_variant_lookup(properties, "Serial", "&s", &v_s))
|
||||
nm_utils_strdup_reset(&peer_info->serial, v_s);
|
||||
nm_strdup_reset(&peer_info->serial, v_s);
|
||||
|
||||
if (nm_g_variant_lookup(properties, "Groups", "^a&o", &v_strv)) {
|
||||
g_free(peer_info->groups);
|
||||
|
|
@ -1907,11 +1907,11 @@ _properties_changed_main(NMSupplicantInterface *self, GVariant *properties)
|
|||
}
|
||||
|
||||
if (nm_g_variant_lookup(properties, "Ifname", "&s", &v_s)) {
|
||||
if (nm_utils_strdup_reset(&priv->ifname, v_s))
|
||||
if (nm_strdup_reset(&priv->ifname, v_s))
|
||||
do_log_driver_info = TRUE;
|
||||
}
|
||||
if (nm_g_variant_lookup(properties, "Driver", "&s", &v_s)) {
|
||||
if (nm_utils_strdup_reset(&priv->driver, v_s))
|
||||
if (nm_strdup_reset(&priv->driver, v_s))
|
||||
do_log_driver_info = TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1728,86 +1728,86 @@ test_nm_utils_strbuf_append(void)
|
|||
char buf[NM_STRLEN(BUF_ORIG) + 1];
|
||||
char str[NM_STRLEN(BUF_ORIG) + 1];
|
||||
|
||||
#define _strbuf_append(buf, len, format, ...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
char ** _buf = (buf); \
|
||||
gsize * _len = (len); \
|
||||
const char * _str_iter; \
|
||||
gs_free char *_str = NULL; \
|
||||
\
|
||||
switch (nmtst_get_rand_uint32() % 4) { \
|
||||
case 0: \
|
||||
nm_utils_strbuf_append(_buf, _len, (format), __VA_ARGS__); \
|
||||
break; \
|
||||
case 1: \
|
||||
_str = g_strdup_printf((format), __VA_ARGS__); \
|
||||
nm_utils_strbuf_append_str(_buf, _len, _str); \
|
||||
break; \
|
||||
case 2: \
|
||||
_str = g_strdup_printf((format), __VA_ARGS__); \
|
||||
nm_utils_strbuf_append_bin(_buf, _len, _str, strlen(_str)); \
|
||||
break; \
|
||||
case 3: \
|
||||
_str = g_strdup_printf((format), __VA_ARGS__); \
|
||||
if (!_str[0]) \
|
||||
nm_utils_strbuf_append_str(_buf, _len, _str); \
|
||||
for (_str_iter = _str; _str_iter[0]; _str_iter++) \
|
||||
nm_utils_strbuf_append_c(_buf, _len, _str_iter[0]); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
#define _strbuf_append(buf, len, format, ...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
char ** _buf = (buf); \
|
||||
gsize * _len = (len); \
|
||||
const char * _str_iter; \
|
||||
gs_free char *_str = NULL; \
|
||||
\
|
||||
switch (nmtst_get_rand_uint32() % 4) { \
|
||||
case 0: \
|
||||
nm_strbuf_append(_buf, _len, (format), __VA_ARGS__); \
|
||||
break; \
|
||||
case 1: \
|
||||
_str = g_strdup_printf((format), __VA_ARGS__); \
|
||||
nm_strbuf_append_str(_buf, _len, _str); \
|
||||
break; \
|
||||
case 2: \
|
||||
_str = g_strdup_printf((format), __VA_ARGS__); \
|
||||
nm_strbuf_append_bin(_buf, _len, _str, strlen(_str)); \
|
||||
break; \
|
||||
case 3: \
|
||||
_str = g_strdup_printf((format), __VA_ARGS__); \
|
||||
if (!_str[0]) \
|
||||
nm_strbuf_append_str(_buf, _len, _str); \
|
||||
for (_str_iter = _str; _str_iter[0]; _str_iter++) \
|
||||
nm_strbuf_append_c(_buf, _len, _str_iter[0]); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
#define _strbuf_append_str(buf, len, str) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
char ** _buf = (buf); \
|
||||
gsize * _len = (len); \
|
||||
const char *_str = (str); \
|
||||
\
|
||||
switch (nmtst_get_rand_uint32() % 4) { \
|
||||
case 0: \
|
||||
nm_utils_strbuf_append(_buf, _len, "%s", _str ?: ""); \
|
||||
break; \
|
||||
case 1: \
|
||||
nm_utils_strbuf_append_str(_buf, _len, _str); \
|
||||
break; \
|
||||
case 2: \
|
||||
nm_utils_strbuf_append_bin(_buf, _len, _str, _str ? strlen(_str) : 0); \
|
||||
break; \
|
||||
case 3: \
|
||||
if (!_str || !_str[0]) \
|
||||
nm_utils_strbuf_append_str(_buf, _len, _str); \
|
||||
for (; _str && _str[0]; _str++) \
|
||||
nm_utils_strbuf_append_c(_buf, _len, _str[0]); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
#define _strbuf_append_str(buf, len, str) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
char ** _buf = (buf); \
|
||||
gsize * _len = (len); \
|
||||
const char *_str = (str); \
|
||||
\
|
||||
switch (nmtst_get_rand_uint32() % 4) { \
|
||||
case 0: \
|
||||
nm_strbuf_append(_buf, _len, "%s", _str ?: ""); \
|
||||
break; \
|
||||
case 1: \
|
||||
nm_strbuf_append_str(_buf, _len, _str); \
|
||||
break; \
|
||||
case 2: \
|
||||
nm_strbuf_append_bin(_buf, _len, _str, _str ? strlen(_str) : 0); \
|
||||
break; \
|
||||
case 3: \
|
||||
if (!_str || !_str[0]) \
|
||||
nm_strbuf_append_str(_buf, _len, _str); \
|
||||
for (; _str && _str[0]; _str++) \
|
||||
nm_strbuf_append_c(_buf, _len, _str[0]); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
#define _strbuf_append_c(buf, len, ch) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
char **_buf = (buf); \
|
||||
gsize *_len = (len); \
|
||||
char _ch = (ch); \
|
||||
\
|
||||
switch (nmtst_get_rand_uint32() % 4) { \
|
||||
case 0: \
|
||||
nm_utils_strbuf_append(_buf, _len, "%c", _ch); \
|
||||
break; \
|
||||
case 1: \
|
||||
nm_utils_strbuf_append_str(_buf, _len, ((char[2]){_ch, 0})); \
|
||||
break; \
|
||||
case 2: \
|
||||
nm_utils_strbuf_append_bin(_buf, _len, &_ch, 1); \
|
||||
break; \
|
||||
case 3: \
|
||||
nm_utils_strbuf_append_c(_buf, _len, _ch); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
#define _strbuf_append_c(buf, len, ch) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
char **_buf = (buf); \
|
||||
gsize *_len = (len); \
|
||||
char _ch = (ch); \
|
||||
\
|
||||
switch (nmtst_get_rand_uint32() % 4) { \
|
||||
case 0: \
|
||||
nm_strbuf_append(_buf, _len, "%c", _ch); \
|
||||
break; \
|
||||
case 1: \
|
||||
nm_strbuf_append_str(_buf, _len, ((char[2]){_ch, 0})); \
|
||||
break; \
|
||||
case 2: \
|
||||
nm_strbuf_append_bin(_buf, _len, &_ch, 1); \
|
||||
break; \
|
||||
case 3: \
|
||||
nm_strbuf_append_c(_buf, _len, _ch); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
for (buf_len = 0; buf_len < 10; buf_len++) {
|
||||
|
|
@ -1854,28 +1854,28 @@ test_nm_utils_strbuf_append(void)
|
|||
if (t_len > 0 && strlen(str) >= buf_len && (nmtst_get_rand_uint32() % 2)) {
|
||||
/* the string was truncated by g_snprintf(). That means, at the last position in the
|
||||
* buffer is now NUL.
|
||||
* Replace the NUL by the actual character, and check that nm_utils_strbuf_seek_end()
|
||||
* Replace the NUL by the actual character, and check that nm_strbuf_seek_end()
|
||||
* does the right thing: NUL terminate the buffer and seek past the end of the buffer. */
|
||||
g_assert_cmpmem(t_buf, t_len - 1, str, t_len - 1);
|
||||
g_assert(t_buf[t_len - 1] == '\0');
|
||||
g_assert(str[t_len - 1] != '\0');
|
||||
t_buf[t_len - 1] = str[t_len - 1];
|
||||
nm_utils_strbuf_seek_end(&t_buf, &t_len);
|
||||
nm_strbuf_seek_end(&t_buf, &t_len);
|
||||
g_assert(t_len == 0);
|
||||
g_assert(t_buf == &buf[buf_len]);
|
||||
g_assert(t_buf[-1] == '\0');
|
||||
} else {
|
||||
nm_utils_strbuf_seek_end(&t_buf, &t_len);
|
||||
nm_strbuf_seek_end(&t_buf, &t_len);
|
||||
if (buf_len > 0 && strlen(str) + 1 > buf_len) {
|
||||
/* the buffer was truncated by g_snprintf() above.
|
||||
*
|
||||
* But nm_utils_strbuf_seek_end() does not recognize that and returns
|
||||
* But nm_strbuf_seek_end() does not recognize that and returns
|
||||
* a remaining length of 1.
|
||||
*
|
||||
* Note that other nm_utils_strbuf_append*() functions recognize
|
||||
* Note that other nm_strbuf_append*() functions recognize
|
||||
* truncation, and properly set the remaining length to zero.
|
||||
* As the assertions below check for the behavior of nm_utils_strbuf_append*(),
|
||||
* we assert here that nm_utils_strbuf_seek_end() behaved as expected, and then
|
||||
* As the assertions below check for the behavior of nm_strbuf_append*(),
|
||||
* we assert here that nm_strbuf_seek_end() behaved as expected, and then
|
||||
* adjust t_buf/t_len according to the "is-truncated" case. */
|
||||
g_assert(t_len == 1);
|
||||
g_assert(t_buf == &buf[buf_len - 1]);
|
||||
|
|
@ -2594,7 +2594,7 @@ main(int argc, char **argv)
|
|||
g_test_add_func("/general/test_logging_domains", test_logging_domains);
|
||||
g_test_add_func("/general/test_logging_error", test_logging_error);
|
||||
|
||||
g_test_add_func("/general/nm_utils_strbuf_append", test_nm_utils_strbuf_append);
|
||||
g_test_add_func("/general/nm_strbuf_append", test_nm_utils_strbuf_append);
|
||||
|
||||
g_test_add_func("/general/nm_utils_ip6_address_clear_host_address",
|
||||
test_nm_utils_ip6_address_clear_host_address);
|
||||
|
|
|
|||
|
|
@ -1267,8 +1267,8 @@ _nm_device_notify_update_prop_hw_address(NMClient * client,
|
|||
|
||||
priv->hw_address_is_new = is_new;
|
||||
|
||||
nm_utils_strdup_reset(&priv->hw_address,
|
||||
_nml_coerce_property_str_not_empty(g_variant_get_string(value, NULL)));
|
||||
nm_strdup_reset(&priv->hw_address,
|
||||
_nml_coerce_property_str_not_empty(g_variant_get_string(value, NULL)));
|
||||
|
||||
/* always emit a changed signal here, even if "priv->hw_address" might be unchanged.
|
||||
* We want to emit the signal because we received a PropertiesChanged signal on D-Bus,
|
||||
|
|
@ -2999,7 +2999,7 @@ nm_lldp_neighbor_get_attr_names(NMLldpNeighbor *neighbor)
|
|||
|
||||
g_return_val_if_fail(NM_IS_LLDP_NEIGHBOR(neighbor), NULL);
|
||||
|
||||
keys = nm_utils_strdict_get_keys(neighbor->attrs, TRUE, NULL);
|
||||
keys = nm_strdict_get_keys(neighbor->attrs, TRUE, NULL);
|
||||
|
||||
return nm_strv_make_deep_copied_nonnull(keys);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
const char **
|
||||
nm_utils_bond_option_arp_ip_targets_split(const char *arp_ip_target)
|
||||
{
|
||||
return nm_utils_strsplit_set_full(arp_ip_target, ",", NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
return nm_strsplit_set_full(arp_ip_target, ",", NM_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ parse_old_openssl_key_file(const guint8 * data,
|
|||
"Malformed PEM file: both Proc-Type and DEK-Info tags are required.");
|
||||
return FALSE;
|
||||
}
|
||||
nm_utils_strbuf_append_str(&str_p, &str_len, p);
|
||||
nm_strbuf_append_str(&str_p, &str_len, p);
|
||||
nm_assert(str_len > 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2483,7 +2483,7 @@ write_hash_of_string(GKeyFile *file, NMSetting *setting, const char *key, const
|
|||
|
||||
hash = g_value_get_boxed(value);
|
||||
|
||||
keys = nm_utils_strdict_get_keys(hash, TRUE, &l);
|
||||
keys = nm_strdict_get_keys(hash, TRUE, &l);
|
||||
for (i = 0; i < l; i++) {
|
||||
gs_free char *to_free = NULL;
|
||||
const char * property, *data;
|
||||
|
|
|
|||
|
|
@ -527,7 +527,7 @@ _nm_ip_address_get_attribute_names(const NMIPAddress *address, gboolean sorted,
|
|||
{
|
||||
nm_assert(address);
|
||||
|
||||
return nm_utils_strdict_get_keys(address->attributes, sorted, out_length);
|
||||
return nm_strdict_get_keys(address->attributes, sorted, out_length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1134,7 +1134,7 @@ _nm_ip_route_get_attribute_names(const NMIPRoute *route, gboolean sorted, guint
|
|||
{
|
||||
nm_assert(route);
|
||||
|
||||
return nm_utils_strdict_get_keys(route->attributes, sorted, out_length);
|
||||
return nm_strdict_get_keys(route->attributes, sorted, out_length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ nm_setting_ovs_external_ids_get_data_keys(NMSettingOvsExternalIDs *setting, guin
|
|||
return priv->data_keys;
|
||||
}
|
||||
|
||||
priv->data_keys = nm_utils_strdict_get_keys(priv->data, TRUE, out_len);
|
||||
priv->data_keys = nm_strdict_get_keys(priv->data, TRUE, out_len);
|
||||
|
||||
/* don't return %NULL, but hijack the @data_keys fields as a pseudo
|
||||
* empty strv array. */
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ nm_sriov_vf_get_attribute_names(const NMSriovVF *vf)
|
|||
g_return_val_if_fail(vf, NULL);
|
||||
g_return_val_if_fail(vf->refcount > 0, NULL);
|
||||
|
||||
return nm_utils_strdict_get_keys(vf->attributes, TRUE, NULL);
|
||||
return nm_strdict_get_keys(vf->attributes, TRUE, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -904,7 +904,7 @@ vfs_to_dbus(const NMSettInfoSetting * sett_info,
|
|||
"index",
|
||||
g_variant_new_uint32(nm_sriov_vf_get_index(vf)));
|
||||
|
||||
attr_names = nm_utils_strdict_get_keys(vf->attributes, TRUE, NULL);
|
||||
attr_names = nm_strdict_get_keys(vf->attributes, TRUE, NULL);
|
||||
if (attr_names) {
|
||||
for (name = attr_names; *name; name++) {
|
||||
g_variant_builder_add(&vf_builder,
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ nm_tc_qdisc_get_attribute_names(NMTCQdisc *qdisc)
|
|||
{
|
||||
g_return_val_if_fail(qdisc, NULL);
|
||||
|
||||
return nm_utils_strdict_get_keys(qdisc->attributes, TRUE, NULL);
|
||||
return nm_strdict_get_keys(qdisc->attributes, TRUE, NULL);
|
||||
}
|
||||
|
||||
GHashTable *
|
||||
|
|
@ -594,7 +594,7 @@ nm_tc_action_get_attribute_names(NMTCAction *action)
|
|||
|
||||
g_return_val_if_fail(action, NULL);
|
||||
|
||||
names = nm_utils_strdict_get_keys(action->attributes, TRUE, NULL);
|
||||
names = nm_strdict_get_keys(action->attributes, TRUE, NULL);
|
||||
return nm_strv_make_deep_copied_nonnull(names);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ nm_setting_user_get_keys(NMSettingUser *setting, guint *out_len)
|
|||
return priv->keys;
|
||||
}
|
||||
|
||||
priv->keys = nm_utils_strdict_get_keys(priv->data, TRUE, out_len);
|
||||
priv->keys = nm_strdict_get_keys(priv->data, TRUE, out_len);
|
||||
|
||||
/* don't return %NULL, but hijack the @keys fields as a pseudo
|
||||
* empty strv array. */
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ nm_setting_vpn_get_data_keys(NMSettingVpn *setting, guint *out_length)
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_VPN(setting), NULL);
|
||||
|
||||
return nm_utils_strdict_get_keys(NM_SETTING_VPN_GET_PRIVATE(setting)->data, TRUE, out_length);
|
||||
return nm_strdict_get_keys(NM_SETTING_VPN_GET_PRIVATE(setting)->data, TRUE, out_length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -278,7 +278,7 @@ foreach_item_helper(NMSettingVpn *self, GHashTable **p_hash, NMVpnIterFunc func,
|
|||
nm_assert(NM_IS_SETTING_VPN(self));
|
||||
nm_assert(func);
|
||||
|
||||
keys = nm_strv_make_deep_copied(nm_utils_strdict_get_keys(*p_hash, TRUE, &len));
|
||||
keys = nm_strv_make_deep_copied(nm_strdict_get_keys(*p_hash, TRUE, &len));
|
||||
if (len == 0u) {
|
||||
nm_assert(!keys);
|
||||
return;
|
||||
|
|
@ -408,9 +408,7 @@ nm_setting_vpn_get_secret_keys(NMSettingVpn *setting, guint *out_length)
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_VPN(setting), NULL);
|
||||
|
||||
return nm_utils_strdict_get_keys(NM_SETTING_VPN_GET_PRIVATE(setting)->secrets,
|
||||
TRUE,
|
||||
out_length);
|
||||
return nm_strdict_get_keys(NM_SETTING_VPN_GET_PRIVATE(setting)->secrets, TRUE, out_length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -960,7 +958,7 @@ vpn_secrets_to_dbus(const NMSettInfoSetting * sett_info,
|
|||
|
||||
g_variant_builder_init(&builder, G_VARIANT_TYPE("a{ss}"));
|
||||
|
||||
keys = nm_utils_strdict_get_keys(priv->secrets, TRUE, &len);
|
||||
keys = nm_strdict_get_keys(priv->secrets, TRUE, &len);
|
||||
for (i = 0; i < len; i++) {
|
||||
const char * key = keys[i];
|
||||
NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
|
||||
|
|
|
|||
|
|
@ -626,7 +626,7 @@ nm_setting_wired_add_s390_option(NMSettingWired *setting, const char *key, const
|
|||
};
|
||||
priv->s390_options.len++;
|
||||
} else {
|
||||
if (!nm_utils_strdup_reset(&priv->s390_options.arr[idx].value_str_mutable, value))
|
||||
if (!nm_strdup_reset(&priv->s390_options.arr[idx].value_str_mutable, value))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -678,21 +678,20 @@ static gboolean
|
|||
_property_direct_set_string(const NMSettInfoProperty *property_info, char **dst, const char *src)
|
||||
{
|
||||
if (property_info->direct_set_string_ascii_strdown)
|
||||
return nm_utils_strdup_reset_take(dst, src ? g_ascii_strdown(src, -1) : NULL);
|
||||
return nm_strdup_reset_take(dst, src ? g_ascii_strdown(src, -1) : NULL);
|
||||
if (property_info->direct_set_string_mac_address_len > 0) {
|
||||
return nm_utils_strdup_reset_take(dst,
|
||||
_nm_utils_hwaddr_canonical_or_invalid(
|
||||
src,
|
||||
property_info->direct_set_string_mac_address_len));
|
||||
return nm_strdup_reset_take(dst,
|
||||
_nm_utils_hwaddr_canonical_or_invalid(
|
||||
src,
|
||||
property_info->direct_set_string_mac_address_len));
|
||||
}
|
||||
if (property_info->direct_set_string_ip_address_addr_family != 0) {
|
||||
return nm_utils_strdup_reset_take(
|
||||
dst,
|
||||
_nm_utils_ipaddr_canonical_or_invalid(
|
||||
property_info->direct_set_string_ip_address_addr_family,
|
||||
src));
|
||||
return nm_strdup_reset_take(dst,
|
||||
_nm_utils_ipaddr_canonical_or_invalid(
|
||||
property_info->direct_set_string_ip_address_addr_family,
|
||||
src));
|
||||
}
|
||||
return nm_utils_strdup_reset(dst, src);
|
||||
return nm_strdup_reset(dst, src);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -1091,7 +1090,7 @@ _nm_setting_property_to_dbus_fcn_gprop(const NMSettInfoSetting * s
|
|||
return nm_g_variant_new_au((const guint32 *) tmp_array->data, tmp_array->len);
|
||||
case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_STRDICT:
|
||||
nm_assert(G_VALUE_HOLDS(&prop_value, G_TYPE_HASH_TABLE));
|
||||
return nm_utils_strdict_to_variant_ass(g_value_get_boxed(&prop_value));
|
||||
return nm_strdict_to_variant_ass(g_value_get_boxed(&prop_value));
|
||||
}
|
||||
|
||||
return nm_assert_unreachable_val(NULL);
|
||||
|
|
@ -1130,7 +1129,7 @@ _nm_setting_property_from_dbus_fcn_direct_mac_address(const NMSettInfoSetting *
|
|||
|
||||
array = g_variant_get_fixed_array(value, &length, 1);
|
||||
|
||||
if (nm_utils_strdup_reset_take(
|
||||
if (nm_strdup_reset_take(
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset),
|
||||
length > 0 ? nm_utils_hwaddr_ntoa(array, length) : NULL))
|
||||
g_object_notify_by_pspec(G_OBJECT(setting), property_info->param_spec);
|
||||
|
|
@ -3327,7 +3326,7 @@ _nm_setting_option_get_all(NMSetting * setting,
|
|||
return len;
|
||||
|
||||
if (G_UNLIKELY(!gendata->names)) {
|
||||
gendata->names = nm_utils_strdict_get_keys(hash, TRUE, NULL);
|
||||
gendata->names = nm_strdict_get_keys(hash, TRUE, NULL);
|
||||
}
|
||||
|
||||
if (out_values) {
|
||||
|
|
|
|||
|
|
@ -2882,7 +2882,7 @@ _nm_sriov_vf_parse_vlans(NMSriovVF *vf, const char *str, GError **error)
|
|||
gs_free const char **vlans = NULL;
|
||||
guint i;
|
||||
|
||||
vlans = nm_utils_strsplit_set(str, ";");
|
||||
vlans = nm_strsplit_set(str, ";");
|
||||
if (!vlans) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
|
|
|
|||
|
|
@ -542,27 +542,25 @@ test_nm_g_slice_free_fcn(void)
|
|||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
_do_test_nm_utils_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags,
|
||||
const char * str,
|
||||
gsize words_len,
|
||||
const char *const * exp_words)
|
||||
_do_test_nm_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags,
|
||||
const char * str,
|
||||
gsize words_len,
|
||||
const char *const * exp_words)
|
||||
{
|
||||
#define DELIMITERS " \n"
|
||||
#define DELIMITERS_C ' ', '\n'
|
||||
|
||||
gs_free const char **words = NULL;
|
||||
gsize i, j, k;
|
||||
const gboolean f_allow_escaping =
|
||||
NM_FLAGS_HAS(flags, NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING);
|
||||
const gboolean f_preserve_empty =
|
||||
NM_FLAGS_HAS(flags, NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY);
|
||||
const gboolean f_allow_escaping = NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING);
|
||||
const gboolean f_preserve_empty = NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY);
|
||||
const char * s1;
|
||||
gsize initial_offset;
|
||||
gs_strfreev char **words_g = NULL;
|
||||
|
||||
g_assert(!NM_FLAGS_ANY(flags,
|
||||
~(NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING
|
||||
| NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY)));
|
||||
g_assert(!NM_FLAGS_ANY(
|
||||
flags,
|
||||
~(NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING | NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY)));
|
||||
|
||||
/* assert that the expected words are valid (and don't contain unescaped delimiters). */
|
||||
for (i = 0; i < words_len; i++) {
|
||||
|
|
@ -623,12 +621,12 @@ _do_test_nm_utils_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags,
|
|||
}
|
||||
}
|
||||
|
||||
if (flags == NM_UTILS_STRSPLIT_SET_FLAGS_NONE && nmtst_get_rand_bool())
|
||||
words = nm_utils_strsplit_set(str, DELIMITERS);
|
||||
else if (flags == NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY && nmtst_get_rand_bool())
|
||||
words = nm_utils_strsplit_set_with_empty(str, DELIMITERS);
|
||||
if (flags == NM_STRSPLIT_SET_FLAGS_NONE && nmtst_get_rand_bool())
|
||||
words = nm_strsplit_set(str, DELIMITERS);
|
||||
else if (flags == NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY && nmtst_get_rand_bool())
|
||||
words = nm_strsplit_set_with_empty(str, DELIMITERS);
|
||||
else
|
||||
words = nm_utils_strsplit_set_full(str, DELIMITERS, flags);
|
||||
words = nm_strsplit_set_full(str, DELIMITERS, flags);
|
||||
|
||||
g_assert_cmpint(NM_PTRARRAY_LEN(words), ==, words_len);
|
||||
|
||||
|
|
@ -751,14 +749,14 @@ _do_test_nm_utils_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags,
|
|||
}
|
||||
|
||||
static void
|
||||
_do_test_nm_utils_strsplit_set_f(NMUtilsStrsplitSetFlags flags,
|
||||
const char * str,
|
||||
gsize words_len,
|
||||
const char *const * exp_words)
|
||||
_do_test_nm_strsplit_set_f(NMUtilsStrsplitSetFlags flags,
|
||||
const char * str,
|
||||
gsize words_len,
|
||||
const char *const * exp_words)
|
||||
{
|
||||
_do_test_nm_utils_strsplit_set_f_one(flags, str, words_len, exp_words);
|
||||
_do_test_nm_strsplit_set_f_one(flags, str, words_len, exp_words);
|
||||
|
||||
if (NM_FLAGS_HAS(flags, NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY)) {
|
||||
if (NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY)) {
|
||||
gs_unref_ptrarray GPtrArray *exp_words2 = NULL;
|
||||
gsize k;
|
||||
|
||||
|
|
@ -768,32 +766,32 @@ _do_test_nm_utils_strsplit_set_f(NMUtilsStrsplitSetFlags flags,
|
|||
g_ptr_array_add(exp_words2, (gpointer) exp_words[k]);
|
||||
}
|
||||
|
||||
_do_test_nm_utils_strsplit_set_f_one(flags & (~NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY),
|
||||
str,
|
||||
exp_words2->len,
|
||||
(const char *const *) exp_words2->pdata);
|
||||
_do_test_nm_strsplit_set_f_one(flags & (~NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY),
|
||||
str,
|
||||
exp_words2->len,
|
||||
(const char *const *) exp_words2->pdata);
|
||||
}
|
||||
}
|
||||
|
||||
#define do_test_nm_utils_strsplit_set_f(flags, str, ...) \
|
||||
_do_test_nm_utils_strsplit_set_f(flags, str, NM_NARG(__VA_ARGS__), NM_MAKE_STRV(__VA_ARGS__))
|
||||
#define do_test_nm_strsplit_set_f(flags, str, ...) \
|
||||
_do_test_nm_strsplit_set_f(flags, str, NM_NARG(__VA_ARGS__), NM_MAKE_STRV(__VA_ARGS__))
|
||||
|
||||
#define do_test_nm_utils_strsplit_set(allow_escaping, str, ...) \
|
||||
do_test_nm_utils_strsplit_set_f((allow_escaping) ? NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING \
|
||||
: NM_UTILS_STRSPLIT_SET_FLAGS_NONE, \
|
||||
str, \
|
||||
##__VA_ARGS__)
|
||||
#define do_test_nm_strsplit_set(allow_escaping, str, ...) \
|
||||
do_test_nm_strsplit_set_f((allow_escaping) ? NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING \
|
||||
: NM_STRSPLIT_SET_FLAGS_NONE, \
|
||||
str, \
|
||||
##__VA_ARGS__)
|
||||
|
||||
static void
|
||||
_do_test_nm_utils_strsplit_set_simple(NMUtilsStrsplitSetFlags flags,
|
||||
const char * str,
|
||||
gsize words_len,
|
||||
const char *const * exp_words)
|
||||
_do_test_nm_strsplit_set_simple(NMUtilsStrsplitSetFlags flags,
|
||||
const char * str,
|
||||
gsize words_len,
|
||||
const char *const * exp_words)
|
||||
{
|
||||
gs_free const char **tokens = NULL;
|
||||
gsize n_tokens;
|
||||
|
||||
tokens = nm_utils_strsplit_set_full(str, DELIMITERS, flags);
|
||||
tokens = nm_strsplit_set_full(str, DELIMITERS, flags);
|
||||
|
||||
if (!tokens) {
|
||||
g_assert_cmpint(words_len, ==, 0);
|
||||
|
|
@ -826,107 +824,87 @@ _do_test_nm_utils_strsplit_set_simple(NMUtilsStrsplitSetFlags flags,
|
|||
}
|
||||
g_assert_cmpint(words_len, ==, NM_PTRARRAY_LEN(tokens));
|
||||
}
|
||||
#define do_test_nm_utils_strsplit_set_simple(flags, str, ...) \
|
||||
_do_test_nm_utils_strsplit_set_simple((flags), \
|
||||
(str), \
|
||||
NM_NARG(__VA_ARGS__), \
|
||||
NM_MAKE_STRV(__VA_ARGS__))
|
||||
#define do_test_nm_strsplit_set_simple(flags, str, ...) \
|
||||
_do_test_nm_strsplit_set_simple((flags), (str), NM_NARG(__VA_ARGS__), NM_MAKE_STRV(__VA_ARGS__))
|
||||
|
||||
static void
|
||||
test_nm_utils_strsplit_set(void)
|
||||
test_nm_strsplit_set(void)
|
||||
{
|
||||
gs_unref_ptrarray GPtrArray *words_exp = NULL;
|
||||
guint test_run;
|
||||
|
||||
do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_NONE, NULL);
|
||||
do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_NONE, "");
|
||||
do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_NONE, " ");
|
||||
do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_NONE, "a b", "a", "b");
|
||||
do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_NONE, NULL);
|
||||
do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_NONE, "");
|
||||
do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_NONE, " ");
|
||||
do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_NONE, "a b", "a", "b");
|
||||
|
||||
do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, NULL);
|
||||
do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "");
|
||||
do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, " ", "", "");
|
||||
do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, " ", "", "", "");
|
||||
do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "a ", "a", "", "");
|
||||
do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY,
|
||||
"a b",
|
||||
"a",
|
||||
"",
|
||||
"b");
|
||||
do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY,
|
||||
" ab b",
|
||||
"",
|
||||
"ab",
|
||||
"",
|
||||
"b");
|
||||
do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY,
|
||||
"ab b",
|
||||
"ab",
|
||||
"",
|
||||
"b");
|
||||
do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "abb", "abb");
|
||||
do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY,
|
||||
"abb bb ",
|
||||
"abb",
|
||||
"",
|
||||
"bb",
|
||||
"");
|
||||
do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY,
|
||||
"abb bcb ",
|
||||
"abb",
|
||||
"bcb",
|
||||
"");
|
||||
do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, NULL);
|
||||
do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "");
|
||||
do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, " ", "", "");
|
||||
do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, " ", "", "", "");
|
||||
do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "a ", "a", "", "");
|
||||
do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "a b", "a", "", "b");
|
||||
do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, " ab b", "", "ab", "", "b");
|
||||
do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "ab b", "ab", "", "b");
|
||||
do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "abb", "abb");
|
||||
do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY,
|
||||
"abb bb ",
|
||||
"abb",
|
||||
"",
|
||||
"bb",
|
||||
"");
|
||||
do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "abb bcb ", "abb", "bcb", "");
|
||||
|
||||
do_test_nm_utils_strsplit_set(FALSE, NULL);
|
||||
do_test_nm_utils_strsplit_set(FALSE, "");
|
||||
do_test_nm_utils_strsplit_set(FALSE, "\n");
|
||||
do_test_nm_utils_strsplit_set(TRUE, " \t\n", "\t");
|
||||
do_test_nm_utils_strsplit_set(FALSE, "a", "a");
|
||||
do_test_nm_utils_strsplit_set(FALSE, "a b", "a", "b");
|
||||
do_test_nm_utils_strsplit_set(FALSE, "a\rb", "a\rb");
|
||||
do_test_nm_utils_strsplit_set(FALSE, " a\rb ", "a\rb");
|
||||
do_test_nm_utils_strsplit_set(FALSE, " a bbbd afds ere", "a", "bbbd", "afds", "ere");
|
||||
do_test_nm_utils_strsplit_set(FALSE,
|
||||
"1 2 3 4 5 6 7 8 9 0 "
|
||||
"1 2 3 4 5 6 7 8 9 0 "
|
||||
"1 2 3 4 5 6 7 8 9 0",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"0",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"0",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"0");
|
||||
do_test_nm_utils_strsplit_set(TRUE, "\\", "\\");
|
||||
do_test_nm_utils_strsplit_set(TRUE, "\\ ", "\\ ");
|
||||
do_test_nm_utils_strsplit_set(TRUE, "\\\\", "\\\\");
|
||||
do_test_nm_utils_strsplit_set(TRUE, "\\\t", "\\\t");
|
||||
do_test_nm_utils_strsplit_set(TRUE, "foo\\", "foo\\");
|
||||
do_test_nm_utils_strsplit_set(TRUE, "bar foo\\", "bar", "foo\\");
|
||||
do_test_nm_utils_strsplit_set(TRUE, "\\ a b\\ \\ c", "\\ a", "b\\ \\ ", "c");
|
||||
do_test_nm_strsplit_set(FALSE, NULL);
|
||||
do_test_nm_strsplit_set(FALSE, "");
|
||||
do_test_nm_strsplit_set(FALSE, "\n");
|
||||
do_test_nm_strsplit_set(TRUE, " \t\n", "\t");
|
||||
do_test_nm_strsplit_set(FALSE, "a", "a");
|
||||
do_test_nm_strsplit_set(FALSE, "a b", "a", "b");
|
||||
do_test_nm_strsplit_set(FALSE, "a\rb", "a\rb");
|
||||
do_test_nm_strsplit_set(FALSE, " a\rb ", "a\rb");
|
||||
do_test_nm_strsplit_set(FALSE, " a bbbd afds ere", "a", "bbbd", "afds", "ere");
|
||||
do_test_nm_strsplit_set(FALSE,
|
||||
"1 2 3 4 5 6 7 8 9 0 "
|
||||
"1 2 3 4 5 6 7 8 9 0 "
|
||||
"1 2 3 4 5 6 7 8 9 0",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"0",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"0",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"0");
|
||||
do_test_nm_strsplit_set(TRUE, "\\", "\\");
|
||||
do_test_nm_strsplit_set(TRUE, "\\ ", "\\ ");
|
||||
do_test_nm_strsplit_set(TRUE, "\\\\", "\\\\");
|
||||
do_test_nm_strsplit_set(TRUE, "\\\t", "\\\t");
|
||||
do_test_nm_strsplit_set(TRUE, "foo\\", "foo\\");
|
||||
do_test_nm_strsplit_set(TRUE, "bar foo\\", "bar", "foo\\");
|
||||
do_test_nm_strsplit_set(TRUE, "\\ a b\\ \\ c", "\\ a", "b\\ \\ ", "c");
|
||||
|
||||
words_exp = g_ptr_array_new_with_free_func(g_free);
|
||||
for (test_run = 0; test_run < 100; test_run++) {
|
||||
|
|
@ -974,52 +952,40 @@ test_nm_utils_strsplit_set(void)
|
|||
words_len = 0;
|
||||
}
|
||||
|
||||
_do_test_nm_utils_strsplit_set_f((f_allow_escaping
|
||||
? NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING
|
||||
: NM_UTILS_STRSPLIT_SET_FLAGS_NONE)
|
||||
| NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY,
|
||||
str,
|
||||
words_len,
|
||||
(const char *const *) words_exp->pdata);
|
||||
_do_test_nm_strsplit_set_f(
|
||||
(f_allow_escaping ? NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING : NM_STRSPLIT_SET_FLAGS_NONE)
|
||||
| NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY,
|
||||
str,
|
||||
words_len,
|
||||
(const char *const *) words_exp->pdata);
|
||||
}
|
||||
|
||||
do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED, "\t", "\t");
|
||||
do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED
|
||||
| NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP,
|
||||
"\t");
|
||||
do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED
|
||||
| NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP
|
||||
| NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY,
|
||||
"\t",
|
||||
"");
|
||||
do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED
|
||||
| NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP
|
||||
| NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY,
|
||||
"\t\\\t\t\t\\\t",
|
||||
"\t\t\t\t");
|
||||
do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED, "\t", "\t");
|
||||
do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED | NM_STRSPLIT_SET_FLAGS_STRSTRIP,
|
||||
"\t");
|
||||
do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED | NM_STRSPLIT_SET_FLAGS_STRSTRIP
|
||||
| NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY,
|
||||
"\t",
|
||||
"");
|
||||
do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED | NM_STRSPLIT_SET_FLAGS_STRSTRIP
|
||||
| NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY,
|
||||
"\t\\\t\t\t\\\t",
|
||||
"\t\t\t\t");
|
||||
|
||||
do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED, "\ta", "\ta");
|
||||
do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED
|
||||
| NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP,
|
||||
"\ta",
|
||||
"a");
|
||||
do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED,
|
||||
"\ta\\ b\t\\ ",
|
||||
"\ta b\t ");
|
||||
do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED
|
||||
| NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP,
|
||||
"\ta\\ b\t\\ \t",
|
||||
"a b\t ");
|
||||
do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED, "a\\ b", "a ", "b");
|
||||
do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED,
|
||||
"\ta\\ b",
|
||||
"\ta ",
|
||||
"b");
|
||||
do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED
|
||||
| NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP,
|
||||
"\ta\\ b",
|
||||
"a ",
|
||||
"b");
|
||||
do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED, "\ta", "\ta");
|
||||
do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED | NM_STRSPLIT_SET_FLAGS_STRSTRIP,
|
||||
"\ta",
|
||||
"a");
|
||||
do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED, "\ta\\ b\t\\ ", "\ta b\t ");
|
||||
do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED | NM_STRSPLIT_SET_FLAGS_STRSTRIP,
|
||||
"\ta\\ b\t\\ \t",
|
||||
"a b\t ");
|
||||
do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED, "a\\ b", "a ", "b");
|
||||
do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED, "\ta\\ b", "\ta ", "b");
|
||||
do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED | NM_STRSPLIT_SET_FLAGS_STRSTRIP,
|
||||
"\ta\\ b",
|
||||
"a ",
|
||||
"b");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -10718,7 +10684,7 @@ main(int argc, char **argv)
|
|||
g_test_add_func("/core/general/test_c_list_sort", test_c_list_sort);
|
||||
g_test_add_func("/core/general/test_dedup_multi", test_dedup_multi);
|
||||
g_test_add_func("/core/general/test_utils_str_utf8safe", test_utils_str_utf8safe);
|
||||
g_test_add_func("/core/general/test_nm_utils_strsplit_set", test_nm_utils_strsplit_set);
|
||||
g_test_add_func("/core/general/test_nm_strsplit_set", test_nm_strsplit_set);
|
||||
g_test_add_func("/core/general/test_nm_utils_escaped_tokens", test_nm_utils_escaped_tokens);
|
||||
g_test_add_func("/core/general/test_nm_in_set", test_nm_in_set);
|
||||
g_test_add_func("/core/general/test_nm_in_strset", test_nm_in_strset);
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ _nm_assert_on_main_thread(void)
|
|||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
nm_utils_strbuf_append_c(char **buf, gsize *len, char c)
|
||||
nm_strbuf_append_c(char **buf, gsize *len, char c)
|
||||
{
|
||||
switch (*len) {
|
||||
case 0:
|
||||
|
|
@ -283,7 +283,7 @@ nm_utils_strbuf_append_c(char **buf, gsize *len, char c)
|
|||
}
|
||||
|
||||
void
|
||||
nm_utils_strbuf_append_bin(char **buf, gsize *len, gconstpointer str, gsize str_len)
|
||||
nm_strbuf_append_bin(char **buf, gsize *len, gconstpointer str, gsize str_len)
|
||||
{
|
||||
switch (*len) {
|
||||
case 0:
|
||||
|
|
@ -318,7 +318,7 @@ nm_utils_strbuf_append_bin(char **buf, gsize *len, gconstpointer str, gsize str_
|
|||
}
|
||||
|
||||
void
|
||||
nm_utils_strbuf_append_str(char **buf, gsize *len, const char *str)
|
||||
nm_strbuf_append_str(char **buf, gsize *len, const char *str)
|
||||
{
|
||||
gsize src_len;
|
||||
|
||||
|
|
@ -352,7 +352,7 @@ nm_utils_strbuf_append_str(char **buf, gsize *len, const char *str)
|
|||
}
|
||||
|
||||
void
|
||||
nm_utils_strbuf_append(char **buf, gsize *len, const char *format, ...)
|
||||
nm_strbuf_append(char **buf, gsize *len, const char *format, ...)
|
||||
{
|
||||
char * p = *buf;
|
||||
va_list args;
|
||||
|
|
@ -375,25 +375,25 @@ nm_utils_strbuf_append(char **buf, gsize *len, const char *format, ...)
|
|||
}
|
||||
|
||||
/**
|
||||
* nm_utils_strbuf_seek_end:
|
||||
* nm_strbuf_seek_end:
|
||||
* @buf: the input/output buffer
|
||||
* @len: the input/output length of the buffer.
|
||||
*
|
||||
* Commonly, one uses nm_utils_strbuf_append*(), to incrementally
|
||||
* Commonly, one uses nm_strbuf_append*(), to incrementally
|
||||
* append strings to the buffer. However, sometimes we need to use
|
||||
* existing API to write to the buffer.
|
||||
* After doing so, we want to adjust the buffer counter.
|
||||
* Essentially,
|
||||
*
|
||||
* g_snprintf (buf, len, ...);
|
||||
* nm_utils_strbuf_seek_end (&buf, &len);
|
||||
* nm_strbuf_seek_end (&buf, &len);
|
||||
*
|
||||
* is almost the same as
|
||||
*
|
||||
* nm_utils_strbuf_append (&buf, &len, ...);
|
||||
* nm_strbuf_append (&buf, &len, ...);
|
||||
*
|
||||
* The only difference is the behavior when the string got truncated:
|
||||
* nm_utils_strbuf_append() will recognize that and set the remaining
|
||||
* nm_strbuf_append() will recognize that and set the remaining
|
||||
* length to zero.
|
||||
*
|
||||
* In general, the behavior is:
|
||||
|
|
@ -411,13 +411,13 @@ nm_utils_strbuf_append(char **buf, gsize *len, const char *format, ...)
|
|||
* the NUL byte. This would happen with
|
||||
*
|
||||
* strncpy (buf, long_str, len);
|
||||
* nm_utils_strbuf_seek_end (&buf, &len).
|
||||
* nm_strbuf_seek_end (&buf, &len).
|
||||
*
|
||||
* where strncpy() does truncate the string and not NUL terminate it.
|
||||
* nm_utils_strbuf_seek_end() would then NUL terminate it.
|
||||
* nm_strbuf_seek_end() would then NUL terminate it.
|
||||
*/
|
||||
void
|
||||
nm_utils_strbuf_seek_end(char **buf, gsize *len)
|
||||
nm_strbuf_seek_end(char **buf, gsize *len)
|
||||
{
|
||||
gsize l;
|
||||
char *end;
|
||||
|
|
@ -622,7 +622,7 @@ nm_g_variant_singleton_aaLsvI(void)
|
|||
/*****************************************************************************/
|
||||
|
||||
GHashTable *
|
||||
nm_utils_strdict_clone(GHashTable *src)
|
||||
nm_strdict_clone(GHashTable *src)
|
||||
{
|
||||
GHashTable * dst;
|
||||
GHashTableIter iter;
|
||||
|
|
@ -644,7 +644,7 @@ nm_utils_strdict_clone(GHashTable *src)
|
|||
* Returns a floating reference.
|
||||
*/
|
||||
GVariant *
|
||||
nm_utils_strdict_to_variant_ass(GHashTable *strdict)
|
||||
nm_strdict_to_variant_ass(GHashTable *strdict)
|
||||
{
|
||||
gs_free NMUtilsNamedValue *values_free = NULL;
|
||||
NMUtilsNamedValue values_prepared[20];
|
||||
|
|
@ -665,7 +665,7 @@ nm_utils_strdict_to_variant_ass(GHashTable *strdict)
|
|||
/*****************************************************************************/
|
||||
|
||||
GVariant *
|
||||
nm_utils_strdict_to_variant_asv(GHashTable *strdict)
|
||||
nm_strdict_to_variant_asv(GHashTable *strdict)
|
||||
{
|
||||
gs_free NMUtilsNamedValue *values_free = NULL;
|
||||
NMUtilsNamedValue values_prepared[20];
|
||||
|
|
@ -714,7 +714,7 @@ nm_strquote(char *buf, gsize buf_len, const char *str)
|
|||
const char *const buf0 = buf;
|
||||
|
||||
if (!str) {
|
||||
nm_utils_strbuf_append_str(&buf, &buf_len, "(null)");
|
||||
nm_strbuf_append_str(&buf, &buf_len, "(null)");
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -733,7 +733,7 @@ nm_strquote(char *buf, gsize buf_len, const char *str)
|
|||
*(buf++) = '"';
|
||||
buf_len--;
|
||||
|
||||
nm_utils_strbuf_append_str(&buf, &buf_len, str);
|
||||
nm_strbuf_append_str(&buf, &buf_len, str);
|
||||
|
||||
/* if the string was too long we indicate truncation with a
|
||||
* '^' instead of a closing quote. */
|
||||
|
|
@ -817,7 +817,7 @@ nm_utils_flags2str(const NMUtilsFlags2StrDesc *descs,
|
|||
if (!flags) {
|
||||
for (i = 0; i < n_descs; i++) {
|
||||
if (!descs[i].flag) {
|
||||
nm_utils_strbuf_append_str(&p, &len, descs[i].name);
|
||||
nm_strbuf_append_str(&p, &len, descs[i].name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -829,14 +829,14 @@ nm_utils_flags2str(const NMUtilsFlags2StrDesc *descs,
|
|||
flags &= ~descs[i].flag;
|
||||
|
||||
if (buf[0] != '\0')
|
||||
nm_utils_strbuf_append_c(&p, &len, ',');
|
||||
nm_utils_strbuf_append_str(&p, &len, descs[i].name);
|
||||
nm_strbuf_append_c(&p, &len, ',');
|
||||
nm_strbuf_append_str(&p, &len, descs[i].name);
|
||||
}
|
||||
}
|
||||
if (flags) {
|
||||
if (buf[0] != '\0')
|
||||
nm_utils_strbuf_append_c(&p, &len, ',');
|
||||
nm_utils_strbuf_append(&p, &len, "0x%x", flags);
|
||||
nm_strbuf_append_c(&p, &len, ',');
|
||||
nm_strbuf_append(&p, &len, "0x%x", flags);
|
||||
}
|
||||
return buf;
|
||||
};
|
||||
|
|
@ -1732,7 +1732,7 @@ _char_lookup_has_all(const CharLookupTable *lookup, const char *candidates)
|
|||
}
|
||||
|
||||
/**
|
||||
* nm_utils_strsplit_set_full:
|
||||
* nm_strsplit_set_full:
|
||||
* @str: the string to split.
|
||||
* @delimiters: the set of delimiters.
|
||||
* @flags: additional flags for controlling the operation.
|
||||
|
|
@ -1746,7 +1746,7 @@ _char_lookup_has_all(const CharLookupTable *lookup, const char *candidates)
|
|||
* This never returns an empty array.
|
||||
*
|
||||
* Returns: %NULL if @str is %NULL or "".
|
||||
* If @str only contains delimiters and %NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY
|
||||
* If @str only contains delimiters and %NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY
|
||||
* is not set, it also returns %NULL.
|
||||
* Otherwise, a %NULL terminated strv array containing the split words.
|
||||
* (delimiter characters are removed).
|
||||
|
|
@ -1757,7 +1757,7 @@ _char_lookup_has_all(const CharLookupTable *lookup, const char *candidates)
|
|||
* like "g_strstrip((char *) iter[0])".
|
||||
*/
|
||||
const char **
|
||||
nm_utils_strsplit_set_full(const char *str, const char *delimiters, NMUtilsStrsplitSetFlags flags)
|
||||
nm_strsplit_set_full(const char *str, const char *delimiters, NMUtilsStrsplitSetFlags flags)
|
||||
{
|
||||
const char ** ptr;
|
||||
gsize num_tokens;
|
||||
|
|
@ -1766,12 +1766,11 @@ nm_utils_strsplit_set_full(const char *str, const char *delimiters, NMUtilsStrsp
|
|||
const char * c_str;
|
||||
char * s;
|
||||
CharLookupTable ch_lookup;
|
||||
const gboolean f_escaped = NM_FLAGS_HAS(flags, NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED);
|
||||
const gboolean f_escaped = NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_ESCAPED);
|
||||
const gboolean f_allow_escaping =
|
||||
f_escaped || NM_FLAGS_HAS(flags, NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING);
|
||||
const gboolean f_preserve_empty =
|
||||
NM_FLAGS_HAS(flags, NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY);
|
||||
const gboolean f_strstrip = NM_FLAGS_HAS(flags, NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
f_escaped || NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING);
|
||||
const gboolean f_preserve_empty = NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY);
|
||||
const gboolean f_strstrip = NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
|
@ -1790,8 +1789,8 @@ nm_utils_strsplit_set_full(const char *str, const char *delimiters, NMUtilsStrsp
|
|||
}
|
||||
|
||||
if (!str[0]) {
|
||||
/* We return %NULL here, also with NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY.
|
||||
* That makes nm_utils_strsplit_set_full() with NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY
|
||||
/* We return %NULL here, also with NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY.
|
||||
* That makes nm_strsplit_set_full() with NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY
|
||||
* different from g_strsplit_set(), which would in this case return an empty array.
|
||||
* If you need to handle %NULL, and "" specially, then check the input string first. */
|
||||
return NULL;
|
||||
|
|
@ -2174,7 +2173,7 @@ nm_utils_escaped_tokens_options_split(char *str, const char **out_key, const cha
|
|||
* with the flags "EXTRACT_UNQUOTE | EXTRACT_RELAX". This is what
|
||||
* systemd uses to parse /proc/cmdline, and we do too.
|
||||
*
|
||||
* Splits the string. We have nm_utils_strsplit_set() which
|
||||
* Splits the string. We have nm_strsplit_set() which
|
||||
* supports a variety of flags. However, extending that already
|
||||
* complex code to also support quotation and escaping is hard.
|
||||
* Instead, add a naive implementation.
|
||||
|
|
@ -4285,7 +4284,7 @@ nm_utils_get_start_time_for_pid(pid_t pid, char *out_state, pid_t *out_ppid)
|
|||
|
||||
state = p[0];
|
||||
|
||||
tokens = nm_utils_strsplit_set(p, " ");
|
||||
tokens = nm_strsplit_set(p, " ");
|
||||
|
||||
if (NM_PTRARRAY_LEN(tokens) < 20)
|
||||
goto fail;
|
||||
|
|
|
|||
|
|
@ -565,25 +565,25 @@ extern const void *const _NM_PTRARRAY_EMPTY[1];
|
|||
#define NM_STRV_EMPTY_CC() NM_PTRARRAY_EMPTY(const char *)
|
||||
|
||||
static inline void
|
||||
_nm_utils_strbuf_init(char *buf, gsize len, char **p_buf_ptr, gsize *p_buf_len)
|
||||
nm_strbuf_init(char *buf, gsize len, char **p_buf_ptr, gsize *p_buf_len)
|
||||
{
|
||||
NM_SET_OUT(p_buf_len, len);
|
||||
NM_SET_OUT(p_buf_ptr, buf);
|
||||
buf[0] = '\0';
|
||||
}
|
||||
|
||||
#define nm_utils_strbuf_init(buf, p_buf_ptr, p_buf_len) \
|
||||
#define nm_strbuf_init_arr(buf, p_buf_ptr, p_buf_len) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
G_STATIC_ASSERT(G_N_ELEMENTS(buf) == sizeof(buf) && sizeof(buf) > sizeof(char *)); \
|
||||
_nm_utils_strbuf_init((buf), sizeof(buf), (p_buf_ptr), (p_buf_len)); \
|
||||
nm_strbuf_init((buf), sizeof(buf), (p_buf_ptr), (p_buf_len)); \
|
||||
} \
|
||||
G_STMT_END
|
||||
void nm_utils_strbuf_append(char **buf, gsize *len, const char *format, ...) _nm_printf(3, 4);
|
||||
void nm_utils_strbuf_append_c(char **buf, gsize *len, char c);
|
||||
void nm_utils_strbuf_append_str(char **buf, gsize *len, const char *str);
|
||||
void nm_utils_strbuf_append_bin(char **buf, gsize *len, gconstpointer str, gsize str_len);
|
||||
void nm_utils_strbuf_seek_end(char **buf, gsize *len);
|
||||
void nm_strbuf_append(char **buf, gsize *len, const char *format, ...) _nm_printf(3, 4);
|
||||
void nm_strbuf_append_c(char **buf, gsize *len, char c);
|
||||
void nm_strbuf_append_str(char **buf, gsize *len, const char *str);
|
||||
void nm_strbuf_append_bin(char **buf, gsize *len, gconstpointer str, gsize str_len);
|
||||
void nm_strbuf_seek_end(char **buf, gsize *len);
|
||||
|
||||
const char *nm_strquote(char *buf, gsize buf_len, const char *str);
|
||||
|
||||
|
|
@ -609,10 +609,10 @@ gboolean nm_utils_gbytes_equal_mem(GBytes *bytes, gconstpointer mem_data, gsize
|
|||
|
||||
GVariant *nm_utils_gbytes_to_variant_ay(GBytes *bytes);
|
||||
|
||||
GHashTable *nm_utils_strdict_clone(GHashTable *src);
|
||||
GHashTable *nm_strdict_clone(GHashTable *src);
|
||||
|
||||
GVariant *nm_utils_strdict_to_variant_ass(GHashTable *strdict);
|
||||
GVariant *nm_utils_strdict_to_variant_asv(GHashTable *strdict);
|
||||
GVariant *nm_strdict_to_variant_ass(GHashTable *strdict);
|
||||
GVariant *nm_strdict_to_variant_asv(GHashTable *strdict);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -656,85 +656,85 @@ int nm_utils_dbus_path_cmp(const char *dbus_path_a, const char *dbus_path_b);
|
|||
/*****************************************************************************/
|
||||
|
||||
typedef enum {
|
||||
NM_UTILS_STRSPLIT_SET_FLAGS_NONE = 0,
|
||||
NM_STRSPLIT_SET_FLAGS_NONE = 0,
|
||||
|
||||
/* by default, strsplit will coalesce consecutive delimiters and remove
|
||||
* them from the result. If this flag is present, empty values are preserved
|
||||
* and returned.
|
||||
*
|
||||
* When combined with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP, if a value gets
|
||||
* When combined with %NM_STRSPLIT_SET_FLAGS_STRSTRIP, if a value gets
|
||||
* empty after strstrip(), it also gets removed. */
|
||||
NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY = (1u << 0),
|
||||
NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY = (1u << 0),
|
||||
|
||||
/* %NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING means that delimiters prefixed
|
||||
/* %NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING means that delimiters prefixed
|
||||
* by a backslash are not treated as a separator. Such delimiters and their escape
|
||||
* character are copied to the current word without unescaping them. In general,
|
||||
* nm_utils_strsplit_set_full() does not remove any backslash escape characters
|
||||
* nm_strsplit_set_full() does not remove any backslash escape characters
|
||||
* and does no unescaping. It only considers them for skipping to split at
|
||||
* an escaped delimiter.
|
||||
*
|
||||
* If this is combined with (or implied by %NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED), then
|
||||
* If this is combined with (or implied by %NM_STRSPLIT_SET_FLAGS_ESCAPED), then
|
||||
* the backslash escapes are removed from the result.
|
||||
*/
|
||||
NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING = (1u << 1),
|
||||
NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING = (1u << 1),
|
||||
|
||||
/* If flag is set, does the same as g_strstrip() on the returned tokens.
|
||||
* This will remove leading and trailing ascii whitespaces (g_ascii_isspace()
|
||||
* and NM_ASCII_SPACES).
|
||||
*
|
||||
* - when combined with !%NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY,
|
||||
* - when combined with !%NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY,
|
||||
* empty tokens will be removed (and %NULL will be returned if that
|
||||
* results in an empty string array).
|
||||
* - when combined with %NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING,
|
||||
* - when combined with %NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING,
|
||||
* trailing whitespace escaped by backslash are not stripped. */
|
||||
NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP = (1u << 2),
|
||||
NM_STRSPLIT_SET_FLAGS_STRSTRIP = (1u << 2),
|
||||
|
||||
/* This implies %NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING.
|
||||
/* This implies %NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING.
|
||||
*
|
||||
* This will do a final run over all tokens and remove all backslash
|
||||
* escape characters that
|
||||
* - precede a delimiter.
|
||||
* - precede a backslash.
|
||||
* - precede a whitespace (only with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP).
|
||||
* - precede a whitespace (only with %NM_STRSPLIT_SET_FLAGS_STRSTRIP).
|
||||
*
|
||||
* Note that with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP, it is only
|
||||
* Note that with %NM_STRSPLIT_SET_FLAGS_STRSTRIP, it is only
|
||||
* necessary to escape the very last whitespace (if the delimiters
|
||||
* are not whitespace themself). So, technically, it would be sufficient
|
||||
* to only unescape a backslash before the last whitespace and the user
|
||||
* still could express everything. However, such a rule would be complicated
|
||||
* to understand, so when using backslash escaping with nm_utils_strsplit_set_full(),
|
||||
* to understand, so when using backslash escaping with nm_strsplit_set_full(),
|
||||
* then all characters (including backslash) are treated verbatim, except:
|
||||
*
|
||||
* - "\\$DELIMITER" (escaped delimiter)
|
||||
* - "\\\\" (escaped backslash)
|
||||
* - "\\$SPACE" (escaped space) (only with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP).
|
||||
* - "\\$SPACE" (escaped space) (only with %NM_STRSPLIT_SET_FLAGS_STRSTRIP).
|
||||
*
|
||||
* Note that all other escapes like "\\n" or "\\001" are left alone.
|
||||
* That makes the escaping/unescaping rules simple. Also, for the most part
|
||||
* a text is just taken as-is, with little additional rules. Only backslashes
|
||||
* need extra care, and then only if they proceed one of the relevant characters.
|
||||
*/
|
||||
NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED = (1u << 3),
|
||||
NM_STRSPLIT_SET_FLAGS_ESCAPED = (1u << 3),
|
||||
|
||||
} NMUtilsStrsplitSetFlags;
|
||||
|
||||
const char **
|
||||
nm_utils_strsplit_set_full(const char *str, const char *delimiter, NMUtilsStrsplitSetFlags flags);
|
||||
nm_strsplit_set_full(const char *str, const char *delimiter, NMUtilsStrsplitSetFlags flags);
|
||||
|
||||
static inline const char **
|
||||
nm_utils_strsplit_set_with_empty(const char *str, const char *delimiters)
|
||||
nm_strsplit_set_with_empty(const char *str, const char *delimiters)
|
||||
{
|
||||
/* this returns the same result as g_strsplit_set(str, delimiters, -1), except
|
||||
* it does not deep-clone the strv array.
|
||||
* Also, for @str == "", this returns %NULL while g_strsplit_set() would return
|
||||
* an empty strv array. */
|
||||
return nm_utils_strsplit_set_full(str, delimiters, NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY);
|
||||
return nm_strsplit_set_full(str, delimiters, NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY);
|
||||
}
|
||||
|
||||
static inline const char **
|
||||
nm_utils_strsplit_set(const char *str, const char *delimiters)
|
||||
nm_strsplit_set(const char *str, const char *delimiters)
|
||||
{
|
||||
return nm_utils_strsplit_set_full(str, delimiters, NM_UTILS_STRSPLIT_SET_FLAGS_NONE);
|
||||
return nm_strsplit_set_full(str, delimiters, NM_STRSPLIT_SET_FLAGS_NONE);
|
||||
}
|
||||
|
||||
gssize _nm_strv_find_first(const char *const *list, gssize len, const char *needle);
|
||||
|
|
@ -769,10 +769,9 @@ nm_copy_func_g_strdup(gconstpointer arg, gpointer user_data)
|
|||
static inline const char **
|
||||
nm_utils_escaped_tokens_split(const char *str, const char *delimiters)
|
||||
{
|
||||
return nm_utils_strsplit_set_full(str,
|
||||
delimiters,
|
||||
NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED
|
||||
| NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
return nm_strsplit_set_full(str,
|
||||
delimiters,
|
||||
NM_STRSPLIT_SET_FLAGS_ESCAPED | NM_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
|
|
@ -895,10 +894,10 @@ char **nm_utils_strsplit_quoted(const char *str);
|
|||
static inline const char **
|
||||
nm_utils_escaped_tokens_options_split_list(const char *str)
|
||||
{
|
||||
return nm_utils_strsplit_set_full(str,
|
||||
",",
|
||||
NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP
|
||||
| NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING);
|
||||
return nm_strsplit_set_full(str,
|
||||
",",
|
||||
NM_STRSPLIT_SET_FLAGS_STRSTRIP
|
||||
| NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING);
|
||||
}
|
||||
|
||||
void nm_utils_escaped_tokens_options_split(char *str, const char **out_key, const char **out_val);
|
||||
|
|
@ -1972,7 +1971,7 @@ gpointer *nm_utils_hash_values_to_array(GHashTable * hash,
|
|||
guint * out_len);
|
||||
|
||||
static inline const char **
|
||||
nm_utils_strdict_get_keys(const GHashTable *hash, gboolean sorted, guint *out_length)
|
||||
nm_strdict_get_keys(const GHashTable *hash, gboolean sorted, guint *out_length)
|
||||
{
|
||||
return (const char **) nm_utils_hash_keys_to_array((GHashTable *) hash,
|
||||
sorted ? nm_strcmp_p_with_data : NULL,
|
||||
|
|
@ -2828,7 +2827,7 @@ guint nm_utils_parse_debug_string(const char *string, const GDebugKey *keys, gui
|
|||
/*****************************************************************************/
|
||||
|
||||
static inline gboolean
|
||||
nm_utils_strdup_reset(char **dst, const char *src)
|
||||
nm_strdup_reset(char **dst, const char *src)
|
||||
{
|
||||
char *old;
|
||||
|
||||
|
|
@ -2843,7 +2842,7 @@ nm_utils_strdup_reset(char **dst, const char *src)
|
|||
}
|
||||
|
||||
static inline gboolean
|
||||
nm_utils_strdup_reset_take(char **dst, char *src)
|
||||
nm_strdup_reset_take(char **dst, char *src)
|
||||
{
|
||||
char *old;
|
||||
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ nm_logging_setup(const char *level, const char *domains, char **bad_domains, GEr
|
|||
}
|
||||
}
|
||||
|
||||
domains_v = nm_utils_strsplit_set(domains, ", ");
|
||||
domains_v = nm_strsplit_set(domains, ", ");
|
||||
for (i_d = 0; domains_v && domains_v[i_d]; i_d++) {
|
||||
const char * s = domains_v[i_d];
|
||||
const char * p;
|
||||
|
|
@ -525,16 +525,16 @@ again:
|
|||
buf_p = _all_logging_domains_to_str;
|
||||
buf_l = sizeof(_all_logging_domains_to_str);
|
||||
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_l, LOGD_DEFAULT_STRING);
|
||||
nm_strbuf_append_str(&buf_p, &buf_l, LOGD_DEFAULT_STRING);
|
||||
for (diter = &domain_desc[0]; diter->name; diter++) {
|
||||
nm_utils_strbuf_append_c(&buf_p, &buf_l, ',');
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_l, diter->name);
|
||||
nm_strbuf_append_c(&buf_p, &buf_l, ',');
|
||||
nm_strbuf_append_str(&buf_p, &buf_l, diter->name);
|
||||
if (diter->num == LOGD_DHCP6)
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_l, "," LOGD_DHCP_STRING);
|
||||
nm_strbuf_append_str(&buf_p, &buf_l, "," LOGD_DHCP_STRING);
|
||||
else if (diter->num == LOGD_IP6)
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_l, "," LOGD_IP_STRING);
|
||||
nm_strbuf_append_str(&buf_p, &buf_l, "," LOGD_IP_STRING);
|
||||
}
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_l, LOGD_ALL_STRING);
|
||||
nm_strbuf_append_str(&buf_p, &buf_l, LOGD_ALL_STRING);
|
||||
|
||||
/* Did you modify the logging domains (or their names)? Adjust the size of
|
||||
* _all_logging_domains_to_str buffer above to have the exact size. */
|
||||
|
|
@ -746,13 +746,13 @@ _nm_log_impl(const char *file,
|
|||
s_log_domains = s_log_domains_buf;
|
||||
l_log_domains = sizeof(s_log_domains_buf);
|
||||
|
||||
nm_utils_strbuf_append_str(&s_log_domains, &l_log_domains, "NM_LOG_DOMAINS=");
|
||||
nm_strbuf_append_str(&s_log_domains, &l_log_domains, "NM_LOG_DOMAINS=");
|
||||
for (diter = &domain_desc[0]; dom_all != 0 && diter->name; diter++) {
|
||||
if (!NM_FLAGS_ANY(dom_all, diter->num))
|
||||
continue;
|
||||
if (dom_all != domain)
|
||||
nm_utils_strbuf_append_c(&s_log_domains, &l_log_domains, ',');
|
||||
nm_utils_strbuf_append_str(&s_log_domains, &l_log_domains, diter->name);
|
||||
nm_strbuf_append_c(&s_log_domains, &l_log_domains, ',');
|
||||
nm_strbuf_append_str(&s_log_domains, &l_log_domains, diter->name);
|
||||
dom_all &= ~diter->num;
|
||||
}
|
||||
nm_assert(l_log_domains > 0);
|
||||
|
|
|
|||
|
|
@ -582,25 +582,25 @@ wait_for_nl_response_to_string(WaitForNlResponseResult seq_result,
|
|||
|
||||
switch (seq_result) {
|
||||
case WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN:
|
||||
nm_utils_strbuf_append_str(&buf, &buf_size, "unknown");
|
||||
nm_strbuf_append_str(&buf, &buf_size, "unknown");
|
||||
break;
|
||||
case WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK:
|
||||
nm_utils_strbuf_append_str(&buf, &buf_size, "success");
|
||||
nm_strbuf_append_str(&buf, &buf_size, "success");
|
||||
break;
|
||||
case WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_UNKNOWN:
|
||||
nm_utils_strbuf_append_str(&buf, &buf_size, "failure");
|
||||
nm_strbuf_append_str(&buf, &buf_size, "failure");
|
||||
break;
|
||||
default:
|
||||
if (seq_result < 0) {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&buf_size,
|
||||
"failure %d (%s%s%s)",
|
||||
-((int) seq_result),
|
||||
nm_strerror_native(-((int) seq_result)),
|
||||
errmsg ? " - " : "",
|
||||
errmsg ?: "");
|
||||
nm_strbuf_append(&buf,
|
||||
&buf_size,
|
||||
"failure %d (%s%s%s)",
|
||||
-((int) seq_result),
|
||||
nm_strerror_native(-((int) seq_result)),
|
||||
errmsg ? " - " : "",
|
||||
errmsg ?: "");
|
||||
} else
|
||||
nm_utils_strbuf_append(&buf, &buf_size, "internal failure %d", (int) seq_result);
|
||||
nm_strbuf_append(&buf, &buf_size, "internal failure %d", (int) seq_result);
|
||||
break;
|
||||
}
|
||||
return buf0;
|
||||
|
|
@ -5811,13 +5811,13 @@ delayed_action_to_string_full(DelayedActionType action_type,
|
|||
char * buf0 = buf;
|
||||
const DelayedActionWaitForNlResponseData *data;
|
||||
|
||||
nm_utils_strbuf_append_str(&buf, &buf_size, delayed_action_to_string(action_type));
|
||||
nm_strbuf_append_str(&buf, &buf_size, delayed_action_to_string(action_type));
|
||||
switch (action_type) {
|
||||
case DELAYED_ACTION_TYPE_MASTER_CONNECTED:
|
||||
nm_utils_strbuf_append(&buf, &buf_size, " (master-ifindex %d)", GPOINTER_TO_INT(user_data));
|
||||
nm_strbuf_append(&buf, &buf_size, " (master-ifindex %d)", GPOINTER_TO_INT(user_data));
|
||||
break;
|
||||
case DELAYED_ACTION_TYPE_REFRESH_LINK:
|
||||
nm_utils_strbuf_append(&buf, &buf_size, " (ifindex %d)", GPOINTER_TO_INT(user_data));
|
||||
nm_strbuf_append(&buf, &buf_size, " (ifindex %d)", GPOINTER_TO_INT(user_data));
|
||||
break;
|
||||
case DELAYED_ACTION_TYPE_WAIT_FOR_NL_RESPONSE:
|
||||
data = user_data;
|
||||
|
|
@ -5826,7 +5826,7 @@ delayed_action_to_string_full(DelayedActionType action_type,
|
|||
gint64 timeout = data->timeout_abs_ns - nm_utils_get_monotonic_timestamp_nsec();
|
||||
char b[255];
|
||||
|
||||
nm_utils_strbuf_append(
|
||||
nm_strbuf_append(
|
||||
&buf,
|
||||
&buf_size,
|
||||
" (seq %u, timeout in %s%" G_GINT64_FORMAT ".%09" G_GINT64_FORMAT
|
||||
|
|
@ -5841,7 +5841,7 @@ delayed_action_to_string_full(DelayedActionType action_type,
|
|||
? wait_for_nl_response_to_string(data->seq_result, NULL, b, sizeof(b))
|
||||
: "");
|
||||
} else
|
||||
nm_utils_strbuf_append_str(&buf, &buf_size, " (any)");
|
||||
nm_strbuf_append_str(&buf, &buf_size, " (any)");
|
||||
break;
|
||||
default:
|
||||
nm_assert(!user_data);
|
||||
|
|
|
|||
|
|
@ -162,28 +162,28 @@ nl_nlmsghdr_to_str(const struct nlmsghdr *hdr, char *buf, gsize len)
|
|||
}
|
||||
|
||||
if (s)
|
||||
nm_utils_strbuf_append_str(&buf, &len, s);
|
||||
nm_strbuf_append_str(&buf, &len, s);
|
||||
else
|
||||
nm_utils_strbuf_append(&buf, &len, "(%u)", (unsigned) hdr->nlmsg_type);
|
||||
nm_strbuf_append(&buf, &len, "(%u)", (unsigned) hdr->nlmsg_type);
|
||||
|
||||
flags = hdr->nlmsg_flags;
|
||||
|
||||
if (!flags) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, ", flags 0");
|
||||
nm_strbuf_append_str(&buf, &len, ", flags 0");
|
||||
goto flags_done;
|
||||
}
|
||||
|
||||
#define _F(f, n) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
if (NM_FLAGS_ALL(flags, f)) { \
|
||||
flags &= ~(f); \
|
||||
nm_utils_strbuf_append(&buf, &len, "%s%s", prefix, n); \
|
||||
if (!flags) \
|
||||
goto flags_done; \
|
||||
prefix = ","; \
|
||||
} \
|
||||
} \
|
||||
#define _F(f, n) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
if (NM_FLAGS_ALL(flags, f)) { \
|
||||
flags &= ~(f); \
|
||||
nm_strbuf_append(&buf, &len, "%s%s", prefix, n); \
|
||||
if (!flags) \
|
||||
goto flags_done; \
|
||||
prefix = ","; \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
prefix = ", flags ";
|
||||
|
|
@ -225,11 +225,11 @@ nl_nlmsghdr_to_str(const struct nlmsghdr *hdr, char *buf, gsize len)
|
|||
|
||||
if (flags_before != flags)
|
||||
prefix = ";";
|
||||
nm_utils_strbuf_append(&buf, &len, "%s0x%04x", prefix, flags);
|
||||
nm_strbuf_append(&buf, &len, "%s0x%04x", prefix, flags);
|
||||
|
||||
flags_done:
|
||||
|
||||
nm_utils_strbuf_append(&buf, &len, ", seq %u", (unsigned) hdr->nlmsg_seq);
|
||||
nm_strbuf_append(&buf, &len, ", seq %u", (unsigned) hdr->nlmsg_seq);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1229,25 +1229,25 @@ nm_platform_link_add(NMPlatform * self,
|
|||
|
||||
switch (type) {
|
||||
case NM_LINK_TYPE_BRIDGE:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_bridge_to_string((const NMPlatformLnkBridge *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
break;
|
||||
case NM_LINK_TYPE_VLAN:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_vlan_to_string((const NMPlatformLnkVlan *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
break;
|
||||
case NM_LINK_TYPE_VRF:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_vrf_to_string((const NMPlatformLnkVrf *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
break;
|
||||
case NM_LINK_TYPE_VXLAN:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_vxlan_to_string((const NMPlatformLnkVxlan *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
|
|
@ -1257,13 +1257,13 @@ nm_platform_link_add(NMPlatform * self,
|
|||
break;
|
||||
case NM_LINK_TYPE_GRE:
|
||||
case NM_LINK_TYPE_GRETAP:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_gre_to_string((const NMPlatformLnkGre *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
break;
|
||||
case NM_LINK_TYPE_SIT:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_sit_to_string((const NMPlatformLnkSit *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
|
|
@ -1271,26 +1271,26 @@ nm_platform_link_add(NMPlatform * self,
|
|||
case NM_LINK_TYPE_IP6TNL:
|
||||
case NM_LINK_TYPE_IP6GRE:
|
||||
case NM_LINK_TYPE_IP6GRETAP:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_ip6tnl_to_string((const NMPlatformLnkIp6Tnl *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
break;
|
||||
case NM_LINK_TYPE_IPIP:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_ipip_to_string((const NMPlatformLnkIpIp *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
break;
|
||||
case NM_LINK_TYPE_MACSEC:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_macsec_to_string((const NMPlatformLnkMacsec *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
break;
|
||||
case NM_LINK_TYPE_MACVLAN:
|
||||
case NM_LINK_TYPE_MACVTAP:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_macvlan_to_string((const NMPlatformLnkMacvlan *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
|
|
@ -2336,13 +2336,13 @@ nm_platform_link_wireguard_change(NMPlatform * self
|
|||
gsize len = sizeof(buf_peers);
|
||||
guint i;
|
||||
|
||||
nm_utils_strbuf_append_str(&b, &len, " { ");
|
||||
nm_strbuf_append_str(&b, &len, " { ");
|
||||
for (i = 0; i < peers_len; i++) {
|
||||
nm_utils_strbuf_append_str(&b, &len, " { ");
|
||||
nm_strbuf_append_str(&b, &len, " { ");
|
||||
nm_platform_wireguard_peer_to_string(&peers[i], b, len);
|
||||
nm_utils_strbuf_seek_end(&b, &len);
|
||||
nm_strbuf_seek_end(&b, &len);
|
||||
if (peer_flags) {
|
||||
nm_utils_strbuf_append(
|
||||
nm_strbuf_append(
|
||||
&b,
|
||||
&len,
|
||||
" (%s)",
|
||||
|
|
@ -2350,9 +2350,9 @@ nm_platform_link_wireguard_change(NMPlatform * self
|
|||
buf_change_flags,
|
||||
sizeof(buf_change_flags)));
|
||||
}
|
||||
nm_utils_strbuf_append_str(&b, &len, " } ");
|
||||
nm_strbuf_append_str(&b, &len, " } ");
|
||||
}
|
||||
nm_utils_strbuf_append_str(&b, &len, "}");
|
||||
nm_strbuf_append_str(&b, &len, "}");
|
||||
}
|
||||
|
||||
_LOG3D("link: change wireguard ifindex %d, %s, (%s), %u peers%s",
|
||||
|
|
@ -2620,30 +2620,30 @@ nm_platform_link_vlan_change(NMPlatform * self,
|
|||
len = sizeof(buf);
|
||||
|
||||
if (flags_mask)
|
||||
nm_utils_strbuf_append(&b,
|
||||
&len,
|
||||
" flags 0x%x/0x%x",
|
||||
(unsigned) flags_set,
|
||||
(unsigned) flags_mask);
|
||||
nm_strbuf_append(&b,
|
||||
&len,
|
||||
" flags 0x%x/0x%x",
|
||||
(unsigned) flags_set,
|
||||
(unsigned) flags_mask);
|
||||
|
||||
if (ingress_reset_all || n_ingress_map) {
|
||||
nm_utils_strbuf_append_str(&b, &len, " ingress-qos-map");
|
||||
nm_strbuf_append_str(&b, &len, " ingress-qos-map");
|
||||
nm_platform_vlan_qos_mapping_to_string("", ingress_map, n_ingress_map, b, len);
|
||||
i = strlen(b);
|
||||
b += i;
|
||||
len -= i;
|
||||
if (ingress_reset_all)
|
||||
nm_utils_strbuf_append_str(&b, &len, " (reset-all)");
|
||||
nm_strbuf_append_str(&b, &len, " (reset-all)");
|
||||
}
|
||||
|
||||
if (egress_reset_all || n_egress_map) {
|
||||
nm_utils_strbuf_append_str(&b, &len, " egress-qos-map");
|
||||
nm_strbuf_append_str(&b, &len, " egress-qos-map");
|
||||
nm_platform_vlan_qos_mapping_to_string("", egress_map, n_egress_map, b, len);
|
||||
i = strlen(b);
|
||||
b += i;
|
||||
len -= i;
|
||||
if (egress_reset_all)
|
||||
nm_utils_strbuf_append_str(&b, &len, " (reset-all)");
|
||||
nm_strbuf_append_str(&b, &len, " (reset-all)");
|
||||
}
|
||||
|
||||
_LOG3D("link: change vlan %s", buf);
|
||||
|
|
@ -5454,7 +5454,7 @@ nm_platform_vlan_qos_mapping_to_string(const char * name,
|
|||
nm_utils_to_string_buffer_init(&buf, &len);
|
||||
|
||||
if (!n_map) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, "");
|
||||
nm_strbuf_append_str(&buf, &len, "");
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
@ -5464,14 +5464,14 @@ nm_platform_vlan_qos_mapping_to_string(const char * name,
|
|||
b = buf;
|
||||
|
||||
if (name) {
|
||||
nm_utils_strbuf_append_str(&b, &len, name);
|
||||
nm_utils_strbuf_append_str(&b, &len, " {");
|
||||
nm_strbuf_append_str(&b, &len, name);
|
||||
nm_strbuf_append_str(&b, &len, " {");
|
||||
} else
|
||||
nm_utils_strbuf_append_c(&b, &len, '{');
|
||||
nm_strbuf_append_c(&b, &len, '{');
|
||||
|
||||
for (i = 0; i < n_map; i++)
|
||||
nm_utils_strbuf_append(&b, &len, " %u:%u", map[i].from, map[i].to);
|
||||
nm_utils_strbuf_append_str(&b, &len, " }");
|
||||
nm_strbuf_append(&b, &len, " %u:%u", map[i].from, map[i].to);
|
||||
nm_strbuf_append_str(&b, &len, " }");
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
@ -5537,13 +5537,13 @@ nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len)
|
|||
s = str_highlighted_flags;
|
||||
l = sizeof(str_highlighted_flags);
|
||||
if (NM_FLAGS_HAS(link->n_ifi_flags, IFF_NOARP))
|
||||
nm_utils_strbuf_append_str(&s, &l, "NOARP,");
|
||||
nm_strbuf_append_str(&s, &l, "NOARP,");
|
||||
if (NM_FLAGS_HAS(link->n_ifi_flags, IFF_UP))
|
||||
nm_utils_strbuf_append_str(&s, &l, "UP");
|
||||
nm_strbuf_append_str(&s, &l, "UP");
|
||||
else
|
||||
nm_utils_strbuf_append_str(&s, &l, "DOWN");
|
||||
nm_strbuf_append_str(&s, &l, "DOWN");
|
||||
if (link->connected)
|
||||
nm_utils_strbuf_append_str(&s, &l, ",LOWER_UP");
|
||||
nm_strbuf_append_str(&s, &l, ",LOWER_UP");
|
||||
nm_assert(s > str_highlighted_flags && l > 0);
|
||||
|
||||
if (link->n_ifi_flags) {
|
||||
|
|
@ -6028,9 +6028,9 @@ nm_platform_lnk_vlan_to_string(const NMPlatformLnkVlan *lnk, char *buf, gsize le
|
|||
|
||||
b = buf;
|
||||
|
||||
nm_utils_strbuf_append(&b, &len, "vlan %u", lnk->id);
|
||||
nm_strbuf_append(&b, &len, "vlan %u", lnk->id);
|
||||
if (lnk->flags)
|
||||
nm_utils_strbuf_append(&b, &len, " flags 0x%x", lnk->flags);
|
||||
nm_strbuf_append(&b, &len, " flags 0x%x", lnk->flags);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
@ -6044,7 +6044,7 @@ nm_platform_lnk_vrf_to_string(const NMPlatformLnkVrf *lnk, char *buf, gsize len)
|
|||
|
||||
b = buf;
|
||||
|
||||
nm_utils_strbuf_append(&b, &len, "table %u", lnk->table);
|
||||
nm_strbuf_append(&b, &len, "table %u", lnk->table);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
@ -6169,36 +6169,36 @@ nm_platform_wireguard_peer_to_string(const NMPWireGuardPeer *peer, char *buf, gs
|
|||
} else
|
||||
s_endpoint[0] = '\0';
|
||||
|
||||
nm_utils_strbuf_append(
|
||||
&buf,
|
||||
&len,
|
||||
"public-key %s"
|
||||
"%s" /* preshared-key */
|
||||
"%s" /* endpoint */
|
||||
" rx %" G_GUINT64_FORMAT " tx %" G_GUINT64_FORMAT "%s" /* persistent-keepalive */
|
||||
"%s", /* allowed-ips */
|
||||
public_key_b64,
|
||||
nm_utils_memeqzero_secret(peer->preshared_key, sizeof(peer->preshared_key))
|
||||
? ""
|
||||
: " preshared-key (hidden)",
|
||||
s_endpoint,
|
||||
peer->rx_bytes,
|
||||
peer->tx_bytes,
|
||||
peer->persistent_keepalive_interval > 0
|
||||
? nm_sprintf_buf(s_keepalive,
|
||||
" keepalive %u",
|
||||
(guint) peer->persistent_keepalive_interval)
|
||||
: "",
|
||||
peer->allowed_ips_len > 0 ? " allowed-ips" : "");
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
"public-key %s"
|
||||
"%s" /* preshared-key */
|
||||
"%s" /* endpoint */
|
||||
" rx %" G_GUINT64_FORMAT " tx %" G_GUINT64_FORMAT
|
||||
"%s" /* persistent-keepalive */
|
||||
"%s", /* allowed-ips */
|
||||
public_key_b64,
|
||||
nm_utils_memeqzero_secret(peer->preshared_key, sizeof(peer->preshared_key))
|
||||
? ""
|
||||
: " preshared-key (hidden)",
|
||||
s_endpoint,
|
||||
peer->rx_bytes,
|
||||
peer->tx_bytes,
|
||||
peer->persistent_keepalive_interval > 0
|
||||
? nm_sprintf_buf(s_keepalive,
|
||||
" keepalive %u",
|
||||
(guint) peer->persistent_keepalive_interval)
|
||||
: "",
|
||||
peer->allowed_ips_len > 0 ? " allowed-ips" : "");
|
||||
|
||||
for (i = 0; i < peer->allowed_ips_len; i++) {
|
||||
const NMPWireGuardAllowedIP *allowed_ip = &peer->allowed_ips[i];
|
||||
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" %s/%u",
|
||||
nm_utils_inet_ntop(allowed_ip->family, &allowed_ip->addr, s_addr),
|
||||
allowed_ip->mask);
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
" %s/%u",
|
||||
nm_utils_inet_ntop(allowed_ip->family, &allowed_ip->addr, s_addr),
|
||||
allowed_ip->mask);
|
||||
}
|
||||
|
||||
return buf0;
|
||||
|
|
@ -6490,7 +6490,7 @@ _rtm_flags_to_string_full(char *buf, gsize buf_size, unsigned rtm_flags)
|
|||
if (!rtm_flags)
|
||||
return "";
|
||||
|
||||
nm_utils_strbuf_append_str(&buf, &buf_size, " rtm_flags ");
|
||||
nm_strbuf_append_str(&buf, &buf_size, " rtm_flags ");
|
||||
_rtm_flags_to_string(rtm_flags, buf, buf_size);
|
||||
nm_assert(strlen(buf) < buf_size);
|
||||
return buf0;
|
||||
|
|
@ -6762,18 +6762,18 @@ _routing_rule_addr_to_string(char ** buf,
|
|||
|
||||
if (plen == 0 && is_zero) {
|
||||
if (is_src)
|
||||
nm_utils_strbuf_append_str(buf, len, " from all");
|
||||
nm_strbuf_append_str(buf, len, " from all");
|
||||
else
|
||||
nm_utils_strbuf_append_str(buf, len, "");
|
||||
nm_strbuf_append_str(buf, len, "");
|
||||
return;
|
||||
}
|
||||
|
||||
nm_utils_strbuf_append_str(buf, len, is_src ? " from " : " to ");
|
||||
nm_strbuf_append_str(buf, len, is_src ? " from " : " to ");
|
||||
|
||||
nm_utils_strbuf_append_str(buf, len, nm_utils_inet_ntop(addr_family, addr, s_addr));
|
||||
nm_strbuf_append_str(buf, len, nm_utils_inet_ntop(addr_family, addr, s_addr));
|
||||
|
||||
if (plen != (addr_size * 8))
|
||||
nm_utils_strbuf_append(buf, len, "/%u", plen);
|
||||
nm_strbuf_append(buf, len, "/%u", plen);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -6783,11 +6783,11 @@ _routing_rule_port_range_to_string(char ** buf,
|
|||
const char * name)
|
||||
{
|
||||
if (port_range->start == 0 && port_range->end == 0)
|
||||
nm_utils_strbuf_append_str(buf, len, "");
|
||||
nm_strbuf_append_str(buf, len, "");
|
||||
else {
|
||||
nm_utils_strbuf_append(buf, len, " %s %u", name, port_range->start);
|
||||
nm_strbuf_append(buf, len, " %s %u", name, port_range->start);
|
||||
if (port_range->start != port_range->end)
|
||||
nm_utils_strbuf_append(buf, len, "-%u", port_range->end);
|
||||
nm_strbuf_append(buf, len, "-%u", port_range->end);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -6814,14 +6814,14 @@ nm_platform_routing_rule_to_string(const NMPlatformRoutingRule *routing_rule, ch
|
|||
rr_flags = routing_rule->flags;
|
||||
|
||||
rr_flags = NM_FLAGS_UNSET(rr_flags, FIB_RULE_INVERT);
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
"[%c] " /* addr-family */
|
||||
"%u:" /* priority */
|
||||
"%s", /* not/FIB_RULE_INVERT */
|
||||
nm_utils_addr_family_to_char(routing_rule->addr_family),
|
||||
routing_rule->priority,
|
||||
(NM_FLAGS_HAS(routing_rule->flags, FIB_RULE_INVERT) ? " not" : ""));
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
"[%c] " /* addr-family */
|
||||
"%u:" /* priority */
|
||||
"%s", /* not/FIB_RULE_INVERT */
|
||||
nm_utils_addr_family_to_char(routing_rule->addr_family),
|
||||
routing_rule->priority,
|
||||
(NM_FLAGS_HAS(routing_rule->flags, FIB_RULE_INVERT) ? " not" : ""));
|
||||
|
||||
_routing_rule_addr_to_string(&buf,
|
||||
&len,
|
||||
|
|
@ -6838,53 +6838,53 @@ nm_platform_routing_rule_to_string(const NMPlatformRoutingRule *routing_rule, ch
|
|||
FALSE);
|
||||
|
||||
if (routing_rule->tos)
|
||||
nm_utils_strbuf_append(&buf, &len, " tos 0x%02x", routing_rule->tos);
|
||||
nm_strbuf_append(&buf, &len, " tos 0x%02x", routing_rule->tos);
|
||||
|
||||
if (routing_rule->fwmark != 0 || routing_rule->fwmask != 0) {
|
||||
nm_utils_strbuf_append(&buf, &len, " fwmark %#x", (unsigned) routing_rule->fwmark);
|
||||
nm_strbuf_append(&buf, &len, " fwmark %#x", (unsigned) routing_rule->fwmark);
|
||||
if (routing_rule->fwmark != 0xFFFFFFFFu)
|
||||
nm_utils_strbuf_append(&buf, &len, "/%#x", (unsigned) routing_rule->fwmask);
|
||||
nm_strbuf_append(&buf, &len, "/%#x", (unsigned) routing_rule->fwmask);
|
||||
}
|
||||
|
||||
if (routing_rule->iifname[0]) {
|
||||
nm_utils_strbuf_append(&buf, &len, " iif %s", routing_rule->iifname);
|
||||
nm_strbuf_append(&buf, &len, " iif %s", routing_rule->iifname);
|
||||
rr_flags = NM_FLAGS_UNSET(rr_flags, FIB_RULE_IIF_DETACHED);
|
||||
if (NM_FLAGS_HAS(routing_rule->flags, FIB_RULE_IIF_DETACHED))
|
||||
nm_utils_strbuf_append_str(&buf, &len, " [detached]");
|
||||
nm_strbuf_append_str(&buf, &len, " [detached]");
|
||||
}
|
||||
|
||||
if (routing_rule->oifname[0]) {
|
||||
nm_utils_strbuf_append(&buf, &len, " oif %s", routing_rule->oifname);
|
||||
nm_strbuf_append(&buf, &len, " oif %s", routing_rule->oifname);
|
||||
rr_flags = NM_FLAGS_UNSET(rr_flags, FIB_RULE_OIF_DETACHED);
|
||||
if (NM_FLAGS_HAS(routing_rule->flags, FIB_RULE_OIF_DETACHED))
|
||||
nm_utils_strbuf_append_str(&buf, &len, " [detached]");
|
||||
nm_strbuf_append_str(&buf, &len, " [detached]");
|
||||
}
|
||||
|
||||
if (routing_rule->l3mdev != 0) {
|
||||
if (routing_rule->l3mdev == 1)
|
||||
nm_utils_strbuf_append_str(&buf, &len, " lookup [l3mdev-table]");
|
||||
nm_strbuf_append_str(&buf, &len, " lookup [l3mdev-table]");
|
||||
else {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" lookup [l3mdev-table/%u]",
|
||||
(unsigned) routing_rule->l3mdev);
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
" lookup [l3mdev-table/%u]",
|
||||
(unsigned) routing_rule->l3mdev);
|
||||
}
|
||||
}
|
||||
|
||||
if (routing_rule->uid_range_has || routing_rule->uid_range.start
|
||||
|| routing_rule->uid_range.end) {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" uidrange %u-%u%s",
|
||||
routing_rule->uid_range.start,
|
||||
routing_rule->uid_range.end,
|
||||
routing_rule->uid_range_has ? "" : "(?)");
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
" uidrange %u-%u%s",
|
||||
routing_rule->uid_range.start,
|
||||
routing_rule->uid_range.end,
|
||||
routing_rule->uid_range_has ? "" : "(?)");
|
||||
}
|
||||
|
||||
if (routing_rule->ip_proto != 0) {
|
||||
/* we don't call getprotobynumber(), just print the numeric value.
|
||||
* This differs from what ip-rule prints. */
|
||||
nm_utils_strbuf_append(&buf, &len, " ipproto %u", routing_rule->ip_proto);
|
||||
nm_strbuf_append(&buf, &len, " ipproto %u", routing_rule->ip_proto);
|
||||
}
|
||||
|
||||
_routing_rule_port_range_to_string(&buf, &len, &routing_rule->sport_range, "sport");
|
||||
|
|
@ -6892,25 +6892,25 @@ nm_platform_routing_rule_to_string(const NMPlatformRoutingRule *routing_rule, ch
|
|||
_routing_rule_port_range_to_string(&buf, &len, &routing_rule->dport_range, "dport");
|
||||
|
||||
if (routing_rule->tun_id != 0) {
|
||||
nm_utils_strbuf_append(&buf, &len, " tun_id %" G_GUINT64_FORMAT, routing_rule->tun_id);
|
||||
nm_strbuf_append(&buf, &len, " tun_id %" G_GUINT64_FORMAT, routing_rule->tun_id);
|
||||
}
|
||||
|
||||
if (routing_rule->table != 0) {
|
||||
nm_utils_strbuf_append(&buf, &len, " lookup %u", routing_rule->table);
|
||||
nm_strbuf_append(&buf, &len, " lookup %u", routing_rule->table);
|
||||
}
|
||||
|
||||
if (routing_rule->suppress_prefixlen_inverse != 0) {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" suppress_prefixlen %d",
|
||||
(int) (~routing_rule->suppress_prefixlen_inverse));
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
" suppress_prefixlen %d",
|
||||
(int) (~routing_rule->suppress_prefixlen_inverse));
|
||||
}
|
||||
|
||||
if (routing_rule->suppress_ifgroup_inverse != 0) {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" suppress_ifgroup %d",
|
||||
(int) (~routing_rule->suppress_ifgroup_inverse));
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
" suppress_ifgroup %d",
|
||||
(int) (~routing_rule->suppress_ifgroup_inverse));
|
||||
}
|
||||
|
||||
if (routing_rule->flow) {
|
||||
|
|
@ -6919,7 +6919,7 @@ nm_platform_routing_rule_to_string(const NMPlatformRoutingRule *routing_rule, ch
|
|||
*
|
||||
* We don't follow the style how ip-rule prints flow/realms. It's confusing. Just
|
||||
* print the value hex. */
|
||||
nm_utils_strbuf_append(&buf, &len, " realms 0x%08x", routing_rule->flow);
|
||||
nm_strbuf_append(&buf, &len, " realms 0x%08x", routing_rule->flow);
|
||||
}
|
||||
|
||||
if (routing_rule->action == RTN_NAT) {
|
||||
|
|
@ -6927,36 +6927,36 @@ nm_platform_routing_rule_to_string(const NMPlatformRoutingRule *routing_rule, ch
|
|||
|
||||
/* NAT is deprecated for many years. We don't support RTA_GATEWAY/FRA_UNUSED2
|
||||
* for the gateway, and so do recent kernels ignore that parameter. */
|
||||
nm_utils_strbuf_append_str(&buf, &len, " masquerade");
|
||||
nm_strbuf_append_str(&buf, &len, " masquerade");
|
||||
} else if (routing_rule->action == FR_ACT_GOTO) {
|
||||
if (routing_rule->goto_target != 0)
|
||||
nm_utils_strbuf_append(&buf, &len, " goto %u", routing_rule->goto_target);
|
||||
nm_strbuf_append(&buf, &len, " goto %u", routing_rule->goto_target);
|
||||
else
|
||||
nm_utils_strbuf_append_str(&buf, &len, " goto none");
|
||||
nm_strbuf_append_str(&buf, &len, " goto none");
|
||||
rr_flags = NM_FLAGS_UNSET(rr_flags, FIB_RULE_UNRESOLVED);
|
||||
if (NM_FLAGS_HAS(routing_rule->flags, FIB_RULE_UNRESOLVED))
|
||||
nm_utils_strbuf_append_str(&buf, &len, " unresolved");
|
||||
nm_strbuf_append_str(&buf, &len, " unresolved");
|
||||
} else if (routing_rule->action != FR_ACT_TO_TBL) {
|
||||
char ss_buf[60];
|
||||
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" %s",
|
||||
nm_net_aux_rtnl_rtntype_n2a(routing_rule->action)
|
||||
?: nm_sprintf_buf(ss_buf, "action-%u", routing_rule->action));
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
" %s",
|
||||
nm_net_aux_rtnl_rtntype_n2a(routing_rule->action)
|
||||
?: nm_sprintf_buf(ss_buf, "action-%u", routing_rule->action));
|
||||
}
|
||||
|
||||
if (routing_rule->protocol != RTPROT_UNSPEC)
|
||||
nm_utils_strbuf_append(&buf, &len, " protocol %u", routing_rule->protocol);
|
||||
nm_strbuf_append(&buf, &len, " protocol %u", routing_rule->protocol);
|
||||
|
||||
if (routing_rule->goto_target != 0 && routing_rule->action != FR_ACT_GOTO) {
|
||||
/* a trailing target is set for an unexpected action. Print it. */
|
||||
nm_utils_strbuf_append(&buf, &len, " goto-target %u", routing_rule->goto_target);
|
||||
nm_strbuf_append(&buf, &len, " goto-target %u", routing_rule->goto_target);
|
||||
}
|
||||
|
||||
if (rr_flags != 0) {
|
||||
/* we have some flags we didn't print about yet. */
|
||||
nm_utils_strbuf_append(&buf, &len, " remaining-flags %x", rr_flags);
|
||||
nm_strbuf_append(&buf, &len, " remaining-flags %x", rr_flags);
|
||||
}
|
||||
|
||||
return buf0;
|
||||
|
|
@ -6973,53 +6973,53 @@ nm_platform_qdisc_to_string(const NMPlatformQdisc *qdisc, char *buf, gsize len)
|
|||
|
||||
buf0 = buf;
|
||||
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
"%s%s family %u handle %x parent %x info %x",
|
||||
qdisc->kind,
|
||||
_to_string_dev(NULL, qdisc->ifindex, str_dev, sizeof(str_dev)),
|
||||
qdisc->addr_family,
|
||||
qdisc->handle,
|
||||
qdisc->parent,
|
||||
qdisc->info);
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
"%s%s family %u handle %x parent %x info %x",
|
||||
qdisc->kind,
|
||||
_to_string_dev(NULL, qdisc->ifindex, str_dev, sizeof(str_dev)),
|
||||
qdisc->addr_family,
|
||||
qdisc->handle,
|
||||
qdisc->parent,
|
||||
qdisc->info);
|
||||
|
||||
if (nm_streq0(qdisc->kind, "fq_codel")) {
|
||||
if (qdisc->fq_codel.limit)
|
||||
nm_utils_strbuf_append(&buf, &len, " limit %u", qdisc->fq_codel.limit);
|
||||
nm_strbuf_append(&buf, &len, " limit %u", qdisc->fq_codel.limit);
|
||||
if (qdisc->fq_codel.flows)
|
||||
nm_utils_strbuf_append(&buf, &len, " flows %u", qdisc->fq_codel.flows);
|
||||
nm_strbuf_append(&buf, &len, " flows %u", qdisc->fq_codel.flows);
|
||||
if (qdisc->fq_codel.target)
|
||||
nm_utils_strbuf_append(&buf, &len, " target %u", qdisc->fq_codel.target);
|
||||
nm_strbuf_append(&buf, &len, " target %u", qdisc->fq_codel.target);
|
||||
if (qdisc->fq_codel.interval)
|
||||
nm_utils_strbuf_append(&buf, &len, " interval %u", qdisc->fq_codel.interval);
|
||||
nm_strbuf_append(&buf, &len, " interval %u", qdisc->fq_codel.interval);
|
||||
if (qdisc->fq_codel.quantum)
|
||||
nm_utils_strbuf_append(&buf, &len, " quantum %u", qdisc->fq_codel.quantum);
|
||||
nm_strbuf_append(&buf, &len, " quantum %u", qdisc->fq_codel.quantum);
|
||||
if (qdisc->fq_codel.ce_threshold != NM_PLATFORM_FQ_CODEL_CE_THRESHOLD_DISABLED)
|
||||
nm_utils_strbuf_append(&buf, &len, " ce_threshold %u", qdisc->fq_codel.ce_threshold);
|
||||
nm_strbuf_append(&buf, &len, " ce_threshold %u", qdisc->fq_codel.ce_threshold);
|
||||
if (qdisc->fq_codel.memory_limit != NM_PLATFORM_FQ_CODEL_MEMORY_LIMIT_UNSET)
|
||||
nm_utils_strbuf_append(&buf, &len, " memory_limit %u", qdisc->fq_codel.memory_limit);
|
||||
nm_strbuf_append(&buf, &len, " memory_limit %u", qdisc->fq_codel.memory_limit);
|
||||
if (qdisc->fq_codel.ecn)
|
||||
nm_utils_strbuf_append(&buf, &len, " ecn");
|
||||
nm_strbuf_append(&buf, &len, " ecn");
|
||||
} else if (nm_streq0(qdisc->kind, "sfq")) {
|
||||
if (qdisc->sfq.quantum)
|
||||
nm_utils_strbuf_append(&buf, &len, " quantum %u", qdisc->sfq.quantum);
|
||||
nm_strbuf_append(&buf, &len, " quantum %u", qdisc->sfq.quantum);
|
||||
if (qdisc->sfq.perturb_period)
|
||||
nm_utils_strbuf_append(&buf, &len, " perturb %d", qdisc->sfq.perturb_period);
|
||||
nm_strbuf_append(&buf, &len, " perturb %d", qdisc->sfq.perturb_period);
|
||||
if (qdisc->sfq.limit)
|
||||
nm_utils_strbuf_append(&buf, &len, " limit %u", (guint) qdisc->sfq.limit);
|
||||
nm_strbuf_append(&buf, &len, " limit %u", (guint) qdisc->sfq.limit);
|
||||
if (qdisc->sfq.divisor)
|
||||
nm_utils_strbuf_append(&buf, &len, " divisor %u", qdisc->sfq.divisor);
|
||||
nm_strbuf_append(&buf, &len, " divisor %u", qdisc->sfq.divisor);
|
||||
if (qdisc->sfq.flows)
|
||||
nm_utils_strbuf_append(&buf, &len, " flows %u", qdisc->sfq.flows);
|
||||
nm_strbuf_append(&buf, &len, " flows %u", qdisc->sfq.flows);
|
||||
if (qdisc->sfq.depth)
|
||||
nm_utils_strbuf_append(&buf, &len, " depth %u", qdisc->sfq.depth);
|
||||
nm_strbuf_append(&buf, &len, " depth %u", qdisc->sfq.depth);
|
||||
} else if (nm_streq0(qdisc->kind, "tbf")) {
|
||||
nm_utils_strbuf_append(&buf, &len, " rate %" G_GUINT64_FORMAT, qdisc->tbf.rate);
|
||||
nm_utils_strbuf_append(&buf, &len, " burst %u", qdisc->tbf.burst);
|
||||
nm_strbuf_append(&buf, &len, " rate %" G_GUINT64_FORMAT, qdisc->tbf.rate);
|
||||
nm_strbuf_append(&buf, &len, " burst %u", qdisc->tbf.burst);
|
||||
if (qdisc->tbf.limit)
|
||||
nm_utils_strbuf_append(&buf, &len, " limit %u", qdisc->tbf.limit);
|
||||
nm_strbuf_append(&buf, &len, " limit %u", qdisc->tbf.limit);
|
||||
if (qdisc->tbf.latency)
|
||||
nm_utils_strbuf_append(&buf, &len, " latency %uns", qdisc->tbf.latency);
|
||||
nm_strbuf_append(&buf, &len, " latency %uns", qdisc->tbf.latency);
|
||||
}
|
||||
|
||||
return buf0;
|
||||
|
|
@ -7114,11 +7114,11 @@ nm_platform_tfilter_to_string(const NMPlatformTfilter *tfilter, char *buf, gsize
|
|||
p = act_buf;
|
||||
l = sizeof(act_buf);
|
||||
|
||||
nm_utils_strbuf_append(&p, &l, " \"%s\"", tfilter->action.kind);
|
||||
nm_strbuf_append(&p, &l, " \"%s\"", tfilter->action.kind);
|
||||
if (nm_streq(tfilter->action.kind, NM_PLATFORM_ACTION_KIND_SIMPLE)) {
|
||||
gs_free char *t = NULL;
|
||||
|
||||
nm_utils_strbuf_append(
|
||||
nm_strbuf_append(
|
||||
&p,
|
||||
&l,
|
||||
" (\"%s\")",
|
||||
|
|
@ -7127,14 +7127,14 @@ nm_platform_tfilter_to_string(const NMPlatformTfilter *tfilter, char *buf, gsize
|
|||
| NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_NON_ASCII,
|
||||
&t));
|
||||
} else if (nm_streq(tfilter->action.kind, NM_PLATFORM_ACTION_KIND_MIRRED)) {
|
||||
nm_utils_strbuf_append(&p,
|
||||
&l,
|
||||
"%s%s%s%s dev %d",
|
||||
tfilter->action.mirred.ingress ? " ingress" : "",
|
||||
tfilter->action.mirred.egress ? " egress" : "",
|
||||
tfilter->action.mirred.mirror ? " mirror" : "",
|
||||
tfilter->action.mirred.redirect ? " redirect" : "",
|
||||
tfilter->action.mirred.ifindex);
|
||||
nm_strbuf_append(&p,
|
||||
&l,
|
||||
"%s%s%s%s dev %d",
|
||||
tfilter->action.mirred.ingress ? " ingress" : "",
|
||||
tfilter->action.mirred.egress ? " egress" : "",
|
||||
tfilter->action.mirred.mirror ? " mirror" : "",
|
||||
tfilter->action.mirred.redirect ? " redirect" : "",
|
||||
tfilter->action.mirred.ifindex);
|
||||
}
|
||||
} else
|
||||
act_buf[0] = '\0';
|
||||
|
|
|
|||
|
|
@ -43,22 +43,20 @@ __ns_types_to_str(int ns_types, int ns_types_already_set, char *buf, gsize len)
|
|||
const char *b = buf;
|
||||
char bb[200];
|
||||
|
||||
nm_utils_strbuf_append_c(&buf, &len, '[');
|
||||
nm_strbuf_append_c(&buf, &len, '[');
|
||||
if (ns_types & ~ns_types_already_set) {
|
||||
nm_utils_strbuf_append_str(
|
||||
&buf,
|
||||
&len,
|
||||
_clone_ns_to_str(ns_types & ~ns_types_already_set, bb, sizeof(bb)));
|
||||
nm_strbuf_append_str(&buf,
|
||||
&len,
|
||||
_clone_ns_to_str(ns_types & ~ns_types_already_set, bb, sizeof(bb)));
|
||||
}
|
||||
if (ns_types & ns_types_already_set) {
|
||||
if (ns_types & ~ns_types_already_set)
|
||||
nm_utils_strbuf_append_c(&buf, &len, '/');
|
||||
nm_utils_strbuf_append_str(
|
||||
&buf,
|
||||
&len,
|
||||
_clone_ns_to_str(ns_types & ns_types_already_set, bb, sizeof(bb)));
|
||||
nm_strbuf_append_c(&buf, &len, '/');
|
||||
nm_strbuf_append_str(&buf,
|
||||
&len,
|
||||
_clone_ns_to_str(ns_types & ns_types_already_set, bb, sizeof(bb)));
|
||||
}
|
||||
nm_utils_strbuf_append_c(&buf, &len, ']');
|
||||
nm_strbuf_append_c(&buf, &len, ']');
|
||||
return b;
|
||||
}
|
||||
#define _ns_types_to_str(ns_types, ns_types_already_set, buf) \
|
||||
|
|
|
|||
|
|
@ -949,30 +949,30 @@ _vt_cmd_obj_to_string_link(const NMPObject * obj,
|
|||
case NMP_OBJECT_TO_STRING_ID:
|
||||
return klass->cmd_plobj_to_string_id(&obj->object, buf, buf_size);
|
||||
case NMP_OBJECT_TO_STRING_ALL:
|
||||
nm_utils_strbuf_append(&b,
|
||||
&buf_size,
|
||||
"[%s,%p,%u,%calive,%cvisible,%cin-nl,%p; ",
|
||||
klass->obj_type_name,
|
||||
obj,
|
||||
obj->parent._ref_count,
|
||||
nmp_object_is_alive(obj) ? '+' : '-',
|
||||
nmp_object_is_visible(obj) ? '+' : '-',
|
||||
obj->_link.netlink.is_in_netlink ? '+' : '-',
|
||||
obj->_link.udev.device);
|
||||
nm_strbuf_append(&b,
|
||||
&buf_size,
|
||||
"[%s,%p,%u,%calive,%cvisible,%cin-nl,%p; ",
|
||||
klass->obj_type_name,
|
||||
obj,
|
||||
obj->parent._ref_count,
|
||||
nmp_object_is_alive(obj) ? '+' : '-',
|
||||
nmp_object_is_visible(obj) ? '+' : '-',
|
||||
obj->_link.netlink.is_in_netlink ? '+' : '-',
|
||||
obj->_link.udev.device);
|
||||
NMP_OBJECT_GET_CLASS(obj)->cmd_plobj_to_string(&obj->object, b, buf_size);
|
||||
nm_utils_strbuf_seek_end(&b, &buf_size);
|
||||
nm_strbuf_seek_end(&b, &buf_size);
|
||||
if (obj->_link.netlink.lnk) {
|
||||
nm_utils_strbuf_append_str(&b, &buf_size, "; ");
|
||||
nm_strbuf_append_str(&b, &buf_size, "; ");
|
||||
nmp_object_to_string(obj->_link.netlink.lnk, NMP_OBJECT_TO_STRING_ALL, b, buf_size);
|
||||
nm_utils_strbuf_seek_end(&b, &buf_size);
|
||||
nm_strbuf_seek_end(&b, &buf_size);
|
||||
}
|
||||
nm_utils_strbuf_append_c(&b, &buf_size, ']');
|
||||
nm_strbuf_append_c(&b, &buf_size, ']');
|
||||
return buf;
|
||||
case NMP_OBJECT_TO_STRING_PUBLIC:
|
||||
NMP_OBJECT_GET_CLASS(obj)->cmd_plobj_to_string(&obj->object, b, buf_size);
|
||||
if (obj->_link.netlink.lnk) {
|
||||
nm_utils_strbuf_seek_end(&b, &buf_size);
|
||||
nm_utils_strbuf_append_str(&b, &buf_size, "; ");
|
||||
nm_strbuf_seek_end(&b, &buf_size);
|
||||
nm_strbuf_append_str(&b, &buf_size, "; ");
|
||||
nmp_object_to_string(obj->_link.netlink.lnk, NMP_OBJECT_TO_STRING_PUBLIC, b, buf_size);
|
||||
}
|
||||
return buf;
|
||||
|
|
@ -1065,29 +1065,28 @@ _vt_cmd_obj_to_string_lnk_wireguard(const NMPObject * obj,
|
|||
case NMP_OBJECT_TO_STRING_ALL:
|
||||
b = buf;
|
||||
|
||||
nm_utils_strbuf_append(
|
||||
&b,
|
||||
&buf_size,
|
||||
"[%s,%p,%u,%calive,%cvisible; %s"
|
||||
"%s",
|
||||
klass->obj_type_name,
|
||||
obj,
|
||||
obj->parent._ref_count,
|
||||
nmp_object_is_alive(obj) ? '+' : '-',
|
||||
nmp_object_is_visible(obj) ? '+' : '-',
|
||||
nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_PUBLIC, buf2, sizeof(buf2)),
|
||||
obj->_lnk_wireguard.peers_len > 0 ? " peers {" : "");
|
||||
nm_strbuf_append(&b,
|
||||
&buf_size,
|
||||
"[%s,%p,%u,%calive,%cvisible; %s"
|
||||
"%s",
|
||||
klass->obj_type_name,
|
||||
obj,
|
||||
obj->parent._ref_count,
|
||||
nmp_object_is_alive(obj) ? '+' : '-',
|
||||
nmp_object_is_visible(obj) ? '+' : '-',
|
||||
nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_PUBLIC, buf2, sizeof(buf2)),
|
||||
obj->_lnk_wireguard.peers_len > 0 ? " peers {" : "");
|
||||
|
||||
for (i = 0; i < obj->_lnk_wireguard.peers_len; i++) {
|
||||
const NMPWireGuardPeer *peer = &obj->_lnk_wireguard.peers[i];
|
||||
|
||||
nm_utils_strbuf_append_str(&b, &buf_size, " { ");
|
||||
nm_strbuf_append_str(&b, &buf_size, " { ");
|
||||
nm_platform_wireguard_peer_to_string(peer, b, buf_size);
|
||||
nm_utils_strbuf_seek_end(&b, &buf_size);
|
||||
nm_utils_strbuf_append_str(&b, &buf_size, " }");
|
||||
nm_strbuf_seek_end(&b, &buf_size);
|
||||
nm_strbuf_append_str(&b, &buf_size, " }");
|
||||
}
|
||||
if (obj->_lnk_wireguard.peers_len)
|
||||
nm_utils_strbuf_append_str(&b, &buf_size, " }");
|
||||
nm_strbuf_append_str(&b, &buf_size, " }");
|
||||
|
||||
return buf;
|
||||
case NMP_OBJECT_TO_STRING_PUBLIC:
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ nm_vpn_openconnect_authenticate_helper(const char *host,
|
|||
* HOST='1.2.3.4'
|
||||
* FINGERPRINT='sha1:32bac90cf09a722e10ecc1942c67fe2ac8c21e2e'
|
||||
*/
|
||||
output_v = nm_utils_strsplit_set_with_empty(output, "\r\n");
|
||||
output_v = nm_strsplit_set_with_empty(output, "\r\n");
|
||||
for (iter = output_v; iter && *iter; iter++) {
|
||||
char *s_mutable = (char *) *iter;
|
||||
|
||||
|
|
|
|||
|
|
@ -191,14 +191,13 @@ _value_strsplit(const char *value, ValueStrsplitMode split_mode, gsize *out_len)
|
|||
/* note that all modes remove empty tokens (",", "a,,b", ",,"). */
|
||||
switch (split_mode) {
|
||||
case VALUE_STRSPLIT_MODE_OBJLIST:
|
||||
strv = nm_utils_strsplit_set_full(value,
|
||||
ESCAPED_TOKENS_DELIMITERS,
|
||||
NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
strv =
|
||||
nm_strsplit_set_full(value, ESCAPED_TOKENS_DELIMITERS, NM_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
break;
|
||||
case VALUE_STRSPLIT_MODE_MULTILIST:
|
||||
strv = nm_utils_strsplit_set_full(value,
|
||||
ESCAPED_TOKENS_WITH_SPACES_DELIMTERS,
|
||||
NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
strv = nm_strsplit_set_full(value,
|
||||
ESCAPED_TOKENS_WITH_SPACES_DELIMTERS,
|
||||
NM_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
break;
|
||||
case VALUE_STRSPLIT_MODE_ESCAPED_TOKENS:
|
||||
strv = nm_utils_escaped_tokens_split(value, ESCAPED_TOKENS_DELIMITERS);
|
||||
|
|
@ -309,7 +308,7 @@ _parse_ip_route(int family, const char *str, GError **error)
|
|||
nm_assert(!error || !*error);
|
||||
|
||||
str_clean = nm_strstrip_avoid_copy_a(300, str, &str_clean_free);
|
||||
routev = nm_utils_strsplit_set(str_clean, " \t");
|
||||
routev = nm_strsplit_set(str_clean, " \t");
|
||||
if (!routev) {
|
||||
g_set_error(error, 1, 0, "'%s' is not valid. %s", str, ROUTE_SYNTAX);
|
||||
return NULL;
|
||||
|
|
@ -922,7 +921,7 @@ _get_fcn_gobject_impl(const NMMetaPropertyInfo *property_info,
|
|||
nm_assert(property_info->property_type->set_fcn == _set_fcn_optionlist);
|
||||
|
||||
strdict = g_value_get_boxed(&val);
|
||||
keys = nm_utils_strdict_get_keys(strdict, TRUE, NULL);
|
||||
keys = nm_strdict_get_keys(strdict, TRUE, NULL);
|
||||
if (!keys)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -2271,7 +2270,7 @@ static gboolean _set_fcn_gobject_bytes(ARGS_SET_FCN)
|
|||
}
|
||||
|
||||
/* Otherwise, consider the following format: AA b 0xCc D */
|
||||
strv = nm_utils_strsplit_set(value, " \t");
|
||||
strv = nm_strsplit_set(value, " \t");
|
||||
array = g_byte_array_sized_new(NM_PTRARRAY_LEN(strv));
|
||||
for (iter = strv; iter && *iter; iter++) {
|
||||
int v;
|
||||
|
|
@ -2916,7 +2915,7 @@ static gboolean _set_fcn_dcb_flags(ARGS_SET_FCN)
|
|||
const char *const * iter;
|
||||
|
||||
/* Check for individual flag numbers */
|
||||
strv = nm_utils_strsplit_set(value, " \t,");
|
||||
strv = nm_strsplit_set(value, " \t,");
|
||||
for (iter = strv; iter && *iter; iter++) {
|
||||
t = _nm_utils_ascii_str_to_int64(*iter, 0, 0, DCB_ALL_FLAGS, -1);
|
||||
|
||||
|
|
@ -2957,7 +2956,7 @@ dcb_parse_uint_array(const char *val,
|
|||
const char *const * iter;
|
||||
gsize i;
|
||||
|
||||
items = nm_utils_strsplit_set_with_empty(val, ",");
|
||||
items = nm_strsplit_set_with_empty(val, ",");
|
||||
if (NM_PTRARRAY_LEN(items) != 8) {
|
||||
g_set_error_literal(error, 1, 0, _("must contain 8 comma-separated numbers"));
|
||||
return FALSE;
|
||||
|
|
@ -4033,7 +4032,7 @@ static gboolean _set_fcn_wired_s390_subchannels(ARGS_SET_FCN)
|
|||
if (_SET_FCN_DO_RESET_DEFAULT(property_info, modifier, value))
|
||||
return _gobject_property_reset_default(setting, property_info->property_name);
|
||||
|
||||
strv = nm_utils_strsplit_set(value, " ,\t");
|
||||
strv = nm_strsplit_set(value, " ,\t");
|
||||
len = NM_PTRARRAY_LEN(strv);
|
||||
if (len != 2 && len != 3) {
|
||||
g_set_error(error, 1, 0, _("'%s' is not valid; 2 or 3 strings should be provided"), value);
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ nmt_newt_parse_colors(const char *s, bool is_newt)
|
|||
gs_free const char **lines = NULL;
|
||||
size_t i;
|
||||
|
||||
lines = nm_utils_strsplit_set(s, ";:\n\r\t ");
|
||||
lines = nm_strsplit_set(s, ";:\n\r\t ");
|
||||
|
||||
if (!lines)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -159,9 +159,9 @@ _get_config_fetch_done_cb(NMHttpClient * http_client,
|
|||
switch (fetch_type) {
|
||||
case GET_CONFIG_FETCH_DONE_TYPE_PRIVATE_IPV4S:
|
||||
|
||||
s_addrs = nm_utils_strsplit_set_full(g_bytes_get_data(response, NULL),
|
||||
",",
|
||||
NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
s_addrs = nm_strsplit_set_full(g_bytes_get_data(response, NULL),
|
||||
",",
|
||||
NM_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
len = NM_PTRARRAY_LEN(s_addrs);
|
||||
nm_assert(!config_iface_data->has_ipv4s);
|
||||
nm_assert(!config_iface_data->ipv4s_arr);
|
||||
|
|
|
|||
|
|
@ -145,9 +145,9 @@ _get_config_fetch_done_cb(NMHttpClient *http_client,
|
|||
gs_free const char **s_addrs = NULL;
|
||||
gsize i, len;
|
||||
|
||||
s_addrs = nm_utils_strsplit_set_full(g_bytes_get_data(response, NULL),
|
||||
"\n",
|
||||
NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
s_addrs = nm_strsplit_set_full(g_bytes_get_data(response, NULL),
|
||||
"\n",
|
||||
NM_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
len = NM_PTRARRAY_LEN(s_addrs);
|
||||
|
||||
nm_assert(!config_iface_data->has_ipv4s);
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ add_uint_array(GKeyFile * kf,
|
|||
if (tmp == NULL)
|
||||
return TRUE;
|
||||
|
||||
split = nm_utils_strsplit_set_with_empty(tmp, " ");
|
||||
split = nm_strsplit_set_with_empty(tmp, " ");
|
||||
if (split) {
|
||||
gs_unref_array GArray *items = NULL;
|
||||
|
||||
|
|
@ -229,7 +229,7 @@ parse_ip4(GKeyFile *kf, GVariant **out_props, const char *section, GError **erro
|
|||
tmp = g_key_file_get_string(kf, section, "domains", error);
|
||||
if (tmp == NULL)
|
||||
return FALSE;
|
||||
split = nm_utils_strsplit_set_with_empty(tmp, " ");
|
||||
split = nm_strsplit_set_with_empty(tmp, " ");
|
||||
if (split) {
|
||||
for (iter = split; *iter; iter++)
|
||||
g_strstrip((char *) *iter);
|
||||
|
|
@ -247,7 +247,7 @@ parse_ip4(GKeyFile *kf, GVariant **out_props, const char *section, GError **erro
|
|||
tmp = g_key_file_get_string(kf, section, "addresses", error);
|
||||
if (tmp == NULL)
|
||||
return FALSE;
|
||||
split = nm_utils_strsplit_set_with_empty(tmp, ",");
|
||||
split = nm_strsplit_set_with_empty(tmp, ",");
|
||||
if (split) {
|
||||
gs_unref_ptrarray GPtrArray *addresses = NULL;
|
||||
const char * gateway = NULL;
|
||||
|
|
@ -291,7 +291,7 @@ parse_ip4(GKeyFile *kf, GVariant **out_props, const char *section, GError **erro
|
|||
|
||||
nm_clear_g_free(&tmp);
|
||||
tmp = g_key_file_get_string(kf, section, "routes", NULL);
|
||||
split = nm_utils_strsplit_set_with_empty(tmp, ",");
|
||||
split = nm_strsplit_set_with_empty(tmp, ",");
|
||||
if (split) {
|
||||
gs_unref_ptrarray GPtrArray *routes = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ reader_read_all_connections_from_fw(Reader *reader, const char *sysfs_dir)
|
|||
gs_free const char ** keys = NULL;
|
||||
|
||||
ibft = nmi_ibft_read(sysfs_dir);
|
||||
keys = nm_utils_strdict_get_keys(ibft, TRUE, &length);
|
||||
keys = nm_strdict_get_keys(ibft, TRUE, &length);
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
gs_unref_object NMConnection *connection = NULL;
|
||||
|
|
@ -461,7 +461,7 @@ _parse_ip_method(const char *kind)
|
|||
|
||||
/* dracut also supports combinations, separated by comma. We don't
|
||||
* support arbitrary combinations, but accept specific subsets. */
|
||||
strv = nm_utils_strsplit_set_full(kind, ",", NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
strv = nm_strsplit_set_full(kind, ",", NM_STRSPLIT_SET_FLAGS_STRSTRIP);
|
||||
if (!strv)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -1292,7 +1292,7 @@ nmi_cmdline_reader_parse(const char * sysfs_dir,
|
|||
_nm_utils_ascii_str_to_int64(argument, 10, 1, G_MAXINT32, dhcp_num_tries);
|
||||
} else if (nm_streq(tag, "rd.net.dhcp.vendor-class")) {
|
||||
if (nm_utils_validate_dhcp4_vendor_class_id(argument, NULL))
|
||||
nm_utils_strdup_reset(&reader->dhcp4_vci, argument);
|
||||
nm_strdup_reset(&reader->dhcp4_vci, argument);
|
||||
} else if (nm_streq(tag, "rd.net.timeout.carrier")) {
|
||||
reader->carrier_timeout_sec =
|
||||
_nm_utils_ascii_str_to_int64(argument, 10, 0, G_MAXINT32, 0);
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ _name_owner_changed_cb(GDBusConnection *connection,
|
|||
gl->name_owner ?: "(null)",
|
||||
new_owner ?: "(null)");
|
||||
|
||||
nm_utils_strdup_reset(&gl->name_owner, new_owner);
|
||||
nm_strdup_reset(&gl->name_owner, new_owner);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ get_secrets_from_user(const NmcConfig *nmc_config,
|
|||
if (secret->value) {
|
||||
/* Prefill the password if we have it. */
|
||||
rl_startup_hook = set_deftext;
|
||||
nm_utils_strdup_reset(&pre_input_deftext, secret->value);
|
||||
nm_strdup_reset(&pre_input_deftext, secret->value);
|
||||
}
|
||||
if (secret->no_prompt_entry_id)
|
||||
pwd = nmc_readline(nmc_config, "%s: ", secret->pretty_name);
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ static gconstpointer _metagen_dhcp_config_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_
|
|||
if (!table)
|
||||
goto arr_out;
|
||||
|
||||
arr2 = (char **) nm_utils_strdict_get_keys(table, TRUE, &n);
|
||||
arr2 = (char **) nm_strdict_get_keys(table, TRUE, &n);
|
||||
if (!n)
|
||||
goto arr_out;
|
||||
|
||||
|
|
@ -712,7 +712,7 @@ get_secrets_from_user(const NmcConfig *nmc_config,
|
|||
} else {
|
||||
/* Prefill the password if we have it. */
|
||||
rl_startup_hook = nmc_rl_set_deftext;
|
||||
nm_utils_strdup_reset(&nmc_rl_pre_input_deftext, secret->value);
|
||||
nm_strdup_reset(&nmc_rl_pre_input_deftext, secret->value);
|
||||
}
|
||||
}
|
||||
if (msg)
|
||||
|
|
|
|||
|
|
@ -1666,7 +1666,7 @@ split_required_fields_for_con_show(const char *input,
|
|||
str1 = g_string_new(NULL);
|
||||
str2 = g_string_new(NULL);
|
||||
|
||||
fields = nm_utils_strsplit_set_with_empty(input, ",");
|
||||
fields = nm_strsplit_set_with_empty(input, ",");
|
||||
for (iter = fields; iter && *iter; iter++) {
|
||||
char * s_mutable = (char *) (*iter);
|
||||
char * dot;
|
||||
|
|
@ -2007,7 +2007,7 @@ parse_preferred_connection_order(const char *order, GError **error)
|
|||
gboolean inverse, unique;
|
||||
guint i;
|
||||
|
||||
strv = nm_utils_strsplit_set(order, ":");
|
||||
strv = nm_strsplit_set(order, ":");
|
||||
if (!strv) {
|
||||
g_set_error(error, NMCLI_ERROR, 0, _("incorrect string '%s' of '--order' option"), order);
|
||||
return NULL;
|
||||
|
|
@ -7377,9 +7377,8 @@ property_edit_submenu(NmCli * nmc,
|
|||
|
||||
case NMC_EDITOR_SUB_CMD_CHANGE:
|
||||
rl_startup_hook = nmc_rl_set_deftext;
|
||||
nm_utils_strdup_reset_take(
|
||||
&nmc_rl_pre_input_deftext,
|
||||
nmc_setting_get_property_parsable(curr_setting, prop_name, NULL));
|
||||
nm_strdup_reset_take(&nmc_rl_pre_input_deftext,
|
||||
nmc_setting_get_property_parsable(curr_setting, prop_name, NULL));
|
||||
prop_val_user = nmc_readline(&nmc->nmc_config, _("Edit '%s' value: "), prop_name);
|
||||
|
||||
if (!nmc_setting_set_property(nmc->client,
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@ _set_fcn_precheck_connection_secondaries(NMClient * client,
|
|||
char ** iter;
|
||||
gboolean modified = FALSE;
|
||||
|
||||
strv0 = nm_utils_strsplit_set(value, " \t,");
|
||||
strv0 = nm_strsplit_set(value, " \t,");
|
||||
if (!strv0)
|
||||
return TRUE;
|
||||
|
||||
|
|
|
|||
|
|
@ -495,7 +495,7 @@ nmc_string_to_arg_array(const char *line,
|
|||
gs_free const char **arr0 = NULL;
|
||||
char ** arr;
|
||||
|
||||
arr0 = nm_utils_strsplit_set(line ?: "", delim ?: " \t");
|
||||
arr0 = nm_strsplit_set(line ?: "", delim ?: " \t");
|
||||
if (!arr0)
|
||||
arr = g_new0(char *, 1);
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue