# Devices

## Functions

discover_device_t * | discover_device_find (char *discover_class, discover_error_t *status)
char * | discover_device_get_data (discover_device_t *device, char *discover_class, char *version, discover_error_t *status)
void | discover_device_copy (discover_device_t *src, discover_device_t *dst)
char * | discover_data_get_class (discover_data_t *data)
char * | discover_data_get_text (discover_data_t *data)
discover_data_t * | discover_data_get_parent (discover_data_t *data)
discover_data_t * | discover_data_get_child (discover_data_t *data)
discover_data_t * | discover_data_get_next (discover_data_t *data)
discover_data_t * | discover_data_get_prev (discover_data_t *data)
discover_data_t * | discover_data_get_first (discover_data_t *data)
discover_data_t * | discover_data_new (void)
void | discover_data_free (discover_data_t *data_tree)
char * | discover_device_get_busclass (discover_device_t *device)
char * | discover_device_get_model_id (discover_device_t *device)
char * | discover_device_get_model_name (discover_device_t *device)
char * | discover_device_get_vendor_id (discover_device_t *device)
char * | discover_device_get_vendor_name (discover_device_t *device)
discover_data_t * | discover_device_get_data_struct (discover_device_t *device)
discover_device_t * | discover_device_get_next (discover_device_t *device)
discover_device_t * | discover_device_new (void)
void | discover_device_free (discover_device_t *devices, int free_data)

## Function Documentation

void discover_data_free | ( | discover_data_t * | data_tree | ) |

Free the data tree. Note that unlike the other free functions in Discover, this one does not free data_tree itself. This is a side-effect of how it is implemented. It frees all children and siblings of data_tree as well as the data. After calling discover_data_free, you have to call free(3) on data_tree itself.

Parameters:

  | data_tree | Data tree to free

Definition at line 436 of file device.c.

References discover_data_free().

Referenced by discover_data_free(), and discover_device_free().

discover_data_t* discover_data_get_child | ( | discover_data_t * | data | ) |

| Get the child member of data. Definition at line 341 of file device.c.

char* discover_data_get_class | ( | discover_data_t * | data | ) |

| Get the class member of data. Definition at line 308 of file device.c.

discover_data_t* discover_data_get_first | ( | discover_data_t * | data | ) |

| Get the first member of data. Definition at line 374 of file device.c.

discover_data_t* discover_data_get_next | ( | discover_data_t * | data | ) |

| Get the next member of data. Definition at line 352 of file device.c.

discover_data_t* discover_data_get_parent | ( | discover_data_t * | data | ) |

| Get the parent member of data. Definition at line 330 of file device.c.

discover_data_t* discover_data_get_prev | ( | discover_data_t * | data | ) |

| Get the prev member of data. Definition at line 363 of file device.c.

char* discover_data_get_text | ( | discover_data_t * | data | ) |

| Get the text member of data. Definition at line 319 of file device.c.

discover_data_t* discover_data_new | ( | void |  | ) |

| Create and initialize a new discover_data_t structure. Definition at line 409 of file device.c. Referenced by _discover_convert_device_data().

void discover_device_copy | ( | discover_device_t * | src,
|  | discover_device_t * | dst
| ) |

Copy a device structure.

Parameters:

  | src | Copy from (source)
  | dst | Copy to (destination)

Definition at line 268 of file device.c.

Referenced by discover_device_find(), and discover_xml_get_matching_devices().

discover_device_t* discover_device_find | ( | char * | discover_class,
|  | discover_error_t * | status
| ) |

Get a list of devices of a specified class on all buses scanned by default.

Parameters:

  | discover_class | Class of devices to find
  | status | Address in which to place status report

Definition at line 63 of file device.c.

References discover_error::code, discover_error::create_message, discover_conf_get_full_bus_map(), discover_device_copy(), discover_device_get_next(), discover_device_new(), DISCOVER_EDEVICENOTFOUND, discover_get_devices(), DISCOVER_SUCCESS, discover_xml_busclass_cmp(), and discover_xml_get_busclasses().

void discover_device_free | ( | discover_device_t * | devices,
|  | int | free_data
| ) |

Free the device or list of devices. Pass 1 as the second argument to free the data structure for this device, 0 to leave it. It is necessary to specify 0 when one structure was copied from another with discover_device_copy. Otherwise, you must pass 1.

Parameters:

  | devices | Device or list of devices to free
  | free_data | Whether to free the data structure

Definition at line 592 of file device.c.

References discover_data_free().

Referenced by discover_free_devices(), and discover_xml_free_devices().

char* discover_device_get_busclass | ( | discover_device_t * | device | ) |

| Get the busclass member of device. Definition at line 485 of file device.c.

char* discover_device_get_data | ( | discover_device_t * | device,
|  | char * | discover_class,
|  | char * | version,
|  | discover_error_t * | status
| ) |

Get the data matching the class path and version number (optional) from the device structure.

The class parameter requires further explanation. The XML data sources have hierarchical data elements for each device. You access the data in an element by specifying the path along the data elements to it.

For example, device elements for video cards usually have a data element of class "xfree86" containing data related to the XFree86 package; that element itself usually contains a data element of class "server" that specifies which server to use for this video card. You access this data by passing the string "xfree86/server" to this function.

Parameters:

  | device | Device from which to get the data
  | discover_class | Class to search for
  | version | Version number to require (NULL for unversioned search)
  | status | Address in which to place status report

Definition at line 204 of file device.c.

References discover_error::code.

discover_data_t* discover_device_get_data_struct | ( | discover_device_t * | device | ) |

| Get the data member of device. Definition at line 540 of file device.c.

char* discover_device_get_model_id | ( | discover_device_t * | device | ) |

| Get the model_id member of device. Definition at line 496 of file device.c.

char* discover_device_get_model_name | ( | discover_device_t * | device | ) |

| Get the model_name member of device. Definition at line 507 of file device.c.

discover_device_t* discover_device_get_next | ( | discover_device_t * | device | ) |

| Get the next member of device. Definition at line 551 of file device.c. Referenced by discover_device_find().

char* discover_device_get_vendor_id | ( | discover_device_t * | device | ) |

| Get the vendor_id member of device. Definition at line 518 of file device.c.

char* discover_device_get_vendor_name | ( | discover_device_t * | device | ) |

| Get the vendor_name member of device. Definition at line 529 of file device.c.

discover_device_t* discover_device_new | ( | void |  | ) |

| Create and initialize a new discover_device_t structure. Definition at line 562 of file device.c. Referenced by discover_device_find(), discover_get_devices(), and discover_xml_get_matching_devices().