summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-02-06 17:00:00 +0100
committerThomas Haller <thaller@redhat.com>2023-02-08 10:11:16 +0100
commit4b2ded7a4aacc00107f216e577d46b8eaa7cf424 (patch)
tree35fec9765f12d1995d3b26ed3994533fb67ff35e
parentd3e2e9dc20756aeeaadfd6eec5ee50fa24aaaf50 (diff)
downloadNetworkManager-4b2ded7a4aacc00107f216e577d46b8eaa7cf424.tar.gz
nmcli/trivial: rename nmc_print() to nmc_print_table()
nmc_print() will be used for something else. Rename. Also, nmc_print_table() is the better name anyway because the function does a lot of formatting and not simple printf().
-rw-r--r--src/nmcli/common.c36
-rw-r--r--src/nmcli/connections.c45
-rw-r--r--src/nmcli/devices.c119
-rw-r--r--src/nmcli/general.c42
-rw-r--r--src/nmcli/settings.c2
-rw-r--r--src/nmcli/utils.c14
-rw-r--r--src/nmcli/utils.h14
7 files changed, 137 insertions, 135 deletions
diff --git a/src/nmcli/common.c b/src/nmcli/common.c
index 4229f66034..8c89f82dcc 100644
--- a/src/nmcli/common.c
+++ b/src/nmcli/common.c
@@ -354,15 +354,15 @@ print_ip_config(NMIPConfig *cfg,
g_strdup_printf("IP%c.%s", nm_utils_addr_family_to_char(addr_family), one_field);
}
- if (!nmc_print(nmc_config,
- (gpointer[]){cfg, NULL},
- NULL,
- NULL,
- addr_family == AF_INET
- ? NMC_META_GENERIC_GROUP("IP4", metagen_ip4_config, N_("GROUP"))
- : NMC_META_GENERIC_GROUP("IP6", metagen_ip6_config, N_("GROUP")),
- field_str,
- &error)) {
+ if (!nmc_print_table(nmc_config,
+ (gpointer[]){cfg, NULL},
+ NULL,
+ NULL,
+ addr_family == AF_INET
+ ? NMC_META_GENERIC_GROUP("IP4", metagen_ip4_config, N_("GROUP"))
+ : NMC_META_GENERIC_GROUP("IP6", metagen_ip6_config, N_("GROUP")),
+ field_str,
+ &error)) {
return FALSE;
}
return TRUE;
@@ -385,15 +385,15 @@ print_dhcp_config(NMDhcpConfig *dhcp,
g_strdup_printf("DHCP%c.%s", nm_utils_addr_family_to_char(addr_family), one_field);
}
- if (!nmc_print(nmc_config,
- (gpointer[]){dhcp, NULL},
- NULL,
- NULL,
- addr_family == AF_INET
- ? NMC_META_GENERIC_GROUP("DHCP4", metagen_dhcp_config, N_("GROUP"))
- : NMC_META_GENERIC_GROUP("DHCP6", metagen_dhcp_config, N_("GROUP")),
- field_str,
- &error)) {
+ if (!nmc_print_table(nmc_config,
+ (gpointer[]){dhcp, NULL},
+ NULL,
+ NULL,
+ addr_family == AF_INET
+ ? NMC_META_GENERIC_GROUP("DHCP4", metagen_dhcp_config, N_("GROUP"))
+ : NMC_META_GENERIC_GROUP("DHCP6", metagen_dhcp_config, N_("GROUP")),
+ field_str,
+ &error)) {
return FALSE;
}
return TRUE;
diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c
index 059bbbf99a..97cd991e8b 100644
--- a/src/nmcli/connections.c
+++ b/src/nmcli/connections.c
@@ -1729,13 +1729,14 @@ nmc_active_connection_details(NMActiveConnection *acon, NmCli *nmc)
if (group_fld)
f = g_strdup_printf("GENERAL.%s", group_fld);
- nmc_print(&nmc->nmc_config,
- (gpointer[]){acon, NULL},
- NULL,
- NULL,
- NMC_META_GENERIC_GROUP("GENERAL", metagen_con_active_general, N_("GROUP")),
- f,
- NULL);
+ nmc_print_table(
+ &nmc->nmc_config,
+ (gpointer[]){acon, NULL},
+ NULL,
+ NULL,
+ NMC_META_GENERIC_GROUP("GENERAL", metagen_con_active_general, N_("GROUP")),
+ f,
+ NULL);
was_output = TRUE;
continue;
}
@@ -1786,13 +1787,13 @@ nmc_active_connection_details(NMActiveConnection *acon, NmCli *nmc)
if (nmc_fields_con_active_details_groups[group_idx]->nested == metagen_con_active_vpn) {
if (NM_IS_VPN_CONNECTION(acon)) {
- nmc_print(&nmc->nmc_config,
- (gpointer[]){acon, NULL},
- NULL,
- NULL,
- NMC_META_GENERIC_GROUP("VPN", metagen_con_active_vpn, N_("NAME")),
- group_fld,
- NULL);
+ nmc_print_table(&nmc->nmc_config,
+ (gpointer[]){acon, NULL},
+ NULL,
+ NULL,
+ NMC_META_GENERIC_GROUP("VPN", metagen_con_active_vpn, N_("NAME")),
+ group_fld,
+ NULL);
was_output = TRUE;
}
continue;
@@ -2367,14 +2368,14 @@ do_connections_show(const NMCCommand *cmd, NmCli *nmc, int argc, const char *con
items = con_show_get_items(nmc, active_only, show_active_fields, order);
g_ptr_array_add(items, NULL);
- if (!nmc_print(&nmc->nmc_config,
- items->pdata,
- NULL,
- active_only ? _("NetworkManager active profiles")
- : _("NetworkManager connection profiles"),
- (const NMMetaAbstractInfo *const *) metagen_con_show,
- fields_str,
- &err))
+ if (!nmc_print_table(&nmc->nmc_config,
+ items->pdata,
+ NULL,
+ active_only ? _("NetworkManager active profiles")
+ : _("NetworkManager connection profiles"),
+ (const NMMetaAbstractInfo *const *) metagen_con_show,
+ fields_str,
+ &err))
goto finish;
} else {
gboolean new_line = FALSE;
diff --git a/src/nmcli/devices.c b/src/nmcli/devices.c
index af9aaa93af..445f12313f 100644
--- a/src/nmcli/devices.c
+++ b/src/nmcli/devices.c
@@ -1654,13 +1654,14 @@ show_device_info(NMDevice *device, NmCli *nmc)
if (nmc_fields_dev_show_sections[section_idx]->nested == metagen_device_detail_general) {
gs_free char *f = section_fld ? g_strdup_printf("GENERAL.%s", section_fld) : NULL;
- nmc_print(&nmc->nmc_config,
- (gpointer[]){device, NULL},
- NULL,
- NULL,
- NMC_META_GENERIC_GROUP("GENERAL", metagen_device_detail_general, N_("NAME")),
- f,
- NULL);
+ nmc_print_table(
+ &nmc->nmc_config,
+ (gpointer[]){device, NULL},
+ NULL,
+ NULL,
+ NMC_META_GENERIC_GROUP("GENERAL", metagen_device_detail_general, N_("NAME")),
+ f,
+ NULL);
was_output = TRUE;
continue;
}
@@ -1669,15 +1670,15 @@ show_device_info(NMDevice *device, NmCli *nmc)
== metagen_device_detail_capabilities) {
gs_free char *f = section_fld ? g_strdup_printf("CAPABILITIES.%s", section_fld) : NULL;
- nmc_print(&nmc->nmc_config,
- (gpointer[]){device, NULL},
- NULL,
- NULL,
- NMC_META_GENERIC_GROUP("CAPABILITIES",
- metagen_device_detail_capabilities,
- N_("NAME")),
- f,
- NULL);
+ nmc_print_table(&nmc->nmc_config,
+ (gpointer[]){device, NULL},
+ NULL,
+ NULL,
+ NMC_META_GENERIC_GROUP("CAPABILITIES",
+ metagen_device_detail_capabilities,
+ N_("NAME")),
+ f,
+ NULL);
was_output = TRUE;
continue;
}
@@ -1687,15 +1688,15 @@ show_device_info(NMDevice *device, NmCli *nmc)
gs_free char *f =
section_fld ? g_strdup_printf("INTERFACE-FLAGS.%s", section_fld) : NULL;
- nmc_print(&nmc->nmc_config,
- (gpointer[]){device, NULL},
- NULL,
- NULL,
- NMC_META_GENERIC_GROUP("INTERFACE-FLAGS",
- metagen_device_detail_interface_flags,
- N_("NAME")),
- f,
- NULL);
+ nmc_print_table(&nmc->nmc_config,
+ (gpointer[]){device, NULL},
+ NULL,
+ NULL,
+ NMC_META_GENERIC_GROUP("INTERFACE-FLAGS",
+ metagen_device_detail_interface_flags,
+ N_("NAME")),
+ f,
+ NULL);
was_output = TRUE;
continue;
}
@@ -1706,15 +1707,15 @@ show_device_info(NMDevice *device, NmCli *nmc)
gs_free char *f =
section_fld ? g_strdup_printf("WIFI-PROPERTIES.%s", section_fld) : NULL;
- nmc_print(&nmc->nmc_config,
- (gpointer[]){device, NULL},
- NULL,
- NULL,
- NMC_META_GENERIC_GROUP("WIFI-PROPERTIES",
- metagen_device_detail_wifi_properties,
- N_("NAME")),
- f,
- NULL);
+ nmc_print_table(&nmc->nmc_config,
+ (gpointer[]){device, NULL},
+ NULL,
+ NULL,
+ NMC_META_GENERIC_GROUP("WIFI-PROPERTIES",
+ metagen_device_detail_wifi_properties,
+ N_("NAME")),
+ f,
+ NULL);
was_output = TRUE;
}
continue;
@@ -1770,15 +1771,15 @@ show_device_info(NMDevice *device, NmCli *nmc)
gs_free char *f =
section_fld ? g_strdup_printf("WIRED-PROPERTIES.%s", section_fld) : NULL;
- nmc_print(&nmc->nmc_config,
- (gpointer[]){device, NULL},
- NULL,
- NULL,
- NMC_META_GENERIC_GROUP("WIRED-PROPERTIES",
- metagen_device_detail_wired_properties,
- N_("NAME")),
- f,
- NULL);
+ nmc_print_table(&nmc->nmc_config,
+ (gpointer[]){device, NULL},
+ NULL,
+ NULL,
+ NMC_META_GENERIC_GROUP("WIRED-PROPERTIES",
+ metagen_device_detail_wired_properties,
+ N_("NAME")),
+ f,
+ NULL);
was_output = TRUE;
}
continue;
@@ -1899,15 +1900,15 @@ show_device_info(NMDevice *device, NmCli *nmc)
== metagen_device_detail_connections) {
gs_free char *f = section_fld ? g_strdup_printf("CONNECTIONS.%s", section_fld) : NULL;
- nmc_print(&nmc->nmc_config,
- (gpointer[]){device, NULL},
- NULL,
- NULL,
- NMC_META_GENERIC_GROUP("CONNECTIONS",
- metagen_device_detail_connections,
- N_("NAME")),
- f,
- NULL);
+ nmc_print_table(&nmc->nmc_config,
+ (gpointer[]){device, NULL},
+ NULL,
+ NULL,
+ NMC_META_GENERIC_GROUP("CONNECTIONS",
+ metagen_device_detail_connections,
+ N_("NAME")),
+ f,
+ NULL);
was_output = TRUE;
continue;
}
@@ -1976,13 +1977,13 @@ do_devices_status(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const
devices = nmc_get_devices_sorted(nmc->client);
- if (!nmc_print(&nmc->nmc_config,
- (gpointer *) devices,
- NULL,
- N_("Status of devices"),
- (const NMMetaAbstractInfo *const *) metagen_device_status,
- fields_str,
- &error)) {
+ if (!nmc_print_table(&nmc->nmc_config,
+ (gpointer *) devices,
+ NULL,
+ N_("Status of devices"),
+ (const NMMetaAbstractInfo *const *) metagen_device_status,
+ fields_str,
+ &error)) {
g_string_printf(nmc->return_text, _("Error: 'device status': %s"), error->message);
g_error_free(error);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
diff --git a/src/nmcli/general.c b/src/nmcli/general.c
index 20471365a8..4cacc027d1 100644
--- a/src/nmcli/general.c
+++ b/src/nmcli/general.c
@@ -491,13 +491,13 @@ show_nm_status(NmCli *nmc, const char *pretty_header_name, const char *print_fld
else
fields_str = nmc->required_fields;
- if (!nmc_print(&nmc->nmc_config,
- (gpointer[]){nmc, NULL},
- NULL,
- pretty_header_name ?: N_("NetworkManager status"),
- (const NMMetaAbstractInfo *const *) metagen_general_status,
- fields_str,
- &error)) {
+ if (!nmc_print_table(&nmc->nmc_config,
+ (gpointer[]){nmc, NULL},
+ NULL,
+ pretty_header_name ?: N_("NetworkManager status"),
+ (const NMMetaAbstractInfo *const *) metagen_general_status,
+ fields_str,
+ &error)) {
g_string_printf(nmc->return_text,
_("Error: only these fields are allowed: %s"),
fields_all);
@@ -570,13 +570,13 @@ print_permissions(void *user_data)
nm_cli_spawn_pager(&nmc->nmc_config, &nmc->pager_data);
- if (!nmc_print(&nmc->nmc_config,
- permissions,
- NULL,
- _("NetworkManager permissions"),
- (const NMMetaAbstractInfo *const *) metagen_general_permissions,
- fields_str,
- &error)) {
+ if (!nmc_print_table(&nmc->nmc_config,
+ permissions,
+ NULL,
+ _("NetworkManager permissions"),
+ (const NMMetaAbstractInfo *const *) metagen_general_permissions,
+ fields_str,
+ &error)) {
g_string_printf(nmc->return_text, _("Error: 'general permissions': %s"), error->message);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
}
@@ -724,13 +724,13 @@ show_general_logging(NmCli *nmc)
} else
fields_str = nmc->required_fields;
- if (!nmc_print(&nmc->nmc_config,
- (gpointer const[]){&d, NULL},
- NULL,
- _("NetworkManager logging"),
- (const NMMetaAbstractInfo *const *) metagen_general_logging,
- fields_str,
- &error)) {
+ if (!nmc_print_table(&nmc->nmc_config,
+ (gpointer const[]){&d, NULL},
+ NULL,
+ _("NetworkManager logging"),
+ (const NMMetaAbstractInfo *const *) metagen_general_logging,
+ fields_str,
+ &error)) {
g_string_printf(nmc->return_text, _("Error: 'general logging': %s"), error->message);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
}
diff --git a/src/nmcli/settings.c b/src/nmcli/settings.c
index 8cc151ba21..3eebb17f3f 100644
--- a/src/nmcli/settings.c
+++ b/src/nmcli/settings.c
@@ -759,7 +759,7 @@ setting_details(const NmcConfig *nmc_config, NMSetting *setting, const char *one
fields_str = g_strdup_printf("%s.%s", nm_setting_get_name(setting), one_prop);
}
- if (!nmc_print(
+ if (!nmc_print_table(
nmc_config,
(gpointer[]){setting, NULL},
NULL,
diff --git a/src/nmcli/utils.c b/src/nmcli/utils.c
index 957c0efaff..3e9674ea6a 100644
--- a/src/nmcli/utils.c
+++ b/src/nmcli/utils.c
@@ -1387,13 +1387,13 @@ _print_do(const NmcConfig *nmc_config,
}
gboolean
-nmc_print(const NmcConfig *nmc_config,
- gpointer const *targets,
- gpointer targets_data,
- const char *header_name_no_l10n,
- const NMMetaAbstractInfo *const *fields,
- const char *fields_str,
- GError **error)
+nmc_print_table(const NmcConfig *nmc_config,
+ gpointer const *targets,
+ gpointer targets_data,
+ const char *header_name_no_l10n,
+ const NMMetaAbstractInfo *const *fields,
+ const char *fields_str,
+ GError **error)
{
gs_unref_ptrarray GPtrArray *gfree_keeper = NULL;
gs_free PrintDataCol *cols_data = NULL;
diff --git a/src/nmcli/utils.h b/src/nmcli/utils.h
index c6ead55b86..3897cd2b87 100644
--- a/src/nmcli/utils.h
+++ b/src/nmcli/utils.h
@@ -359,13 +359,13 @@ nmc_meta_generic_get_enum_with_detail(NmcMetaGenericGetEnumType get_enum_type,
/*****************************************************************************/
-gboolean nmc_print(const NmcConfig *nmc_config,
- gpointer const *targets,
- gpointer targets_data,
- const char *header_name_no_l10n,
- const NMMetaAbstractInfo *const *fields,
- const char *fields_str,
- GError **error);
+gboolean nmc_print_table(const NmcConfig *nmc_config,
+ gpointer const *targets,
+ gpointer targets_data,
+ const char *header_name_no_l10n,
+ const NMMetaAbstractInfo *const *fields,
+ const char *fields_str,
+ GError **error);
/*****************************************************************************/