91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina Pavel Březina <pbrezina@redhat.com>
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina Copyright (C) 2014 Red Hat
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina This program is free software; you can redistribute it and/or modify
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina it under the terms of the GNU General Public License as published by
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina the Free Software Foundation; either version 3 of the License, or
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina (at your option) any later version.
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina This program is distributed in the hope that it will be useful,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina GNU General Public License for more details.
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina You should have received a copy of the GNU General Public License
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina#define GET_ATTR(attrs, name, rtype, field, out, ret) do { \
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina sss_sifp_attr *attr = sss_sifp_find_attr(attrs, name); \
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina#define GET_ATTR_ARRAY(attrs, name, rtype, field, out_num, out_val, ret) \
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina sss_sifp_attr *attr = sss_sifp_find_attr(attrs, name); \
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinastatic sss_sifp_attr *sss_sifp_find_attr(sss_sifp_attr **attrs,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_bool(sss_sifp_attr **attrs,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina GET_ATTR(attrs, name, SSS_SIFP_ATTR_TYPE_BOOL, boolean, *_value, ret);
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_int16(sss_sifp_attr **attrs,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina GET_ATTR(attrs, name, SSS_SIFP_ATTR_TYPE_INT16, int16, *_value, ret);
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_uint16(sss_sifp_attr **attrs,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina GET_ATTR(attrs, name, SSS_SIFP_ATTR_TYPE_UINT16, uint16, *_value, ret);
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_int32(sss_sifp_attr **attrs,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina GET_ATTR(attrs, name, SSS_SIFP_ATTR_TYPE_INT32, int32, *_value, ret);
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_uint32(sss_sifp_attr **attrs,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina GET_ATTR(attrs, name, SSS_SIFP_ATTR_TYPE_UINT32, uint32, *_value, ret);
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_int64(sss_sifp_attr **attrs,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina GET_ATTR(attrs, name, SSS_SIFP_ATTR_TYPE_INT64, int64, *_value, ret);
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_uint64(sss_sifp_attr **attrs,
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina GET_ATTR(attrs, name, SSS_SIFP_ATTR_TYPE_UINT64, uint64, *_value, ret);
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_string(sss_sifp_attr **attrs,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina const char **_value)
973be642f3d33ba21ea9c06791295f09efcdba46Pavel Březina GET_ATTR(attrs, name, SSS_SIFP_ATTR_TYPE_STRING, str, value, ret);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březinasss_sifp_find_attr_as_string_dict(sss_sifp_attr **attrs,
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina sss_sifp_attr *attr = sss_sifp_find_attr(attrs, name);
efa6c1f75c4c18bcc148d6e7efd429c2d56499adPavel Březina if (attr->type != SSS_SIFP_ATTR_TYPE_STRING_DICT) {
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina * @brief Find attribute in list and return its values.
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina * @param[in] attrs Attributes
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina * @param[in] name Name of the attribute to find
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina * @return Attribute values or NULL if it is not found.
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_bool_array(sss_sifp_attr **attrs,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina unsigned int *_num_values,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina GET_ATTR_ARRAY(attrs, name, SSS_SIFP_ATTR_TYPE_BOOL, boolean,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_int16_array(sss_sifp_attr **attrs,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina unsigned int *_num_values,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina GET_ATTR_ARRAY(attrs, name, SSS_SIFP_ATTR_TYPE_INT16, int16,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_uint16_array(sss_sifp_attr **attrs,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina unsigned int *_num_values,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina GET_ATTR_ARRAY(attrs, name, SSS_SIFP_ATTR_TYPE_UINT16, uint16,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_int32_array(sss_sifp_attr **attrs,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina unsigned int *_num_values,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina GET_ATTR_ARRAY(attrs, name, SSS_SIFP_ATTR_TYPE_INT32, int32,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_uint32_array(sss_sifp_attr **attrs,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina unsigned int *_num_values,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina GET_ATTR_ARRAY(attrs, name, SSS_SIFP_ATTR_TYPE_UINT32, uint32,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_int64_array(sss_sifp_attr **attrs,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina unsigned int *_num_values,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina GET_ATTR_ARRAY(attrs, name, SSS_SIFP_ATTR_TYPE_INT64, int64,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_uint64_array(sss_sifp_attr **attrs,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina unsigned int *_num_values,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina GET_ATTR_ARRAY(attrs, name, SSS_SIFP_ATTR_TYPE_UINT64, uint64,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březinasss_sifp_find_attr_as_string_array(sss_sifp_attr **attrs,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina unsigned int *_num_values,
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina const char * const **_value)
91cf6f4c6069d6aff01aab171825e83a1a669e2fPavel Březina GET_ATTR_ARRAY(attrs, name, SSS_SIFP_ATTR_TYPE_STRING, str,