diff options
author | raster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33> | 2012-08-30 09:54:57 +0000 |
---|---|---|
committer | raster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33> | 2012-08-30 09:54:57 +0000 |
commit | 75cedceb190d191366c6cdec95f938f497b48aa9 (patch) | |
tree | 777edb8860438f02c0ebb7c64c11a33bdcff10f6 /src/lib/eeze_udev_walk.c | |
download | eeze-75cedceb190d191366c6cdec95f938f497b48aa9.tar.gz eeze-75cedceb190d191366c6cdec95f938f497b48aa9.tar.bz2 eeze-75cedceb190d191366c6cdec95f938f497b48aa9.zip |
EFL 1.7 svn doobies
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/branches/eeze-1.7@75862 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33
Diffstat (limited to 'src/lib/eeze_udev_walk.c')
-rw-r--r-- | src/lib/eeze_udev_walk.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/lib/eeze_udev_walk.c b/src/lib/eeze_udev_walk.c new file mode 100644 index 0000000..78e2aab --- /dev/null +++ b/src/lib/eeze_udev_walk.c @@ -0,0 +1,65 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <Eeze.h> +#include "eeze_udev_private.h" + +EAPI Eina_Bool +eeze_udev_walk_check_sysattr(const char *syspath, + const char *sysattr, + const char *value) +{ + _udev_device *device, *child, *parent; + Eina_Bool ret = EINA_FALSE; + const char *test = NULL; + + if (!udev) + return EINA_FALSE; + + if (!(device = _new_device(syspath))) + return EINA_FALSE; + + for (parent = device; parent; + child = parent, parent = udev_device_get_parent(child)) + { + if (!(test = udev_device_get_sysattr_value(parent, sysattr))) + continue; + if ((value && (!strcmp(test, value))) || (!value)) + { + ret = EINA_TRUE; + break; + } + } + + udev_device_unref(device); + return ret; +} + +EAPI const char * +eeze_udev_walk_get_sysattr(const char *syspath, + const char *sysattr) +{ + _udev_device *device, *child, *parent; + const char *test = NULL; + + if (!syspath) + return NULL; + + if (!(device = _new_device(syspath))) + return NULL; + + for (parent = device; parent; + child = parent, parent = udev_device_get_parent(child)) + { + if ((test = udev_device_get_sysattr_value(parent, sysattr))) + { + test = eina_stringshare_add(test); + udev_device_unref(device); + return test; + } + } + + udev_device_unref(device); + return NULL; +} |