diff options
author | Thomas Haller <thaller@redhat.com> | 2020-04-02 19:10:15 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-04-04 19:28:41 +0200 |
commit | 30b8bb476a004ecb95a1cf867fed74b21f3b9c1d (patch) | |
tree | 9b68a0f8dc8818f55401fa3702db357f33056145 | |
parent | dbf697c75967406ff05e15e93eb96e7b47df2a1e (diff) | |
download | NetworkManager-30b8bb476a004ecb95a1cf867fed74b21f3b9c1d.tar.gz |
cli: avoid using nm_cli global variable in print_data()
-rw-r--r-- | clients/cli/connections.c | 20 | ||||
-rw-r--r-- | clients/cli/devices.c | 26 | ||||
-rw-r--r-- | clients/cli/utils.c | 14 | ||||
-rw-r--r-- | clients/cli/utils.h | 2 |
4 files changed, 41 insertions, 21 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index e9e21be827..7fe22adf63 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -1388,9 +1388,13 @@ nmc_connection_profile_details (NMConnection *connection, NmCli *nmc) for (i = 0; i < _NM_META_SETTING_TYPE_NUM; i++) row[i].info = (const NMMetaAbstractInfo *) &nm_meta_setting_infos_editor[i]; - print_required_fields (&nmc->nmc_config, NMC_OF_FLAG_MAIN_HEADER_ONLY, - out_indices, header_name, - 0, row); + print_required_fields (&nmc->nmc_config, + &nmc->pager_data, + NMC_OF_FLAG_MAIN_HEADER_ONLY, + out_indices, + header_name, + 0, + row); } /* Loop through the required settings and print them. */ @@ -1473,9 +1477,13 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc) for (i = 0; nmc_fields_con_active_details_groups[i]; i++) row[i].info = (const NMMetaAbstractInfo *) nmc_fields_con_active_details_groups[i]; - print_required_fields (&nmc->nmc_config, NMC_OF_FLAG_MAIN_HEADER_ONLY, - out_indices, header_name, - 0, row); + print_required_fields (&nmc->nmc_config, + &nmc->pager_data, + NMC_OF_FLAG_MAIN_HEADER_ONLY, + out_indices, + header_name, + 0, + row); } /* Loop through the groups and print them. */ diff --git a/clients/cli/devices.c b/clients/cli/devices.c index d829368304..94f7c3c214 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -1340,7 +1340,7 @@ print_bond_bridge_info (NMDevice *device, g_ptr_array_add (out.output_data, arr); print_data_prepare_width (out.output_data); - print_data (&nmc->nmc_config, out_indices, NULL, 0, &out); + print_data (&nmc->nmc_config, &nmc->pager_data, out_indices, NULL, 0, &out); g_string_free (slaves_str, FALSE); @@ -1410,7 +1410,7 @@ print_team_info (NMDevice *device, g_ptr_array_add (out.output_data, arr); print_data_prepare_width (out.output_data); - print_data (&nmc->nmc_config, out_indices, NULL, 0, &out); + print_data (&nmc->nmc_config, &nmc->pager_data, out_indices, NULL, 0, &out); g_string_free (slaves_str, FALSE); @@ -1465,9 +1465,13 @@ show_device_info (NMDevice *device, NmCli *nmc) for (i = 0; i < G_N_ELEMENTS (metagen_device_detail_general); i++) row[i].info = (const NMMetaAbstractInfo *) &metagen_device_detail_general[i]; - print_required_fields (&nmc->nmc_config, NMC_OF_FLAG_MAIN_HEADER_ONLY, - out_indices, header_name, - 0, row); + print_required_fields (&nmc->nmc_config, + &nmc->pager_data, + NMC_OF_FLAG_MAIN_HEADER_ONLY, + out_indices, + header_name, + 0, + row); } /* Loop through the required sections and print them. */ @@ -1578,7 +1582,7 @@ show_device_info (NMDevice *device, NmCli *nmc) } print_data_prepare_width (out.output_data); - print_data (&nmc->nmc_config, out_indices, NULL, 0, &out); + print_data (&nmc->nmc_config, &nmc->pager_data, out_indices, NULL, 0, &out); was_output = TRUE; } } @@ -1659,7 +1663,7 @@ show_device_info (NMDevice *device, NmCli *nmc) g_ptr_array_add (out.output_data, arr); print_data_prepare_width (out.output_data); - print_data (&nmc->nmc_config, out_indices, NULL, 0, &out); + print_data (&nmc->nmc_config, &nmc->pager_data, out_indices, NULL, 0, &out); was_output = TRUE; } @@ -1681,7 +1685,7 @@ show_device_info (NMDevice *device, NmCli *nmc) g_ptr_array_add (out.output_data, arr); print_data_prepare_width (out.output_data); - print_data (&nmc->nmc_config, out_indices, NULL, 0, &out); + print_data (&nmc->nmc_config, &nmc->pager_data, out_indices, NULL, 0, &out); was_output = TRUE; } } @@ -2870,7 +2874,7 @@ wifi_print_aps (NMDeviceWifi *wifi, fill_output_access_point (ap, info); print_data_prepare_width (out.output_data); - print_data (&nmc->nmc_config, out_indices, header_name, 0, &out); + print_data (&nmc->nmc_config, &nmc->pager_data, out_indices, header_name, 0, &out); g_free (info); *bssid_found = TRUE; @@ -2878,7 +2882,7 @@ wifi_print_aps (NMDeviceWifi *wifi, } } else { show_access_point_info (wifi, nmc, &out); - print_data (&nmc->nmc_config, out_indices, header_name, 0, &out); + print_data (&nmc->nmc_config, &nmc->pager_data, out_indices, header_name, 0, &out); empty_line = TRUE; } } @@ -4537,7 +4541,7 @@ show_device_lldp_list (NMDevice *device, NmCli *nmc, const char *fields_str, int } print_data_prepare_width (out.output_data); - print_data (&nmc->nmc_config, out_indices, header_name, 0, &out); + print_data (&nmc->nmc_config, &nmc->pager_data, out_indices, header_name, 0, &out); return neighbors->len; } diff --git a/clients/cli/utils.c b/clients/cli/utils.c index e97003de8f..67d5a742a0 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -1571,6 +1571,7 @@ get_value_to_print (const NmcConfig *nmc_config, */ void print_required_fields (const NmcConfig *nmc_config, + NmcPagerData *pager_data, NmcOfFlags of_flags, const GArray *indices, const char *header_name, @@ -1587,7 +1588,7 @@ print_required_fields (const NmcConfig *nmc_config, gboolean field_names = of_flags & NMC_OF_FLAG_FIELD_NAMES; gboolean section_prefix = of_flags & NMC_OF_FLAG_SECTION_PREFIX; - nm_cli_spawn_pager (nmc_config, &nm_cli.pager_data); + nm_cli_spawn_pager (nmc_config, pager_data); /* --- Main header --- */ if ( nmc_config->print_output == NMC_PRINT_PRETTY @@ -1796,6 +1797,7 @@ print_data_prepare_width (GPtrArray *output_data) void print_data (const NmcConfig *nmc_config, + NmcPagerData *pager_data, const GArray *indices, const char *header_name, int indent, @@ -1806,9 +1808,13 @@ print_data (const NmcConfig *nmc_config, for (i = 0; i < out->output_data->len; i++) { const NmcOutputField *field_values = g_ptr_array_index (out->output_data, i); - print_required_fields (nmc_config, field_values[0].flags, - indices, header_name, - indent, field_values); + print_required_fields (nmc_config, + pager_data, + field_values[0].flags, + indices, + header_name, + indent, + field_values); } } diff --git a/clients/cli/utils.h b/clients/cli/utils.h index e770a50b9b..87e93ce082 100644 --- a/clients/cli/utils.h +++ b/clients/cli/utils.h @@ -51,6 +51,7 @@ GArray *parse_output_fields (const char *fields_str, NmcOutputField *nmc_dup_fields_array (const NMMetaAbstractInfo *const*fields, NmcOfFlags flags); void nmc_empty_output_fields (NmcOutputData *output_data); void print_required_fields (const NmcConfig *nmc_config, + NmcPagerData *pager_data, NmcOfFlags of_flags, const GArray *indices, const char *header_name, @@ -58,6 +59,7 @@ void print_required_fields (const NmcConfig *nmc_config, const NmcOutputField *field_values); void print_data_prepare_width (GPtrArray *output_data); void print_data (const NmcConfig *nmc_config, + NmcPagerData *pager_data, const GArray *indices, const char *header_name, int indent, |