diff options
| author | Michael Biebl <biebl@debian.org> | 2017-11-07 00:14:39 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2017-11-07 00:14:39 +0100 |
| commit | 90e8691111889a7b5f3c812f5a41f15a8a058913 (patch) | |
| tree | f101a879eca27c34a9bfa5f3da52266b22539a36 /clients/cli/nmcli.h | |
| parent | bdb6eeb0670658255c2a4c3c501c0a27fa8cfe55 (diff) | |
New upstream version 1.9.90 upstream/1.9.90
Diffstat (limited to 'clients/cli/nmcli.h')
| -rw-r--r-- | clients/cli/nmcli.h | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/clients/cli/nmcli.h b/clients/cli/nmcli.h index 7e33e3a7..874bca21 100644 --- a/clients/cli/nmcli.h +++ b/clients/cli/nmcli.h @@ -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. * - * Copyright 2010 - 2015 Red Hat, Inc. + * Copyright 2010 - 2017 Red Hat, Inc. */ #ifndef NMC_NMCLI_H @@ -23,6 +23,8 @@ #include "NetworkManager.h" #include "nm-secret-agent-old.h" +#include "nm-meta-setting-desc.h" + #if WITH_POLKIT_AGENT #include "nm-polkit-listener.h" #else @@ -30,6 +32,8 @@ typedef gpointer NMPolkitListener; #endif +typedef char *(*NmcCompEntryFunc) (const char *, int); + /* nmcli exit codes */ typedef enum { /* Indicates successful execution */ @@ -70,58 +74,35 @@ typedef enum { } NMCResultCode; typedef enum { - NMC_TERM_COLOR_NORMAL = 0, - NMC_TERM_COLOR_BLACK = 1, - NMC_TERM_COLOR_RED = 2, - NMC_TERM_COLOR_GREEN = 3, - NMC_TERM_COLOR_YELLOW = 4, - NMC_TERM_COLOR_BLUE = 5, - NMC_TERM_COLOR_MAGENTA = 6, - NMC_TERM_COLOR_CYAN = 7, - NMC_TERM_COLOR_WHITE = 8 -} NmcTermColor; - -typedef enum { - NMC_TERM_FORMAT_NORMAL, - NMC_TERM_FORMAT_BOLD, - NMC_TERM_FORMAT_DIM, - NMC_TERM_FORMAT_UNDERLINE, - NMC_TERM_FORMAT_BLINK, - NMC_TERM_FORMAT_REVERSE, - NMC_TERM_FORMAT_HIDDEN, -} NmcTermFormat; - -typedef enum { NMC_PRINT_TERSE = 0, NMC_PRINT_NORMAL = 1, NMC_PRINT_PRETTY = 2 } NMCPrintOutput; /* === Output fields === */ -/* Flags for NmcOutputField */ -#define NMC_OF_FLAG_FIELD_NAMES 0x00000001 /* Print field names instead of values */ -#define NMC_OF_FLAG_SECTION_PREFIX 0x00000002 /* Use the first value as section prefix for the other field names - just in multiline */ -#define NMC_OF_FLAG_MAIN_HEADER_ADD 0x00000004 /* Print main header in addition to values/field names */ -#define NMC_OF_FLAG_MAIN_HEADER_ONLY 0x00000008 /* Print main header only */ - -typedef struct _NmcOutputField { - const char *name; /* Field's name */ - const char *name_l10n; /* Field's name for translation */ + +typedef enum { + NMC_OF_FLAG_FIELD_NAMES = 0x00000001, /* Print field names instead of values */ + NMC_OF_FLAG_SECTION_PREFIX = 0x00000002, /* Use the first value as section prefix for the other field names - just in multiline */ + NMC_OF_FLAG_MAIN_HEADER_ADD = 0x00000004, /* Print main header in addition to values/field names */ + NMC_OF_FLAG_MAIN_HEADER_ONLY = 0x00000008, /* Print main header only */ +} NmcOfFlags; + +extern const NMMetaType nmc_meta_type_generic_info; + +typedef struct _NmcOutputField NmcOutputField; +typedef struct _NmcMetaGenericInfo NmcMetaGenericInfo; + +struct _NmcOutputField { + const NMMetaAbstractInfo *info; int width; /* Width in screen columns */ - struct _NmcOutputField *group; /* Points to an array with available section field names if this is a section (group) field */ void *value; /* Value of current field - char* or char** (NULL-terminated array) */ gboolean value_is_array; /* Whether value is char** instead of char* */ gboolean free_value; /* Whether to free the value */ - guint32 flags; /* Flags - whether and how to print values/field names/headers */ - NmcTermColor color; /* Use this color to print value */ - NmcTermFormat color_fmt; /* Use this terminal format to print value */ -} NmcOutputField; - -typedef struct { - GArray *indices; /* Array of field indices to the array of allowed fields */ - char *header_name; /* Name of the output */ - int indent; /* Indent by this number of spaces */ -} NmcPrintFields; + NmcOfFlags flags; /* Flags - whether and how to print values/field names/headers */ + NMMetaTermColor color; /* Use this color to print value */ + NMMetaTermFormat color_fmt; /* Use this terminal format to print value */ +}; typedef enum { NMC_USE_COLOR_AUTO, @@ -129,12 +110,26 @@ typedef enum { NMC_USE_COLOR_NO, } NmcColorOption; +typedef struct _NmcConfig { + NMCPrintOutput print_output; /* Output mode */ + NmcColorOption use_colors; /* Whether to use colors for output: option '--color' */ + bool multiline_output; /* Multiline output instead of default tabular */ + bool escape_values; /* Whether to escape ':' and '\' in terse tabular mode */ + bool in_editor; /* Whether running the editor - nmcli con edit' */ + bool show_secrets; /* Whether to display secrets (both input and output): option '--show-secrets' */ +} NmcConfig; + +typedef struct _NmcOutputData { + GPtrArray *output_data; /* GPtrArray of arrays of NmcOutputField structs - accumulates data for output */ +} NmcOutputData; + /* NmCli - main structure */ typedef struct _NmCli { NMClient *client; /* Pointer to NMClient of libnm */ NMCResultCode return_value; /* Return code of nmcli */ GString *return_text; /* Reason text */ + pid_t pager_pid; /* PID of a pager, if one was spawned */ int timeout; /* Operation timeout */ @@ -144,22 +139,17 @@ typedef struct _NmCli { int should_wait; /* Semaphore indicating whether nmcli should not end or not yet */ gboolean nowait_flag; /* '--nowait' option; used for passing to callbacks */ - NMCPrintOutput print_output; /* Output mode */ - gboolean multiline_output; /* Multiline output instead of default tabular */ gboolean mode_specified; /* Whether tabular/multiline mode was specified via '--mode' option */ - NmcColorOption use_colors; /* Whether to use colors for output: option '--color' */ - gboolean escape_values; /* Whether to escape ':' and '\' in terse tabular mode */ + union { + const NmcConfig nmc_config; + NmcConfig nmc_config_mutable; + }; char *required_fields; /* Required fields in output: '--fields' option */ - GPtrArray *output_data; /* GPtrArray of arrays of NmcOutputField structs - accumulates data for output */ - NmcPrintFields print_fields; /* Structure with field indices to print */ gboolean ask; /* Ask for missing parameters: option '--ask' */ gboolean complete; /* Autocomplete the command line */ - gboolean show_secrets; /* Whether to display secrets (both input and output): option '--show-secrets' */ - gboolean in_editor; /* Whether running the editor - nmcli con edit' */ gboolean editor_status_line; /* Whether to display status line in connection editor */ gboolean editor_save_confirmation; /* Whether to ask for confirmation on saving connections with 'autoconnect=yes' */ - gboolean editor_show_secrets; /* Whether to display secrets in the editor' */ - NmcTermColor editor_prompt_color; /* Color of prompt in connection editor */ + NMMetaTermColor editor_prompt_color; /* Color of prompt in connection editor */ } NmCli; extern NmCli nm_cli; @@ -168,9 +158,19 @@ extern NmCli nm_cli; #define NMCLI_ERROR (nmcli_error_quark ()) GQuark nmcli_error_quark (void); +extern GMainLoop *loop; + gboolean nmc_seen_sigint (void); void nmc_clear_sigint (void); void nmc_set_sigquit_internal (void); void nmc_exit (void); +void nmc_empty_output_fields (NmcOutputData *output_data); + +#define NMC_OUTPUT_DATA_DEFINE_SCOPED(out) \ + gs_unref_array GArray *out##_indices = NULL; \ + nm_auto (nmc_empty_output_fields) NmcOutputData out = { \ + .output_data = g_ptr_array_new_full (20, g_free), \ + } + #endif /* NMC_NMCLI_H */ |