diff options
author | Thomas Haller <thaller@redhat.com> | 2014-08-26 16:20:06 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-10-12 20:13:17 +0200 |
commit | 83e99c22276fec33d66b031b2a08db7cd3d3572b (patch) | |
tree | fbe27eb36eac9db8e10dec7718c967430aa8e09b | |
parent | c9476a4242cb648126bdc304d7aaa12b0e4b8cbf (diff) | |
download | NetworkManager-83e99c22276fec33d66b031b2a08db7cd3d3572b.tar.gz |
cli: add nmc_property_set_int() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | clients/cli/settings.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 9b3cbb2ba9..79437dca03 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -2160,6 +2160,26 @@ nmc_property_set_uint (NMSetting *setting, const char *prop, const char *val, GE } static gboolean +nmc_property_set_int (NMSetting *setting, const char *prop, const char *val, GError **error) +{ + long int val_int; + + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + if (!nmc_string_to_int (val, TRUE, G_MININT, G_MAXINT, &val_int)) { + g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val); + return FALSE; + } + + /* Validate the number according to the property spec */ + if (!validate_int (setting, prop, (gint) val_int, error)) + return FALSE; + + g_object_set (setting, prop, (gint) val_int, NULL); + return TRUE; +} + +static gboolean nmc_property_set_bool (NMSetting *setting, const char *prop, const char *val, GError **error) { gboolean val_bool; |