2010-02-25 09:52:30 -08:00
|
|
|
/* nmcli - command-line tool to control NetworkManager
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*
|
2015-02-13 13:25:16 +01:00
|
|
|
* Copyright 2010 - 2015 Red Hat, Inc.
|
2010-02-25 09:52:30 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef NMC_UTILS_H
|
|
|
|
|
#define NMC_UTILS_H
|
|
|
|
|
|
2010-03-18 15:39:15 +01:00
|
|
|
#include "nmcli.h"
|
|
|
|
|
|
2013-01-16 12:26:45 +01:00
|
|
|
/* === Types === */
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
const char *name;
|
|
|
|
|
gboolean has_value;
|
|
|
|
|
const char **value;
|
|
|
|
|
gboolean mandatory;
|
|
|
|
|
gboolean found;
|
|
|
|
|
} nmc_arg_t;
|
|
|
|
|
|
2010-03-18 15:39:15 +01:00
|
|
|
/* === Functions === */
|
2017-03-30 16:09:46 +02:00
|
|
|
int next_arg (NmCli *nmc, int *argc, char ***argv, ...);
|
2013-04-18 11:25:49 +02:00
|
|
|
gboolean nmc_arg_is_help (const char *arg);
|
2013-11-07 14:47:12 +01:00
|
|
|
gboolean nmc_arg_is_option (const char *arg, const char *opt_name);
|
2013-01-16 12:26:45 +01:00
|
|
|
gboolean nmc_parse_args (nmc_arg_t *arg_arr, gboolean last, int *argc, char ***argv, GError **error);
|
2013-05-16 16:26:15 +02:00
|
|
|
char *ssid_to_hex (const char *str, gsize len);
|
2012-04-28 22:32:21 +01:00
|
|
|
void nmc_terminal_erase_line (void);
|
|
|
|
|
void nmc_terminal_show_progress (const char *str);
|
2013-04-05 23:42:56 +02:00
|
|
|
const char *nmc_term_color_sequence (NmcTermColor color);
|
2015-02-17 13:20:37 +01:00
|
|
|
const char *nmc_term_format_sequence (NmcTermFormat format);
|
2015-06-10 17:41:53 +02:00
|
|
|
NmcTermColor nmc_term_color_parse_string (const char *str, GError **error);
|
2017-03-30 12:23:26 +02:00
|
|
|
char *nmc_colorize (NmcColorOption color_option, NmcTermColor color, NmcTermFormat format, const char * fmt, ...) _nm_printf (4, 5);
|
2015-02-13 13:25:16 +01:00
|
|
|
void nmc_filter_out_colors_inplace (char *str);
|
|
|
|
|
char *nmc_filter_out_colors (const char *str);
|
2012-11-21 16:53:23 +01:00
|
|
|
char *nmc_get_user_input (const char *ask_str);
|
2015-03-12 14:11:18 +01:00
|
|
|
int nmc_string_to_arg_array (const char *line, const char *delim, gboolean unquote,
|
|
|
|
|
char ***argv, int *argc);
|
2013-04-08 09:25:44 +02:00
|
|
|
const char *nmc_string_is_valid (const char *input, const char **allowed, GError **error);
|
2017-03-25 13:20:11 +01:00
|
|
|
char * nmc_util_strv_for_display (const char *const*strv, gboolean brackets);
|
2013-01-18 15:21:00 +01:00
|
|
|
char **nmc_strsplit_set (const char *str, const char *delimiter, int max_tokens);
|
2010-04-26 17:32:18 +02:00
|
|
|
int nmc_string_screen_width (const char *start, const char *end);
|
2013-05-22 08:36:09 +02:00
|
|
|
void set_val_str (NmcOutputField fields_array[], guint32 index, char *value);
|
|
|
|
|
void set_val_strc (NmcOutputField fields_array[], guint32 index, const char *value);
|
|
|
|
|
void set_val_arr (NmcOutputField fields_array[], guint32 index, char **value);
|
|
|
|
|
void set_val_arrc (NmcOutputField fields_array[], guint32 index, const char **value);
|
2015-02-13 08:54:32 +01:00
|
|
|
void set_val_color_all (NmcOutputField fields_array[], NmcTermColor color);
|
2015-02-17 13:20:37 +01:00
|
|
|
void set_val_color_fmt_all (NmcOutputField fields_array[], NmcTermFormat format);
|
2013-03-25 10:44:15 -04:00
|
|
|
void nmc_free_output_field_values (NmcOutputField fields_array[]);
|
2013-12-10 12:00:53 +01:00
|
|
|
GArray *parse_output_fields (const char *fields_str,
|
|
|
|
|
const NmcOutputField fields_array[],
|
|
|
|
|
gboolean parse_groups,
|
|
|
|
|
GPtrArray **group_fields,
|
|
|
|
|
GError **error);
|
2013-11-07 14:47:12 +01:00
|
|
|
char *nmc_get_allowed_fields (const NmcOutputField fields_array[], int group_idx);
|
2013-05-22 08:36:09 +02:00
|
|
|
NmcOutputField *nmc_dup_fields_array (NmcOutputField fields[], size_t size, guint32 flags);
|
2017-03-30 13:34:35 +02:00
|
|
|
void nmc_empty_output_fields (NmcOutputData *output_data);
|
2017-03-31 12:55:43 +02:00
|
|
|
void print_required_fields (const NmcConfig *nmc_config,
|
|
|
|
|
NmcOfFlags of_flags,
|
|
|
|
|
const GArray *indices,
|
|
|
|
|
const char *header_name,
|
|
|
|
|
int indent,
|
|
|
|
|
const NmcOutputField *field_values);
|
2017-03-30 13:46:09 +02:00
|
|
|
void print_data_prepare_width (GPtrArray *output_data);
|
2017-03-31 13:21:47 +02:00
|
|
|
void print_data (const NmcConfig *nmc_config,
|
|
|
|
|
const GArray *indices,
|
|
|
|
|
const char *header_name,
|
|
|
|
|
int indent,
|
|
|
|
|
const NmcOutputData *out);
|
2010-02-25 09:52:30 -08:00
|
|
|
|
|
|
|
|
#endif /* NMC_UTILS_H */
|