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 === */
|
2010-02-25 09:52:30 -08:00
|
|
|
int matches (const char *cmd, const char *pattern);
|
|
|
|
|
int next_arg (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);
|
2013-01-16 12:28:37 +01:00
|
|
|
gboolean nmc_string_to_int_base (const char *str,
|
|
|
|
|
int base,
|
|
|
|
|
gboolean range_check,
|
|
|
|
|
long int min,
|
|
|
|
|
long int max,
|
|
|
|
|
long int *value);
|
|
|
|
|
gboolean nmc_string_to_uint_base (const char *str,
|
|
|
|
|
int base,
|
|
|
|
|
gboolean range_check,
|
|
|
|
|
unsigned long int min,
|
|
|
|
|
unsigned long int max,
|
|
|
|
|
unsigned long int *value);
|
|
|
|
|
gboolean nmc_string_to_int (const char *str,
|
|
|
|
|
gboolean range_check,
|
|
|
|
|
long int min,
|
|
|
|
|
long int max,
|
|
|
|
|
long int *value);
|
|
|
|
|
gboolean nmc_string_to_uint (const char *str,
|
|
|
|
|
gboolean range_check,
|
|
|
|
|
unsigned long int min,
|
|
|
|
|
unsigned long int max,
|
|
|
|
|
unsigned long int *value);
|
2013-04-06 23:25:38 +02:00
|
|
|
gboolean nmc_string_to_bool (const char *str, gboolean *val_bool, GError **error);
|
2012-01-05 16:30:22 +01:00
|
|
|
char *nmc_ip4_address_as_string (guint32 ip, GError **error);
|
|
|
|
|
char *nmc_ip6_address_as_string (const struct in6_addr *ip, GError **error);
|
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);
|
|
|
|
|
char *nmc_colorize (NmcTermColor color, NmcTermFormat format, const char * fmt, ...);
|
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);
|
2013-01-18 15:21:00 +01:00
|
|
|
GSList *nmc_util_strv_to_slist (char **strv);
|
2015-04-22 11:46:55 +02:00
|
|
|
char * nmc_util_strv_for_display (const char **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);
|
2010-03-22 18:43:28 +01:00
|
|
|
gboolean nmc_terse_option_check (NMCPrintOutput print_output, const char *fields, GError **error);
|
2013-05-22 08:36:09 +02:00
|
|
|
NmcOutputField *nmc_dup_fields_array (NmcOutputField fields[], size_t size, guint32 flags);
|
|
|
|
|
void nmc_empty_output_fields (NmCli *nmc);
|
|
|
|
|
void print_required_fields (NmCli *nmc, const NmcOutputField field_values[]);
|
|
|
|
|
void print_data (NmCli *nmc);
|
2011-02-16 17:36:50 +01:00
|
|
|
gboolean nmc_versions_match (NmCli *nmc);
|
2010-02-25 09:52:30 -08:00
|
|
|
|
|
|
|
|
#endif /* NMC_UTILS_H */
|