Unverified Commit 3587cbd8 authored by Thomas Haller's avatar Thomas Haller
Browse files

all: rename nm_utils_strsplit_set*() to nm_strsplit_set*()

parent 4ac66a42
......@@ -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);
......
......@@ -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++) {
......
......@@ -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++)
......
......@@ -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,
......
......@@ -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))
......
......@@ -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);
......
......@@ -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];
......
......@@ -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
......
......@@ -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,
......
This diff is collapsed.
......@@ -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;
......
......@@ -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