From: Marcel Holtmann Date: Fri, 2 Jan 2009 19:03:55 +0000 (+0100) Subject: Add checks for unavailable udev functions X-Git-Tag: 0.6~42 X-Git-Url: http://git.maemo.org/git/?p=connman;a=commitdiff_plain;h=7c00f5fc19e3fbc03e62a8f1a6edb6068afbaa06 Add checks for unavailable udev functions --- diff --git a/configure.ac b/configure.ac index ce99f4e..8b2abcd 100644 --- a/configure.ac +++ b/configure.ac @@ -103,6 +103,14 @@ AC_ARG_ENABLE(udev, AC_HELP_STRING([--enable-udev], [enable udev support]), [enable_udev=${enableval}]) if (test "${enable_udev}" = "yes"); then AC_DEFINE(HAVE_UDEV, 1, [Define if udev support is available]) + AC_CHECK_LIB(udev, udev_monitor_receive_device, dummy=yes, + AC_DEFINE(NEED_UDEV_MONITOR_RECEIVE_DEVICE, 1, + [Define to 1 if you need the + udev_monitor_receive_device() function.])) + AC_CHECK_LIB(udev, udev_device_get_action, dummy=yes, + AC_DEFINE(NEED_UDEV_DEVICE_GET_ACTION, 1, + [Define to 1 if you need the + udev_device_get_action() function.])) PKG_CHECK_MODULES(UDEV, libudev >= 127, enable_udev=yes, AC_MSG_ERROR(udev >= 127 is required)) fi diff --git a/src/udev.c b/src/udev.c index fcb0c4c..a14ce93 100644 --- a/src/udev.c +++ b/src/udev.c @@ -33,12 +33,26 @@ #include "connman.h" +#ifdef NEED_UDEV_MONITOR_RECEIVE_DEVICE +static struct udev_device *udev_monitor_receive_device(struct udev_monitor *monitor); +{ + return udev_monitor_get_device(monitor); +} +#endif + +#ifdef NEED_UDEV_DEVICE_GET_ACTION +static const char *udev_device_get_action(struct udev_device *device) +{ + return NULL; +} +#endif + static gboolean udev_event(GIOChannel *channel, GIOCondition condition, gpointer user_data) { struct udev_monitor *monitor = user_data; struct udev_device *device; - const char *action, *sysname; + const char *action; device = udev_monitor_receive_device(monitor); if (device == NULL) @@ -46,11 +60,12 @@ static gboolean udev_event(GIOChannel *channel, action = udev_device_get_action(device); if (action == NULL) - return TRUE; + goto done; - sysname = udev_device_get_sysname(device); + connman_debug("=== %s ===", action); - DBG("%s %s", action, sysname); +done: + udev_device_unref(device); return TRUE; }