2011-04-08 03:43:13 -07:00
|
|
|
/**
|
2013-01-03 12:37:42 -08:00
|
|
|
|
|
|
|
@brief Eeze Device Library
|
|
|
|
|
|
|
|
@page eeze_main Eeze
|
|
|
|
|
|
|
|
@date 2010 (created)
|
|
|
|
|
|
|
|
@section toc Table of Contents
|
|
|
|
|
|
|
|
@li @ref eeze_main_intro
|
|
|
|
@li @ref eeze_main_compiling
|
|
|
|
@li @ref eeze_main_next_steps
|
|
|
|
|
|
|
|
@section eeze_main_intro Introduction
|
|
|
|
|
|
|
|
Eeze is a library for manipulating devices through udev with a
|
|
|
|
simple and fast api. It interfaces directly with libudev, avoiding
|
|
|
|
such middleman daemons as udisks/upower or hal, to immediately
|
|
|
|
gather device information the instant it becomes known to the
|
|
|
|
system. This can be used to determine such things as:
|
|
|
|
|
|
|
|
@li If a cdrom has a disk inserted
|
|
|
|
@li The temperature of a cpu core
|
|
|
|
@li The remaining power left in a battery
|
|
|
|
@li The current power consumption of various parts
|
|
|
|
@li Monitor in realtime the status of peripheral devices
|
|
|
|
|
|
|
|
Each of the above examples can be performed by using only a single eeze
|
|
|
|
function, as one of the primary focuses of the library is to reduce the
|
|
|
|
complexity of managing devices.
|
|
|
|
|
|
|
|
@section eeze_main_compiling How to compile
|
|
|
|
|
|
|
|
Eeze is a library your application links to. The procedure for this is very
|
|
|
|
simple. You simply have to compile your application with the appropriate
|
|
|
|
compiler flags that the @p pkg-config script outputs. For example:
|
|
|
|
|
|
|
|
Compiling C or C++ files into object files:
|
|
|
|
|
|
|
|
@verbatim
|
|
|
|
gcc -c -o main.o main.c `pkg-config --cflags eeze`
|
|
|
|
@endverbatim
|
|
|
|
|
|
|
|
Linking object files into a binary executable:
|
|
|
|
|
|
|
|
@verbatim
|
|
|
|
gcc -o my_application main.o `pkg-config --libs eeze`
|
|
|
|
@endverbatim
|
|
|
|
|
|
|
|
See @ref pkgconfig
|
|
|
|
|
|
|
|
@section eeze_main_next_steps Next Steps
|
|
|
|
|
|
|
|
After you understood what Eeze is and installed it in your system
|
|
|
|
you should proceed understanding the programming interface. We'd
|
|
|
|
recommend you to take a while to learn @ref Eina and @ref Ecore as
|
|
|
|
they convenient and Eeze provides integration with it.
|
|
|
|
|
|
|
|
Recommended reading:
|
|
|
|
|
|
|
|
@li @link Eeze.h Eeze functions @endlink
|
|
|
|
@li @ref Eeze_Udev UDEV functions
|
|
|
|
@li @ref Eeze_Watch Functions that watch for events
|
|
|
|
@li @ref Eeze_Syspath Functions that accept a device /sys/ path
|
|
|
|
@li @ref Eeze_Find Functions which find types of devices
|
|
|
|
@li @ref Eeze_Disk Disk functions
|
|
|
|
@li @ref Eeze_Net Net functions
|
|
|
|
@li @ref Eeze_Sensor Sensor functions
|
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
*/
|
2010-05-13 22:21:52 -07:00
|
|
|
#ifndef EEZE_UDEV_H
|
|
|
|
#define EEZE_UDEV_H
|
2010-05-13 03:49:17 -07:00
|
|
|
|
2010-10-12 19:53:33 -07:00
|
|
|
#include <Eina.h>
|
2010-05-13 03:49:17 -07:00
|
|
|
|
|
|
|
#ifdef EAPI
|
2010-05-22 11:50:27 -07:00
|
|
|
# undef EAPI
|
2010-05-13 03:49:17 -07:00
|
|
|
#endif
|
2010-05-14 00:02:50 -07:00
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
# if __GNUC__ >= 4
|
|
|
|
# define EAPI __attribute__ ((visibility("default")))
|
2010-05-13 03:49:17 -07:00
|
|
|
# else
|
|
|
|
# define EAPI
|
|
|
|
# endif
|
2010-05-14 00:02:50 -07:00
|
|
|
#else
|
|
|
|
# define EAPI
|
2010-05-13 03:49:17 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2010-05-22 14:44:26 -07:00
|
|
|
* @file Eeze.h
|
|
|
|
* @brief Easy device manipulation.
|
2011-03-12 10:41:03 -08:00
|
|
|
*
|
2010-08-20 20:45:58 -07:00
|
|
|
* Eeze is a library for manipulating devices through udev with a simple and fast
|
|
|
|
* api. It interfaces directly with libudev, avoiding such middleman daemons as
|
|
|
|
* udisks/upower or hal, to immediately gather device information the instant it
|
|
|
|
* becomes known to the system. This can be used to determine such things as:
|
|
|
|
* @li If a cdrom has a disk inserted
|
|
|
|
* @li The temperature of a cpu core
|
|
|
|
* @li The remaining power left in a battery
|
|
|
|
* @li The current power consumption of various parts
|
|
|
|
* @li Monitor in realtime the status of peripheral devices
|
|
|
|
* Each of the above examples can be performed by using only a single eeze
|
|
|
|
* function, as one of the primary focuses of the library is to reduce the
|
|
|
|
* complexity of managing devices.
|
2010-05-13 03:49:17 -07:00
|
|
|
*
|
2010-07-30 11:19:04 -07:00
|
|
|
*
|
|
|
|
* For udev functions, see @ref udev.
|
2010-05-13 03:49:17 -07:00
|
|
|
*/
|
2011-04-08 03:43:13 -07:00
|
|
|
|
|
|
|
/**
|
2013-01-03 12:37:42 -08:00
|
|
|
* @defgroup Eeze_Main main
|
|
|
|
* @ingroup Eeze
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* These are general eeze functions which include init and shutdown.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-01-03 12:37:42 -08:00
|
|
|
* @defgroup Eeze_Udev udev
|
|
|
|
* @ingroup Eeze_Main
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* These are functions which interact directly with udev.
|
|
|
|
*/
|
|
|
|
|
2010-05-13 03:49:17 -07:00
|
|
|
/**
|
2013-01-03 12:37:42 -08:00
|
|
|
* @addtogroup Eeze_Udev
|
2011-03-12 10:41:03 -08:00
|
|
|
*
|
2010-07-30 11:19:04 -07:00
|
|
|
* These are the device subsystems of udev:
|
|
|
|
* @li ac97
|
|
|
|
* @li acpi
|
|
|
|
* @li bdi
|
|
|
|
* @li block
|
|
|
|
* @li bsg
|
|
|
|
* @li dmi
|
|
|
|
* @li graphics
|
|
|
|
* @li hid
|
|
|
|
* @li hwmon
|
|
|
|
* @li i2c
|
|
|
|
* @li input
|
|
|
|
* @li mem
|
|
|
|
* @li misc
|
|
|
|
* @li net
|
|
|
|
* @li pci
|
|
|
|
* @li pci_bus
|
|
|
|
* @li pci_express
|
|
|
|
* @li platform
|
|
|
|
* @li pnp
|
|
|
|
* @li rtc
|
|
|
|
* @li scsi
|
|
|
|
* @li scsi_device
|
|
|
|
* @li scsi_disk
|
|
|
|
* @li scsi_generic
|
|
|
|
* @li scsi_host
|
|
|
|
* @li serio
|
|
|
|
* @li sound
|
|
|
|
* @li thermal
|
|
|
|
* @li tty
|
|
|
|
* @li usb
|
|
|
|
* @li usb_device
|
|
|
|
* @li vc
|
|
|
|
* @li vtconsole
|
2010-05-13 03:49:17 -07:00
|
|
|
*
|
2010-07-30 11:19:04 -07:00
|
|
|
* These are the devtypes of udev.
|
|
|
|
* @li atapi
|
|
|
|
* @li audio
|
|
|
|
* @li block
|
|
|
|
* @li cd
|
|
|
|
* @li char
|
|
|
|
* @li disk
|
|
|
|
* @li floppy
|
|
|
|
* @li generic
|
|
|
|
* @li hid
|
|
|
|
* @li hub
|
|
|
|
* @li media
|
|
|
|
* @li optical
|
|
|
|
* @li printer
|
|
|
|
* @li rbc
|
|
|
|
* @li scsi
|
|
|
|
* @li storage
|
|
|
|
* @li tape
|
|
|
|
* @li video
|
2010-05-13 03:49:17 -07:00
|
|
|
*/
|
2010-07-30 11:19:04 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2010-05-13 03:49:17 -07:00
|
|
|
|
2010-05-22 14:44:26 -07:00
|
|
|
/**
|
2013-01-03 12:37:42 -08:00
|
|
|
* @addtogroup Eeze_Udev
|
2010-07-30 11:19:04 -07:00
|
|
|
* @typedef Eeze_Udev_Event
|
|
|
|
* @enum Eeze_Udev_Event
|
|
|
|
* @brief Flags for watch events
|
|
|
|
*
|
|
|
|
* These events are used to specify the events to watch in a
|
2010-10-15 20:57:54 -07:00
|
|
|
* #Eeze_Udev_Watch. They can be ORed together.
|
2010-07-30 11:19:04 -07:00
|
|
|
*@{
|
2010-05-22 14:44:26 -07:00
|
|
|
*/
|
2010-07-30 11:19:04 -07:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
/** - No event specified */
|
|
|
|
EEZE_UDEV_EVENT_NONE = 0xf0,
|
|
|
|
/** - Device added */
|
|
|
|
EEZE_UDEV_EVENT_ADD = (1 << 1),
|
|
|
|
/** - Device removed */
|
|
|
|
EEZE_UDEV_EVENT_REMOVE = (1 << 2),
|
|
|
|
/** - Device changed */
|
|
|
|
EEZE_UDEV_EVENT_CHANGE = (1 << 3),
|
|
|
|
/** - Device has come online */
|
|
|
|
EEZE_UDEV_EVENT_ONLINE = (1 << 4),
|
|
|
|
/** - Device has gone offline */
|
|
|
|
EEZE_UDEV_EVENT_OFFLINE = (1 << 5)
|
|
|
|
} Eeze_Udev_Event;
|
2010-05-22 14:44:26 -07:00
|
|
|
/** @} */
|
2010-05-19 21:28:05 -07:00
|
|
|
|
2010-05-22 14:44:26 -07:00
|
|
|
/**
|
2013-01-03 12:37:42 -08:00
|
|
|
* @addtogroup Eeze_Udev udev
|
2010-07-30 11:19:04 -07:00
|
|
|
* @typedef Eeze_Udev_Type Eeze_Udev_Type
|
|
|
|
* @enum Eeze_Udev_Type
|
2010-05-22 14:44:26 -07:00
|
|
|
* @brief Convenience types to simplify udev access.
|
2011-03-12 10:41:03 -08:00
|
|
|
*
|
2010-05-22 14:44:26 -07:00
|
|
|
* These types allow easy access to certain udev device types. They
|
|
|
|
* may only be used in specified functions.
|
2011-03-12 10:41:03 -08:00
|
|
|
*
|
2010-05-22 14:44:26 -07:00
|
|
|
* @{
|
|
|
|
*/
|
2010-05-13 03:49:17 -07:00
|
|
|
/*FIXME: these probably need to be bitmasks with categories*/
|
|
|
|
typedef enum
|
2010-07-30 11:19:04 -07:00
|
|
|
{
|
|
|
|
/** - No type */
|
2010-05-14 00:02:50 -07:00
|
|
|
EEZE_UDEV_TYPE_NONE,
|
2010-05-22 14:44:26 -07:00
|
|
|
/** - Keyboard device */
|
2010-05-14 00:02:50 -07:00
|
|
|
EEZE_UDEV_TYPE_KEYBOARD,
|
2010-05-22 14:44:26 -07:00
|
|
|
/** - Mouse device */
|
2010-05-14 00:02:50 -07:00
|
|
|
EEZE_UDEV_TYPE_MOUSE,
|
2010-05-22 14:44:26 -07:00
|
|
|
/** - Touchpad device */
|
2010-05-14 00:02:50 -07:00
|
|
|
EEZE_UDEV_TYPE_TOUCHPAD,
|
2010-05-22 14:44:26 -07:00
|
|
|
/** - Mountable drive */
|
2010-05-14 00:02:50 -07:00
|
|
|
EEZE_UDEV_TYPE_DRIVE_MOUNTABLE,
|
2010-05-22 14:44:26 -07:00
|
|
|
/** - Internal drive */
|
2010-05-14 00:02:50 -07:00
|
|
|
EEZE_UDEV_TYPE_DRIVE_INTERNAL,
|
2010-05-22 14:44:26 -07:00
|
|
|
/** - Removable drive */
|
2010-05-14 00:02:50 -07:00
|
|
|
EEZE_UDEV_TYPE_DRIVE_REMOVABLE,
|
2010-05-22 14:44:26 -07:00
|
|
|
/** - cd drive */
|
2010-05-14 00:02:50 -07:00
|
|
|
EEZE_UDEV_TYPE_DRIVE_CDROM,
|
2010-05-22 14:44:26 -07:00
|
|
|
/** - AC adapter */
|
2010-05-14 00:02:50 -07:00
|
|
|
EEZE_UDEV_TYPE_POWER_AC,
|
2010-05-22 14:44:26 -07:00
|
|
|
/** - Battery */
|
2010-05-19 21:28:05 -07:00
|
|
|
EEZE_UDEV_TYPE_POWER_BAT,
|
2010-05-22 14:44:26 -07:00
|
|
|
/** - Temperature sensor */
|
2011-03-12 10:39:33 -08:00
|
|
|
EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR,
|
|
|
|
/** - Network devices */
|
2011-07-15 10:28:13 -07:00
|
|
|
EEZE_UDEV_TYPE_NET,
|
|
|
|
/** - WebCam */
|
2012-01-09 02:50:05 -08:00
|
|
|
EEZE_UDEV_TYPE_V4L,
|
|
|
|
/** - Bluetooth */
|
2012-06-29 01:18:12 -07:00
|
|
|
EEZE_UDEV_TYPE_BLUETOOTH,
|
|
|
|
/** - Joystick
|
2012-07-09 03:20:21 -07:00
|
|
|
* @since 1.7
|
2012-06-29 01:18:12 -07:00
|
|
|
*/
|
|
|
|
EEZE_UDEV_TYPE_JOYSTICK
|
2010-05-14 00:02:50 -07:00
|
|
|
} Eeze_Udev_Type;
|
2010-05-22 14:44:26 -07:00
|
|
|
/**@}*/
|
2010-05-13 03:49:17 -07:00
|
|
|
|
2010-05-14 00:02:50 -07:00
|
|
|
struct Eeze_Udev_Watch;
|
2012-06-26 02:08:49 -07:00
|
|
|
|
|
|
|
/**
|
2013-01-03 12:37:42 -08:00
|
|
|
* @addtogroup Eeze_Watch
|
2012-06-26 02:08:49 -07:00
|
|
|
* @typedef Eeze_Udev_Watch Eeze_Udev_Watch
|
|
|
|
* @brief Opaque structure to hold data for a udev watch
|
|
|
|
*/
|
2010-05-14 00:02:50 -07:00
|
|
|
typedef struct Eeze_Udev_Watch Eeze_Udev_Watch;
|
2010-05-13 03:49:17 -07:00
|
|
|
|
2010-08-16 02:59:13 -07:00
|
|
|
#define EEZE_VERSION_MAJOR 1
|
2012-09-03 02:55:34 -07:00
|
|
|
#define EEZE_VERSION_MINOR 8
|
2010-08-16 02:59:13 -07:00
|
|
|
|
|
|
|
typedef struct _Eeze_Version
|
|
|
|
{
|
|
|
|
int major;
|
|
|
|
int minor;
|
|
|
|
int micro;
|
|
|
|
int revision;
|
|
|
|
} Eeze_Version;
|
|
|
|
|
|
|
|
EAPI extern Eeze_Version *eeze_version;
|
2010-05-31 02:33:54 -07:00
|
|
|
|
2010-07-30 11:19:04 -07:00
|
|
|
/**
|
2013-01-03 12:37:42 -08:00
|
|
|
* @addtogroup Eeze_Watch
|
2012-06-26 02:08:49 -07:00
|
|
|
* @typedef Eeze_Udev_Watch_Cb Eeze_Udev_Watch_Cb
|
2010-10-15 20:57:54 -07:00
|
|
|
* @brief Callback type for use with #Eeze_Udev_Watch
|
2010-07-30 11:19:04 -07:00
|
|
|
*/
|
|
|
|
typedef void(*Eeze_Udev_Watch_Cb)(const char *, Eeze_Udev_Event, void *, Eeze_Udev_Watch *);
|
|
|
|
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Initialize the eeze library.
|
|
|
|
* @return The number of times the function has been called, or -1 on failure.
|
|
|
|
*
|
|
|
|
* This function should be called prior to using any eeze functions, and MUST
|
|
|
|
* be called prior to using any udev functions to avoid a segv.
|
|
|
|
*
|
2013-01-03 12:37:42 -08:00
|
|
|
* @ingroup Eeze_Main
|
2011-04-08 03:43:13 -07:00
|
|
|
*/
|
|
|
|
EAPI int eeze_init(void);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Shut down the eeze library.
|
|
|
|
* @return The number of times the eeze_init has been called, or -1 when
|
|
|
|
* all occurrences of eeze have been shut down.
|
|
|
|
*
|
|
|
|
* This function should be called when no further eeze functions will be called.
|
|
|
|
*
|
2013-01-03 12:37:42 -08:00
|
|
|
* @ingroup Eeze_Main
|
2011-04-08 03:43:13 -07:00
|
|
|
*/
|
|
|
|
EAPI int eeze_shutdown(void);
|
|
|
|
|
|
|
|
/**
|
2013-01-03 12:37:42 -08:00
|
|
|
* @addtogroup Eeze_Find Find
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* These are functions which find/supplement lists of devices.
|
|
|
|
*
|
2013-01-03 12:37:42 -08:00
|
|
|
* @ingroup Eeze_Udev
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Returns a stringshared list of all syspaths that are (or should be) the same
|
|
|
|
* device as the device pointed at by @p syspath.
|
|
|
|
*
|
|
|
|
* @param syspath The syspath of the device to find matches for
|
|
|
|
* @return All devices which are the same as the one passed
|
|
|
|
*/
|
|
|
|
EAPI Eina_List *eeze_udev_find_similar_from_syspath(const char *syspath);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Updates a list of all syspaths that are (or should be) the same
|
|
|
|
* device.
|
|
|
|
*
|
|
|
|
* @param list The list of devices to update
|
|
|
|
* @return The updated list
|
|
|
|
*
|
|
|
|
* This function will update @p list to include all devices matching
|
|
|
|
* devices with syspaths currently stored in @p list. All strings are
|
|
|
|
* stringshared.
|
2011-05-16 17:14:44 -07:00
|
|
|
*
|
|
|
|
* @note This is an expensive call, do not use it unless you must.
|
2011-04-08 03:43:13 -07:00
|
|
|
*/
|
|
|
|
EAPI Eina_List *eeze_udev_find_unlisted_similar(Eina_List *list);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Find a list of devices by a sysattr (and, optionally, a value of that sysattr).
|
|
|
|
*
|
|
|
|
* @param sysattr The attribute to find
|
|
|
|
* @param value Optional: the value that the attribute should have
|
|
|
|
*
|
|
|
|
* @return A stringshared list of the devices found with the attribute
|
|
|
|
*
|
2013-01-03 12:37:42 -08:00
|
|
|
* @ingroup Eeze_Find
|
2011-04-08 03:43:13 -07:00
|
|
|
*/
|
|
|
|
EAPI Eina_List *eeze_udev_find_by_sysattr(const char *sysattr, const char *value);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Find devices using an #Eeze_Udev_Type and/or a name.
|
|
|
|
*
|
2012-03-31 22:30:28 -07:00
|
|
|
* @param type An #Eeze_Udev_Type or 0
|
|
|
|
* @param name A filter for the device name or @c NULL
|
|
|
|
* @return A stringshared Eina_List of matched devices or @c NULL on failure
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* Return a list of syspaths (/sys/$syspath) for matching udev devices.
|
|
|
|
*/
|
|
|
|
EAPI Eina_List *eeze_udev_find_by_type(Eeze_Udev_Type type, const char *name);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* A more advanced find, allows finds using udev properties.
|
|
|
|
*
|
2012-03-31 22:30:28 -07:00
|
|
|
* @param subsystem The udev subsystem to filter by, or @c NULL
|
|
|
|
* @param type "ID_INPUT_KEY", "ID_INPUT_MOUSE", "ID_INPUT_TOUCHPAD", @c NULL, etc
|
|
|
|
* @param name A filter for the device name, or @c NULL
|
|
|
|
* @return A stringshared Eina_List* of matched devices or @c NULL on failure
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* Return a list of syspaths (/sys/$syspath) for matching udev devices.
|
|
|
|
* Requires at least one filter.
|
|
|
|
*/
|
|
|
|
EAPI Eina_List *eeze_udev_find_by_filter(const char *subsystem, const char *type, const char *name);
|
2011-05-16 03:38:47 -07:00
|
|
|
/**
|
|
|
|
* @}
|
2011-04-08 03:43:13 -07:00
|
|
|
*/
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
2013-01-03 12:37:42 -08:00
|
|
|
* @addtogroup Eeze_Syspath Syspath
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* These are functions which interact with the syspath (/sys/$PATH) of
|
|
|
|
* a device.
|
|
|
|
*
|
2013-01-03 12:37:42 -08:00
|
|
|
* @ingroup Eeze_Udev
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Get the syspath of a device from the /dev/ path.
|
|
|
|
*
|
|
|
|
* @param devpath The /dev/ path of the device
|
2012-03-31 22:30:28 -07:00
|
|
|
* @return A stringshared char* which corresponds to the /sys/ path of the device or @c NULL on failure
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* Takes "/dev/path" and returns the corresponding /sys/ path (without the "/sys/")
|
|
|
|
*/
|
|
|
|
EAPI const char *eeze_udev_devpath_get_syspath(const char *devpath);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Find the root device of a device from its syspath.
|
|
|
|
*
|
|
|
|
* @param syspath The syspath of a device, with or without "/sys/"
|
|
|
|
* @return The syspath of the parent device
|
|
|
|
*
|
|
|
|
* Return a stringshared syspath (/sys/$syspath) for the parent device.
|
|
|
|
*/
|
|
|
|
EAPI const char *eeze_udev_syspath_get_parent(const char *syspath);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Returns a list of all parent device syspaths for @p syspath.
|
|
|
|
*
|
|
|
|
* @param syspath The device to find parents of
|
|
|
|
* @return A stringshared list of the parent devices of @p syspath
|
|
|
|
*/
|
|
|
|
EAPI Eina_List *eeze_udev_syspath_get_parents(const char *syspath);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Get the /dev/ path from the /sys/ path.
|
|
|
|
*
|
|
|
|
* @param syspath The /sys/ path with or without the /sys/
|
2012-03-31 22:30:28 -07:00
|
|
|
* @return A stringshared char* with the /dev/ path or @c NULL on failure
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* Takes /sys/$PATH and turns it into the corresponding "/dev/x/y".
|
|
|
|
*/
|
|
|
|
EAPI const char *eeze_udev_syspath_get_devpath(const char *syspath);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Get the /dev/ name from the /sys/ path.
|
|
|
|
*
|
|
|
|
* @param syspath The /sys/ path with or without the /sys/
|
2012-03-31 22:30:28 -07:00
|
|
|
* @return A stringshared char* of the device name without the /dev/ path, or @c NULL on failure
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* Takes /sys/$PATH and turns it into the corresponding /dev/x/"y".
|
|
|
|
*/
|
|
|
|
EAPI const char *eeze_udev_syspath_get_devname(const char *syspath);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Get the subsystem of a device from the /sys/ path.
|
|
|
|
*
|
|
|
|
* @param syspath The /sys/ path with or without the /sys/
|
2012-03-31 22:30:28 -07:00
|
|
|
* @return A stringshared char* with the subsystem of the device or @c NULL on failure
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* Takes /sys/$PATH and returns the corresponding device subsystem,
|
|
|
|
* such as "input" for keyboards/mice.
|
|
|
|
*/
|
|
|
|
EAPI const char *eeze_udev_syspath_get_subsystem(const char *syspath);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Get the property value of a device from the /sys/ path.
|
|
|
|
*
|
|
|
|
* @param syspath The /sys/ path with or without the /sys/
|
|
|
|
* @param property The property to get; full list of these is a FIXME
|
2012-03-31 22:30:28 -07:00
|
|
|
* @return A stringshared char* with the property or @c NULL on failure
|
2011-04-08 03:43:13 -07:00
|
|
|
*/
|
|
|
|
EAPI const char *eeze_udev_syspath_get_property(const char *syspath, const char *property);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Get the sysattr value of a device from the /sys/ path.
|
|
|
|
*
|
|
|
|
* @param syspath The /sys/ path with or without the /sys/
|
|
|
|
* @param sysattr The sysattr to get; full list of these is a FIXME
|
2012-03-31 22:30:28 -07:00
|
|
|
* @return A stringshared char* with the sysattr or @c NULL on failure
|
2011-04-08 03:43:13 -07:00
|
|
|
*/
|
|
|
|
EAPI const char *eeze_udev_syspath_get_sysattr(const char *syspath, const char *sysattr);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Checks whether the device is a mouse.
|
|
|
|
*
|
|
|
|
* @param syspath The /sys/ path with or without the /sys/
|
|
|
|
* @return If true, the device is a mouse
|
|
|
|
*/
|
|
|
|
EAPI Eina_Bool eeze_udev_syspath_is_mouse(const char *syspath);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Checks whether the device is a keyboard.
|
|
|
|
*
|
|
|
|
* @param syspath The /sys/ path with or without the /sys/
|
|
|
|
* @return If true, the device is a keyboard
|
|
|
|
*/
|
|
|
|
EAPI Eina_Bool eeze_udev_syspath_is_kbd(const char *syspath);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Checks whether the device is a touchpad.
|
|
|
|
*
|
|
|
|
* @param syspath The /sys/ path with or without the /sys/
|
|
|
|
* @return If true, the device is a touchpad
|
|
|
|
*/
|
|
|
|
EAPI Eina_Bool eeze_udev_syspath_is_touchpad(const char *syspath);
|
2012-06-29 01:18:12 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether the device is a joystick.
|
|
|
|
*
|
|
|
|
* @param syspath The /sys/ path with or without the /sys/
|
|
|
|
* @return If true, the device is a joystick
|
2012-07-09 03:20:21 -07:00
|
|
|
* @since 1.7
|
2012-06-29 01:18:12 -07:00
|
|
|
*/
|
|
|
|
EAPI Eina_Bool eeze_udev_syspath_is_joystick(const char *syspath);
|
2011-05-16 03:38:47 -07:00
|
|
|
/**
|
|
|
|
* @}
|
2011-04-08 03:43:13 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-01-03 12:37:42 -08:00
|
|
|
* @addtogroup Eeze_Walks Walks
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* These are functions which walk up the device chain.
|
|
|
|
*
|
2013-01-03 12:37:42 -08:00
|
|
|
* @ingroup Eeze_Udev
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Walks up the device chain starting at @p syspath,
|
|
|
|
* checking each device for @p sysattr with (optional) @p value.
|
|
|
|
*
|
|
|
|
* @param syspath The /sys/ path of the device to start at, with or without the /sys/
|
|
|
|
* @param sysattr The attribute to find
|
2012-03-31 22:30:28 -07:00
|
|
|
* @param value OPTIONAL: The value that @p sysattr should have, or @c NULL
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* @return If the sysattr (with value) is found, returns TRUE. Else, false.
|
|
|
|
*/
|
|
|
|
EAPI Eina_Bool eeze_udev_walk_check_sysattr(const char *syspath, const char *sysattr, const char *value);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Walks up the device chain starting at @p syspath,
|
|
|
|
* checking each device for @p sysattr, and returns the value if found.
|
|
|
|
*
|
|
|
|
* @param syspath The /sys/ path of the device to start at, with or without the /sys/
|
|
|
|
* @param sysattr The attribute to find
|
|
|
|
*
|
2012-03-31 22:30:28 -07:00
|
|
|
* @return The stringshared value of @p sysattr if found, or @c NULL
|
2011-04-08 03:43:13 -07:00
|
|
|
*/
|
|
|
|
EAPI const char *eeze_udev_walk_get_sysattr(const char *syspath, const char *sysattr);
|
2011-05-16 03:38:47 -07:00
|
|
|
/**
|
|
|
|
* @}
|
2011-04-08 03:43:13 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-01-03 12:37:42 -08:00
|
|
|
* @addtogroup Eeze_Watch Watch
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* @brief These are functions which monitor udev for events.
|
|
|
|
*
|
|
|
|
* Eeze watches are simple: you specify a type of device to watch (or all devices), some events (or all) to watch for, a callback,
|
|
|
|
* and some data, and then udev watches those device types for events of the type you specified. Your callback is called with a
|
|
|
|
* syspath of the triggering device and the event that happened to the device, along with the data you associated with the watch and
|
|
|
|
* the watch object itself in case you want to stop the watch easily in a callback.
|
|
|
|
*
|
2013-01-03 12:37:42 -08:00
|
|
|
* @ingroup Eeze_Udev
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Add a watch for a device type
|
|
|
|
*
|
|
|
|
* @param type The #Eeze_Udev_Type to watch
|
|
|
|
* @param event The events to watch; an OR list of #Eeze_Udev_Event (ie (#EEZE_UDEV_EVENT_ADD | #EEZE_UDEV_EVENT_REMOVE)), or 0 for all events
|
|
|
|
* @param cb The function to call when the watch receives data of type #Eeze_Udev_Watch_Cb
|
|
|
|
* @param user_data Data to pass to the callback function
|
|
|
|
*
|
2012-03-31 22:30:28 -07:00
|
|
|
* @return A watch struct for the watch type specified, or @c NULL on failure
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* Eeze watches will monitor udev for changes of type(s) @p event to devices of type @p type. When these changes occur, the stringshared
|
|
|
|
* syspath of the device will be sent to function @p func, along with the bitmask of the event type which can be detected through
|
|
|
|
* binary &.
|
|
|
|
*/
|
|
|
|
EAPI Eeze_Udev_Watch *eeze_udev_watch_add(Eeze_Udev_Type type, int event, Eeze_Udev_Watch_Cb cb, void *user_data);
|
2011-05-16 03:38:47 -07:00
|
|
|
|
2011-04-08 03:43:13 -07:00
|
|
|
/**
|
|
|
|
* Deletes a watch.
|
|
|
|
*
|
|
|
|
* @param watch An Eeze_Udev_Watch object
|
2012-03-31 22:30:28 -07:00
|
|
|
* @return The data originally associated with the watch, or @c NULL
|
2011-04-08 03:43:13 -07:00
|
|
|
*
|
|
|
|
* Deletes a watch, closing file descriptors and freeing related udev memory.
|
|
|
|
*/
|
|
|
|
EAPI void *eeze_udev_watch_del(Eeze_Udev_Watch *watch);
|
2011-05-16 03:38:47 -07:00
|
|
|
/**
|
|
|
|
* @}
|
2011-04-08 03:43:13 -07:00
|
|
|
*/
|
2010-05-13 03:49:17 -07:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|