Iterating through a list of devices

Danny Budik dbudik at ist-traffic.com
Fri Apr 7 16:25:27 PDT 2006


I'm looking for a way to use HAL to iterate through a list of devices 
attached to my computer (in C). I previously used HAL to determine the 
device info of a "just plugged in device" using a libhal context. Now I 
need to search through the current device list to find a specific device 
  without having this context. In particular I'm looking for USB devices.

It seems to me from looking at the documentation that this is the order 
of what I need to be doing:

1) declare a LibHalPropertySet set
since I will be searching for usb devices I will set
set->properties_head->key ="usb.subsystem" and 
set->properties_head->str_value = "usb".

This is where I'm confused. What is the int type used for?

2) declare a LibHalPropertySet iterator
3) call libhal_property_set_get_num_elems (LibHalPropertySet *set)
4) do what i need to do with each property in the current set
5) iterate through the rest by iterating through the list by 
set->properties_head->next

Thanks,
Danny

-- 
Danny Budik
Systems Engineer
Inductive Signature Technologies, Inc.
http://www.ist-traffic.com
(865) 673-9434


More information about the hal mailing list