[PATCH]: adapt to new DBusWatch api

Kel Modderman kel
Tue Nov 6 03:52:56 PST 2007


On Tue, 6 Nov 2007 01:36:23 pm Jouni Malinen wrote:
> On Tue, Nov 06, 2007 at 07:51:23AM +1000, Kel Modderman wrote:
> > Most other projects around that adjusted to this new stuff used
> > DBUS_VERSION_MAJOR, DBUS_VERSION_MINOR, DBUS_VERSION_MICRO that were
> > generated by `pkg-config --modversion dbus-1` + script somewhere in the
> > build system.
>
> This sounds like the best option here if the dbus header files cannot be
> assumed to have this sort of information. It would probably be fine to
> drop DBUS_VERSION_MICRO though and just base API selection on 1.0 vs.
> 1.1. In general, I do not like adding dependencies on new mechanisms in
> the build process, but since we are already using pkg-config for dbus,
> this should be fine.

Hi Dan, Jouni,

Here is the best pkg-config (ab)use I can come up with, perhaps it can be done
a bit better.

---
diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile
index 5821780..f99cbde 100644
--- a/wpa_supplicant/Makefile
+++ b/wpa_supplicant/Makefile
@@ -757,6 +757,17 @@ LIBS += $(DBUS_LIBS)
 ifndef DBUS_INCLUDE
 DBUS_INCLUDE := $(shell pkg-config --cflags dbus-1)
 endif
+dbus_version=$(subst ., ,$(shell pkg-config --modversion dbus-1))
+DBUS_VERSION_MAJOR=$(word 1,$(dbus_version))
+DBUS_VERSION_MINOR=$(word 2,$(dbus_version))
+ifeq ($(DBUS_VERSION_MAJOR),)
+DBUS_VERSION_MAJOR=0
+endif
+ifeq ($(DBUS_VERSION_MINOR),)
+DBUS_VERSION_MINOR=0
+endif
+DBUS_INCLUDE += -DDBUS_VERSION_MAJOR=$(DBUS_VERSION_MAJOR)
+DBUS_INCLUDE += -DDBUS_VERSION_MINOR=$(DBUS_VERSION_MINOR)
 CFLAGS += $(DBUS_INCLUDE)
 endif

diff --git a/wpa_supplicant/ctrl_iface_dbus.c b/wpa_supplicant/ctrl_iface_dbus.c
index 4f20d1e..7957e24 100644
--- a/wpa_supplicant/ctrl_iface_dbus.c
+++ b/wpa_supplicant/ctrl_iface_dbus.c
@@ -83,7 +83,11 @@ static void connection_setup_add_watch(struct ctrl_iface_dbus_priv *iface,
                return;

        flags = dbus_watch_get_flags(watch);
+#if (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MAJOR >= 1) || (DBUS_VERSION_MAJOR > 1)
+       fd = dbus_watch_get_unix_fd(watch);
+#else
        fd = dbus_watch_get_fd(watch);
+#endif

        eloop_register_sock(fd, EVENT_TYPE_EXCEPTION, process_watch_exception,
                            iface, watch);
@@ -108,7 +112,11 @@ static void connection_setup_remove_watch(struct ctrl_iface_dbus_priv *iface,
        int fd;

        flags = dbus_watch_get_flags(watch);
+#if (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MAJOR >= 1) || (DBUS_VERSION_MAJOR > 1)
+       fd = dbus_watch_get_unix_fd(watch);
+#else
        fd = dbus_watch_get_fd(watch);
+#endif

        eloop_unregister_sock(fd, EVENT_TYPE_EXCEPTION);





More information about the Hostap mailing list