Add checks for unavailable udev functions
authorMarcel Holtmann <marcel@holtmann.org>
Fri, 2 Jan 2009 19:03:55 +0000 (20:03 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 2 Jan 2009 19:03:55 +0000 (20:03 +0100)
configure.ac
src/udev.c

index ce99f4e..8b2abcd 100644 (file)
@@ -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])
                [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
        PKG_CHECK_MODULES(UDEV, libudev >= 127, enable_udev=yes,
                                AC_MSG_ERROR(udev >= 127 is required))
 fi
index fcb0c4c..a14ce93 100644 (file)
 
 #include "connman.h"
 
 
 #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;
 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)
 
        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)
 
        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;
 }
 
        return TRUE;
 }