sd_hwdb_get
systemd
sd_hwdb_get
3
sd_hwdb_get
sd_hwdb_seek
sd_hwdb_enumerate
SD_HWDB_FOREACH_PROPERTY
Seek to a location in hwdb or access entries
#include <systemd/sd-hwdb.h>
int sd_hwdb_get
sd_hwdb *hwdb
const char *modalias
const char *key
const char **value
int sd_hwdb_seek
sd_hwdb *hwdb
const char *modalias
int sd_hwdb_enumerate
sd_hwdb *hwdb
const char **key
const char **value
SD_HWDB_FOREACH_PROPERTY
hwdb
modalias
key
value
Description
sd_hwdb_get() queries the hwdb object created earlier
with sd_hwdb_new3 for
entries matching the specified string modalias, and returns the value
corresponding to the the key key. The value is returned as a
NUL-terminated string in value. It must not be modified by
the caller and is valid as long as a reference to hwdb is kept. When multiple
patterns in the database match modalias, the one with the highest priority is
used. See hwdb7 for
details.
sd_hwdb_seek() selects entries matching the specified string
modalias. Subsequent queries with sd_hwdb_enumerate() will
access the key-value pairs for that string.
sd_hwdb_enumerate() returns (in turn) all the key-value pairs defined for the
string used with sd_hwdb_seek(). Each pair is returned as
NUL-terminated strings in key and
value. The strings must not be modified by the caller and are valid as long as a
reference to hwdb is kept. When multiple patterns in the database match
modalias, the combination of all matching key-value pairs is used. See
hwdb7 for
details.
The SD_HWDB_FOREACH_PROPERTY macro combines
sd_hwdb_seek() and sd_hwdb_enumerate(). No error handling is
performed and iteration simply stops on error. See the example below.
Return Value
On success, sd_hwdb_get() and sd_hwdb_seek() return a
non-negative integer. On failure, they return a negative errno-style error code.
sd_hwdb_enumerate() returns a positive integer if another key-value pair was found or zero if
all entries have already been enumerated. On failure, it returns a negative errno-style error code.
Errors
Returned errors may indicate the following problems:
-EINVAL
A parameter is NULL.
-ENOENT
An entry for the specified modalias was not found.
-EAGAIN
sd_hwdb_seek() was not called before
sd_hwdb_enumerate().
Examples
Look up hwdb entries for a USB device
The effect is similar to calling systemd-hwdb query usb:v046DpC534.
See Also
systemd1,
systemd-udev.service8,
sd-hwdb3,
systemd-hwdb8