summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-09-27 11:49:52 -0400
committerDan Winship <danw@gnome.org>2014-09-27 11:49:52 -0400
commitd83881a64125cd7d398834eec6a31ce7ee8d006f (patch)
tree31baa9431e1db412f48c8fce20f035beed6e9eaf
parentdf230fc2c635e2b47788f008737a9e84b415f5e6 (diff)
parente684f363654892754a12ec172a14689c425dad88 (diff)
tui, cli: improve printing of Wi-Fi strength bars (rh #1131491)
-rw-r--r--clients/cli/connections.c1010
-rw-r--r--clients/cli/devices.c231
-rw-r--r--clients/cli/network-manager.c161
-rw-r--r--clients/cli/nmcli.c61
-rw-r--r--clients/cli/settings.c35
-rw-r--r--clients/cli/utils.c38
-rw-r--r--clients/tui/nmt-connect-connection-list.c31
-rw-r--r--libnm-core/nm-utils.c60
-rw-r--r--libnm-core/nm-utils.h2
-rw-r--r--libnm/libnm.ver1
10 files changed, 811 insertions, 819 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 6160b94f36..a7e71c705b 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -245,232 +245,222 @@ static char *gen_connection_types (const char *text, int state);
static void
usage (void)
{
- fprintf (stderr,
- _("Usage: nmcli connection { COMMAND | help }\n\n"
- "COMMAND := { show | up | down | add | modify | edit | delete | reload | load }\n\n"
- " show [--active] [[id | uuid | path | apath] <ID>] ...\n\n"
+ g_printerr (_("Usage: nmcli connection { COMMAND | help }\n\n"
+ "COMMAND := { show | up | down | add | modify | edit | delete | reload | load }\n\n"
+ " show [--active] [[id | uuid | path | apath] <ID>] ...\n\n"
#if WITH_WIMAX
- " up [[id | uuid | path] <ID>] [ifname <ifname>] [ap <BSSID>] [nsp <name>]\n\n"
+ " up [[id | uuid | path] <ID>] [ifname <ifname>] [ap <BSSID>] [nsp <name>]\n\n"
#else
- " up [[id | uuid | path] <ID>] [ifname <ifname>] [ap <BSSID>]\n\n"
+ " up [[id | uuid | path] <ID>] [ifname <ifname>] [ap <BSSID>]\n\n"
#endif
- " down [id | uuid | path | apath] <ID>\n\n"
- " add COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS IP_OPTIONS\n\n"
- " modify [--temporary] [id | uuid | path] <ID> ([+|-]<setting>.<property> <value>)+\n\n"
- " edit [id | uuid | path] <ID>\n"
- " edit [type <new_con_type>] [con-name <new_con_name>]\n\n"
- " delete [id | uuid | path] <ID>\n\n"
- " reload\n\n"
- " load <filename> [ <filename>... ]\n\n"));
+ " down [id | uuid | path | apath] <ID>\n\n"
+ " add COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS IP_OPTIONS\n\n"
+ " modify [--temporary] [id | uuid | path] <ID> ([+|-]<setting>.<property> <value>)+\n\n"
+ " edit [id | uuid | path] <ID>\n"
+ " edit [type <new_con_type>] [con-name <new_con_name>]\n\n"
+ " delete [id | uuid | path] <ID>\n\n"
+ " reload\n\n"
+ " load <filename> [ <filename>... ]\n\n"));
}
static void
usage_connection_show (void)
{
- fprintf (stderr,
- _("Usage: nmcli connection show { ARGUMENTS | help }\n"
- "\n"
- "ARGUMENTS := [--active]\n"
- "\n"
- "List in-memory and on-disk connection profiles, some of which may also be\n"
- "active if a device is using that connection profile. Without a parameter, all\n"
- "profiles are listed. When --active option is specified, only the active\n"
- "profiles are shown.\n"
- "\n"
- "ARGUMENTS := [--active] [id | uuid | path | apath] <ID> ...\n"
- "\n"
- "Show details for specified connections. By default, both static configuration\n"
- "and active connection data are displayed. It is possible to filter the output\n"
- "using global '--fields' option. Refer to the manual page for more information.\n"
- "When --active option is specified, only the active profiles are taken into\n"
- "account.\n"));
+ g_printerr (_("Usage: nmcli connection show { ARGUMENTS | help }\n"
+ "\n"
+ "ARGUMENTS := [--active]\n"
+ "\n"
+ "List in-memory and on-disk connection profiles, some of which may also be\n"
+ "active if a device is using that connection profile. Without a parameter, all\n"
+ "profiles are listed. When --active option is specified, only the active\n"
+ "profiles are shown.\n"
+ "\n"
+ "ARGUMENTS := [--active] [id | uuid | path | apath] <ID> ...\n"
+ "\n"
+ "Show details for specified connections. By default, both static configuration\n"
+ "and active connection data are displayed. It is possible to filter the output\n"
+ "using global '--fields' option. Refer to the manual page for more information.\n"
+ "When --active option is specified, only the active profiles are taken into\n"
+ "account.\n"));
}
static void
usage_connection_up (void)
{
- fprintf (stderr,
- _("Usage: nmcli connection up { ARGUMENTS | help }\n"
- "\n"
- "ARGUMENTS := [id | uuid | path] <ID> [ifname <ifname>] [ap <BSSID>] [nsp <name>]\n"
- "\n"
- "Activate a connection on a device. The profile to activate is identified by its\n"
- "name, UUID or D-Bus path.\n"
- "\n"
- "ARGUMENTS := ifname <ifname> [ap <BSSID>] [nsp <name>]\n"
- "\n"
- "Activate a device with a connection. The connection profile is selected\n"
- "automatically by NetworkManager.\n"
- "\n"
- "ifname - specifies the device to active the connection on\n"
- "ap - specifies AP to connect to (only valid for Wi-Fi)\n"
- "nsp - specifies NSP to connect to (only valid for WiMAX)\n\n"));
+ g_printerr (_("Usage: nmcli connection up { ARGUMENTS | help }\n"
+ "\n"
+ "ARGUMENTS := [id | uuid | path] <ID> [ifname <ifname>] [ap <BSSID>] [nsp <name>]\n"
+ "\n"
+ "Activate a connection on a device. The profile to activate is identified by its\n"
+ "name, UUID or D-Bus path.\n"
+ "\n"
+ "ARGUMENTS := ifname <ifname> [ap <BSSID>] [nsp <name>]\n"
+ "\n"
+ "Activate a device with a connection. The connection profile is selected\n"
+ "automatically by NetworkManager.\n"
+ "\n"
+ "ifname - specifies the device to active the connection on\n"
+ "ap - specifies AP to connect to (only valid for Wi-Fi)\n"
+ "nsp - specifies NSP to connect to (only valid for WiMAX)\n\n"));
}
static void
usage_connection_down (void)
{
- fprintf (stderr,
- _("Usage: nmcli connection down { ARGUMENTS | help }\n"
- "\n"
- "ARGUMENTS := [id | uuid | path | apath] <ID>\n"
- "\n"
- "Deactivate a connection from a device (without preventing the device from\n"
- "further auto-activation). The profile to deactivate is identified by its name,\n"
- "UUID or D-Bus path.\n\n"));
+ g_printerr (_("Usage: nmcli connection down { ARGUMENTS | help }\n"
+ "\n"
+ "ARGUMENTS := [id | uuid | path | apath] <ID>\n"
+ "\n"
+ "Deactivate a connection from a device (without preventing the device from\n"
+ "further auto-activation). The profile to deactivate is identified by its name,\n"
+ "UUID or D-Bus path.\n\n"));
}
static void
usage_connection_add (void)
{
- fprintf (stderr,
- _("Usage: nmcli connection add { ARGUMENTS | help }\n"
- "\n"
- "ARGUMENTS := COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS IP_OPTIONS\n\n"
- " COMMON_OPTIONS:\n"
- " type <type>\n"
- " ifname <interface name> | \"*\"\n"
- " [con-name <connection name>]\n"
- " [autoconnect yes|no]\n\n"
- " [save yes|no]\n\n"
- " TYPE_SPECIFIC_OPTIONS:\n"
- " ethernet: [mac <MAC address>]\n"
- " [cloned-mac <cloned MAC address>]\n"
- " [mtu <MTU>]\n\n"
- " wifi: ssid <SSID>\n"
- " [mac <MAC address>]\n"
- " [cloned-mac <cloned MAC address>]\n"
- " [mtu <MTU>]\n\n"
- " wimax: [mac <MAC address>]\n"
- " [nsp <NSP>]\n\n"
- " pppoe: username <PPPoE username>\n"
- " [password <PPPoE password>]\n"
- " [service <PPPoE service name>]\n"
- " [mtu <MTU>]\n"
- " [mac <MAC address>]\n\n"
- " gsm: apn <APN>\n"
- " [user <username>]\n"
- " [password <password>]\n\n"
- " cdma: [user <username>]\n"
- " [password <password>]\n\n"
- " infiniband: [mac <MAC address>]\n"
- " [mtu <MTU>]\n"
- " [transport-mode datagram | connected]\n"
- " [parent <ifname>]\n"
- " [p-key <IPoIB P_Key>]\n\n"
- " bluetooth: [addr <bluetooth address>]\n"
- " [bt-type panu|dun-gsm|dun-cdma]\n\n"
- " vlan: dev <parent device (connection UUID, ifname, or MAC)>\n"
- " id <VLAN ID>\n"
- " [flags <VLAN flags>]\n"
- " [ingress <ingress priority mapping>]\n"
- " [egress <egress priority mapping>]\n"
- " [mtu <MTU>]\n\n"
- " bond: [mode balance-rr (0) | active-backup (1) | balance-xor (2) | broadcast (3) |\n"
- " 802.3ad (4) | balance-tlb (5) | balance-alb (6)]\n"
- " [primary <ifname>]\n"
- " [miimon <num>]\n"
- " [downdelay <num>]\n"
- " [updelay <num>]\n"
- " [arp-interval <num>]\n"
- " [arp-ip-target <num>]\n\n"
- " bond-slave: master <master (ifname, or connection UUID or name)>\n\n"
- " team: [config <file>|<raw JSON data>]\n\n"
- " team-slave: master <master (ifname, or connection UUID or name)>\n"
- " [config <file>|<raw JSON data>]\n\n"
- " bridge: [stp yes|no]\n"
- " [priority <num>]\n"
- " [forward-delay <2-30>]\n"
- " [hello-time <1-10>]\n"
- " [max-age <6-40>]\n"
- " [ageing-time <0-1000000>]\n"
- " [mac <MAC address>]\n\n"
- " bridge-slave: master <master (ifname, or connection UUID or name)>\n"
- " [priority <0-63>]\n"
- " [path-cost <1-65535>]\n"
- " [hairpin yes|no]\n\n"
- " vpn: vpn-type vpnc|openvpn|pptp|openconnect|openswan|libreswan|ssh|l2tp|iodine|...\n"
- " [user <username>]\n\n"
- " olpc-mesh: ssid <SSID>\n"
- " [channel <1-13>]\n"
- " [dhcp-anycast <MAC address>]\n\n"
- " IP_OPTIONS:\n"
- " [ip4 <IPv4 address>] [gw4 <IPv4 gateway>]\n"
- " [ip6 <IPv6 address>] [gw6 <IPv6 gateway>]\n\n"));
+ g_printerr (_("Usage: nmcli connection add { ARGUMENTS | help }\n"
+ "\n"
+ "ARGUMENTS := COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS IP_OPTIONS\n\n"
+ " COMMON_OPTIONS:\n"
+ " type <type>\n"
+ " ifname <interface name> | \"*\"\n"
+ " [con-name <connection name>]\n"
+ " [autoconnect yes|no]\n\n"
+ " [save yes|no]\n\n"
+ " TYPE_SPECIFIC_OPTIONS:\n"
+ " ethernet: [mac <MAC address>]\n"
+ " [cloned-mac <cloned MAC address>]\n"
+ " [mtu <MTU>]\n\n"
+ " wifi: ssid <SSID>\n"
+ " [mac <MAC address>]\n"
+ " [cloned-mac <cloned MAC address>]\n"
+ " [mtu <MTU>]\n\n"
+ " wimax: [mac <MAC address>]\n"
+ " [nsp <NSP>]\n\n"
+ " pppoe: username <PPPoE username>\n"
+ " [password <PPPoE password>]\n"
+ " [service <PPPoE service name>]\n"
+ " [mtu <MTU>]\n"
+ " [mac <MAC address>]\n\n"
+ " gsm: apn <APN>\n"
+ " [user <username>]\n"
+ " [password <password>]\n\n"
+ " cdma: [user <username>]\n"
+ " [password <password>]\n\n"
+ " infiniband: [mac <MAC address>]\n"
+ " [mtu <MTU>]\n"
+ " [transport-mode datagram | connected]\n"
+ " [parent <ifname>]\n"
+ " [p-key <IPoIB P_Key>]\n\n"
+ " bluetooth: [addr <bluetooth address>]\n"
+ " [bt-type panu|dun-gsm|dun-cdma]\n\n"
+ " vlan: dev <parent device (connection UUID, ifname, or MAC)>\n"
+ " id <VLAN ID>\n"
+ " [flags <VLAN flags>]\n"
+ " [ingress <ingress priority mapping>]\n"
+ " [egress <egress priority mapping>]\n"
+ " [mtu <MTU>]\n\n"
+ " bond: [mode balance-rr (0) | active-backup (1) | balance-xor (2) | broadcast (3) |\n"
+ " 802.3ad (4) | balance-tlb (5) | balance-alb (6)]\n"
+ " [primary <ifname>]\n"
+ " [miimon <num>]\n"
+ " [downdelay <num>]\n"
+ " [updelay <num>]\n"
+ " [arp-interval <num>]\n"
+ " [arp-ip-target <num>]\n\n"
+ " bond-slave: master <master (ifname, or connection UUID or name)>\n\n"
+ " team: [config <file>|<raw JSON data>]\n\n"
+ " team-slave: master <master (ifname, or connection UUID or name)>\n"
+ " [config <file>|<raw JSON data>]\n\n"
+ " bridge: [stp yes|no]\n"
+ " [priority <num>]\n"
+ " [forward-delay <2-30>]\n"
+ " [hello-time <1-10>]\n"
+ " [max-age <6-40>]\n"
+ " [ageing-time <0-1000000>]\n"
+ " [mac <MAC address>]\n\n"
+ " bridge-slave: master <master (ifname, or connection UUID or name)>\n"
+ " [priority <0-63>]\n"
+ " [path-cost <1-65535>]\n"
+ " [hairpin yes|no]\n\n"
+ " vpn: vpn-type vpnc|openvpn|pptp|openconnect|openswan|libreswan|ssh|l2tp|iodine|...\n"
+ " [user <username>]\n\n"
+ " olpc-mesh: ssid <SSID>\n"
+ " [channel <1-13>]\n"
+ " [dhcp-anycast <MAC address>]\n\n"
+ " IP_OPTIONS:\n"
+ " [ip4 <IPv4 address>] [gw4 <IPv4 gateway>]\n"
+ " [ip6 <IPv6 address>] [gw6 <IPv6 gateway>]\n\n"));
}
static void
usage_connection_modify (void)
{
- fprintf (stderr,
- _("Usage: nmcli connection modify { ARGUMENTS | help }\n"
- "\n"
- "ARGUMENTS := [id | uuid | path] <ID> ([+|-]<setting>.<property> <value>)+\n"
- "\n"
- "Modify one or more properties of the connection profile.\n"
- "The profile is identified by its name, UUID or D-Bus path. For multi-valued\n"
- "properties you can use optional '+' or '-' prefix to the property name.\n"
- "The '+' sign allows appending items instead of overwriting the whole value.\n"
- "The '-' sign allows removing selected items instead of the whole value.\n"
- "\n"
- "Examples:\n"
- "nmcli con mod home-wifi wifi.ssid rakosnicek\n"
- "nmcli con mod em1-1 ipv4.method manual ipv4.addr \"192.168.1.2/24, 10.10.1.5/8\"\n"
- "nmcli con mod em1-1 +ipv4.dns 8.8.4.4\n"
- "nmcli con mod em1-1 -ipv4.dns 1\n"
- "nmcli con mod em1-1 -ipv6.addr \"abbe::cafe/56\"\n"
- "nmcli con mod bond0 +bond.options mii=500\n"
- "nmcli con mod bond0 -bond.options downdelay\n\n"));
+ g_printerr (_("Usage: nmcli connection modify { ARGUMENTS | help }\n"
+ "\n"
+ "ARGUMENTS := [id | uuid | path] <ID> ([+|-]<setting>.<property> <value>)+\n"
+ "\n"
+ "Modify one or more properties of the connection profile.\n"
+ "The profile is identified by its name, UUID or D-Bus path. For multi-valued\n"
+ "properties you can use optional '+' or '-' prefix to the property name.\n"
+ "The '+' sign allows appending items instead of overwriting the whole value.\n"
+ "The '-' sign allows removing selected items instead of the whole value.\n"
+ "\n"
+ "Examples:\n"
+ "nmcli con mod home-wifi wifi.ssid rakosnicek\n"
+ "nmcli con mod em1-1 ipv4.method manual ipv4.addr \"192.168.1.2/24, 10.10.1.5/8\"\n"
+ "nmcli con mod em1-1 +ipv4.dns 8.8.4.4\n"
+ "nmcli con mod em1-1 -ipv4.dns 1\n"
+ "nmcli con mod em1-1 -ipv6.addr \"abbe::cafe/56\"\n"
+ "nmcli con mod bond0 +bond.options mii=500\n"
+ "nmcli con mod bond0 -bond.options downdelay\n\n"));
}
static void
usage_connection_edit (void)
{
- fprintf (stderr,
- _("Usage: nmcli connection edit { ARGUMENTS | help }\n"
- "\n"
- "ARGUMENTS := [id | uuid | path] <ID>\n"
- "\n"
- "Edit an existing connection profile in an interactive editor.\n"
- "The profile is identified by its name, UUID or D-Bus path\n"
- "\n"
- "ARGUMENTS := [type <new connection type>] [con-name <new connection name>]\n"
- "\n"
- "Add a new connection profile in an interactive editor.\n\n"));
+ g_printerr (_("Usage: nmcli connection edit { ARGUMENTS | help }\n"
+ "\n"
+ "ARGUMENTS := [id | uuid | path] <ID>\n"
+ "\n"
+ "Edit an existing connection profile in an interactive editor.\n"
+ "The profile is identified by its name, UUID or D-Bus path\n"
+ "\n"
+ "ARGUMENTS := [type <new connection type>] [con-name <new connection name>]\n"
+ "\n"
+ "Add a new connection profile in an interactive editor.\n\n"));
}
static void
usage_connection_delete (void)
{
- fprintf (stderr,
- _("Usage: nmcli connection delete { ARGUMENTS | help }\n"
- "\n"
- "ARGUMENTS := [id | uuid | path] <ID>\n"
- "\n"
- "Delete a connection profile.\n"
- "The profile is identified by its name, UUID or D-Bus path.\n\n"));
+ g_printerr (_("Usage: nmcli connection delete { ARGUMENTS | help }\n"
+ "\n"
+ "ARGUMENTS := [id | uuid | path] <ID>\n"
+ "\n"
+ "Delete a connection profile.\n"
+ "The profile is identified by its name, UUID or D-Bus path.\n\n"));
}
static void
usage_connection_reload (void)
{
- fprintf (stderr,
- _("Usage: nmcli connection reload { help }\n"
- "\n"
- "Reload all connection files from disk.\n\n"));
+ g_printerr (_("Usage: nmcli connection reload { help }\n"
+ "\n"
+ "Reload all connection files from disk.\n\n"));
}
static void
usage_connection_load (void)
{
- fprintf (stderr,
- _("Usage: nmcli connection load { ARGUMENTS | help }\n"
- "\n"
- "ARGUMENTS := <filename> [<filename>...]\n"
- "\n"
- "Load/reload one or more connection files from disk. Use this after manually\n"
- "editing a connection file to ensure that NetworkManager is aware of its latest\n"
- "state.\n\n"));
+ g_printerr (_("Usage: nmcli connection load { ARGUMENTS | help }\n"
+ "\n"
+ "ARGUMENTS := <filename> [<filename>...]\n"
+ "\n"
+ "Load/reload one or more connection files from disk. Use this after manually\n"
+ "editing a connection file to ensure that NetworkManager is aware of its latest\n"
+ "state.\n\n"));
}
static gboolean
@@ -682,7 +672,7 @@ nmc_connection_profile_details (NMConnection *connection, NmCli *nmc)
const char *prop_name = (const char *) g_ptr_array_index (prop_array, i);
if (nmc->print_output != NMC_PRINT_TERSE && !nmc->multiline_output && was_output)
- printf ("\n"); /* Empty line */
+ g_print ("\n"); /* Empty line */
was_output = FALSE;
@@ -1033,7 +1023,7 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc)
char *group_fld = (char *) g_ptr_array_index (group_fields, i);
if (nmc->print_output != NMC_PRINT_TERSE && !nmc->multiline_output && was_output)
- printf ("\n"); /* Empty line */
+ g_print ("\n"); /* Empty line */
was_output = FALSE;
@@ -1376,7 +1366,7 @@ do_connections_show (NmCli *nmc, gboolean active_only, int argc, char **argv)
/* Show an empty line between connections */
if (new_line)
- printf ("\n");
+ g_print ("\n");
/* Show profile configuration */
if (without_fields || profile_flds) {
@@ -1648,15 +1638,15 @@ device_state_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
if (ac_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
if (nmc->print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
- printf (_("Connection successfully activated (D-Bus active path: %s)\n"),
- nm_object_get_path (NM_OBJECT (active)));
+ g_print (_("Connection successfully activated (D-Bus active path: %s)\n"),
+ nm_object_get_path (NM_OBJECT (active)));
quit ();
} else if ( ac_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATING
&& state == NM_DEVICE_STATE_IP_CONFIG) {
if (nmc->print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
- printf (_("Connection successfully activated (master waiting for slaves) (D-Bus active path: %s)\n"),
- nm_object_get_path (NM_OBJECT (active)));
+ g_print (_("Connection successfully activated (master waiting for slaves) (D-Bus active path: %s)\n"),
+ nm_object_get_path (NM_OBJECT (active)));
quit ();
} else if (ac_state != NM_ACTIVE_CONNECTION_STATE_ACTIVATING) {
g_string_printf (nmc->return_text, _("Error: Connection activation failed."));
@@ -1676,8 +1666,8 @@ active_connection_state_cb (NMActiveConnection *active, GParamSpec *pspec, gpoin
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
if (nmc->print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
- printf (_("Connection successfully activated (D-Bus active path: %s)\n"),
- nm_object_get_path (NM_OBJECT (active)));
+ g_print (_("Connection successfully activated (D-Bus active path: %s)\n"),
+ nm_object_get_path (NM_OBJECT (active)));
g_object_unref (active);
quit ();
} else if ( state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
@@ -1726,8 +1716,8 @@ vpn_connection_state_cb (NMVpnConnection *vpn,
case NM_VPN_CONNECTION_STATE_ACTIVATED:
if (nmc->print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
- printf (_("VPN connection successfully activated (D-Bus active path: %s)\n"),
- nm_object_get_path (NM_OBJECT (vpn)));
+ g_print (_("VPN connection successfully activated (D-Bus active path: %s)\n"),
+ nm_object_get_path (NM_OBJECT (vpn)));
g_object_unref (vpn);
quit ();
break;
@@ -1830,8 +1820,8 @@ activate_connection_cb (GObject *client, GAsyncResult *result, gpointer user_dat
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
if (nmc->print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
- printf (_("Connection successfully activated (D-Bus active path: %s)\n"),
- nm_object_get_path (NM_OBJECT (active)));
+ g_print (_("Connection successfully activated (D-Bus active path: %s)\n"),
+ nm_object_get_path (NM_OBJECT (active)));
}
g_object_unref (active);
quit ();
@@ -1993,8 +1983,8 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
nsp = *argv;
}
#endif
- else {
- fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
+ else {
+ g_printerr (_("Unknown parameter: %s\n"), *argv);
}
argc--;
@@ -2816,9 +2806,9 @@ want_provide_opt_args (const char *type, int num)
gboolean ret = TRUE;
/* Ask for optional arguments. */
- printf (ngettext ("There is %d optional argument for '%s' connection type.\n",
- "There are %d optional arguments for '%s' connection type.\n", num),
- num, type);
+ g_print (ngettext ("There is %d optional argument for '%s' connection type.\n",
+ "There are %d optional arguments for '%s' connection type.\n", num),
+ num, type);
answer = nmc_readline (ngettext ("Do you want to provide it? %s",
"Do you want to provide them? %s", num),
prompt_yes_no (TRUE, NULL));
@@ -2845,7 +2835,7 @@ do_questionnaire_ethernet (gboolean ethernet, char **mtu, char **mac, char **clo
*mtu = nmc_readline (_("MTU [auto]: "));
once_more = !check_and_convert_mtu (*mtu, NULL, &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*mtu);
}
@@ -2856,7 +2846,7 @@ do_questionnaire_ethernet (gboolean ethernet, char **mtu, char **mac, char **clo
*mac = nmc_readline (_("MAC [none]: "));
once_more = !check_mac (*mac, ARPHRD_ETHER, "mac", &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*mac);
}
@@ -2867,7 +2857,7 @@ do_questionnaire_ethernet (gboolean ethernet, char **mtu, char **mac, char **clo
*cloned_mac = nmc_readline (_("Cloned MAC [none]: "));
once_more = !check_mac (*cloned_mac, ARPHRD_ETHER, "cloned-mac", &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*cloned_mac);
}
@@ -2893,7 +2883,7 @@ do_questionnaire_infiniband (char **mtu, char **mac, char **mode, char **parent,
*mtu = nmc_readline (_("MTU [auto]: "));
once_more = !check_and_convert_mtu (*mtu, NULL, &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*mtu);
}
@@ -2904,7 +2894,7 @@ do_questionnaire_infiniband (char **mtu, char **mac, char **mode, char **parent,
*mac = nmc_readline (_("MAC [none]: "));
once_more = !check_mac (*mac, ARPHRD_INFINIBAND, "mac", &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*mac);
}
@@ -2917,7 +2907,7 @@ do_questionnaire_infiniband (char **mtu, char **mac, char **mode, char **parent,
*mode = g_strdup ("datagram");
once_more = !check_infiniband_mode (mode, &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*mode);
}
@@ -2928,7 +2918,7 @@ do_questionnaire_infiniband (char **mtu, char **mac, char **mode, char **parent,
*parent = nmc_readline (_("Parent interface [none]: "));
once_more = !check_infiniband_parent (*parent, &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*parent);
}
@@ -2939,14 +2929,14 @@ do_questionnaire_infiniband (char **mtu, char **mac, char **mode, char **parent,
*p_key = nmc_readline (_("P_KEY [none]: "));
once_more = !check_infiniband_p_key (*p_key, NULL, &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*p_key);
}
/* If parent is specified, so has to be P_KEY */
if (!once_more && *parent && !*p_key) {
once_more = TRUE;
- printf (_("Error: 'p-key' is mandatory when 'parent' is specified.\n"));
+ g_print (_("Error: 'p-key' is mandatory when 'parent' is specified.\n"));
}
} while (once_more);
}
@@ -2974,7 +2964,7 @@ do_questionnaire_wimax (char **mac)
*mac = nmc_readline (_("MAC [none]: "));
once_more = !check_mac (*mac, ARPHRD_ETHER, "mac", &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*mac);
}
@@ -3002,7 +2992,7 @@ do_questionnaire_pppoe (char **password, char **service, char **mtu, char **mac)
*mtu = nmc_readline (_("MTU [auto]: "));
once_more = !check_and_convert_mtu (*mtu, NULL, &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*mtu);
}
@@ -3013,7 +3003,7 @@ do_questionnaire_pppoe (char **password, char **service, char **mtu, char **mac)
*mac = nmc_readline (_("MAC [none]: "));
once_more = !check_mac (*mac, ARPHRD_ETHER, "mac", &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*mac);
}
@@ -3057,7 +3047,7 @@ do_questionnaire_bluetooth (char **bt_type)
tmp = nmc_string_is_valid (*bt_type, types, NULL);
once_more = !tmp;
if (once_more) {
- printf (_("Error: 'bt-type': '%s' is not a valid bluetooth type.\n"), *bt_type);
+ g_print (_("Error: 'bt-type': '%s' is not a valid bluetooth type.\n"), *bt_type);
g_free (*bt_type);
}
} while (once_more);
@@ -3081,7 +3071,7 @@ do_questionnaire_vlan (char **mtu, char **flags, char **ingress, char **egress)
*mtu = nmc_readline (_("MTU [auto]: "));
once_more = !check_and_convert_mtu (*mtu, NULL, &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*mtu);
}
@@ -3092,7 +3082,7 @@ do_questionnaire_vlan (char **mtu, char **flags, char **ingress, char **egress)
*flags = nmc_readline (_("VLAN flags (<0-7>) [none]: "));
once_more = !check_and_convert_vlan_flags (*flags, NULL, &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*flags);
}
@@ -3103,7 +3093,7 @@ do_questionnaire_vlan (char **mtu, char **flags, char **ingress, char **egress)
*ingress = nmc_readline (_("Ingress priority maps [none]: "));
once_more = !check_and_convert_vlan_prio_maps (*ingress, NM_VLAN_INGRESS_MAP, NULL, &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*ingress);
}
@@ -3114,7 +3104,7 @@ do_questionnaire_vlan (char **mtu, char **flags, char **ingress, char **egress)
*egress = nmc_readline (_("Egress priority maps [none]: "));
once_more = !check_and_convert_vlan_prio_maps (*egress, NM_VLAN_EGRESS_MAP, NULL, &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*egress);
}
@@ -3151,7 +3141,7 @@ do_questionnaire_bond (char **mode, char **primary, char **miimon,
if (mode_tmp) {
*mode = g_strdup (mode_tmp);
} else {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
}
} while (!mode_tmp);
@@ -3162,8 +3152,8 @@ do_questionnaire_bond (char **mode, char **primary, char **miimon,
*primary = nmc_readline (_("Bonding primary interface [none]: "));
once_more = *primary && !nm_utils_iface_valid_name (*primary);
if (once_more) {
- printf (_("Error: 'primary': '%s' is not a valid interface name.\n"),
- *primary);
+ g_print (_("Error: 'primary': '%s' is not a valid interface name.\n"),
+ *primary);
g_free (*primary);
}
} while (once_more);
@@ -3176,8 +3166,8 @@ do_questionnaire_bond (char **mode, char **primary, char **miimon,
g_strstrip (monitor_mode);
once_more = matches (monitor_mode, WORD_MIIMON) != 0 && matches (monitor_mode, WORD_ARP) != 0;
if (once_more) {
- printf (_("Error: '%s' is not a valid monitoring mode; use '%s' or '%s'.\n"),
- monitor_mode, WORD_MIIMON, WORD_ARP);
+ g_print (_("Error: '%s' is not a valid monitoring mode; use '%s' or '%s'.\n"),
+ monitor_mode, WORD_MIIMON, WORD_ARP);
g_free (monitor_mode);
}
} while (once_more);
@@ -3188,8 +3178,8 @@ do_questionnaire_bond (char **mode, char **primary, char **miimon,
*miimon = nmc_readline (_("Bonding miimon [100]: "));
once_more = *miimon && !nmc_string_to_uint (*miimon, TRUE, 0, G_MAXUINT32, &tmp);
if (once_more) {
- printf (_("Error: 'miimon': '%s' is not a valid number <0-%u>.\n"),
- *miimon, G_MAXUINT32);
+ g_print (_("Error: 'miimon': '%s' is not a valid number <0-%u>.\n"),
+ *miimon, G_MAXUINT32);
g_free (*miimon);
}
} while (once_more);
@@ -3199,8 +3189,8 @@ do_questionnaire_bond (char **mode, char **primary, char **miimon,
*downdelay = nmc_readline (_("Bonding downdelay [0]: "));
once_more = *downdelay && !nmc_string_to_uint (*downdelay, TRUE, 0, G_MAXUINT32, &tmp);
if (once_more) {
- printf (_("Error: 'downdelay': '%s' is not a valid number <0-%u>.\n"),
- *downdelay, G_MAXUINT32);
+ g_print (_("Error: 'downdelay': '%s' is not a valid number <0-%u>.\n"),
+ *downdelay, G_MAXUINT32);
g_free (*downdelay);
}
} while (once_more);
@@ -3210,8 +3200,8 @@ do_questionnaire_bond (char **mode, char **primary, char **miimon,
*updelay = nmc_readline (_("Bonding updelay [0]: "));
once_more = *updelay && !nmc_string_to_uint (*updelay, TRUE, 0, G_MAXUINT32, &tmp);
if (once_more) {
- printf (_("Error: 'updelay': '%s' is not a valid number <0-%u>.\n"),
- *updelay, G_MAXUINT32);
+ g_print (_("Error: 'updelay': '%s' is not a valid number <0-%u>.\n"),
+ *updelay, G_MAXUINT32);
g_free (*updelay);
}
} while (once_more);
@@ -3222,8 +3212,8 @@ do_questionnaire_bond (char **mode, char **primary, char **miimon,
*arpinterval = nmc_readline (_("Bonding arp-interval [0]: "));
once_more = *arpinterval && !nmc_string_to_uint (*arpinterval, TRUE, 0, G_MAXUINT32, &tmp);
if (once_more) {
- printf (_("Error: 'arp-interval': '%s' is not a valid number <0-%u>.\n"),
- *arpinterval, G_MAXUINT32);
+ g_print (_("Error: 'arp-interval': '%s' is not a valid number <0-%u>.\n"),
+ *arpinterval, G_MAXUINT32);
g_free (*arpinterval);
}
} while (once_more);
@@ -3253,7 +3243,7 @@ do_questionnaire_team_common (const char *type_name, char **config)
*config = nmc_readline (_("Team JSON configuration [none]: "));
once_more = !nmc_team_check_config (*config, &json, &error);
if (once_more) {
- printf ("Error: %s\n", error->message);
+ g_print ("Error: %s\n", error->message);
g_clear_error (&error);
g_free (*config);
}
@@ -3296,7 +3286,7 @@ do_questionnaire_bridge (char **stp, char **priority, char **fwd_delay, char **h
normalize_yes_no (stp);
once_more = !nmc_string_to_bool (*stp, &stp_bool, &error);
if (once_more) {
- printf (_("Error: 'stp': %s.\n"), error->message);
+ g_print (_("Error: 'stp': %s.\n"), error->message);
g_clear_error (&error);
g_free (*stp);
}
@@ -3308,8 +3298,8 @@ do_questionnaire_bridge (char **stp, char **priority, char **fwd_delay, char **h
*priority = *priority ? *priority : g_strdup ("32768");
once_more = !nmc_string_to_uint (*priority, TRUE, 0, G_MAXUINT16, &tmp);
if (once_more) {
- printf (_("Error: 'priority': '%s' is not a valid number <0-%d>.\n"),
- *priority, G_MAXUINT16);
+ g_print (_("Error: 'priority': '%s' is not a valid number <0-%d>.\n"),
+ *priority, G_MAXUINT16);
g_free (*priority);
}
} while (once_more);
@@ -3320,8 +3310,8 @@ do_questionnaire_bridge (char **stp, char **priority, char **fwd_delay, char **h
*fwd_delay = *fwd_delay ? *fwd_delay : g_strdup ("15");
once_more = !nmc_string_to_uint (*fwd_delay, TRUE, 2, 30, &tmp);
if (once_more) {
- printf (_("Error: 'forward-delay': '%s' is not a valid number <2-30>.\n"),
- *fwd_delay);
+ g_print (_("Error: 'forward-delay': '%s' is not a valid number <2-30>.\n"),
+ *fwd_delay);
g_free (*fwd_delay);
}
} while (once_more);
@@ -3333,8 +3323,8 @@ do_questionnaire_bridge (char **stp, char **priority, char **fwd_delay, char **h
*hello_time = *hello_time ? *hello_time : g_strdup ("2");
once_more = !nmc_string_to_uint (*hello_time, TRUE, 1, 10, &tmp);
if (once_more) {
- printf (_("Error: 'hello-time': '%s' is not a valid number <1-10>.\n"),
- *hello_time);
+ g_print (_("Error: 'hello-time': '%s' is not a valid number <1-10>.\n"),
+ *hello_time);
g_free (*hello_time);
}
} while (once_more);
@@ -3345,8 +3335,8 @@ do_questionnaire_bridge (char **stp, char **priority, char **fwd_delay, char **h
*max_age = *max_age ? *max_age : g_strdup ("20");
once_more = !nmc_string_to_uint (*max_age, TRUE, 6, 40, &tmp);
if (once_more) {
- printf (_("Error: 'max-age': '%s' is not a valid number <6-40>.\n"),
- *max_age);
+ g_print (_("Error: 'max-age': '%s' is not a valid number <6-40>.\n"),
+ *max_age);
g_free (*max_age);
}
} while (once_more);
@@ -3357,8 +3347,8 @@ do_questionnaire_bridge (char **stp, char **priority, char **fwd_delay, char **h
*ageing_time = *ageing_time ? *ageing_time : g_strdup ("300");
once_more = !nmc_string_to_uint (*ageing_time, TRUE, 0, 1000000, &tmp);
if (once_more) {
- printf (_("Error: 'ageing-time': '%s' is not a valid number <0-1000000>.\n"),
- *ageing_time);
+ g_print (_("Error: 'ageing-time': '%s' is not a valid number <0-1000000>.\n"),
+ *ageing_time);
g_free (*ageing_time);
}
} while (once_more);
@@ -3368,7 +3358,7 @@ do_questionnaire_bridge (char **stp, char **priority, char **fwd_delay, char **h
*mac = nmc_get_user_input (_("MAC [none]: "));
once_more = !check_mac (*mac, ARPHRD_ETHER, "mac", &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*mac);
}
@@ -3394,7 +3384,7 @@ do_questionnaire_bridge_slave (char **priority, char **path_cost, char **hairpin
once_more = !bridge_prop_string_to_uint (*priority, "priority", NM_TYPE_SETTING_BRIDGE_PORT,
NM_SETTING_BRIDGE_PORT_PRIORITY, &tmp, &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*priority);
}
@@ -3407,7 +3397,7 @@ do_questionnaire_bridge_slave (char **priority, char **path_cost, char **hairpin
once_more = !bridge_prop_string_to_uint (*path_cost, "path-cost", NM_TYPE_SETTING_BRIDGE_PORT,
NM_SETTING_BRIDGE_PORT_PATH_COST, &tmp, &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*path_cost);
}
@@ -3421,7 +3411,7 @@ do_questionnaire_bridge_slave (char **priority, char **path_cost, char **hairpin
normalize_yes_no (hairpin);
once_more = !nmc_string_to_bool (*hairpin, &hairpin_bool, &error);
if (once_more) {
- printf (_("Error: 'hairpin': %s.\n"), error->message);
+ g_print (_("Error: 'hairpin': %s.\n"), error->message);
g_clear_error (&error);
g_free (*hairpin);
}
@@ -3456,8 +3446,8 @@ do_questionnaire_olpc (char **channel, char **dhcp_anycast)
*channel = nmc_readline (_("OLPC Mesh channel [1]: "));
once_more = *channel && !nmc_string_to_uint (*channel, TRUE, 1, 13, &tmp);
if (once_more) {
- printf (_("Error: 'channel': '%s' is not a valid number <1-13>.\n"),
- *channel);
+ g_print (_("Error: 'channel': '%s' is not a valid number <1-13>.\n"),
+ *channel);
g_free (*channel);
}
} while (once_more);
@@ -3467,7 +3457,7 @@ do_questionnaire_olpc (char **channel, char **dhcp_anycast)
*dhcp_anycast = nmc_readline (_("DHCP anycast MAC address [none]: "));
once_more = !check_mac (*dhcp_anycast, ARPHRD_ETHER, "dhcp-anycast", &error);
if (once_more) {
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
g_free (*dhcp_anycast);
}
@@ -3529,14 +3519,14 @@ ask_for_ip_addresses (NMConnection *connection, int family)
added = add_ip6_address_to_connection ((NMIP6Address *) ipaddr, connection);
gw = gw ? gw : (family == 4) ? "0.0.0.0" : "::";
if (added)
- printf (_(" Address successfully added: %s %s\n"), ip, gw);
+ g_print (_(" Address successfully added: %s %s\n"), ip, gw);
else
- printf (_(" Warning: address already present: %s %s\n"), ip, gw);
+ g_print (_(" Warning: address already present: %s %s\n"), ip, gw);
if (rest)
- printf (_(" Warning: ignoring garbage at the end: '%s'\n"), rest);
+ g_print (_(" Warning: ignoring garbage at the end: '%s'\n"), rest);
} else {
g_prefix_error (&error, _("Error: "));
- printf ("%s\n", error->message);
+ g_print ("%s\n", error->message);
g_clear_error (&error);
}
} else
@@ -3559,7 +3549,7 @@ do_questionnaire_ip (NMConnection *connection)
return;
}
- printf (_("Press <Enter> to finish adding addresses.\n"));
+ g_print (_("Press <Enter> to finish adding addresses.\n"));
ask_for_ip_addresses (connection, 4);
ask_for_ip_addresses (connection, 6);
@@ -4305,11 +4295,11 @@ cleanup_bond:
/* Verify master argument */
checked_master = verify_master_for_slave (all_connections, master, NM_SETTING_BOND_SETTING_NAME);
if (!checked_master)
- printf (_("Warning: master='%s' doesn't refer to any existing profile.\n"), master);
+ g_print (_("Warning: master='%s' doesn't refer to any existing profile.\n"), master);
if (type)
- printf (_("Warning: 'type' is currently ignored. "
- "We only support ethernet slaves for now.\n"));
+ g_print (_("Warning: 'type' is currently ignored. "
+ "We only support ethernet slaves for now.\n"));
/* Change properties in 'connection' setting */
g_object_set (s_con,
@@ -4403,7 +4393,7 @@ cleanup_team:
/* Verify master argument */
checked_master = verify_master_for_slave (all_connections, master, NM_SETTING_TEAM_SETTING_NAME);
if (!checked_master)
- printf (_("Warning: master='%s' doesn't refer to any existing profile.\n"), master);
+ g_print (_("Warning: master='%s' doesn't refer to any existing profile.\n"), master);
/* Also ask for all optional arguments if '--ask' is specified. */
config = g_strdup (config_c);
@@ -4411,8 +4401,8 @@ cleanup_team:
do_questionnaire_team_slave (&config);
if (type)
- printf (_("Warning: 'type' is currently ignored. "
- "We only support ethernet slaves for now.\n"));
+ g_print (_("Warning: 'type' is currently ignored. "
+ "We only support ethernet slaves for now.\n"));
/* Add 'team-port' setting */
s_team_port = (NMSettingTeamPort *) nm_setting_team_port_new ();
@@ -4605,11 +4595,11 @@ cleanup_bridge:
/* Verify master argument */
checked_master = verify_master_for_slave (all_connections, master, NM_SETTING_BRIDGE_SETTING_NAME);
if (!checked_master)
- printf (_("Warning: master='%s' doesn't refer to any existing profile.\n"), master);
+ g_print (_("Warning: master='%s' doesn't refer to any existing profile.\n"), master);
if (type)
- printf (_("Warning: 'type' is currently ignored. "
- "We only support ethernet slaves for now.\n"));
+ g_print (_("Warning: 'type' is currently ignored. "
+ "We only support ethernet slaves for now.\n"));
/* Add 'bridge-port' setting */
/* Must be done *before* bridge_prop_string_to_uint() so that the type is known */
@@ -4695,7 +4685,7 @@ cleanup_bridge_slave:
vpn_type = g_strstrip (vpn_type_ask);
if (!(st = nmc_string_is_valid (vpn_type, nmc_known_vpns, NULL))) {
- printf (_("Warning: 'vpn-type': %s not known.\n"), vpn_type);
+ g_print (_("Warning: 'vpn-type': %s not known.\n"), vpn_type);
st = vpn_type;
}
service_type = g_strdup_printf ("%s.%s", NM_DBUS_INTERFACE, st);
@@ -4894,9 +4884,9 @@ add_connection_cb (GObject *settings,
g_error_free (error);
nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION;
} else {
- printf (_("Connection '%s' (%s) successfully added.\n"),
- nm_connection_get_id (NM_CONNECTION (connection)),
- nm_connection_get_uuid (NM_CONNECTION (connection)));
+ g_print (_("Connection '%s' (%s) successfully added.\n"),
+ nm_connection_get_id (NM_CONNECTION (connection)),
+ nm_connection_get_uuid (NM_CONNECTION (connection)));
g_object_unref (connection);
}
@@ -5100,7 +5090,7 @@ do_connection_add (NmCli *nmc, int argc, char **argv)
if (!type && nmc->ask) {
char *types_tmp = get_valid_options_string (nmc_valid_connection_types);
- printf ("Valid types: [%s]\n", types_tmp);
+ g_print ("Valid types: [%s]\n", types_tmp);
type = type_ask = nmc_readline (PROMPT_CON_TYPE);
g_free (types_tmp);
}
@@ -5865,7 +5855,7 @@ load_history_cmds (const char *uuid)
kf = g_key_file_new ();
if (!g_key_file_load_from_file (kf, filename, G_KEY_FILE_KEEP_COMMENTS, &err)) {
if (err->code == G_KEY_FILE_ERROR_PARSE)
- printf ("Warning: %s parse error: %s\n", filename, err->message);
+ g_print ("Warning: %s parse error: %s\n", filename, err->message);
g_key_file_free (kf);
g_free (filename);
return;
@@ -5901,7 +5891,7 @@ save_history_cmds (const char *uuid)
if (!g_key_file_load_from_file (kf, filename, G_KEY_FILE_KEEP_COMMENTS, &err)) {
if ( err->code != G_FILE_ERROR_NOENT
&& err->code != G_KEY_FILE_ERROR_NOT_FOUND) {
- printf ("Warning: %s parse error: %s\n", filename, err->message);
+ g_print ("Warning: %s parse error: %s\n", filename, err->message);
g_key_file_free (kf);
g_free (filename);
g_clear_error (&err);
@@ -5948,8 +5938,8 @@ editor_show_connection (NMConnection *connection, NmCli *nmc)
static void
editor_show_setting (NMSetting *setting, NmCli *nmc)
{
- printf (_("['%s' setting values]\n"),
- nm_setting_get_name (setting));
+ g_print (_("['%s' setting values]\n"),
+ nm_setting_get_name (setting));
nmc->print_output = NMC_PRINT_NORMAL;
nmc->multiline_output = TRUE;
@@ -6026,24 +6016,24 @@ parse_editor_main_cmd (const char *cmd, char **cmd_arg)
static void
editor_main_usage (void)
{
- printf ("------------------------------------------------------------------------------\n");
+ g_print ("------------------------------------------------------------------------------\n");
/* TRANSLATORS: do not translate command names and keywords before ::
* However, you should translate terms enclosed in <>.
*/
- printf (_("---[ Main menu ]---\n"
- "goto [<setting> | <prop>] :: go to a setting or property\n"
- "remove <setting>[.<prop>] | <prop> :: remove setting or reset property value\n"
- "set [<setting>.<prop> <value>] :: set property value\n"
- "describe [<setting>.<prop>] :: describe property\n"
- "print [all | <setting>[.<prop>]] :: print the connection\n"
- "verify [all] :: verify the connection\n"
- "save [persistent|temporary] :: save the connection\n"
- "activate [<ifname>] [/<ap>|<nsp>] :: activate the connection\n"
- "back :: go one level up (back)\n"
- "help/? [<command>] :: print this help\n"
- "nmcli <conf-option> <value> :: nmcli configuration\n"
- "quit :: exit nmcli\n"));
- printf ("------------------------------------------------------------------------------\n");
+ g_print (_("---[ Main menu ]---\n"
+ "goto [<setting> | <prop>] :: go to a setting or property\n"
+ "remove <setting>[.<prop>] | <prop> :: remove setting or reset property value\n"
+ "set [<setting>.<prop> <value>] :: set property value\n"
+ "describe [<setting>.<prop>] :: describe property\n"
+ "print [all | <setting>[.<prop>]] :: print the connection\n"
+ "verify [all] :: verify the connection\n"
+ "save [persistent|temporary] :: save the connection\n"
+ "activate [<ifname>] [/<ap>|<nsp>] :: activate the connection\n"
+ "back :: go one level up (back)\n"
+ "help/? [<command>] :: print this help\n"
+ "nmcli <conf-option> <value> :: nmcli configuration\n"
+ "quit :: exit nmcli\n"));
+ g_print ("------------------------------------------------------------------------------\n");
}
static void
@@ -6057,92 +6047,92 @@ editor_main_help (const char *command)
switch (cmd) {
case NMC_EDITOR_MAIN_CMD_GOTO:
- printf (_("goto <setting>[.<prop>] | <prop> :: enter setting/property for editing\n\n"
- "This command enters into a setting or property for editing it.\n\n"
- "Examples: nmcli> goto connection\n"
- " nmcli connection> goto secondaries\n"
- " nmcli> goto ipv4.addresses\n"));
+ g_print (_("goto <setting>[.<prop>] | <prop> :: enter setting/property for editing\n\n"
+ "This command enters into a setting or property for editing it.\n\n"
+ "Examples: nmcli> goto connection\n"
+ " nmcli connection> goto secondaries\n"
+ " nmcli> goto ipv4.addresses\n"));
break;
case NMC_EDITOR_MAIN_CMD_REMOVE:
- printf (_("remove <setting>[.<prop>] :: remove setting or reset property value\n\n"
- "This command removes an entire setting from the connection, or if a property\n"
- "is given, resets that property to the default value.\n\n"
- "Examples: nmcli> remove wifi-sec\n"
- " nmcli> remove eth.mtu\n"));
+ g_print (_("remove <setting>[.<prop>] :: remove setting or reset property value\n\n"
+ "This command removes an entire setting from the connection, or if a property\n"
+ "is given, resets that property to the default value.\n\n"
+ "Examples: nmcli> remove wifi-sec\n"
+ " nmcli> remove eth.mtu\n"));
break;
case NMC_EDITOR_MAIN_CMD_SET:
- printf (_("set [<setting>.<prop> <value>] :: set property value\n\n"
- "This command sets property value.\n\n"
- "Example: nmcli> set con.id My connection\n"));
+ g_print (_("set [<setting>.<prop> <value>] :: set property value\n\n"
+ "This command sets property value.\n\n"
+ "Example: nmcli> set con.id My connection\n"));
break;
case NMC_EDITOR_MAIN_CMD_DESCRIBE:
- printf (_("describe [<setting>.<prop>] :: describe property\n\n"
- "Shows property description. You can consult nm-settings(5) "
- "manual page to see all NM settings and properties.\n"));
+ g_print (_("describe [<setting>.<prop>] :: describe property\n\n"
+ "Shows property description. You can consult nm-settings(5) "
+ "manual page to see all NM settings and properties.\n"));
break;
case NMC_EDITOR_MAIN_CMD_PRINT:
- printf (_("print [all] :: print setting or connection values\n\n"
- "Shows current property or the whole connection.\n\n"
- "Example: nmcli ipv4> print all\n"));
+ g_print (_("print [all] :: print setting or connection values\n\n"
+ "Shows current property or the whole connection.\n\n"
+ "Example: nmcli ipv4> print all\n"));
break;
case NMC_EDITOR_MAIN_CMD_VERIFY:
- printf (_("verify [all] :: verify setting or connection validity\n\n"
- "Verifies whether the setting or connection is valid and can "
- "be saved later. It indicates invalid values on error.\n\n"
- "Examples: nmcli> verify\n"
- " nmcli bond> verify\n"));
+ g_print (_("verify [all] :: verify setting or connection validity\n\n"
+ "Verifies whether the setting or connection is valid and can "
+ "be saved later. It indicates invalid values on error.\n\n"
+ "Examples: nmcli> verify\n"
+ " nmcli bond> verify\n"));
break;
case NMC_EDITOR_MAIN_CMD_SAVE:
- printf (_("save [persistent|temporary] :: save the connection\n\n"
- "Sends the connection profile to NetworkManager that either will save it\n"
- "persistently, or will only keep it in memory. 'save' without an argument\n"
- "means 'save persistent'.\n"
- "Note that once you save the profile persistently those settings are saved\n"
- "across reboot or restart. Subsequent changes can also be temporary or\n"
- "persistent, but any temporary changes will not persist across reboot or\n"
- "restart. If you want to fully remove the persistent connection, the connection\n"
- "profile must be deleted.\n"));
+ g_print (_("save [persistent|temporary] :: save the connection\n\n"
+ "Sends the connection profile to NetworkManager that either will save it\n"
+ "persistently, or will only keep it in memory. 'save' without an argument\n"
+ "means 'save persistent'.\n"
+ "Note that once you save the profile persistently those settings are saved\n"
+ "across reboot or restart. Subsequent changes can also be temporary or\n"
+ "persistent, but any temporary changes will not persist across reboot or\n"
+ "restart. If you want to fully remove the persistent connection, the connection\n"
+ "profile must be deleted.\n"));
break;
case NMC_EDITOR_MAIN_CMD_ACTIVATE:
- printf (_("activate [<ifname>] [/<ap>|<nsp>] :: activate the connection\n\n"
- "Activates the connection.\n\n"
- "Available options:\n"
- "<ifname> - device the connection will be activated on\n"
- "/<ap>|<nsp> - AP (Wi-Fi) or NSP (WiMAX) (prepend with / when <ifname> is not specified)\n"));
+ g_print (_("activate [<ifname>] [/<ap>|<nsp>] :: activate the connection\n\n"
+ "Activates the connection.\n\n"
+ "Available options:\n"
+ "<ifname> - device the connection will be activated on\n"
+ "/<ap>|<nsp> - AP (Wi-Fi) or NSP (WiMAX) (prepend with / when <ifname> is not specified)\n"));
break;
case NMC_EDITOR_MAIN_CMD_BACK:
- printf (_("back :: go to upper menu level\n\n"));
+ g_print (_("back :: go to upper menu level\n\n"));
break;
case NMC_EDITOR_MAIN_CMD_HELP:
- printf (_("help/? [<command>] :: help for the nmcli commands\n\n"));
+ g_print (_("help/? [<command>] :: help for the nmcli commands\n\n"));
break;
case NMC_EDITOR_MAIN_CMD_NMCLI:
- printf (_("nmcli [<conf-option> <value>] :: nmcli configuration\n\n"
- "Configures nmcli. The following options are available:\n"
- "status-line yes | no [default: no]\n"
- "save-confirmation yes | no [default: yes]\n"
- "prompt-color <0-8> [default: 0]\n"
- " 0 = normal\n"
- " 1 = \33[30mblack\33[0m\n"
- " 2 = \33[31mred\33[0m\n"
- " 3 = \33[32mgreen\33[0m\n"
- " 4 = \33[33myellow\33[0m\n"
- " 5 = \33[34mblue\33[0m\n"
- " 6 = \33[35mmagenta\33[0m\n"
- " 7 = \33[36mcyan\33[0m\n"
- " 8 = \33[37mwhite\33[0m\n"
- "\n"
- "Examples: nmcli> nmcli status-line yes\n"
- " nmcli> nmcli save-confirmation no\n"
- " nmcli> nmcli prompt-color 3\n"));
+ g_print (_("nmcli [<conf-option> <value>] :: nmcli configuration\n\n"
+ "Configures nmcli. The following options are available:\n"
+ "status-line yes | no [default: no]\n"
+ "save-confirmation yes | no [default: yes]\n"
+ "prompt-color <0-8> [default: 0]\n"
+ " 0 = normal\n"
+ " 1 = \33[30mblack\33[0m\n"
+ " 2 = \33[31mred\33[0m\n"
+ " 3 = \33[32mgreen\33[0m\n"
+ " 4 = \33[33myellow\33[0m\n"
+ " 5 = \33[34mblue\33[0m\n"
+ " 6 = \33[35mmagenta\33[0m\n"
+ " 7 = \33[36mcyan\33[0m\n"
+ " 8 = \33[37mwhite\33[0m\n"
+ "\n"
+ "Examples: nmcli> nmcli status-line yes\n"
+ " nmcli> nmcli save-confirmation no\n"
+ " nmcli> nmcli prompt-color 3\n"));
break;
case NMC_EDITOR_MAIN_CMD_QUIT:
- printf (_("quit :: exit nmcli\n\n"
- "This command exits nmcli. When the connection being edited "
- "is not saved, the user is asked to confirm the action.\n"));
+ g_print (_("quit :: exit nmcli\n\n"
+ "This command exits nmcli. When the connection being edited "
+ "is not saved, the user is asked to confirm the action.\n"));
break;
default:
- printf (_("Unknown command: '%s'\n"), command);
+ g_print (_("Unknown command: '%s'\n"), command);
break;
}
}
@@ -6204,21 +6194,21 @@ parse_editor_sub_cmd (const char *cmd, char **cmd_arg)
static void
editor_sub_help (void)
{
- printf ("------------------------------------------------------------------------------\n");
+ g_print ("------------------------------------------------------------------------------\n");
/* TRANSLATORS: do not translate command names and keywords before ::
* However, you should translate terms enclosed in <>.
*/
- printf (_("---[ Property menu ]---\n"
- "set [<value>] :: set new value\n"
- "add [<value>] :: add new option to the property\n"
- "change :: change current value\n"
- "remove [<index> | <option>] :: delete the value\n"
- "describe :: describe property\n"
- "print [setting | connection] :: print property (setting/connection) value(s)\n"
- "back :: go to upper level\n"
- "help/? [<command>] :: print this help or command description\n"
- "quit :: exit nmcli\n"));
- printf ("------------------------------------------------------------------------------\n");
+ g_print (_("---[ Property menu ]---\n"
+ "set [<value>] :: set new value\n"
+ "add [<value>] :: add new option to the property\n"
+ "change :: change current value\n"
+ "remove [<index> | <option>] :: delete the value\n"
+ "describe :: describe property\n"
+ "print [setting | connection] :: print property (setting/connection) value(s)\n"
+ "back :: go to upper level\n"
+ "help/? [<command>] :: print this help or command description\n"
+ "quit :: exit nmcli\n"));
+ g_print ("------------------------------------------------------------------------------\n");
}
static void
@@ -6233,53 +6223,53 @@ editor_sub_usage (const char *command)
switch (cmdsub) {
case NMC_EDITOR_SUB_CMD_SET:
- printf (_("set [<value>] :: set new value\n\n"
- "This command sets provided <value> to this property\n"));
+ g_print (_("set [<value>] :: set new value\n\n"
+ "This command sets provided <value> to this property\n"));
break;
case NMC_EDITOR_SUB_CMD_ADD:
- printf (_("add [<value>] :: append new value to the property\n\n"
- "This command adds provided <value> to this property, if "
- "the property is of a container type. For single-valued "
- "properties the property value is replaced (same as 'set').\n"));
+ g_print (_("add [<value>] :: append new value to the property\n\n"
+ "This command adds provided <value> to this property, if "
+ "the property is of a container type. For single-valued "
+ "properties the property value is replaced (same as 'set').\n"));
break;
case NMC_EDITOR_SUB_CMD_CHANGE:
- printf (_("change :: change current value\n\n"
- "Displays current value and allows editing it.\n"));
+ g_print (_("change :: change current value\n\n"
+ "Displays current value and allows editing it.\n"));
break;
case NMC_EDITOR_SUB_CMD_REMOVE:
- printf (_("remove [<value>|<index>|<option name>] :: delete the value\n\n"
- "Removes the property value. For single-valued properties, this sets the\n"
- "property back to its default value. For container-type properties, this removes\n"
- "all the values of that property, or you can specify an argument to remove just\n"
- "a single item or option. The argument is either a value or index of the item to\n"
- "remove, or an option name (for properties with named options).\n\n"
- "Examples: nmcli ipv4.dns> remove 8.8.8.8\n"
- " nmcli ipv4.dns> remove 2\n"
- " nmcli bond.options> remove downdelay\n\n"));
+ g_print (_("remove [<value>|<index>|<option name>] :: delete the value\n\n"
+ "Removes the property value. For single-valued properties, this sets the\n"
+ "property back to its default value. For container-type properties, this removes\n"
+ "all the values of that property, or you can specify an argument to remove just\n"
+ "a single item or option. The argument is either a value or index of the item to\n"
+ "remove, or an option name (for properties with named options).\n\n"
+ "Examples: nmcli ipv4.dns> remove 8.8.8.8\n"
+ " nmcli ipv4.dns> remove 2\n"
+ " nmcli bond.options> remove downdelay\n\n"));
break;
case NMC_EDITOR_SUB_CMD_DESCRIBE:
- printf (_("describe :: describe property\n\n"
- "Shows property description. You can consult nm-settings(5) "
- "manual page to see all NM settings and properties.\n"));
+ g_print (_("describe :: describe property\n\n"
+ "Shows property description. You can consult nm-settings(5) "
+ "manual page to see all NM settings and properties.\n"));
break;
case NMC_EDITOR_SUB_CMD_PRINT:
- printf (_("print [property|setting|connection] :: print property (setting, connection) value(s)\n\n"
- "Shows property value. Providing an argument you can also display "
- "values for the whole setting or connection.\n"));
+ g_print (_("print [property|setting|connection] :: print property (setting, connection) value(s)\n\n"
+ "Shows property value. Providing an argument you can also display "
+ "values for the whole setting or connection.\n"));
break;
case NMC_EDITOR_SUB_CMD_BACK:
- printf (_("back :: go to upper menu level\n\n"));
+ g_print (_("back :: go to upper menu level\n\n"));
break;
case NMC_EDITOR_SUB_CMD_HELP:
- printf (_("help/? [<command>] :: help for nmcli commands\n\n"));
+ g_print (_("help/? [<command>] :: help for nmcli commands\n\n"));
break;
case NMC_EDITOR_SUB_CMD_QUIT:
- printf (_("quit :: exit nmcli\n\n"
- "This command exits nmcli. When the connection being edited "
- "is not saved, the user is asked to confirm the action.\n"));
+ g_print (_("quit :: exit nmcli\n\n"
+ "This command exits nmcli. When the connection being edited "
+ "is not saved, the user is asked to confirm the action.\n"));
break;
default:
- printf (_("Unknown command: '%s'\n"), command);
+ g_print (_("Unknown command: '%s'\n"), command);
break;
}
}
@@ -6364,13 +6354,13 @@ progress_activation_editor_cb (gpointer user_data)
if ( ac_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED
|| dev_state == NM_DEVICE_STATE_ACTIVATED) {
nmc_terminal_erase_line ();
- printf (_("Connection successfully activated (D-Bus active path: %s)\n"),
- nm_object_get_path (NM_OBJECT (ac)));
+ g_print (_("Connection successfully activated (D-Bus active path: %s)\n"),
+ nm_object_get_path (NM_OBJECT (ac)));
goto finish; /* we are done */
} else if ( ac_state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
|| dev_state == NM_DEVICE_STATE_FAILED) {
nmc_terminal_erase_line ();
- printf (_("Error: Connection activation failed.\n"));
+ g_print (_("Error: Connection activation failed.\n"));
goto finish; /* we are done */
}
@@ -6423,7 +6413,7 @@ print_property_description (NMSetting *setting, const char *prop_name)
char *desc;
desc = nmc_setting_get_property_desc (setting, prop_name);
- printf ("\n=== [%s] ===\n%s\n", prop_name, desc);
+ g_print ("\n=== [%s] ===\n%s\n", prop_name, desc);
g_free (desc);
}
@@ -6435,7 +6425,7 @@ print_setting_description (NMSetting *setting)
int i;
all_props = nmc_setting_get_valid_properties (setting);
- printf (("<<< %s >>>\n"), nm_setting_get_name (setting));
+ g_print (("<<< %s >>>\n"), nm_setting_get_name (setting));
for (i = 0; all_props && all_props[i]; i++)
print_property_description (setting, all_props[i]);
g_strfreev (all_props);
@@ -6453,8 +6443,8 @@ connection_remove_setting (NMConnection *connection, NMSetting *setting)
nm_connection_remove_setting (connection, G_OBJECT_TYPE (setting));
return TRUE;
}
- printf (_("Error: setting '%s' is mandatory and cannot be removed.\n"),
- nm_setting_get_name (setting));
+ g_print (_("Error: setting '%s' is mandatory and cannot be removed.\n"),
+ nm_setting_get_name (setting));
return FALSE;
}
@@ -6471,10 +6461,10 @@ editor_show_status_line (NMConnection *connection, gboolean dirty, gboolean temp
con_uuid = nm_connection_get_uuid (connection);
/* TRANSLATORS: status line in nmcli connection editor */
- printf (_("[ Type: %s | Name: %s | UUID: %s | Dirty: %s | Temp: %s ]\n"),
- con_type, con_id, con_uuid,
- dirty ? _("yes") : _("no"),
- temp ? _("yes") : _("no"));
+ g_print (_("[ Type: %s | Name: %s | UUID: %s | Dirty: %s | Temp: %s ]\n"),
+ con_type, con_id, con_uuid,
+ dirty ? _("yes") : _("no"),
+ temp ? _("yes") : _("no"));
}
static gboolean
@@ -6551,8 +6541,8 @@ property_edit_submenu (NmCli *nmc,
/* Get the remote connection again, it may have disapeared */
removed = refresh_remote_connection (rem_con_weak, rem_con);
if (removed)
- printf (_("The connection profile has been removed from another client. "
- "You may type 'save' in the main menu to restore it.\n"));
+ g_print (_("The connection profile has been removed from another client. "
+ "You may type 'save' in the main menu to restore it.\n"));
/* Connection is dirty? (not saved or differs from the saved) */
dirty = is_connection_dirty (connection, *rem_con);
@@ -6588,7 +6578,7 @@ property_edit_submenu (NmCli *nmc,
set_result = nmc_setting_set_property (curr_setting, prop_name, prop_val_user, &tmp_err);
g_free (prop_val_user);
if (!set_result) {
- printf (_("Error: failed to set '%s' property: %s\n"), prop_name, tmp_err->message);
+ g_print (_("Error: failed to set '%s' property: %s\n"), prop_name, tmp_err->message);
g_clear_error (&tmp_err);
if (cmdsub == NMC_EDITOR_SUB_CMD_SET)
nmc_property_set_gvalue (curr_setting, prop_name, &prop_g_value);
@@ -6606,7 +6596,7 @@ property_edit_submenu (NmCli *nmc,
nmc_property_set_default_value (curr_setting, prop_name);
if (!nmc_setting_set_property (curr_setting, prop_name, prop_val_user, &tmp_err)) {
- printf (_("Error: failed to set '%s' property: %s\n"), prop_name, tmp_err->message);
+ g_print (_("Error: failed to set '%s' property: %s\n"), prop_name, tmp_err->message);
g_clear_error (&tmp_err);
nmc_property_set_gvalue (curr_setting, prop_name, &prop_g_value);
}
@@ -6627,14 +6617,14 @@ property_edit_submenu (NmCli *nmc,
option ? g_strstrip (option) : NULL,
(guint32) val_int,
&tmp_err)) {
- printf (_("Error: %s\n"), tmp_err->message);
+ g_print (_("Error: %s\n"), tmp_err->message);
g_clear_error (&tmp_err);
}
g_free (option);
} else {
if (!nmc_setting_reset_property (curr_setting, prop_name, &tmp_err)) {
- printf (_("Error: failed to remove value of '%s': %s\n"), prop_name,
- tmp_err->message);
+ g_print (_("Error: failed to remove value of '%s': %s\n"), prop_name,
+ tmp_err->message);
g_clear_error (&tmp_err);
}
}
@@ -6654,10 +6644,10 @@ property_edit_submenu (NmCli *nmc,
|| matches (cmd_property_arg, "all") == 0)
editor_show_connection (connection, nmc);
else
- printf (_("Unknown command argument: '%s'\n"), cmd_property_arg);
+ g_print (_("Unknown command argument: '%s'\n"), cmd_property_arg);
} else {
char *prop_val = nmc_setting_get_property (curr_setting, prop_name, NULL);
- printf ("%s: %s\n", prop_name, prop_val);
+ g_print ("%s: %s\n", prop_name, prop_val);
g_free (prop_val);
}
break;
@@ -6684,7 +6674,7 @@ property_edit_submenu (NmCli *nmc,
case NMC_EDITOR_SUB_CMD_UNKNOWN:
default:
- printf (_("Unknown command: '%s'\n"), cmd_property_user);
+ g_print (_("Unknown command: '%s'\n"), cmd_property_user);
break;
}
g_free (cmd_property_user);
@@ -6780,7 +6770,7 @@ ask_check_setting (const char *arg,
GError *err = NULL;
if (!arg) {
- printf (_("Available settings: %s\n"), valid_settings_str);
+ g_print (_("Available settings: %s\n"), valid_settings_str);
setting_name_user = nmc_readline (EDITOR_PROMPT_SETTING);
} else
setting_name_user = g_strdup (arg);
@@ -6789,7 +6779,7 @@ ask_check_setting (const char *arg,
g_strstrip (setting_name_user);
if (!(setting_name = check_valid_name (setting_name_user, valid_settings_arr, &err))) {
- printf (_("Error: invalid setting name; %s\n"), err->message);
+ g_print (_("Error: invalid setting name; %s\n"), err->message);
g_clear_error (&err);
}
g_free (setting_name_user);
@@ -6806,7 +6796,7 @@ ask_check_property (const char *arg,
GError *tmp_err = NULL;
if (!arg) {
- printf (_("Available properties: %s\n"), valid_props_str);
+ g_print (_("Available properties: %s\n"), valid_props_str);
prop_name_user = nmc_readline (EDITOR_PROMPT_PROPERTY);
if (prop_name_user)
g_strstrip (prop_name_user);
@@ -6814,7 +6804,7 @@ ask_check_property (const char *arg,
prop_name_user = g_strdup (arg);
if (!(prop_name = nmc_string_is_valid (prop_name_user, valid_props, &tmp_err))) {
- printf (_("Error: property %s\n"), tmp_err->message);
+ g_print (_("Error: property %s\n"), tmp_err->message);
g_clear_error (&tmp_err);
}
g_free (prop_name_user);
@@ -6930,7 +6920,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
valid_settings_arr = get_valid_settings_array (connection_type);
valid_settings_str = get_valid_options_string (valid_settings_arr);
- printf (_("You may edit the following settings: %s\n"), valid_settings_str);
+ g_print (_("You may edit the following settings: %s\n"), valid_settings_str);
menu_ctx.level = 0;
menu_ctx.main_prompt = nmc_colorize (nmc->editor_prompt_color, BASE_PROMPT);
@@ -6957,8 +6947,8 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
/* Get the remote connection again, it may have disapeared */
removed = refresh_remote_connection (&weak, &rem_con);
if (removed)
- printf (_("The connection profile has been removed from another client. "
- "You may type 'save' to restore it.\n"));
+ g_print (_("The connection profile has been removed from another client. "
+ "You may type 'save' to restore it.\n"));
if (!cmd_user || *cmd_user == '\0')
continue;
@@ -6986,18 +6976,18 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
avals = nmc_setting_get_property_allowed_values (menu_ctx.curr_setting, prop_name);
if (avals)
- printf (_("Allowed values for '%s' property: %s\n"), prop_name, avals);
+ g_print (_("Allowed values for '%s' property: %s\n"), prop_name, avals);
prop_val_user = nmc_readline (_("Enter '%s' value: "), prop_name);
/* Set property value */
if (!nmc_setting_set_property (menu_ctx.curr_setting, prop_name, prop_val_user, &tmp_err)) {
- printf (_("Error: failed to set '%s' property: %s\n"), prop_name, tmp_err->message);
+ g_print (_("Error: failed to set '%s' property: %s\n"), prop_name, tmp_err->message);
g_clear_error (&tmp_err);
}
} else {
- printf (_("Error: no setting selected; valid are [%s]\n"), valid_settings_str);
- printf (_("use 'goto <setting>' first, or 'set <setting>.<property>'\n"));
+ g_print (_("Error: no setting selected; valid are [%s]\n"), valid_settings_str);
+ g_print (_("use 'goto <setting>' first, or 'set <setting>.<property>'\n"));
}
} else {
NMSetting *ss = NULL;
@@ -7011,8 +7001,8 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
if (!ss) {
ss = create_setting_by_name (cmd_arg_s, valid_settings_arr);
if (!ss) {
- printf (_("Error: invalid setting argument '%s'; valid are [%s]\n"),
- cmd_arg_s, valid_settings_str);
+ g_print (_("Error: invalid setting argument '%s'; valid are [%s]\n"),
+ cmd_arg_s, valid_settings_str);
break;
}
created_ss = TRUE;
@@ -7021,14 +7011,14 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
if (menu_ctx.curr_setting)
ss = menu_ctx.curr_setting;
else {
- printf (_("Error: missing setting for '%s' property\n"), cmd_arg_p);
+ g_print (_("Error: missing setting for '%s' property\n"), cmd_arg_p);
break;
}
}
prop_name = is_property_valid (ss, cmd_arg_p, &tmp_err);
if (!prop_name) {
- printf (_("Error: invalid property: %s\n"), tmp_err->message);
+ g_print (_("Error: invalid property: %s\n"), tmp_err->message);
g_clear_error (&tmp_err);
if (created_ss)
g_object_unref (ss);
@@ -7041,15 +7031,15 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
if (!cmd_arg_v) {
const char *avals = nmc_setting_get_property_allowed_values (ss, prop_name);
if (avals)
- printf (_("Allowed values for '%s' property: %s\n"), prop_name, avals);
+ g_print (_("Allowed values for '%s' property: %s\n"), prop_name, avals);
cmd_arg_v = nmc_readline (_("Enter '%s' value: "), prop_name);
}
/* Set property value */
if (!nmc_setting_set_property (ss, prop_name, cmd_arg_v, &tmp_err)) {
- printf (_("Error: failed to set '%s' property: %s\n"),
- prop_name, tmp_err->message);
+ g_print (_("Error: failed to set '%s' property: %s\n"),
+ prop_name, tmp_err->message);
g_clear_error (&tmp_err);
}
@@ -7075,7 +7065,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
if (!setting) {
setting = nmc_setting_new_for_name (setting_name);
if (!setting) {
- printf (_("Error: unknown setting '%s'\n"), setting_name);
+ g_print (_("Error: unknown setting '%s'\n"), setting_name);
break;
}
nmc_setting_custom_init (setting);
@@ -7088,7 +7078,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
menu_switch_to_level1 (&menu_ctx, setting, setting_name, nmc->editor_prompt_color);
if (!cmd_arg_s) {
- printf (_("You may edit the following properties: %s\n"), menu_ctx.valid_props_str);
+ g_print (_("You may edit the following properties: %s\n"), menu_ctx.valid_props_str);
break;
}
}
@@ -7127,12 +7117,12 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
/* Delete property value */
if (!nmc_setting_reset_property (menu_ctx.curr_setting, prop_name, &tmp_err)) {
- printf (_("Error: failed to remove value of '%s': %s\n"), prop_name,
- tmp_err->message);
+ g_print (_("Error: failed to remove value of '%s': %s\n"), prop_name,
+ tmp_err->message);
g_clear_error (&tmp_err);
}
} else
- printf (_("Error: no argument given; valid are [%s]\n"), valid_settings_str);
+ g_print (_("Error: no argument given; valid are [%s]\n"), valid_settings_str);
} else {
NMSetting *ss = NULL;
gboolean descr_all;
@@ -7145,10 +7135,10 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
ss = is_setting_valid (connection, valid_settings_arr, user_s);
if (!ss) {
if (check_valid_name (user_s, valid_settings_arr, NULL))
- printf (_("Setting '%s' is not present in the connection.\n"), user_s);
+ g_print (_("Setting '%s' is not present in the connection.\n"), user_s);
else
- printf (_("Error: invalid setting argument '%s'; valid are [%s]\n"),
- user_s, valid_settings_str);
+ g_print (_("Error: invalid setting argument '%s'; valid are [%s]\n"),
+ user_s, valid_settings_str);
break;
}
} else
@@ -7168,8 +7158,8 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
if (prop_name) {
/* Delete property value */
if (!nmc_setting_reset_property (ss, prop_name, &tmp_err)) {
- printf (_("Error: failed to remove value of '%s': %s\n"), prop_name,
- tmp_err->message);
+ g_print (_("Error: failed to remove value of '%s': %s\n"), prop_name,
+ tmp_err->message);
g_clear_error (&tmp_err);
}
} else {
@@ -7186,8 +7176,8 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
nmc_tab_completion.setting = NULL; /* for TAB completion */
}
} else
- printf (_("Error: %s properties, nor it is a setting name.\n"),
- tmp_err->message);
+ g_print (_("Error: %s properties, nor it is a setting name.\n"),
+ tmp_err->message);
g_clear_error (&tmp_err);
}
g_free (prop_name);
@@ -7210,8 +7200,8 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
/* Show property description */
print_property_description (menu_ctx.curr_setting, prop_name);
} else {
- printf (_("Error: no setting selected; valid are [%s]\n"), valid_settings_str);
- printf (_("use 'goto <setting>' first, or 'describe <setting>.<property>'\n"));
+ g_print (_("Error: no setting selected; valid are [%s]\n"), valid_settings_str);
+ g_print (_("use 'goto <setting>' first, or 'describe <setting>.<property>'\n"));
}
} else {
NMSetting *ss = NULL;
@@ -7227,8 +7217,8 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
if (!ss) {
ss = create_setting_by_name (user_s, valid_settings_arr);
if (!ss) {
- printf (_("Error: invalid setting argument '%s'; valid are [%s]\n"),
- user_s, valid_settings_str);
+ g_print (_("Error: invalid setting argument '%s'; valid are [%s]\n"),
+ user_s, valid_settings_str);
break;
}
unref_ss = TRUE;
@@ -7252,9 +7242,9 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
if (s_tmp)
print_setting_description (s_tmp);
else
- printf (_("Error: invalid property: %s, "
- "neither a valid setting name.\n"),
- tmp_err->message);
+ g_print (_("Error: invalid property: %s, "
+ "neither a valid setting name.\n"),
+ tmp_err->message);
g_clear_error (&tmp_err);
}
g_free (prop_name);
@@ -7281,12 +7271,12 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
const char *s_name;
s_name = check_valid_name (user_s, valid_settings_arr, NULL);
if (!s_name) {
- printf (_("Error: unknown setting: '%s'\n"), user_s);
+ g_print (_("Error: unknown setting: '%s'\n"), user_s);
break;
}
ss = nm_connection_get_setting_by_name (connection, s_name);
if (!ss) {
- printf (_("Error: '%s' setting not present in the connection\n"), s_name);
+ g_print (_("Error: '%s' setting not present in the connection\n"), s_name);
break;
}
} else
@@ -7301,7 +7291,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
if (prop_name) {
/* Print one property */
char *prop_val = nmc_setting_get_property (ss, prop_name, NULL);
- printf ("%s.%s: %s\n", nm_setting_get_name (ss),prop_name , prop_val);
+ g_print ("%s.%s: %s\n", nm_setting_get_name (ss),prop_name , prop_val);
g_free (prop_val);
} else {
/* If the string is not a property, try it as a setting */
@@ -7311,9 +7301,9 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
/* Print the whole setting */
editor_show_setting (s_tmp, nmc);
} else
- printf (_("Error: invalid property: %s%s\n"),
- err->message,
- cmd_arg_s ? "" : _(", neither a valid setting name"));
+ g_print (_("Error: invalid property: %s%s\n"),
+ err->message,
+ cmd_arg_s ? "" : _(", neither a valid setting name"));
g_clear_error (&err);
}
g_free (prop_name);
@@ -7333,15 +7323,15 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
&& (!cmd_arg || strcmp (cmd_arg, "all") != 0)) {
GError *tmp_err = NULL;
(void) nm_setting_verify (menu_ctx.curr_setting, NULL, &tmp_err);
- printf (_("Verify setting '%s': %s\n"),
- nm_setting_get_name (menu_ctx.curr_setting),
- tmp_err ? tmp_err->message : "OK");
+ g_print (_("Verify setting '%s': %s\n"),
+ nm_setting_get_name (menu_ctx.curr_setting),
+ tmp_err ? tmp_err->message : "OK");
g_clear_error (&tmp_err);
} else {
GError *tmp_err = NULL;
(void) nm_connection_verify (connection, &tmp_err);
- printf (_("Verify connection: %s\n"),
- tmp_err ? tmp_err->message : "OK");
+ g_print (_("Verify connection: %s\n"),
+ tmp_err ? tmp_err->message : "OK");
g_clear_error (&tmp_err);
}
break;
@@ -7358,7 +7348,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
else if (matches (cmd_arg, "persistent") == 0)
persistent = TRUE;
else {
- printf (_("Error: invalid argument '%s'\n"), cmd_arg);
+ g_print (_("Error: invalid argument '%s'\n"), cmd_arg);
break;
}
}
@@ -7391,18 +7381,18 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
g_cond_wait (&nmc_editor_cond, &nmc_editor_mutex);
if (nmc_editor_error) {
- printf (_("Error: Failed to save '%s' (%s) connection: (%d) %s\n"),
- nm_connection_get_id (connection),
- nm_connection_get_uuid (connection),
- nmc_editor_error->code, nmc_editor_error->message);
+ g_print (_("Error: Failed to save '%s' (%s) connection: (%d) %s\n"),
+ nm_connection_get_id (connection),
+ nm_connection_get_uuid (connection),
+ nmc_editor_error->code, nmc_editor_error->message);
g_error_free (nmc_editor_error);
} else {
- printf (!rem_con ?
- _("Connection '%s' (%s) successfully saved.\n") :
- _("Connection '%s' (%s) successfully updated.\n"),
- nm_connection_get_id (connection),
- nm_connection_get_uuid (connection));
+ g_print (!rem_con ?
+ _("Connection '%s' (%s) successfully saved.\n") :
+ _("Connection '%s' (%s) successfully updated.\n"),
+ nm_connection_get_id (connection),
+ nm_connection_get_uuid (connection));
con_tmp = nm_remote_settings_get_connection_by_uuid (nmc->system_settings,
nm_connection_get_uuid (connection));
@@ -7433,8 +7423,8 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
nmc_editor_error = NULL;
g_mutex_unlock (&nmc_editor_mutex);
} else
- printf (_("Error: connection verification failed: %s\n"),
- err1 ? err1->message : _("(unknown error)"));
+ g_print (_("Error: connection verification failed: %s\n"),
+ err1 ? err1->message : _("(unknown error)"));
g_clear_error (&err1);
break;
@@ -7455,11 +7445,11 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
ap_nsp = ap_nsp && ap_nsp[0] == '/' ? ap_nsp + 1 : ap_nsp;
if (is_connection_dirty (connection, rem_con)) {
- printf (_("Error: connection is not saved. Type 'save' first.\n"));
+ g_print (_("Error: connection is not saved. Type 'save' first.\n"));
break;
}
if (!nm_connection_verify (NM_CONNECTION (rem_con), &tmp_err)) {
- printf (_("Error: connection is not valid: %s\n"), tmp_err->message);
+ g_print (_("Error: connection is not valid: %s\n"), tmp_err->message);
g_clear_error (&tmp_err);
break;
}
@@ -7469,7 +7459,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
nmc->print_output = NMC_PRINT_PRETTY;
if (!nmc_activate_connection (nmc, NM_CONNECTION (rem_con), ifname, ap_nsp, ap_nsp,
activate_connection_editor_cb, &tmp_err)) {
- printf (_("Error: Cannot activate connection: %s.\n"), tmp_err->message);
+ g_print (_("Error: Cannot activate connection: %s.\n"), tmp_err->message);
g_clear_error (&tmp_err);
break;
}
@@ -7479,13 +7469,13 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
g_cond_wait (&nmc_editor_cond, &nmc_editor_mutex);
if (nmc_editor_error) {
- printf (_("Error: Failed to activate '%s' (%s) connection: (%d) %s\n"),
- nm_connection_get_id (connection),
- nm_connection_get_uuid (connection),
- nmc_editor_error->code, nmc_editor_error->message);
+ g_print (_("Error: Failed to activate '%s' (%s) connection: (%d) %s\n"),
+ nm_connection_get_id (connection),
+ nm_connection_get_uuid (connection),
+ nmc_editor_error->code, nmc_editor_error->message);
g_error_free (nmc_editor_error);
} else {
- printf (_("Monitoring connection activation (press any key to continue)\n"));
+ g_print (_("Monitoring connection activation (press any key to continue)\n"));
nmc_get_user_input ("");
}
@@ -7523,7 +7513,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
GError *tmp_err = NULL;
gboolean bb;
if (!nmc_string_to_bool (cmd_arg_v ? g_strstrip (cmd_arg_v) : "", &bb, &tmp_err)) {
- printf (_("Error: status-line: %s\n"), tmp_err->message);
+ g_print (_("Error: status-line: %s\n"), tmp_err->message);
g_clear_error (&tmp_err);
} else
nmc->editor_status_line = bb;
@@ -7531,7 +7521,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
GError *tmp_err = NULL;
gboolean bb;
if (!nmc_string_to_bool (cmd_arg_v ? g_strstrip (cmd_arg_v) : "", &bb, &tmp_err)) {
- printf (_("Error: save-confirmation: %s\n"), tmp_err->message);
+ g_print (_("Error: save-confirmation: %s\n"), tmp_err->message);
g_clear_error (&tmp_err);
} else
nmc->editor_save_confirmation = bb;
@@ -7539,8 +7529,8 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
unsigned long color;
if (!nmc_string_to_uint (cmd_arg_v ? g_strstrip (cmd_arg_v) : "X",
TRUE, 0, 8, &color))
- printf (_("Error: bad color number: '%s'; use <0-8>\n"),
- cmd_arg_v ? cmd_arg_v : "");
+ g_print (_("Error: bad color number: '%s'; use <0-8>\n"),
+ cmd_arg_v ? cmd_arg_v : "");
else {
nmc->editor_prompt_color = color;
g_free (menu_ctx.main_prompt);
@@ -7551,16 +7541,16 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
nm_setting_get_name (menu_ctx.curr_setting));
}
} else if (!cmd_arg_p) {
- printf (_("Current nmcli configuration:\n"));
- printf ("status-line: %s\n"
- "save-confirmation: %s\n"
- "prompt-color: %d\n",
- nmc->editor_status_line ? "yes" : "no",
- nmc->editor_save_confirmation ? "yes" : "no",
- nmc->editor_prompt_color);
+ g_print (_("Current nmcli configuration:\n"));
+ g_print ("status-line: %s\n"
+ "save-confirmation: %s\n"
+ "prompt-color: %d\n",
+ nmc->editor_status_line ? "yes" : "no",
+ nmc->editor_save_confirmation ? "yes" : "no",
+ nmc->editor_prompt_color);
} else
- printf (_("Invalid configuration option '%s'; allowed [%s]\n"),
- cmd_arg_v ? cmd_arg_v : "", "status-line, save-confirmation, prompt-color");
+ g_print (_("Invalid configuration option '%s'; allowed [%s]\n"),
+ cmd_arg_v ? cmd_arg_v : "", "status-line, save-confirmation, prompt-color");
break;
@@ -7574,7 +7564,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
case NMC_EDITOR_MAIN_CMD_UNKNOWN:
default:
- printf (_("Unknown command: '%s'\n"), cmd_user);
+ g_print (_("Unknown command: '%s'\n"), cmd_user);
break;
}
@@ -7828,11 +7818,11 @@ do_connection_edit (NmCli *nmc, int argc, char **argv)
connection_type = nm_setting_connection_get_connection_type (s_con);
if (type)
- printf (_("Warning: editing existing connection '%s'; 'type' argument is ignored\n"),
- nm_connection_get_id (connection));
+ g_print (_("Warning: editing existing connection '%s'; 'type' argument is ignored\n"),
+ nm_connection_get_id (connection));
if (con_name)
- printf (_("Warning: editing existing connection '%s'; 'con-name' argument is ignored\n"),
- nm_connection_get_id (connection));
+ g_print (_("Warning: editing existing connection '%s'; 'con-name' argument is ignored\n"),
+ nm_connection_get_id (connection));
/* Load previously saved history commands for the connection */
load_history_cmds (nm_connection_get_uuid (connection));
@@ -7845,9 +7835,9 @@ do_connection_edit (NmCli *nmc, int argc, char **argv)
while (!connection_type) {
if (!type)
- printf (_("Valid connection types: %s\n"), tmp_str);
+ g_print (_("Valid connection types: %s\n"), tmp_str);
else
- printf (_("Error: invalid connection type; %s\n"), err1->message);
+ g_print (_("Error: invalid connection type; %s\n"), err1->message);
g_clear_error (&err1);
type_ask = nmc_readline (EDITOR_PROMPT_CON_TYPE);
@@ -7885,18 +7875,18 @@ do_connection_edit (NmCli *nmc, int argc, char **argv)
/* nmcli runs the editor */
nmc->in_editor = TRUE;
- printf ("\n");
- printf (_("===| nmcli interactive connection editor |==="));
- printf ("\n\n");
+ g_print ("\n");
+ g_print (_("===| nmcli interactive connection editor |==="));
+ g_print ("\n\n");
if (con)
- printf (_("Editing existing '%s' connection: '%s'"), connection_type, con);
+ g_print (_("Editing existing '%s' connection: '%s'"), connection_type, con);
else
- printf (_("Adding a new '%s' connection"), connection_type);
- printf ("\n\n");
- printf (_("Type 'help' or '?' for available commands."));
- printf ("\n");
- printf (_("Type 'describe [<setting>.<prop>]' for detailed property description."));
- printf ("\n\n");
+ g_print (_("Adding a new '%s' connection"), connection_type);
+ g_print ("\n\n");
+ g_print (_("Type 'help' or '?' for available commands."));
+ g_print ("\n");
+ g_print (_("Type 'describe [<setting>.<prop>]' for detailed property description."));
+ g_print ("\n\n");
/* Set global variables for use in TAB completion */
nmc_tab_completion.nmc = nmc;
@@ -7940,9 +7930,9 @@ modify_connection_cb (GObject *connection,
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
} else {
if (nmc->print_output == NMC_PRINT_PRETTY)
- printf (_("Connection '%s' (%s) successfully modified.\n"),
- nm_connection_get_id (NM_CONNECTION (connection)),
- nm_connection_get_uuid (NM_CONNECTION (connection)));
+ g_print (_("Connection '%s' (%s) successfully modified.\n"),
+ nm_connection_get_id (NM_CONNECTION (connection)),
+ nm_connection_get_uuid (NM_CONNECTION (connection)));
}
quit ();
}
@@ -8207,7 +8197,7 @@ do_connection_delete (NmCli *nmc, int argc, char **argv)
connection = nmc_find_connection (nmc->system_connections, selector, *arg_ptr, &pos);
if (!connection) {
if (nmc->print_output != NMC_PRINT_TERSE)
- printf (_("Error: unknown connection: %s\n"), *arg_ptr);
+ g_print (_("Error: unknown connection: %s\n"), *arg_ptr);
if (!invalid_cons)
invalid_cons = g_string_new (NULL);
@@ -8315,7 +8305,7 @@ do_connection_load (NmCli *nmc, int argc, char **argv)
if (failures) {
for (i = 0; failures[i]; i++)
- fprintf (stderr, _("Could not load file '%s'\n"), failures[i]);
+ g_printerr (_("Could not load file '%s'\n"), failures[i]);
g_strfreev (failures);
}
diff --git a/clients/cli/devices.c b/clients/cli/devices.c
index d3ec905ca0..fc88309212 100644
--- a/clients/cli/devices.c
+++ b/clients/cli/devices.c
@@ -253,142 +253,134 @@ static guint progress_id = 0; /* ID of event source for displaying progress */
static void
usage (void)
{
- fprintf (stderr,
- _("Usage: nmcli device { COMMAND | help }\n\n"
+ g_printerr (_("Usage: nmcli device { COMMAND | help }\n\n"
#if WITH_WIMAX
- "COMMAND := { status | show | connect | disconnect | delete | wifi | wimax }\n\n"
+ "COMMAND := { status | show | connect | disconnect | delete | wifi | wimax }\n\n"
#else
- "COMMAND := { status | show | connect | disconnect | delete | wifi }\n\n"
+ "COMMAND := { status | show | connect | disconnect | delete | wifi }\n\n"
#endif
- " status\n\n"
- " show [<ifname>]\n\n"
- " connect <ifname>\n\n"
- " disconnect <ifname>\n\n"
- " delete <ifname>\n\n"
- " wifi [list [ifname <ifname>] [bssid <BSSID>]]\n\n"
- " wifi connect <(B)SSID> [password <password>] [wep-key-type key|phrase] [ifname <ifname>]\n"
- " [bssid <BSSID>] [name <name>] [private yes|no]\n\n"
- " wifi rescan [[ifname] <ifname>]\n\n"
+ " status\n\n"
+ " show [<ifname>]\n\n"
+ " connect <ifname>\n\n"
+ " disconnect <ifname>\n\n"
+ " delete <ifname>\n\n"
+ " wifi [list [ifname <ifname>] [bssid <BSSID>]]\n\n"
+ " wifi connect <(B)SSID> [password <password>] [wep-key-type key|phrase] [ifname <ifname>]\n"
+ " [bssid <BSSID>] [name <name>] [private yes|no]\n\n"
+ " wifi rescan [[ifname] <ifname>]\n\n"
#if WITH_WIMAX
- " wimax [list [ifname <ifname>] [nsp <name>]]\n\n"
+ " wimax [list [ifname <ifname>] [nsp <name>]]\n\n"
#endif
- ));
+ ));
}
static void
usage_device_status (void)
{
- fprintf (stderr,
- _("Usage: nmcli device status { help }\n"
- "\n"
- "Show status for all devices.\n"
- "By default, the following columns are shown:\n"
- " DEVICE - interface name\n"
- " TYPE - device type\n"
- " STATE - device state\n"
- " CONNECTION - connection activated on device (if any)\n"
- "Displayed columns can be changed using '--fields' global option. 'status' is\n"
- "the default command, which means 'nmcli device' calls 'nmcli device status'.\n\n"));
+ g_printerr (_("Usage: nmcli device status { help }\n"
+ "\n"
+ "Show status for all devices.\n"
+ "By default, the following columns are shown:\n"
+ " DEVICE - interface name\n"
+ " TYPE - device type\n"
+ " STATE - device state\n"
+ " CONNECTION - connection activated on device (if any)\n"
+ "Displayed columns can be changed using '--fields' global option. 'status' is\n"
+ "the default command, which means 'nmcli device' calls 'nmcli device status'.\n\n"));
}
static void
usage_device_show (void)
{
- fprintf (stderr,
- _("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"));
+ 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"));
}
static void
usage_device_connect (void)
{
- fprintf (stderr,
- _("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"));
+ 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"));
}
static void
usage_device_disconnect (void)
{
- fprintf (stderr,
- _("Usage: nmcli device disconnect { ARGUMENTS | help }\n"
- "\n"
- "ARGUMENTS := <ifname>\n"
- "\n"
- "Disconnect the device.\n"
- "The command disconnects the device and prevents it from auto-activating\n"
- "further connections without user/manual intervention.\n\n"));
+ g_printerr (_("Usage: nmcli device disconnect { ARGUMENTS | help }\n"
+ "\n"
+ "ARGUMENTS := <ifname>\n"
+ "\n"
+ "Disconnect the device.\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)
{
- fprintf (stderr,
- _("Usage: nmcli device delete { ARGUMENTS | help }\n"
- "\n"
- "ARGUMENTS := <ifname>\n"
- "\n"
- "Deletes the software device.\n"
- "The command removes the interface. It only works for software devices\n"
- "(like bonds, bridges, etc.). Hardware devices cannot be deleted by the\n"
- "command.\n\n"));
+ g_printerr (_("Usage: nmcli device delete { ARGUMENTS | help }\n"
+ "\n"
+ "ARGUMENTS := <ifname>\n"
+ "\n"
+ "Deletes the software device.\n"
+ "The command removes the interface. 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_wifi (void)
{
- fprintf (stderr,
- _("Usage: nmcli device wifi { ARGUMENTS | help }\n"
- "\n"
- "Perform operation on Wi-Fi devices.\n"
- "\n"
- "ARGUMENTS := [list [ifname <ifname>] [bssid <BSSID>]]\n"
- "\n"
- "List available Wi-Fi access points. The 'ifname' and 'bssid' options can be\n"
- "used to list APs for a particular interface, or with a specific BSSID.\n"
- "\n"
- "ARGUMENTS := connect <(B)SSID> [password <password>] [wep-key-type key|phrase] [ifname <ifname>]\n"
- " [bssid <BSSID>] [name <name>] [private yes|no]\n"
- "\n"
- "Connect to a Wi-Fi network specified by SSID or BSSID. The command creates\n"
- "a new connection and then activates it on a device. This is a command-line\n"
- "counterpart of clicking an SSID in a GUI client. The command always creates\n"
- "a new connection and thus it is mainly useful for connecting to new Wi-Fi\n"
- "networks. If a connection for the network already exists, it is better to\n"
- "bring up the existing profile as follows: nmcli con up id <name>. Note that\n"
- "only open, WEP and WPA-PSK networks are supported at the moment. It is also\n"
- "assumed that IP configuration is obtained via DHCP.\n"
- "\n"
- "ARGUMENTS := rescan [[ifname] <ifname>]\n"
- "\n"
- "Request that NetworkManager immediately re-scan for available access points.\n"
- "NetworkManager scans Wi-Fi networks periodically, but in some cases it might\n"
- "be useful to start scanning manually. Note that this command does not show\n"
- "the APs, use 'nmcli device wifi list' for that.\n\n"));
+ g_printerr (_("Usage: nmcli device wifi { ARGUMENTS | help }\n"
+ "\n"
+ "Perform operation on Wi-Fi devices.\n"
+ "\n"
+ "ARGUMENTS := [list [ifname <ifname>] [bssid <BSSID>]]\n"
+ "\n"
+ "List available Wi-Fi access points. The 'ifname' and 'bssid' options can be\n"
+ "used to list APs for a particular interface, or with a specific BSSID.\n"
+ "\n"
+ "ARGUMENTS := connect <(B)SSID> [password <password>] [wep-key-type key|phrase] [ifname <ifname>]\n"
+ " [bssid <BSSID>] [name <name>] [private yes|no]\n"
+ "\n"
+ "Connect to a Wi-Fi network specified by SSID or BSSID. The command creates\n"
+ "a new connection and then activates it on a device. This is a command-line\n"
+ "counterpart of clicking an SSID in a GUI client. The command always creates\n"
+ "a new connection and thus it is mainly useful for connecting to new Wi-Fi\n"
+ "networks. If a connection for the network already exists, it is better to\n"
+ "bring up the existing profile as follows: nmcli con up id <name>. Note that\n"
+ "only open, WEP and WPA-PSK networks are supported at the moment. It is also\n"
+ "assumed that IP configuration is obtained via DHCP.\n"
+ "\n"
+ "ARGUMENTS := rescan [[ifname] <ifname>]\n"
+ "\n"
+ "Request that NetworkManager immediately re-scan for available access points.\n"
+ "NetworkManager scans Wi-Fi networks periodically, but in some cases it might\n"
+ "be useful to start scanning manually. Note that this command does not show\n"
+ "the APs, use 'nmcli device wifi list' for that.\n\n"));
}
#if WITH_WIMAX
static void
usage_device_wimax (void)
{
- fprintf (stderr,
- _("Usage: nmcli device wimax { ARGUMENTS | help }\n"
- "\n"
- "Perform operation on WiMAX devices.\n"
- "\n"
- "ARGUMENTS := [list [ifname <ifname>] [nsp <name>]]\n"
- "\n"
- "List available WiMAX NSPs. The 'ifname' and 'nsp' options can be used to\n"
- "list networks for a particular interface, or with a specific NSP.\n\n"));
+ g_printerr (_("Usage: nmcli device wimax { ARGUMENTS | help }\n"
+ "\n"
+ "Perform operation on WiMAX devices.\n"
+ "\n"
+ "ARGUMENTS := [list [ifname <ifname>] [nsp <name>]]\n"
+ "\n"
+ "List available WiMAX NSPs. The 'ifname' and 'nsp' options can be used to\n"
+ "list networks for a particular interface, or with a specific NSP.\n\n"));
}
#endif
@@ -509,11 +501,6 @@ fill_output_access_point (gpointer data, gpointer user_data)
*bitrate_str, *strength_str, *wpa_flags_str, *rsn_flags_str;
GString *security_str;
char *ap_name;
- const char *sig_level_0 = "____";
- const char *sig_level_1 = "▂___";
- const char *sig_level_2 = "▂▄__";
- const char *sig_level_3 = "▂▄▆_";
- const char *sig_level_4 = "▂▄▆█";
const char *sig_bars;
if (info->active_bssid) {
@@ -548,11 +535,7 @@ fill_output_access_point (gpointer data, gpointer user_data)
strength_str = g_strdup_printf ("%u", strength);
wpa_flags_str = ap_wpa_rsn_flags_to_string (wpa_flags);
rsn_flags_str = ap_wpa_rsn_flags_to_string (rsn_flags);
- sig_bars = strength > 80 ? sig_level_4 :
- strength > 55 ? sig_level_3 :
- strength > 30 ? sig_level_2 :
- strength > 5 ? sig_level_1 :
- sig_level_0;
+ sig_bars = nm_utils_wifi_strength_bars (strength);
security_str = g_string_new (NULL);
@@ -831,7 +814,7 @@ show_device_info (NMDevice *device, NmCli *nmc)
char *section_fld = (char *) g_ptr_array_index (fields_in_section, k);
if (nmc->print_output != NMC_PRINT_TERSE && !nmc->multiline_output && was_output)
- printf ("\n"); /* Print empty line between groups in tabular mode */
+ g_print ("\n"); /* Print empty line between groups in tabular mode */
was_output = FALSE;
@@ -1244,7 +1227,7 @@ do_devices_status (NmCli *nmc, int argc, char **argv)
size_t tmpl_len;
while (argc > 0) {
- fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
+ g_printerr (_("Unknown parameter: %s\n"), *argv);
argc--;
argv++;
}
@@ -1329,7 +1312,7 @@ do_devices_show (NmCli *nmc, int argc, char **argv)
if (!ret)
break;
if (devices[i + 1])
- printf ("\n"); /* Empty line */
+ g_print ("\n"); /* Empty line */
}
}
@@ -1371,9 +1354,9 @@ connected_state_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
if (state == NM_DEVICE_STATE_ACTIVATED) {
nmc_terminal_erase_line ();
- printf (_("Device '%s' successfully activated with '%s'.\n"),
- nm_device_get_iface (device),
- nm_active_connection_get_uuid (active));
+ g_print (_("Device '%s' successfully activated with '%s'.\n"),
+ nm_device_get_iface (device),
+ nm_active_connection_get_uuid (active));
g_object_unref (active);
quit ();
}
@@ -1393,8 +1376,8 @@ monitor_device_state_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data
if (nmc->print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
- printf (_("Connection with UUID '%s' created and activated on device '%s'\n"),
- nm_active_connection_get_uuid (active), nm_device_get_iface (device));
+ g_print (_("Connection with UUID '%s' created and activated on device '%s'\n"),
+ nm_active_connection_get_uuid (active), nm_device_get_iface (device));
quit ();
} else if (state == NM_DEVICE_STATE_FAILED) {
reason = nm_device_get_state_reason (device);
@@ -1444,8 +1427,8 @@ add_and_activate_cb (GObject *client,
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
if (nmc->print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
- printf (_("Connection with UUID '%s' created and activated on device '%s'\n"),
- nm_active_connection_get_uuid (active), nm_device_get_iface (device));
+ g_print (_("Connection with UUID '%s' created and activated on device '%s'\n"),
+ nm_active_connection_get_uuid (active), nm_device_get_iface (device));
}
g_object_unref (active);
quit ();
@@ -1534,7 +1517,7 @@ connect_device_cb (GObject *client, GAsyncResult *result, gpointer user_data)
/* Don't want to wait or device already activated */
if (state == NM_DEVICE_STATE_ACTIVATED && nmc->print_output == NMC_PRINT_PRETTY) {
nmc_terminal_erase_line ();
- printf (_("Device '%s' has been connected.\n"), nm_device_get_iface (device));
+ g_print (_("Device '%s' has been connected.\n"), nm_device_get_iface (device));
}
quit ();
} else {
@@ -1668,7 +1651,7 @@ disconnect_device_cb (GObject *object, GAsyncResult *result, gpointer user_data)
if (state == NM_DEVICE_STATE_DISCONNECTED) {
if (nmc->print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
- printf (_("Device '%s' has been disconnected.\n"), nm_device_get_iface (device));
+ g_print (_("Device '%s' has been disconnected.\n"), nm_device_get_iface (device));
}
quit ();
} else {
@@ -1911,7 +1894,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
}
bssid_user = *argv;
} else {
- fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
+ g_printerr (_("Unknown parameter: %s\n"), *argv);
}
argc--;
@@ -2041,7 +2024,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
g_free (bssid_up);
}
if (empty_line)
- printf ("\n"); /* Empty line between devices' APs */
+ g_print ("\n"); /* Empty line between devices' APs */
print_data (nmc); /* Print all data */
nmc_empty_output_fields (nmc);
empty_line = TRUE;
@@ -2063,7 +2046,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
if (NM_IS_DEVICE_WIFI (dev)) {
if (empty_line)
- printf ("\n"); /* Empty line between devices' APs */
+ g_print ("\n"); /* Empty line between devices' APs */
show_access_point_info (dev, nmc);
empty_line = TRUE;
}
@@ -2285,7 +2268,7 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv)
goto error;
}
} else {
- fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
+ g_printerr (_("Unknown parameter: %s\n"), *argv);
}
argc--;
@@ -2571,7 +2554,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
}
nsp_user = *argv;
} else {
- fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
+ g_printerr (_("Unknown parameter: %s\n"), *argv);
}
argc--;
@@ -2684,7 +2667,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
g_free (nsp_up);
}
if (empty_line)
- printf ("\n"); /* Empty line between devices' NSPs */
+ g_print ("\n"); /* Empty line between devices' NSPs */
print_data (nmc); /* Print all data */
nmc_empty_output_fields (nmc);
empty_line = TRUE;
@@ -2705,7 +2688,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
if (NM_IS_DEVICE_WIMAX (dev)) {
if (empty_line)
- printf ("\n"); /* Empty line between devices' NSPs */
+ g_print ("\n"); /* Empty line between devices' NSPs */
show_nsp_info (dev, nmc);
empty_line = TRUE;
}
diff --git a/clients/cli/network-manager.c b/clients/cli/network-manager.c
index f65b51a82c..a071d6694c 100644
--- a/clients/cli/network-manager.c
+++ b/clients/cli/network-manager.c
@@ -19,7 +19,6 @@
#include "config.h"
-#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -89,161 +88,147 @@ extern GMainLoop *loop;
static void
usage_general (void)
{
- fprintf (stderr,
- _("Usage: nmcli general { COMMAND | help }\n\n"
- "COMMAND := { status | hostname | permissions | logging }\n\n"
- " status\n\n"
- " hostname [<hostname>]\n\n"
- " permissions\n\n"
- " logging [level <log level>] [domains <log domains>]\n\n"));
+ g_printerr (_("Usage: nmcli general { COMMAND | help }\n\n"
+ "COMMAND := { status | hostname | permissions | logging }\n\n"
+ " status\n\n"
+ " hostname [<hostname>]\n\n"
+ " permissions\n\n"
+ " logging [level <log level>] [domains <log domains>]\n\n"));
}
static void
usage_general_status (void)
{
- fprintf (stderr,
- _("Usage: nmcli general status { help }\n"
- "\n"
- "Show overall status of NetworkManager.\n"
- "'status' is the default action, which means 'nmcli gen' calls 'nmcli gen status'\n\n"));
+ g_printerr (_("Usage: nmcli general status { help }\n"
+ "\n"
+ "Show overall status of NetworkManager.\n"
+ "'status' is the default action, which means 'nmcli gen' calls 'nmcli gen status'\n\n"));
}
static void
usage_general_hostname (void)
{
- fprintf (stderr,
- _("Usage: nmcli general hostname { ARGUMENTS | help }\n"
- "\n"
- "ARGUMENTS := [<hostname>]\n"
- "\n"
- "Get or change persistent system hostname.\n"
- "With no arguments, this prints currently configured hostname. When you pass\n"
- "a hostname, NetworkManager will set it as the new persistent system hostname.\n\n"));
+ g_printerr (_("Usage: nmcli general hostname { ARGUMENTS | help }\n"
+ "\n"
+ "ARGUMENTS := [<hostname>]\n"
+ "\n"
+ "Get or change persistent system hostname.\n"
+ "With no arguments, this prints currently configured hostname. When you pass\n"
+ "a hostname, NetworkManager will set it as the new persistent system hostname.\n\n"));
}
static void
usage_general_permissions (void)
{
- fprintf (stderr,
- _("Usage: nmcli general permissions { help }\n"
- "\n"
- "Show caller permissions for authenticated operations.\n\n"));
+ g_printerr (_("Usage: nmcli general permissions { help }\n"
+ "\n"
+ "Show caller permissions for authenticated operations.\n\n"));
}
static void
usage_general_logging (void)
{
- fprintf (stderr,
- _("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"));
+ 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"));
}
static void
usage_networking (void)
{
- fprintf (stderr,
- _("Usage: nmcli networking { COMMAND | help }\n\n"
- "COMMAND := { [ on | off | connectivity ] }\n\n"
- " on\n\n"
- " off\n\n"
- " connectivity [check]\n\n"));
+ 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"));
}
static void
usage_networking_on (void)
{
- fprintf (stderr,
- _("Usage: nmcli networking on { help }\n"
- "\n"
- "Switch networking on.\n\n"));
+ g_printerr (_("Usage: nmcli networking on { help }\n"
+ "\n"
+ "Switch networking on.\n\n"));
}
static void
usage_networking_off (void)
{
- fprintf (stderr,
- _("Usage: nmcli networking off { help }\n"
- "\n"
- "Switch networking off.\n\n"));
+ g_printerr (_("Usage: nmcli networking off { help }\n"
+ "\n"
+ "Switch networking off.\n\n"));
}
static void
usage_networking_connectivity (void)
{
- fprintf (stderr,
- _("Usage: nmcli networking connectivity { ARGUMENTS | help }\n"
- "\n"
- "ARGUMENTS := [check]\n"
- "\n"
- "Get network connectivity state.\n"
- "The optional 'check' argument makes NetworkManager re-check the connectivity.\n\n"));
+ g_printerr (_("Usage: nmcli networking connectivity { ARGUMENTS | help }\n"
+ "\n"
+ "ARGUMENTS := [check]\n"
+ "\n"
+ "Get network connectivity state.\n"
+ "The optional 'check' argument makes NetworkManager re-check the connectivity.\n\n"));
}
static void
usage_radio (void)
{
- fprintf (stderr,
- _("Usage: nmcli radio { COMMAND | help }\n\n"
+ g_printerr (_("Usage: nmcli radio { COMMAND | help }\n\n"
#if WITH_WIMAX
- "COMMAND := { all | wifi | wwan | wimax }\n\n"
- " all | wifi | wwan | wimax [ on | off ]\n\n"
+ "COMMAND := { all | wifi | wwan | wimax }\n\n"
+ " all | wifi | wwan | wimax [ on | off ]\n\n"
#else
- "COMMAND := { all | wifi | wwan }\n\n"
- " all | wifi | wwan [ on | off ]\n\n"
+ "COMMAND := { all | wifi | wwan }\n\n"
+ " all | wifi | wwan [ on | off ]\n\n"
#endif
- ));
+ ));
}
static void
usage_radio_all (void)
{
- fprintf (stderr,
- _("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"));
+ 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"));
}
static void
usage_radio_wifi (void)
{
- fprintf (stderr,
- _("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"));
+ 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"));
}
static void
usage_radio_wwan (void)
{
- fprintf (stderr,
- _("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"));
+ 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"));
}
#if WITH_WIMAX
static void
usage_radio_wimax (void)
{
- fprintf (stderr,
- _("Usage: nmcli radio wimax { ARGUMENTS | help }\n"
- "\n"
- "ARGUMENTS := [on | off]\n"
- "\n"
- "Get status of WiMAX radio switch, or turn it on/off.\n\n"));
+ g_printerr (_("Usage: nmcli radio wimax { ARGUMENTS | help }\n"
+ "\n"
+ "ARGUMENTS := [on | off]\n"
+ "\n"
+ "Get status of WiMAX radio switch, or turn it on/off.\n\n"));
}
#endif
@@ -620,14 +605,14 @@ do_general (NmCli *nmc, int argc, char **argv)
g_object_get (rem_settings, NM_REMOTE_SETTINGS_HOSTNAME, &hostname, NULL);
if (hostname)
- printf ("%s\n", hostname);
+ g_print ("%s\n", hostname);
g_free (hostname);
} else {
/* hostname provided -> set it */
const char *hostname = *argv;
if (next_arg (&argc, &argv) == 0)
- printf ("Warning: ignoring extra garbage after '%s' hostname\n", hostname);
+ g_print ("Warning: ignoring extra garbage after '%s' hostname\n", hostname);
nmc->should_wait = TRUE;
nm_remote_settings_save_hostname_async (rem_settings, hostname, NULL, save_hostname_cb, nmc);
diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c
index 99d0254b4c..83fa4f0603 100644
--- a/clients/cli/nmcli.c
+++ b/clients/cli/nmcli.c
@@ -78,29 +78,28 @@ nmcli_error_quark (void)
static void
usage (const char *prog_name)
{
- fprintf (stderr,
- _("Usage: %s [OPTIONS] OBJECT { COMMAND | help }\n"
- "\n"
- "OPTIONS\n"
- " -t[erse] terse output\n"
- " -p[retty] pretty output\n"
- " -m[ode] tabular|multiline output mode\n"
- " -f[ields] <field1,field2,...>|all|common specify fields to output\n"
- " -e[scape] yes|no escape columns separators in values\n"
- " -n[ocheck] don't check nmcli and NetworkManager versions\n"
- " -a[sk] ask for missing parameters\n"
- " -w[ait] <seconds> set timeout waiting for finishing operations\n"
- " -v[ersion] show program version\n"
- " -h[elp] print this help\n"
- "\n"
- "OBJECT\n"
- " g[eneral] NetworkManager's general status and operations\n"
- " n[etworking] overall networking control\n"
- " r[adio] NetworkManager radio switches\n"
- " c[onnection] NetworkManager's connections\n"
- " d[evice] devices managed by NetworkManager\n"
- "\n"),
- prog_name);
+ g_printerr (_("Usage: %s [OPTIONS] OBJECT { COMMAND | help }\n"
+ "\n"
+ "OPTIONS\n"
+ " -t[erse] terse output\n"
+ " -p[retty] pretty output\n"
+ " -m[ode] tabular|multiline output mode\n"
+ " -f[ields] <field1,field2,...>|all|common specify fields to output\n"
+ " -e[scape] yes|no escape columns separators in values\n"
+ " -n[ocheck] don't check nmcli and NetworkManager versions\n"
+ " -a[sk] ask for missing parameters\n"
+ " -w[ait] <seconds> set timeout waiting for finishing operations\n"
+ " -v[ersion] show program version\n"
+ " -h[elp] print this help\n"
+ "\n"
+ "OBJECT\n"
+ " g[eneral] NetworkManager's general status and operations\n"
+ " n[etworking] overall networking control\n"
+ " r[adio] NetworkManager radio switches\n"
+ " c[onnection] NetworkManager's connections\n"
+ " d[evice] devices managed by NetworkManager\n"
+ "\n"),
+ prog_name);
}
static NMCResultCode
@@ -248,7 +247,7 @@ parse_command_line (NmCli *nmc, int argc, char **argv)
}
nmc->timeout = (int) timeout;
} else if (matches (opt, "-version") == 0) {
- printf (_("nmcli tool, version %s\n"), NMCLI_VERSION);
+ g_print (_("nmcli tool, version %s\n"), NMCLI_VERSION);
return NMC_RESULT_SUCCESS;
} else if (matches (opt, "-help") == 0) {
usage (base);
@@ -334,8 +333,8 @@ signal_handling_thread (void *arg) {
} else {
/* We can quit nmcli */
nmc_cleanup_readline ();
- printf (_("\nError: nmcli terminated by signal %s (%d)\n"),
- strsignal (signo), signo);
+ g_print (_("\nError: nmcli terminated by signal %s (%d)\n"),
+ strsignal (signo), signo);
exit (1);
}
break;
@@ -343,8 +342,8 @@ signal_handling_thread (void *arg) {
case SIGTERM:
nmc_cleanup_readline ();
if (!nmcli_sigquit_internal)
- printf (_("\nError: nmcli terminated by signal %s (%d)\n"),
- strsignal (signo), signo);
+ g_print (_("\nError: nmcli terminated by signal %s (%d)\n"),
+ strsignal (signo), signo);
exit (1);
break;
default:
@@ -374,14 +373,14 @@ setup_signals (void)
/* Block all signals of interest. */
status = pthread_sigmask (SIG_BLOCK, &signal_set, NULL);
if (status != 0) {
- fprintf (stderr, _("Failed to set signal mask: %d\n"), status);
+ g_printerr (_("Failed to set signal mask: %d\n"), status);
return FALSE;
}
/* Create the signal handling thread. */
status = pthread_create (&signal_thread_id, NULL, signal_handling_thread, NULL);
if (status != 0) {
- fprintf (stderr, _("Failed to create signal handling thread: %d\n"), status);
+ g_printerr (_("Failed to create signal handling thread: %d\n"), status);
return FALSE;
}
@@ -588,7 +587,7 @@ main (int argc, char *argv[])
/* Print result descripting text */
if (nm_cli.return_value != NMC_RESULT_SUCCESS) {
- fprintf (stderr, "%s\n", nm_cli.return_text->str);
+ g_printerr ("%s\n", nm_cli.return_text->str);
}
g_main_loop_unref (loop);
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
index 33d8aca118..370b9d38da 100644
--- a/clients/cli/settings.c
+++ b/clients/cli/settings.c
@@ -19,7 +19,6 @@
#include "config.h"
-#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
@@ -1841,9 +1840,9 @@ wireless_band_channel_changed_cb (GObject *object, GParamSpec *pspec, gpointer u
mode = nm_setting_wireless_get_mode (NM_SETTING_WIRELESS (object));
if (!mode || !*mode || strcmp (mode, NM_SETTING_WIRELESS_MODE_INFRA) == 0) {
- printf (_("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);
+ 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);
}
}
@@ -2504,7 +2503,7 @@ nmc_property_connection_set_secondaries (NMSetting *setting, const char *prop, c
con = nmc_find_connection (nm_cli.system_connections,
"uuid", *iter, NULL);
if (!con)
- printf (_("Warning: %s is not an UUID of any existing connection profile\n"), *iter);
+ g_print (_("Warning: %s is not an UUID of any existing connection profile\n"), *iter);
else {
/* Currenly NM only supports VPN connections as secondaries */
if (!nm_connection_is_type (con, NM_SETTING_VPN_SETTING_NAME)) {
@@ -3804,8 +3803,8 @@ nmc_property_vlan_remove_priority_map (NMSetting *setting,
if (!prio_map)
return FALSE;
if (prio_map[1])
- printf (_("Warning: only one mapping at a time is supported; taking the first one (%s)\n"),
- prio_map[0]);
+ g_print (_("Warning: only one mapping at a time is supported; taking the first one (%s)\n"),
+ prio_map[0]);
ret = nm_setting_vlan_remove_priority_str_by_value (NM_SETTING_VLAN (setting),
map,
prio_map[0]);
@@ -4276,9 +4275,9 @@ nmc_property_wifi_set_wep_key (NMSetting *setting, const char *prop, const char
}
prev_idx = nm_setting_wireless_security_get_wep_tx_keyidx (NM_SETTING_WIRELESS_SECURITY (setting));
idx = prop[strlen (prop) - 1] - '0';
- printf (_("WEP key is guessed to be of '%s'\n"), wep_key_type_to_string (guessed_type));
+ g_print (_("WEP key is guessed to be of '%s'\n"), wep_key_type_to_string (guessed_type));
if (idx != prev_idx)
- printf (_("WEP key index set to '%d'\n"), idx);
+ g_print (_("WEP key index set to '%d'\n"), idx);
g_object_set (setting, prop, val, NULL);
g_object_set (setting, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, guessed_type, NULL);
@@ -4317,17 +4316,17 @@ nmc_property_wifi_set_wep_key_type (NMSetting *setting, const char *prop, const
key2 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 2);
key3 = nm_setting_wireless_security_get_wep_key (NM_SETTING_WIRELESS_SECURITY (setting), 3);
if (key0 && !nm_utils_wep_key_valid (key0, type))
- printf (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
- NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, wep_key_type_to_string (type));
+ g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
+ NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, wep_key_type_to_string (type));
if (key1 && !nm_utils_wep_key_valid (key1, type))
- printf (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
- NM_SETTING_WIRELESS_SECURITY_WEP_KEY1, wep_key_type_to_string (type));
+ g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
+ NM_SETTING_WIRELESS_SECURITY_WEP_KEY1, wep_key_type_to_string (type));
if (key2 && !nm_utils_wep_key_valid (key2, type))
- printf (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
- NM_SETTING_WIRELESS_SECURITY_WEP_KEY2, wep_key_type_to_string (type));
+ g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
+ NM_SETTING_WIRELESS_SECURITY_WEP_KEY2, wep_key_type_to_string (type));
if (key3 && !nm_utils_wep_key_valid (key3, type))
- printf (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
- NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, wep_key_type_to_string (type));
+ g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"),
+ NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, wep_key_type_to_string (type));
g_object_set (setting, prop, type, NULL);
return TRUE;
@@ -4487,7 +4486,7 @@ dcb_check_feature_enabled (NMSettingDcb *s_dcb, const char *flags_prop)
g_object_get (s_dcb, flags_prop, &flags, NULL);
if (!(flags & NM_SETTING_DCB_FLAG_ENABLE))
- printf (_("Warning: changes will have no effect until '%s' includes 1 (enabled)\n\n"), flags_prop);
+ g_print (_("Warning: changes will have no effect until '%s' includes 1 (enabled)\n\n"), flags_prop);
}
static gboolean
diff --git a/clients/cli/utils.c b/clients/cli/utils.c
index f9dac07d94..3152fe4de2 100644
--- a/clients/cli/utils.c
+++ b/clients/cli/utils.c
@@ -248,6 +248,9 @@ nmc_ip6_address_as_string (const struct in6_addr *ip, GError **error)
void
nmc_terminal_erase_line (void)
{
+ /* We intentionally use printf(), not g_print() here, to ensure that
+ * GLib doesn't mistakenly try to convert the string.
+ */
printf ("\33[2K\r");
fflush (stdout);
}
@@ -264,7 +267,7 @@ nmc_terminal_show_progress (const char *str)
const char slashes[4] = {'|', '/', '-', '\\'};
nmc_terminal_erase_line ();
- printf ("%c %s", slashes[idx++], str ? str : "");
+ g_print ("%c %s", slashes[idx++], str ? str : "");
fflush (stdout);
if (idx == 4)
idx = 0;
@@ -432,7 +435,7 @@ nmc_get_user_input (const char *ask_str)
size_t line_ln = 0;
ssize_t num;
- fprintf (stdout, "%s", ask_str);
+ g_print ("%s", ask_str);
num = getline (&line, &line_ln, stdin);
/* Remove newline from the string */
@@ -895,9 +898,9 @@ print_required_fields (NmCli *nmc, const NmcOutputField field_values[])
line = g_strnfill (ML_HEADER_WIDTH, '=');
width1 = strlen (fields.header_name);
width2 = nmc_string_screen_width (fields.header_name, NULL);
- printf ("%s\n", line);
- printf ("%*s\n", (table_width + width2)/2 + width1 - width2, fields.header_name);
- printf ("%s\n", line);
+ g_print ("%s\n", line);
+ g_print ("%*s\n", (table_width + width2)/2 + width1 - width2, fields.header_name);
+ g_print ("%s\n", line);
g_free (line);
}
@@ -927,8 +930,8 @@ print_required_fields (NmCli *nmc, const NmcOutputField field_values[])
j);
width1 = strlen (tmp);
width2 = nmc_string_screen_width (tmp, NULL);
- printf ("%-*s%s\n", terse ? 0 : ML_VALUE_INDENT+width1-width2, tmp,
- *p ? *p : not_set_str);
+ g_print ("%-*s%s\n", terse ? 0 : ML_VALUE_INDENT+width1-width2, tmp,
+ *p ? *p : not_set_str);
g_free (tmp);
}
} else {
@@ -942,14 +945,14 @@ print_required_fields (NmCli *nmc, const NmcOutputField field_values[])
_(field_values[idx].name_l10n));
width1 = strlen (tmp);
width2 = nmc_string_screen_width (tmp, NULL);
- printf ("%-*s%s\n", terse ? 0 : ML_VALUE_INDENT+width1-width2, tmp,
- val ? val : not_set_str);
+ g_print ("%-*s%s\n", terse ? 0 : ML_VALUE_INDENT+width1-width2, tmp,
+ val ? val : not_set_str);
g_free (tmp);
}
}
if (pretty) {
line = g_strnfill (ML_HEADER_WIDTH, '-');
- printf ("%s\n", line);
+ g_print ("%s\n", line);
g_free (line);
}
}
@@ -997,9 +1000,9 @@ print_required_fields (NmCli *nmc, const NmcOutputField field_values[])
line = g_strnfill (table_width, '=');
width1 = strlen (fields.header_name);
width2 = nmc_string_screen_width (fields.header_name, NULL);
- printf ("%s\n", line);
- printf ("%*s\n", (table_width + width2)/2 + width1 - width2, fields.header_name);
- printf ("%s\n", line);
+ g_print ("%s\n", line);
+ g_print ("%*s\n", (table_width + width2)/2 + width1 - width2, fields.header_name);
+ g_print ("%s\n", line);
g_free (line);
}
@@ -1011,14 +1014,14 @@ print_required_fields (NmCli *nmc, const NmcOutputField field_values[])
g_string_prepend (str, indent_str);
g_free (indent_str);
}
- printf ("%s\n", str->str);
+ g_print ("%s\n", str->str);
}
/* Print horizontal separator */
if (!main_header_only && field_names && pretty) {
if (str->len > 0) {
line = g_strnfill (table_width, '-');
- printf ("%s\n", line);
+ g_print ("%s\n", line);
g_free (line);
}
}
@@ -1107,9 +1110,8 @@ nmc_versions_match (NmCli *nmc)
if (dot) {
dot = strchr (dot + 1, '.');
if (dot && !strncmp (nm_ver, VERSION, dot-nm_ver)) {
- fprintf(stderr,
- _("Warning: nmcli (%s) and NetworkManager (%s) versions don't match. Use --nocheck to suppress the warning.\n"),
- VERSION, nm_ver);
+ g_printerr (_("Warning: nmcli (%s) and NetworkManager (%s) versions don't match. Use --nocheck to suppress the warning.\n"),
+ VERSION, nm_ver);
match = TRUE;
}
}
diff --git a/clients/tui/nmt-connect-connection-list.c b/clients/tui/nmt-connect-connection-list.c
index 98e46ba14f..a596364533 100644
--- a/clients/tui/nmt-connect-connection-list.c
+++ b/clients/tui/nmt-connect-connection-list.c
@@ -61,8 +61,6 @@ typedef struct {
GSList *nmt_devices;
} NmtConnectConnectionListPrivate;
-static const char *strength_full, *strength_high, *strength_med, *strength_low, *strength_none;
-
/**
* nmt_connect_connection_list_new:
*
@@ -527,16 +525,7 @@ nmt_connect_connection_list_rebuild (NmtConnectConnectionList *list)
if (nmtconn->ap) {
guint8 strength = nm_access_point_get_strength (nmtconn->ap);
- if (strength > 80)
- strength_col = strength_full;
- else if (strength > 55)
- strength_col = strength_high;
- else if (strength > 30)
- strength_col = strength_med;
- else if (strength > 5)
- strength_col = strength_low;
- else
- strength_col = strength_none;
+ strength_col = nm_utils_wifi_strength_bars (strength);
} else
strength_col = NULL;
@@ -608,30 +597,12 @@ static void
nmt_connect_connection_list_class_init (NmtConnectConnectionListClass *list_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (list_class);
- char *tmp;
g_type_class_add_private (list_class, sizeof (NmtConnectConnectionListPrivate));
/* virtual methods */
object_class->constructed = nmt_connect_connection_list_constructed;
object_class->finalize = nmt_connect_connection_list_finalize;
-
- /* globals */
- tmp = nmt_newt_locale_from_utf8 ("\342\226\202\342\226\204\342\226\206\342\226\210");
- if (*tmp) {
- strength_full = /* ▂▄▆█ */ "\342\226\202\342\226\204\342\226\206\342\226\210";
- strength_high = /* ▂▄▆_ */ "\342\226\202\342\226\204\342\226\206_";
- strength_med = /* ▂▄__ */ "\342\226\202\342\226\204__";
- strength_low = /* ▂___ */ "\342\226\202___";
- strength_none = /* ____ */ "____";
- } else {
- strength_full = "****";
- strength_high = "*** ";
- strength_med = "** ";
- strength_low = "* ";
- strength_none = " ";
- }
- g_free (tmp);
}
/**
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index 617b0b4df8..f1e592f535 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -2101,6 +2101,66 @@ nm_utils_wifi_is_channel_valid (guint32 channel, const char *band)
}
/**
+ * nm_utils_wifi_strength_bars:
+ * @strength: the access point strength, from 0 to 100
+ *
+ * Converts @strength into a 4-character-wide graphical representation of
+ * strength suitable for printing to stdout. If the current locale and terminal
+ * support it, this will use unicode graphics characters to represent
+ * "bars". Otherwise it will use 0 to 4 asterisks.
+ *
+ * Returns: the graphical representation of the access point strength
+ */
+const char *
+nm_utils_wifi_strength_bars (guint8 strength)
+{
+ static const char *strength_full, *strength_high, *strength_med, *strength_low, *strength_none;
+
+ if (G_UNLIKELY (strength_full == NULL)) {
+ gboolean can_show_graphics = TRUE;
+ char *locale_str;
+
+ if (!g_get_charset (NULL)) {
+ /* Non-UTF-8 locale */
+ locale_str = g_locale_from_utf8 ("\342\226\202\342\226\204\342\226\206\342\226\210", -1, NULL, NULL, NULL);
+ if (locale_str)
+ g_free (locale_str);
+ else
+ can_show_graphics = FALSE;
+ }
+
+ /* The linux console font doesn't have these characters */
+ if (g_strcmp0 (g_getenv ("TERM"), "linux") == 0)
+ can_show_graphics = FALSE;
+
+ if (can_show_graphics) {
+ strength_full = /* ▂▄▆█ */ "\342\226\202\342\226\204\342\226\206\342\226\210";
+ strength_high = /* ▂▄▆_ */ "\342\226\202\342\226\204\342\226\206_";
+ strength_med = /* ▂▄__ */ "\342\226\202\342\226\204__";
+ strength_low = /* ▂___ */ "\342\226\202___";
+ strength_none = /* ____ */ "____";
+ } else {
+ strength_full = "****";
+ strength_high = "*** ";
+ strength_med = "** ";
+ strength_low = "* ";
+ strength_none = " ";
+ }
+ }
+
+ if (strength > 80)
+ return strength_full;
+ else if (strength > 55)
+ return strength_high;
+ else if (strength > 30)
+ return strength_med;
+ else if (strength > 5)
+ return strength_low;
+ else
+ return strength_none;
+}
+
+/**
* nm_utils_hwaddr_len:
* @type: the type of address; either %ARPHRD_ETHER or %ARPHRD_INFINIBAND
*
diff --git a/libnm-core/nm-utils.h b/libnm-core/nm-utils.h
index 3bb4b9ff49..7402cd921d 100644
--- a/libnm-core/nm-utils.h
+++ b/libnm-core/nm-utils.h
@@ -131,6 +131,8 @@ guint32 nm_utils_wifi_channel_to_freq (guint32 channel, const char *band);
guint32 nm_utils_wifi_find_next_channel (guint32 channel, int direction, char *band);
gboolean nm_utils_wifi_is_channel_valid (guint32 channel, const char *band);
+const char *nm_utils_wifi_strength_bars (guint8 strength);
+
/**
* NM_UTILS_HWADDR_LEN_MAX:
*
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index 58da6c3be6..98a80082df 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -931,6 +931,7 @@ global:
nm_utils_wifi_find_next_channel;
nm_utils_wifi_freq_to_channel;
nm_utils_wifi_is_channel_valid;
+ nm_utils_wifi_strength_bars;
nm_utils_wpa_psk_valid;
nm_vlan_flags_get_type;
nm_vlan_priority_map_get_type;