mirror of
https://github.com/systemd/systemd.git
synced 2025-01-06 17:18:12 +03:00
sd-device: introduce device_get_property_int()
This commit is contained in:
parent
210033847c
commit
eedfef0f0d
@ -18,6 +18,7 @@ int device_new_from_strv(sd_device **ret, char **strv);
|
||||
int device_opendir(sd_device *device, const char *subdir, DIR **ret);
|
||||
|
||||
int device_get_property_bool(sd_device *device, const char *key);
|
||||
int device_get_property_int(sd_device *device, const char *key, int *ret);
|
||||
int device_get_sysattr_int(sd_device *device, const char *sysattr, int *ret_value);
|
||||
int device_get_sysattr_unsigned(sd_device *device, const char *sysattr, unsigned *ret_value);
|
||||
int device_get_sysattr_bool(sd_device *device, const char *sysattr);
|
||||
|
@ -2185,6 +2185,26 @@ int device_get_property_bool(sd_device *device, const char *key) {
|
||||
return parse_boolean(value);
|
||||
}
|
||||
|
||||
int device_get_property_int(sd_device *device, const char *key, int *ret) {
|
||||
const char *value;
|
||||
int r, v;
|
||||
|
||||
assert(device);
|
||||
assert(key);
|
||||
|
||||
r = sd_device_get_property_value(device, key, &value);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = safe_atoi(value, &v);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (ret)
|
||||
*ret = v;
|
||||
return 0;
|
||||
}
|
||||
|
||||
_public_ int sd_device_get_trigger_uuid(sd_device *device, sd_id128_t *ret) {
|
||||
const char *s;
|
||||
sd_id128_t id;
|
||||
|
Loading…
Reference in New Issue
Block a user