2010-05-20 21:11:58 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-05-22 00:04:00 -07:00
|
|
|
#include <Eeze.h>
|
2010-05-20 21:11:58 -07:00
|
|
|
#include "eeze_udev_private.h"
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
2011-01-05 10:46:32 -08:00
|
|
|
eeze_udev_walk_check_sysattr(const char *syspath,
|
|
|
|
const char *sysattr,
|
2010-05-21 18:55:14 -07:00
|
|
|
const char *value)
|
2010-05-20 21:11:58 -07:00
|
|
|
{
|
2010-05-21 18:55:14 -07:00
|
|
|
_udev_device *device, *child, *parent;
|
2010-10-12 19:53:38 -07:00
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2010-05-21 18:55:14 -07:00
|
|
|
const char *test = NULL;
|
|
|
|
|
|
|
|
if (!udev)
|
2010-10-15 21:18:26 -07:00
|
|
|
return EINA_FALSE;
|
2010-05-21 18:55:14 -07:00
|
|
|
|
2010-10-12 19:53:38 -07:00
|
|
|
if (!(device = _new_device(syspath)))
|
|
|
|
return EINA_FALSE;
|
2010-05-21 18:55:14 -07:00
|
|
|
|
|
|
|
for (parent = device; parent;
|
2011-01-05 10:46:32 -08:00
|
|
|
child = parent, parent = udev_device_get_parent(child))
|
2010-05-21 18:55:14 -07:00
|
|
|
{
|
2010-10-12 19:53:38 -07:00
|
|
|
if (!(test = udev_device_get_sysattr_value(parent, sysattr)))
|
|
|
|
continue;
|
|
|
|
if ((value && (!strcmp(test, value))) || (!value))
|
2010-05-21 18:55:14 -07:00
|
|
|
{
|
2010-10-12 19:53:38 -07:00
|
|
|
ret = EINA_TRUE;
|
|
|
|
break;
|
2010-05-21 18:55:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-20 21:11:58 -07:00
|
|
|
udev_device_unref(device);
|
2011-01-15 12:14:40 -08:00
|
|
|
return ret;
|
2010-05-20 21:11:58 -07:00
|
|
|
}
|
|
|
|
|
2010-05-21 18:55:14 -07:00
|
|
|
EAPI const char *
|
2011-01-05 10:46:32 -08:00
|
|
|
eeze_udev_walk_get_sysattr(const char *syspath,
|
|
|
|
const char *sysattr)
|
2010-05-20 21:11:58 -07:00
|
|
|
{
|
2010-05-21 18:55:14 -07:00
|
|
|
_udev_device *device, *child, *parent;
|
|
|
|
const char *test = NULL;
|
|
|
|
|
|
|
|
if (!syspath)
|
|
|
|
return NULL;
|
|
|
|
|
2010-10-12 19:53:38 -07:00
|
|
|
if (!(device = _new_device(syspath)))
|
|
|
|
return NULL;
|
2011-01-05 10:46:32 -08:00
|
|
|
|
2010-05-21 18:55:14 -07:00
|
|
|
for (parent = device; parent;
|
2011-01-05 10:46:32 -08:00
|
|
|
child = parent, parent = udev_device_get_parent(child))
|
2010-05-21 18:55:14 -07:00
|
|
|
{
|
|
|
|
if ((test = udev_device_get_sysattr_value(parent, sysattr)))
|
|
|
|
{
|
|
|
|
test = eina_stringshare_add(test);
|
|
|
|
udev_device_unref(device);
|
|
|
|
return test;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-20 21:11:58 -07:00
|
|
|
udev_device_unref(device);
|
|
|
|
return NULL;
|
|
|
|
}
|