summaryrefslogtreecommitdiff
path: root/src/lib/eeze
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2014-03-21 16:37:21 -0400
committerMike Blumenkrantz <zmike@samsung.com>2014-03-21 16:40:52 -0400
commit68d8afac9d36c80ae086c330daa5e45990661b91 (patch)
tree19960fbbe2f968942424a78e562ac217eba42731 /src/lib/eeze
parent4619c3de4e897a60b9c173c8867f93be790dcf8b (diff)
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.h35
-rw-r--r--src/lib/eeze/eeze_udev_syspath.c59
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);
419EAPI const char *eeze_udev_syspath_get_parent(const char *syspath); 419EAPI const char *eeze_udev_syspath_get_parent(const char *syspath);
420 420
421/** 421/**
422 * Find the parent device of a device from its syspath with a filter applied.
423 *
424 * @param syspath The syspath of a device, with or without "/sys/"
425 * @param subsystem The desired subsystem of the parent device
426 * @param devtype The desired device type of the parent device
427 * @return The syspath of the parent device
428 *
429 * Return a stringshared syspath (/sys/$syspath) for the parent device if one exists which matches the filter.
430 * @since 1.10
431 */
432EAPI Eina_Stringshare *eeze_udev_syspath_get_parent_filtered(const char *syspath, const char *subsystem, const char *devtype);
433
434/**
422 * Returns a list of all parent device syspaths for @p syspath. 435 * Returns a list of all parent device syspaths for @p syspath.
423 * 436 *
424 * @param syspath The device to find parents of 437 * @param syspath The device to find parents of
@@ -458,6 +471,17 @@ EAPI const char *eeze_udev_syspath_get_devname(const char *syspath);
458EAPI const char *eeze_udev_syspath_get_subsystem(const char *syspath); 471EAPI const char *eeze_udev_syspath_get_subsystem(const char *syspath);
459 472
460/** 473/**
474 * Check the property value of a device from the /sys/ path against a provided value.
475 *
476 * @param syspath The /sys/ path with or without the /sys/
477 * @param property The property to check; full list of these is a FIXME
478 * @param value The value to check the property against
479 * @return @c EINA_TRUE if the property matches the supplied value
480 * @since 1.10
481 */
482EAPI Eina_Bool eeze_udev_syspath_check_property(const char *syspath, const char *property, const char *value);
483
484/**
461 * Get the property value of a device from the /sys/ path. 485 * Get the property value of a device from the /sys/ path.
462 * 486 *
463 * @param syspath The /sys/ path with or without the /sys/ 487 * @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
476EAPI const char *eeze_udev_syspath_get_sysattr(const char *syspath, const char *sysattr); 500EAPI const char *eeze_udev_syspath_get_sysattr(const char *syspath, const char *sysattr);
477 501
478/** 502/**
503 * Check the sysattr value of a device from the /sys/ path against a provided value.
504 *
505 * @param syspath The /sys/ path with or without the /sys/
506 * @param sysattr The sysattr to check; full list of these is a FIXME
507 * @param value The value to check the property against
508 * @return @c EINA_TRUE if the sysattr matches the supplied value
509 * @since 1.10
510 */
511EAPI Eina_Bool eeze_udev_syspath_check_sysattr(const char *syspath, const char *sysattr, const char *value);
512
513/**
479 * Checks whether the device is a mouse. 514 * Checks whether the device is a mouse.
480 * 515 *
481 * @param syspath The /sys/ path with or without the /sys/ 516 * @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 @@
5#include <Eeze.h> 5#include <Eeze.h>
6#include "eeze_udev_private.h" 6#include "eeze_udev_private.h"
7 7
8EAPI Eina_Stringshare *
9eeze_udev_syspath_get_parent_filtered(const char *syspath, const char *subsystem, const char *devtype)
10{
11 _udev_device *device, *parent;
12 Eina_Stringshare *ret = NULL;
13
14 EINA_SAFETY_ON_NULL_RETURN_VAL(syspath, NULL);
15
16 if (!(device = _new_device(syspath)))
17 return NULL;
18 parent = udev_device_get_parent_with_subsystem_devtype(device, subsystem, devtype);
19 if (parent)
20 ret = eina_stringshare_add(udev_device_get_syspath(parent));
21 udev_device_unref(device);
22 return ret;
23}
24
8EAPI const char * 25EAPI const char *
9eeze_udev_syspath_get_parent(const char *syspath) 26eeze_udev_syspath_get_parent(const char *syspath)
10{ 27{
@@ -104,12 +121,32 @@ eeze_udev_syspath_get_subsystem(const char *syspath)
104 return subsystem; 121 return subsystem;
105} 122}
106 123
124EAPI Eina_Bool
125eeze_udev_syspath_check_property(const char *syspath, const char *property, const char *value)
126{
127 _udev_device *device;
128 const char *test;
129 Eina_Bool ret = EINA_FALSE;
130
131 if (!syspath || !property || !value)
132 return EINA_FALSE;
133
134 if (!(device = _new_device(syspath)))
135 return EINA_FALSE;
136 if ((test = udev_device_get_property_value(device, property)))
137 ret = !strcmp(test, value);
138
139 udev_device_unref(device);
140 return ret;
141}
142
107EAPI const char * 143EAPI const char *
108eeze_udev_syspath_get_property(const char *syspath, 144eeze_udev_syspath_get_property(const char *syspath,
109 const char *property) 145 const char *property)
110{ 146{
111 _udev_device *device; 147 _udev_device *device;
112 const char *value = NULL, *test; 148 const char *test;
149 Eina_Stringshare *value;
113 150
114 if (!syspath || !property) 151 if (!syspath || !property)
115 return NULL; 152 return NULL;
@@ -123,6 +160,26 @@ eeze_udev_syspath_get_property(const char *syspath,
123 return value; 160 return value;
124} 161}
125 162
163EAPI Eina_Bool
164eeze_udev_syspath_check_sysattr(const char *syspath, const char *sysattr, const char *value)
165{
166 _udev_device *device;
167 const char *test;
168 Eina_Bool ret = EINA_FALSE;
169
170 if (!syspath || !sysattr || !value)
171 return EINA_FALSE;
172
173 if (!(device = _new_device(syspath)))
174 return EINA_FALSE;
175
176 if ((test = udev_device_get_sysattr_value(device, sysattr)))
177 ret = !strcmp(test, value);
178
179 udev_device_unref(device);
180 return ret;
181}
182
126EAPI const char * 183EAPI const char *
127eeze_udev_syspath_get_sysattr(const char *syspath, 184eeze_udev_syspath_get_sysattr(const char *syspath,
128 const char *sysattr) 185 const char *sysattr)