diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2008-09-28 01:34:55 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-09-28 01:34:55 +0200 |
commit | 0de33a61d741699f41f47ebdb505f518722159b2 (patch) | |
tree | c49789c423a93087a7034505284d5c68e113ee34 /udev/lib/test-libudev.c | |
parent | e345e2670a8c17f5e1145cc554b7a7646e271032 (diff) |
libudev: more list rework
Diffstat (limited to 'udev/lib/test-libudev.c')
-rw-r--r-- | udev/lib/test-libudev.c | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/udev/lib/test-libudev.c b/udev/lib/test-libudev.c index f361ab12a4..bff55cfcd6 100644 --- a/udev/lib/test-libudev.c +++ b/udev/lib/test-libudev.c @@ -42,44 +42,60 @@ static void print_device(struct udev_device *device) const char *str; dev_t devnum; int count; - struct udev_list *list; + struct udev_list_entry *list_entry; printf("*** device: %p ***\n", device); str = udev_device_get_action(device); - printf("action: '%s'\n", str); + if (str != NULL) + printf("action: '%s'\n", str); + str = udev_device_get_syspath(device); printf("syspath: '%s'\n", str); + str = udev_device_get_devpath(device); printf("devpath: '%s'\n", str); + str = udev_device_get_subsystem(device); - printf("subsystem: '%s'\n", str); + if (str != NULL) + printf("subsystem: '%s'\n", str); + str = udev_device_get_driver(device); - printf("driver: '%s'\n", str); + if (str != NULL) + printf("driver: '%s'\n", str); + str = udev_device_get_devnode(device); - printf("devname: '%s'\n", str); + if (str != NULL) + printf("devname: '%s'\n", str); + devnum = udev_device_get_devnum(device); - printf("devnum: %u:%u\n", major(devnum), minor(devnum)); + if (major(devnum) > 0) + printf("devnum: %u:%u\n", major(devnum), minor(devnum)); count = 0; - list = udev_device_get_devlinks_list(device); - while (list != NULL) { - printf("link: '%s'\n", udev_list_entry_get_name(list)); + list_entry = udev_device_get_devlinks_list_entry(device); + while (list_entry != NULL) { + printf("link: '%s'\n", udev_list_entry_get_name(list_entry)); count++; - list = udev_list_entry_get_next(list); + list_entry = udev_list_entry_get_next(list_entry); } - printf("found %i links\n", count); + if (count > 0) + printf("found %i links\n", count); count = 0; - list = udev_device_get_properties_list(device); - while (list != NULL) { - printf("property: '%s=%s'\n", udev_list_entry_get_name(list), udev_list_entry_get_value(list)); + list_entry = udev_device_get_properties_list_entry(device); + while (list_entry != NULL) { + printf("property: '%s=%s'\n", + udev_list_entry_get_name(list_entry), + udev_list_entry_get_value(list_entry)); count++; - list = udev_list_entry_get_next(list); + list_entry = udev_list_entry_get_next(list_entry); } - printf("found %i properties\n", count); + if (count > 0) + printf("found %i properties\n", count); str = udev_device_get_attr_value(device, "dev"); - printf("attr{dev}: '%s'\n", str); + if (str != NULL) + printf("attr{dev}: '%s'\n", str); printf("\n"); } @@ -144,17 +160,17 @@ static int test_device_devnum(struct udev *udev) static int test_enumerate(struct udev *udev, const char *subsystem) { struct udev_enumerate *enumerate; - struct udev_list *list; + struct udev_list_entry *list_entry; int count = 0; enumerate = udev_enumerate_new_from_subsystems(udev, NULL); if (enumerate == NULL) return -1; - list = udev_enumerate_get_list(enumerate); - while (list != NULL) { + list_entry = udev_enumerate_get_list_entry(enumerate); + while (list_entry != NULL) { struct udev_device *device; - device = udev_device_new_from_syspath(udev, udev_list_entry_get_name(list)); + device = udev_device_new_from_syspath(udev, udev_list_entry_get_name(list_entry)); if (device != NULL) { printf("device: '%s' (%s) '%s'\n", udev_device_get_syspath(device), @@ -163,7 +179,7 @@ static int test_enumerate(struct udev *udev, const char *subsystem) udev_device_unref(device); count++; } - list = udev_list_entry_get_next(list); + list_entry = udev_list_entry_get_next(list_entry); } udev_enumerate_unref(enumerate); printf("found %i devices\n\n", count); |