cli: mark argv argument for command line parsing as const
It's bad style to pass the argv argument around and mutate it. We shouldn't mutate it, and not assume that it stays around after the function returns to the caller (meaning, we should clone the array if we intend to use it later). Add const specifier.
This commit is contained in:
@@ -122,7 +122,7 @@ secrets_requested (NMSecretAgentSimple *agent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_agent_secret (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_agent_secret (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
next_arg (nmc, &argc, &argv, NULL);
|
next_arg (nmc, &argc, &argv, NULL);
|
||||||
if (nmc->complete)
|
if (nmc->complete)
|
||||||
@@ -164,7 +164,7 @@ polkit_error (gpointer instance,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_agent_polkit (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_agent_polkit (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
gs_free_error GError *error = NULL;
|
gs_free_error GError *error = NULL;
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ do_agent_polkit (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_agent_all (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_agent_all (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMCResultCode secret_res;
|
NMCResultCode secret_res;
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ do_agent_all (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NMCResultCode
|
NMCResultCode
|
||||||
nmc_command_func_agent (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
nmc_command_func_agent (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
static const NMCCommand cmds[] = {
|
static const NMCCommand cmds[] = {
|
||||||
{ "secret", do_agent_secret, usage_agent_secret, TRUE, TRUE },
|
{ "secret", do_agent_secret, usage_agent_secret, TRUE, TRUE },
|
||||||
|
@@ -1219,7 +1219,7 @@ typedef struct {
|
|||||||
} CmdCall;
|
} CmdCall;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
call_cmd (NmCli *nmc, GTask *task, const NMCCommand *cmd, int argc, char **argv);
|
call_cmd (NmCli *nmc, GTask *task, const NMCCommand *cmd, int argc, const char *const*argv);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
got_client (GObject *source_object, GAsyncResult *res, gpointer user_data)
|
got_client (GObject *source_object, GAsyncResult *res, gpointer user_data)
|
||||||
@@ -1245,14 +1245,15 @@ got_client (GObject *source_object, GAsyncResult *res, gpointer user_data)
|
|||||||
error->message);
|
error->message);
|
||||||
} else {
|
} else {
|
||||||
nmc->client = NM_CLIENT (source_object);
|
nmc->client = NM_CLIENT (source_object);
|
||||||
call_cmd (nmc, g_steal_pointer (&task), call->cmd, call->argc, call->argv);
|
call_cmd (nmc, g_steal_pointer (&task), call->cmd, call->argc, (const char *const*) call->argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_slice_free (CmdCall, call);
|
g_strfreev (call->argv);
|
||||||
|
nm_g_slice_free (call);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
call_cmd (NmCli *nmc, GTask *task, const NMCCommand *cmd, int argc, char **argv)
|
call_cmd (NmCli *nmc, GTask *task, const NMCCommand *cmd, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
CmdCall *call;
|
CmdCall *call;
|
||||||
|
|
||||||
@@ -1272,11 +1273,13 @@ call_cmd (NmCli *nmc, GTask *task, const NMCCommand *cmd, int argc, char **argv)
|
|||||||
nm_assert (nmc->client == NULL);
|
nm_assert (nmc->client == NULL);
|
||||||
|
|
||||||
nmc->should_wait++;
|
nmc->should_wait++;
|
||||||
call = g_slice_new0 (CmdCall);
|
call = g_slice_new (CmdCall);
|
||||||
call->cmd = cmd;
|
*call = (CmdCall) {
|
||||||
call->argc = argc;
|
.cmd = cmd,
|
||||||
call->argv = argv;
|
.argc = argc,
|
||||||
call->task = task;
|
.argv = nm_utils_strv_dup ((char **) argv, argc, TRUE),
|
||||||
|
.task = task,
|
||||||
|
};
|
||||||
nmc_client_new_async (NULL,
|
nmc_client_new_async (NULL,
|
||||||
got_client,
|
got_client,
|
||||||
call,
|
call,
|
||||||
@@ -1313,7 +1316,7 @@ nmc_complete_help (const char *prefix)
|
|||||||
* no callback to free the memory in (for simplicity).
|
* no callback to free the memory in (for simplicity).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
nmc_do_cmd (NmCli *nmc, const NMCCommand cmds[], const char *cmd, int argc, char **argv)
|
nmc_do_cmd (NmCli *nmc, const NMCCommand cmds[], const char *cmd, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
const NMCCommand *c;
|
const NMCCommand *c;
|
||||||
gs_unref_object GTask *task = NULL;
|
gs_unref_object GTask *task = NULL;
|
||||||
@@ -1349,7 +1352,7 @@ nmc_do_cmd (NmCli *nmc, const NMCCommand cmds[], const char *cmd, int argc, char
|
|||||||
c->usage ();
|
c->usage ();
|
||||||
g_task_return_boolean (task, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
} else {
|
} else {
|
||||||
call_cmd (nmc, g_steal_pointer (&task), c, argc, argv);
|
call_cmd (nmc, g_steal_pointer (&task), c, argc, (const char *const*) argv);
|
||||||
}
|
}
|
||||||
} else if (cmd) {
|
} else if (cmd) {
|
||||||
/* Not a known command. */
|
/* Not a known command. */
|
||||||
@@ -1362,7 +1365,7 @@ nmc_do_cmd (NmCli *nmc, const NMCCommand cmds[], const char *cmd, int argc, char
|
|||||||
}
|
}
|
||||||
} else if (c->func) {
|
} else if (c->func) {
|
||||||
/* No command, run the default handler. */
|
/* No command, run the default handler. */
|
||||||
call_cmd (nmc, g_steal_pointer (&task), c, argc, argv);
|
call_cmd (nmc, g_steal_pointer (&task), c, argc, (const char *const*) argv);
|
||||||
} else {
|
} else {
|
||||||
/* No command and no default handler. */
|
/* No command and no default handler. */
|
||||||
g_task_return_new_error (task, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,
|
g_task_return_new_error (task, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,
|
||||||
|
@@ -62,7 +62,7 @@ int nmc_rl_set_deftext (void);
|
|||||||
|
|
||||||
char *nmc_parse_lldp_capabilities (guint value);
|
char *nmc_parse_lldp_capabilities (guint value);
|
||||||
|
|
||||||
void nmc_do_cmd (NmCli *nmc, const NMCCommand cmds[], const char *cmd, int argc, char **argv);
|
void nmc_do_cmd (NmCli *nmc, const NMCCommand cmds[], const char *cmd, int argc, const char *const*argv);
|
||||||
|
|
||||||
void nmc_complete_strv (const char *prefix, gssize nargs, const char *const*args);
|
void nmc_complete_strv (const char *prefix, gssize nargs, const char *const*args);
|
||||||
|
|
||||||
|
@@ -1976,7 +1976,7 @@ parse_preferred_connection_order (const char *order, GError **error)
|
|||||||
static NMConnection *
|
static NMConnection *
|
||||||
get_connection (NmCli *nmc,
|
get_connection (NmCli *nmc,
|
||||||
int *argc,
|
int *argc,
|
||||||
char ***argv,
|
const char *const**argv,
|
||||||
const char **out_selector,
|
const char **out_selector,
|
||||||
const char **out_value,
|
const char **out_value,
|
||||||
GPtrArray **out_result,
|
GPtrArray **out_result,
|
||||||
@@ -2028,7 +2028,7 @@ get_connection (NmCli *nmc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_connections_show (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_connections_show (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
gs_free_error GError *err = NULL;
|
gs_free_error GError *err = NULL;
|
||||||
gs_free char *profile_flds = NULL;
|
gs_free char *profile_flds = NULL;
|
||||||
@@ -2134,7 +2134,7 @@ do_connections_show (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
* option after the connection ids */
|
* option after the connection ids */
|
||||||
if (!nmc->nmc_config.show_secrets && !nmc->complete) {
|
if (!nmc->nmc_config.show_secrets && !nmc->complete) {
|
||||||
int argc_cp = argc;
|
int argc_cp = argc;
|
||||||
char **argv_cp = argv;
|
const char *const*argv_cp = argv;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (NM_IN_STRSET (*argv_cp, "id", "uuid", "path", "filename", "apath")) {
|
if (NM_IN_STRSET (*argv_cp, "id", "uuid", "path", "filename", "apath")) {
|
||||||
@@ -2855,7 +2855,7 @@ nmc_activate_connection (NmCli *nmc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_connection_up (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_connection_up (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMConnection *connection = NULL;
|
NMConnection *connection = NULL;
|
||||||
const char *ifname = NULL;
|
const char *ifname = NULL;
|
||||||
@@ -2863,9 +2863,9 @@ do_connection_up (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
const char *nsp = NULL;
|
const char *nsp = NULL;
|
||||||
const char *pwds = NULL;
|
const char *pwds = NULL;
|
||||||
gs_free_error GError *error = NULL;
|
gs_free_error GError *error = NULL;
|
||||||
char **arg_arr = NULL;
|
gs_strfreev char **arg_arr = NULL;
|
||||||
int arg_num;
|
int arg_num;
|
||||||
char ***argv_ptr;
|
const char *const**argv_ptr;
|
||||||
int *argc_ptr;
|
int *argc_ptr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2888,7 +2888,7 @@ do_connection_up (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
line = nmc_readline (&nmc->nmc_config,
|
line = nmc_readline (&nmc->nmc_config,
|
||||||
PROMPT_CONNECTION);
|
PROMPT_CONNECTION);
|
||||||
nmc_string_to_arg_array (line, NULL, TRUE, &arg_arr, &arg_num);
|
nmc_string_to_arg_array (line, NULL, TRUE, &arg_arr, &arg_num);
|
||||||
argv_ptr = &arg_arr;
|
argv_ptr = (const char *const**) &arg_arr;
|
||||||
argc_ptr = &arg_num;
|
argc_ptr = &arg_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3113,13 +3113,13 @@ connection_op_timeout_cb (gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_connection_down (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_connection_down (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMActiveConnection *active;
|
NMActiveConnection *active;
|
||||||
ConnectionCbInfo *info = NULL;
|
ConnectionCbInfo *info = NULL;
|
||||||
const GPtrArray *active_cons;
|
const GPtrArray *active_cons;
|
||||||
gs_strfreev char **arg_arr = NULL;
|
gs_strfreev char **arg_arr = NULL;
|
||||||
char **arg_ptr;
|
const char *const*arg_ptr;
|
||||||
int arg_num;
|
int arg_num;
|
||||||
guint i;
|
guint i;
|
||||||
gs_unref_ptrarray GPtrArray *found_active_cons = NULL;
|
gs_unref_ptrarray GPtrArray *found_active_cons = NULL;
|
||||||
@@ -3141,7 +3141,7 @@ do_connection_down (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
line = nmc_readline (&nmc->nmc_config,
|
line = nmc_readline (&nmc->nmc_config,
|
||||||
PROMPT_ACTIVE_CONNECTIONS);
|
PROMPT_ACTIVE_CONNECTIONS);
|
||||||
nmc_string_to_arg_array (line, NULL, TRUE, &arg_arr, &arg_num);
|
nmc_string_to_arg_array (line, NULL, TRUE, &arg_arr, &arg_num);
|
||||||
arg_ptr = arg_arr;
|
arg_ptr = (const char *const*) arg_arr;
|
||||||
}
|
}
|
||||||
if (arg_num == 0) {
|
if (arg_num == 0) {
|
||||||
g_string_printf (nmc->return_text, _("Error: No connection specified."));
|
g_string_printf (nmc->return_text, _("Error: No connection specified."));
|
||||||
@@ -3715,7 +3715,7 @@ prompt_yes_no (gboolean default_yes, char *delim)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMSetting *
|
static NMSetting *
|
||||||
is_setting_valid (NMConnection *connection, const NMMetaSettingValidPartItem *const*valid_settings_main, const NMMetaSettingValidPartItem *const*valid_settings_slave, char *setting)
|
is_setting_valid (NMConnection *connection, const NMMetaSettingValidPartItem *const*valid_settings_main, const NMMetaSettingValidPartItem *const*valid_settings_slave, const char *setting)
|
||||||
{
|
{
|
||||||
const char *setting_name;
|
const char *setting_name;
|
||||||
|
|
||||||
@@ -4726,7 +4726,7 @@ connection_remove_setting (NMConnection *connection, NMSetting *setting, GError
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
get_value (const char **value, int *argc, char ***argv, const char *option, GError **error)
|
get_value (const char **value, int *argc, const char *const**argv, const char *option, GError **error)
|
||||||
{
|
{
|
||||||
if (!**argv) {
|
if (!**argv) {
|
||||||
g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,
|
g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,
|
||||||
@@ -4749,7 +4749,7 @@ gboolean
|
|||||||
nmc_process_connection_properties (NmCli *nmc,
|
nmc_process_connection_properties (NmCli *nmc,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
int *argc,
|
int *argc,
|
||||||
char ***argv,
|
const char *const**argv,
|
||||||
gboolean allow_setting_removal,
|
gboolean allow_setting_removal,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@@ -4789,7 +4789,7 @@ nmc_process_connection_properties (NmCli *nmc,
|
|||||||
&& modifier == NM_META_ACCESSOR_MODIFIER_SET
|
&& modifier == NM_META_ACCESSOR_MODIFIER_SET
|
||||||
&& nm_streq (option, "remove")) {
|
&& nm_streq (option, "remove")) {
|
||||||
NMSetting *ss;
|
NMSetting *ss;
|
||||||
char *setting_name;
|
const char *setting_name;
|
||||||
|
|
||||||
(*argc)--;
|
(*argc)--;
|
||||||
(*argv)++;
|
(*argv)++;
|
||||||
@@ -5349,7 +5349,7 @@ again:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_connection_add (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_connection_add (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
gs_unref_object NMConnection *connection = NULL;
|
gs_unref_object NMConnection *connection = NULL;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
@@ -8355,7 +8355,7 @@ nmc_complete_connection_type (const char *prefix)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_connection_edit (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_connection_edit (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
const GPtrArray *connections;
|
const GPtrArray *connections;
|
||||||
gs_unref_object NMConnection *connection = NULL;
|
gs_unref_object NMConnection *connection = NULL;
|
||||||
@@ -8574,7 +8574,7 @@ modify_connection_cb (GObject *connection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_connection_modify (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_connection_modify (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMConnection *connection = NULL;
|
NMConnection *connection = NULL;
|
||||||
NMRemoteConnection *rc = NULL;
|
NMRemoteConnection *rc = NULL;
|
||||||
@@ -8642,7 +8642,7 @@ clone_connection_cb (GObject *client,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_connection_clone (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_connection_clone (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMConnection *connection = NULL;
|
NMConnection *connection = NULL;
|
||||||
gs_unref_object NMConnection *new_connection = NULL;
|
gs_unref_object NMConnection *new_connection = NULL;
|
||||||
@@ -8650,9 +8650,9 @@ do_connection_clone (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
gs_free char *new_name_free = NULL;
|
gs_free char *new_name_free = NULL;
|
||||||
gs_free char *uuid = NULL;
|
gs_free char *uuid = NULL;
|
||||||
gboolean temporary = FALSE;
|
gboolean temporary = FALSE;
|
||||||
char **arg_arr = NULL;
|
gs_strfreev char **arg_arr = NULL;
|
||||||
int arg_num;
|
int arg_num;
|
||||||
char ***argv_ptr;
|
const char *const**argv_ptr;
|
||||||
int *argc_ptr;
|
int *argc_ptr;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
@@ -8673,7 +8673,7 @@ do_connection_clone (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
line = nmc_readline (&nmc->nmc_config,
|
line = nmc_readline (&nmc->nmc_config,
|
||||||
PROMPT_CONNECTION);
|
PROMPT_CONNECTION);
|
||||||
nmc_string_to_arg_array (line, NULL, TRUE, &arg_arr, &arg_num);
|
nmc_string_to_arg_array (line, NULL, TRUE, &arg_arr, &arg_num);
|
||||||
argv_ptr = &arg_arr;
|
argv_ptr = (const char *const**) &arg_arr;
|
||||||
argc_ptr = &arg_num;
|
argc_ptr = &arg_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8743,12 +8743,12 @@ delete_cb (GObject *con, GAsyncResult *result, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_connection_delete (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_connection_delete (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
ConnectionCbInfo *info = NULL;
|
ConnectionCbInfo *info = NULL;
|
||||||
gs_strfreev char **arg_arr = NULL;
|
gs_strfreev char **arg_arr = NULL;
|
||||||
char **arg_ptr;
|
const char *const*arg_ptr;
|
||||||
guint i;
|
guint i;
|
||||||
int arg_num;
|
int arg_num;
|
||||||
nm_auto_free_gstring GString *invalid_cons = NULL;
|
nm_auto_free_gstring GString *invalid_cons = NULL;
|
||||||
@@ -8772,7 +8772,7 @@ do_connection_delete (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
line = nmc_readline (&nmc->nmc_config,
|
line = nmc_readline (&nmc->nmc_config,
|
||||||
PROMPT_CONNECTIONS);
|
PROMPT_CONNECTIONS);
|
||||||
nmc_string_to_arg_array (line, NULL, TRUE, &arg_arr, &arg_num);
|
nmc_string_to_arg_array (line, NULL, TRUE, &arg_arr, &arg_num);
|
||||||
arg_ptr = arg_arr;
|
arg_ptr = (const char *const*) arg_arr;
|
||||||
}
|
}
|
||||||
if (arg_num == 0) {
|
if (arg_num == 0) {
|
||||||
g_string_printf (nmc->return_text, _("Error: No connection specified."));
|
g_string_printf (nmc->return_text, _("Error: No connection specified."));
|
||||||
@@ -8889,7 +8889,7 @@ connection_removed (NMClient *client, NMRemoteConnection *con, NmCli *nmc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_connection_monitor (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_connection_monitor (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
guint i;
|
guint i;
|
||||||
@@ -8938,7 +8938,7 @@ do_connection_monitor (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_connection_reload (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_connection_reload (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
gs_unref_variant GVariant *result = NULL;
|
gs_unref_variant GVariant *result = NULL;
|
||||||
gs_free_error GError *error = NULL;
|
gs_free_error GError *error = NULL;
|
||||||
@@ -8964,10 +8964,11 @@ do_connection_reload (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_connection_load (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_connection_load (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
char **filenames, **failures = NULL;
|
gs_free const char **filenames = NULL;
|
||||||
|
gs_strfreev char **failures = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
next_arg (nmc, &argc, &argv, NULL);
|
next_arg (nmc, &argc, &argv, NULL);
|
||||||
@@ -8979,13 +8980,9 @@ do_connection_load (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
if (nmc->complete)
|
if (nmc->complete)
|
||||||
return NMC_RESULT_COMPLETE_FILE;
|
return NMC_RESULT_COMPLETE_FILE;
|
||||||
|
|
||||||
filenames = g_new (char *, argc + 1);
|
filenames = (const char **) nm_utils_strv_dup ((char **) argv, argc, FALSE);
|
||||||
for (i = 0; i < argc; i++)
|
|
||||||
filenames[i] = argv[i];
|
|
||||||
filenames[i] = NULL;
|
|
||||||
|
|
||||||
nm_client_load_connections (nmc->client, filenames, &failures, NULL, &error);
|
nm_client_load_connections (nmc->client, (char **) filenames, &failures, NULL, &error);
|
||||||
g_free (filenames);
|
|
||||||
if (error) {
|
if (error) {
|
||||||
g_string_printf (nmc->return_text, _("Error: failed to load connection: %s."),
|
g_string_printf (nmc->return_text, _("Error: failed to load connection: %s."),
|
||||||
nmc_error_get_simple_message (error));
|
nmc_error_get_simple_message (error));
|
||||||
@@ -8996,7 +8993,6 @@ do_connection_load (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
if (failures) {
|
if (failures) {
|
||||||
for (i = 0; failures[i]; i++)
|
for (i = 0; failures[i]; i++)
|
||||||
g_printerr (_("Could not load file '%s'\n"), failures[i]);
|
g_printerr (_("Could not load file '%s'\n"), failures[i]);
|
||||||
g_strfreev (failures);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nmc->return_value;
|
return nmc->return_value;
|
||||||
@@ -9005,7 +9001,7 @@ do_connection_load (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
#define PROMPT_IMPORT_FILE N_("File to import: ")
|
#define PROMPT_IMPORT_FILE N_("File to import: ")
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_connection_import (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_connection_import (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
gs_free_error GError *error = NULL;
|
gs_free_error GError *error = NULL;
|
||||||
const char *type = NULL, *filename = NULL;
|
const char *type = NULL, *filename = NULL;
|
||||||
@@ -9138,7 +9134,7 @@ do_connection_import (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_connection_export (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_connection_export (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMConnection *connection = NULL;
|
NMConnection *connection = NULL;
|
||||||
const char *out_name = NULL;
|
const char *out_name = NULL;
|
||||||
@@ -9148,9 +9144,9 @@ do_connection_export (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
NMVpnEditorPlugin *plugin;
|
NMVpnEditorPlugin *plugin;
|
||||||
gs_free_error GError *error = NULL;
|
gs_free_error GError *error = NULL;
|
||||||
char tmpfile[] = "/tmp/nmcli-export-temp-XXXXXX";
|
char tmpfile[] = "/tmp/nmcli-export-temp-XXXXXX";
|
||||||
char **arg_arr = NULL;
|
gs_strfreev char **arg_arr = NULL;
|
||||||
int arg_num;
|
int arg_num;
|
||||||
char ***argv_ptr;
|
const char *const**argv_ptr;
|
||||||
int *argc_ptr;
|
int *argc_ptr;
|
||||||
|
|
||||||
next_arg (nmc, &argc, &argv, NULL);
|
next_arg (nmc, &argc, &argv, NULL);
|
||||||
@@ -9166,7 +9162,7 @@ do_connection_export (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
line = nmc_readline (&nmc->nmc_config,
|
line = nmc_readline (&nmc->nmc_config,
|
||||||
PROMPT_VPN_CONNECTION);
|
PROMPT_VPN_CONNECTION);
|
||||||
nmc_string_to_arg_array (line, NULL, TRUE, &arg_arr, &arg_num);
|
nmc_string_to_arg_array (line, NULL, TRUE, &arg_arr, &arg_num);
|
||||||
argv_ptr = &arg_arr;
|
argv_ptr = (const char *const**) &arg_arr;
|
||||||
argc_ptr = &arg_num;
|
argc_ptr = &arg_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9341,7 +9337,7 @@ nmcli_con_tab_completion (const char *text, int start, int end)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NMCResultCode
|
NMCResultCode
|
||||||
nmc_command_func_connection (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
nmc_command_func_connection (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
static const NMCCommand cmds[] = {
|
static const NMCCommand cmds[] = {
|
||||||
{ "show", do_connections_show, usage_connection_show, TRUE, TRUE },
|
{ "show", do_connections_show, usage_connection_show, TRUE, TRUE },
|
||||||
|
@@ -14,7 +14,7 @@ gboolean
|
|||||||
nmc_process_connection_properties (NmCli *nmc,
|
nmc_process_connection_properties (NmCli *nmc,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
int *argc,
|
int *argc,
|
||||||
char ***argv,
|
const char *const**argv,
|
||||||
gboolean allow_remove_setting,
|
gboolean allow_remove_setting,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
@@ -996,11 +996,11 @@ nmc_complete_device (NMClient *client, const char *prefix, gboolean wifi_only)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GSList *
|
static GSList *
|
||||||
get_device_list (NmCli *nmc, int argc, char **argv)
|
get_device_list (NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
int arg_num = argc;
|
int arg_num = argc;
|
||||||
char **arg_arr = NULL;
|
gs_strfreev char **arg_arr = NULL;
|
||||||
char **arg_ptr = argv;
|
const char *const*arg_ptr = argv;
|
||||||
NMDevice **devices;
|
NMDevice **devices;
|
||||||
GSList *queue = NULL;
|
GSList *queue = NULL;
|
||||||
NMDevice *device;
|
NMDevice *device;
|
||||||
@@ -1013,7 +1013,7 @@ get_device_list (NmCli *nmc, int argc, char **argv)
|
|||||||
line = nmc_readline (&nmc->nmc_config,
|
line = nmc_readline (&nmc->nmc_config,
|
||||||
PROMPT_INTERFACES);
|
PROMPT_INTERFACES);
|
||||||
nmc_string_to_arg_array (line, NULL, FALSE, &arg_arr, &arg_num);
|
nmc_string_to_arg_array (line, NULL, FALSE, &arg_arr, &arg_num);
|
||||||
arg_ptr = arg_arr;
|
arg_ptr = (const char *const*) arg_arr;
|
||||||
}
|
}
|
||||||
if (arg_num == 0) {
|
if (arg_num == 0) {
|
||||||
g_string_printf (nmc->return_text, _("Error: No interface specified."));
|
g_string_printf (nmc->return_text, _("Error: No interface specified."));
|
||||||
@@ -1059,7 +1059,7 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMDevice *
|
static NMDevice *
|
||||||
get_device (NmCli *nmc, int *argc, char ***argv, GError **error)
|
get_device (NmCli *nmc, int *argc, const char *const**argv, GError **error)
|
||||||
{
|
{
|
||||||
gs_free NMDevice **devices = NULL;
|
gs_free NMDevice **devices = NULL;
|
||||||
gs_free char *ifname_ask = NULL;
|
gs_free char *ifname_ask = NULL;
|
||||||
@@ -1729,7 +1729,7 @@ nmc_device_state_to_color (NMDeviceState state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_devices_status (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_devices_status (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gs_free NMDevice **devices = NULL;
|
gs_free NMDevice **devices = NULL;
|
||||||
@@ -1769,7 +1769,7 @@ do_devices_status (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_device_show (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_device_show (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
gs_free_error GError *error = NULL;
|
gs_free_error GError *error = NULL;
|
||||||
|
|
||||||
@@ -2037,7 +2037,7 @@ connect_device_cb (GObject *client, GAsyncResult *result, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_device_connect (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_device_connect (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMDevice *device = NULL;
|
NMDevice *device = NULL;
|
||||||
AddAndActivateInfo *info;
|
AddAndActivateInfo *info;
|
||||||
@@ -2207,7 +2207,7 @@ reapply_device_cb (GObject *object, GAsyncResult *result, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_device_reapply (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_device_reapply (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMDevice *device;
|
NMDevice *device;
|
||||||
DeviceCbInfo *info = NULL;
|
DeviceCbInfo *info = NULL;
|
||||||
@@ -2288,6 +2288,8 @@ modify_get_applied_cb (GObject *object,
|
|||||||
gs_free_error GError *error = NULL;
|
gs_free_error GError *error = NULL;
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
guint64 version_id;
|
guint64 version_id;
|
||||||
|
int argc;
|
||||||
|
const char *const*argv;
|
||||||
|
|
||||||
connection = nm_device_get_applied_connection_finish (device,
|
connection = nm_device_get_applied_connection_finish (device,
|
||||||
result,
|
result,
|
||||||
@@ -2304,7 +2306,10 @@ modify_get_applied_cb (GObject *object,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nmc_process_connection_properties (info->nmc, connection, &info->argc, &info->argv, TRUE, &error)) {
|
argc = info->argc;
|
||||||
|
argv = (const char *const*) info->argv;
|
||||||
|
|
||||||
|
if (!nmc_process_connection_properties (info->nmc, connection, &argc, &argv, TRUE, &error)) {
|
||||||
g_string_assign (nmc->return_text, error->message);
|
g_string_assign (nmc->return_text, error->message);
|
||||||
nmc->return_value = error->code;
|
nmc->return_value = error->code;
|
||||||
g_slice_free (ModifyInfo, info);
|
g_slice_free (ModifyInfo, info);
|
||||||
@@ -2319,7 +2324,7 @@ modify_get_applied_cb (GObject *object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_device_modify (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_device_modify (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMDevice *device = NULL;
|
NMDevice *device = NULL;
|
||||||
ModifyInfo *info = NULL;
|
ModifyInfo *info = NULL;
|
||||||
@@ -2341,7 +2346,7 @@ do_device_modify (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
info = g_slice_new0 (ModifyInfo);
|
info = g_slice_new0 (ModifyInfo);
|
||||||
info->nmc = nmc;
|
info->nmc = nmc;
|
||||||
info->argc = argc;
|
info->argc = argc;
|
||||||
info->argv = argv;
|
info->argv = nm_utils_strv_dup ((char **) argv, argc, TRUE);
|
||||||
|
|
||||||
nm_device_get_applied_connection_async (device, 0, NULL, modify_get_applied_cb, info);
|
nm_device_get_applied_connection_async (device, 0, NULL, modify_get_applied_cb, info);
|
||||||
|
|
||||||
@@ -2386,7 +2391,7 @@ disconnect_device_cb (GObject *object, GAsyncResult *result, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_devices_disconnect (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_devices_disconnect (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMDevice *device;
|
NMDevice *device;
|
||||||
DeviceCbInfo *info = NULL;
|
DeviceCbInfo *info = NULL;
|
||||||
@@ -2458,7 +2463,7 @@ delete_device_cb (GObject *object, GAsyncResult *result, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_devices_delete (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_devices_delete (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMDevice *device;
|
NMDevice *device;
|
||||||
DeviceCbInfo *info = NULL;
|
DeviceCbInfo *info = NULL;
|
||||||
@@ -2499,7 +2504,7 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_device_set (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_device_set (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
#define DEV_SET_AUTOCONNECT 0
|
#define DEV_SET_AUTOCONNECT 0
|
||||||
#define DEV_SET_MANAGED 1
|
#define DEV_SET_MANAGED 1
|
||||||
@@ -2658,7 +2663,7 @@ device_removed (NMClient *client, NMDevice *device, NmCli *nmc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_devices_monitor (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_devices_monitor (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
if (nmc->complete)
|
if (nmc->complete)
|
||||||
return nmc->return_value;
|
return nmc->return_value;
|
||||||
@@ -2902,7 +2907,7 @@ typedef struct {
|
|||||||
NmCli *nmc;
|
NmCli *nmc;
|
||||||
NMDevice **devices;
|
NMDevice **devices;
|
||||||
const NMMetaAbstractInfo *const *tmpl;
|
const NMMetaAbstractInfo *const *tmpl;
|
||||||
const char *bssid_user;
|
char *bssid_user;
|
||||||
GArray *out_indices;
|
GArray *out_indices;
|
||||||
gint64 rescan_cutoff_msec;
|
gint64 rescan_cutoff_msec;
|
||||||
guint pending;
|
guint pending;
|
||||||
@@ -2959,6 +2964,7 @@ wifi_list_finish (WifiListData *wifi_list_data,
|
|||||||
g_object_unref (scan_info->devices[i]);
|
g_object_unref (scan_info->devices[i]);
|
||||||
g_free (scan_info->devices);
|
g_free (scan_info->devices);
|
||||||
g_array_unref (scan_info->out_indices);
|
g_array_unref (scan_info->out_indices);
|
||||||
|
g_free (scan_info->bssid_user);
|
||||||
nm_g_slice_free (scan_info);
|
nm_g_slice_free (scan_info);
|
||||||
|
|
||||||
nmc->should_wait--;
|
nmc->should_wait--;
|
||||||
@@ -3028,7 +3034,7 @@ nmc_complete_bssid (NMClient *client, const char *ifname, const char *bssid_pref
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_device_wifi_list (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_device_wifi_list (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
NMDevice *device = NULL;
|
NMDevice *device = NULL;
|
||||||
@@ -3187,7 +3193,7 @@ do_device_wifi_list (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
*scan_info = (ScanInfo) {
|
*scan_info = (ScanInfo) {
|
||||||
.out_indices = g_array_ref (out_indices),
|
.out_indices = g_array_ref (out_indices),
|
||||||
.tmpl = tmpl,
|
.tmpl = tmpl,
|
||||||
.bssid_user = bssid_user,
|
.bssid_user = g_strdup (bssid_user),
|
||||||
.nmc = nmc,
|
.nmc = nmc,
|
||||||
.rescan_cutoff_msec = rescan_cutoff_msec,
|
.rescan_cutoff_msec = rescan_cutoff_msec,
|
||||||
};
|
};
|
||||||
@@ -3294,7 +3300,7 @@ save_and_activate_connection (NmCli *nmc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_device_wifi_connect (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_device_wifi_connect (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMDevice *device = NULL;
|
NMDevice *device = NULL;
|
||||||
NMAccessPoint *ap = NULL;
|
NMAccessPoint *ap = NULL;
|
||||||
@@ -3935,7 +3941,7 @@ create_hotspot_conn (const GPtrArray *connections,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_device_wifi_hotspot (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_device_wifi_hotspot (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
const char *ifname = NULL;
|
const char *ifname = NULL;
|
||||||
const char *con_name = NULL;
|
const char *con_name = NULL;
|
||||||
@@ -4138,15 +4144,14 @@ request_rescan_cb (GObject *object, GAsyncResult *result, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_device_wifi_rescan (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_device_wifi_rescan (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMDevice *device;
|
NMDevice *device;
|
||||||
const char *ifname = NULL;
|
const char *ifname = NULL;
|
||||||
GPtrArray *ssids;
|
gs_unref_ptrarray GPtrArray *ssids = NULL;
|
||||||
gs_free NMDevice **devices = NULL;
|
gs_free NMDevice **devices = NULL;
|
||||||
GVariantBuilder builder, array_builder;
|
GVariantBuilder builder, array_builder;
|
||||||
GVariant *options;
|
GVariant *options;
|
||||||
const char *ssid;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ssids = g_ptr_array_new ();
|
ssids = g_ptr_array_new ();
|
||||||
@@ -4182,7 +4187,7 @@ do_device_wifi_rescan (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
g_ptr_array_add (ssids, *argv);
|
g_ptr_array_add (ssids, (gpointer) *argv);
|
||||||
} else if (!nmc->complete) {
|
} else if (!nmc->complete) {
|
||||||
g_string_printf (nmc->return_text, _("Error: invalid extra argument '%s'."), *argv);
|
g_string_printf (nmc->return_text, _("Error: invalid extra argument '%s'."), *argv);
|
||||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||||
@@ -4212,7 +4217,8 @@ do_device_wifi_rescan (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("aay"));
|
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("aay"));
|
||||||
|
|
||||||
for (i = 0; i < ssids->len; i++) {
|
for (i = 0; i < ssids->len; i++) {
|
||||||
ssid = g_ptr_array_index (ssids, i);
|
const char *ssid = g_ptr_array_index (ssids, i);
|
||||||
|
|
||||||
g_variant_builder_add (&array_builder, "@ay",
|
g_variant_builder_add (&array_builder, "@ay",
|
||||||
g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, ssid, strlen (ssid), 1));
|
g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, ssid, strlen (ssid), 1));
|
||||||
}
|
}
|
||||||
@@ -4228,7 +4234,6 @@ do_device_wifi_rescan (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
|
|
||||||
nmc->should_wait++;
|
nmc->should_wait++;
|
||||||
finish:
|
finish:
|
||||||
g_ptr_array_free (ssids, FALSE);
|
|
||||||
return nmc->return_value;
|
return nmc->return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4369,7 +4374,7 @@ wifi_show_device (const NmcConfig *nmc_config, NMDevice *device, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_device_wifi_show_password (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_device_wifi_show_password (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
const char *ifname = NULL;
|
const char *ifname = NULL;
|
||||||
gs_free NMDevice **devices = NULL;
|
gs_free NMDevice **devices = NULL;
|
||||||
@@ -4453,7 +4458,7 @@ static NMCCommand device_wifi_cmds[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_device_wifi (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_device_wifi (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
next_arg (nmc, &argc, &argv, NULL);
|
next_arg (nmc, &argc, &argv, NULL);
|
||||||
nmc_do_cmd (nmc, device_wifi_cmds, *argv, argc, argv);
|
nmc_do_cmd (nmc, device_wifi_cmds, *argv, argc, argv);
|
||||||
@@ -4547,7 +4552,7 @@ show_device_lldp_list (NMDevice *device, NmCli *nmc, const char *fields_str, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_device_lldp_list (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_device_lldp_list (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMDevice *device = NULL;
|
NMDevice *device = NULL;
|
||||||
gs_free_error GError *error = NULL;
|
gs_free_error GError *error = NULL;
|
||||||
@@ -4618,7 +4623,7 @@ static NMCCommand device_lldp_cmds[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_device_lldp (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_device_lldp (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
if (!nmc->mode_specified)
|
if (!nmc->mode_specified)
|
||||||
nmc->nmc_config_mutable.multiline_output = TRUE; /* multiline mode is default for 'device lldp' */
|
nmc->nmc_config_mutable.multiline_output = TRUE; /* multiline mode is default for 'device lldp' */
|
||||||
@@ -4672,7 +4677,7 @@ nmcli_device_tab_completion (const char *text, int start, int end)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NMCResultCode
|
NMCResultCode
|
||||||
nmc_command_func_device (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
nmc_command_func_device (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
static const NMCCommand cmds[] = {
|
static const NMCCommand cmds[] = {
|
||||||
{ "status", do_devices_status, usage_device_status, TRUE, TRUE },
|
{ "status", do_devices_status, usage_device_status, TRUE, TRUE },
|
||||||
|
@@ -490,7 +490,7 @@ show_nm_status (NmCli *nmc, const char *pretty_header_name, const char *print_fl
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_general_status (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_general_status (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
next_arg (nmc, &argc, &argv, NULL);
|
next_arg (nmc, &argc, &argv, NULL);
|
||||||
if (nmc->complete)
|
if (nmc->complete)
|
||||||
@@ -609,7 +609,7 @@ show_nm_permissions (NmCli *nmc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_general_reload (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_general_reload (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
gs_unref_variant GVariant *result = NULL;
|
gs_unref_variant GVariant *result = NULL;
|
||||||
gs_free_error GError *error = NULL;
|
gs_free_error GError *error = NULL;
|
||||||
@@ -673,7 +673,7 @@ do_general_reload (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_general_permissions (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_general_permissions (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
next_arg (nmc, &argc, &argv, NULL);
|
next_arg (nmc, &argc, &argv, NULL);
|
||||||
if (nmc->complete)
|
if (nmc->complete)
|
||||||
@@ -747,7 +747,7 @@ _set_logging_cb (GObject *object, GAsyncResult *result, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_general_logging (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_general_logging (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
next_arg (nmc, &argc, &argv, NULL);
|
next_arg (nmc, &argc, &argv, NULL);
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
@@ -837,7 +837,7 @@ save_hostname_cb (GObject *object, GAsyncResult *result, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_general_hostname (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_general_hostname (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
next_arg (nmc, &argc, &argv, NULL);
|
next_arg (nmc, &argc, &argv, NULL);
|
||||||
if (nmc->complete)
|
if (nmc->complete)
|
||||||
@@ -867,7 +867,7 @@ do_general_hostname (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NMCResultCode
|
NMCResultCode
|
||||||
nmc_command_func_general (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
nmc_command_func_general (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
static const NMCCommand cmds[] = {
|
static const NMCCommand cmds[] = {
|
||||||
{ "status", do_general_status, usage_general_status, TRUE, TRUE },
|
{ "status", do_general_status, usage_general_status, TRUE, TRUE },
|
||||||
@@ -950,7 +950,7 @@ _do_networking_on_off_cb (GObject *object, GAsyncResult *result, gpointer user_d
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_networking_on_off (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_networking_on_off (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
gboolean enable = nm_streq (cmd->cmd, "on");
|
gboolean enable = nm_streq (cmd->cmd, "on");
|
||||||
|
|
||||||
@@ -977,7 +977,7 @@ do_networking_on_off (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_networking_connectivity (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_networking_connectivity (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
next_arg (nmc, &argc, &argv, NULL);
|
next_arg (nmc, &argc, &argv, NULL);
|
||||||
if (nmc->complete) {
|
if (nmc->complete) {
|
||||||
@@ -1011,7 +1011,7 @@ do_networking_connectivity (const NMCCommand *cmd, NmCli *nmc, int argc, char **
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_networking_show (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_networking_show (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
next_arg (nmc, &argc, &argv, NULL);
|
next_arg (nmc, &argc, &argv, NULL);
|
||||||
if (nmc->complete)
|
if (nmc->complete)
|
||||||
@@ -1023,7 +1023,7 @@ do_networking_show (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NMCResultCode
|
NMCResultCode
|
||||||
nmc_command_func_networking (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
nmc_command_func_networking (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
static const NMCCommand cmds[] = {
|
static const NMCCommand cmds[] = {
|
||||||
{ "on", do_networking_on_off, usage_networking_on, TRUE, TRUE },
|
{ "on", do_networking_on_off, usage_networking_on, TRUE, TRUE },
|
||||||
@@ -1038,7 +1038,7 @@ nmc_command_func_networking (const NMCCommand *cmd, NmCli *nmc, int argc, char *
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_radio_all (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_radio_all (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
gboolean enable_flag;
|
gboolean enable_flag;
|
||||||
|
|
||||||
@@ -1083,7 +1083,7 @@ _do_radio_wifi_cb (GObject *object, GAsyncResult *result, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_radio_wifi (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_radio_wifi (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
gboolean enable_flag;
|
gboolean enable_flag;
|
||||||
|
|
||||||
@@ -1121,7 +1121,7 @@ do_radio_wifi (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_radio_wwan (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
do_radio_wwan (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
gboolean enable_flag;
|
gboolean enable_flag;
|
||||||
|
|
||||||
@@ -1148,7 +1148,7 @@ do_radio_wwan (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NMCResultCode
|
NMCResultCode
|
||||||
nmc_command_func_radio (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
nmc_command_func_radio (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
static const NMCCommand cmds[] = {
|
static const NMCCommand cmds[] = {
|
||||||
{ "all", do_radio_all, usage_radio_all, TRUE, TRUE },
|
{ "all", do_radio_all, usage_radio_all, TRUE, TRUE },
|
||||||
@@ -1403,7 +1403,7 @@ ac_overview (NmCli *nmc, NMActiveConnection *ac)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NMCResultCode
|
NMCResultCode
|
||||||
nmc_command_func_overview (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
nmc_command_func_overview (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
NMDevice **devices;
|
NMDevice **devices;
|
||||||
const GPtrArray *p;
|
const GPtrArray *p;
|
||||||
@@ -1518,7 +1518,7 @@ nmc_command_func_overview (const NMCCommand *cmd, NmCli *nmc, int argc, char **a
|
|||||||
}
|
}
|
||||||
|
|
||||||
NMCResultCode
|
NMCResultCode
|
||||||
nmc_command_func_monitor (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv)
|
nmc_command_func_monitor (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv)
|
||||||
{
|
{
|
||||||
next_arg (nmc, &argc, &argv, NULL);
|
next_arg (nmc, &argc, &argv, NULL);
|
||||||
|
|
||||||
|
@@ -257,9 +257,20 @@ usage (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
matches_arg (NmCli *nmc, int *argc, char ***argv, const char *pattern, char **arg)
|
matches_arg (NmCli *nmc,
|
||||||
|
int *argc,
|
||||||
|
const char *const**argv,
|
||||||
|
const char *pattern,
|
||||||
|
char **arg)
|
||||||
{
|
{
|
||||||
char *opt = *argv[0];
|
gs_free char *opt_free = NULL;
|
||||||
|
const char *opt = (*argv)[0];
|
||||||
|
gs_free char *arg_tmp = NULL;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
nm_assert (opt);
|
||||||
|
nm_assert (opt[0] == '-');
|
||||||
|
nm_assert (!arg || !*arg);
|
||||||
|
|
||||||
if (nmc->return_value != NMC_RESULT_SUCCESS) {
|
if (nmc->return_value != NMC_RESULT_SUCCESS) {
|
||||||
/* Don't process further matches if there has been an error. */
|
/* Don't process further matches if there has been an error. */
|
||||||
@@ -275,33 +286,31 @@ matches_arg (NmCli *nmc, int *argc, char ***argv, const char *pattern, char **ar
|
|||||||
if (arg) {
|
if (arg) {
|
||||||
/* If there's a "=" separator, replace it with NUL so that matches()
|
/* If there's a "=" separator, replace it with NUL so that matches()
|
||||||
* works and consider the part after it to be the arguemnt's value. */
|
* works and consider the part after it to be the arguemnt's value. */
|
||||||
*arg = strchr (opt, '=');
|
s = strchr (opt, '=');
|
||||||
if (*arg) {
|
if (s) {
|
||||||
**arg = '\0';
|
opt = nm_strndup_a (300, opt, s - opt, &opt_free);
|
||||||
(*arg)++;
|
arg_tmp = g_strdup (&s[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!matches (opt, pattern)) {
|
if (!matches (opt, pattern))
|
||||||
if (arg && *arg) {
|
|
||||||
/* Back off the replacement of "=". */
|
|
||||||
(*arg)--;
|
|
||||||
**arg = '=';
|
|
||||||
}
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
if (arg && !*arg) {
|
if (arg) {
|
||||||
/* We need a value, but the option didn't contain a "=<value>" part.
|
if (arg_tmp)
|
||||||
* Proceed to the next argument. */
|
*arg = g_steal_pointer (&arg_tmp);
|
||||||
(*argc)--;
|
else {
|
||||||
(*argv)++;
|
/* We need a value, but the option didn't contain a "=<value>" part.
|
||||||
if (!*argc) {
|
* Proceed to the next argument. */
|
||||||
g_string_printf (nmc->return_text, _("Error: missing argument for '%s' option."), opt);
|
if (*argc <= 1) {
|
||||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
g_string_printf (nmc->return_text, _("Error: missing argument for '%s' option."), opt);
|
||||||
return FALSE;
|
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
(*argc)--;
|
||||||
|
(*argv)++;
|
||||||
|
*arg = g_strdup (*argv[0]);
|
||||||
}
|
}
|
||||||
*arg = *argv[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -687,7 +696,7 @@ set_colors (NmcColorOption color_option,
|
|||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
process_command_line (NmCli *nmc, int argc, char **argv)
|
process_command_line (NmCli *nmc, int argc, char **argv_orig)
|
||||||
{
|
{
|
||||||
static const NMCCommand nmcli_cmds[] = {
|
static const NMCCommand nmcli_cmds[] = {
|
||||||
{ "general", nmc_command_func_general, NULL, FALSE, FALSE },
|
{ "general", nmc_command_func_general, NULL, FALSE, FALSE },
|
||||||
@@ -700,23 +709,30 @@ process_command_line (NmCli *nmc, int argc, char **argv)
|
|||||||
{ NULL, nmc_command_func_overview, usage, TRUE, TRUE },
|
{ NULL, nmc_command_func_overview, usage, TRUE, TRUE },
|
||||||
};
|
};
|
||||||
NmcColorOption colors = NMC_USE_COLOR_AUTO;
|
NmcColorOption colors = NMC_USE_COLOR_AUTO;
|
||||||
char *base;
|
const char *base;
|
||||||
|
const char *const*argv;
|
||||||
|
|
||||||
base = strrchr (argv[0], '/');
|
base = strrchr (argv_orig[0], '/');
|
||||||
if (base == NULL)
|
if (base == NULL)
|
||||||
base = argv[0];
|
base = argv_orig[0];
|
||||||
else
|
else
|
||||||
base++;
|
base++;
|
||||||
if (argc > 1 && nm_streq (argv[1], "--complete-args")) {
|
|
||||||
|
if ( argc > 1
|
||||||
|
&& nm_streq (argv_orig[1], "--complete-args")) {
|
||||||
nmc->complete = TRUE;
|
nmc->complete = TRUE;
|
||||||
argv[1] = argv[0];
|
argv_orig[1] = argv_orig[0];
|
||||||
next_arg (nmc, &argc, &argv, NULL);
|
argc--;
|
||||||
|
argv_orig++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
argv = (const char *const*) argv_orig;
|
||||||
|
|
||||||
next_arg (nmc, &argc, &argv, NULL);
|
next_arg (nmc, &argc, &argv, NULL);
|
||||||
|
|
||||||
/* parse options */
|
/* parse options */
|
||||||
while (argc) {
|
while (argc) {
|
||||||
char *value;
|
gs_free char *value = NULL;
|
||||||
|
|
||||||
if (argv[0][0] != '-')
|
if (argv[0][0] != '-')
|
||||||
break;
|
break;
|
||||||
|
@@ -170,20 +170,20 @@ struct _NMCCommand;
|
|||||||
|
|
||||||
typedef struct _NMCCommand {
|
typedef struct _NMCCommand {
|
||||||
const char *cmd;
|
const char *cmd;
|
||||||
NMCResultCode (*func) (const struct _NMCCommand *cmd, NmCli *nmc, int argc, char **argv);
|
NMCResultCode (*func) (const struct _NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv);
|
||||||
void (*usage) (void);
|
void (*usage) (void);
|
||||||
bool needs_client;
|
bool needs_client;
|
||||||
bool needs_nm_running;
|
bool needs_nm_running;
|
||||||
} NMCCommand;
|
} NMCCommand;
|
||||||
|
|
||||||
NMCResultCode nmc_command_func_agent (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv);
|
NMCResultCode nmc_command_func_agent (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv);
|
||||||
NMCResultCode nmc_command_func_general (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv);
|
NMCResultCode nmc_command_func_general (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv);
|
||||||
NMCResultCode nmc_command_func_networking (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv);
|
NMCResultCode nmc_command_func_networking (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv);
|
||||||
NMCResultCode nmc_command_func_radio (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv);
|
NMCResultCode nmc_command_func_radio (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv);
|
||||||
NMCResultCode nmc_command_func_monitor (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv);
|
NMCResultCode nmc_command_func_monitor (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv);
|
||||||
NMCResultCode nmc_command_func_overview (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv);
|
NMCResultCode nmc_command_func_overview (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv);
|
||||||
NMCResultCode nmc_command_func_connection (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv);
|
NMCResultCode nmc_command_func_connection (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv);
|
||||||
NMCResultCode nmc_command_func_device (const NMCCommand *cmd, NmCli *nmc, int argc, char **argv);
|
NMCResultCode nmc_command_func_device (const NMCCommand *cmd, NmCli *nmc, int argc, const char *const*argv);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
@@ -154,7 +154,7 @@ parse_global_arg (NmCli *nmc, const char *arg)
|
|||||||
* -1 otherwise (no more args).
|
* -1 otherwise (no more args).
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
next_arg (NmCli *nmc, int *argc, char ***argv, ...)
|
next_arg (NmCli *nmc, int *argc, const char *const**argv, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
const char *cmd_option;
|
const char *cmd_option;
|
||||||
@@ -248,7 +248,7 @@ nmc_arg_is_option (const char *str, const char *opt_name)
|
|||||||
* Returns: TRUE on success, FALSE on an error and sets 'error'
|
* Returns: TRUE on success, FALSE on an error and sets 'error'
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
nmc_parse_args (nmc_arg_t *arg_arr, gboolean last, int *argc, char ***argv, GError **error)
|
nmc_parse_args (nmc_arg_t *arg_arr, gboolean last, int *argc, const char *const**argv, GError **error)
|
||||||
{
|
{
|
||||||
nmc_arg_t *p;
|
nmc_arg_t *p;
|
||||||
gboolean found;
|
gboolean found;
|
||||||
|
@@ -19,10 +19,10 @@ typedef struct {
|
|||||||
} nmc_arg_t;
|
} nmc_arg_t;
|
||||||
|
|
||||||
/* === Functions === */
|
/* === Functions === */
|
||||||
int next_arg (NmCli *nmc, int *argc, char ***argv, ...);
|
int next_arg (NmCli *nmc, int *argc, const char *const**argv, ...);
|
||||||
gboolean nmc_arg_is_help (const char *arg);
|
gboolean nmc_arg_is_help (const char *arg);
|
||||||
gboolean nmc_arg_is_option (const char *arg, const char *opt_name);
|
gboolean nmc_arg_is_option (const char *arg, const char *opt_name);
|
||||||
gboolean nmc_parse_args (nmc_arg_t *arg_arr, gboolean last, int *argc, char ***argv, GError **error);
|
gboolean nmc_parse_args (nmc_arg_t *arg_arr, gboolean last, int *argc, const char *const**argv, GError **error);
|
||||||
char *ssid_to_hex (const char *str, gsize len);
|
char *ssid_to_hex (const char *str, gsize len);
|
||||||
void nmc_terminal_erase_line (void);
|
void nmc_terminal_erase_line (void);
|
||||||
void nmc_terminal_show_progress (const char *str);
|
void nmc_terminal_show_progress (const char *str);
|
||||||
|
Reference in New Issue
Block a user