mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-06-19 11:18:28 +02:00
nmcli: replace all uses of g_print()/g_printerr() with nmc_print()/nmc_printerr()
The main purpose is to simplify printf debugging and manual testing. We can now trivially patch the code so that all output from nmcli gets (additionally) written to a file. That is useful when debugging a unit test in "test-client.py". Thereby we can duplicate all messages via nm_utils_print(), which is in sync with the debug messages from libnm and which honors LIBNM_CLIENT_DEBUG_FILE.
This commit is contained in:
parent
4cf94f30c7
commit
b32e4c941a
9 changed files with 885 additions and 859 deletions
|
|
@ -22,36 +22,36 @@
|
|||
static void
|
||||
usage(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli agent { COMMAND | help }\n\n"
|
||||
"COMMAND := { secret | polkit | all }\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli agent { COMMAND | help }\n\n"
|
||||
"COMMAND := { secret | polkit | all }\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_agent_secret(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli agent secret { help }\n"
|
||||
"\n"
|
||||
"Runs nmcli as NetworkManager secret agent. When NetworkManager requires\n"
|
||||
"a password it asks registered agents for it. This command keeps nmcli running\n"
|
||||
"and if a password is required asks the user for it.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli agent secret { help }\n"
|
||||
"\n"
|
||||
"Runs nmcli as NetworkManager secret agent. When NetworkManager requires\n"
|
||||
"a password it asks registered agents for it. This command keeps nmcli running\n"
|
||||
"and if a password is required asks the user for it.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_agent_polkit(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli agent polkit { help }\n"
|
||||
"\n"
|
||||
"Registers nmcli as a polkit action for the user session.\n"
|
||||
"When a polkit daemon requires an authorization, nmcli asks the user and gives\n"
|
||||
"the response back to polkit.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli agent polkit { help }\n"
|
||||
"\n"
|
||||
"Registers nmcli as a polkit action for the user session.\n"
|
||||
"When a polkit daemon requires an authorization, nmcli asks the user and gives\n"
|
||||
"the response back to polkit.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_agent_all(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli agent all { help }\n"
|
||||
"\n"
|
||||
"Runs nmcli as both NetworkManager secret and a polkit agent.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli agent all { help }\n"
|
||||
"\n"
|
||||
"Runs nmcli as both NetworkManager secret and a polkit agent.\n\n"));
|
||||
}
|
||||
|
||||
static char *pre_input_deftext;
|
||||
|
|
@ -82,7 +82,7 @@ get_secrets_from_user(const NmcConfig *nmc_config,
|
|||
|
||||
/* Ask user for the password */
|
||||
if (msg)
|
||||
g_print("%s\n", msg);
|
||||
nmc_print("%s\n", msg);
|
||||
if (secret->value) {
|
||||
/* Prefill the password if we have it. */
|
||||
rl_startup_hook = set_deftext;
|
||||
|
|
@ -138,7 +138,7 @@ do_agent_secret(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *
|
|||
NM_SECRET_AGENT_SIMPLE_REQUEST_SECRETS,
|
||||
G_CALLBACK(secrets_requested),
|
||||
nmc);
|
||||
g_print(_("nmcli successfully registered as a NetworkManager's secret agent.\n"));
|
||||
nmc_print(_("nmcli successfully registered as a NetworkManager's secret agent.\n"));
|
||||
} else {
|
||||
g_string_printf(nmc->return_text, _("Error: secret agent initialization failed"));
|
||||
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
||||
|
|
@ -148,7 +148,7 @@ do_agent_secret(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *
|
|||
static void
|
||||
polkit_registered(gpointer instance, gpointer user_data)
|
||||
{
|
||||
g_print(_("nmcli successfully registered as a polkit agent.\n"));
|
||||
nmc_print(_("nmcli successfully registered as a polkit agent.\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -202,14 +202,14 @@ do_agent_all(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *arg
|
|||
do_agent_secret(cmd, nmc, argc, argv);
|
||||
r = nmc->return_value;
|
||||
if (r != NMC_RESULT_SUCCESS) {
|
||||
g_printerr("%s\n", nmc->return_text->str);
|
||||
nmc_printerr("%s\n", nmc->return_text->str);
|
||||
g_string_truncate(nmc->return_text, 0);
|
||||
nmc->return_value = NMC_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
do_agent_polkit(cmd, nmc, argc, argv);
|
||||
if (nmc->return_value != NMC_RESULT_SUCCESS) {
|
||||
g_printerr("%s\n", nmc->return_text->str);
|
||||
nmc_printerr("%s\n", nmc->return_text->str);
|
||||
g_string_truncate(nmc->return_text, 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -660,16 +660,16 @@ vpn_openconnect_get_secrets(NMConnection *connection, GPtrArray *secrets)
|
|||
/* Interactively authenticate to OpenConnect server and get secrets */
|
||||
ret = nm_vpn_openconnect_authenticate_helper(gw, &cookie, &gateway, &gwcert, &status, &error);
|
||||
if (!ret) {
|
||||
g_printerr(_("Error: openconnect failed: %s\n"), error->message);
|
||||
nmc_printerr(_("Error: openconnect failed: %s\n"), error->message);
|
||||
g_clear_error(&error);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (WIFEXITED(status)) {
|
||||
if (WEXITSTATUS(status) != 0)
|
||||
g_printerr(_("Error: openconnect failed with status %d\n"), WEXITSTATUS(status));
|
||||
nmc_printerr(_("Error: openconnect failed with status %d\n"), WEXITSTATUS(status));
|
||||
} else if (WIFSIGNALED(status))
|
||||
g_printerr(_("Error: openconnect failed with signal %d\n"), WTERMSIG(status));
|
||||
nmc_printerr(_("Error: openconnect failed with signal %d\n"), WTERMSIG(status));
|
||||
|
||||
/* Append port to the host value */
|
||||
if (gateway && port) {
|
||||
|
|
@ -743,7 +743,7 @@ get_secrets_from_user(const NmcConfig *nmc_config,
|
|||
}
|
||||
}
|
||||
if (msg)
|
||||
g_print("%s\n", msg);
|
||||
nmc_print("%s\n", msg);
|
||||
|
||||
echo_on = secret->is_secret ? nmc_config->show_secrets : TRUE;
|
||||
|
||||
|
|
@ -760,10 +760,10 @@ get_secrets_from_user(const NmcConfig *nmc_config,
|
|||
pwd = g_strdup("");
|
||||
} else {
|
||||
if (msg)
|
||||
g_print("%s\n", msg);
|
||||
g_printerr(_("Warning: password for '%s' not given in 'passwd-file' "
|
||||
"and nmcli cannot ask without '--ask' option.\n"),
|
||||
secret->entry_id);
|
||||
nmc_print("%s\n", msg);
|
||||
nmc_printerr(_("Warning: password for '%s' not given in 'passwd-file' "
|
||||
"and nmcli cannot ask without '--ask' option.\n"),
|
||||
secret->entry_id);
|
||||
}
|
||||
}
|
||||
/* No password provided, cancel the secrets. */
|
||||
|
|
@ -1532,7 +1532,7 @@ nmc_do_cmd(NmCli *nmc, const NMCCommand cmds[], const char *cmd, int argc, const
|
|||
if (argc == 1 && nmc->complete) {
|
||||
for (c = cmds; c->cmd; ++c) {
|
||||
if (!*cmd || matches(cmd, c->cmd))
|
||||
g_print("%s\n", c->cmd);
|
||||
nmc_print("%s\n", c->cmd);
|
||||
}
|
||||
nmc_complete_help(cmd);
|
||||
g_task_return_boolean(task, TRUE);
|
||||
|
|
@ -1612,7 +1612,7 @@ nmc_complete_strv(const char *prefix, gssize nargs, const char *const *args)
|
|||
if (prefix && !matches(prefix, candidate))
|
||||
continue;
|
||||
|
||||
g_print("%s\n", candidate);
|
||||
nmc_print("%s\n", candidate);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -838,34 +838,35 @@ static guint progress_id = 0; /* ID of event source for displaying progress */
|
|||
static void
|
||||
usage(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli device { COMMAND | help }\n\n"
|
||||
"COMMAND := { status | show | set | connect | reapply | modify | disconnect | "
|
||||
"delete | monitor | wifi | lldp }\n\n"
|
||||
" status\n\n"
|
||||
" show [<ifname>]\n\n"
|
||||
" set [ifname] <ifname> [autoconnect yes|no] [managed yes|no]\n\n"
|
||||
" connect <ifname>\n\n"
|
||||
" reapply <ifname>\n\n"
|
||||
" modify <ifname> ([+|-]<setting>.<property> <value>)+\n\n"
|
||||
" disconnect <ifname> ...\n\n"
|
||||
" delete <ifname> ...\n\n"
|
||||
" monitor <ifname> ...\n\n"
|
||||
" wifi [list [ifname <ifname>] [bssid <BSSID>] [--rescan yes|no|auto]]\n\n"
|
||||
" wifi connect <(B)SSID> [password <password>] [wep-key-type key|phrase] [ifname "
|
||||
"<ifname>]\n"
|
||||
" [bssid <BSSID>] [name <name>] [private yes|no] [hidden "
|
||||
"yes|no]\n\n"
|
||||
" wifi hotspot [ifname <ifname>] [con-name <name>] [ssid <SSID>] [band a|bg] "
|
||||
"[channel <channel>] [password <password>]\n\n"
|
||||
" wifi rescan [ifname <ifname>] [[ssid <SSID to scan>] ...]\n\n"
|
||||
" wifi show-password [ifname <ifname>]\n\n"
|
||||
" lldp [list [ifname <ifname>]]\n\n"));
|
||||
nmc_printerr(
|
||||
_("Usage: nmcli device { COMMAND | help }\n\n"
|
||||
"COMMAND := { status | show | set | connect | reapply | modify | disconnect | "
|
||||
"delete | monitor | wifi | lldp }\n\n"
|
||||
" status\n\n"
|
||||
" show [<ifname>]\n\n"
|
||||
" set [ifname] <ifname> [autoconnect yes|no] [managed yes|no]\n\n"
|
||||
" connect <ifname>\n\n"
|
||||
" reapply <ifname>\n\n"
|
||||
" modify <ifname> ([+|-]<setting>.<property> <value>)+\n\n"
|
||||
" disconnect <ifname> ...\n\n"
|
||||
" delete <ifname> ...\n\n"
|
||||
" monitor <ifname> ...\n\n"
|
||||
" wifi [list [ifname <ifname>] [bssid <BSSID>] [--rescan yes|no|auto]]\n\n"
|
||||
" wifi connect <(B)SSID> [password <password>] [wep-key-type key|phrase] [ifname "
|
||||
"<ifname>]\n"
|
||||
" [bssid <BSSID>] [name <name>] [private yes|no] [hidden "
|
||||
"yes|no]\n\n"
|
||||
" wifi hotspot [ifname <ifname>] [con-name <name>] [ssid <SSID>] [band a|bg] "
|
||||
"[channel <channel>] [password <password>]\n\n"
|
||||
" wifi rescan [ifname <ifname>] [[ssid <SSID to scan>] ...]\n\n"
|
||||
" wifi show-password [ifname <ifname>]\n\n"
|
||||
" lldp [list [ifname <ifname>]]\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_device_status(void)
|
||||
{
|
||||
g_printerr(
|
||||
nmc_printerr(
|
||||
_("Usage: nmcli device status { help }\n"
|
||||
"\n"
|
||||
"Show status for all devices.\n"
|
||||
|
|
@ -881,41 +882,41 @@ usage_device_status(void)
|
|||
static void
|
||||
usage_device_show(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli device show { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [<ifname>]\n"
|
||||
"\n"
|
||||
"Show details of device(s).\n"
|
||||
"The command lists details for all devices, or for a given device.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli device show { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [<ifname>]\n"
|
||||
"\n"
|
||||
"Show details of device(s).\n"
|
||||
"The command lists details for all devices, or for a given device.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_device_connect(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli device connect { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname>\n"
|
||||
"\n"
|
||||
"Connect the device.\n"
|
||||
"NetworkManager will try to find a suitable connection that will be activated.\n"
|
||||
"It will also consider connections that are not set to auto-connect.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli device connect { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname>\n"
|
||||
"\n"
|
||||
"Connect the device.\n"
|
||||
"NetworkManager will try to find a suitable connection that will be activated.\n"
|
||||
"It will also consider connections that are not set to auto-connect.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_device_reapply(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli device reapply { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname>\n"
|
||||
"\n"
|
||||
"Attempts to update device with changes to the currently active connection\n"
|
||||
"made since it was last applied.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli device reapply { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname>\n"
|
||||
"\n"
|
||||
"Attempts to update device with changes to the currently active connection\n"
|
||||
"made since it was last applied.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_device_modify(void)
|
||||
{
|
||||
g_printerr(_(
|
||||
nmc_printerr(_(
|
||||
"Usage: nmcli device modify { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname> ([+|-]<setting>.<property> <value>)+\n"
|
||||
|
|
@ -936,57 +937,57 @@ usage_device_modify(void)
|
|||
static void
|
||||
usage_device_disconnect(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli device disconnect { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname> ...\n"
|
||||
"\n"
|
||||
"Disconnect devices.\n"
|
||||
"The command disconnects the device and prevents it from auto-activating\n"
|
||||
"further connections without user/manual intervention.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli device disconnect { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname> ...\n"
|
||||
"\n"
|
||||
"Disconnect devices.\n"
|
||||
"The command disconnects the device and prevents it from auto-activating\n"
|
||||
"further connections without user/manual intervention.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_device_delete(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli device delete { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname> ...\n"
|
||||
"\n"
|
||||
"Delete the software devices.\n"
|
||||
"The command removes the interfaces. It only works for software devices\n"
|
||||
"(like bonds, bridges, etc.). Hardware devices cannot be deleted by the\n"
|
||||
"command.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli device delete { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := <ifname> ...\n"
|
||||
"\n"
|
||||
"Delete the software devices.\n"
|
||||
"The command removes the interfaces. It only works for software devices\n"
|
||||
"(like bonds, bridges, etc.). Hardware devices cannot be deleted by the\n"
|
||||
"command.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_device_set(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli device set { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := DEVICE { PROPERTY [ PROPERTY ... ] }\n"
|
||||
"DEVICE := [ifname] <ifname> \n"
|
||||
"PROPERTY := { autoconnect { yes | no } |\n"
|
||||
" { managed { yes | no }\n"
|
||||
"\n"
|
||||
"Modify device properties.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli device set { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := DEVICE { PROPERTY [ PROPERTY ... ] }\n"
|
||||
"DEVICE := [ifname] <ifname> \n"
|
||||
"PROPERTY := { autoconnect { yes | no } |\n"
|
||||
" { managed { yes | no }\n"
|
||||
"\n"
|
||||
"Modify device properties.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_device_monitor(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli device monitor { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [<ifname>] ...\n"
|
||||
"\n"
|
||||
"Monitor device activity.\n"
|
||||
"This command prints a line whenever the specified devices change state.\n"
|
||||
"Monitors all devices in case no interface is specified.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli device monitor { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [<ifname>] ...\n"
|
||||
"\n"
|
||||
"Monitor device activity.\n"
|
||||
"This command prints a line whenever the specified devices change state.\n"
|
||||
"Monitors all devices in case no interface is specified.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_device_wifi(void)
|
||||
{
|
||||
g_printerr(
|
||||
nmc_printerr(
|
||||
_("Usage: nmcli device wifi { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"Perform operation on Wi-Fi devices.\n"
|
||||
|
|
@ -1035,24 +1036,24 @@ usage_device_wifi(void)
|
|||
static void
|
||||
usage_device_lldp(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli device lldp { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [list [ifname <ifname>]]\n"
|
||||
"\n"
|
||||
"List neighboring devices discovered through LLDP. The 'ifname' option can be\n"
|
||||
"used to list neighbors for a particular interface.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli device lldp { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [list [ifname <ifname>]]\n"
|
||||
"\n"
|
||||
"List neighboring devices discovered through LLDP. The 'ifname' option can be\n"
|
||||
"used to list neighbors for a particular interface.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_device_checkpoint(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli device checkpoint { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [--timeout <seconds>] -- COMMAND...\n"
|
||||
"\n"
|
||||
"Runs the command with a configuration checkpoint taken and asks for a\n"
|
||||
"confirmation when finished. When the confirmation is not given, the\n"
|
||||
"checkpoint is automatically restored after timeout.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli device checkpoint { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [--timeout <seconds>] -- COMMAND...\n"
|
||||
"\n"
|
||||
"Runs the command with a configuration checkpoint taken and asks for a\n"
|
||||
"confirmation when finished. When the confirmation is not given, the\n"
|
||||
"checkpoint is automatically restored after timeout.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1109,7 +1110,7 @@ complete_device(NMDevice **devices, const char *prefix, gboolean wifi_only)
|
|||
continue;
|
||||
|
||||
if (g_str_has_prefix(iface, prefix))
|
||||
g_print("%s\n", iface);
|
||||
nmc_print("%s\n", iface);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1178,10 +1179,10 @@ get_device_list(NmCli *nmc, int *argc, const char *const **argv)
|
|||
if (!g_ptr_array_find(queue, device, NULL))
|
||||
g_ptr_array_add(queue, g_object_ref(device));
|
||||
else
|
||||
g_printerr(_("Warning: argument '%s' is duplicated.\n"), **argv);
|
||||
nmc_printerr(_("Warning: argument '%s' is duplicated.\n"), **argv);
|
||||
} else {
|
||||
if (!nmc->complete)
|
||||
g_printerr(_("Error: Device '%s' not found.\n"), **argv);
|
||||
nmc_printerr(_("Error: Device '%s' not found.\n"), **argv);
|
||||
g_string_printf(nmc->return_text, _("Error: not all devices found."));
|
||||
nmc->return_value = NMC_RESULT_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
|
@ -1645,7 +1646,7 @@ show_device_info(NMDevice *device, NmCli *nmc)
|
|||
|
||||
if (NM_IN_SET(nmc->nmc_config.print_output, NMC_PRINT_NORMAL, NMC_PRINT_PRETTY)
|
||||
&& !nmc->nmc_config.multiline_output && was_output)
|
||||
g_print("\n"); /* Print empty line between groups in tabular mode */
|
||||
nmc_print("\n"); /* Print empty line between groups in tabular mode */
|
||||
|
||||
was_output = FALSE;
|
||||
|
||||
|
|
@ -2033,7 +2034,7 @@ do_device_show(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *a
|
|||
if (!show_device_info(devices[i], nmc))
|
||||
break;
|
||||
if (devices[i + 1])
|
||||
g_print("\n"); /* Empty line */
|
||||
nmc_print("\n"); /* Empty line */
|
||||
}
|
||||
|
||||
g_free(devices);
|
||||
|
|
@ -2124,12 +2125,12 @@ add_and_activate_check_state(AddAndActivateInfo *info)
|
|||
|
||||
if (state == NM_DEVICE_STATE_ACTIVATED) {
|
||||
nmc_terminal_erase_line();
|
||||
g_print(_("Device '%s' successfully activated with '%s'.\n"),
|
||||
nm_device_get_iface(info->device),
|
||||
nm_active_connection_get_uuid(info->active));
|
||||
nmc_print(_("Device '%s' successfully activated with '%s'.\n"),
|
||||
nm_device_get_iface(info->device),
|
||||
nm_active_connection_get_uuid(info->active));
|
||||
|
||||
if (info->hotspot)
|
||||
g_print(
|
||||
nmc_print(
|
||||
_("Hint: \"nmcli dev wifi show-password\" shows the Wi-Fi name and password.\n"));
|
||||
} else if (state <= NM_DEVICE_STATE_DISCONNECTED || state >= NM_DEVICE_STATE_DEACTIVATING) {
|
||||
reason = nm_device_get_state_reason(info->device);
|
||||
|
|
@ -2195,7 +2196,7 @@ add_and_activate_cb(GObject *client, GAsyncResult *result, gpointer user_data)
|
|||
deprecated =
|
||||
nmc_connection_check_deprecated(NM_CONNECTION(nm_active_connection_get_connection(active)));
|
||||
if (deprecated)
|
||||
g_printerr(_("Warning: %s.\n"), deprecated);
|
||||
nmc_printerr(_("Warning: %s.\n"), deprecated);
|
||||
|
||||
if (nmc->nowait_flag) {
|
||||
quit();
|
||||
|
|
@ -2383,9 +2384,9 @@ device_removed_cb(NMClient *client, NMDevice *device, DeviceCbInfo *info)
|
|||
return;
|
||||
|
||||
if (info->cmd_disconnect)
|
||||
g_print(_("Device '%s' successfully disconnected.\n"), nm_device_get_iface(device));
|
||||
nmc_print(_("Device '%s' successfully disconnected.\n"), nm_device_get_iface(device));
|
||||
else
|
||||
g_print(_("Device '%s' successfully removed.\n"), nm_device_get_iface(device));
|
||||
nmc_print(_("Device '%s' successfully removed.\n"), nm_device_get_iface(device));
|
||||
device_cb_info_finish(info, device);
|
||||
}
|
||||
|
||||
|
|
@ -2396,7 +2397,7 @@ disconnect_state_cb(NMDevice *device, GParamSpec *pspec, DeviceCbInfo *info)
|
|||
return;
|
||||
|
||||
if (nm_device_get_state(device) <= NM_DEVICE_STATE_DISCONNECTED) {
|
||||
g_print(_("Device '%s' successfully disconnected.\n"), nm_device_get_iface(device));
|
||||
nmc_print(_("Device '%s' successfully disconnected.\n"), nm_device_get_iface(device));
|
||||
device_cb_info_finish(info, device);
|
||||
}
|
||||
}
|
||||
|
|
@ -2455,8 +2456,8 @@ reapply_device_cb(GObject *object, GAsyncResult *result, gpointer user_data)
|
|||
} else {
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line();
|
||||
g_print(_("Connection successfully reapplied to device '%s'.\n"),
|
||||
nm_device_get_iface(device));
|
||||
nmc_print(_("Connection successfully reapplied to device '%s'.\n"),
|
||||
nm_device_get_iface(device));
|
||||
device_cb_info_finish(info, device);
|
||||
}
|
||||
}
|
||||
|
|
@ -2536,8 +2537,8 @@ modify_reapply_cb(GObject *object, GAsyncResult *result, gpointer user_data)
|
|||
} else {
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line();
|
||||
g_print(_("Connection successfully reapplied to device '%s'.\n"),
|
||||
nm_device_get_iface(device));
|
||||
nmc_print(_("Connection successfully reapplied to device '%s'.\n"),
|
||||
nm_device_get_iface(device));
|
||||
}
|
||||
|
||||
quit();
|
||||
|
|
@ -2636,10 +2637,10 @@ disconnect_device_cb(GObject *object, GAsyncResult *result, gpointer user_data)
|
|||
return;
|
||||
nmc = info->nmc;
|
||||
g_string_printf(nmc->return_text, _("Error: not all devices disconnected."));
|
||||
g_printerr(_("Error: Device '%s' (%s) disconnecting failed: %s\n"),
|
||||
nm_device_get_iface(device),
|
||||
nm_object_get_path(NM_OBJECT(device)),
|
||||
error->message);
|
||||
nmc_printerr(_("Error: Device '%s' (%s) disconnecting failed: %s\n"),
|
||||
nm_device_get_iface(device),
|
||||
nm_object_get_path(NM_OBJECT(device)),
|
||||
error->message);
|
||||
g_error_free(error);
|
||||
nmc->return_value = NMC_RESULT_ERROR_DEV_DISCONNECT;
|
||||
device_cb_info_finish(info, device);
|
||||
|
|
@ -2651,7 +2652,8 @@ disconnect_device_cb(GObject *object, GAsyncResult *result, gpointer user_data)
|
|||
if (state <= NM_DEVICE_STATE_DISCONNECTED) {
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line();
|
||||
g_print(_("Device '%s' successfully disconnected.\n"), nm_device_get_iface(device));
|
||||
nmc_print(_("Device '%s' successfully disconnected.\n"),
|
||||
nm_device_get_iface(device));
|
||||
}
|
||||
device_cb_info_finish(info, device);
|
||||
}
|
||||
|
|
@ -2713,15 +2715,15 @@ delete_device_cb(GObject *object, GAsyncResult *result, gpointer user_data)
|
|||
|
||||
if (!nm_device_delete_finish(device, result, &error)) {
|
||||
g_string_printf(nmc->return_text, _("Error: not all devices deleted."));
|
||||
g_printerr(_("Error: Device '%s' (%s) deletion failed: %s\n"),
|
||||
nm_device_get_iface(device),
|
||||
nm_object_get_path(NM_OBJECT(device)),
|
||||
error->message);
|
||||
nmc_printerr(_("Error: Device '%s' (%s) deletion failed: %s\n"),
|
||||
nm_device_get_iface(device),
|
||||
nm_object_get_path(NM_OBJECT(device)),
|
||||
error->message);
|
||||
g_error_free(error);
|
||||
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
||||
device_cb_info_finish(info, device);
|
||||
} else {
|
||||
g_print(_("Device '%s' successfully removed.\n"), nm_device_get_iface(device));
|
||||
nmc_print(_("Device '%s' successfully removed.\n"), nm_device_get_iface(device));
|
||||
device_cb_info_finish(info, device);
|
||||
}
|
||||
}
|
||||
|
|
@ -2877,7 +2879,7 @@ device_state(NMDevice *device, GParamSpec *pspec, NmCli *nmc)
|
|||
nm_device_get_iface(device),
|
||||
gettext(nmc_device_state_to_string_with_external(device)));
|
||||
|
||||
g_print("%s", str);
|
||||
nmc_print("%s", str);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2889,7 +2891,7 @@ device_ac(NMDevice *device, GParamSpec *pspec, NmCli *nmc)
|
|||
if (!id)
|
||||
return;
|
||||
|
||||
g_print(_("%s: using connection '%s'\n"), nm_device_get_iface(device), id);
|
||||
nmc_print(_("%s: using connection '%s'\n"), nm_device_get_iface(device), id);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2915,14 +2917,14 @@ device_unwatch(NmCli *nmc, NMDevice *device)
|
|||
static void
|
||||
device_added(NMClient *client, NMDevice *device, NmCli *nmc)
|
||||
{
|
||||
g_print(_("%s: device created\n"), nm_device_get_iface(device));
|
||||
nmc_print(_("%s: device created\n"), nm_device_get_iface(device));
|
||||
device_watch(nmc, NM_DEVICE(device));
|
||||
}
|
||||
|
||||
static void
|
||||
device_removed(NMClient *client, NMDevice *device, NmCli *nmc)
|
||||
{
|
||||
g_print(_("%s: device removed\n"), nm_device_get_iface(device));
|
||||
nmc_print(_("%s: device removed\n"), nm_device_get_iface(device));
|
||||
device_unwatch(nmc, device);
|
||||
}
|
||||
|
||||
|
|
@ -3020,7 +3022,7 @@ find_ap_on_device(NMDevice *device, const char *bssid, const char *ssid, gboolea
|
|||
/* Compare BSSIDs */
|
||||
if (complete) {
|
||||
if (g_str_has_prefix(candidate_bssid, bssid))
|
||||
g_print("%s\n", candidate_bssid);
|
||||
nmc_print("%s\n", candidate_bssid);
|
||||
} else if (strcmp(bssid, candidate_bssid) != 0)
|
||||
continue;
|
||||
}
|
||||
|
|
@ -3040,7 +3042,7 @@ find_ap_on_device(NMDevice *device, const char *bssid, const char *ssid, gboolea
|
|||
/* Compare SSIDs */
|
||||
if (complete) {
|
||||
if (g_str_has_prefix(ssid_tmp, ssid))
|
||||
g_print("%s\n", ssid_tmp);
|
||||
nmc_print("%s\n", ssid_tmp);
|
||||
} else if (strcmp(ssid, ssid_tmp) != 0) {
|
||||
g_free(ssid_tmp);
|
||||
continue;
|
||||
|
|
@ -3108,7 +3110,7 @@ wifi_print_aps(NMDeviceWifi *wifi,
|
|||
static gboolean empty_line = FALSE;
|
||||
|
||||
if (empty_line)
|
||||
g_print("\n"); /* Empty line between devices' APs */
|
||||
nmc_print("\n"); /* Empty line between devices' APs */
|
||||
|
||||
/* Main header name */
|
||||
header_name = construct_header_name(base_hdr, nm_device_get_iface(NM_DEVICE(wifi)));
|
||||
|
|
@ -3980,9 +3982,10 @@ do_device_wifi_connect(const NMCCommand *cmd, NmCli *nmc, int argc, const char *
|
|||
|
||||
/* Warn when the provided AP identifier looks like BSSID instead of SSID */
|
||||
if (bssid1_arr)
|
||||
g_printerr(_("Warning: '%s' should be SSID for hidden APs; but it looks like a "
|
||||
"BSSID.\n"),
|
||||
param_user);
|
||||
nmc_printerr(
|
||||
_("Warning: '%s' should be SSID for hidden APs; but it looks like a "
|
||||
"BSSID.\n"),
|
||||
param_user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4202,7 +4205,7 @@ set_wireless_security_for_hotspot(NMSettingWirelessSecurity *s_wsec,
|
|||
NULL);
|
||||
}
|
||||
if (show_password)
|
||||
g_print(_("Hotspot password: %s\n"), key);
|
||||
nmc_print(_("Hotspot password: %s\n"), key);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -4688,7 +4691,7 @@ print_wifi_connection(const NmcConfig *nmc_config, NMConnection *connection)
|
|||
g_return_if_fail(ssid_bytes);
|
||||
ssid = nm_utils_ssid_to_utf8(g_bytes_get_data(ssid_bytes, NULL), g_bytes_get_size(ssid_bytes));
|
||||
g_return_if_fail(ssid);
|
||||
g_print("SSID: %s\n", ssid);
|
||||
nmc_print("SSID: %s\n", ssid);
|
||||
|
||||
string = g_string_sized_new(64);
|
||||
g_string_append(string, "WIFI:");
|
||||
|
|
@ -4701,21 +4704,21 @@ print_wifi_connection(const NmcConfig *nmc_config, NMConnection *connection)
|
|||
|
||||
if (key_mgmt == NULL) {
|
||||
type = "nopass";
|
||||
g_print("%s: %s\n", _("Security"), _("None"));
|
||||
nmc_print("%s: %s\n", _("Security"), _("None"));
|
||||
} else if (strcmp(key_mgmt, "none") == 0 || strcmp(key_mgmt, "ieee8021x") == 0) {
|
||||
type = "WEP";
|
||||
g_print("%s: WEP\n", _("Security"));
|
||||
nmc_print("%s: WEP\n", _("Security"));
|
||||
} else if (strcmp(key_mgmt, "wpa-none") == 0 || strcmp(key_mgmt, "wpa-psk") == 0
|
||||
|| strcmp(key_mgmt, "sae") == 0) {
|
||||
type = "WPA";
|
||||
g_print("%s: WPA\n", _("Security"));
|
||||
nmc_print("%s: WPA\n", _("Security"));
|
||||
} else if (strcmp(key_mgmt, "owe") == 0) {
|
||||
type = "nopass";
|
||||
g_print("%s: OWE\n", _("Security"));
|
||||
nmc_print("%s: OWE\n", _("Security"));
|
||||
}
|
||||
|
||||
if (psk)
|
||||
g_print("%s: %s\n", _("Password"), psk);
|
||||
nmc_print("%s: %s\n", _("Password"), psk);
|
||||
|
||||
string_append_mecard(string, "T:", type);
|
||||
string_append_mecard(string, "S:", ssid);
|
||||
|
|
@ -4728,7 +4731,7 @@ print_wifi_connection(const NmcConfig *nmc_config, NMConnection *connection)
|
|||
if (nmc_config->use_colors)
|
||||
nmc_print_qrcode(string->str);
|
||||
|
||||
g_print("\n");
|
||||
nmc_print("\n");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -5091,7 +5094,7 @@ checkpoints_changed_cb(GObject *object, GParamSpec *pspec, CheckpointCbInfo *inf
|
|||
|
||||
if (!info->child_id) {
|
||||
/* The command is done, we're in the confirmation prompt. */
|
||||
g_print("%s\n", _("No"));
|
||||
nmc_print("%s\n", _("No"));
|
||||
g_main_loop_quit(loop);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -299,19 +299,19 @@ static const NmcMetaGenericInfo
|
|||
static void
|
||||
usage_general(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli general { COMMAND | help }\n\n"
|
||||
"COMMAND := { status | hostname | permissions | logging | reload }\n\n"
|
||||
" status\n\n"
|
||||
" hostname [<hostname>]\n\n"
|
||||
" permissions\n\n"
|
||||
" logging [level <log level>] [domains <log domains>]\n\n"
|
||||
" reload [<flags>]\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli general { COMMAND | help }\n\n"
|
||||
"COMMAND := { status | hostname | permissions | logging | reload }\n\n"
|
||||
" status\n\n"
|
||||
" hostname [<hostname>]\n\n"
|
||||
" permissions\n\n"
|
||||
" logging [level <log level>] [domains <log domains>]\n\n"
|
||||
" reload [<flags>]\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_general_status(void)
|
||||
{
|
||||
g_printerr(
|
||||
nmc_printerr(
|
||||
_("Usage: nmcli general status { help }\n"
|
||||
"\n"
|
||||
"Show overall status of NetworkManager.\n"
|
||||
|
|
@ -321,7 +321,7 @@ usage_general_status(void)
|
|||
static void
|
||||
usage_general_hostname(void)
|
||||
{
|
||||
g_printerr(
|
||||
nmc_printerr(
|
||||
_("Usage: nmcli general hostname { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [<hostname>]\n"
|
||||
|
|
@ -334,87 +334,88 @@ usage_general_hostname(void)
|
|||
static void
|
||||
usage_general_permissions(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli general permissions { help }\n"
|
||||
"\n"
|
||||
"Show caller permissions for authenticated operations.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli general permissions { help }\n"
|
||||
"\n"
|
||||
"Show caller permissions for authenticated operations.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_general_reload(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli general reload { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [<flag>[,<flag>...]]\n"
|
||||
"\n"
|
||||
"Reload NetworkManager's configuration and perform certain updates, like\n"
|
||||
"flushing caches or rewriting external state to disk. This is similar to\n"
|
||||
"sending SIGHUP to NetworkManager but it allows for more fine-grained\n"
|
||||
"control over what to reload through the flags argument. It also allows\n"
|
||||
"non-root access via PolicyKit and contrary to signals it is synchronous.\n"
|
||||
"\n"
|
||||
"Available flags are:\n"
|
||||
"\n"
|
||||
" 'conf' Reload the NetworkManager.conf configuration from\n"
|
||||
" disk. Note that this does not include connections, which\n"
|
||||
" can be reloaded through 'nmcli connection reload' instead.\n"
|
||||
"\n"
|
||||
" 'dns-rc' Update DNS configuration, which usually involves writing\n"
|
||||
" /etc/resolv.conf anew. This is equivalent to sending the\n"
|
||||
" SIGUSR1 signal to the NetworkManager process.\n"
|
||||
"\n"
|
||||
" 'dns-full' Restart the DNS plugin. This is for example useful when\n"
|
||||
" using dnsmasq plugin, which uses additional configuration\n"
|
||||
" in /etc/NetworkManager/dnsmasq.d. If you edit those files,\n"
|
||||
" you can restart the DNS plugin. This action shortly\n"
|
||||
" interrupts name resolution.\n"
|
||||
"\n"
|
||||
"With no flags, everything that is supported is reloaded, which is\n"
|
||||
"identical to sending a SIGHUP.\n"));
|
||||
nmc_printerr(_("Usage: nmcli general reload { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [<flag>[,<flag>...]]\n"
|
||||
"\n"
|
||||
"Reload NetworkManager's configuration and perform certain updates, like\n"
|
||||
"flushing caches or rewriting external state to disk. This is similar to\n"
|
||||
"sending SIGHUP to NetworkManager but it allows for more fine-grained\n"
|
||||
"control over what to reload through the flags argument. It also allows\n"
|
||||
"non-root access via PolicyKit and contrary to signals it is synchronous.\n"
|
||||
"\n"
|
||||
"Available flags are:\n"
|
||||
"\n"
|
||||
" 'conf' Reload the NetworkManager.conf configuration from\n"
|
||||
" disk. Note that this does not include connections, which\n"
|
||||
" can be reloaded through 'nmcli connection reload' instead.\n"
|
||||
"\n"
|
||||
" 'dns-rc' Update DNS configuration, which usually involves writing\n"
|
||||
" /etc/resolv.conf anew. This is equivalent to sending the\n"
|
||||
" SIGUSR1 signal to the NetworkManager process.\n"
|
||||
"\n"
|
||||
" 'dns-full' Restart the DNS plugin. This is for example useful when\n"
|
||||
" using dnsmasq plugin, which uses additional configuration\n"
|
||||
" in /etc/NetworkManager/dnsmasq.d. If you edit those files,\n"
|
||||
" you can restart the DNS plugin. This action shortly\n"
|
||||
" interrupts name resolution.\n"
|
||||
"\n"
|
||||
"With no flags, everything that is supported is reloaded, which is\n"
|
||||
"identical to sending a SIGHUP.\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_general_logging(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli general logging { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [level <log level>] [domains <log domains>]\n"
|
||||
"\n"
|
||||
"Get or change NetworkManager logging level and domains.\n"
|
||||
"Without any argument current logging level and domains are shown. In order to\n"
|
||||
"change logging state, provide level and/or domain. Please refer to the man page\n"
|
||||
"for the list of possible logging domains.\n\n"));
|
||||
nmc_printerr(
|
||||
_("Usage: nmcli general logging { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [level <log level>] [domains <log domains>]\n"
|
||||
"\n"
|
||||
"Get or change NetworkManager logging level and domains.\n"
|
||||
"Without any argument current logging level and domains are shown. In order to\n"
|
||||
"change logging state, provide level and/or domain. Please refer to the man page\n"
|
||||
"for the list of possible logging domains.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_networking(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli networking { COMMAND | help }\n\n"
|
||||
"COMMAND := { [ on | off | connectivity ] }\n\n"
|
||||
" on\n\n"
|
||||
" off\n\n"
|
||||
" connectivity [check]\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli networking { COMMAND | help }\n\n"
|
||||
"COMMAND := { [ on | off | connectivity ] }\n\n"
|
||||
" on\n\n"
|
||||
" off\n\n"
|
||||
" connectivity [check]\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_networking_on(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli networking on { help }\n"
|
||||
"\n"
|
||||
"Switch networking on.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli networking on { help }\n"
|
||||
"\n"
|
||||
"Switch networking on.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_networking_off(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli networking off { help }\n"
|
||||
"\n"
|
||||
"Switch networking off.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli networking off { help }\n"
|
||||
"\n"
|
||||
"Switch networking off.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_networking_connectivity(void)
|
||||
{
|
||||
g_printerr(
|
||||
nmc_printerr(
|
||||
_("Usage: nmcli networking connectivity { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [check]\n"
|
||||
|
|
@ -426,48 +427,48 @@ usage_networking_connectivity(void)
|
|||
static void
|
||||
usage_radio(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli radio { COMMAND | help }\n\n"
|
||||
"COMMAND := { all | wifi | wwan }\n\n"
|
||||
" all | wifi | wwan [ on | off ]\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli radio { COMMAND | help }\n\n"
|
||||
"COMMAND := { all | wifi | wwan }\n\n"
|
||||
" all | wifi | wwan [ on | off ]\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_radio_all(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli radio all { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [on | off]\n"
|
||||
"\n"
|
||||
"Get status of all radio switches, or turn them on/off.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli radio all { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [on | off]\n"
|
||||
"\n"
|
||||
"Get status of all radio switches, or turn them on/off.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_radio_wifi(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli radio wifi { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [on | off]\n"
|
||||
"\n"
|
||||
"Get status of Wi-Fi radio switch, or turn it on/off.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli radio wifi { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [on | off]\n"
|
||||
"\n"
|
||||
"Get status of Wi-Fi radio switch, or turn it on/off.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_radio_wwan(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli radio wwan { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [on | off]\n"
|
||||
"\n"
|
||||
"Get status of mobile broadband radio switch, or turn it on/off.\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli radio wwan { ARGUMENTS | help }\n"
|
||||
"\n"
|
||||
"ARGUMENTS := [on | off]\n"
|
||||
"\n"
|
||||
"Get status of mobile broadband radio switch, or turn it on/off.\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
usage_monitor(void)
|
||||
{
|
||||
g_printerr(_("Usage: nmcli monitor\n"
|
||||
"\n"
|
||||
"Monitor NetworkManager changes.\n"
|
||||
"Prints a line whenever a change occurs in NetworkManager\n\n"));
|
||||
nmc_printerr(_("Usage: nmcli monitor\n"
|
||||
"\n"
|
||||
"Monitor NetworkManager changes.\n"
|
||||
"Prints a line whenever a change occurs in NetworkManager\n\n"));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -748,7 +749,7 @@ nmc_complete_strings_nocase(const char *prefix, ...)
|
|||
va_start(args, prefix);
|
||||
while ((candidate = va_arg(args, const char *))) {
|
||||
if (strncasecmp(prefix, candidate, len) == 0)
|
||||
g_print("%s\n", candidate);
|
||||
nmc_print("%s\n", candidate);
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
|
@ -919,13 +920,13 @@ do_general_hostname(const NMCCommand *cmd, NmCli *nmc, int argc, const char *con
|
|||
|
||||
g_object_get(nmc->client, NM_CLIENT_HOSTNAME, &s, NULL);
|
||||
if (s)
|
||||
g_print("%s\n", s);
|
||||
nmc_print("%s\n", s);
|
||||
return;
|
||||
}
|
||||
|
||||
hostname = *argv;
|
||||
if (next_arg(nmc, &argc, &argv, NULL) == 0)
|
||||
g_print("Warning: ignoring extra garbage after '%s' hostname\n", hostname);
|
||||
nmc_print("Warning: ignoring extra garbage after '%s' hostname\n", hostname);
|
||||
|
||||
nmc->should_wait++;
|
||||
nm_client_save_hostname_async(nmc->client, hostname, NULL, save_hostname_cb, nmc);
|
||||
|
|
@ -1234,7 +1235,7 @@ networkmanager_running(NMClient *client, GParamSpec *param, NmCli *nmc)
|
|||
str = nmc_colorize(&nmc->nmc_config,
|
||||
running ? NM_META_COLOR_MANAGER_RUNNING : NM_META_COLOR_MANAGER_STOPPED,
|
||||
running ? _("NetworkManager is running") : _("NetworkManager is stopped"));
|
||||
g_print("%s\n", str);
|
||||
nmc_print("%s\n", str);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
|
|
@ -1244,7 +1245,7 @@ client_hostname(NMClient *client, GParamSpec *param, NmCli *nmc)
|
|||
const char *hostname;
|
||||
|
||||
g_object_get(client, NM_CLIENT_HOSTNAME, &hostname, NULL);
|
||||
g_print(_("Hostname set to '%s'\n"), hostname);
|
||||
nmc_print(_("Hostname set to '%s'\n"), hostname);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1259,9 +1260,9 @@ client_primary_connection(NMClient *client, GParamSpec *param, NmCli *nmc)
|
|||
if (!id)
|
||||
id = nm_active_connection_get_uuid(primary);
|
||||
|
||||
g_print(_("'%s' is now the primary connection\n"), id);
|
||||
nmc_print(_("'%s' is now the primary connection\n"), id);
|
||||
} else {
|
||||
g_print(_("There's no primary connection\n"));
|
||||
nmc_print(_("There's no primary connection\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1276,7 +1277,7 @@ client_connectivity(NMClient *client, GParamSpec *param, NmCli *nmc)
|
|||
connectivity_to_color(connectivity),
|
||||
_("Connectivity is now '%s'\n"),
|
||||
gettext(nm_connectivity_to_string(connectivity)));
|
||||
g_print("%s", str);
|
||||
nmc_print("%s", str);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
|
|
@ -1291,7 +1292,7 @@ client_state(NMClient *client, GParamSpec *param, NmCli *nmc)
|
|||
state_to_color(state),
|
||||
_("Networkmanager is now in the '%s' state\n"),
|
||||
gettext(nm_state_to_string(state)));
|
||||
g_print("%s", str);
|
||||
nmc_print("%s", str);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
|
|
@ -1310,9 +1311,9 @@ device_overview(NmCli *nmc, NMDevice *device)
|
|||
if (nm_device_get_state(device) == NM_DEVICE_STATE_DISCONNECTED) {
|
||||
if (activatable) {
|
||||
if (activatable->len == 1)
|
||||
g_print("\t%d %s\n", activatable->len, _("connection available"));
|
||||
nmc_print("\t%d %s\n", activatable->len, _("connection available"));
|
||||
else if (activatable->len > 1)
|
||||
g_print("\t%d %s\n", activatable->len, _("connections available"));
|
||||
nmc_print("\t%d %s\n", activatable->len, _("connections available"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1401,7 +1402,7 @@ device_overview(NmCli *nmc, NMDevice *device)
|
|||
|
||||
if (outbuf->len >= 2) {
|
||||
g_string_truncate(outbuf, outbuf->len - 2);
|
||||
g_print("\t%s\n", outbuf->str);
|
||||
nmc_print("\t%s\n", outbuf->str);
|
||||
}
|
||||
|
||||
g_string_free(outbuf, TRUE);
|
||||
|
|
@ -1428,7 +1429,7 @@ ac_overview(NmCli *nmc, NMActiveConnection *ac)
|
|||
g_string_append_printf(outbuf, "%s, ", _("ip6 default"));
|
||||
if (outbuf->len >= 2) {
|
||||
g_string_truncate(outbuf, outbuf->len - 2);
|
||||
g_print("\t%s\n", outbuf->str);
|
||||
nmc_print("\t%s\n", outbuf->str);
|
||||
}
|
||||
|
||||
ip = nm_active_connection_get_ip4_config(ac);
|
||||
|
|
@ -1439,7 +1440,7 @@ ac_overview(NmCli *nmc, NMActiveConnection *ac)
|
|||
p = nm_ip_config_get_addresses(ip);
|
||||
for (i = 0; i < p->len; i++) {
|
||||
NMIPAddress *a = p->pdata[i];
|
||||
g_print("\tinet4 %s/%d\n", nm_ip_address_get_address(a), nm_ip_address_get_prefix(a));
|
||||
nmc_print("\tinet4 %s/%d\n", nm_ip_address_get_address(a), nm_ip_address_get_prefix(a));
|
||||
}
|
||||
|
||||
p = nm_ip_config_get_routes(ip);
|
||||
|
|
@ -1449,7 +1450,7 @@ ac_overview(NmCli *nmc, NMActiveConnection *ac)
|
|||
nm_str_buf_reset(&str);
|
||||
_nm_ip_route_to_string(a, &str);
|
||||
|
||||
g_print("\troute4 %s\n", nm_str_buf_get_str(&str));
|
||||
nmc_print("\troute4 %s\n", nm_str_buf_get_str(&str));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1461,7 +1462,7 @@ ac_overview(NmCli *nmc, NMActiveConnection *ac)
|
|||
p = nm_ip_config_get_addresses(ip);
|
||||
for (i = 0; i < p->len; i++) {
|
||||
NMIPAddress *a = p->pdata[i];
|
||||
g_print("\tinet6 %s/%d\n", nm_ip_address_get_address(a), nm_ip_address_get_prefix(a));
|
||||
nmc_print("\tinet6 %s/%d\n", nm_ip_address_get_address(a), nm_ip_address_get_prefix(a));
|
||||
}
|
||||
|
||||
p = nm_ip_config_get_routes(ip);
|
||||
|
|
@ -1471,7 +1472,7 @@ ac_overview(NmCli *nmc, NMActiveConnection *ac)
|
|||
nm_str_buf_reset(&str);
|
||||
_nm_ip_route_to_string(a, &str);
|
||||
|
||||
g_print("\troute6 %s\n", nm_str_buf_get_str(&str));
|
||||
nmc_print("\troute6 %s\n", nm_str_buf_get_str(&str));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1509,11 +1510,11 @@ nmc_command_func_overview(const NMCCommand *cmd, NmCli *nmc, int argc, const cha
|
|||
color,
|
||||
_("%s VPN connection"),
|
||||
nm_active_connection_get_id(ac));
|
||||
g_print("%s\n", tmp);
|
||||
nmc_print("%s\n", tmp);
|
||||
g_free(tmp);
|
||||
|
||||
ac_overview(nmc, ac);
|
||||
g_print("\n");
|
||||
nmc_print("\n");
|
||||
}
|
||||
|
||||
devices = nmc_get_devices_sorted(nmc->client);
|
||||
|
|
@ -1541,16 +1542,16 @@ nmc_command_func_overview(const NMCCommand *cmd, NmCli *nmc, int argc, const cha
|
|||
nm_device_get_iface(device),
|
||||
gettext(nmc_device_state_to_string_with_external(device)));
|
||||
}
|
||||
g_print("%s\n", tmp);
|
||||
nmc_print("%s\n", tmp);
|
||||
g_free(tmp);
|
||||
|
||||
if (nm_device_get_description(device) && strcmp(nm_device_get_description(device), ""))
|
||||
g_print("\t\"%s\"\n", nm_device_get_description(device));
|
||||
nmc_print("\t\"%s\"\n", nm_device_get_description(device));
|
||||
|
||||
device_overview(nmc, device);
|
||||
if (ac)
|
||||
ac_overview(nmc, ac);
|
||||
g_print("\n");
|
||||
nmc_print("\n");
|
||||
}
|
||||
g_free(devices);
|
||||
|
||||
|
|
@ -1566,31 +1567,32 @@ nmc_command_func_overview(const NMCCommand *cmd, NmCli *nmc, int argc, const cha
|
|||
}
|
||||
|
||||
if (i == 0)
|
||||
g_print("DNS configuration:\n");
|
||||
nmc_print("DNS configuration:\n");
|
||||
|
||||
tmp = g_strjoinv(" ", (char **) strv);
|
||||
g_print("\tservers: %s\n", tmp);
|
||||
nmc_print("\tservers: %s\n", tmp);
|
||||
g_free(tmp);
|
||||
|
||||
strv = nm_dns_entry_get_domains(dns);
|
||||
if (strv && strv[0]) {
|
||||
tmp = g_strjoinv(" ", (char **) strv);
|
||||
g_print("\tdomains: %s\n", tmp);
|
||||
nmc_print("\tdomains: %s\n", tmp);
|
||||
g_free(tmp);
|
||||
}
|
||||
|
||||
if (nm_dns_entry_get_interface(dns))
|
||||
g_print("\tinterface: %s\n", nm_dns_entry_get_interface(dns));
|
||||
nmc_print("\tinterface: %s\n", nm_dns_entry_get_interface(dns));
|
||||
|
||||
if (nm_dns_entry_get_vpn(dns))
|
||||
g_print("\ttype: vpn\n");
|
||||
g_print("\n");
|
||||
nmc_print("\ttype: vpn\n");
|
||||
nmc_print("\n");
|
||||
}
|
||||
|
||||
g_print(_("Use \"nmcli device show\" to get complete information about known devices and\n"
|
||||
"\"nmcli connection show\" to get an overview on active connection profiles.\n"
|
||||
"\n"
|
||||
"Consult nmcli(1) and nmcli-examples(7) manual pages for complete usage details.\n"));
|
||||
nmc_print(
|
||||
_("Use \"nmcli device show\" to get complete information about known devices and\n"
|
||||
"\"nmcli connection show\" to get an overview on active connection profiles.\n"
|
||||
"\n"
|
||||
"Consult nmcli(1) and nmcli-examples(7) manual pages for complete usage details.\n"));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -166,13 +166,13 @@ complete_one(gpointer key, gpointer value, gpointer user_data)
|
|||
/* value prefix was not a standalone argument,
|
||||
* it was part of --option=<value> argument.
|
||||
* Repeat the part leading to "=". */
|
||||
g_print("%s=", option);
|
||||
nmc_print("%s=", option);
|
||||
}
|
||||
g_print("%.*s%s%s\n",
|
||||
(int) (last - prefix),
|
||||
prefix,
|
||||
name,
|
||||
strcmp(last, name) == 0 ? "," : "");
|
||||
nmc_print("%.*s%s%s\n",
|
||||
(int) (last - prefix),
|
||||
prefix,
|
||||
name,
|
||||
strcmp(last, name) == 0 ? "," : "");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -228,9 +228,9 @@ complete_option_with_value(const char *option, const char *prefix, ...)
|
|||
/* value prefix was not a standalone argument,
|
||||
* it was part of --option=<value> argument.
|
||||
* Repeat the part leading to "=". */
|
||||
g_print("%s=", option);
|
||||
nmc_print("%s=", option);
|
||||
}
|
||||
g_print("%s\n", candidate);
|
||||
nmc_print("%s\n", candidate);
|
||||
}
|
||||
}
|
||||
va_end(args);
|
||||
|
|
@ -239,7 +239,7 @@ complete_option_with_value(const char *option, const char *prefix, ...)
|
|||
static void
|
||||
usage(void)
|
||||
{
|
||||
g_printerr(_(
|
||||
nmc_printerr(_(
|
||||
"Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }\n"
|
||||
"\n"
|
||||
"OPTIONS\n"
|
||||
|
|
@ -889,7 +889,7 @@ process_command_line(NmCli *nmc, int argc, char **argv_orig)
|
|||
nmc->timeout = (int) timeout;
|
||||
} else if (matches_arg(nmc, &argc, &argv, "-version", NULL)) {
|
||||
if (!nmc->complete)
|
||||
g_print(_("nmcli tool, version %s\n"), NMCLI_VERSION);
|
||||
nmc_print(_("nmcli tool, version %s\n"), NMCLI_VERSION);
|
||||
return NMC_RESULT_SUCCESS;
|
||||
} else if (matches_arg(nmc, &argc, &argv, "-help", NULL)) {
|
||||
if (!nmc->complete)
|
||||
|
|
@ -1047,7 +1047,7 @@ main(int argc, char *argv[])
|
|||
nm_cli.return_value = NMC_RESULT_SUCCESS;
|
||||
} else if (nm_cli.return_value != NMC_RESULT_SUCCESS) {
|
||||
/* Print result descripting text */
|
||||
g_printerr("%s\n", nm_cli.return_text->str);
|
||||
nmc_printerr("%s\n", nm_cli.return_text->str);
|
||||
}
|
||||
|
||||
nmc_cleanup(&nm_cli);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "libnmc-base/nm-polkit-listener.h"
|
||||
#include "common.h"
|
||||
#include "utils.h"
|
||||
|
||||
static char *
|
||||
polkit_read_passwd(gpointer instance,
|
||||
|
|
@ -23,8 +24,8 @@ polkit_read_passwd(gpointer instance,
|
|||
{
|
||||
NmCli *nmc = user_data;
|
||||
|
||||
g_print("%s\n", message);
|
||||
g_print("(action_id: %s)\n", action_id);
|
||||
nmc_print("%s\n", message);
|
||||
nmc_print("(action_id: %s)\n", action_id);
|
||||
|
||||
/* Ask user for polkit authorization password */
|
||||
if (user) {
|
||||
|
|
@ -36,7 +37,7 @@ polkit_read_passwd(gpointer instance,
|
|||
static void
|
||||
polkit_error(gpointer instance, const char *error, gpointer user_data)
|
||||
{
|
||||
g_printerr(_("Error: polkit agent failed: %s\n"), error);
|
||||
nmc_printerr(_("Error: polkit agent failed: %s\n"), error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
@ -89,7 +90,7 @@ nmc_start_polkit_agent_start_try(NmCli *nmc)
|
|||
return TRUE;
|
||||
|
||||
if (!nmc_polkit_agent_init(nmc, FALSE, &error)) {
|
||||
g_printerr(_("Warning: polkit agent initialization failed: %s\n"), error->message);
|
||||
nmc_printerr(_("Warning: polkit agent initialization failed: %s\n"), error->message);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -246,10 +246,10 @@ wireless_band_channel_changed_cb(GObject *object, GParamSpec *pspec, gpointer us
|
|||
|
||||
mode = nm_setting_wireless_get_mode(NM_SETTING_WIRELESS(object));
|
||||
if (!mode || !*mode || strcmp(mode, NM_SETTING_WIRELESS_MODE_INFRA) == 0) {
|
||||
g_print(_("Warning: %s.%s set to '%s', but it might be ignored in infrastructure mode\n"),
|
||||
nm_setting_get_name(NM_SETTING(s_wireless)),
|
||||
g_param_spec_get_name(pspec),
|
||||
value);
|
||||
nmc_print(_("Warning: %s.%s set to '%s', but it might be ignored in infrastructure mode\n"),
|
||||
nm_setting_get_name(NM_SETTING(s_wireless)),
|
||||
g_param_spec_get_name(pspec),
|
||||
value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -266,9 +266,9 @@ connection_master_changed_cb(GObject *object, GParamSpec *pspec, gpointer user_d
|
|||
s_ipv4 = nm_connection_get_setting_by_name(connection, NM_SETTING_IP4_CONFIG_SETTING_NAME);
|
||||
s_ipv6 = nm_connection_get_setting_by_name(connection, NM_SETTING_IP6_CONFIG_SETTING_NAME);
|
||||
if (s_ipv4 || s_ipv6) {
|
||||
g_print(_("Warning: setting %s.%s requires removing ipv4 and ipv6 settings\n"),
|
||||
nm_setting_get_name(NM_SETTING(s_con)),
|
||||
g_param_spec_get_name(pspec));
|
||||
nmc_print(_("Warning: setting %s.%s requires removing ipv4 and ipv6 settings\n"),
|
||||
nm_setting_get_name(NM_SETTING(s_con)),
|
||||
g_param_spec_get_name(pspec));
|
||||
tmp_str = nmc_get_user_input(_("Do you want to remove them? [yes] "));
|
||||
if (!tmp_str || matches(tmp_str, "yes")) {
|
||||
if (s_ipv4)
|
||||
|
|
@ -373,8 +373,8 @@ _set_fcn_precheck_connection_secondaries(NMClient *client,
|
|||
if (nm_utils_is_uuid(*iter)) {
|
||||
con = nmc_find_connection(connections, "uuid", *iter, NULL, FALSE);
|
||||
if (!con) {
|
||||
g_print(_("Warning: %s is not an UUID of any existing connection profile\n"),
|
||||
*iter);
|
||||
nmc_print(_("Warning: %s is not an UUID of any existing connection profile\n"),
|
||||
*iter);
|
||||
} else {
|
||||
/* Currently, NM only supports VPN connections as secondaries */
|
||||
if (!nm_connection_is_type(con, NM_SETTING_VPN_SETTING_NAME)) {
|
||||
|
|
@ -431,13 +431,13 @@ _env_warn_fcn_handle(
|
|||
|
||||
switch (warn_level) {
|
||||
case NM_META_ENV_WARN_LEVEL_WARN:
|
||||
g_print(_("Warning: %s\n"), m);
|
||||
nmc_print(_("Warning: %s\n"), m);
|
||||
return;
|
||||
case NM_META_ENV_WARN_LEVEL_INFO:
|
||||
g_print(_("Info: %s\n"), m);
|
||||
nmc_print(_("Info: %s\n"), m);
|
||||
return;
|
||||
}
|
||||
g_print(_("Error: %s\n"), m);
|
||||
nmc_print(_("Error: %s\n"), m);
|
||||
}
|
||||
|
||||
static NMDevice *const *
|
||||
|
|
|
|||
|
|
@ -346,7 +346,7 @@ ssid_to_hex(const char *str, gsize len)
|
|||
void
|
||||
nmc_terminal_erase_line(void)
|
||||
{
|
||||
/* We intentionally use printf(), not g_print() here, to ensure that
|
||||
/* We intentionally use printf(), not nmc_print() here, to ensure that
|
||||
* GLib doesn't mistakenly try to convert the string.
|
||||
*/
|
||||
printf("\33[2K\r");
|
||||
|
|
@ -365,7 +365,7 @@ nmc_terminal_show_progress(const char *str)
|
|||
const char slashes[4] = {'|', '/', '-', '\\'};
|
||||
|
||||
nmc_terminal_erase_line();
|
||||
g_print("%c %s", slashes[idx++], str ?: "");
|
||||
nmc_print("%c %s", slashes[idx++], str ?: "");
|
||||
fflush(stdout);
|
||||
if (idx == 4)
|
||||
idx = 0;
|
||||
|
|
@ -467,7 +467,7 @@ nmc_get_user_input(const char *ask_str)
|
|||
size_t line_ln = 0;
|
||||
ssize_t num;
|
||||
|
||||
g_print("%s", ask_str);
|
||||
nmc_print("%s", ask_str);
|
||||
num = getline(&line, &line_ln, stdin);
|
||||
|
||||
/* Remove newline from the string */
|
||||
|
|
@ -1251,9 +1251,9 @@ _print_do(const NmcConfig *nmc_config,
|
|||
|
||||
width1 = strlen(header_name);
|
||||
width2 = nmc_string_screen_width(header_name, NULL);
|
||||
g_print("%s\n", line);
|
||||
g_print("%*s\n", (table_width + width2) / 2 + width1 - width2, header_name);
|
||||
g_print("%s\n", line);
|
||||
nmc_print("%s\n", line);
|
||||
nmc_print("%*s\n", (table_width + width2) / 2 + width1 - width2, header_name);
|
||||
nmc_print("%s\n", line);
|
||||
}
|
||||
|
||||
str = !nmc_config->multiline_output ? g_string_sized_new(100) : NULL;
|
||||
|
|
@ -1283,14 +1283,14 @@ _print_do(const NmcConfig *nmc_config,
|
|||
|
||||
if (str->len)
|
||||
g_string_truncate(str, str->len - 1); /* Chop off last column separator */
|
||||
g_print("%s\n", str->str);
|
||||
nmc_print("%s\n", str->str);
|
||||
g_string_truncate(str, 0);
|
||||
|
||||
/* Print horizontal separator */
|
||||
if (nmc_config->print_output == NMC_PRINT_PRETTY) {
|
||||
gs_free char *line = NULL;
|
||||
|
||||
g_print("%s\n", (line = g_strnfill(table_width, '-')));
|
||||
nmc_print("%s\n", (line = g_strnfill(table_width, '-')));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1332,12 +1332,12 @@ _print_do(const NmcConfig *nmc_config,
|
|||
prefix = g_strdup_printf("%s:", cell->header_cell->title);
|
||||
width1 = strlen(prefix);
|
||||
width2 = nmc_string_screen_width(prefix, NULL);
|
||||
g_print("%-*s%s\n",
|
||||
(int) (nmc_config->print_output == NMC_PRINT_TERSE
|
||||
? 0
|
||||
: ML_VALUE_INDENT + width1 - width2),
|
||||
prefix,
|
||||
text);
|
||||
nmc_print("%-*s%s\n",
|
||||
(int) (nmc_config->print_output == NMC_PRINT_TERSE
|
||||
? 0
|
||||
: ML_VALUE_INDENT + width1 - width2),
|
||||
prefix,
|
||||
text);
|
||||
} else {
|
||||
nm_assert(str);
|
||||
if (nmc_config->print_output == NMC_PRINT_TERSE) {
|
||||
|
|
@ -1373,7 +1373,7 @@ _print_do(const NmcConfig *nmc_config,
|
|||
if (!nmc_config->multiline_output) {
|
||||
if (str->len)
|
||||
g_string_truncate(str, str->len - 1); /* Chop off last column separator */
|
||||
g_print("%s\n", str->str);
|
||||
nmc_print("%s\n", str->str);
|
||||
|
||||
g_string_truncate(str, 0);
|
||||
}
|
||||
|
|
@ -1381,7 +1381,7 @@ _print_do(const NmcConfig *nmc_config,
|
|||
if (nmc_config->print_output == NMC_PRINT_PRETTY && nmc_config->multiline_output) {
|
||||
gs_free char *line = NULL;
|
||||
|
||||
g_print("%s\n", (line = g_strnfill(ML_HEADER_WIDTH, '-')));
|
||||
nmc_print("%s\n", (line = g_strnfill(ML_HEADER_WIDTH, '-')));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1458,7 +1458,7 @@ nmc_terminal_spawn_pager(const NmcConfig *nmc_config)
|
|||
|
||||
if (pipe(fd) == -1) {
|
||||
errsv = errno;
|
||||
g_printerr(_("Failed to create pager pipe: %s\n"), nm_strerror_native(errsv));
|
||||
nmc_printerr(_("Failed to create pager pipe: %s\n"), nm_strerror_native(errsv));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1471,7 +1471,7 @@ nmc_terminal_spawn_pager(const NmcConfig *nmc_config)
|
|||
pager_pid = fork();
|
||||
if (pager_pid == -1) {
|
||||
errsv = errno;
|
||||
g_printerr(_("Failed to fork pager: %s\n"), nm_strerror_native(errsv));
|
||||
nmc_printerr(_("Failed to fork pager: %s\n"), nm_strerror_native(errsv));
|
||||
nm_close(fd[0]);
|
||||
nm_close(fd[1]);
|
||||
return 0;
|
||||
|
|
@ -1515,11 +1515,11 @@ nmc_terminal_spawn_pager(const NmcConfig *nmc_config)
|
|||
/* Return in the parent */
|
||||
if (dup2(fd[1], STDOUT_FILENO) < 0) {
|
||||
errsv = errno;
|
||||
g_printerr(_("Failed to duplicate pager pipe: %s\n"), nm_strerror_native(errsv));
|
||||
nmc_printerr(_("Failed to duplicate pager pipe: %s\n"), nm_strerror_native(errsv));
|
||||
}
|
||||
if (dup2(fd[1], STDERR_FILENO) < 0) {
|
||||
errsv = errno;
|
||||
g_printerr(_("Failed to duplicate pager pipe: %s\n"), nm_strerror_native(errsv));
|
||||
nmc_printerr(_("Failed to duplicate pager pipe: %s\n"), nm_strerror_native(errsv));
|
||||
}
|
||||
|
||||
nm_close(fd[0]);
|
||||
|
|
@ -1608,9 +1608,9 @@ print_required_fields(const NmcConfig *nmc_config,
|
|||
|
||||
width1 = strlen(header_name);
|
||||
width2 = nmc_string_screen_width(header_name, NULL);
|
||||
g_print("%s\n", line);
|
||||
g_print("%*s\n", (table_width + width2) / 2 + width1 - width2, header_name);
|
||||
g_print("%s\n", line);
|
||||
nmc_print("%s\n", line);
|
||||
nmc_print("%*s\n", (table_width + width2) / 2 + width1 - width2, header_name);
|
||||
nmc_print("%s\n", line);
|
||||
}
|
||||
|
||||
if (main_header_only)
|
||||
|
|
@ -1656,12 +1656,12 @@ print_required_fields(const NmcConfig *nmc_config,
|
|||
j);
|
||||
width1 = strlen(tmp);
|
||||
width2 = nmc_string_screen_width(tmp, NULL);
|
||||
g_print("%-*s%s\n",
|
||||
(int) (nmc_config->print_output == NMC_PRINT_TERSE
|
||||
? 0
|
||||
: ML_VALUE_INDENT + width1 - width2),
|
||||
tmp,
|
||||
print_val);
|
||||
nmc_print("%-*s%s\n",
|
||||
(int) (nmc_config->print_output == NMC_PRINT_TERSE
|
||||
? 0
|
||||
: ML_VALUE_INDENT + width1 - width2),
|
||||
tmp,
|
||||
print_val);
|
||||
}
|
||||
} else {
|
||||
gs_free char *val_to_free = NULL;
|
||||
|
|
@ -1681,18 +1681,18 @@ print_required_fields(const NmcConfig *nmc_config,
|
|||
nm_meta_abstract_info_get_name(field_values[idx].info, FALSE));
|
||||
width1 = strlen(tmp);
|
||||
width2 = nmc_string_screen_width(tmp, NULL);
|
||||
g_print("%-*s%s\n",
|
||||
(int) (nmc_config->print_output == NMC_PRINT_TERSE
|
||||
? 0
|
||||
: ML_VALUE_INDENT + width1 - width2),
|
||||
tmp,
|
||||
print_val);
|
||||
nmc_print("%-*s%s\n",
|
||||
(int) (nmc_config->print_output == NMC_PRINT_TERSE
|
||||
? 0
|
||||
: ML_VALUE_INDENT + width1 - width2),
|
||||
tmp,
|
||||
print_val);
|
||||
}
|
||||
}
|
||||
if (nmc_config->print_output == NMC_PRINT_PRETTY) {
|
||||
gs_free char *line = NULL;
|
||||
|
||||
g_print("%s\n", (line = g_strnfill(ML_HEADER_WIDTH, '-')));
|
||||
nmc_print("%s\n", (line = g_strnfill(ML_HEADER_WIDTH, '-')));
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
@ -1749,13 +1749,13 @@ print_required_fields(const NmcConfig *nmc_config,
|
|||
g_string_prepend(str, (indent_str = g_strnfill(indent, ' ')));
|
||||
}
|
||||
|
||||
g_print("%s\n", str->str);
|
||||
nmc_print("%s\n", str->str);
|
||||
|
||||
/* Print horizontal separator */
|
||||
if (nmc_config->print_output == NMC_PRINT_PRETTY && field_names) {
|
||||
gs_free char *line = NULL;
|
||||
|
||||
g_print("%s\n", (line = g_strnfill(table_width, '-')));
|
||||
nmc_print("%s\n", (line = g_strnfill(table_width, '-')));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue