9 struct udev_enumerate
*udev_enum
;
10 struct udev_list_entry
*udev_le
, *udev_le_first
;
11 struct udev_monitor
*udev_monitor
;
12 struct udev_device
*udev_dev
;
14 prop_dictionary_t dict
;
24 udev_enum
= udev_enumerate_new(udev
);
26 perror("udev_enumerate_new");
31 ret
= udev_enumerate_add_match_expr(udev_enum
, "name", "da*");
33 err(1, "udev_enumerate_add_match_expr, out, ret=%d\n", ret
);
35 ret
= udev_enumerate_add_match_regex(udev_enum
, "name", "ad.*");
37 err(1, "udev_enumerate_add_match_regex, out, ret=%d\n", ret
);
39 ret
= udev_enumerate_scan_devices(udev_enum
);
43 err(1, "udev_enumerate_scan_device ret = %d", ret
);
47 udev_le_first
= udev_enumerate_get_list_entry(udev_enum
);
49 if (udev_le_first
== NULL
)
50 err(1, "udev_enumerate_get_list_entry error");
53 pa
= udev_enumerate_get_array(udev_enum
);
55 prop_array_externalize_to_file(pa
, "array_out.xml");
57 udev_list_entry_foreach(udev_le
, udev_le_first
) {
58 dict
= udev_list_entry_get_dictionary(udev_le
);
59 printf("xml: %s\n\n\n", prop_dictionary_externalize(dict
));
62 udev_enumerate_unref(udev_enum
);
64 udev_monitor
= udev_monitor_new(udev
);
66 ret
= udev_monitor_filter_add_match_regex(udev_monitor
, "name", "vn.*");
68 err(1, "udev_monitor_filter_add_match_expr ret = %d", ret
);
71 ret
= udev_monitor_filter_add_nomatch_expr(udev_monitor
, "name", "vn*");
73 err(1, "udev_monitor_filter_add_match_expr2 ret = %d", ret
);
75 ret
= udev_monitor_enable_receiving(udev_monitor
);
77 err(1, "udev_monitor_enable_receiving ret = %d", ret
);
80 while ((udev_dev
= udev_monitor_receive_device(udev_monitor
))) {
83 err(1, "udev_monitor_receive_device failed");
86 dict
= udev_device_get_dictionary(udev_dev
);
87 printf("xml of new device: %s\n", prop_dictionary_externalize(dict
));
89 udev_monitor_unref(udev_monitor
);