Commit 39bc8dbd authored by Thomas Haller's avatar Thomas Haller

cli/trivial: rename NmcOutputSelectionItem type

parent 2026d52f
...@@ -1314,8 +1314,8 @@ split_required_fields_for_con_show (const char *input, ...@@ -1314,8 +1314,8 @@ split_required_fields_for_con_show (const char *input,
else if (!strcasecmp (*iter, CON_SHOW_DETAIL_GROUP_ACTIVE)) else if (!strcasecmp (*iter, CON_SHOW_DETAIL_GROUP_ACTIVE))
group_active = TRUE; group_active = TRUE;
else { else {
char *allowed1 = nmc_get_allowed_fields ((const NMMetaAbstractInfo *const*) nm_meta_setting_infos_editor_p (), NULL); char *allowed1 = nm_meta_abstract_infos_get_names_str ((const NMMetaAbstractInfo *const*) nm_meta_setting_infos_editor_p (), NULL);
char *allowed2 = nmc_get_allowed_fields ((const NMMetaAbstractInfo *const*) nmc_fields_con_active_details_groups, NULL); char *allowed2 = nm_meta_abstract_infos_get_names_str ((const NMMetaAbstractInfo *const*) nmc_fields_con_active_details_groups, NULL);
g_set_error (error, NMCLI_ERROR, 0, _("invalid field '%s'; allowed fields: %s and %s, or %s,%s"), g_set_error (error, NMCLI_ERROR, 0, _("invalid field '%s'; allowed fields: %s and %s, or %s,%s"),
*iter, allowed1, allowed2, CON_SHOW_DETAIL_GROUP_PROFILE, CON_SHOW_DETAIL_GROUP_ACTIVE); *iter, allowed1, allowed2, CON_SHOW_DETAIL_GROUP_PROFILE, CON_SHOW_DETAIL_GROUP_ACTIVE);
g_free (allowed1); g_free (allowed1);
......
...@@ -762,12 +762,12 @@ typedef struct { ...@@ -762,12 +762,12 @@ typedef struct {
gsize sub_offset_plus_1; gsize sub_offset_plus_1;
} OutputSelectionItem; } OutputSelectionItem;
static NmcOutputSelection * static NMMetaSelectionResultList *
_output_selection_pack (const NMMetaAbstractInfo *const* fields_array, _output_selection_pack (const NMMetaAbstractInfo *const* fields_array,
GArray *array, GArray *array,
GString *str) GString *str)
{ {
NmcOutputSelection *result; NMMetaSelectionResultList *result;
guint i; guint i;
guint len; guint len;
...@@ -776,16 +776,16 @@ _output_selection_pack (const NMMetaAbstractInfo *const* fields_array, ...@@ -776,16 +776,16 @@ _output_selection_pack (const NMMetaAbstractInfo *const* fields_array,
/* re-organize the collected output data in one buffer that can be freed using /* re-organize the collected output data in one buffer that can be freed using
* g_free(). This makes allocation more complicated, but saves us from special * g_free(). This makes allocation more complicated, but saves us from special
* handling for free. */ * handling for free. */
result = g_malloc0 (sizeof (NmcOutputSelection) + (len * sizeof (NmcOutputSelectionItem)) + (str ? str->len : 0)); result = g_malloc0 (sizeof (NMMetaSelectionResultList) + (len * sizeof (NMMetaSelectionItem)) + (str ? str->len : 0));
*((guint *) &result->num) = len; *((guint *) &result->num) = len;
if (len > 0) { if (len > 0) {
char *pdata = &((char *) result)[sizeof (NmcOutputSelection) + (len * sizeof (NmcOutputSelectionItem))]; char *pdata = &((char *) result)[sizeof (NMMetaSelectionResultList) + (len * sizeof (NMMetaSelectionItem))];
if (str) if (str)
memcpy (pdata, str->str, str->len); memcpy (pdata, str->str, str->len);
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
const OutputSelectionItem *a = &g_array_index (array, OutputSelectionItem, i); const OutputSelectionItem *a = &g_array_index (array, OutputSelectionItem, i);
NmcOutputSelectionItem *p = (NmcOutputSelectionItem *) &result->items[i]; NMMetaSelectionItem *p = (NMMetaSelectionItem *) &result->items[i];
p->info = fields_array[a->idx]; p->info = fields_array[a->idx];
p->idx = a->idx; p->idx = a->idx;
...@@ -875,9 +875,9 @@ not_found: ...@@ -875,9 +875,9 @@ not_found:
p = g_strdup_printf ("%s.%s", fields_prefix, p = g_strdup_printf ("%s.%s", fields_prefix,
nm_meta_abstract_info_get_name (fields_array_failure, FALSE)); nm_meta_abstract_info_get_name (fields_array_failure, FALSE));
} }
allowed_fields = nmc_get_allowed_fields_nested (fields_array_failure, p); allowed_fields = nm_meta_abstract_info_get_nested_names_str (fields_array_failure, p);
} else } else
allowed_fields = nmc_get_allowed_fields (fields_array, NULL); allowed_fields = nm_meta_abstract_infos_get_names_str (fields_array, NULL);
g_set_error (error, NMCLI_ERROR, 1, _("invalid field '%s%s%s%s%s'; %s%s%s"), g_set_error (error, NMCLI_ERROR, 1, _("invalid field '%s%s%s%s%s'; %s%s%s"),
fields_prefix ?: "", fields_prefix ? "." : "", fields_prefix ?: "", fields_prefix ? "." : "",
...@@ -917,8 +917,8 @@ not_found: ...@@ -917,8 +917,8 @@ not_found:
return TRUE; return TRUE;
} }
static NmcOutputSelection * static NMMetaSelectionResultList *
_output_selection_create_all (const NMMetaAbstractInfo *const* fields_array) nm_meta_selection_create_all (const NMMetaAbstractInfo *const* fields_array)
{ {
gs_unref_array GArray *array = NULL; gs_unref_array GArray *array = NULL;
guint i; guint i;
...@@ -937,12 +937,12 @@ _output_selection_create_all (const NMMetaAbstractInfo *const* fields_array) ...@@ -937,12 +937,12 @@ _output_selection_create_all (const NMMetaAbstractInfo *const* fields_array)
return _output_selection_pack (fields_array, array, NULL); return _output_selection_pack (fields_array, array, NULL);
} }
static NmcOutputSelection * static NMMetaSelectionResultList *
_output_selection_create_one (const NMMetaAbstractInfo *const* fields_array, nm_meta_selection_create_parse_one (const NMMetaAbstractInfo *const* fields_array,
const char *fields_prefix, const char *fields_prefix,
const char *fields_str, /* one field selector (contains not commas) and is alrady stripped of spaces. */ const char *fields_str, /* one field selector (contains no commas) and is already stripped of spaces. */
gboolean validate_nested, gboolean validate_nested,
GError **error) GError **error)
{ {
gs_unref_array GArray *array = NULL; gs_unref_array GArray *array = NULL;
nm_auto_free_gstring GString *str = NULL; nm_auto_free_gstring GString *str = NULL;
...@@ -965,7 +965,7 @@ _output_selection_create_one (const NMMetaAbstractInfo *const* fields_array, ...@@ -965,7 +965,7 @@ _output_selection_create_one (const NMMetaAbstractInfo *const* fields_array,
#define PRINT_DATA_COL_PARENT_NIL (G_MAXUINT) #define PRINT_DATA_COL_PARENT_NIL (G_MAXUINT)
typedef struct { typedef struct {
const NmcOutputSelectionItem *selection_item; const NMMetaSelectionItem *selection_item;
guint parent_idx; guint parent_idx;
guint self_idx; guint self_idx;
bool is_leaf; bool is_leaf;
...@@ -975,7 +975,7 @@ static gboolean ...@@ -975,7 +975,7 @@ static gboolean
_output_selection_append (GArray *cols, _output_selection_append (GArray *cols,
const char *fields_prefix, const char *fields_prefix,
guint parent_idx, guint parent_idx,
const NmcOutputSelectionItem *selection_item, const NMMetaSelectionItem *selection_item,
GPtrArray *gfree_keeper, GPtrArray *gfree_keeper,
GError **error) GError **error)
{ {
...@@ -983,8 +983,8 @@ _output_selection_append (GArray *cols, ...@@ -983,8 +983,8 @@ _output_selection_append (GArray *cols,
guint col_idx; guint col_idx;
guint i; guint i;
const NMMetaAbstractInfo *const*nested; const NMMetaAbstractInfo *const*nested;
NmcOutputSelection *selection; NMMetaSelectionResultList *selection;
const NmcOutputSelectionItem *si; const NMMetaSelectionItem *si;
col_idx = cols->len; col_idx = cols->len;
...@@ -1006,7 +1006,7 @@ _output_selection_append (GArray *cols, ...@@ -1006,7 +1006,7 @@ _output_selection_append (GArray *cols,
if (parent_idx != PRINT_DATA_COL_PARENT_NIL) { if (parent_idx != PRINT_DATA_COL_PARENT_NIL) {
si = g_array_index (cols, PrintDataCol, parent_idx).selection_item; si = g_array_index (cols, PrintDataCol, parent_idx).selection_item;
allowed_fields = nmc_get_allowed_fields_nested (si->info, si->self_selection); allowed_fields = nm_meta_abstract_info_get_nested_names_str (si->info, si->self_selection);
} }
if (!allowed_fields) { if (!allowed_fields) {
g_set_error (error, NMCLI_ERROR, 1, _("invalid field '%s%s%s'; no such field"), g_set_error (error, NMCLI_ERROR, 1, _("invalid field '%s%s%s'; no such field"),
...@@ -1021,13 +1021,13 @@ _output_selection_append (GArray *cols, ...@@ -1021,13 +1021,13 @@ _output_selection_append (GArray *cols,
return FALSE; return FALSE;
} }
selection = _output_selection_create_one (nested, selection_item->self_selection, selection = nm_meta_selection_create_parse_one (nested, selection_item->self_selection,
selection_item->sub_selection, FALSE, error); selection_item->sub_selection, FALSE, error);
if (!selection) if (!selection)
return FALSE; return FALSE;
nm_assert (selection->num == 1); nm_assert (selection->num == 1);
} else if (nested) { } else if (nested) {
selection = _output_selection_create_all (nested); selection = nm_meta_selection_create_all (nested);
nm_assert (selection && selection->num > 0); nm_assert (selection && selection->num > 0);
} else } else
selection = NULL; selection = NULL;
...@@ -1053,12 +1053,12 @@ _output_selection_append (GArray *cols, ...@@ -1053,12 +1053,12 @@ _output_selection_append (GArray *cols,
/*****************************************************************************/ /*****************************************************************************/
NmcOutputSelection * NMMetaSelectionResultList *
nmc_output_selection_create (const NMMetaAbstractInfo *const* fields_array, nm_meta_selection_create_parse_list (const NMMetaAbstractInfo *const* fields_array,
const char *fields_prefix, const char *fields_prefix,
const char *fields_str, /* a comma separated list of selectors */ const char *fields_str, /* a comma separated list of selectors */
gboolean validate_nested, gboolean validate_nested,
GError **error) GError **error)
{ {
gs_unref_array GArray *array = NULL; gs_unref_array GArray *array = NULL;
nm_auto_free_gstring GString *str = NULL; nm_auto_free_gstring GString *str = NULL;
...@@ -1069,7 +1069,7 @@ nmc_output_selection_create (const NMMetaAbstractInfo *const* fields_array, ...@@ -1069,7 +1069,7 @@ nmc_output_selection_create (const NMMetaAbstractInfo *const* fields_array,
g_return_val_if_fail (!error || !*error, NULL); g_return_val_if_fail (!error || !*error, NULL);
if (!fields_str) if (!fields_str)
return _output_selection_create_all (fields_array); return nm_meta_selection_create_all (fields_array);
fields_str_clone = g_strdup (fields_str); fields_str_clone = g_strdup (fields_str);
for (fields_str_cur = fields_str_clone; fields_str_cur; fields_str_cur = fields_str_next) { for (fields_str_cur = fields_str_clone; fields_str_cur; fields_str_cur = fields_str_next) {
...@@ -1117,12 +1117,12 @@ _output_selection_parse (const NMMetaAbstractInfo *const*fields, ...@@ -1117,12 +1117,12 @@ _output_selection_parse (const NMMetaAbstractInfo *const*fields,
GPtrArray **out_gfree_keeper, GPtrArray **out_gfree_keeper,
GError **error) GError **error)
{ {
NmcOutputSelection *selection; NMMetaSelectionResultList *selection;
gs_unref_ptrarray GPtrArray *gfree_keeper = NULL; gs_unref_ptrarray GPtrArray *gfree_keeper = NULL;
gs_unref_array GArray *cols = NULL; gs_unref_array GArray *cols = NULL;
guint i; guint i;
selection = nmc_output_selection_create (fields, NULL, fields_str, FALSE, error); selection = nm_meta_selection_create_parse_list (fields, NULL, fields_str, FALSE, error);
if (!selection) if (!selection)
return FALSE; return FALSE;
...@@ -1137,7 +1137,7 @@ _output_selection_parse (const NMMetaAbstractInfo *const*fields, ...@@ -1137,7 +1137,7 @@ _output_selection_parse (const NMMetaAbstractInfo *const*fields,
cols = g_array_new (FALSE, TRUE, sizeof (PrintDataCol)); cols = g_array_new (FALSE, TRUE, sizeof (PrintDataCol));
for (i = 0; i < selection->num; i++) { for (i = 0; i < selection->num; i++) {
const NmcOutputSelectionItem *si = &selection->items[i]; const NMMetaSelectionItem *si = &selection->items[i];
if (!_output_selection_append (cols, NULL, PRINT_DATA_COL_PARENT_NIL, if (!_output_selection_append (cols, NULL, PRINT_DATA_COL_PARENT_NIL,
si, gfree_keeper, error)) si, gfree_keeper, error))
...@@ -1178,7 +1178,7 @@ parse_output_fields (const char *fields_str, ...@@ -1178,7 +1178,7 @@ parse_output_fields (const char *fields_str,
GPtrArray **out_group_fields, GPtrArray **out_group_fields,
GError **error) GError **error)
{ {
gs_free NmcOutputSelection *selection = NULL; gs_free NMMetaSelectionResultList *selection = NULL;
GArray *array; GArray *array;
GPtrArray *group_fields = NULL; GPtrArray *group_fields = NULL;
guint i; guint i;
...@@ -1186,7 +1186,7 @@ parse_output_fields (const char *fields_str, ...@@ -1186,7 +1186,7 @@ parse_output_fields (const char *fields_str,
g_return_val_if_fail (!error || !*error, NULL); g_return_val_if_fail (!error || !*error, NULL);
g_return_val_if_fail (!out_group_fields || !*out_group_fields, NULL); g_return_val_if_fail (!out_group_fields || !*out_group_fields, NULL);
selection = nmc_output_selection_create (fields_array, NULL, fields_str, TRUE, error); selection = nm_meta_selection_create_parse_list (fields_array, NULL, fields_str, TRUE, error);
if (!selection) if (!selection)
return NULL; return NULL;
...@@ -1208,7 +1208,7 @@ parse_output_fields (const char *fields_str, ...@@ -1208,7 +1208,7 @@ parse_output_fields (const char *fields_str,
} }
char * char *
nmc_get_allowed_fields_nested (const NMMetaAbstractInfo *abstract_info, const char *name_prefix) nm_meta_abstract_info_get_nested_names_str (const NMMetaAbstractInfo *abstract_info, const char *name_prefix)
{ {
gs_free gpointer nested_to_free = NULL; gs_free gpointer nested_to_free = NULL;
guint i; guint i;
...@@ -1233,7 +1233,7 @@ nmc_get_allowed_fields_nested (const NMMetaAbstractInfo *abstract_info, const ch ...@@ -1233,7 +1233,7 @@ nmc_get_allowed_fields_nested (const NMMetaAbstractInfo *abstract_info, const ch
} }
char * char *
nmc_get_allowed_fields (const NMMetaAbstractInfo *const*fields_array, const char *name_prefix) nm_meta_abstract_infos_get_names_str (const NMMetaAbstractInfo *const*fields_array, const char *name_prefix)
{ {
GString *allowed_fields; GString *allowed_fields;
guint i; guint i;
...@@ -1523,7 +1523,7 @@ static gboolean ...@@ -1523,7 +1523,7 @@ static gboolean
_print_skip_column (const NmcConfig *nmc_config, _print_skip_column (const NmcConfig *nmc_config,
const PrintDataHeaderCell *header_cell) const PrintDataHeaderCell *header_cell)
{ {
const NmcOutputSelectionItem *selection_item; const NMMetaSelectionItem *selection_item;
const NMMetaAbstractInfo *info; const NMMetaAbstractInfo *info;
selection_item = header_cell->col->selection_item; selection_item = header_cell->col->selection_item;
......
...@@ -66,26 +66,26 @@ typedef struct { ...@@ -66,26 +66,26 @@ typedef struct {
const char *self_selection; const char *self_selection;
const char *sub_selection; const char *sub_selection;
guint idx; guint idx;
} NmcOutputSelectionItem; } NMMetaSelectionItem;
typedef struct { typedef struct {
const guint num; const guint num;
const NmcOutputSelectionItem items[]; const NMMetaSelectionItem items[];
} NmcOutputSelection; } NMMetaSelectionResultList;
NmcOutputSelection *nmc_output_selection_create (const NMMetaAbstractInfo *const* fields_array, NMMetaSelectionResultList *nm_meta_selection_create_parse_list (const NMMetaAbstractInfo *const* fields_array,
const char *fields_prefix, const char *fields_prefix,
const char *fields_str, const char *fields_str,
gboolean validate_nested, gboolean validate_nested,
GError **error); GError **error);
GArray *parse_output_fields (const char *fields_str, GArray *parse_output_fields (const char *fields_str,
const NMMetaAbstractInfo *const* fields_array, const NMMetaAbstractInfo *const* fields_array,
gboolean parse_groups, gboolean parse_groups,
GPtrArray **group_fields, GPtrArray **group_fields,
GError **error); GError **error);
char *nmc_get_allowed_fields_nested (const NMMetaAbstractInfo *abstract_info, const char *name_prefix); char *nm_meta_abstract_info_get_nested_names_str (const NMMetaAbstractInfo *abstract_info, const char *name_prefix);
char *nmc_get_allowed_fields (const NMMetaAbstractInfo *const*fields_array, const char *name_prefix); char *nm_meta_abstract_infos_get_names_str (const NMMetaAbstractInfo *const*fields_array, const char *name_prefix);
NmcOutputField *nmc_dup_fields_array (const NMMetaAbstractInfo *const*fields, NmcOfFlags flags); NmcOutputField *nmc_dup_fields_array (const NMMetaAbstractInfo *const*fields, NmcOfFlags flags);
void nmc_empty_output_fields (NmcOutputData *output_data); void nmc_empty_output_fields (NmcOutputData *output_data);
void print_required_fields (const NmcConfig *nmc_config, void print_required_fields (const NmcConfig *nmc_config,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment