cli: allow field values to be null-terminated string arrays

Field values can now be string arrays. print_fields() recognizes the format and
prints values accordingly.
Setter functions was added to facilitate setting string vs. array:
set_val_str(), set_val_arr()
This commit is contained in:
Jiří Klimeš
2012-01-03 15:07:17 +01:00
parent a080a1ed08
commit c15d047b46
3 changed files with 75 additions and 26 deletions

View File

@@ -14,7 +14,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2010 - 2011 Red Hat, Inc.
* (C) Copyright 2010 - 2012 Red Hat, Inc.
*/
#ifndef NMC_UTILS_H
@@ -29,6 +29,8 @@ int matches (const char *cmd, const char *pattern);
int next_arg (int *argc, char ***argv);
char *ssid_to_printable (const char *str, gsize len);
int nmc_string_screen_width (const char *start, const char *end);
void set_val_str (NmcOutputField fields_array[], guint32 index, const char *value);
void set_val_arr (NmcOutputField fields_array[], guint32 index, const char **value);
GArray *parse_output_fields (const char *fields_str, const NmcOutputField fields_array[], GError **error);
gboolean nmc_terse_option_check (NMCPrintOutput print_output, const char *fields, GError **error);
void print_fields (const NmcPrintFields fields, const NmcOutputField field_values[]);