mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-05 11:20:36 +02:00
2007-01-26 Dan Williams <dcbw@redhat.com>
* libnm-util/dbus-dict-helpers.c libnm-util/dbus-dict-helpers.h - Coordinate style with wpa_supplicant version to minimize diff - Add uint32 array support - (nmu_dbus_dict_append_uint32_array): new function - (nmu_dbus_dict_begin_string_array, nmu_dbus_dict_string_array_add_element, nmu_dbus_dict_end_string_array): bring over from wpa_supplicant version; allow adding string array elements individually * test/libnm-util/test-dbus-dict-helpers.c - Test uint32 arrays git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2249 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
7798f8b2e6
commit
ca666cc549
4 changed files with 522 additions and 160 deletions
14
ChangeLog
14
ChangeLog
|
|
@ -1,3 +1,17 @@
|
|||
2007-01-26 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* libnm-util/dbus-dict-helpers.c
|
||||
libnm-util/dbus-dict-helpers.h
|
||||
- Coordinate style with wpa_supplicant version to minimize diff
|
||||
- Add uint32 array support
|
||||
- (nmu_dbus_dict_append_uint32_array): new function
|
||||
- (nmu_dbus_dict_begin_string_array, nmu_dbus_dict_string_array_add_element,
|
||||
nmu_dbus_dict_end_string_array): bring over from wpa_supplicant
|
||||
version; allow adding string array elements individually
|
||||
|
||||
* test/libnm-util/test-dbus-dict-helpers.c
|
||||
- Test uint32 arrays
|
||||
|
||||
2007-01-27 Jürg Billeter <j@bitron.ch>
|
||||
|
||||
* src/backends/NetworkManagerPaldo.c
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -99,6 +99,29 @@ nmu_dbus_dict_append_byte_array (DBusMessageIter *iter_dict,
|
|||
const char * value,
|
||||
const dbus_uint32_t value_len);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_uint32_array (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const dbus_uint32_t * value,
|
||||
const dbus_uint32_t value_len);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_begin_string_array (DBusMessageIter *iter_dict,
|
||||
const char *key,
|
||||
DBusMessageIter *iter_dict_entry,
|
||||
DBusMessageIter *iter_dict_val,
|
||||
DBusMessageIter *iter_array);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_string_array_add_element (DBusMessageIter *iter_array,
|
||||
const char *elem);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_end_string_array (DBusMessageIter *iter_dict,
|
||||
DBusMessageIter *iter_dict_entry,
|
||||
DBusMessageIter *iter_dict_val,
|
||||
DBusMessageIter *iter_array);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_string_array (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
|
|
@ -127,6 +150,7 @@ typedef struct NMUDictEntry {
|
|||
dbus_uint64_t uint64_value;
|
||||
double double_value;
|
||||
char * bytearray_value;
|
||||
dbus_uint32_t * uint32array_value;
|
||||
char ** strarray_value;
|
||||
};
|
||||
dbus_uint32_t array_len;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ DECLARE_ENTRY(UInt64Entry, dbus_uint64_t)
|
|||
DECLARE_ENTRY(DoubleEntry, double)
|
||||
DECLARE_ENTRY(OPEntry, const char *)
|
||||
DECLARE_ENTRY(ByteArrayEntry, const char *)
|
||||
DECLARE_ENTRY(UInt32ArrayEntry, dbus_uint32_t *)
|
||||
DECLARE_ENTRY(StringArrayEntry, char **)
|
||||
|
||||
struct DictEntries {
|
||||
|
|
@ -66,6 +67,8 @@ struct DictEntries {
|
|||
struct OPEntry op;
|
||||
struct ByteArrayEntry bytearr;
|
||||
struct ByteArrayEntry zlbytearr;
|
||||
struct UInt32ArrayEntry uint32arr;
|
||||
struct UInt32ArrayEntry zluint32arr;
|
||||
struct StringArrayEntry strarr;
|
||||
struct StringArrayEntry zlstrarr;
|
||||
};
|
||||
|
|
@ -83,10 +86,18 @@ struct DictEntries {
|
|||
#define TEST_KEY_OP "ObjectPath"
|
||||
#define TEST_KEY_BYTEARR "ByteArray"
|
||||
#define TEST_KEY_ZLBYTEARR "ZLByteArray"
|
||||
#define UINT32ARR_LEN 4
|
||||
#define TEST_KEY_UINT32ARR "UInt32Array"
|
||||
#define TEST_KEY_ZLUINT32ARR "ZLUInt32Array"
|
||||
#define STRARR_LEN 2
|
||||
#define TEST_KEY_STRINGARR "StringArray"
|
||||
#define TEST_KEY_ZLSTRINGARR "ZLStringArray"
|
||||
|
||||
#define UINT32ARR_ELEM0 0xdeadbeef
|
||||
#define UINT32ARR_ELEM1 0x1337bead
|
||||
#define UINT32ARR_ELEM2 0x11111113
|
||||
#define UINT32ARR_ELEM3 0xbdefac44
|
||||
|
||||
struct DictEntries entries = {
|
||||
{ TEST_KEY_STRING, "foobar22", FALSE, DBUS_TYPE_STRING },
|
||||
{ TEST_KEY_BYTE, 0x78, FALSE, DBUS_TYPE_BYTE },
|
||||
|
|
@ -101,6 +112,8 @@ struct DictEntries entries = {
|
|||
{ TEST_KEY_OP, "/com/it/foobar", FALSE, DBUS_TYPE_OBJECT_PATH },
|
||||
{ TEST_KEY_BYTEARR, "qazwsxedcrfvtgb",FALSE, DBUS_TYPE_BYTE },
|
||||
{ TEST_KEY_ZLBYTEARR,NULL, FALSE, DBUS_TYPE_BYTE },
|
||||
{ TEST_KEY_UINT32ARR,NULL, FALSE, DBUS_TYPE_UINT32 },
|
||||
{ TEST_KEY_ZLUINT32ARR,NULL, FALSE, DBUS_TYPE_UINT32 },
|
||||
{ TEST_KEY_STRINGARR,NULL, FALSE, DBUS_TYPE_STRING },
|
||||
{ TEST_KEY_ZLSTRINGARR,NULL, FALSE, DBUS_TYPE_STRING }
|
||||
};
|
||||
|
|
@ -173,6 +186,21 @@ test_write_dict (DBusMessage *message)
|
|||
err_string = "failed to append zero-length byte array entry";
|
||||
goto done;
|
||||
}
|
||||
entries.uint32arr.val = malloc (sizeof (dbus_uint32_t) * UINT32ARR_LEN);
|
||||
entries.uint32arr.val[0] = UINT32ARR_ELEM0;
|
||||
entries.uint32arr.val[1] = UINT32ARR_ELEM1;
|
||||
entries.uint32arr.val[2] = UINT32ARR_ELEM2;
|
||||
entries.uint32arr.val[3] = UINT32ARR_ELEM3;
|
||||
if (!nmu_dbus_dict_append_uint32_array (&iter_dict, entries.uint32arr.key,
|
||||
(const dbus_uint32_t *) entries.uint32arr.val, UINT32ARR_LEN)) {
|
||||
err_string = "failed to append uint32 array entry";
|
||||
goto done;
|
||||
}
|
||||
if (!nmu_dbus_dict_append_uint32_array (&iter_dict, entries.zluint32arr.key,
|
||||
(const dbus_uint32_t *)entries.zluint32arr.val, 0)) {
|
||||
err_string = "failed to append zero-length uint32 array entry";
|
||||
goto done;
|
||||
}
|
||||
entries.strarr.val = malloc (sizeof (char *) * STRARR_LEN);
|
||||
entries.strarr.val[0] = "foo";
|
||||
entries.strarr.val[1] = "bar";
|
||||
|
|
@ -251,8 +279,7 @@ test_read_dict (DBusMessage *message)
|
|||
goto done;
|
||||
}
|
||||
|
||||
while (nmu_dbus_dict_has_dict_entry (&iter_dict))
|
||||
{
|
||||
while (nmu_dbus_dict_has_dict_entry (&iter_dict)) {
|
||||
dbus_uint32_t bytearr_len = strlen (entries.bytearr.val);
|
||||
|
||||
if (!nmu_dbus_dict_get_entry (&iter_dict, &entry)) {
|
||||
|
|
@ -275,6 +302,13 @@ test_read_dict (DBusMessage *message)
|
|||
!memcmp (entry.bytearray_value, entries.bytearr.val, bytearr_len))
|
||||
TEST_CASE_ARRAY (TEST_KEY_ZLBYTEARR, entries.zlbytearr, 0,
|
||||
entry.bytearray_value == entries.zlbytearr.val)
|
||||
TEST_CASE_ARRAY (TEST_KEY_UINT32ARR, entries.uint32arr, UINT32ARR_LEN,
|
||||
(entry.uint32array_value[0] == UINT32ARR_ELEM0 &&
|
||||
entry.uint32array_value[1] == UINT32ARR_ELEM1 &&
|
||||
entry.uint32array_value[2] == UINT32ARR_ELEM2 &&
|
||||
entry.uint32array_value[3] == UINT32ARR_ELEM3))
|
||||
TEST_CASE_ARRAY (TEST_KEY_ZLUINT32ARR, entries.zluint32arr, 0,
|
||||
entry.uint32array_value == entries.zluint32arr.val)
|
||||
TEST_CASE_ARRAY (TEST_KEY_STRINGARR, entries.strarr, STRARR_LEN,
|
||||
(!strcmp (entry.strarray_value[0], "foo") && !strcmp (entry.strarray_value[1], "bar")))
|
||||
TEST_CASE_ARRAY (TEST_KEY_ZLSTRINGARR, entries.zlstrarr, 0,
|
||||
|
|
@ -291,6 +325,7 @@ test_read_dict (DBusMessage *message)
|
|||
|| !entries.uint16.found || !entries.int32.found || !entries.uint32.found
|
||||
|| !entries.int64.found || !entries.uint64.found || !entries.dbl.found
|
||||
|| !entries.op.found || !entries.bytearr.found || !entries.zlbytearr.found
|
||||
|| !entries.uint32arr.found || !entries.zluint32arr.found
|
||||
|| !entries.strarr.found || !entries.zlstrarr.found) {
|
||||
err_string = "A required entry was not found in the dict.";
|
||||
goto done;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue