dbus: Simplify _wpa_dbus_dict_fill_value_from_variant() a bit

This commit is contained in:
Jouni Malinen 2010-01-02 10:59:51 +02:00
parent 97d3f8c3a9
commit fff9ab1b2d

View file

@ -765,87 +765,52 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_array(
static dbus_bool_t _wpa_dbus_dict_fill_value_from_variant( static dbus_bool_t _wpa_dbus_dict_fill_value_from_variant(
struct wpa_dbus_dict_entry *entry, DBusMessageIter *iter_dict_val) struct wpa_dbus_dict_entry *entry, DBusMessageIter *iter)
{ {
dbus_bool_t success = TRUE; const char *v;
switch (entry->type) { switch (entry->type) {
case DBUS_TYPE_STRING: { case DBUS_TYPE_OBJECT_PATH:
const char *v; case DBUS_TYPE_STRING:
dbus_message_iter_get_basic(iter_dict_val, &v); dbus_message_iter_get_basic(iter, &v);
entry->str_value = os_strdup(v); entry->str_value = os_strdup(v);
if (entry->str_value == NULL)
return FALSE;
break; break;
} case DBUS_TYPE_BOOLEAN:
case DBUS_TYPE_BOOLEAN: { dbus_message_iter_get_basic(iter, &entry->bool_value);
dbus_bool_t v;
dbus_message_iter_get_basic(iter_dict_val, &v);
entry->bool_value = v;
break; break;
} case DBUS_TYPE_BYTE:
case DBUS_TYPE_BYTE: { dbus_message_iter_get_basic(iter, &entry->byte_value);
char v;
dbus_message_iter_get_basic(iter_dict_val, &v);
entry->byte_value = v;
break; break;
} case DBUS_TYPE_INT16:
case DBUS_TYPE_INT16: { dbus_message_iter_get_basic(iter, &entry->int16_value);
dbus_int16_t v;
dbus_message_iter_get_basic(iter_dict_val, &v);
entry->int16_value = v;
break; break;
} case DBUS_TYPE_UINT16:
case DBUS_TYPE_UINT16: { dbus_message_iter_get_basic(iter, &entry->uint16_value);
dbus_uint16_t v;
dbus_message_iter_get_basic(iter_dict_val, &v);
entry->uint16_value = v;
break; break;
} case DBUS_TYPE_INT32:
case DBUS_TYPE_INT32: { dbus_message_iter_get_basic(iter, &entry->int32_value);
dbus_int32_t v;
dbus_message_iter_get_basic(iter_dict_val, &v);
entry->int32_value = v;
break; break;
} case DBUS_TYPE_UINT32:
case DBUS_TYPE_UINT32: { dbus_message_iter_get_basic(iter, &entry->uint32_value);
dbus_uint32_t v;
dbus_message_iter_get_basic(iter_dict_val, &v);
entry->uint32_value = v;
break; break;
} case DBUS_TYPE_INT64:
case DBUS_TYPE_INT64: { dbus_message_iter_get_basic(iter, &entry->int64_value);
dbus_int64_t v;
dbus_message_iter_get_basic(iter_dict_val, &v);
entry->int64_value = v;
break; break;
} case DBUS_TYPE_UINT64:
case DBUS_TYPE_UINT64: { dbus_message_iter_get_basic(iter, &entry->uint64_value);
dbus_uint64_t v;
dbus_message_iter_get_basic(iter_dict_val, &v);
entry->uint64_value = v;
break; break;
} case DBUS_TYPE_DOUBLE:
case DBUS_TYPE_DOUBLE: { dbus_message_iter_get_basic(iter, &entry->double_value);
double v;
dbus_message_iter_get_basic(iter_dict_val, &v);
entry->double_value = v;
break; break;
} case DBUS_TYPE_ARRAY:
case DBUS_TYPE_OBJECT_PATH: { return _wpa_dbus_dict_entry_get_array(iter, entry);
char *v;
dbus_message_iter_get_basic(iter_dict_val, &v);
entry->str_value = os_strdup(v);
break;
}
case DBUS_TYPE_ARRAY: {
success = _wpa_dbus_dict_entry_get_array(iter_dict_val, entry);
break;
}
default: default:
success = FALSE; return FALSE;
break;
} }
return success; return TRUE;
} }