/** * nm_setting_bond_validate_option: * @name: the name of the option to validate * @value: the value of the option to validate * * Checks whether @name is a valid bond option and @value is a valid value for * the @name. If @value is %NULL, the function only validates the option name. * * Returns: %TRUE, if the @value is valid for the given name. * If the @name is not a valid option, %FALSE will be returned. **/ gboolean nm_setting_bond_validate_option (const char *name, const char *value) { guint i; if (!name || !name[0]) return FALSE; for (i = 0; i < G_N_ELEMENTS (defaults); i++) { if (g_strcmp0 (defaults[i].opt, name) == 0) { if (value == NULL) return TRUE; switch (defaults[i].opt_type) { case NM_BOND_OPTION_TYPE_INT: return validate_int (name, value, &defaults[i]); case NM_BOND_OPTION_TYPE_STRING: return validate_list (name, value, &defaults[i]); case NM_BOND_OPTION_TYPE_BOTH: return ( validate_int (name, value, &defaults[i]) || validate_list (name, value, &defaults[i])); case NM_BOND_OPTION_TYPE_IP: return validate_ip (name, value); case NM_BOND_OPTION_TYPE_MAC: return nm_utils_hwaddr_valid (value, ETH_ALEN); case NM_BOND_OPTION_TYPE_IFNAME: return validate_ifname (name, value); } return FALSE; } } return FALSE; }
void test_inotify_map_get_path() { int i; setup(); for(i=0; i < 4; i++) validate_list(i, inotify_map_get_path(wdref[i])); assert(inotify_map_get_path(25) == NULL); teardown(); }