diff options
author | Mike Blumenkrantz <zmike@samsung.com> | 2014-03-21 16:37:21 -0400 |
---|---|---|
committer | Mike Blumenkrantz <zmike@samsung.com> | 2014-03-21 16:40:52 -0400 |
commit | 68d8afac9d36c80ae086c330daa5e45990661b91 (patch) | |
tree | 19960fbbe2f968942424a78e562ac217eba42731 /src/lib/eeze | |
parent | 4619c3de4e897a60b9c173c8867f93be790dcf8b (diff) | |
download | efl-68d8afac9d36c80ae086c330daa5e45990661b91.tar.gz |
eeze_udev gets more helper functions
eeze_udev_syspath_get_parent_filtered, eeze_udev_syspath_check_property, eeze_udev_syspath_check_sysattr
@feature
Diffstat (limited to 'src/lib/eeze')
-rw-r--r-- | src/lib/eeze/Eeze.h | 35 | ||||
-rw-r--r-- | src/lib/eeze/eeze_udev_syspath.c | 59 |
2 files changed, 93 insertions, 1 deletions
diff --git a/src/lib/eeze/Eeze.h b/src/lib/eeze/Eeze.h index 55d2230884..834956688f 100644 --- a/src/lib/eeze/Eeze.h +++ b/src/lib/eeze/Eeze.h @@ -419,6 +419,19 @@ EAPI const char *eeze_udev_devpath_get_syspath(const char *devpath); EAPI const char *eeze_udev_syspath_get_parent(const char *syspath); /** + * Find the parent device of a device from its syspath with a filter applied. + * + * @param syspath The syspath of a device, with or without "/sys/" + * @param subsystem The desired subsystem of the parent device + * @param devtype The desired device type of the parent device + * @return The syspath of the parent device + * + * Return a stringshared syspath (/sys/$syspath) for the parent device if one exists which matches the filter. + * @since 1.10 + */ +EAPI Eina_Stringshare *eeze_udev_syspath_get_parent_filtered(const char *syspath, const char *subsystem, const char *devtype); + +/** * Returns a list of all parent device syspaths for @p syspath. * * @param syspath The device to find parents of @@ -458,6 +471,17 @@ EAPI const char *eeze_udev_syspath_get_devname(const char *syspath); EAPI const char *eeze_udev_syspath_get_subsystem(const char *syspath); /** + * Check the property value of a device from the /sys/ path against a provided value. + * + * @param syspath The /sys/ path with or without the /sys/ + * @param property The property to check; full list of these is a FIXME + * @param value The value to check the property against + * @return @c EINA_TRUE if the property matches the supplied value + * @since 1.10 + */ +EAPI Eina_Bool eeze_udev_syspath_check_property(const char *syspath, const char *property, const char *value); + +/** * Get the property value of a device from the /sys/ path. * * @param syspath The /sys/ path with or without the /sys/ @@ -476,6 +500,17 @@ EAPI const char *eeze_udev_syspath_get_property(const char *syspath, const EAPI const char *eeze_udev_syspath_get_sysattr(const char *syspath, const char *sysattr); /** + * Check the sysattr value of a device from the /sys/ path against a provided value. + * + * @param syspath The /sys/ path with or without the /sys/ + * @param sysattr The sysattr to check; full list of these is a FIXME + * @param value The value to check the property against + * @return @c EINA_TRUE if the sysattr matches the supplied value + * @since 1.10 + */ +EAPI Eina_Bool eeze_udev_syspath_check_sysattr(const char *syspath, const char *sysattr, const char *value); + +/** * Checks whether the device is a mouse. * * @param syspath The /sys/ path with or without the /sys/ diff --git a/src/lib/eeze/eeze_udev_syspath.c b/src/lib/eeze/eeze_udev_syspath.c index 0dcf097c02..ea8dfadea0 100644 --- a/src/lib/eeze/eeze_udev_syspath.c +++ b/src/lib/eeze/eeze_udev_syspath.c @@ -5,6 +5,23 @@ #include <Eeze.h> #include "eeze_udev_private.h" +EAPI Eina_Stringshare * +eeze_udev_syspath_get_parent_filtered(const char *syspath, const char *subsystem, const char *devtype) +{ + _udev_device *device, *parent; + Eina_Stringshare *ret = NULL; + + EINA_SAFETY_ON_NULL_RETURN_VAL(syspath, NULL); + + if (!(device = _new_device(syspath))) + return NULL; + parent = udev_device_get_parent_with_subsystem_devtype(device, subsystem, devtype); + if (parent) + ret = eina_stringshare_add(udev_device_get_syspath(parent)); + udev_device_unref(device); + return ret; +} + EAPI const char * eeze_udev_syspath_get_parent(const char *syspath) { @@ -104,12 +121,32 @@ eeze_udev_syspath_get_subsystem(const char *syspath) return subsystem; } +EAPI Eina_Bool +eeze_udev_syspath_check_property(const char *syspath, const char *property, const char *value) +{ + _udev_device *device; + const char *test; + Eina_Bool ret = EINA_FALSE; + + if (!syspath || !property || !value) + return EINA_FALSE; + + if (!(device = _new_device(syspath))) + return EINA_FALSE; + if ((test = udev_device_get_property_value(device, property))) + ret = !strcmp(test, value); + + udev_device_unref(device); + return ret; +} + EAPI const char * eeze_udev_syspath_get_property(const char *syspath, const char *property) { _udev_device *device; - const char *value = NULL, *test; + const char *test; + Eina_Stringshare *value; if (!syspath || !property) return NULL; @@ -123,6 +160,26 @@ eeze_udev_syspath_get_property(const char *syspath, return value; } +EAPI Eina_Bool +eeze_udev_syspath_check_sysattr(const char *syspath, const char *sysattr, const char *value) +{ + _udev_device *device; + const char *test; + Eina_Bool ret = EINA_FALSE; + + if (!syspath || !sysattr || !value) + return EINA_FALSE; + + if (!(device = _new_device(syspath))) + return EINA_FALSE; + + if ((test = udev_device_get_sysattr_value(device, sysattr))) + ret = !strcmp(test, value); + + udev_device_unref(device); + return ret; +} + EAPI const char * eeze_udev_syspath_get_sysattr(const char *syspath, const char *sysattr) |