On Mon, 20 Jun 2011, Hendrik Sattler wrote: > > <openobex/obex.h> file, the following: > > > > #if !defined(bt_addr_t) > > # if defined(SOL_RFCOMM) > > # if defined(_WIN32) /* Windows */ > > # define bt_addr_t BTH_ADDR > > # else /* Linux, FreeBSD, NetBSD */ > > # define bt_addr_t bdaddr_t > > # endif > > # else /* no bluetooth stack available */ > > # define bt_addr_t unsigned long > > # endif > > #endif > > > > does not actually work since SOL_RFCOMM is never defined on BSD at least > > (we just use the BTPROTO_RFCOMM value instead), and on BlueZ/Linux it is > > only defined where <bluetooth/bluetooth.h> is included prior (otherwise > > the problem is masked, by using unsigned long) > > That is exactly the intended behaviour. If you want to use the bluetooth > functions, you must include the proper bluetooth headers, see > lib/bluez_compat.h.
Trouble is, the prototypes exist no matter if the bluetooth support is wanted, and detecting the type of bdaddr_t according to OS does not necessarily mean that the bdaddr_t type is defined.. For example, on NetBSD bt_addr_t will be set to bdaddr_t which is correct, except that if you are writing an obex program that wants to use TcpOBEX routines only then the compilation will fail because you didn't include the bluetooth header and bdaddr_t is an unknown type.. Looking at it further, the following would seem to be a more reliable way to detect if the type has been declared 1. Windows BTH_ADDR_NULL is defined in <wga/bluetooth/bthdef.h>, included from <ws2bth.h> 2. FreeBSD NG_HCI_BDADDR_ANY is defined in <netgraph/bluetooth/include/ng_hci.h>, included from <bluetooth.h> 3. NetBSD (including DragonflyBSD, OpenBSD & OpenSolaris) BDADDR_ANY defined in <netbt/bluetooth.h>, included from <bluetooth.h> 4. BlueZ/Linux BDADDR_ANY defined in <bluetooth/bluetooth.h> all near the appropriate type declaration.. ? iain diff --git a/include/openobex/obex.h b/include/openobex/obex.h index f948113..0d7b917 100644 --- a/include/openobex/obex.h +++ b/include/openobex/obex.h @@ -131,18 +131,19 @@ OPENOBEX_SYMBOL(int) IrOBEX_TransportConnect(obex_t *self, const char *service); * Bluetooth OBEX API */ #if !defined(bt_addr_t) -# if defined(SOL_RFCOMM) -# if defined(_WIN32) /* Windows */ -# define bt_addr_t BTH_ADDR -# else /* Linux, FreeBSD, NetBSD */ -# define bt_addr_t bdaddr_t -# endif -# else /* no bluetooth stack available */ -# define bt_addr_t unsigned long +# if defined(BTH_ADDR_NULL) /* Windows */ +# define bt_addr_t BTH_ADDR +# elif defined(NG_HCI_BDADDR_ANY) /* FreeBSD */ +# define bt_addr_t bdaddr_t +# elif defined(BDADDR_ANY) /* BlueZ, NetBSD, etc.. */ +# define bt_addr_t bdaddr_t # endif #endif -OPENOBEX_SYMBOL(int) BtOBEX_ServerRegister(obex_t *self, bt_addr_t *src, uint8_t channel); -OPENOBEX_SYMBOL(int) BtOBEX_TransportConnect(obex_t *self, bt_addr_t *src, bt_addr_t *dst, uint8_t channel); + +#if defined(bt_addr_t) +OPENOBEX_SYMBOL(int) BtOBEX_ServerRegister(obex_t *self, const bt_addr_t *src, uint8_t channel); +OPENOBEX_SYMBOL(int) BtOBEX_TransportConnect(obex_t *self, const bt_addr_t *src, const bt_addr_t *dst, uint8_t channel); +#endif /* * OBEX File API diff --git a/lib/obex.c b/lib/obex.c index 165fcb8..874cfcd 100644 --- a/lib/obex.c +++ b/lib/obex.c @@ -1058,7 +1058,7 @@ int CALLAPI IrOBEX_TransportConnect(obex_t *self, const char *service) An easier server function to use for Bluetooth (Bluetooth OBEX) only. */ LIB_SYMBOL -int CALLAPI BtOBEX_ServerRegister(obex_t *self, bdaddr_t *src, uint8_t channel) +int CALLAPI BtOBEX_ServerRegister(obex_t *self, const bt_addr_t *src, uint8_t channel) { DEBUG(3, "\n"); @@ -1085,8 +1085,8 @@ int CALLAPI BtOBEX_ServerRegister(obex_t *self, bdaddr_t *src, uint8_t channel) An easier connect function to use for Bluetooth (Bluetooth OBEX) only. */ LIB_SYMBOL -int CALLAPI BtOBEX_TransportConnect(obex_t *self, bdaddr_t *src, - bdaddr_t *dst, uint8_t channel) +int CALLAPI BtOBEX_TransportConnect(obex_t *self, const bt_addr_t *src, + const bt_addr_t *dst, uint8_t channel) { DEBUG(4, "\n"); ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ Openobex-users mailing list Openobex-users@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/openobex-users