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
|
|
|
|
2010-05-13 21:52:42 -07:00
|
|
|
#define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE 1
|
2010-05-13 21:56:07 -07:00
|
|
|
#include <libudev.h>
|
2010-05-13 21:52:42 -07:00
|
|
|
|
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
|
|
|
*/
|
|
|
|
/**
|
2010-07-30 11:19:04 -07:00
|
|
|
* @addtogroup 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
|
|
|
/**
|
2010-07-30 11:19:04 -07:00
|
|
|
* @addtogroup udev
|
|
|
|
* @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
|
|
|
/**
|
2010-07-30 11:19:04 -07:00
|
|
|
* @addtogroup udev udev
|
|
|
|
* @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 */
|
|
|
|
EEZE_UDEV_TYPE_NET
|
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;
|
|
|
|
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
|
|
|
|
#define EEZE_VERSION_MINOR 0
|
|
|
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* @addtogroup watch
|
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 *);
|
|
|
|
|
2010-05-22 00:04:00 -07:00
|
|
|
EAPI int eeze_init(void);
|
|
|
|
EAPI int eeze_shutdown(void);
|
2010-05-13 03:49:17 -07:00
|
|
|
|
2010-05-16 19:59:07 -07:00
|
|
|
EAPI Eina_List *eeze_udev_find_similar_from_syspath(const char *syspath);
|
2010-07-30 11:19:04 -07:00
|
|
|
EAPI Eina_List *eeze_udev_find_unlisted_similar(Eina_List *list);
|
2010-05-16 19:59:07 -07:00
|
|
|
EAPI Eina_List *eeze_udev_find_by_sysattr(const char *sysattr, const char *value);
|
2010-07-30 11:19:04 -07:00
|
|
|
EAPI Eina_List *eeze_udev_find_by_type(Eeze_Udev_Type type, const char *name);
|
2010-05-13 22:21:52 -07:00
|
|
|
EAPI Eina_List *eeze_udev_find_by_filter(const char *subsystem, const char *type, const char *name);
|
2011-03-12 10:41:03 -08:00
|
|
|
|
2010-05-22 14:44:26 -07:00
|
|
|
EAPI const char *eeze_udev_devpath_get_syspath(const char *devpath);
|
2010-05-16 19:59:07 -07:00
|
|
|
EAPI const char *eeze_udev_syspath_get_parent(const char *syspath);
|
|
|
|
EAPI Eina_List *eeze_udev_syspath_get_parents(const char *syspath);
|
2010-05-13 22:21:52 -07:00
|
|
|
EAPI const char *eeze_udev_syspath_get_devpath(const char *syspath);
|
2011-03-18 10:10:50 -07:00
|
|
|
EAPI const char *eeze_udev_syspath_get_devname(const char *syspath);
|
2010-05-13 22:21:52 -07:00
|
|
|
EAPI const char *eeze_udev_syspath_get_subsystem(const char *syspath);
|
|
|
|
EAPI const char *eeze_udev_syspath_get_property(const char *syspath, const char *property);
|
2010-05-20 00:30:41 -07:00
|
|
|
EAPI const char *eeze_udev_syspath_get_sysattr(const char *syspath, const char *sysattr);
|
2011-03-12 10:41:03 -08:00
|
|
|
|
2010-05-13 22:21:52 -07:00
|
|
|
EAPI Eina_Bool eeze_udev_syspath_is_mouse(const char *syspath);
|
|
|
|
EAPI Eina_Bool eeze_udev_syspath_is_kbd(const char *syspath);
|
|
|
|
EAPI Eina_Bool eeze_udev_syspath_is_touchpad(const char *syspath);
|
2011-03-12 10:41:03 -08:00
|
|
|
|
2010-05-20 21:11:58 -07:00
|
|
|
EAPI Eina_Bool eeze_udev_walk_check_sysattr(const char *syspath, const char *sysattr, const char *value);
|
|
|
|
EAPI const char *eeze_udev_walk_get_sysattr(const char *syspath, const char *sysattr);
|
2010-05-13 03:49:17 -07:00
|
|
|
|
2010-07-30 11:19:04 -07:00
|
|
|
EAPI Eeze_Udev_Watch *eeze_udev_watch_add(Eeze_Udev_Type type, int event, Eeze_Udev_Watch_Cb cb, void *user_data);
|
2010-05-14 00:02:50 -07:00
|
|
|
EAPI void *eeze_udev_watch_del(Eeze_Udev_Watch *watch);
|
2010-05-13 03:49:17 -07:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|